2010-06-17 Zoltan Varga <vargaz@gmail.com>
[mono.git] / CMakeLists.txt
blobf2f2089f386f44bc72cfab7ec4344a3e5b76de6c
1 cmake_minimum_required(VERSION 2.6.4)
3 # To keep this in sync with the autoconf based system:
4 # git log -n --format=oneline CMakeLists.txt
5 # git diff <commit displayed by previous line>..HEAD configure.in Makefile.am
7 # FIXME: Sanitize the variables, no need for the duplicate am conditionals
8 # - It would be nice to rename 'CMakeFiles' to something like '.cmake'
9 # - It would be nice to have a per-target VERBOSE setting
10 # - or a way to change the setting name to 'V' and the output to CC <src>
11 #   to be similar to the current build output
12 # - Add a cache to the manual checks
14 # We use lowercase commands as advocated by the kde cmake coding style
16 include(CheckIncludeFile)
17 include(CheckCSourceCompiles)
19 # Implementation of AC_CHECK_HEADERS
20 # In addition, it also records the list of variables in the variable 
21 # 'autoheader_vars', and for each variable, a documentation string in the
22 # variable ${var}_doc
23 function(ac_check_headers headers)
24   foreach (header ${ARGV})
25         string(TOUPPER ${header} header_var)
26         string(REPLACE "." "_" header_var ${header_var})
27         string(REPLACE "/" "_" header_var ${header_var})
28         set(header_var "HAVE_${header_var}")
29         check_include_file (${header} ${header_var})
30         set("${header_var}_doc" "Define to 1 if you have the <${header}> header file." PARENT_SCOPE)
31         if (${header_var})
32           set("${header_var}_defined" "1" PARENT_SCOPE)
33         endif()
34         set("${header_var}_val" "1" PARENT_SCOPE)
35         set (autoheader_vars ${autoheader_vars} ${header_var})
36   endforeach()
37   set (autoheader_vars ${autoheader_vars} PARENT_SCOPE)
38 endfunction()
40 function(ac_check_funcs funcs)
41   foreach (func ${ARGV})
42         string(TOUPPER ${func} var)
43         set(var "HAVE_${var}")
44         set(${var})
45         check_function_exists (${func} ${var})
46         set("${var}_doc" "Define to 1 if you have the '${func}' function." PARENT_SCOPE)
47         if (${var})
48           set("${var}_defined" "1" PARENT_SCOPE)
49           set(${var} yes PARENT_SCOPE)
50         endif()
51         set("${var}_val" "1" PARENT_SCOPE)
52         set (autoheader_vars ${autoheader_vars} ${var})
53   endforeach()
54   set (autoheader_vars ${autoheader_vars} PARENT_SCOPE)
55 endfunction()
57 # Implementation of AC_DEFINE
58 function(ac_define varname value doc)
59   if (${varname} MATCHES ",")
60         message(FATAL_ERROR ",")
61   endif()
62   set("${varname}_doc" ${doc} PARENT_SCOPE)
63   set("${varname}_defined" 1 PARENT_SCOPE)
64   set("${varname}_val" ${value} PARENT_SCOPE)
65   set (autoheader_vars ${autoheader_vars} ${varname} PARENT_SCOPE)
66 endfunction()
68 # Implementation of AC_DEFINE_UNQUOTED
69 function(ac_define_unquoted varname value doc)
70   if (${varname} MATCHES ",")
71         message(FATAL_ERROR ",")
72   endif()
73   set("${varname}_doc" ${doc} PARENT_SCOPE)
74   set("${varname}_defined" 1 PARENT_SCOPE)
75   set("${varname}_val" \"${value}\" PARENT_SCOPE)
76   set (autoheader_vars ${autoheader_vars} ${varname} PARENT_SCOPE)
77 endfunction()
79 Include(CheckTypeSize)
81 # Implementation of AC_CHECK_SIZEOF
82 # FIXME: cross compiling
83 function(ac_check_sizeof type)
84   check_type_size(${type} size)
85   if (HAVE_size STREQUAL "TRUE")
86   else()
87         message(FATAL_ERROR "Type ${type} not found.")
88   endif()
89   string(TOUPPER "SIZEOF_${type}" varname)
90   string(REPLACE " " "_" varname ${varname})
91   string(REPLACE "*" "P" varname ${varname})
93   set("${varname}_doc" "The size of '${type}' as computed by sizeof" PARENT_SCOPE)
94   set("${varname}_defined" 1 PARENT_SCOPE)
95   set("${varname}_val" ${size} PARENT_SCOPE)
96   set (autoheader_vars ${autoheader_vars} ${varname} PARENT_SCOPE)
97 endfunction()
99 # Implementation of autoheader
100 function(AUTOHEADER filename variables)
101   set(tmp_filename "${filename}.tmp")
102   file(WRITE ${tmp_filename} "")
103   foreach(var ${${variables}})
104         file(APPEND ${tmp_filename} "\n/* ${${var}_doc} */\n")
105         if(${${var}_defined})
106           file(APPEND ${tmp_filename} "#define ${var} ${${var}_val}\n")
107         else()
108           file(APPEND ${tmp_filename} "/* #undef ${var} */\n")
109         endif()
110   endforeach()
111   # FIXME: This is unix specific
112   execute_process(COMMAND diff ${filename} ${filename}.tmp RESULT_VARIABLE diff_res OUTPUT_QUIET)
113   if (NOT diff_res STREQUAL 0)
114         message(STATUS "generating ${filename}.")
115         execute_process(COMMAND mv ${filename}.tmp ${filename})
116   else()
117         message(STATUS "${filename} is unchanged.")
118   endif()
119 endfunction()
121 function(ac_msg_checking)
122   message(STATUS "checking ${ARGV}...")
123   set(last_msg_checking ${ARGV} PARENT_SCOPE)
124 endfunction()
126 function(ac_msg_result)
127   message(STATUS "checking ${last_msg_checking}... ${ARGV}")
128 endfunction()
130 function(ac_msg_error)
131   message(FATAL_ERROR "${ARGV}")
132 endfunction()
134 function(ac_msg_warn)
135   message(STATUS "WARNING: ${ARGV}")
136 endfunction()
138 # The lines commented out using ### are the stuff from configure.in which still 
139 # need to be ported to cmake
141 set(VERSION 2.7)
142 ac_define_unquoted(VERSION ${VERSION} "Version number of package")
143 set(API_VER 1.0)
145 ###AC_PROG_LN_S
147 #### In case of cygwin, override LN_S, irrespective of what it determines.
148 #### The build uses cygwin, but the actual runtime doesn't.
149 ###case $host_os in
150 ###*cygwin* ) set(LN_S 'cp -p';;)
151 ###esac
156 # These variables are the CPPFLAGS/CFLAGS passed to libgc's configure
157 # libgc should inherit the original CFLAGS/CPPFLAGS passed to configure, i.e. -O0
159 set(CPPFLAGS_FOR_LIBGC ${CPPFLAGS})
160 set(CFLAGS_FOR_LIBGC ${CFLAGS})
163 # These are the flags that need to be stored in the mono.pc file for 
164 # compiling code that will embed Mono
166 set(libmono_cflags "")
167 set(libmono_ldflags "")
169 ###AC_SUBST(libmono_cflags)
170 ###AC_SUBST(libmono_ldflags)
172 #### Variable to have relocatable .pc files (lib, or lib64)
173 ###set(reloc_libdir `basename ${libdir}`)
174 ###AC_SUBST(reloc_libdir)
176 # if linker handles the version script
177 set(no_version_script no)
179 # Set to yes if Unix sockets cannot be created in an anonymous namespace
180 set(need_link_unlink no)
183 # Platform support
186 # Obtain the GNU style target
187 # From GetTargetTriple.cmake in LLVM
188 function( get_target_triple var )
189   if( MSVC )
190     set( ${var} "i686-pc-win32" PARENT_SCOPE )
191   else( MSVC )
192     set(config_guess config.guess)
193     execute_process(COMMAND sh ${config_guess}
194       RESULT_VARIABLE TT_RV
195       OUTPUT_VARIABLE TT_OUT
196       OUTPUT_STRIP_TRAILING_WHITESPACE)
197     if( NOT TT_RV EQUAL 0 )
198       message(FATAL_ERROR "Failed to execute ${config_guess}")
199     endif( NOT TT_RV EQUAL 0 )
200     set( ${var} ${TT_OUT} PARENT_SCOPE )
201   endif( MSVC )
202 endfunction( get_target_triple var )
204 get_target_triple(host)
206 message(STATUS "checking host platform characteristics...")
208 set(libgc_threads no)
209 set(has_dtrace no)
210 set(parallel_mark yes)
212 if(host MATCHES .*-.*-linux.*)
213   set(platform_win32 no)
214   set(CPPFLAGS "${CPPFLAGS} -DHAVE_CONFIG_H -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP -DUSE_MUNMAP")
215   set(libmono_cflags "-D_REENTRANT")
216   set(libmono_ldflags "-lpthread")
217   set(libdl "-ldl")
218   set(libgc_threads pthreads)
219   set(AOT_SUPPORTED "yes")
220   set(use_sigposix yes)
221 else()
222   message(FATAL_ERROR "The cmake build doesn't yet support host '${host}'.")
223 endif()
225 #### Thread configuration inspired by sleepycat's db
226 ###case "$host" in
227 ###     *-*-mingw*|*-*-cygwin*)
228 ###             set(platform_win32 yes)
229 ###             AC_DEFINE(PLATFORM_WIN32,1,[Host Platform is Win32])
230 ###             AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32])
231 ###             ac_define(DISABLE_PORTABILITY,1,[Disable the io-portability layer])
232 ###             ac_define(PLATFORM_NO_SYMLINKS,1,[This platform does not support symlinks])
233 ###             if test "x$cross_compiling" = "xno"; then
234 ###                     set(CC "gcc -mno-cygwin -g")
235 ###                     # So libgc configure gets -mno-cygwin
236 ###                     export CC
237 ###             fi
238 ###             set(HOST_CC "gcc")
239 ###             # Windows 2000 is required that includes Internet Explorer 5.01
240 ###             set(CPPFLAGS "$CPPFLAGS -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0501 -D_UNICODE -DUNICODE -DWIN32_THREADS -DFD_SETSIZE=1024")
241 ###             set(libmono_cflags "-mno-cygwin -mms-bitfields -mwindows")
242 ###             set(libmono_ldflags "-mno-cygwin -mms-bitfields -mwindows")
243 ###             set(libdl )
244 ###             set(libgc_threads win32)
245 ###             set(gc_default included)
246 ###             set(with_sigaltstack no)
247 ###             set(LN_S cp)
248 ###             # This forces libgc to use the DllMain based thread registration code on win32
249 ###             set(libgc_configure_args "$libgc_configure_args --enable-win32-dllmain=yes")
250 ###             ;;
251 ###     *-*-*netbsd*)
252 ###             set(platform_win32 no)
253 ###             set(CPPFLAGS "$CPPFLAGS -D_REENTRANT -DGC_NETBSD_THREADS -D_GNU_SOURCE")
254 ###             set(libmono_cflags "-D_REENTRANT")
255 ###             set(LDFLAGS "$LDFLAGS -pthread")
256 ###             set(CPPFLAGS "$CPPFLAGS -DPLATFORM_BSD")
257 ###             set(libmono_ldflags "-pthread")
258 ###             set(need_link_unlink yes)
259 ###             set(libdl "-ldl")
260 ###             set(libgc_threads pthreads)
261 ###             set(with_sigaltstack no)
262 ###             set(use_sigposix yes)
263 ###             ;;
264 ###     *-*-*freebsd*)
265 ###             set(platform_win32 no)
266 ###             if test "x$PTHREAD_CFLAGS" = "x"; then
267 ###                     set(CPPFLAGS "$CPPFLAGS -DGC_FREEBSD_THREADS")
268 ###                     set(libmono_cflags )
269 ###             else
270 ###                     set(CPPFLAGS "$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS")
271 ###                     set(libmono_cflags "$PTHREAD_CFLAGS")
272 ###             fi
273 ###             if test "x$PTHREAD_LIBS" = "x"; then
274 ###                     set(LDFLAGS "$LDFLAGS -pthread")
275 ###                     set(libmono_ldflags "-pthread")
276 ###             else
277 ###                     set(LDFLAGS "$LDFLAGS $PTHREAD_LIBS")
278 ###                     set(libmono_ldflags "$PTHREAD_LIBS")
279 ###             fi
280 ###             set(CPPFLAGS "$CPPFLAGS -DPLATFORM_BSD")
281 ###             set(need_link_unlink yes)
282 ###             ac_define(PTHREAD_POINTER_ID, 1, [pthread is a pointer])
283 ###             set(libdl )
284 ###             set(libgc_threads pthreads)
285 ###             # This doesn't seem to work as of 7.0 on amd64
286 ###             set(with_sigaltstack no)
287 #### TLS is only partially implemented on -CURRENT (compiler support
288 #### but NOT library support)
289 ####
290 ###             set(with_tls pthread)
291 ###             set(use_sigposix yes)
292 ###             ;;
293 ###     *-*-*openbsd*)
294 ###             set(platform_win32 no)
295 ###             set(CPPFLAGS "$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS -DPLATFORM_BSD")
296 ###             set(libmono_cflags "-D_THREAD_SAFE")
297 ###             set(LDFLAGS "$LDFLAGS -pthread")
298 ###             set(libmono_ldflags "-pthread")
299 ###             set(need_link_unlink yes)
300 ###             ac_define(PTHREAD_POINTER_ID)
301 ###             set(libdl )
302 ###             set(libgc_threads pthreads)
303 ###             set(use_sigposix yes)
304 ###             ;;
305 ###     *-*-linux*)
306 ###             set(platform_win32 no)
307 ###             set(CPPFLAGS "$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP -DUSE_MUNMAP")
308 ###             set(libmono_cflags "-D_REENTRANT")
309 ###             set(libmono_ldflags "-lpthread")
310 ###             set(libdl "-ldl")
311 ###             set(libgc_threads pthreads)
312 ###             set(AOT_SUPPORTED "yes")
313 ###             set(use_sigposix yes)
314 ###             ;;
315 ###     *-*-hpux*)
316 ###             set(platform_win32 no)
317 ###             set(CPPFLAGS "$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT")
318 ###             # +ESdbgasm only valid on bundled cc on RISC
319 ###             # silently ignored for ia64
320 ###             if test $GCC != "yes"; then
321 ###                     set(CFLAGS "$CFLAGS +ESdbgasm")
322 ###                     # Arrange for run-time dereferencing of null
323 ###                     # pointers to produce a SIGSEGV signal.
324 ###                     set(LDFLAGS "$LDFLAGS -z")
325 ###             fi
326 ###             set(CFLAGS "$CFLAGS +ESdbgasm")
327 ###             set(LDFLAGS "$LDFLAGS -z")
328 ###             set(libmono_cflags "-D_REENTRANT")
329 ###             set(libmono_ldflags "-lpthread")
330 ###             set(libgc_threads pthreads)
331 ###             set(need_link_unlink yes)
332 ###             set(use_sigposix yes)
333 ###             ;;
334 ###     *-*-solaris*)
335 ###             set(platform_win32 no)
336 ###             set(CPPFLAGS "$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP -DPLATFORM_SOLARIS")
337 ###             set(need_link_unlink yes)
338 ###             set(libmono_cflags "-D_REENTRANT")
339 ###             set(libgc_threads pthreads)
340 ###             # This doesn't seem to work on solaris/x86, but the configure test runs
341 ###             set(with_tls pthread)
342 ###             set(has_dtrace yes)
343 ###             set(use_sigposix yes)
344 ###             ;;
345 ###     *-*-darwin*)
346 ###             set(parallel_mark "Disabled_Currently_Hangs_On_MacOSX")
347 ###             set(platform_win32 no)
348 ###             set(platform_darwin yes)
349 ###             set(CPPFLAGS "$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE -DGC_MACOSX_THREADS -DPLATFORM_MACOSX -DUSE_MMAP -DUSE_MUNMAP")
350 ###             set(CPPFLAGS "$CPPFLAGS -DGetCurrentProcess=MonoGetCurrentProcess -DGetCurrentThread=MonoGetCurrentThread -DCreateEvent=MonoCreateEvent")
351 ###             set(libmono_cflags "-D_THREAD_SAFE")
352 ###             set(LDFLAGS "$LDFLAGS -pthread")
353 ###             set(libmono_ldflags "-pthread")
354 ###             set(need_link_unlink yes)
355 ###             ac_define(PTHREAD_POINTER_ID)
356 ###             ac_define(USE_MACH_SEMA, 1, [...])
357 ###             set(no_version_script yes)
358 ###             set(libdl )
359 ###             set(libgc_threads pthreads)
360 ###             set(has_dtrace yes)
361 ###             if test "x$cross_compiling" = "xyes"; then
362 ###                     set(has_broken_apple_cpp yes)
363 ###             fi
364 ###             ;;
365 ###     *)
366 ###             AC_MSG_WARN([*** Please add $host to configure.in checks!])
367 ###             set(platform_win32 no)
368 ###             set(libdl "-ldl")
369 ###             ;;
370 ###esac
371 ###AC_MSG_RESULT(ok)
373 ###if test x$need_link_unlink = xyes; then
374 ###   ac_define(NEED_LINK_UNLINK, 1, [Define if Unix sockets cannot be created in an anonymous namespace])
375 ###fi
378 if(use_sigposix)
379   set(PLATFORM_SIGPOSIX 1)
380 endif()
381 if(platform_win32)
382   set(HOST_WIN32 yes)
383   set(TARGET_WIN32 yes)
384 endif()
385 if(${target_os} MATCHES "*linux*")
386   set(PLATFORM_LINUX yes)
387 endif()
388 if(platform_darwin)
389   set(PLATFORM_DARWIN yes)
390 endif()
392 include(CMakeDetermineASM-ATTCompiler)
394 find_program(BISON NAMES bison)
396 if(BISON STREQUAL "BISON-NOTFOUND")
397   message(FATAL_ERROR "You need to install bison")
398 else()
399   message(STATUS "Found bison: ${BISON}")
400 endif()
402 ###AC_PROG_INSTALL
403 ###AC_PROG_AWK
404 #### We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
405 ###: ${set(CCAS '$(CC)'})
406 #### Set ASFLAGS if not already set.
407 ###: ${set(CCASFLAGS '$(CFLAGS)'})
408 ###AC_SUBST(CCAS)
409 ###AC_SUBST(CCASFLAGS)
411 #### may require a specific autoconf version
412 #### AC_PROG_CC_FOR_BUILD
413 #### CC_FOR_BUILD not automatically detected
414 ###set(CC_FOR_BUILD $CC)
415 ###set(CFLAGS_FOR_BUILD $CFLAGS)
416 ###set(BUILD_EXEEXT )
417 ###if test "x$cross_compiling" = "xyes"; then
418 ###     set(CC_FOR_BUILD cc)
419 ###     set(CFLAGS_FOR_BUILD )
420 ###     set(BUILD_EXEEXT "")
421 ###fi
422 ###AC_SUBST(CC_FOR_BUILD)
423 ###AC_SUBST(CFLAGS_FOR_BUILD)
424 ###AC_SUBST(HOST_CC)
425 ###AC_SUBST(BUILD_EXEEXT)
427 ###AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
428 ###AM_CONDITIONAL(USE_BATCH_FILES, [test x$platform_win32 = xyes -a x$cross_compiling = xyes])
430 #### Set STDC_HEADERS
431 ###AC_HEADER_STDC
432 ###AC_LIBTOOL_WIN32_DLL
433 #### This causes monodis to not link correctly
434 ####AC_DISABLE_FAST_INSTALL
435 ###set(export_ldflags `(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`)
436 ###AC_SUBST(export_ldflags)
438 #### Test whenever ld supports -version-script
439 ###AC_PROG_LD
440 ###AC_PROG_LD_GNU
441 ###if test "x$lt_cv_prog_gnu_ld" = "xno"; then
442 ###   set(no_version_script yes)
443 ###fi
445 ###AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
448 ac_check_headers(unistd.h stdint.h sys/types.h)
449 ac_check_headers(sys/filio.h sys/sockio.h netdb.h utime.h sys/utime.h semaphore.h sys/un.h linux/rtc.h sys/syscall.h sys/mkdev.h)
450 ac_check_headers(sys/user.h sys/socket.h sys/ipc.h sys/sem.h sys/utsname.h alloca.h ucontext.h pwd.h)
452 ac_check_headers(zlib.h)
453 set(have_zlib ${HAVE_ZLIB_H})
454 if(have_zlib)
455   set(compiles)
456   check_c_source_compiles("
457 #include <zlib.h>
458 void main () {
459 #if defined(ZLIB_VERNUM) && (ZLIB_VERNUM >= 0x1230)
461 #else
462 #error No good zlib found
463 #endif
464 " compiles)
465   if(compiles)
466         ac_msg_result("Using system zlib")
467         set(zlib_msg "system zlib")
468   set(HAVE_ZLIB yes)
469   else()
470         ac_msg_result("Using embedded zlib")
471         set(have_zlib no)
472         set(zlib_msg "bundled zlib")
473   endif()
474 endif()
476 if(have_zlib)
477   set(HAVE_ZLIB yes)
478 endif()
479 ac_define(HAVE_ZLIB 1 "Have system zlib")
481 # for mono/metadata/debug-symfile.c
482 ac_check_headers(elf.h)
484 # for support
485 ac_check_headers(poll.h)
486 ac_check_headers(sys/poll.h)
487 ac_check_headers(sys/wait.h)
488 ac_check_headers(grp.h)
489 ac_check_headers(syslog.h)
491 # for mono/dis
492 ac_check_headers(wchar.h)
493 ac_check_headers(ieeefp.h)
495 # Check whenever using GCC
496 include(CheckCSourceCompiles)
497 include(CheckCCompilerFlag)
498 check_c_source_compiles("
499 #ifdef __GNUC__
500 #else
501 #error 1
502 #endif
503 void main () {}
504 " GCC)
506 if(NOT HAVE_ISINF)
507   ac_msg_checking("for isinf")
508   set(compiles)
509   check_c_source_compiles("
510 #include <math.h>
511 void main () {
512 int f = isinf (1);
514 " compiles)
515   if(compiles)
516         ac_msg_result(yes)
517         ac_define(HAVE_ISINF 1 "isinf available")
518         set(HAVE_ISINF 1 CACHE BOOL "Have the isinf function")
519   else()
520         ac_msg_result(no)
521   endif()
522 endif()
524 # not 64 bit clean in cross-compile
525 ac_check_sizeof("void *" 4)
527 set(WARN '')
529 if(GCC)
530   set(WARN "-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wwrite-strings")
531   # The runtime code does not respect ANSI C strict aliasing rules
532   set(CFLAGS "${CFLAGS} -fno-strict-aliasing")
533   CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement" HAS_WDECL_AFTER_STATEMENT)
534   if(HAS_WDECL_AFTER_STATEMENT)
535         set(WARN "${WARN} -Wdeclaration-after-statement")
536   endif()
537 else()
538         # The Sun Forte compiler complains about inline functions that access static variables
539         # so disable all inlining.
540 ###     case "$host" in
541 ###     *-*-solaris*)
542 ###             set(CFLAGS "$CFLAGS -Dinline=")
543 ###             ;;
544 ###     esac
545 ###fi
546 endif()
548 set(CFLAGS "${CFLAGS} -g ${WARN}")
550 ###set(CFLAGS_FOR_LIBGC "$CFLAGS_FOR_LIBGC -g")
553 set(srcdir ${CMAKE_SOURCE_DIR})
554 set(top_srcdir ${CMAKE_SOURCE_DIR})
555 set(abs_top_srcdir ${top_srcdir})
557 # FIXME:
558 set(top_builddir ${CMAKE_BINARY_DIR})
560 # Where's the 'mcs' source tree?
561 if(EXISTS ${srcdir}/mcs)
562   set(mcsdir mcs)
563 else()
564   set(mcsdir ../mcs)
565 endif()
568 # A sanity check to catch cases where the package was unpacked
569 # with an ancient tar program (Solaris)
571 set(solaris-tar-check yes CACHE BOOL "Enable/disable solaris tar check")
573 if(solaris-tar-check)
574   ac_msg_checking("integrity of package")
575   if(EXISTS ${srcdir}/${mcsdir}/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapTypeMapper.cs)
576         ac_msg_result(ok)
577   else()
578         set(errorm "Your mono distribution is incomplete;  if unpacking from a tar file, make sure you use GNU tar;  see http://www.mono-project.com/IncompletePackage for more details")
579         ac_msg_error(${errorm})
580   endif()
581 endif()
583 set(mcs_topdir ${top_srcdir}/${mcsdir})
584 set(mcs_topdir_from_srcdir ${top_builddir}/${mcsdir})
586 ##### Maybe should also disable if mcsdir is invalid.  Let's punt the issue for now.
587 ###AM_CONDITIONAL(BUILD_MCS, [test x$cross_compiling = xno && test x$enable_mcs_build != xno])
589 ###AC_SUBST([mcs_topdir])
590 ###AC_SUBST([mcs_topdir_from_srcdir])
592 #### Where's the 'olive' source tree?
593 ###if test -d $srcdir/olive; then
594 ###  set(olivedir olive)
595 ###else
596 ###  set(olivedir ../olive)
597 ###fi
599 ###if test -d $srcdir/$olivedir; then
600 ###set(olive_topdir '$(top_srcdir)/'$olivedir)
601 ###fi
603 #### gettext: prepare the translation directories. 
604 #### we do not configure the full gettext, as we consume it dynamically from C#
605 ###AM_PO_SUBDIRS
607 ###if test "x$USE_NLS" = "xyes"; then
608 ###   AC_CHECK_PROG(HAVE_MSGFMT, msgfmt,yes,no)
610 ###   if test "x$HAVE_MSGFMT" = "xno"; then
611 ###       ac_msg_error([msgfmt not found. You need to install the 'gettext' package, or pass --enable-set(nls no to configure.]))
612 ###   fi
613 ###fi
615 set(libgdiplus installed CACHE STRING "=installed|sibling|<path> Override the libgdiplus used for System.Drawing tests (defaults to installed)")
616 set(with_libgdiplus ${libgdiplus})
618 ###case $with_libgdiplus in
619 ###no|installed) set(libgdiplus_loc  ;;)
620 ###yes|sibling) set(libgdiplus_loc `cd ../libgdiplus && pwd`/src/libgdiplus.la ;;)
621 ###/*) set(libgdiplus_loc $with_libgdiplus ;;)
622 ###*) set(libgdiplus_loc `pwd`/$with_libgdiplus ;;)
623 ###esac
624 ###AC_SUBST([libgdiplus_loc])
627 ###set(pkg_config_path )
628 ###set(crosspkgdir, [  --with-set(crosspkgdir /path/to/pkg-config/dir      Change pkg-config dir to custom dir],)
629 ###     if test x$with_crosspkgdir = "x"; then
630 ###             if test -s $PKG_CONFIG_PATH; then
631 ###                     set(pkg_config_path $PKG_CONFIG_PATH)
632 ###             fi
633 ###     else
634 ###             set(pkg_config_path $with_crosspkgdir)
635 ###             set(PKG_CONFIG_PATH $pkg_config_path)
636 ###             export PKG_CONFIG_PATH
637 ###     fi
638 ###)
640 ###set([glib],
641 ###     [  --with-set(glib embedded|system    Choose glib API: system or embedded (default to system)],)
642 ###     [], [set(with_glib system]))
644 ###set(eglib_dir )
647 include(FindPkgConfig)
649 # FIXME:
650 set(with_glib "system")
651 if (${with_glib} STREQUAL "system")
652   ###  if test "x$cross_compiling" = "xyes"; then
653   ###    set(pkg_config_path "$PKG_CONFIG_PATH")
654   ###    unset PKG_CONFIG_PATH
655   ###  fi
656   PKG_CHECK_MODULES(GLIB2 REQUIRED glib-2.0 gthread-2.0)
657   set(BUILD_GLIB_CFLAGS ${GLIB2_CFLAGS})
658   set(BUILD_GLIB_LIBS ${GLIB2_LIBRARIES})
660   ###  if test "x$cross_compiling" = "xyes"; then
661   ###    set(PKG_CONFIG_PATH $pkg_config_path)
662   ###    export PKG_CONFIG_PATH
663   ###  fi
664   ###  
665   ## Versions of dependencies
666   set(GLIB_REQUIRED_VERSION 2.4.0)
668   PKG_CHECK_MODULES(GLIB2 REQUIRED glib-2.0 >= ${GLIB_REQUIRED_VERSION} gthread-2.0)
669   set(GLIB_CFLAGS ${GLIB2_CFLAGS})
670   set(GLIB_LIBS ${GLIB2_LIBRARIES})
671   PKG_CHECK_MODULES(GMODULE REQUIRED gmodule-2.0)
672   set(GMODULE_CFLAGS ${GMODULE_CFLAGS})
673   set(GMODULE_LIBS ${GMODULE_LIBRARIES})
674 endif()
676 ###case $with_glib in
677 ###embedded) 
678 ###  set(GLIB_CFLAGS '-I$(top_srcdir)/eglib/src -I$(top_builddir)/eglib/src')
679 ###  set(GLIB_LIBS '-L$(top_builddir)/eglib/src -leglib -lm')
680 ###  set(BUILD_GLIB_CFLAGS "$GLIB_CFLAGS")
681 ###  set(BUILD_GLIB_LIBS "$GLIB_LIBS")
682 ###  set(GMODULE_CFLAGS "$GLIB_CFLAGS")
683 ###  set(GMODULE_LIBS "$GLIB_LIBS")
684 ###  set(eglib_dir eglib)
685 ###  AC_CONFIG_SUBDIRS(eglib)
686 ###  ;;
687 ###*)
688 ###  ac_msg_error([Invalid argument to --with-glib.])
689 ###esac
690 if(with_glib STREQUAL "embedded")
691   set(EGLIB_BUILD yes)
692 endif()
693 ###  
694 ###AC_SUBST(GLIB_CFLAGS)
695 ###AC_SUBST(GLIB_LIBS)
696 ###AC_SUBST(GMODULE_CFLAGS)
697 ###AC_SUBST(GMODULE_LIBS)
698 ###AC_SUBST(BUILD_GLIB_CFLAGS)
699 ###AC_SUBST(BUILD_GLIB_LIBS)
700 ###AC_SUBST(eglib_dir)
702 ###if test x$cross_compiling$platform_win32 = xnoyes; then
703 ###   ac_msg_checking(for cygwin glib2-dev package)
704 ###   if [ cygcheck --f /usr/lib/libglib-2.0.dll.a | grep -q glib2-devel ]; then
705 ###      ac_msg_result(found)
706 ###       ac_msg_error([Mono cannot be built with the cygwin glib2-devel package installed, because that package doesn't work with -mno-cygwin. Please uninstall it then re-run configure.])
707 ###   else
708 ###      ac_msg_result(not found, ok)
709 ###   fi
711 ###   ac_msg_checking(for broken gwin32.h)
712 ###   set(glib_include `$PKG_CONFIG --cflags-only-I glib-2.0 | sed -e 's/ -I.*//g' | sed -e 's/-I//g'`)
713 ###   if test -f $glib_include/glib/gwin32.h; then
714 ###       if [ grep ftruncate $glib_include/glib/gwin32.h | grep -q define ]; then
715 ###              ac_msg_result(failed)
716 ###              set(hashmark '#')
717 ###              ac_msg_error([Your version of gwin32.h is broken and will cause compilation errors when building mono. Please fix it by deleting the line: '$hashmark   define ftruncate...' from '$glib_include/glib/gwin32.h' then re-run configure.])
718 ###       fi
719 ###   fi
720 ###   ac_msg_result(ok)
721 ###fi
723 # Enable support for fast thread-local storage
724 # Some systems have broken support, so we allow to disable it.
725 set(tls __thread CACHE STRING "Select Thread Local Storage implementation. Possible values are '__thread_' and 'pthread' (defaults to __thread)")
726 set(with_tls ${tls})
728 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
729 # This does not work on some platforms (bug #55253)
730 set(sigaltstack yes CACHE BOOL "Enable/disable support for sigaltstack (defaults to yes)")
731 set(with_sigaltstack ${sigaltstack})
733 set(static_mono yes CACHE BOOL "Link mono statically to libmono (faster) (defaults to yes)")
734 set(with_static_mono ${static_mono})
736 ###if test "x$enable_static" = "xno"; then
737 ###   set(with_static_mono no)
738 ###fi
740 ###if test "x$platform_win32" = "xyes"; then
741 ###   # Boehm GC requires the runtime to be in its own dll
742 ###   set(with_static_mono no)
743 ###fi
745 if(with_static_mono)
746   set(STATIC_MONO yes)
747 endif()
748 set(enable_mcs_build yes)
749 ###AC_ARG_ENABLE(mcs-build, [  --disable-mcs-build disable the build of the mcs directory], set(try_mcs_build $enableval, enable_mcs_build=yes))
751 ###set(xen_opt,   [  --with-set(xen_opt yes,no          Enable Xen-specific behaviour (defaults to yes)],[],[with_xen_opt=yes]))
752 ###if test "x$with_xen_opt" = "xyes"; then
753 ###     ac_define(MONO_XEN_OPT, 1, [Xen-specific behaviour])
754 ###     set(ORIG_CFLAGS $CFLAGS)
755 ###     set(CFLAGS "$CFLAGS -mno-tls-direct-seg-refs")
756 ###     ac_msg_checking(for -mno-tls-direct-seg-refs option to gcc)
757 ###     AC_TRY_COMPILE([], [
758 ###                                        void main () { }
759 ###     ], [
760 ###        ac_msg_result(yes)
761 ###        # Pass it to libgc as well
762 ###        set(CFLAGS_FOR_LIBGC "$CFLAGS_FOR_LIBGC -mno-tls-direct-seg-refs")
763 ###     ], [
764 ###        ac_msg_result(no)
765 ###        set(CFLAGS $ORIG_CFLAGS)
766 ###     ])
767 ###fi
769 set (quiet-build yes CACHE BOOL "Enable quiet runtime build (on by default)")
771 set(DISABLED_FEATURES none)
773 ###AC_ARG_ENABLE(minimal, [  --enable-set(minimal LIST      drop support for LIST subsystems.)
774 ###     LIST is a comma-separated list from: aot, profiler, decimal, pinvoke, debug,
775 ###     reflection_emit, reflection_emit_save, large_code, logging, com, ssa, generics, attach, jit, simd.],
776 ###[
777 ###     for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
778 ###             eval "mono_feature_disable_$set(feature 'yes'")
779 ###             AC_MSG_NOTICE([Disabled support for feature: $feature])
780 ###     done
781 ###     set(DISABLED_FEATURES $enable_minimal)
782 ###     set(disabled "Disabled:    $enable_minimal")
783 ###],[])
785 ac_define_unquoted(DISABLED_FEATURES "${DISABLED_FEATURES}" "String of disabled features")
787 ###if test "x$mono_feature_disable_aot" = "xyes"; then
788 ###     AC_DEFINE(DISABLE_AOT_COMPILER, 1, [Disable AOT Compiler])
789 ###     AC_MSG_NOTICE([Disabled AOT compiler])
790 ###fi
792 ###if test "x$mono_feature_disable_profiler" = "xyes"; then
793 ###     ac_define(DISABLE_PROFILER, 1, [Disable default profiler support])
794 ###fi
795 ###AM_CONDITIONAL(DISABLE_PROFILER, test x$mono_feature_disable_profiler = xyes)
797 ###if test "x$mono_feature_disable_decimal" = "xyes"; then
798 ###     ac_define(DISABLE_DECIMAL, 1, [Disable System.Decimal support])
799 ###fi
801 ###if test "x$mono_feature_disable_pinvoke" = "xyes"; then
802 ###     ac_define(DISABLE_PINVOKE, 1, [Disable P/Invoke support])
803 ###fi
805 ###if test "x$mono_feature_disable_debug" = "xyes"; then
806 ###     ac_define(DISABLE_DEBUG, 1, [Disable runtime debugging support])
807 ###fi
809 ###if test "x$mono_feature_disable_reflection_emit" = "xyes"; then
810 ###     ac_define(DISABLE_REFLECTION_EMIT, 1, [Disable reflection emit support])
811 ###     set(mono_feature_disable_reflection_emit_save yes)
812 ###fi
814 ###if test "x$mono_feature_disable_reflection_emit_save" = "xyes"; then
815 ###     ac_define(DISABLE_REFLECTION_EMIT_SAVE, 1, [Disable assembly saving support in reflection emit])
816 ###fi
818 ###if test "x$mono_feature_disable_large_code" = "xyes"; then
819 ###     ac_define(DISABLE_LARGE_CODE, 1, [Disable support for huge assemblies])
820 ###fi
822 ###if test "x$mono_feature_disable_logging" = "xyes"; then
823 ###     ac_define(DISABLE_LOGGING, 1, [Disable support debug logging])
824 ###fi
826 ###if test "x$mono_feature_disable_com" = "xyes"; then
827 ###     ac_define(DISABLE_COM, 1, [Disable COM support])
828 ###fi
830 ###if test "x$mono_feature_disable_ssa" = "xyes"; then
831 ###     ac_define(DISABLE_SSA, 1, [Disable advanced SSA JIT optimizations])
832 ###fi
834 ###if test "x$mono_feature_disable_generics" = "xyes"; then
835 ###     ac_define(DISABLE_GENERICS, 1, [Disable generics support])
836 ###fi
838 ###if test "x$mono_feature_disable_attach" = "xyes"; then
839 ###     ac_define(DISABLE_ATTACH, 1, [Disable agent attach support])
840 ###fi
842 ###if test "x$mono_feature_disable_jit" = "xyes"; then
843 ###     ac_define(DISABLE_JIT, 1, [Disable the JIT, only full-aot mode will be supported by the runtime.])
844 ###fi
846 ###AM_CONDITIONAL(DISABLE_JIT, test x$mono_feature_disable_jit = xyes)
848 ###if test "x$mono_feature_disable_simd" = "xyes"; then
849 ###     ac_define(DISABLE_SIMD, 1, [Disable SIMD intrinsics related optimizations.])
850 ###fi
852 ###ac_msg_checking(for visibility __attribute__)
853 ###AC_TRY_COMPILE([], [
854 ###   void __attribute__ ((visibility ("hidden"))) doit (void) {}
855 ###   void main () { doit (); }
856 ###], [
857 ###   set(have_visibility_hidden yes)
858 ###   ac_msg_result(yes)
859 ###], [
860 ###   set(have_visibility_hidden no)
861 ###   ac_msg_result(no)
862 ###])
866 # libgc checks
869 set(gc_headers no)
870 set(gc included)
871 set(use_included_gc no)
872 set(libgc_configure_args)
873 set(gc_default included)
875 set(gc ${gc_default} CACHE STRING "The GC library to use (defaults to included)")
876 set(with_gc ${gc})
878 # FIXME:
879 set(enable_parallel_mark yes)
880 ###AC_ARG_ENABLE(parallel-mark, [  --enable-parallel-mark     Enables GC Parallel Marking], set(enable_parallel_mark $enableval, enable_parallel_mark=$parallel_mark))
881 ###if test x$enable_parallel_mark = xyes; then
882 ###     set(libgc_configure_args "$libgc_configure_args --enable-parallel-mark")
883 ###fi
885 set(LIBGC_CFLAGS )
886 set(LIBGC_LIBS )
887 set(LIBGC_STATIC_LIBS )
888 set(libgc_dir )
890 if (gc STREQUAL included)
891   set(found_boehm yes)
892   set(gc_headers yes)
893   set(use_included_gc yes)
894   set(libgc_dir libgc)
896   set(LIBGC_CFLAGS '-I${top_srcdir}/libgc/include')
897   set(LIBGC_LIBS '${top_builddir}/libgc/libmonogc.la')
898   set(LIBGC_STATIC_LIBS '${top_builddir}/libgc/libmonogc-static.la')
900   ac_define(HAVE_BOEHM_GC 1 "Have Boehm GC")
901 ###  AC_SUBST(HAVE_BOEHM_GC)
903   ac_define(HAVE_GC_H 1 "Have gc.h")
904   ac_define(USE_INCLUDED_LIBGC 1 "Use included libgc")
906   # The included libgc contains GCJ support
907   ac_define(HAVE_GC_GCJ_MALLOC 1 "Have GC_gcj_malloc")
908   ac_define(HAVE_GC_ENABLE 1 "Have GC_enable")
909   if (enable_parallel_mark STREQUAL yes)
910         ac_define_unquoted(USED_GC_NAME "Included Boehm (with typed GC and Parallel Mark)" "GC description")
911   else()
912         ac_define_unquoted(USED_GC_NAME "Included Boehm (with typed GC)" "GC description")
913   endif()
914 endif()
915   
916 ###case "x$gc" in
917 ###     xboehm|xbohem|xyes)
918 ###             ac_check_headers(gc.h gc/gc.h, set(gc_headers yes))
919 ###             AC_CHECK_LIB(gc, GC_malloc, set(found_boehm "yes",,$libdl))
921 ###             if test "x$found_boehm" != "xyes"; then
922 ###                     ac_msg_error("GC requested but libgc not found! Install libgc or run configure with --with-set(gc none."))
923 ###             fi
924 ###             if test "x$gc_headers" != "xyes"; then
925 ###                     ac_msg_error("GC requested but header files not found! You may need to install them by hand.")
926 ###             fi
928 ###             ac_define(HAVE_BOEHM_GC, 1, [Have Boehm GC])
929 ###             AC_SUBST(HAVE_BOEHM_GC)
930 ###             set(LIBGC_LIBS "-lgc $libdl")
931 ###             set(LIBGC_STATIC_LIBS "$LIBGC_LIBS")
933 ###             # ac_check_funcs does not work for some reason...
934 ###             AC_CHECK_LIB(gc, GC_gcj_malloc, set(found_gcj_malloc "yes",,$libdl))
935 ###             if test "x$found_gcj_malloc" = "xyes"; then
936 ###                     ac_define(HAVE_GC_GCJ_MALLOC, 1, [Have GC_gcj_malloc])
937 ###                     ac_define_unquoted(USED_GC_NAME, "System Boehm (with typed GC)", [GC description])
938 ###             else
939 ###                     ac_define_unquoted(USED_GC_NAME, "System Boehm (no typed GC)", [GC description])
940 ###             fi
941 ###             AC_CHECK_LIB(gc, GC_enable, set(found_gc_enable "yes",,$libdl))
942 ###             if test "x$found_gc_enable" = "xyes"; then
943 ###                     ac_define(HAVE_GC_ENABLE, 1, [Have 'GC_enable'])
944 ###             fi
945 ###             ;;
947 ###     xincluded)
948 ###             set(found_boehm yes)
949 ###             set(gc_headers yes)
950 ###             set(use_included_gc yes)
951 ###             set(libgc_dir libgc)
953 ###             set(LIBGC_CFLAGS '-I$(top_srcdir)/libgc/include')
954 ###             set(LIBGC_LIBS '$(top_builddir)/libgc/libmonogc.la')
955 ###             set(LIBGC_STATIC_LIBS '$(top_builddir)/libgc/libmonogc-static.la')
957 ###             ac_define(HAVE_BOEHM_GC, 1, [Have Boehm GC])
958 ###             AC_SUBST(HAVE_BOEHM_GC)
960 ###             ac_define(HAVE_GC_H, 1, [Have gc.h])
961 ###             ac_define(USE_INCLUDED_LIBGC, 1, [Use included libgc])
963 ###             # The included libgc contains GCJ support
964 ###             ac_define(HAVE_GC_GCJ_MALLOC, 1, [Have GC_gcj_malloc])
965 ###             ac_define(HAVE_GC_ENABLE, 1, [Have GC_enable])
966 ###             if test x$enable_parallel_mark = xyes; then
967 ###                     ac_define_unquoted(USED_GC_NAME, "Included Boehm (with typed GC and Parallel Mark)", [GC description])
968 ###             else
969 ###                     ac_define_unquoted(USED_GC_NAME, "Included Boehm (with typed GC)", [GC description])
970 ###             fi
971 ###             ;;
973 ###     xsgen)
974 ###             set(found_boehm no)
975 ###             set(gc_headers no)
976 ###             set(use_included_gc no)
977 ###             ac_define(HAVE_SGEN_GC,1,[Using the simple generational GC.])
978 ###             ac_define(HAVE_MOVING_COLLECTOR,1,[The GC can move objects.])
979 ###             ac_define(HAVE_WRITE_BARRIERS,1,[The GC needs write barriers.])
980 ###             ac_define_unquoted(USED_GC_NAME, "Simple generational", [GC description])
981 ###             ;;
983 ###     xnone)
984 ###             AC_MSG_WARN("Compiling mono without GC.")
985 ###             ac_define_unquoted(USED_GC_NAME, "none", [GC description])
986 ###             ac_define(HAVE_NULL_GC,1,[No GC support.])
987 ###             ;;
988 ###     *)
989 ###             ac_msg_error([Invalid argument to --with-gc.])
990 ###             ;;
991 ###esac
993 ###set(large-heap, [  --with-large-set(heap yes,no       Enable support for GC heaps larger than 3GB (defaults to no)], [large_heap=$withval], [large_heap=no]))
994 ###if test "x$large_heap" = "xyes"; then
995 ###   echo "FOO"
996 ###   set(CPPFLAGS "$CPPFLAGS -DLARGE_CONFIG")
997 ###fi
999 ###AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
1000 ###AC_SUBST(LIBGC_CFLAGS)
1001 ###AC_SUBST(LIBGC_LIBS)
1002 ###AC_SUBST(LIBGC_STATIC_LIBS)
1003 ###AC_SUBST(libgc_dir)
1006 # End of libgc checks
1009 include(CheckFunctionExists)
1010 include(CheckLibraryExists)
1012 if(platform_win32 STREQUAL no)
1015         # hires monotonic clock support
1016 ###     AC_SEARCH_LIBS(clock_gettime, rt)
1018   check_function_exists (dlopen dlopen_found)
1019   if (dlopen_found)
1020         set(DL_LIB "")
1021   else()
1022         check_library_exists (-ldl dlopen "" libdl_found)
1023         if (libdl_found)
1024           set(DL_LIB "-ldl")
1025         else()
1026           set(dl_support no)
1027         endif()
1028   endif()
1030   if (dl_support STREQUAL no)
1031         # FIXME:
1032         ###             AC_MSG_WARN([No dynamic loading support available])
1033   else()
1034         set(LIBS ${LIBS} ${DL_LIB})
1035         ac_define(HAVE_DL_LOADER 1 "dlopen-based dynamic loader available")
1036         
1037 ###             # from glib's configure.in
1038 ###             AC_CACHE_CHECK([for preceeding underscore in symbols],
1039 ###                     mono_cv_uscore,[
1040 ###                     AC_TRY_RUN([#include <dlfcn.h>
1041 ###                     int mono_underscore_test (void) { return 42; }
1042 ###                     int main() {
1043 ###                       void *f1 = (void*)0, *f2 = (void*)0, *handle;
1044 ###                       handle = dlopen ((void*)0, 0);
1045 ###                       if (handle) {
1046 ###                         f1 = dlsym (handle, "mono_underscore_test");
1047 ###                         f2 = dlsym (handle, "_mono_underscore_test");
1048 ###                       } return (!f2 || f1);
1049 ###                     }],
1050 ###                             [set(mono_cv_uscore yes],)
1051 ###                             [set(mono_cv_uscore no],)
1052 ###                     [])
1053 ###             ])
1054 ###             if test "x$mono_cv_uscore" = "xyes"; then
1055 ###                     set(MONO_DL_NEED_USCORE 1)
1056 ###             else
1057 ###                     set(MONO_DL_NEED_USCORE 0)
1058 ###             fi
1059 ###             AC_SUBST(MONO_DL_NEED_USCORE)
1060 ###             AC_CHECK_FUNC(dlerror)
1061     endif()
1063         # ******************************************************************
1064         # *** Checks for the IKVM JNI interface library                  ***
1065         # ******************************************************************
1066         set(ikvm-native yes CACHE BOOL "Build the IKVM JNI interface library (defaults to yes)")
1067         set(with_ikvm_native ${ikvm-native})
1068         set(ikvm_native_dir )
1069         if(with_ikvm_native)
1070           set(ikvm_native_dir ikvm-native)
1071           set(jdk_headers_found "IKVM Native")
1072         endif()
1074         ac_check_headers(execinfo.h)
1076         ac_check_funcs(getgrgid_r)
1077         ac_check_funcs(getgrnam_r)
1078         ac_check_funcs(getpwnam_r)
1079         ac_check_funcs(getpwuid_r)
1080         ac_check_funcs(getresuid)
1081         ac_check_funcs(setresuid)
1082         ac_check_funcs(kqueue)
1083         ac_check_funcs(backtrace_symbols)
1084         ac_check_funcs(mkstemp)
1085         ac_check_funcs(mmap)
1086         ac_check_funcs(madvise)
1087         ac_check_funcs(getrusage)
1088         ac_check_funcs(getpriority)
1089         ac_check_funcs(setpriority)
1091         ac_check_funcs(sched_setaffinity)
1093         # ******************************************************************
1094         # *** Check for large file support                               ***
1095         # *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
1096         # ******************************************************************
1097 ###     
1098         # Check that off_t can represent 2**63 - 1 correctly, working around
1099         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
1100         # CPPFLAGS and sets $large_offt to yes if the test succeeds
1101 ###     set(large_offt no)
1102 ###     AC_DEFUN([LARGE_FILES], [
1103 ###             set(large_CPPFLAGS $CPPFLAGS)
1104 ###             set(CPPFLAGS "$CPPFLAGS $1")
1105 ###             AC_TRY_RUN([
1106 ###                     #include <sys/types.h>
1108 ###                     #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
1110 ###                     int main(void) {
1111 ###                             int set(big_off_t ((BIG_OFF_T%2147483629==721) &&)
1112 ###                                            (BIG_OFF_T%set(2147483647 =1));)
1113 ###                             if(big_off_t) {
1114 ###                                     exit(0);
1115 ###                             } else {
1116 ###                                     exit(1);
1117 ###                             }
1118 ###                     }
1119 ###             ], [
1120 ###                     ac_msg_result(ok)
1121 ###                     ac_define(HAVE_LARGE_FILE_SUPPORT, 1, [Have large file support])
1122 ###                     set(large_CPPFLAGS "$large_CPPFLAGS $1")
1123 ###                     set(large_offt yes)
1124 ###             ], [
1125 ###                     ac_msg_result(no)
1126 ###             ], "")
1127 ###             set(CPPFLAGS $large_CPPFLAGS)
1128 ###     ])
1130 ###     ac_msg_checking(if off_t is 64 bits wide)
1131 ###     LARGE_FILES("")
1132 ###     if test $large_offt = no; then
1133 ###             ac_msg_checking(if set(_FILE_OFFSET_BITS 64 gives 64 bit off_t))
1134 ###             LARGE_FILES("-set(D_FILE_OFFSET_BITS 64"))
1135 ###     fi
1136 ###     if test $large_offt = no; then
1137 ###             AC_MSG_WARN([No 64 bit file size support available])
1138 ###     fi
1139 ###     
1140         # *****************************
1141         # *** Checks for libsocket  ***
1142         # *****************************
1143 ###     AC_CHECK_LIB(socket, socket, set(LIBS "$LIBS -lsocket"))
1145         # *******************************
1146         # *** Checks for MSG_NOSIGNAL ***
1147         # *******************************
1148 ###     ac_msg_checking(for MSG_NOSIGNAL)
1149 ###     AC_TRY_COMPILE([#include <sys/socket.h>], [
1150 ###             int f = MSG_NOSIGNAL;
1151 ###     ], [
1152 ###             # Yes, we have it...
1153 ###             ac_msg_result(yes)
1154 ###             ac_define(HAVE_MSG_NOSIGNAL, 1, [Have MSG_NOSIGNAL])
1155 ###     ], [
1156 ###             # We'll have to use signals
1157 ###             ac_msg_result(no)
1158 ###     ])
1160         # *****************************
1161         # *** Checks for SOL_IP     ***
1162         # *****************************
1163 ###     ac_msg_checking(for SOL_IP)
1164 ###     AC_TRY_COMPILE([#include <netdb.h>], [
1165 ###             int level = SOL_IP;
1166 ###     ], [
1167 ###             # Yes, we have it...
1168 ###             ac_msg_result(yes)
1169 ###             ac_define(HAVE_SOL_IP, 1, [Have SOL_IP])
1170 ###     ], [
1171 ###             # We'll have to use getprotobyname
1172 ###             ac_msg_result(no)
1173 ###     ])
1175         # *****************************
1176         # *** Checks for SOL_IPV6     ***
1177         # *****************************
1178 ###     ac_msg_checking(for SOL_IPV6)
1179 ###     AC_TRY_COMPILE([#include <netdb.h>], [
1180 ###             int level = SOL_IPV6;
1181 ###     ], [
1182 ###             # Yes, we have it...
1183 ###             ac_msg_result(yes)
1184 ###             ac_define(HAVE_SOL_IPV6, 1, [Have SOL_IPV6])
1185 ###     ], [
1186 ###             # We'll have to use getprotobyname
1187 ###             ac_msg_result(no)
1188 ###     ])
1190         # *****************************
1191         # *** Checks for SOL_TCP    ***
1192         # *****************************
1193 ###     ac_msg_checking(for SOL_TCP)
1194 ###     AC_TRY_COMPILE([#include <netdb.h>], [
1195 ###             int level = SOL_TCP;
1196 ###     ], [
1197 ###             # Yes, we have it...
1198 ###             ac_msg_result(yes)
1199 ###             ac_define(HAVE_SOL_TCP, 1, [Have SOL_TCP])
1200 ###     ], [
1201 ###             # We'll have to use getprotobyname
1202 ###             ac_msg_result(no)
1203 ###     ])
1205         # *****************************
1206         # *** Checks for IP_PKTINFO ***
1207         # *****************************
1208 ###     ac_msg_checking(for IP_PKTINFO)
1209 ###     AC_TRY_COMPILE([#include <netdb.h>], [
1210 ###             int level = IP_PKTINFO;
1211 ###     ], [
1212 ###             # Yes, we have it...
1213 ###             ac_msg_result(yes)
1214 ###             ac_define(HAVE_IP_PKTINFO, 1, [Have IP_PKTINFO])
1215 ###     ], [
1216 ###             ac_msg_result(no)
1217 ###     ])
1219         # *****************************
1220         # *** Checks for IPV6_PKTINFO ***
1221         # *****************************
1222 ###     ac_msg_checking(for IPV6_PKTINFO)
1223 ###     AC_TRY_COMPILE([#include <netdb.h>], [
1224 ###             int level = IPV6_PKTINFO;
1225 ###     ], [
1226 ###             # Yes, we have it...
1227 ###             ac_msg_result(yes)
1228 ###             ac_define(HAVE_IPV6_PKTINFO, 1, [Have IPV6_PKTINFO])
1229 ###     ], [
1230 ###             ac_msg_result(no)
1231 ###     ])
1233         # **********************************
1234         # *** Checks for IP_DONTFRAGMENT ***
1235         # **********************************
1236 ###     ac_msg_checking(for IP_DONTFRAGMENT)
1237 ###     AC_TRY_COMPILE([#include <netdb.h>], [
1238 ###             int level = IP_DONTFRAGMENT;
1239 ###     ], [
1240 ###             # Yes, we have it...
1241 ###             ac_msg_result(yes)
1242 ###             ac_define(HAVE_IP_DONTFRAGMENT, 1, [Have IP_DONTFRAGMENT])
1243 ###     ], [
1244 ###             ac_msg_result(no)
1245 ###     ])
1247         # **********************************
1248         # *** Checks for IP_MTU_DISCOVER ***
1249         # **********************************
1250 ###     ac_msg_checking(for IP_MTU_DISCOVER)
1251 ###     AC_TRY_COMPILE([#include <netdb.h>], [
1252 ###             int level = IP_MTU_DISCOVER;
1253 ###     ], [
1254 ###             # Yes, we have it...
1255 ###             ac_msg_result(yes)
1256 ###             ac_define(HAVE_IP_MTU_DISCOVER, 1, [Have IP_MTU_DISCOVER])
1257 ###     ], [
1258 ###             ac_msg_result(no)
1259 ###     ])
1261 ###     # *********************************
1262         # *** Check for struct ip_mreqn ***
1263         # *********************************
1264 ###     ac_msg_checking(for struct ip_mreqn)
1265 ###     AC_TRY_COMPILE([#include <netinet/in.h>], [
1266 ###             struct ip_mreqn mreq;
1267 ###             mreq.imr_address.s_addr = 0;
1268 ###     ], [
1269 ###             # Yes, we have it...
1270 ###             ac_msg_result(yes)
1271 ###             ac_define(HAVE_STRUCT_IP_MREQN, 1, [Have struct ip_mreqn])
1272 ###     ], [
1273 ###             # We'll just have to try and use struct ip_mreq
1274 ###             ac_msg_result(no)
1275 ###             ac_msg_checking(for struct ip_mreq)
1276 ###             AC_TRY_COMPILE([#include <netinet/in.h>], [
1277 ###                     struct ip_mreq mreq;
1278 ###                     mreq.imr_interface.s_addr = 0;
1279 ###             ], [
1280 ###                     # Yes, we have it...
1281 ###                     ac_msg_result(yes)
1282 ###                     ac_define(HAVE_STRUCT_IP_MREQ, 1, [Have struct ip_mreq])
1283 ###             ], [
1284 ###                     # No multicast support
1285 ###                     ac_msg_result(no)
1286 ###             ])
1287 ###     ])
1288 ###     
1289         # **********************************
1290         # *** Check for gethostbyname2_r ***
1291         # **********************************
1292 ###     ac_msg_checking(for gethostbyname2_r)
1293 ###             AC_TRY_LINK([#include <netdb.h>], [
1294 ###             gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
1295 ###     ], [
1296 ###             # Yes, we have it...
1297 ###             ac_msg_result(yes)
1298 ###             ac_define(HAVE_GETHOSTBYNAME2_R, 1, [Have gethostbyname2_r])
1299 ###     ], [
1300 ###             ac_msg_result(no)
1301 ###     ])
1303         # *****************************
1304         # *** Checks for libnsl     ***
1305         # *****************************
1306 ###     AC_CHECK_FUNC(gethostbyaddr, , AC_CHECK_LIB(nsl, gethostbyaddr, set(LIBS "$LIBS -lnsl")))
1308 ac_check_funcs(inet_pton inet_aton)
1310 # ***********************************************
1311 # *** Checks for size of sockaddr_un.sun_path ***
1312 # ***********************************************
1313 # FIXME: cache
1314 ac_msg_checking("size of sockaddr_un.sun_path")
1316 FILE(WRITE "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/conftest.c"
1318                         #include <sys/types.h>
1319                         #include <stdio.h>
1320                         #include <sys/un.h>
1322                         int main(void) {
1323                                 struct sockaddr_un sock_un;
1324                                 printf(\"%d\\n\", sizeof(sock_un.sun_path));
1325                                 exit(0);
1326                         }
1329 TRY_RUN(run_res run_compiled
1330   ${CMAKE_BINARY_DIR}
1331   ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/conftest.c
1332   RUN_OUTPUT_VARIABLE output)
1334 set(mono_cv_sizeof_sunpath 0)
1335 if(run_compiled)
1336   if (run_res EQUAL 0)
1337         string(REGEX MATCH "[0-9]+" mono_cv_sizeof_sunpath ${output})
1338   endif()
1339 endif()
1341 ac_msg_result(${mono_cv_sizeof_sunpath})
1342 ac_define(MONO_SIZEOF_SUNPATH ${mono_cv_sizeof_sunpath} "Sizeof sock_un.sun_path")
1344         # *************************************
1345         # *** Checks for zero length arrays ***
1346         # *************************************
1347 ###     ac_msg_checking(whether $CC supports zero length arrays)
1348 ###     AC_TRY_COMPILE([
1349 ###                struct s {
1350 ###                        int  length;
1351 ###                        char data [0];
1352 ###                };
1353 ###        ], [], [
1354 ###             ac_msg_result(yes)
1355 ###             ac_define_unquoted(MONO_ZERO_ARRAY_LENGTH, 0, [Length of zero length arrays])
1356 ###     ], [
1357 ###             ac_msg_result(no)
1358 ###             ac_define_unquoted(MONO_ZERO_ARRAY_LENGTH, 1, [Length of zero length arrays])
1359 ###     ])
1361         # *****************************
1362         # *** Checks for libxnet    ***
1363         # *****************************
1364 ###     case "${host}" in
1365 ###             *solaris* )
1366 ###                     ac_msg_checking(for Solaris XPG4 support)
1367 ###                     if test -f /usr/lib/libxnet.so; then
1368 ###                             set(CPPFLAGS "$CPPFLAGS -D_XOPEN_SOURCE=500")
1369 ###                             set(CPPFLAGS "$CPPFLAGS -D__EXTENSIONS__")
1370 ###                             set(CPPFLAGS "$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1")
1371 ###                             set(LIBS "$LIBS -lxnet")
1372 ###                             ac_msg_result(yes)
1373 ###                     else
1374 ###                             ac_msg_result(no)
1375 ###                     fi
1377 ###                     if test "$GCC" = "yes"; then
1378 ###                             set(CFLAGS "$CFLAGS -Wno-char-subscripts")
1379 ###                     fi
1380 ###             ;;
1381 ###     esac
1383         # *****************************
1384         # *** Checks for libpthread ***
1385         # *****************************
1386 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
1387 # and libpthread does not exist
1389 ###     case "${host}" in
1390 ###             *-*-*freebsd*)
1391 ###                     AC_CHECK_LIB(pthread, main, set(LIBS "$LIBS -pthread"))
1392 ###             ;;
1393 ###             *)
1394 ###                     AC_CHECK_LIB(pthread, main, set(LIBS "$LIBS -lpthread"))
1395 ###             ;;
1396 ###     esac
1397 ac_check_headers(pthread.h)
1398 ###     ac_check_funcs(pthread_mutex_timedlock)
1399 ###     ac_check_funcs(pthread_getattr_np pthread_attr_get_np)
1400 ###     ac_msg_checking(for PTHREAD_MUTEX_RECURSIVE)
1401 ###     AC_TRY_COMPILE([ #include <pthread.h>], [
1402 ###             pthread_mutexattr_t attr;
1403 ###             pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1404 ###     ], [
1405 ###             ac_msg_result(ok)
1406 ###     ], [
1407 ###             ac_msg_result(no)
1408 ###             AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
1409 ###             ac_define(USE_MONO_MUTEX, 1, [Use mono_mutex_t])
1410 ###     ])
1411 ###     ac_check_funcs(pthread_attr_setstacksize)
1412 ###     ac_check_funcs(pthread_attr_getstack)
1413 ###     ac_check_funcs(pthread_get_stacksize_np pthread_get_stackaddr_np)
1415         # ***********************************
1416         # *** Checks for working __thread ***
1417         # ***********************************
1418 ###     ac_msg_checking(for working __thread)
1419 ###     if test "x$with_tls" != "x__thread"; then
1420 ###             ac_msg_result(disabled)
1421 ###     else
1422 ###             AC_TRY_RUN([
1423 ###                     #include <pthread.h>
1424 ###                     __thread int i;
1425 ###                     static int res1, res2;
1427 ###                     void thread_main (void *arg)
1428 ###                     {
1429 ###                             i = arg;
1430 ###                             sleep (1);
1431 ###                             if (arg == 1)
1432 ###                                     res1 = (i == arg);
1433 ###                             else
1434 ###                                     res2 = (i == arg);
1435 ###                     }
1437 ###                     int main () {
1438 ###                             pthread_t t1, t2;
1440 ###                             i = 5;
1442 ###                             pthread_create (&t1, NULL, thread_main, 1);
1443 ###                             pthread_create (&t2, NULL, thread_main, 2);
1445 ###                             pthread_join (t1, NULL);
1446 ###                             pthread_join (t2, NULL);
1448 ###                             return !(res1 + res2 == 2);
1449 ###                     }
1450 ###             ], [
1451 ###                             ac_msg_result(yes)
1452 ###             ], [
1453 ###                             ac_msg_result(no)
1454 ###                             set(with_tls pthread)
1455 ###             ])
1456 ###     fi
1458         # **************************************
1459         # *** Checks for working sigaltstack ***
1460         # **************************************
1461 ###     ac_msg_checking(for working sigaltstack)
1462 ###     if test "x$with_sigaltstack" != "xyes"; then
1463 ###             ac_msg_result(disabled)
1464 ###     else
1465 ###             AC_TRY_RUN([
1466 ###                     #include <stdio.h>
1467 ###                     #include <stdlib.h>
1468 ###                     #include <unistd.h>
1469 ###                     #include <signal.h>
1470 ###                     #include <pthread.h>
1471 ###                     #include <sys/wait.h>
1472 ###                     #if defined(__FreeBSD__) || defined(__NetBSD__)
1473 ###                     #define SA_STACK SA_ONSTACK
1474 ###                     #endif
1475 ###                     static void
1476 ###                     sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
1477 ###                     {
1478 ###                             exit (0);
1479 ###                     }
1481 ###                     static void *
1482 ###                     loop (void *ignored)
1483 ###                     {
1484 ###                             char *ptr = NULL;
1486 ###                             *ptr = 0;
1487 ###                             return NULL;
1488 ###                     }
1490 ###                     static void
1491 ###                     child ()
1492 ###                     {
1493 ###                             struct sigaction sa;
1494 ###                             struct sigaltstack sas;
1495 ###                             pthread_t id;
1496 ###                             pthread_attr_t attr;
1498 ###                             sa.sa_sigaction = sigsegv_signal_handler;
1499 ###                             sigemptyset (&sa.sa_mask);
1500 ###                             sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
1501 ###                             if (sigaction (SIGSEGV, &sa, NULL) == -1) {
1502 ###                                     perror ("sigaction");
1503 ###                                     return;
1504 ###                             }
1506 ###                             sas.ss_sp = malloc (SIGSTKSZ);
1507 ###                             sas.ss_size = SIGSTKSZ;
1508 ###                             sas.ss_flags = 0;
1509 ###                             if (sigaltstack (&sas, NULL) == -1) {
1510 ###                                     perror ("sigaltstack");
1511 ###                                     return;
1512 ###                             }
1514 ###                             pthread_attr_init (&attr);
1515 ###                             if (pthread_create(&id, &attr, loop, &attr) != 0) {
1516 ###                                     printf ("pthread_create\n");
1517 ###                                     return;
1518 ###                             }
1520 ###                             sleep (100);
1521 ###                     }
1523 ###                     int
1524 ###                     main ()
1525 ###                     {
1526 ###                             pid_t son;
1527 ###                             int status;
1528 ###                             int i;
1530 ###                             son = fork ();
1531 ###                             if (son == -1) {
1532 ###                                     return 1;
1533 ###                             }
1535 ###                             if (son == 0) {
1536 ###                                     child ();
1537 ###                                     return 0;
1538 ###                             }
1540 ###                             for (i = 0; i < 3; ++i) {
1541 ###                                     sleep (1);
1542 ###                                     waitpid (son, &status, WNOHANG);
1543 ###                                     if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
1544 ###                                             return 0;
1545 ###                             }
1547 ###                             kill (son, SIGKILL);
1548 ###                             return 1;
1549 ###                     }
1551 ###             ], [
1552 ###                             ac_msg_result(yes)
1553 ###                             ac_define(HAVE_WORKING_SIGALTSTACK, 1, [Have a working sigaltstack])
1554 ###             ], [
1555 ###                             set(with_sigaltstack no)
1556 ###                             ac_msg_result(no)
1557 ###             ])
1558 ###     fi
1560         # ********************************
1561         # *** Checks for semaphore lib ***
1562         # ********************************
1563         # 'Real Time' functions on Solaris
1564         # posix4 on Solaris 2.6
1565         # pthread (first!) on Linux
1566 ###     AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
1567         check_library_exists(pthread shm_open "" HAVE_SHM_OPEN1)
1568         if(HAVE_SHM_OPEN1)
1569           # FIXME:
1570         else()
1571           check_library_exists(rt shm_open "" HAVE_SHM_OPEN2)
1572           if(HAVE_SHM_OPEN2)
1573                 set(LIBS ${LIBS} -lrt)
1574                 set(CMAKE_REQUIRED_LIBRARIES rt)
1575                 ac_check_funcs(shm_open)
1576                 set(CMAKE_REQUIRED_LIBRARIES)
1577           else()
1578                 # FIXME: posix4
1579           endif()
1580         endif()
1582         # ********************************
1583         # *** Checks for timezone stuff **
1584         # ********************************
1585 ###     AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
1586 ###             AC_TRY_COMPILE([
1587 ###                     #include <time.h>
1588 ###                     ], [
1589 ###                     struct tm tm;
1590 ###                     tm.tm_gmtoff = 1;
1591 ###                     ], set(ac_cv_struct_tm_gmtoff yes, ac_cv_struct_tm_gmtoff=no)))
1592 ###     if test $ac_cv_struct_tm_gmtoff = yes; then
1593 ###             ac_define(HAVE_TM_GMTOFF, 1, [Have tm_gmtoff])
1594 ###     else
1595 ###             AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
1596 ###                     AC_TRY_COMPILE([
1597 ###                             #include <time.h>
1598 ###                     ], [
1599 ###                             timezone = 1;
1600 ###                     ], set(ac_cv_var_timezone yes, ac_cv_var_timezone=no)))
1601 ###             if test $ac_cv_var_timezone = yes; then
1602 ###                     ac_define(HAVE_TIMEZONE, 1, [Have timezone variable])
1603 ###             else
1604 ###                     AC_ERROR(unable to find a way to determine timezone)
1605 ###             fi
1606 ###     fi
1608 # *********************************
1609 # *** Checks for math functions ***
1610 # *********************************
1611 set(LIBS ${LIBS} -lm)
1612 ###     if test "x$has_broken_apple_cpp" != "xyes"; then
1613 ###             ac_check_funcs(finite, , ac_msg_checking(for finite in math.h)
1614 ###                     AC_TRY_LINK([#include <math.h>], 
1615 ###                     [ finite(0.0); ], 
1616 ###                     ac_define(HAVE_FINITE, 1, [Have finite]) ac_msg_result(yes),
1617 ###                     ac_msg_result(no)))
1618 ###     fi
1619 ###        ac_check_funcs(isfinite, , ac_msg_checking(for isfinite in math.h)
1620 ###                AC_TRY_LINK([#include <math.h>], 
1621 ###                [ isfinite(0.0); ], 
1622 ###                ac_define(HAVE_ISFINITE, 1, [Have isfinite]) ac_msg_result(yes),
1623 ###                ac_msg_result(no)))
1625 # ****************************************************************
1626 # *** Checks for working poll() (macosx defines it but doesn't ***
1627 # *** have it in the library (duh))                            ***
1628 # ****************************************************************
1629 ###     ac_check_funcs(poll)
1631 # *************************
1632 # *** Check for signbit ***
1633 # *************************
1634 ###     ac_msg_checking(for signbit)
1635 ###     AC_TRY_LINK([#include <math.h>], [
1636 ###             int s = signbit(1.0);
1637 ###     ], [
1638 ###             ac_msg_result(yes)
1639 ###             ac_define(HAVE_SIGNBIT, 1, [Have signbit])
1640 ###     ], [
1641 ###             ac_msg_result(no)
1642 ###     ]) 
1644 # **********************************
1645 # *** epoll                        ***
1646 # **********************************
1647 ac_check_headers(sys/epoll.h)
1648 set(haveepoll no)
1649 ###     ac_check_funcs(epoll_ctl, [set(haveepoll yes], ))
1650 ###     if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes" ; then
1651 ###             ac_define(HAVE_EPOLL, 1, [epoll supported])
1652 ###     fi
1654 # ******************************
1655 # *** Checks for SIOCGIFCONF ***
1656 # ******************************
1657 ac_check_headers(sys/ioctl.h)
1658 ac_check_headers(net/if.h)
1659 ###     ac_msg_checking(for ifreq)
1660 ###     AC_TRY_COMPILE([
1661 ###             #include <stdio.h>
1662 ###             #include <sys/ioctl.h>
1663 ###             #include <net/if.h>
1664 ###             ], [
1665 ###             struct ifconf ifc;
1666 ###             struct ifreq *ifr;
1667 ###             void *x;
1668 ###             ifc.ifc_len = 0;
1669 ###             ifc.ifc_buf = NULL;
1670 ###             x = (void *) &ifr->ifr_addr;
1671 ###             ],[
1672 ###                     ac_msg_result(yes)
1673 ###                     ac_define(HAVE_SIOCGIFCONF, 1, [Can get interface list])
1674 ###             ], [
1675 ###                     ac_msg_result(no)
1676 ###             ])
1677 # **********************************
1678 # ***     Checks for sin_len     ***
1679 # **********************************
1680 ###     ac_msg_checking(for sockaddr_in.sin_len)
1681 ###     AC_TRY_COMPILE([
1682 ###             #include <netinet/in.h>
1683 ###             ], [
1684 ###             struct sockaddr_in saddr;
1685 ###             saddr.sin_len = sizeof (saddr);
1686 ###             ],[
1687 ###                     ac_msg_result(yes)
1688 ###                     ac_define(HAVE_SOCKADDR_IN_SIN_LEN, 1, [sockaddr_in has sin_len])
1689 ###             ], [
1690 ###                     ac_msg_result(no)
1691 ###             ])      
1692 # **********************************
1693 # ***    Checks for sin6_len     ***
1694 # **********************************
1695 ###     ac_msg_checking(for sockaddr_in6.sin6_len)
1696 ###     AC_TRY_COMPILE([
1697 ###             #include <netinet/in.h>
1698 ###             ], [
1699 ###             struct sockaddr_in6 saddr6;
1700 ###             saddr6.sin6_len = sizeof (saddr6);
1701 ###             ],[
1702 ###                     ac_msg_result(yes)
1703 ###                     ac_define(HAVE_SOCKADDR_IN6_SIN_LEN, 1, [sockaddr_in6 has sin6_len])
1704 ###             ], [
1705 ###                     ac_msg_result(no)
1706 ###             ])      
1707 # **********************************
1708 # *** Checks for MonoPosixHelper ***
1709 # **********************************
1710 ac_check_headers(checklist.h)
1711 ac_check_headers(fstab.h)
1712 ac_check_headers(attr/xattr.h)
1713 ac_check_headers(sys/extattr.h)
1714 ac_check_headers(sys/sendfile.h)
1715 ac_check_headers(sys/statvfs.h)
1716 ac_check_headers(sys/statfs.h)
1717 ac_check_headers(sys/vfstab.h)
1718 ac_check_headers(sys/xattr.h)
1719 ac_check_headers(sys/mman.h)
1720 ac_check_headers(sys/param.h)
1721 ac_check_headers(sys/mount.h)
1722 ###     ac_check_funcs(getdomainname)
1723 ###     ac_check_funcs(setdomainname)
1724 ###     ac_check_funcs(fgetgrent)
1725 ###     ac_check_funcs(fgetpwent)
1726 ###     ac_check_funcs(fgetpwent)
1727 ###     ac_check_funcs(getfsstat)
1728 ###     ac_check_funcs(lutimes)
1729 ###     ac_check_funcs(mremap)
1730 ###     ac_check_funcs(remap_file_pages)
1731 ###     ac_check_funcs(posix_fadvise)
1732 ###     ac_check_funcs(posix_fallocate)
1733 ###     ac_check_funcs(posix_madvise)
1734 ###     ac_check_funcs(vsnprintf)
1735 ###     ac_check_funcs(sendfile)
1736 ###     ac_check_funcs(sethostid)
1737 ###     ac_check_funcs(statfs)
1738 ###     ac_check_funcs(fstatfs)
1739 ###     ac_check_funcs(statvfs)
1740 ###     ac_check_funcs(fstatvfs)
1741 ###     ac_check_funcs(stime)
1742 ###     ac_check_funcs(strerror_r)
1743 ###     ac_check_funcs(ttyname_r)
1744 ac_check_sizeof(size_t)
1745 ###     AC_CHECK_TYPES([blksize_t], [ac_define(HAVE_BLKSIZE_T)], , 
1746 ###             [#include <sys/types.h>
1747 ###              #include <sys/stat.h>
1748 ###              #include <unistd.h>])
1749 ###     AC_CHECK_TYPES([blkcnt_t], [ac_define(HAVE_BLKCNT_T)], ,
1750 ###             [#include <sys/types.h>
1751 ###              #include <sys/stat.h>
1752 ###              #include <unistd.h>])
1753 ###     AC_CHECK_TYPES([suseconds_t], [ac_define(HAVE_SUSECONDS_T)], ,
1754 ###             [#include <sys/time.h>])
1755 ###     AC_CHECK_TYPES([struct flock], [ac_define(HAVE_STRUCT_FLOCK)], ,
1756 ###             [#include <unistd.h>
1757 ###              #include <fcntl.h>])
1758 ###     AC_CHECK_TYPES([struct pollfd], [ac_define(HAVE_STRUCT_POLLFD)], ,
1759 ###             [#include <sys/poll.h>])
1760 ###     AC_CHECK_TYPES([struct stat], [ac_define(HAVE_STRUCT_STAT)], ,
1761 ###             [#include <sys/types.h>
1762 ###              #include <sys/stat.h>
1763 ###              #include <unistd.h>])
1764 ###     AC_CHECK_TYPES([struct timespec], [ac_define(HAVE_STRUCT_TIMESPEC)], ,
1765 ###             [#include <time.h>])
1766 ###     AC_CHECK_TYPES([struct timeval], [ac_define(HAVE_STRUCT_TIMEVAL)], ,
1767 ###             [#include <sys/time.h>
1768 ###              #include <sys/types.h>
1769 ###              #include <utime.h>])
1770 ###     AC_CHECK_TYPES([struct timezone], [ac_define(HAVE_STRUCT_TIMEZONE)], ,
1771 ###             [#include <sys/time.h>])
1772 ###     AC_CHECK_TYPES([struct utimbuf], [ac_define(HAVE_STRUCT_UTIMBUF)], ,
1773 ###             [#include <sys/types.h>
1774 ###              #include <utime.h>])
1775 ###     AC_CHECK_MEMBERS(
1776 ###             [struct dirent.d_off, struct dirent.d_reclen, struct dirent.d_type],,, 
1777 ###             [#include <sys/types.h>
1778 ###              #include <dirent.h>])
1780 # Favour xattr through glibc, but use libattr if we have to
1781 ###     AC_CHECK_FUNC(lsetxattr, ,
1782 ###             AC_CHECK_LIB(attr, lsetxattr, set(XATTR_LIB "-lattr",))
1783 ###     )
1784 ###     AC_SUBST(XATTR_LIB)
1786 # kinfo_proc.kp_proc works on darwin but fails on other simil-bsds
1787 ###     AC_CHECK_MEMBERS(
1788 ###             [struct kinfo_proc.kp_proc],,, 
1789 ###             [#include <sys/types.h>
1790 ###              #include <sys/sysctl.h>
1791 ###              #include <sys/proc.h>
1792 ###              ])
1794 # *********************************
1795 # *** Checks for Windows compilation ***
1796 # *********************************
1797 ac_check_headers(sys/time.h)
1798 ac_check_headers(sys/param.h)
1799 ac_check_headers(dirent.h)
1801 # *********************************
1802 # *** Check for Console 2.0 I/O ***
1803 # *********************************
1804 ac_check_headers(curses.h)
1805 ac_check_headers(term.h)
1806 ###     ac_check_headers([term.h], [], [],
1807 ###     [#if HAVE_CURSES_H
1808 ###      #include <curses.h>
1809 ###      #endif
1810 ###     ])
1811 ac_check_headers(termios.h)
1813 # * This is provided in io-layer, but on windows it's only available
1814 # * on xp+
1815 ###     ac_define(HAVE_GETPROCESSID, 1, [Define if GetProcessId is available])
1816 ###else
1817 ###     set(jdk_headers_found no)
1818 ###     AC_CHECK_LIB(ws2_32, main, set(LIBS "$LIBS -lws2_32", AC_ERROR(bad mingw install?)))
1819 ###     AC_CHECK_LIB(psapi, main, set(LIBS "$LIBS -lpsapi", AC_ERROR(bad mingw install?)))
1820 ###     AC_CHECK_LIB(ole32, main, set(LIBS "$LIBS -lole32", AC_ERROR(bad mingw install?)))
1821 ###     AC_CHECK_LIB(winmm, main, set(LIBS "$LIBS -lwinmm", AC_ERROR(bad mingw install?)))
1822 ###     AC_CHECK_LIB(oleaut32, main, set(LIBS "$LIBS -loleaut32", AC_ERROR(bad mingw install?)))
1823 ###     AC_CHECK_LIB(advapi32, main, set(LIBS "$LIBS -ladvapi32", AC_ERROR(bad mingw install?)))
1824 ###     AC_CHECK_LIB(version, main, set(LIBS "$LIBS -lversion", AC_ERROR(bad mingw install?)))
1826 # *********************************
1827 # *** Check for struct ip_mreqn ***
1828 # *********************************
1829 ###     ac_msg_checking(for struct ip_mreqn)
1830 ###     AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1831 ###             struct ip_mreqn mreq;
1832 ###             mreq.imr_address.s_addr = 0;
1833 ###     ], [
1834 ###             # Yes, we have it...
1835 ###             ac_msg_result(yes)
1836 ###             ac_define(HAVE_STRUCT_IP_MREQN)
1837 ###     ], [
1838 ###             # We'll just have to try and use struct ip_mreq
1839 ###             ac_msg_result(no)
1840 ###             ac_msg_checking(for struct ip_mreq)
1841 ###             AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1842 ###                     struct ip_mreq mreq;
1843 ###                     mreq.imr_interface.s_addr = 0;
1844 ###             ], [
1845 ###                     # Yes, we have it...
1846 ###                     ac_msg_result(yes)
1847 ###                     ac_define(HAVE_STRUCT_IP_MREQ)
1848 ###             ], [
1849 ###                     # No multicast support
1850 ###                     ac_msg_result(no)
1851 ###             ])
1852 ###     ])
1853 ###     ac_check_funcs(GetProcessId)
1854 ###fi
1856 endif()
1858 # socklen_t check
1859 ac_msg_checking("for socklen_t")
1860 check_c_source_compiles("
1861 #include <sys/types.h>
1862 #include <sys/socket.h>
1863 void main () { 
1864   socklen_t foo; 
1865 }" HAVE_SOCKLEN_T)
1866 if(HAVE_SOCKLEN_T)
1867   ac_define(HAVE_SOCKLEN_T 1 "Have socklen_t")
1868   ac_msg_result(yes)
1869 else()
1870   ac_msg_result(no)
1871 endif()
1873 ###ac_msg_checking(for array element initalizer support)
1874 ###AC_TRY_COMPILE([#include <sys/socket.h>], [
1875 ###     const int array[] = {[1] = 2,};
1876 ###], [
1877 # Yes, we have it...
1878 ###     ac_msg_result(yes)
1879 ###     ac_define(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
1880 ###], [
1881 # We'll have to use signals
1882 ###     ac_msg_result(no)
1883 ###])
1885 ac_check_funcs(trunc)
1886 if(NOT HAVE_TRUNC)
1887   ac_msg_checking("for trunc in math.h")
1888   # Simply calling trunc (0.0) is no good since gcc will optimize the call away
1889   set(compiles)
1890   check_c_source_compiles("
1891 #include <math.h>
1892 void main () {
1893 static void *p = &trunc;
1895 " compiles)
1896   if (compiles)
1897         ac_define(HAVE_TRUNC 1 "")
1898         ac_msg_result(yes)
1899   else()
1900         ac_msg_result(no)
1901   endif()
1902 endif()
1904 ###if test "x$ac_cv_truncl" != "xyes"; then
1905 ###   AC_CHECK_LIB(sunmath, aintl, [ ac_define(HAVE_AINTL, 1, [Has the 'aintl' function]) set(LIBS "$LIBS -lsunmath"]))
1906 ###fi
1908 ac_check_funcs(round)
1909 ac_check_funcs(rint)
1911 # ****************************
1912 # *** Look for /dev/random ***
1913 # ****************************
1915 ###ac_msg_checking([if usage of random device is requested])
1916 ###AC_ARG_ENABLE(dev-random,
1917 ###[  --disable-dev-random    disable the use of the random device (enabled by default)],
1918 ###set(try_dev_random $enableval, try_dev_random=yes))
1920 ###ac_msg_result($try_dev_random)
1922 ###case "{$target}" in
1923 ###    *-openbsd*)
1924 ###    set(NAME_DEV_RANDOM "/dev/srandom")
1925 ###    ;;
1927 # Win32 does not have /dev/random, they have their own method...
1929 ###    *-*-mingw*|*-*-cygwin*)
1930 ###    set(ac_cv_have_dev_random no)
1931 ###    ;;
1933 # Everywhere else, it's /dev/random
1935 ###    *)
1936 ###    set(NAME_DEV_RANDOM "/dev/random")
1937 ###    ;;
1938 ###esac
1940 ###ac_define_unquoted(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM", [Name of /dev/random])
1942 # Now check if the device actually exists
1944 ###if test "x$try_dev_random" = "xyes"; then
1945 ###    AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1946 ###    [if test -r "$NAME_DEV_RANDOM" ; then
1947 ###        set(ac_cv_have_dev_random yes; else ac_cv_have_dev_random=no; fi]))
1948 ###    if test "x$ac_cv_have_dev_random" = "xyes"; then
1949 ###        ac_define(HAVE_CRYPT_RNG, 1, [Have /dev/random])
1950 ###    fi
1951 ###else
1952 ###    ac_msg_checking(for random device)
1953 ###    set(ac_cv_have_dev_random no)
1954 ###    ac_msg_result(has been disabled)
1955 ###fi
1957 ###if test "x$platform_win32" = "xyes"; then
1958 ###    ac_define(HAVE_CRYPT_RNG)
1959 ###fi
1961 ###if test "x$ac_cv_have_dev_random" = "xno" \
1962 ###    && test "x$platform_win32" = "xno"; then
1963 ###    AC_MSG_WARN([[
1964 ###***
1965 ###*** A system-provided entropy source was not found on this system.
1966 ###*** Because of this, the System.Security.Cryptography random number generator
1967 ###*** will throw a NotImplemented exception.
1968 ###***
1969 ###*** If you are seeing this message, and you know your system DOES have an
1970 ###*** entropy collection in place, please contact <crichton@gimp.org> and
1971 ###*** provide information about the system and how to access the random device.
1972 ###***
1973 ###*** Otherwise you can install either egd or prngd and set the environment
1974 ###*** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
1975 ###***]])
1976 ###fi
1977 ### 
1978 ###ac_msg_checking([if inter-process shared handles are requested])
1979 ###AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], set(try_shared_handles $enableval, try_shared_handles=yes))
1980 ###ac_msg_result($try_shared_handles)
1981 ###if test "x$try_shared_handles" != "xyes"; then
1982 ###     ac_define(DISABLE_SHARED_HANDLES, 1, [Disable inter-process shared handles])
1983 ###     AC_SUBST(DISABLE_SHARED_HANDLES)
1984 ###fi
1986 ###if test x$gc = xsgen; then
1987 ###   if test x$with_tls != x__thread; then
1988 ###       ac_msg_error([The SGEN garbage collector depends on a working __thread implementation, and either --with-set(thread pthread was passed to configure, or the configure test for __thread failed.]))
1989 ###   fi
1990 ###fi
1992 ###AC_ARG_ENABLE(nunit-tests, [  --enable-nunit-tests   Run the nunit tests of the class library on 'make check'])
1993 ###AM_CONDITIONAL(ENABLE_NUNIT_TESTS, [test x$enable_nunit_tests = xyes])
1995 ac_msg_checking("if big-arrays are to be enabled")
1996 set(big-arrays no CACHE STRING "Enable the allocation and indexing of arrays greater than Int32.MaxValue]")
1997 set(enable_big_arrays ${big-arrays})
1998 ###if test "x$enable_big_arrays" = "xyes" ; then
1999 ###    if  test "x$ac_cv_sizeof_void_p" = "x8"; then
2000 ###     ac_define(MONO_BIG_ARRAYS,1,[Enable the allocation and indexing of arrays greater than Int32.MaxValue])
2001 ###    else
2002 ###        ac_msg_error([The allocation and indexing of arrays greater than Int32.MaxValue is not supported on this platform.])
2003 ###    fi
2004 ###fi
2005 ###ac_msg_result($enable_big_arrays)
2007 # **************
2008 # *** DTRACE ***
2009 # **************
2011 set(dtrace ${has_dtrace} CACHE BOOL "Enable DTrace probes")
2012 set(enable_dtrace ${dtrace})
2014 ###if test "x$enable_dtrace" = "xyes"; then
2015 ###   if test "x$has_dtrace" = "xno"; then
2016 ###       ac_msg_error([DTrace probes are not supported on this platform.])
2017 ###   fi
2018 ###   AC_PATH_PROG(DTRACE, [dtrace], [no], [$PATH:/usr/sbin])
2019 ###   if test "x$DTRACE" = "xno"; then
2020 ###       ac_msg_result([dtrace utility not found, dtrace support disabled.])
2021 ###       set(enable_dtrace no)
2022 ###   fi
2023 ###fi
2025 set(dtrace_g no)
2026 ###if test "x$enable_dtrace" = "xyes"; then
2027 ###     ac_define(ENABLE_DTRACE, 1, [Enable DTrace probes])
2028 ###     set(DTRACEFLAGS )
2029 ###     if test "x$ac_cv_sizeof_void_p" = "x8"; then
2030 ###             case "$host" in
2031 ###                     powerpc-*-darwin*)
2032 ###                     set(DTRACEFLAGS "-arch ppc64")
2033 ###                     ;;
2034 ###                     i*86-*-darwin*)
2035 ###                     set(DTRACEFLAGS "-arch x86_64")
2036 ###                     ;;
2037 ###                     *)
2038 ###                     set(DTRACEFLAGS -64)
2039 ###                     ;;
2040 ###             esac
2041 ###     else
2042 ###             case "$host" in
2043 ###                     powerpc-*-darwin*)
2044 ###                     set(DTRACEFLAGS "-arch ppc")
2045 ###                     ;;
2046 ###                     i*86-*-darwin*)
2047 ###                     set(DTRACEFLAGS "-arch i386")
2048 ###                     ;;
2049 ###                     *)
2050 ###                     set(DTRACEFLAGS -32)
2051 ###                     ;;
2052 ###             esac
2053 ###     fi
2054 ###     AC_SUBST(DTRACEFLAGS)
2055 ###     case "$host" in
2056 ###             *-*-solaris*)
2057 ###             set(dtrace_g yes)
2058 ###             ;;
2059 ###     esac
2060 ###     ac_check_headers([sys/sdt.h])
2061 ###fi
2062 ###AM_CONDITIONAL(ENABLE_DTRACE, [test x$enable_dtrace = xyes])
2063 ###AM_CONDITIONAL(DTRACE_G_REQUIRED, [test x$dtrace_g = xyes])
2065 # **************
2066 # ***  LLVM  ***
2067 # **************
2069 set(llvm no CACHE BOOL "Enable the experimental LLVM back-end")
2070 set(enable_llvm ${llvm})
2072 ###if test "x$enable_llvm" = "xyes"; then
2073 ###   AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
2074 ###   if test "x$LLVM_CONFIG" = "xno"; then
2075 ###       ac_msg_error([llvm-config not found.])
2076 ###   fi
2078 ###   set(LLVM_CXXFLAGS `$LLVM_CONFIG --cflags`)
2079 ###   set(LLVM_LDFLAGS `$LLVM_CONFIG --ldflags`)
2080 ###   LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter jit x86codegen`
2081 ###   set(LLVM_LIBS "$LLVM_LDFLAGS $LLVM_LIBS -lstdc++")
2083 ###   AC_SUBST(LLVM_CXXFLAGS)
2084 ###   AC_SUBST(LLVM_LIBS)
2085 ###   AC_SUBST(LLVM_LDFLAGS)
2086 ###   ac_define(ENABLE_LLVM, 1, [Enable the LLVM back end])
2087 ###fi
2089 if(enable_llvm)
2090   set(ENABLE_LLVM yes)
2091 endif()
2094 # Architecture-specific checks
2096 set(TARGET "unknown")
2097 set(ACCESS_UNALIGNED "yes")
2099 set(JIT_SUPPORTED no)
2100 set(INTERP_SUPPORTED no)
2101 set(LIBC "libc.so.6")
2102 set(INTL "libc.so.6")
2103 set(SQLITE "libsqlite.so.0")
2104 set(SQLITE3 "libsqlite3.so.0")
2105 set(X11 "libX11.so")
2107 set(sizeof_register "SIZEOF_VOID_P")
2109 set(jit_wanted false)
2110 set(interp_wanted false)
2112 if(host MATCHES "(x86_64-.*-.*)|(amd64-.*-.*)")
2113   set(TARGET AMD64)
2114   set(arch_target amd64)
2115   set(JIT_SUPPORTED yes)
2116   set(jit_wanted true)
2117 elseif(host MATCHES "arm.*-linux.*")
2118   set(TARGET ARM)
2119   set(arch_target arm)
2120   set(ACCESS_UNALIGNED no)
2121   set(JIT_SUPPORTED yes)
2122   set(jit_wanted true)
2123 elseif(host MATCHES "mips.*")
2124   set(TARGET MIPS)
2125   set(arch_target mips)
2126   set(ACCESS_UNALIGNED no)
2127   set(JIT_SUPPORTED yes)
2128   set(jit_wanted true)
2129 ###             ac_msg_checking(for mips n32)
2130 ###             AC_TRY_COMPILE([], [
2131 ###             void main () {
2132 ###             #if _MIPS_SIM != _ABIN32
2133 ###             #error Not mips n32
2134 ###             #endif
2135 ###             }
2136 ###             ],[
2137 ###             ac_msg_result(yes)
2138 ###             set(sizeof_register 8)
2139 ###             ],[
2140 ###             ac_msg_result(no)
2141 ###             ])
2142 ###             ;;
2143 else()
2144   message(FATAL_ERROR "Host ${host} not yet supported by the cmake build.")
2145 endif()
2147 # FIXME: Define the others as well
2148 if (${TARGET} STREQUAL "X86")
2149   ac_define(TARGET_X86 1 [...])
2150 elseif (${TARGET} STREQUAL "AMD64")
2151   ac_define(TARGET_AMD64 1 [...])
2152 elseif (${TARGET} STREQUAL "ARM")
2153   ac_define(TARGET_ARM 1 [...])
2154 endif()
2156 ###case "$host" in
2157 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
2158 #               set(TARGET MIPS;)
2159 #               set(ACCESS_UNALIGNED "no")
2160 #               ;;
2161 ###     i*86-*-*)
2162 ###             set(TARGET X86;)
2163 ###             set(arch_target x86;)
2164 ###             set(JIT_SUPPORTED yes)
2165 ###             set(jit_wanted true)
2166 ###             case $host_os in
2167 ###               solaris*)
2168 ###                     set(LIBC "libc.so")
2169 ###                     set(INTL "libintl.so")
2170 ###                     if test "x$ac_cv_sizeof_void_p" = "x8"; then
2171 ###                             set(TARGET AMD64)
2172 ###                             set(arch_target amd64)
2173 ###                     fi
2175 ###                     # On solaris 10 x86, gcc prints a warning saying 'visibility attribute not supported on this configuration; ignored', but linking fails. A test case:
2176 ###                     # int astruct __attribute__ ((visibility ("hidden")));
2177 ###                     # void foo ()
2178 ###                     # {
2179 ###                     #       void *p = &astruct;
2180 ###                     # }
2181 ###                     # gcc -fPIC --shared -o libfoo.so foo.c
2182 ###                     # yields:
2183 ###                     # foo.c:6: warning: visibility attribute not supported in this configuration; ignored
2184 ###                     # ld: fatal: relocation error: R_386_GOTOFF: file /var/tmp//ccxYR96k.o: symbol astruct: relocation must bind locally
2185 ###                     set(have_visibility_hidden no)
2187 ###             esac
2188 ###             ;;
2189 ###     ia64-*-*)
2190 ###             set(TARGET IA64)
2191 ###             set(arch_target ia64)
2192 ###             set(ACCESS_UNALIGNED "no")
2193 ###             set(JIT_SUPPORTED yes)
2194 ###             set(jit_wanted true)
2195 ###             set(LIBC "libc.so.6.1")
2196 ###             set(INTL "libc.so.6.1")
2197 ###             AC_CHECK_LIB(unwind, _U_dyn_register, [], [ac_msg_error(library libunwind not found)])
2198 ###             set(libmono_ldflags "-lunwind")
2199 ###             ;;
2200 ###     sparc*-*-*)
2201 ###             if test "x$ac_cv_sizeof_void_p" = "x8"; then
2202 ###                set(TARGET SPARC64)
2203 ###             else
2204 ###                     set(TARGET SPARC)
2205 ###             fi
2206 ###             set(arch_target sparc;)
2207 ###             set(JIT_SUPPORTED yes)
2208 ###             set(ACCESS_UNALIGNED "no")
2209 ###             case $host_os in
2210 ###               linux*) ;;
2211 ###               *)
2212 ###                     set(LIBC "libc.so")
2213 ###                     set(INTL "libintl.so")
2214 ###             esac
2215 ###             set(jit_wanted true)
2216 ###             if test x"$GCC" = xyes; then
2217 ###                     # We don't support v8 cpus
2218 ###                     set(CFLAGS "$CFLAGS -Wno-cast-align -mcpu=v9")
2219 ###             fi
2220 ###             if test x"$AR" = xfalse; then
2221 ###                     ac_msg_error([The required utility 'ar' is not found in your PATH. Usually it can be found in /usr/ccs/bin.])
2222 ###             fi
2223 ###             ;;
2224 ###       alpha*-*-linux* | alpha*-*-osf*)
2225 ###             set(TARGET ALPHA;)
2226 ###             set(ACCESS_UNALIGNED "no")
2227 ###             set(JIT_SUPPORTED yes)
2228 ###             set(jit_wanted true)
2229 ###             set(arch_target alpha;)
2230 ###             set(CFLAGS "$CFLAGS -mieee -O0")
2231 ###             case $host_os in
2232 ###               linux*)
2233 ###                     set(LIBC "libc.so.6.1")
2234 ###                     set(INTL "libc.so.6.1")
2235 ###             esac
2236 ###            ;;
2237 ###     *-*-mingw*|*-*-cygwin*)
2238 ###             # When this is enabled, it leads to very strange crashes at runtime (gcc-3.4.4)
2239 ###             set(have_visibility_hidden no)
2240 ###             set(INTL "intl")
2241 ###             ;;
2242 ###     hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
2243 ###             set(TARGET HPPA;)
2244 ###             set(arch_target hppa; )
2245 ###             set(LIBC "libc.sl")
2246 ###             set(ACCESS_UNALIGNED "no")
2247 ###             set(INTERP_SUPPORTED yes)
2248 ###             set(interp_wanted true)
2249 ###             ;;
2250 ###     hppa*linux*)
2251 ###             set(TARGET HPPA;)
2252 ###             ac_define(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
2253 ###             set(arch_target hppa; )
2254 ###             set(ACCESS_UNALIGNED "no")
2255 ###             set(JIT_SUPPORTED yes)
2256 ###             set(jit_wanted true)
2257 ###             ;;
2258 ###     macppc-*-openbsd* | powerpc*-*-linux* | powerpc-*-openbsd* | \
2259 ###        powerpc-*-sysv* | powerpc-*-darwin* | powerpc-*-netbsd* )
2260 ###             if test "x$ac_cv_sizeof_void_p" = "x8"; then
2261 ###                     set(TARGET POWERPC64;)
2262 ###                     set(CPPFLAGS "$CPPFLAGS -D__mono_ppc__ -D__mono_ppc64__")
2263 ###                     set(CFLAGS "$CFLAGS -mminimal-toc")
2264 ###             else
2265 ###                     set(TARGET POWERPC;)
2266 ###                     set(CPPFLAGS "$CPPFLAGS -D__mono_ppc__")
2267 ###             fi
2268 ###             ac_define(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
2269 ###             set(arch_target ppc;)
2270 ###             set(JIT_SUPPORTED yes)
2271 ###             set(jit_wanted true)
2272 ###             ;;
2273 ###     arm*-darwin*)
2274 ###             set(TARGET ARM;)
2275 ###             set(arch_target arm;)
2276 ###             set(ACCESS_UNALIGNED "no")
2277 ###             set(JIT_SUPPORTED yes)
2278 ###             set(CPPFLAGS "$CPPFLAGS -DARM_FPU_NONE=1")
2279 ###             set(jit_wanted true)
2280 ###             ;;
2281 ###     s390-*-linux*)
2282 ###             set(TARGET S390;)
2283 ###             ac_define(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
2284 ###             set(arch_target s390;)
2285 ###             set(ACCESS_UNALIGNED "no")
2286 ###             set(JIT_SUPPORTED yes)
2287 ###             set(jit_wanted true)
2288 ###             # Required CFLAGS for s390[x].  USE_STRING_INLINES is automatic with gcc 4.1
2289 ###             set(CFLAGS "$CFLAGS -mbackchain -D__USE_STRING_INLINES")
2290 ###             ;;
2291 ###     s390x-*-linux*)
2292 ###             set(TARGET S390x;)
2293 ###             ac_define(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
2294 ###             set(arch_target s390x;)
2295 ###             set(ACCESS_UNALIGNED "no")
2296 ###             set(JIT_SUPPORTED yes)
2297 ###             set(jit_wanted true)
2298 ###             set(CFLAGS "$CFLAGS -mbackchain -D__USE_STRING_INLINES")
2299 ###             ;;
2300 ###esac
2302 if (${sizeof_register} STREQUAL "4")
2303    ac_define(SIZEOF_REGISTER 4 "size of machine integer registers")
2304 elseif (${sizeof_register} STREQUAL "8")
2305    ac_define(SIZEOF_REGISTER 8 "size of machine integer registers")
2306 else()
2307    ac_define(SIZEOF_REGISTER SIZEOF_VOID_P "size of machine integer registers")
2308 endif()
2310 ###if test "x$target_byte_order" = "xG_BIG_ENDIAN"; then
2311 ###   AC_DEFINE(TARGET_BYTE_ORDER,G_BIG_ENDIAN,[byte order of target])
2312 ###elif test "x$target_byte_order" = "xG_LITTLE_ENDIAN"; then
2313 ###   AC_DEFINE(TARGET_BYTE_ORDER,G_LITTLE_ENDIAN,[byte order of target])
2314 ###else
2315 ###   AC_DEFINE(TARGET_BYTE_ORDER,G_BYTE_ORDER,[byte order of target])
2316 ###fi
2318 ###if (${have_visibility_hidden" = "xyes"; then
2319 ###   ac_define(HAVE_VISIBILITY_HIDDEN, 1, [Support for the visibility ("hidden") attribute])
2320 ###fi
2322 ###set(jit, [  --with-set(jit yes,no              If you want to build scripts that default to the JIT (defaults to no)],[)
2323 ###     if test x$withval = xyes; then
2324 ###        set(jit_wanted true)
2325 ###     else
2326 ###        set(jit_wanted false)
2327 ###     fi
2328 ###])
2330 ###set(interp, [  --with-set(interp yes,no           If you want to build scripts that default to the interpreter (defaults to no)],[)
2331 ###     if test x$withval = xyes; then
2332 ###        set(interp_wanted true)
2333 ###     else
2334 ###        set(interp_wanted false)
2335 ###     fi
2336 ###])
2338 set(USEJIT no)
2339 if(JIT_SUPPORTED)
2340   if (jit_wanted)
2341         set(USEJIT yes)
2342         set(jit_status "Building and using the JIT")
2343   else()
2344         if (interp_wanted)
2345           set(jit_status "Building the JIT, defaulting to the interpreter")
2346         else()
2347           message(FATAL_ERROR "No JIT or interpreter support available or selected.")
2348         endif()
2349   endif()
2350 else()
2351         if (interp_wanted)
2352           set(jit_status "interpreter")
2353         else()
2354           message(FATAL_ERROR "No JIT or interpreter support available or selected.")
2355         endif()
2356 endif()  
2357 set(USE_JIT ${USEJIT})
2359 set(libsuffix ".so")
2361 ###case "$host" in
2362 ###     *-*-darwin*)
2363 ###     set(libsuffix ".dylib")
2364 ###     set(LIBC "libc.dylib")
2365 ###     set(INTL "libintl.dylib")
2366 ###     set(SQLITE "libsqlite.0.dylib")
2367 ###     set(SQLITE3 "libsqlite3.0.dylib")
2368 ###     set(X11 "libX11.dylib")
2369 ###     ;;
2370 ###     *-*-*netbsd*)
2371 ###     set(LIBC "libc.so.12")
2372 ###     set(INTL "libintl.so.0")
2373 ###     ;;
2374 ###    *-*-*freebsd*)
2375 ###     set(LIBC "libc.so")
2376 ###     set(INTL "libintl.so")
2377 ###     ;;
2378 ###    *-*-*openbsd*)
2379 ###     set(LIBC "libc.so")
2380 ###     set(INTL "libintl.so")
2381 ###     ;;
2382 ###    *-*-*linux*)
2383 ###     AC_PATH_X
2384 ###     ac_msg_checking(for the soname of libX11.so)
2385 ###     for i in $x_libraries /usr/lib /usr/lib64; do
2386 ###             for r in 4 5 6; do
2387 ###                     if test -f $i/libX11.so.$r; then
2388 ###                             set(X11 libX11.so.$r)
2389 ###                             ac_msg_result($X11)
2390 ###                     fi
2391 ###             done
2392 ###     done
2393 ###     
2394 ###     if (${X11" = "xlibX11.so"; then
2395 ###             AC_MSG_WARN([Could not find X development libs. Do you have the -devel package installed? WinForms may not work...]);
2396 ###     fi
2397 ###     ;;
2398 ###esac
2401 ###AC_SUBST(libsuffix)
2403 ac_check_headers(valgrind/memcheck.h)
2404 if(${TARGET} STREQUAL "AMD64" OR ${TARGET} STREQUAL "X86")
2405   if(with_tls STREQUAL __thread)
2406                 #
2407                 # On some linux distributions, TLS works in executables, but linking 
2408                 # against a shared library containing TLS fails with:
2409                 # undefined reference to `__tls_get_addr'
2410                 #
2411 ###             rm -f conftest.c conftest.so conftest
2412 ###             echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
2413 ###             $CC -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
2414 ###             $CC -o conftest conftest.so > /dev/null 2>&1
2415 ###             if test ! -f conftest; then
2416 ###                AC_MSG_WARN([Disabling usage of __thread.]);
2417 ###                set(with_tls pthread)
2418 ###             fi
2419 ###             rm -f conftest.c conftest.so conftest
2420   endif()
2421 endif()
2423 set(mono_debugger_supported no)
2424 if(${TARGET} STREQUAL "AMD64" OR ${TARGET} STREQUAL "X86")
2425   if(use_included_gc)
2426         if (host MATCHES ".*-.*-.*linux.*")
2427           set(mono_debugger_supported yes)
2428         endif()
2429         if (host MATCHES ".*86-apple-darwin.*")
2430           set(mono_debugger_supported yes)
2431         endif()
2432   endif()
2433 endif()
2435 ac_msg_checking("if the Mono Debugger is supported on this platform")
2436 if(mono_debugger_supported)
2437   ac_define(MONO_DEBUGGER_SUPPORTED 1 "The Mono Debugger is supported on this platform")
2438 endif()
2439 ac_msg_result(${mono_debugger_supported})
2440 if(mono_debugger_supported)
2441   set(MONO_DEBUGGER_SUPPORTED yes)
2442 endif()
2444 if (with_tls STREQUAL "__thread")
2445   ac_define(HAVE_KW_THREAD 1 "Have __thread keyword")
2446   ac_define(USE_COMPILER_TLS 1 "Use __thread for TLS access")
2447 # Pass the information to libgc
2448 set(CPPFLAGS "${CPPFLAGS} -DUSE_COMPILER_TLS")
2449 ###     ac_msg_checking(if the tls_model attribute is supported)
2450 ###     AC_TRY_COMPILE([static __thread int foo __attribute__((tls_model("initial-exec")));], [
2451 ###             ], [
2452 ###                     ac_msg_result(yes)
2453 ###                     ac_define(HAVE_TLS_MODEL_ATTR, 1, [tld_model available])
2454 ###             ], [
2455 ###                     ac_msg_result(no)
2456 ###     ])
2457 ###fi
2459 endif()
2461 # ******************************************
2462 # *** Check to see what FPU is available ***
2463 # ******************************************
2464 # FIXME: Don't do this if cross-compiling
2465 if(${TARGET} STREQUAL "ARM")
2466   ac_msg_checking("which FPU to use")
2467   set(CMAKE_REQUIRED_FLAGS "-mfloat-abi=softfp -mfpu=vfp")
2468   set(compiles_fpu_vfp)
2469   check_c_source_compiles("
2470 void main () {
2471                 __asm__ (\"faddd   d7, d6, d7\");
2473 " compiles_fpu_vfp)
2474   set(compiles_fpu_fpa)
2475   set(cmake_required_flags)
2476   check_c_source_compiles("
2477 void main () {
2478                 __asm__ (\"ldfd f0, [r0]\");
2480 " compiles_fpu_fpa)
2481   if(compiles_fpu_vfp)
2482         set(fpu VFP)
2483   elseif(compiles_fpu_fpa)
2484         set(fpu FPA)
2485   else()
2486         set(fpu NONE)
2487   endif()
2488   ac_msg_result(${fpu})
2489   set(CPPFLAGS "${CPPFLAGS} -DARM_FPU_${fpu}=1")
2490   set(fpu)
2491 endif()
2493 if(${TARGET} STREQUAL "unknown")
2494         set(CPPFLAGS ${CPPFLAGS} -DNO_PORT)
2495         ac_msg_warn("mono has not been ported to ${host}: some things may not work.")
2496 endif()
2498 if(NOT ACCESS_UNALIGNED)
2499   set(CPPFLAGS "${CPPFLAGS} -DNO_UNALIGNED_ACCESS")
2500 endif()
2502 ###case "x$gc" in
2503 ###     xincluded)
2504 ###             # Pass CPPFLAGS to libgc configure
2505 ###             # We should use a separate variable for this to avoid passing useless and
2506 ###             # potentially problematic defines to libgc (like -set(D_FILE_OFFSET_BITS 64))
2507 ###             # This should be executed late so we pick up the final version of CPPFLAGS
2508 ###             # The problem with this approach, is that during a reconfigure, the main
2509 ###             # configure scripts gets invoked with these arguments, so we use separate
2510 ###             # variables understood by libgc's configure to pass CPPFLAGS and CFLAGS.
2511 ###             set(LIBGC_CPPFLAGS $CPPFLAGS)
2512 ###             if test x$TARGET = xSPARC -o x$TARGET = xSPARC64; then
2513 ###                     set(LIBGC_CPPFLAGS `echo $LIBGC_CPPFLAGS | sed -e 's/-D_FILE_OFFSET_BITS=64//g'`)
2514 ###             fi
2515 ###             set(ac_configure_args "$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads $libgc_configure_args \"CPPFLAGS_FOR_LIBGC=$LIBGC_CPPFLAGS\" \"CFLAGS_FOR_LIBGC=$CFLAGS_FOR_LIBGC\"")
2516 ###             AC_CONFIG_SUBDIRS(libgc)
2517 ###             ;;
2518 ###esac
2520 set(with_moonlight yes CACHE BOOL "If you want to build the Moonlight 2.1 assemblies (defaults to yes)")
2521 set(with_profile4 no CACHE BOOL "If you want to install the 4.0 FX (defaults to no)")
2522 set(with_monotouch no CACHE BOOL "If you want to build the raw MonoTouch 2.1 assemblies (defaults to no)")
2523 set(with_oprofile no)
2524 set(with_oprofile no CACHE STRING "<oprofile install dir> or 'no' to disable oprofile support (defaults to no)")
2525 if (NOT with_oprofile STREQUAL no)
2526 ###     if test x$with_oprofile != xno; then
2527 ###         set(oprofile_include $with_oprofile/include)
2528 ###         if test ! -f $oprofile_include/opagent.h; then
2529 ###               ac_msg_error([oprofile include file not found at $oprofile_include/opagent.h])
2530 ###             fi
2531 ###         set(OPROFILE yes)
2532 ###             set(OPROFILE_CFLAGS "-I$oprofile_include")
2533 ###         set(OPROFILE_LIBS "-L$with_oprofile/lib/oprofile -lopagent")
2534 ###         ac_define(HAVE_OPROFILE,1,[Have oprofile support])
2535 ###     fi
2536 ###])
2538 endif()
2539 set(MALLOC_MEMPOOLS no)
2540 set(malloc_mempools no CACHE STRING "Use malloc for each single mempool allocation (only for runtime debugging, defaults to no)")
2541 ###     if test x$with_malloc_mempools = xyes; then
2542 ###             set(MALLOC_MEMPOOLS yes)
2543 ###             ac_define(USE_MALLOC_FOR_MEMPOOLS,1,[Use malloc for each single mempool allocation])
2544 ###     fi
2545 ###])
2548 set(DISABLE_MCS_DOCS no)
2549 set(mcs_docs yes CACHE STRING "If you want to build the documentation under mcs (defaults to yes)")
2550 if(NOT mcs_docs)
2551   set(DISABLE_MCS_DOCS yes)
2552 endif()
2553 if(with_oprofile)
2554   set(HAVE_OPROFILE yes)
2555 endif()
2556 ###AC_SUBST(OPROFILE_CFLAGS)
2557 ###AC_SUBST(OPROFILE_LIBS)
2559 set(libs_list)
2560 foreach(lib ${LIBS})
2561   set(libs_list "${libs_list} ${lib}")
2562 endforeach()
2563 set(libmono_ldflags "${libmono_ldflags} ${libs_list}")
2565 if(PREVIEW)
2566   set(INSTALL_2_0 yes)
2567 endif()
2568 if(MOONLIGHT)
2569   set(INSTALL_2_1 yes)
2570 endif()
2572 ###AM_CONDITIONAL(INSTALL_2_1, [test "x$with_moonlight" = xyes])
2573 ###AM_CONDITIONAL(INSTALL_4_0, [test "x$with_profile4" = xyes])
2574 ###AM_CONDITIONAL(INSTALL_MONOTOUCH, [test "x$with_monotouch" = xyes])
2576 ###AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
2577 ###AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
2578 # Define a variable for the target
2579 set(${TARGET} 1)
2581 if (interp_wanted)
2582   set(INTERP_SUPPORTED yes)
2583 endif()
2584 if (gc STREQUAL "included")
2585   set(INCLUDED_LIBGC yes)
2586 endif()
2588 ###AC_SUBST(LIBC)
2589 ###AC_SUBST(INTL)
2590 ###AC_SUBST(SQLITE)
2591 ###AC_SUBST(SQLITE3)
2592 ###AC_SUBST(X11)
2593 ac_define_unquoted(ARCHITECTURE "${arch_target}" "The architecture this is running on")
2594 ###AC_SUBST(arch_target)
2595 ###AC_SUBST(CFLAGS)
2596 ###AC_SUBST(CPPFLAGS)
2597 ###AC_SUBST(LDFLAGS)
2599 set(mono_build_root ${CMAKE_BINARY_DIR})
2601 if (USEJIT)
2602   set(mono_runtime mono/mini/mono)
2603 else()
2604   set(mono_runtime mono/interpreter/mint)
2605 endif()
2607 set(mono_cfg_root ${mono_build_root}/runtime)
2608 if (platform_win32)
2609 ###if test x$platform_win32 = xyes; then
2610 ###  if (${cross_compiling" = "xno"; then
2611 ###    set(mono_cfg_dir `cygpath -w -a $mono_cfg_root`\\etc)
2612 ###  else
2613 ###    set(mono_cfg_dir `echo $mono_cfg_root | tr '/' '\\\'`\\etc)
2614 ###  fi
2615 else()
2616   set(mono_cfg_dir ${mono_cfg_root}/etc)
2617 endif()
2619 function(ac_config_files file)
2620   configure_file("${file}.in" ${file} @ONLY)
2621 endfunction()
2622 ac_config_files("po/mcs/Makefile.in")
2624 ac_config_files("runtime/mono-wrapper")
2625 ac_config_files("runtime/monodis-wrapper")
2626 execute_process (COMMAND chmod a+x runtime/mono-wrapper runtime/monodis-wrapper)
2628 ###AC_CONFIG_COMMANDS([runtime/etc/mono/1.0/machine.config],
2629 ###[   set(depth ../../../..)
2630 ###    case $srcdir in
2631 ###    [[\\/$]]* | ?:[[\\/]]* ) set(reldir $srcdir ;;)
2632 ###    .) set(reldir $depth ;;)
2633 ###    *) set(reldir $depth/$srcdir ;;)
2634 ###    esac
2635 ###    $ac_aux_dir/install-sh -d runtime/etc/mono/1.0
2636 ###    cd runtime/etc/mono/1.0
2637 ###    rm -f machine.config
2638 ###    $LN_S $reldir/data/net_1_1/machine.config machine.config
2639 ###    cd $depth
2640 ###],[set(LN_S '$LN_S']))
2642 ###AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/machine.config],
2643 ###[   set(depth ../../../..)
2644 ###    case $srcdir in
2645 ###    [[\\/$]]* | ?:[[\\/]]* ) set(reldir $srcdir ;;)
2646 ###    .) set(reldir $depth ;;)
2647 ###    *) set(reldir $depth/$srcdir ;;)
2648 ###    esac
2649 ###    $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
2650 ###    cd runtime/etc/mono/2.0
2651 ###    rm -f machine.config
2652 ###    $LN_S $reldir/data/net_2_0/machine.config machine.config
2653 ###    cd $depth
2654 ###],[set(LN_S '$LN_S']))
2656 ###AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/web.config],
2657 ###[   set(depth ../../../..)
2658 ###    case $srcdir in
2659 ###    [[\\/$]]* | ?:[[\\/]]* ) set(reldir $srcdir ;;)
2660 ###    .) set(reldir $depth ;;)
2661 ###    *) set(reldir $depth/$srcdir ;;)
2662 ###    esac
2663 ###    $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
2664 ###    cd runtime/etc/mono/2.0
2665 ###    rm -f web.config
2666 ###    $LN_S $reldir/data/net_2_0/web.config web.config
2667 ###    cd $depth
2668 ###],[set(LN_S '$LN_S']))
2670 ###AC_CONFIG_COMMANDS([runtime/etc/mono/browscap.ini],
2671 ###[   set(depth ../../..)
2672 ###    case $srcdir in
2673 ###    [[\\/$]]* | ?:[[\\/]]* ) set(reldir $srcdir ;;)
2674 ###    .) set(reldir $depth ;;)
2675 ###    *) set(reldir $depth/$srcdir ;;)
2676 ###    esac
2677 ###    $ac_aux_dir/install-sh -d runtime/etc/mono/
2678 ###    cd runtime/etc/mono/
2679 ###    rm -f browscap.ini
2680 ###    $LN_S $reldir/data/browscap.ini browscap.ini
2681 ###    cd $depth
2682 ###],[set(LN_S '$LN_S']))
2684 ###AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/Browsers/Compat.browser],
2685 ###[   set(depth ../../../../..)
2686 ###    case $srcdir in
2687 ###    [[\\/$]]* | ?:[[\\/]]* ) set(reldir $srcdir ;;)
2688 ###    .) set(reldir $depth ;;)
2689 ###    *) set(reldir $depth/$srcdir ;;)
2690 ###    esac
2691 ###    $ac_aux_dir/install-sh -d runtime/etc/mono/2.0/Browsers/
2692 ###    cd runtime/etc/mono/2.0/Browsers
2693 ###    rm -f Compat.browser
2694 ###    $LN_S $reldir/data/net_2_0/Browsers/Compat.browser Compat.browser
2695 ###    cd $depth
2696 ###],[set(LN_S '$LN_S']))
2699 ###AC_CONFIG_COMMANDS([runtime/etc/mono/4.0/machine.config],
2700 ###[   depth=../../../..
2701 ###    case $srcdir in
2702 ###    [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2703 ###    .) reldir=$depth ;;
2704 ###    *) reldir=$depth/$srcdir ;;
2705 ###    esac
2706 ###    $ac_aux_dir/install-sh -d runtime/etc/mono/4.0
2707 ###    cd runtime/etc/mono/4.0
2708 ###    rm -f machine.config
2709 ###    $LN_S $reldir/data/net_4_0/machine.config machine.config
2710 ###    cd $depth
2711 ###],[LN_S='$LN_S'])
2713 ###AC_CONFIG_COMMANDS([runtime/etc/mono/4.0/web.config],
2714 ###[   depth=../../../..
2715 ###    case $srcdir in
2716 ###    [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2717 ###    .) reldir=$depth ;;
2718 ###    *) reldir=$depth/$srcdir ;;
2719 ###    esac
2720 ###    $ac_aux_dir/install-sh -d runtime/etc/mono/4.0
2721 ###    cd runtime/etc/mono/4.0
2722 ###    rm -f web.config
2723 ###    $LN_S $reldir/data/net_4_0/web.config web.config
2724 ###    cd $depth
2725 ###],[LN_S='$LN_S'])
2728 ###if test x$enable_quiet_build = xyes; then
2729 ###   AC_CONFIG_COMMANDS([quiet], [for i in `find mono libgc support -name Makefile.in | sed -e 's/Makefile.in/Makefile/g'`; do if test -f $i; then $srcdir/scripts/patch-quiet.sh $i; fi; done], [set(shell $SHELL]))
2730 ###   AC_CONFIG_COMMANDS([quiet-libtool], [sed -e 's/$echo "copying selected/$show "copying selected/g' < libtool > libtool.tmp && mv libtool.tmp libtool && chmod a+x libtool; sed -e 's/$ECHO "copying selected/# "copying selected/g' < libtool > libtool.tmp && mv libtool.tmp libtool && chmod a+x libtool])
2731 ###fi
2733 if("${prefix}" STREQUAL "")
2734   set(prefix /usr/local)
2735 endif()
2736 if("${exec_prefix}" STREQUAL "")
2737   set(exec_prefix "\${prefix}")
2738   set(exec_prefix_full "${prefix}")
2739 else()
2740   set(exec_prefix_full "${exec_prefix}")
2741 endif()
2743 # FIXME: Make these overridable
2744 set(bindir "\${exec_prefix}/bin")
2745 set(bindir_full "${exec_prefix_full}/bin")
2746 set(sbindir "\${exec_prefix}/sbin")
2747 set(libexecdir "\${exec_prefix}/libexec")
2748 set(datarootdir "\${prefix}/share")
2749 set(datadir "\${datarootdir}")
2750 set(sysconfdir "\${prefix}/etc")
2751 set(sharedstatedir "\${prefix}/com")
2752 set(localstatedir "\${prefix}/var")
2753 set(includedir "\${prefix}/include")
2754 set(oldincludedir "/usr/include")
2755 set(docdir "\${datarootdir}/doc/\${PACKAGE}")
2756 set(infodir "\${datarootdir}/info")
2757 set(htmldir "\${docdir}")
2758 set(dvidir "\${docdir}")
2759 set(pdfdir "\${docdir}")
2760 set(psdir "\${docdir}")
2761 set(libdir "\${exec_prefix}/lib")
2762 set(localedir "\${datarootdir}/locale")
2763 set(mandir "\${datarootdir}/man")
2765 autoheader("config.h" autoheader_vars)
2767 set(SUBDIRS po ${libgc_dir} ${eglib_dir} mono ${ikvm_native_dir} support data runtime scripts man samples web msvc docs)
2769 foreach(dir ${SUBDIRS})
2770   add_subdirectory(${dir})
2771 endforeach()
2773 # Implementation of AC_OUTPUT for cmake
2774 function(ac_output outputs)
2775   foreach (output ${ARGV})
2776         configure_file ("${output}.in" "${output}" @ONLY)
2777   endforeach()
2778 endfunction()
2780 ac_output(
2781 mono-uninstalled.pc
2782 scripts/mono-find-provides
2783 scripts/mono-find-requires
2784 mono/tests/tests-config
2785 data/mint.pc
2786 data/mono.pc
2787 data/mono-cairo.pc
2788 data/mono-nunit.pc
2789 data/mono-options.pc
2790 data/mono-lineeditor.pc
2791 data/monodoc.pc
2792 data/mono.web.pc
2793 data/dotnet.pc
2794 data/dotnet35.pc
2795 data/wcf.pc
2796 data/cecil.pc
2797 data/system.web.extensions_1.0.pc
2798 data/system.web.extensions.design_1.0.pc
2799 data/system.web.mvc.pc
2800 data/config
2803 ###AC_OUTPUT([
2804 ###mono-core.spec
2805 ###mono-uninstalled.pc
2806 ###scripts/mono-find-provides
2807 ###scripts/mono-find-requires
2808 ###mono/dis/Makefile
2809 ###mono/cil/Makefile
2810 ###mono/arch/Makefile
2811 ###mono/arch/x86/Makefile
2812 ###mono/arch/amd64/Makefile
2813 ###mono/arch/hppa/Makefile
2814 ###mono/arch/ppc/Makefile
2815 ###mono/arch/sparc/Makefile
2816 ###mono/arch/s390/Makefile
2817 ###mono/arch/s390x/Makefile
2818 ###mono/arch/arm/Makefile
2819 ###mono/arch/alpha/Makefile
2820 ###mono/arch/ia64/Makefile
2821 ###mono/arch/mips/Makefile
2822 ###mono/interpreter/Makefile
2823 ###mono/tests/Makefile
2824 ###mono/tests/tests-config
2825 ###mono/tests/assemblyresolve/Makefile
2826 ###mono/tests/cas/Makefile
2827 ###mono/tests/cas/assembly/Makefile
2828 ###mono/tests/cas/demand/Makefile
2829 ###mono/tests/cas/inheritance/Makefile
2830 ###mono/tests/cas/linkdemand/Makefile
2831 ###mono/tests/cas/threads/Makefile
2832 ###mono/benchmark/Makefile
2833 ###mono/monograph/Makefile
2834 ###mono/profiler/Makefile
2835 ###ikvm-native/Makefile
2836 ###scripts/Makefile
2837 ###man/Makefile
2838 ###web/Makefile
2839 ###docs/Makefile
2840 ###data/Makefile
2841 ###data/net_2_0/Makefile
2842 ###data/net_4_0/Makefile
2843 ###data/net_2_0/Browsers/Makefile
2844 ###data/mint.pc
2845 ###data/mono.pc
2846 ###data/mono-cairo.pc
2847 ###data/mono-nunit.pc
2848 ###data/mono-options.pc
2849 ###data/mono-lineeditor.pc
2850 ###data/monodoc.pc
2851 ###data/mono.web.pc
2852 ###data/dotnet.pc
2853 ###data/dotnet35.pc
2854 ###data/wcf.pc
2855 ###data/cecil.pc
2856 ###data/system.web.extensions_1.0.pc
2857 ###data/system.web.extensions.design_1.0.pc
2858 ###data/system.web.mvc.pc
2859 ###samples/Makefile
2860 ###support/Makefile
2861 ###data/config
2862 ###tools/Makefile
2863 ###tools/locale-builder/Makefile
2864 ###runtime/Makefile
2865 ###msvc/Makefile
2866 ###po/Makefile
2867 ###])
2869 ###if test x$platform_win32 = xyes; then
2870 ###   # Get rid of 'cyg' prefixes in library names
2871 ###   sed -e "s/\/cyg\//\/\//" libtool > libtool.new; mv libtool.new libtool; chmod 755 libtool
2872 ###   # libtool seems to inherit -mno-cygwin from our CFLAGS, and uses it to compile its executable
2873 ###   # wrapper scripts which use exec(). gcc has no problem compiling+linking this, but the resulting
2874 ###   # executable doesn't work...
2875 ###   sed -e "s,-mno-cygwin,,g" libtool > libtool.new; mv libtool.new libtool; chmod 755 libtool
2876 ###fi
2878 # FIXME:
2879 set(mcs_INSTALL ${mono_build_root}/install-sh)
2881 ###    case $INSTALL in
2882 ###    [[\\/$]]* | ?:[[\\/]]* ) set(mcs_INSTALL $INSTALL ;;)
2883 ###    *) set(mcs_INSTALL $mono_build_root/$INSTALL ;;)
2884 ###    esac
2886 # Compute a 4 part version number into myver from ${mono_version}
2887 string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1.\\2.\\3.\\4" myver "${mono_version}.0.0.0")
2889 set(config.make ${srcdir}/${mcsdir}/build/config.make)
2891 # If we are cross compiling, we don't build in the mcs/ tree.  Let us not clobber
2892 # any existing config.make.  This allows people to share the same source tree
2893 # with different build directories, one native and one cross
2895 if(NOT cross_compiling)
2896   set(not_cross_compiling yes)
2897 endif()
2898 if(not_cross_compiling AND enable_mcs_build)
2899   file(WRITE ${config.make} "prefix=${prefix}
2900 exec_prefix=${exec_prefix}
2901 sysconfdir=${sysconfdir}
2902 mono_libdir=\${exec_prefix}/lib
2903 MCS_FLAGS=$(PLATFORM_DEBUG_FLAGS)
2904 IL_FLAGS=/debug
2905 RUNTIME=${mono_build_root}/runtime/mono-wrapper
2906 ILDISASM=${mono_build_root}/runtime/monodis-wrapper
2907 INSTALL=${mcs_INSTALL}
2908 MONO_VERSION=${myver}
2910 endif()
2912 if(platform_darwin)
2913   file(APPEND ${config.make} "PLATFORM=darwin\n")
2914 endif()
2916 if (${TARGET} STREQUAL "AMD64" AND ${platform_win32} STREQUAL "no" AND AOT_SUPPORTED)
2917   file(APPEND ${config.make} "ENABLE_AOT=1\n")
2918 endif()
2920 if (DISABLE_MCS_DOCS)
2921   file(APPEND ${config.make} "DISABLE_MCS_DOCS=yes\n")
2922 endif()
2924 ###  # if we have an olive folder, override the default settings
2925 ###  if test -d $olivedir; then
2927 ###    test -w $srcdir/$olivedir/build || chmod +w $srcdir/$olivedir/build
2929 ###    if test x$cross_compiling = xno && test x$enable_olive_build != xno; then
2930 ###      echo "set(prefix $prefix" > $srcdir/$olivedir/build/config.make)
2931 ###      echo "set(exec_prefix $exec_prefix" >> $srcdir/$olivedir/build/config.make)
2932 ###      echo 'set(mono_libdir ${exec_prefix}/lib' >> $srcdir/$olivedir/build/config.make)
2933 ###      echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $srcdir/$olivedir/build/config.make
2934 ###      echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $srcdir/$olivedir/build/config.make
2935 ###      echo "MONO_VERSION = $myver" >> $srcdir/$olivedir/build/config.make
2936 ###       if test x$with_moonlight = xyes; then
2937 ###        echo "WITH_MOONLIGHT = yes" >> $srcdir/$olivedir/build/config.make
2938 ###      fi
2939 ###    fi
2940 ###  fi
2942 if(NOT libgdiplus_loc)
2943   set(libgdiplus_msg "assumed to be installed")
2944 else()
2945   set(libgdiplus_msg ${libgdiplus_loc})
2946 endif()
2948 message(STATUS
2950         mcs source:    ${mcs_topdir}
2951         olive source:  ${olive_topdir}
2953         GC:            ${gc}
2954         TLS:           ${with_tls}
2955         SIGALTSTACK:   ${with_sigaltstack}
2956         Engine:        ${jit_status}
2957         Moon Profile:  ${with_moonlight}
2958         4.0 Alpha:     ${with_profile4}
2959         MonoTouch:     ${with_monotouch}
2960         JNI support:   ${jdk_headers_found}
2961         libgdiplus:    ${libgdiplus_msg}
2962         zlib:          ${zlib_msg}
2963         oprofile:      ${with_oprofile}
2964         BigArrays:     ${enable_big_arrays}
2965         DTrace:        ${enable_dtrace}
2966         Parallel Mark: ${enable_parallel_mark}
2967         LLVM Back End: ${enable_llvm}
2968         ${disabled}
2972 if(NOT with_static_mono)
2973   if(NOT platform_win32)
2974         ac_msg_warn("Turning off static Mono is a risk, you might run into unexpected bugs")
2975   endif()
2976 endif()
2978 if(gc STREQUAL sgen)
2979 message("
2980  IMPORTANT:
2981  IMPORTANT: You have selected an experimental, work-in-progress 
2982  IMPORTANT: GC engine.  This GC engine is currently not supported
2983  IMPORTANT: and is not yet ready for use.  
2984  IMPORTANT:
2985  IMPORTANT: There are known problems with it, use at your own risk.
2986  IMPORTANT:
2988 endif()
2990 if(enable_llvm)
2991 message("
2992  IMPORTANT:
2993  IMPORTANT: The LLVM Back End is experimental and does not work yet.
2994  IMPORTANT:
2996 endif()
2998 # Makefile.am
3000 ###     -rm -fr $(mcslib)/monolite-*
3001 ###     -mkdir -p $(mcslib)
3002 ###     test ! -d $(monolite) || test ! -d $(monolite).old || rm -fr $(monolite).old
3003 ###     test ! -d $(monolite) || mv -f $(monolite) $(monolite).old
3004 ###     cd $(mcslib) && { (wget -O- $(monolite_url) || curl $(monolite_url)) | gzip -d | tar xf - ; }
3005 ###     cd $(mcslib) && mv -f monolite-* monolite
3008 #### Keep in sync with SUBDIRS
3009 ##### 'tools' is not normally built
3010 ###DIST_SUBDIRS = po libgc $(eglib_dir) mono ikvm-native support data runtime scripts man samples web tools msvc docs
3012 ###EXTRA_DIST= nls.m4 po.m4 progtest.m4 mono-uninstalled.pc.in build-mingw32.sh LICENSE mkinstalldirs
3014 ###DISTCHECK_CONFIGURE_FLAGS = EXTERNAL_MCS=false EXTERNAL_RUNTIME=false
3016 #### Distribute the 'mcs' tree too
3017 ###dist-hook:
3018 ###     test -d $(distdir)/mcs || mkdir $(distdir)/mcs
3019 ### d=`cd $(distdir)/mcs && pwd`; cd $(mcs_topdir) && $(MAKE) distdir=$$d dist-recursive
3021 ###pkgconfigdir = $(libdir)/pkgconfig
3022 ###noinst_DATA = mono-uninstalled.pc
3023 ###DISTCLEANFILES= mono-uninstalled.pc
3025 ###.PHONY: get-monolite-latest mcs-do-compiler-tests compiler-tests bootstrap-world
3027 #### building with monolite
3028 set(mcslib ${mcs_topdir}/class/lib)
3029 set(monolite ${mcslib}/monolite)
3030 set(monolite_url http://mono.ximian.com/daily/monolite-latest.tar.gz)
3031 add_custom_target(get-monolite-latest
3032 COMMAND -rm -fr ${mcslib}/monolite-*
3033 COMMAND -mkdir -p ${mcslib}
3034 COMMAND test ! -d ${monolite} || test ! -d ${monolite}.old || rm -fr ${monolite}.old
3035 COMMAND test ! -d ${monolite} || mv -f ${monolite} ${monolite}.old
3036 COMMAND cd ${mcslib} && { (wget -O- ${monolite_url} || curl ${monolite_url}) | gzip -d | tar xf - \; }
3037 COMMAND cd ${mcslib} && mv -f monolite-* monolite
3040 ###compiler-tests: mcs-do-clean
3041 ###     $(MAKE) all
3042 ###     $(MAKE) mcs-do-compiler-tests
3044 ###compiler-tests-net_2_0:
3045 ###     -rm -f $(mcs_topdir)/build/common/Consts.cs.save
3046 ###     -mv -f $(mcs_topdir)/build/common/Consts.cs $(mcs_topdir)/build/common/Consts.cs.save
3047 ###     cd $(mcs_topdir) && $(MAKE) PROFILE=net_2_0_bootstrap clean
3048 ###     cd $(mcs_topdir) && $(MAKE) PROFILE=net_2_0 clean
3049 ###     -mv -f $(mcs_topdir)/build/common/Consts.cs.save $(mcs_topdir)/build/common/Consts.cs
3050 ###     $(MAKE) all
3051 ###     $(MAKE) build_profiles=net_2_0 mcs-do-compiler-tests
3053 ###bootstrap-world: compiler-tests
3054 ###     $(MAKE) install
3056 ###bootstrap-world-net_2_0: compiler-tests-net_2_0
3057 ###     $(MAKE) install
3059 #### internal targets
3060 ###mcs-do-clean:
3061 ###     cd runtime && $(MAKE) clean-local
3062 ###     cd mono/tests && $(MAKE) clean
3063 ###mcs-do-compiler-tests:
3064 ###     cd runtime && $(MAKE) test_select='TEST_SUBDIRS="tests errors"' check-local
3065 ###     cd mono/tests && $(MAKE) check
3067 ###win32getdeps:
3068 ###     wget http://www.go-mono.com/archive/pkgconfig-0.11-20020310.zip
3069 ###     wget http://www.go-mono.com/archive/glib-2.0.4-20020703.zip 
3070 ###     wget http://www.go-mono.com/archive/glib-dev-2.0.4-20020703.zip 
3071 ###     wget http://www.go-mono.com/archive/libiconv-1.7.zip 
3072 ###     wget http://www.go-mono.com/archive/libiconv-dev-1.7.zip 
3073 ###     wget http://www.go-mono.com/archive/libintl-0.10.40-20020101.zip
3074 ###     unzip -n -d / pkgconfig-0.11-20020310.zip
3075 ###     unzip -n -d / glib-2.0.4-20020703.zip
3076 ###     unzip -n -d / glib-dev-2.0.4-20020703.zip
3077 ###     unzip -n -d / libiconv-1.7.zip
3078 ###     unzip -n -d / libiconv-dev-1.7.zip
3079 ###     unzip -n -d / libintl-0.10.40-20020101.zip
3081 ###win32setup:
3082 ###     makensis /DMILESTONE=$(VERSION) /DSOURCE_INSTALL_DIR=$(SOURCE_INSTALL_DIR) /DBUILDNUM=$(BUILDNUM) monowiz.win32.nsi
3084 ###bootstrap: all
3085 ###     @echo "*** 'make bootstrap' is obsolete.  Just run 'make' to perform a combined mono+mcs build"
3086 ###     exit 1
3088 ###patch-quiet:
3089 ###     find mono -name Makefile -exec scripts/patch-quiet.sh {} \;
3090 ###     find libgc -name Makefile -exec scripts/patch-quiet.sh {} \;
3092 ###update-csproj:
3093 ###     (cd $(mcs_topdir)/build/csproj && gmcs genproj.cs) && (cd runtime; make V=1 extra_targets=csproj-local)