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