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