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