Disable some warnings when using clang.
[mono.git] / configure.in
1 # Process this file with autoconf to produce a configure script.
2 #AC_PREREQ([2.62])
3
4 AC_INIT(mono, [3.1.0],
5         [http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
6
7 AC_CONFIG_SRCDIR([README])
8 AC_CONFIG_MACRO_DIR([m4])
9 AC_CANONICAL_SYSTEM
10 AC_CANONICAL_HOST
11
12 # Gross hack to enable 'make dist' on automake 1.9+tar 1.14.
13 # The extra brackets are to foil regex-based scans.
14 m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
15
16 AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar no-dist-gzip foreign])
17 AC_CONFIG_HEADERS([config.h])
18 AM_MAINTAINER_MODE
19
20 API_VER=2.0
21 AC_SUBST(API_VER)
22
23 AC_PROG_LN_S
24
25 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
26
27 # In case of cygwin, override LN_S, irrespective of what it determines.
28 # The build uses cygwin, but the actual runtime doesn't.
29 case $host_os in
30 *cygwin* ) LN_S='cp -p';;
31 esac
32
33 dnl
34 dnl libgc checks
35 dnl
36
37 gc_headers=no
38 gc=included
39 gc_msg="included Boehm"
40 use_included_gc=no
41 libgc_configure_args=
42
43 if test -d $srcdir/libgc ; then
44   gc_default=included
45 else
46   gc_default=boehm
47 fi
48
49 # These variables are the CPPFLAGS/CFLAGS passed to libgc's configure
50 # libgc should inherit the original CFLAGS/CPPFLAGS passed to configure, i.e. -O0
51 CPPFLAGS_FOR_LIBGC=$CPPFLAGS
52 CFLAGS_FOR_LIBGC=$CFLAGS
53 CPPFLAGS_FOR_EGLIB=$CPPFLAGS
54 CFLAGS_FOR_EGLIB=$CFLAGS
55
56 #
57 # These are the flags that need to be stored in the mono.pc file for 
58 # compiling code that will embed Mono
59 #
60 libmono_cflags=""
61 libmono_ldflags=""
62 AC_SUBST(libmono_cflags)
63 AC_SUBST(libmono_ldflags)
64
65 # Variable to have relocatable .pc files (lib, or lib64)
66 reloc_libdir=`basename ${libdir}`
67 AC_SUBST(reloc_libdir)
68
69 dnl if linker handles the version script
70 no_version_script=no
71
72 # Set to yes if Unix sockets cannot be created in an anonymous namespace
73 need_link_unlink=no
74
75 #Set to extra linker flags to be passed to the runtime binaries (mono /mono-sgen)
76 extra_runtime_ldflags=""
77
78 # Thread configuration inspired by sleepycat's db
79 AC_MSG_CHECKING([host platform characteristics])
80 libgc_threads=no
81 has_dtrace=no
82 parallel_mark=yes
83 ikvm_native=yes
84
85 case "$host" in
86         powerpc*-*-linux*)
87                 # https://bugzilla.novell.com/show_bug.cgi?id=504411
88                 disable_munmap=yes
89         ;;
90 esac
91
92 host_win32=no
93 target_win32=no
94 platform_android=no
95 platform_darwin=no
96 case "$host" in
97         *-mingw*|*-*-cygwin*)
98                 AC_DEFINE(HOST_WIN32,1,[Host Platform is Win32])
99                 AC_DEFINE(DISABLE_PORTABILITY,1,[Disable the io-portability layer])
100                 AC_DEFINE(PLATFORM_NO_SYMLINKS,1,[This platform does not support symlinks])
101                 host_win32=yes
102                 mono_cv_clang=no
103                 if test "x$cross_compiling" = "xno"; then
104                         target_win32=yes
105                         if test "x$host" == "x$build" -a "x$host" == "x$target"; then
106                                 AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32])
107                         fi
108                         #
109                         # gcc-3/g++-3 are from the gcc-core/gcc-g++ cygwin packages.
110                         # Other gcc packages will not work:
111                         # - the gcc-4 packages no longer support -mno-cygwin
112                         # - the mingw-gcc packages produce executables which depends on a libgcc<...>
113                         # dll, which means we would have to distribute that file too.
114                         #
115                         if test "x$CC" != "x"; then
116                                 AC_ERROR(Don't set CC. mono can only be compiled with gcc-3 from the 'gcc-core' package)
117                         fi
118                         CC="gcc-3.exe -mno-cygwin -g"
119                         CXX="g++-3.exe -mno-cygwin -g"
120                         # So libgc configure gets -mno-cygwin
121                         export CC
122                         export CXX
123                         CFLAGS_FOR_EGLIB="$CFLAGS_FOR_EGLIB -mno-cygwin"
124                 else
125                         target_win32=yes
126                         AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32/MinGW])
127                         AC_DEFINE(MINGW_CROSS_COMPILE,1,[Cross-compiling using MinGW])
128                 fi
129                 HOST_CC="gcc"
130                 # Windows 2000 is required that includes Internet Explorer 5.01
131                 CPPFLAGS="$CPPFLAGS -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0501 -D_UNICODE -DUNICODE -DWIN32_THREADS -DFD_SETSIZE=1024"
132                 LDFLAGS="$LDFLAGS -lmswsock -lws2_32 -lole32 -loleaut32 -lpsapi -lversion -ladvapi32 -lwinmm -lkernel32"
133                 libmono_cflags="-mno-cygwin -mms-bitfields -mwindows"
134                 libmono_ldflags="-mno-cygwin -mms-bitfields -mwindows"
135                 libdl=
136                 libgc_threads=win32
137                 gc_default=included
138                 with_sigaltstack=no
139                 LN_S=cp
140                 # This forces libgc to use the DllMain based thread registration code on win32
141                 libgc_configure_args="$libgc_configure_args --enable-win32-dllmain=yes"
142                 ;;
143         *-*-*netbsd*)
144                 host_win32=no
145                 CPPFLAGS="$CPPFLAGS -D_REENTRANT -DGC_NETBSD_THREADS -D_GNU_SOURCE"
146                 libmono_cflags="-D_REENTRANT"
147                 LDFLAGS="$LDFLAGS -pthread"
148                 CPPFLAGS="$CPPFLAGS -DPLATFORM_BSD"
149                 libmono_ldflags="-pthread"
150                 need_link_unlink=yes
151                 libdl="-ldl"
152                 libgc_threads=pthreads
153                 with_sigaltstack=no
154                 use_sigposix=yes
155                 ;;
156         *-*-*freebsd*)
157                 host_win32=no
158                 if test "x$PTHREAD_CFLAGS" = "x"; then
159                         CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
160                         libmono_cflags=
161                 else
162                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
163                         libmono_cflags="$PTHREAD_CFLAGS"
164                 fi
165                 if test "x$PTHREAD_LIBS" = "x"; then
166                         LDFLAGS="$LDFLAGS -pthread -L/usr/local/lib"
167                         libmono_ldflags="-pthread"
168                 else
169                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS -L/usr/local/lib"
170                         libmono_ldflags="$PTHREAD_LIBS"
171                 fi
172                 CPPFLAGS="$CPPFLAGS -DPLATFORM_BSD"
173                 need_link_unlink=yes
174                 AC_DEFINE(PTHREAD_POINTER_ID, 1, [pthread is a pointer])
175                 libdl=
176                 libgc_threads=pthreads
177                 # This doesn't seem to work as of 7.0 on amd64
178                 with_sigaltstack=no
179                 use_sigposix=yes
180                 ;;
181         *-*-*openbsd*)
182                 host_win32=no
183                 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_OPENBSD_THREADS -DPLATFORM_BSD -D_REENTRANT -DUSE_MMAP"
184                 if test "x$disable_munmap" != "xyes"; then
185                 CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
186                 fi
187                 libmono_cflags="-D_THREAD_SAFE -D_REENTRANT"
188                 LDFLAGS="$LDFLAGS -pthread"
189                 need_link_unlink=yes
190                 AC_DEFINE(PTHREAD_POINTER_ID)
191                 libdl=
192                 gc_default=boehm
193                 libgc_threads=pthreads
194                 with_sigaltstack=no
195                 use_sigposix=yes
196                 ;;
197         *-*-linux-android*)
198                 host_win32=no
199                 platform_android=yes
200                 AC_DEFINE(PLATFORM_ANDROID,1,[Targeting the Android platform])
201                 AC_DEFINE(TARGET_ANDROID,1,[Targeting the Android platform])
202
203                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
204                 if test "x$disable_munmap" != "xyes"; then
205                         CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
206                 fi
207                 libmono_cflags="-D_REENTRANT"
208                 libdl="-ldl"
209                 libgc_threads=pthreads
210                 use_sigposix=yes
211
212                 with_tls=pthread
213                 with_sigaltstack=no
214                 with_static_mono=no
215
216                 # Android doesn't support boehm, as it's missing <link.h>
217                 support_boehm=no
218                 with_gc=sgen
219
220                 # isinf(3) requires -lm; see isinf check below
221                 LDFLAGS="$LDFLAGS -lm"
222
223                 # Bionic's <pthread.h> sets PTHREAD_STACK_MIN=2*PAGE_SIZE; doesn't define
224                 # PAGE_SIZE; breaks mono/io-layer/collection.c
225                 # Bionic doesn't provide S_IWRITE; breaks io-layer/io.c
226                 CFLAGS="$CFLAGS -DPAGE_SIZE=4096 -DS_IWRITE=S_IWUSR"
227                 CXXFLAGS="$CXXFLAGS -DPAGE_SIZE=4096 -DS_IWRITE=S_IWUSR"
228
229                 # to bypass the underscore linker check, can't work when cross-compiling
230                 mono_cv_uscore=yes
231                 mono_cv_clang=no
232                 ;;
233         *-*-linux*)
234                 host_win32=no
235                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
236                 if test "x$disable_munmap" != "xyes"; then
237                         CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
238                 fi
239                 libmono_cflags="-D_REENTRANT"
240                 libdl="-ldl"
241                 libgc_threads=pthreads
242                 use_sigposix=yes
243                 if test "x$cross_compiling" != "xno"; then
244                         # to bypass the underscore linker check, not
245                         # available during cross-compilation
246                         mono_cv_uscore=no
247                 fi
248                 ;;
249         *-*-nacl*)
250                 host_win32=no
251                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
252                 if test "x$disable_munmap" != "xyes"; then
253                         CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
254                 fi
255                 libmono_cflags="-D_REENTRANT"
256                 libdl=
257                 libgc_threads=pthreads
258                 gc_default=boehm
259                 use_sigposix=yes
260                 ikvm_native=no
261                 AC_DEFINE(DISABLE_SOCKETS,1,[Disable sockets support])
262                 AC_DEFINE(DISABLE_ATTACH, 1, [Disable agent attach support])
263                 ;;
264         *-*-hpux*)
265                 host_win32=no
266                 CPPFLAGS="$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
267                 # +ESdbgasm only valid on bundled cc on RISC
268                 # silently ignored for ia64
269                 if test $GCC != "yes"; then
270                         CFLAGS="$CFLAGS +ESdbgasm"
271                         # Arrange for run-time dereferencing of null
272                         # pointers to produce a SIGSEGV signal.
273                         LDFLAGS="$LDFLAGS -z"
274                 fi
275                 CFLAGS="$CFLAGS +ESdbgasm"
276                 LDFLAGS="$LDFLAGS -z"
277                 libmono_cflags="-D_REENTRANT"
278                 libmono_ldflags="-lpthread"
279                 libgc_threads=pthreads
280                 need_link_unlink=yes
281                 use_sigposix=yes
282                 ;;
283         *-*-solaris*)
284                 host_win32=no
285                 CPPFLAGS="$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP -DPLATFORM_SOLARIS"
286                 need_link_unlink=yes
287                 libmono_cflags="-D_REENTRANT"
288                 libgc_threads=pthreads
289                 # This doesn't seem to work on solaris/x86, but the configure test runs
290                 with_tls=pthread
291                 has_dtrace=yes
292                 use_sigposix=yes
293                 enable_solaris_tar_check=yes
294                 ;;
295         *-*-darwin*)
296                 parallel_mark="Disabled_Currently_Hangs_On_MacOSX"
297                 host_win32=no
298                 platform_darwin=yes
299                 target_mach=yes
300                 CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE -DGC_MACOSX_THREADS -DPLATFORM_MACOSX -DUSE_MMAP -DUSE_MUNMAP"
301                 CPPFLAGS="$CPPFLAGS -DGetCurrentProcess=MonoGetCurrentProcess -DGetCurrentThread=MonoGetCurrentThread -DCreateEvent=MonoCreateEvent"
302                 libmono_cflags="-D_THREAD_SAFE"
303                 need_link_unlink=yes
304                 AC_DEFINE(PTHREAD_POINTER_ID)
305                 AC_DEFINE(USE_MACH_SEMA, 1, [...])
306                 no_version_script=yes
307                 libdl=
308                 libgc_threads=pthreads
309                 has_dtrace=yes
310                 if test "x$cross_compiling" = "xyes"; then
311                         has_broken_apple_cpp=yes
312                 fi
313                 dnl Snow Leopard is horribly broken -- it reports itself as i386-apple-darwin*, but
314                 dnl its gcc defaults to 64-bit mode.  They have also deprecated the usage of ucontext
315                 dnl we need to set some flags to build our 32-bit binaries on 10.6 properly
316                 case "$host" in
317                         dnl Snow Leopard and newer config.guess reports as this
318                         i*86-*-darwin*)
319                                 BROKEN_DARWIN_FLAGS="-arch i386 -D_XOPEN_SOURCE"
320                                 BROKEN_DARWIN_CPPFLAGS="-D_XOPEN_SOURCE"
321                                 CPPFLAGS="$CPPFLAGS $BROKEN_DARWIN_CPPFLAGS"
322                                 CFLAGS="$CFLAGS $BROKEN_DARWIN_FLAGS"
323                                 CXXFLAGS="$CXXFLAGS $BROKEN_DARWIN_FLAGS"
324                                 CCASFLAGS="$CCASFLAGS $BROKEN_DARWIN_FLAGS"
325                                 CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC $BROKEN_DARWIN_CPPFLAGS"
326                                 CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC $BROKEN_DARWIN_FLAGS"
327                                 CPPFLAGS_FOR_EGLIB="$CPPFLAGS_FOR_EGLIB $BROKEN_DARWIN_CPPFLAGS"
328                                 CFLAGS_FOR_EGLIB="$CFLAGS_FOR_EGLIB $BROKEN_DARWIN_FLAGS"
329                                 extra_runtime_ldflags="-stack_size,0x800000"
330                                 ;;
331                         x*64-*-darwin*)
332                                 extra_runtime_ldflags="-stack_size,0x800000"
333                                 ;;
334                         arm*-darwin*)
335                                 has_dtrace=no
336                                 ;;                      
337                 esac
338                 ;;
339         *-*-haiku*)
340                 host_win32=no
341                 CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
342                 libmono_cflags="-D_REENTRANT -D_THREAD_SAFE"
343                 libdl=
344                 LIBS="$LIBS -lnetwork"
345                 need_link_unlink=yes
346                 AC_DEFINE(PTHREAD_POINTER_ID)
347                 libgc_threads=pthreads
348                 use_sigposix=yes
349                 ;;
350         *)
351                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
352                 host_win32=no
353                 libdl="-ldl"
354                 ;;
355 esac
356 AC_MSG_RESULT(ok)
357
358 if test x$need_link_unlink = xyes; then
359    AC_DEFINE(NEED_LINK_UNLINK, 1, [Define if Unix sockets cannot be created in an anonymous namespace])
360 fi
361
362 AC_SUBST(extra_runtime_ldflags)
363 AM_CONDITIONAL(HOST_WIN32, test x$host_win32 = xyes)
364 AM_CONDITIONAL(TARGET_WIN32, test x$target_win32 = xyes)
365 AM_CONDITIONAL(PLATFORM_LINUX, echo x$target_os | grep -q linux)
366 AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
367 AM_CONDITIONAL(PLATFORM_SIGPOSIX, test x$use_sigposix = xyes)
368 AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
369
370 AC_CHECK_TOOL(CC, gcc, gcc)
371 AC_PROG_CC
372 AC_CHECK_TOOL(CXX, g++, g++)
373 AC_PROG_CXX
374 AM_PROG_AS
375 AC_PROG_INSTALL
376 AC_PROG_AWK
377 dnl We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
378 : ${CCAS='$(CC)'}
379 # Set ASFLAGS if not already set.
380 : ${CCASFLAGS='$(CFLAGS)'}
381 AC_SUBST(CCAS)
382 AC_SUBST(CCASFLAGS)
383
384 # AC_PROG_CXX helpfully sets CXX to g++ even if no c++ compiler is found so check
385 # GXX instead. See http://lists.gnu.org/archive/html/bug-autoconf/2002-04/msg00056.html
386 if test "x$CXX" = "xg++"; then
387         if test "x$GXX" != "xyes"; then
388                 # automake/libtool is so broken, it requires g++ even if the c++ sources
389                 # are inside automake conditionals
390                 AC_MSG_ERROR([You need to install g++])
391         fi
392 fi
393
394 dnl may require a specific autoconf version
395 dnl AC_PROG_CC_FOR_BUILD
396 dnl CC_FOR_BUILD not automatically detected
397 CC_FOR_BUILD=$CC
398 CFLAGS_FOR_BUILD=$CFLAGS
399 BUILD_EXEEXT=
400 if test "x$cross_compiling" = "xyes"; then
401         CC_FOR_BUILD=cc
402         CFLAGS_FOR_BUILD=
403         BUILD_EXEEXT=""
404 fi
405 AC_SUBST(CC_FOR_BUILD)
406 AC_SUBST(CFLAGS_FOR_BUILD)
407 AC_SUBST(HOST_CC)
408 AC_SUBST(BUILD_EXEEXT)
409
410 AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
411 AM_CONDITIONAL(USE_BATCH_FILES, [test x$host_win32 = xyes -a x$cross_compiling = xyes])
412
413 # Set STDC_HEADERS
414 AC_HEADER_STDC
415 AC_LIBTOOL_WIN32_DLL
416 # This causes monodis to not link correctly
417 #AC_DISABLE_FAST_INSTALL
418 AM_PROG_LIBTOOL
419 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
420 DOLT
421
422 export_ldflags=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
423 AC_SUBST(export_ldflags)
424
425 # Test whenever ld supports -version-script
426 AC_PROG_LD
427 AC_PROG_LD_GNU
428 if test "x$lt_cv_prog_gnu_ld" = "xno"; then
429    no_version_script=yes
430 fi
431
432 AM_ICONV()
433
434 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
435
436 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 sys/uio.h sys/param.h libproc.h)
437 AC_CHECK_HEADERS(sys/param.h sys/socket.h sys/ipc.h sys/sem.h sys/utsname.h alloca.h ucontext.h pwd.h sys/select.h netinet/tcp.h netinet/in.h unistd.h sys/types.h link.h asm/sigcontext.h sys/inotify.h)
438 AC_CHECK_HEADERS([linux/netlink.h linux/rtnetlink.h],
439                   [], [], [#include <stddef.h>
440                   #include <sys/socket.h>
441                   #include <linux/socket.h>])
442
443 AC_CHECK_HEADERS(sys/user.h, [], [],
444 [
445 #ifdef HAVE_SYS_PARAM_H
446 # include <sys/param.h>
447 #endif
448 ])
449
450 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
451 if test x$have_zlib = xyes; then
452    AC_TRY_COMPILE([#include <zlib.h>], [
453    #if defined(ZLIB_VERNUM) && (ZLIB_VERNUM >= 0x1230)
454    return 0;
455    #else
456    #error No good zlib found
457    #endif
458    ],[
459         AC_MSG_RESULT(Using system zlib)
460         zlib_msg="system zlib"
461         AC_DEFINE(HAVE_SYS_ZLIB,1,[Have system zlib])
462    ],[
463         AC_MSG_RESULT(Using embedded zlib)
464         have_zlib=no
465         zlib_msg="bundled zlib"
466    ])
467 fi
468
469 AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
470 AC_DEFINE(HAVE_ZLIB,1,[Have system zlib])
471
472 # for mono/metadata/debug-symfile.c
473 AC_CHECK_HEADERS(elf.h)
474
475 # for support
476 AC_CHECK_HEADERS(poll.h)
477 AC_CHECK_HEADERS(sys/poll.h)
478 AC_CHECK_HEADERS(sys/wait.h)
479 AC_CHECK_HEADERS(grp.h)
480 AC_CHECK_HEADERS(syslog.h)
481
482 # for mono/dis
483 AC_CHECK_HEADERS(wchar.h)
484 AC_CHECK_HEADERS(ieeefp.h)
485 AC_MSG_CHECKING(for isinf)
486 AC_TRY_LINK([#include <math.h>], [
487         int f = isinf (1);
488 ], [
489         AC_MSG_RESULT(yes)
490         AC_DEFINE(HAVE_ISINF, 1, [isinf available])
491 ], [
492         # We'll have to use signals
493         AC_MSG_RESULT(no)
494 ])
495
496 # for Linux statfs support
497 AC_CHECK_HEADERS(linux/magic.h)
498
499 # not 64 bit clean in cross-compile
500 AC_CHECK_SIZEOF(void *, 4)
501
502 AC_CACHE_CHECK([for clang],
503         mono_cv_clang,[
504         AC_TRY_COMPILE([], [
505                 #ifdef __clang__
506                 #else
507                 #error "FAILED"
508                 #endif
509                 return 0;
510         ],
511         [mono_cv_clang=yes],
512         [mono_cv_clang=no],
513         [])
514 ])
515
516 WARN=''
517 if test x"$GCC" = xyes; then
518         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value'
519                 # The runtime code does not respect ANSI C strict aliasing rules
520                 CFLAGS="$CFLAGS -fno-strict-aliasing"
521
522                 ORIG_CFLAGS=$CFLAGS
523                 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
524                 AC_MSG_CHECKING(for -Wdeclaration-after-statement option to gcc)
525                 AC_TRY_COMPILE([],[
526                                 return 0;
527                 ], [
528                    AC_MSG_RESULT(yes)
529                 ], [
530                    AC_MSG_RESULT(no)
531                    CFLAGS=$ORIG_CFLAGS
532                 ])
533
534                 ORIG_CFLAGS=$CFLAGS
535                 # Check for the normal version, since gcc ignores unknown -Wno options
536                 CFLAGS="$CFLAGS -Wunused-but-set-variable -Werror"
537                 AC_MSG_CHECKING(for -Wno-unused-but-set-variable option to gcc)
538                 AC_TRY_COMPILE([],[
539                                 return 0;
540                 ], [
541                    AC_MSG_RESULT(yes)
542                    CFLAGS="$ORIG_CFLAGS -Wno-unused-but-set-variable"
543                 ], [
544                    AC_MSG_RESULT(no)
545                    CFLAGS=$ORIG_CFLAGS
546                 ])
547
548                 if test "x$mono_cv_clang" = "xyes"; then
549                    # https://bugzilla.samba.org/show_bug.cgi?id=8118
550                    WARN="$WARN -Qunused-arguments"
551                    WARN="$WARN -Wno-unused-function -Wno-tautological-compare"
552                 fi
553 else
554         # The Sun Forte compiler complains about inline functions that access static variables
555         # so disable all inlining.
556         case "$host" in
557         *-*-solaris*)
558                 CFLAGS="$CFLAGS -Dinline="
559                 ;;
560         esac
561 fi
562 CFLAGS="$CFLAGS -g $WARN"
563 CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -g"
564
565 # Where's the 'mcs' source tree?
566 if test -d $srcdir/mcs; then
567   mcsdir=mcs
568 else
569   mcsdir=../mcs
570 fi
571
572 AC_ARG_WITH(mcs-path, [  --with-mcs-path=/path/to/mcs      Specify an alternate mcs source tree],
573         if test x$with_mcs_path != "x" -a -d $with_mcs_path ; then
574                 mcsdir=$with_mcs_path
575         fi
576 )
577
578 AC_ARG_WITH(jumptables, [  --with-jumptables=yes,no      enable/disable support for jumptables (ARM-only for now) (defaults to no)],[],[with_jumptables=no])
579
580 #
581 # A sanity check to catch cases where the package was unpacked
582 # with an ancient tar program (Solaris)
583 #
584 AC_ARG_ENABLE(solaris-tar-check,
585 [  --disable-solaris-tar-check    disable solaris tar check],
586    do_solaris_tar_check=no, do_solaris_tar_check=yes)
587
588 if test x"$do_solaris_tar_check" = xyes -a x"$enable_solaris_tar_check" = xyes; then
589         AC_MSG_CHECKING(integrity of package)
590         if test -f $mcsdir/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapTypeMapper.cs
591         then
592                 AC_MSG_RESULT(ok)
593         else
594                 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"
595                 AC_MSG_ERROR([$errorm])
596         fi
597 fi
598
599 if test "x$with_mcs_path" != "x"; then
600 mcs_topdir=$(cd "$mcsdir" && pwd)
601 mcs_topdir_from_srcdir=$mcs_topdir
602 else
603 mcs_topdir=$(cd "$srcdir/$mcsdir" && pwd)
604 mcs_topdir_from_srcdir='$(top_builddir)'/$mcsdir
605 fi
606
607 # Convert mcs_topdir* paths to Windows syntax.
608 if test x$cross_compiling$host_win32 = xnoyes; then
609   mcs_topdir=$(cygpath -m $mcs_topdir)
610   case $mcs_topdir_from_srcdir in
611     /cygdrive/*)
612         mcs_topdir_from_srcdir=$(cygpath -m $mcs_topdir_from_srcdir)
613         ;;
614   esac
615 fi
616
617 AC_SUBST([mcs_topdir])
618 AC_SUBST([mcs_topdir_from_srcdir])
619
620 # Where's the 'olive' source tree?
621 if test -d $srcdir/olive; then
622   olivedir=olive
623 else
624   olivedir=../olive
625 fi
626
627 if test -d $srcdir/$olivedir; then
628 olive_topdir='$(top_srcdir)/'$olivedir
629 fi
630
631 # gettext: prepare the translation directories. 
632 # we do not configure the full gettext, as we consume it dynamically from C#
633 AM_PO_SUBDIRS
634
635 if test "x$USE_NLS" = "xyes"; then
636    AC_CHECK_PROG(HAVE_MSGFMT, msgfmt,yes,no)
637
638    if test "x$HAVE_MSGFMT" = "xno"; then
639           AC_MSG_ERROR([msgfmt not found. You need to install the 'gettext' package, or pass --enable-nls=no to configure.])
640    fi
641 fi
642
643 AC_ARG_WITH([libgdiplus], 
644         [  --with-libgdiplus=installed|sibling|<path>   Override the libgdiplus used for System.Drawing tests (defaults to installed)], 
645         [], [with_libgdiplus=installed])
646
647 case $with_libgdiplus in
648 no|installed) libgdiplus_loc= ;;
649 yes|sibling) libgdiplus_loc=`cd ../libgdiplus && pwd`/src/libgdiplus.la ;;
650 /*) libgdiplus_loc=$with_libgdiplus ;;
651 *) libgdiplus_loc=`pwd`/$with_libgdiplus ;;
652 esac
653 AC_SUBST([libgdiplus_loc])
654
655 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
656
657 pkg_config_path=
658 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir      Change pkg-config dir to custom dir],
659         if test x$with_crosspkgdir = "x"; then
660                 if test -s $PKG_CONFIG_PATH; then
661                         pkg_config_path=$PKG_CONFIG_PATH
662                 fi
663         else
664                 pkg_config_path=$with_crosspkgdir
665                 PKG_CONFIG_PATH=$pkg_config_path
666                 export PKG_CONFIG_PATH
667         fi
668 )
669
670 ac_configure_args="$ac_configure_args \"CPPFLAGS_FOR_EGLIB=$EGLIB_CPPFLAGS\" \"CFLAGS_FOR_EGLIB=$CFLAGS_FOR_EGLIB\""
671 AC_CONFIG_SUBDIRS(eglib)
672
673 GLIB_CFLAGS='-I$(top_srcdir)/eglib/src -I$(top_builddir)/eglib/src'
674 GLIB_LIBS='-L$(top_builddir)/eglib/src -leglib -lm'
675 BUILD_GLIB_CFLAGS="$GLIB_CFLAGS"
676 BUILD_GLIB_LIBS="$GLIB_LIBS"
677 GMODULE_CFLAGS="$GLIB_CFLAGS"
678 GMODULE_LIBS="$GLIB_LIBS"
679   
680 AC_SUBST(GLIB_CFLAGS)
681 AC_SUBST(GLIB_LIBS)
682 AC_SUBST(GMODULE_CFLAGS)
683 AC_SUBST(GMODULE_LIBS)
684 AC_SUBST(BUILD_GLIB_CFLAGS)
685 AC_SUBST(BUILD_GLIB_LIBS)
686
687 AC_ARG_WITH(gc,   [  --with-gc=boehm,included,none  Controls the Boehm GC config, default=included],[gc=$with_gc],[gc=$gc_default])
688
689 # Enable support for fast thread-local storage
690 # Some systems have broken support, so we allow to disable it.
691 AC_ARG_WITH(tls, [  --with-tls=__thread,pthread    select Thread Local Storage implementation (defaults to __thread)],[],[with_tls=__thread])
692
693 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
694 # This does not work on some platforms (bug #55253)
695 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack (defaults to yes)],[],[with_sigaltstack=yes])
696
697 AC_ARG_WITH(static_mono, [  --with-static_mono=yes,no      link mono statically to libmono (faster) (defaults to yes)],[],[with_static_mono=yes])
698 AC_ARG_WITH(shared_mono, [  --with-shared_mono=yes,no      build a shared libmono library (defaults to yes)],[],[with_shared_mono=yes])
699 # Same as --with-shared_mono=no
700 AC_ARG_ENABLE(libraries, [  --disable-libraries disable the build of libmono], enable_libraries=$enableval, enable_libraries=yes)
701
702 if test "x$enable_static" = "xno"; then
703    with_static_mono=no
704 fi
705
706 if test "x$enable_shared" = "xno"; then
707    with_shared_mono=no
708 fi
709
710 if test "x$enable_libraries" = "xno"; then
711    with_shared_mono=no
712 fi
713
714 AM_CONDITIONAL(DISABLE_LIBRARIES, test x$enable_libraries = xno)
715
716 case $host in
717 *nacl* ) with_shared_mono=yes;;
718 esac
719
720 if test "x$host_win32" = "xyes"; then
721    # Boehm GC requires the runtime to be in its own dll
722    with_static_mono=no
723 fi
724
725 AM_CONDITIONAL(STATIC_MONO, test x$with_static_mono != xno)
726 AM_CONDITIONAL(SHARED_MONO, test x$with_shared_mono != xno)
727 AC_ARG_ENABLE(mcs-build, [  --disable-mcs-build disable the build of the mcs directory], try_mcs_build=$enableval, enable_mcs_build=yes)
728
729 AC_ARG_WITH(xen_opt,   [  --with-xen_opt=yes,no          Enable Xen-specific behaviour (defaults to yes)],[],[with_xen_opt=yes])
730 if test "x$with_xen_opt" = "xyes" -a "x$mono_cv_clang" = "xno"; then
731         AC_DEFINE(MONO_XEN_OPT, 1, [Xen-specific behaviour])
732         ORIG_CFLAGS=$CFLAGS
733         CFLAGS="$CFLAGS -mno-tls-direct-seg-refs"
734         AC_MSG_CHECKING(for -mno-tls-direct-seg-refs option to gcc)
735         AC_TRY_COMPILE([], [
736                 return 0;
737         ], [
738            AC_MSG_RESULT(yes)
739            # Pass it to libgc as well
740            CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -mno-tls-direct-seg-refs"
741         ], [
742            AC_MSG_RESULT(no)
743            CFLAGS=$ORIG_CFLAGS
744         ])
745 fi
746
747 AC_ARG_ENABLE(small-config, [  --enable-small-config Enable tweaks to reduce requirements (and capabilities)], enable_small_config=$enableval, enable_small_config=no)
748
749 if test x$enable_small_config = xyes; then
750         AC_DEFINE(MONO_SMALL_CONFIG,1,[Reduce runtime requirements (and capabilities)])
751         CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DSMALL_CONFIG"
752 fi
753
754 AC_ARG_ENABLE(system-aot, [  --enable-system-aot  Enable the Ahead-Of-Time compilation of system assemblies during the build (on by default on some platforms)], enable_system_aot=$enableval, enable_system_aot=default)
755
756 DISABLED_FEATURES=none
757
758 AC_ARG_ENABLE(minimal, [  --enable-minimal=LIST      drop support for LIST subsystems.
759      LIST is a comma-separated list from: aot, profiler, decimal, pinvoke, debug, appdomains, verifier, 
760      reflection_emit, reflection_emit_save, large_code, logging, com, ssa, generics, attach, jit, simd, soft_debug, perfcounters, normalization, assembly_remapping, shared_perfcounters, remoting,
761          security, sgen_remset, sgen_marksweep_par, sgen_marksweep_fixed, sgen_marksweep_fixed_par, sgen_copying.],
762 [
763         for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
764                 eval "mono_feature_disable_$feature='yes'"
765         done
766         DISABLED_FEATURES=$enable_minimal
767         disabled="Disabled:      $enable_minimal"
768 ],[])
769
770 AC_DEFINE_UNQUOTED(DISABLED_FEATURES, "$DISABLED_FEATURES", [String of disabled features])
771
772 if test "x$mono_feature_disable_aot" = "xyes"; then
773         AC_DEFINE(DISABLE_AOT_COMPILER, 1, [Disable AOT Compiler])
774         AC_MSG_NOTICE([Disabled AOT compiler])
775 fi
776
777 if test "x$mono_feature_disable_profiler" = "xyes"; then
778         AC_DEFINE(DISABLE_PROFILER, 1, [Disable default profiler support])
779         AC_MSG_NOTICE([Disabled support for the profiler])
780 fi
781 AM_CONDITIONAL(DISABLE_PROFILER, test x$mono_feature_disable_profiler = xyes)
782
783 if test "x$mono_feature_disable_decimal" = "xyes"; then
784         AC_DEFINE(DISABLE_DECIMAL, 1, [Disable System.Decimal support])
785         AC_MSG_NOTICE([Disabled support for decimal])
786 fi
787
788 if test "x$mono_feature_disable_pinvoke" = "xyes"; then
789         AC_DEFINE(DISABLE_PINVOKE, 1, [Disable P/Invoke support])
790         AC_MSG_NOTICE([Disabled support for P/Invoke])
791 fi
792
793 if test "x$mono_feature_disable_debug" = "xyes"; then
794         AC_DEFINE(DISABLE_DEBUG, 1, [Disable runtime debugging support])
795         AC_MSG_NOTICE([Disabled support for runtime debugging])
796 fi
797
798 if test "x$mono_feature_disable_reflection_emit" = "xyes"; then
799         AC_DEFINE(DISABLE_REFLECTION_EMIT, 1, [Disable reflection emit support])
800         mono_feature_disable_reflection_emit_save=yes
801         AC_MSG_NOTICE([Disabled support for Reflection.Emit])
802 fi
803
804 if test "x$mono_feature_disable_reflection_emit_save" = "xyes"; then
805         AC_DEFINE(DISABLE_REFLECTION_EMIT_SAVE, 1, [Disable assembly saving support in reflection emit])
806         AC_MSG_NOTICE([Disabled support for Reflection.Emit.Save])
807 fi
808
809 if test "x$mono_feature_disable_large_code" = "xyes"; then
810         AC_DEFINE(DISABLE_LARGE_CODE, 1, [Disable support for huge assemblies])
811         AC_MSG_NOTICE([Disabled support for large assemblies])
812 fi
813
814 if test "x$mono_feature_disable_logging" = "xyes"; then
815         AC_DEFINE(DISABLE_LOGGING, 1, [Disable support debug logging])
816         AC_MSG_NOTICE([Disabled support for logging])
817 fi
818
819 if test "x$mono_feature_disable_com" = "xyes"; then
820         AC_DEFINE(DISABLE_COM, 1, [Disable COM support])
821         AC_MSG_NOTICE([Disabled 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         AC_MSG_NOTICE([Disabled SSA JIT optimizations])
827 fi
828
829 if test "x$mono_feature_disable_generics" = "xyes"; then
830         AC_DEFINE(DISABLE_GENERICS, 1, [Disable generics support])
831         AC_MSG_NOTICE([Disabled Generics Support])
832 fi
833
834 if test "x$mono_feature_disable_shadowcopy" = "xyes"; then
835         AC_DEFINE(DISABLE_SHADOW_COPY, 1, [Disable Shadow Copy for AppDomains])
836         AC_MSG_NOTICE([Disabled Shadow copy for AppDomains])
837 fi
838
839 if test "x$mono_feature_disable_portability" = "xyes"; then
840         AC_DEFINE(DISABLE_PORTABILITY, 1, [Disables the IO portability layer])
841         AC_MSG_NOTICE([Disabled IO Portability layer])
842 fi
843
844 if test "x$mono_feature_disable_attach" = "xyes"; then
845         AC_DEFINE(DISABLE_ATTACH, 1, [Disable agent attach support])
846         AC_MSG_NOTICE([Disabled agent attach])
847 fi
848
849 if test "x$mono_feature_disable_full_messages" = "xyes"; then
850         AC_DEFINE(DISABLE_FULL_MESSAGES, 1, [Disables building in the full table of WAPI messages])
851         AC_MSG_NOTICE([Disabled full messages for Win32 errors, only core message strings shipped])
852 fi
853
854 if test "x$mono_feature_disable_verifier" = "xyes"; then
855         AC_DEFINE(DISABLE_VERIFIER, 1, [Disables the verifier])
856         AC_MSG_NOTICE([Disabled the metadata and IL verifiers])
857 fi
858
859 if test "x$mono_feature_disable_jit" = "xyes"; then
860         AC_DEFINE(DISABLE_JIT, 1, [Disable the JIT, only full-aot mode will be supported by the runtime.])
861         AC_MSG_NOTICE([Disabled the JIT engine, only full AOT will be supported])
862 fi
863
864 AM_CONDITIONAL(DISABLE_JIT, test x$mono_feature_disable_jit = xyes)
865
866 if test "x$mono_feature_disable_simd" = "xyes"; then
867         AC_DEFINE(DISABLE_SIMD, 1, [Disable SIMD intrinsics related optimizations.])
868         AC_MSG_NOTICE([Disabled SIMD support])
869 fi
870
871 if test "x$mono_feature_disable_soft_debug" = "xyes"; then
872         AC_DEFINE(DISABLE_SOFT_DEBUG, 1, [Disable Soft Debugger Agent.])
873         AC_MSG_NOTICE([Disabled Soft Debugger.])
874 fi
875
876 if test "x$mono_feature_disable_perfcounters" = "xyes"; then
877         AC_DEFINE(DISABLE_PERFCOUNTERS, 1, [Disable Performance Counters.])
878         AC_MSG_NOTICE([Disabled Performance Counters.])
879 fi
880 if test "x$mono_feature_disable_normalization" = "xyes"; then
881         AC_DEFINE(DISABLE_NORMALIZATION, 1, [Disable String normalization support.])
882         AC_MSG_NOTICE([Disabled String normalization support.])
883 fi
884
885 if test "x$mono_feature_disable_assembly_remapping" = "xyes"; then
886         AC_DEFINE(DISABLE_ASSEMBLY_REMAPPING, 1, [Disable assembly remapping.])
887         AC_MSG_NOTICE([Disabled Assembly remapping.])
888 fi
889
890 if test "x$mono_feature_disable_shared_perfcounters" = "xyes"; then
891         AC_DEFINE(DISABLE_SHARED_PERFCOUNTERS, 1, [Disable shared perfcounters.])
892         AC_MSG_NOTICE([Disabled Shared perfcounters.])
893 fi
894
895 if test "x$mono_feature_disable_appdomains" = "xyes"; then
896         AC_DEFINE(DISABLE_APPDOMAINS, 1, [Disable support for multiple appdomains.])
897         AC_MSG_NOTICE([Disabled support for multiple appdomains.])
898 fi
899
900 if test "x$mono_feature_disable_remoting" = "xyes"; then
901         AC_DEFINE(DISABLE_REMOTING, 1, [Disable remoting support (This disables type proxies and make com non-functional)])
902         AC_MSG_NOTICE([Disabled remoting])
903 fi
904
905 if test "x$mono_feature_disable_security" = "xyes"; then
906         AC_DEFINE(DISABLE_SECURITY, 1, [Disable CAS/CoreCLR security])
907         AC_MSG_NOTICE([Disabled CAS/CoreCLR security manager (used e.g. for Moonlight)])
908 fi
909
910 if test "x$mono_feature_disable_sgen_remset" = "xyes"; then
911         AC_DEFINE(DISABLE_SGEN_REMSET, 1, [Disable wbarrier=remset support in SGEN.])
912         AC_MSG_NOTICE([Disabled wbarrier=remset support in SGEN.])
913 fi
914
915 if test "x$mono_feature_disable_sgen_marksweep_par" = "xyes"; then
916         AC_DEFINE(DISABLE_SGEN_MAJOR_MARKSWEEP_PAR, 1, [Disable major=marksweep-par support in SGEN.])
917         AC_MSG_NOTICE([Disabled major=marksweep-par support in SGEN.])
918 fi
919
920 if test "x$mono_feature_disable_sgen_marksweep_fixed" = "xyes"; then
921         AC_DEFINE(DISABLE_SGEN_MAJOR_MARKSWEEP_FIXED, 1, [Disable major=marksweep-fixed support in SGEN.])
922         AC_MSG_NOTICE([Disabled major=marksweep-fixed support in SGEN.])
923 fi
924
925 if test "x$mono_feature_disable_sgen_marksweep_fixed_par" = "xyes"; then
926         AC_DEFINE(DISABLE_SGEN_MAJOR_MARKSWEEP_FIXED_PAR, 1, [Disable major=marksweep-fixed-par support in SGEN.])
927         AC_MSG_NOTICE([Disabled major=marksweep-fixed-par support in SGEN.])
928 fi
929
930 if test "x$mono_feature_disable_sgen_copying" = "xyes"; then
931         AC_DEFINE(DISABLE_SGEN_MAJOR_COPYING, 1, [Disable major=copying support in SGEN.])
932         AC_MSG_NOTICE([Disabled major=copying support in SGEN.])
933 fi
934
935 AC_ARG_ENABLE(executables, [  --disable-executables disable the build of the runtime executables], enable_executables=$enableval, enable_executables=yes)
936 AM_CONDITIONAL(DISABLE_EXECUTABLES, test x$enable_executables = xno)
937
938 AC_ARG_ENABLE(extension-module, [  --enable-extension-module enables usage of the extension module], has_extension_module=$enableval, has_extension_module=no)
939 AM_CONDITIONAL([HAS_EXTENSION_MODULE], [test x$has_extension_module != xno])
940
941 if test x$has_extension_module != xno ; then
942         AC_DEFINE([ENABLE_EXTENSION_MODULE], 1, [Extension module enabled])
943         AC_MSG_NOTICE([Enabling mono extension module.])
944 fi
945
946
947 AC_MSG_CHECKING(for visibility __attribute__)
948 AC_COMPILE_IFELSE([
949         AC_LANG_SOURCE([[
950                 void __attribute__ ((visibility ("hidden"))) doit (void) {}
951                 int main () { doit (); return 0; }
952         ]])
953 ], [
954    have_visibility_hidden=yes
955    AC_MSG_RESULT(yes)
956 ], [
957    have_visibility_hidden=no
958    AC_MSG_RESULT(no)
959 ])
960
961 AC_MSG_CHECKING(for deprecated __attribute__)
962 AC_TRY_COMPILE([
963      int doit (void) __attribute__ ((deprecated));
964      int doit (void) { return 0; }
965 ], [
966         return 0;
967 ], [
968    have_deprecated=yes
969    AC_MSG_RESULT(yes)
970 ], [
971    have_deprecated=no
972    AC_MSG_RESULT(no)
973 ])
974
975 AC_ARG_ENABLE(parallel-mark, [  --enable-parallel-mark     Enables GC Parallel Marking], enable_parallel_mark=$enableval, enable_parallel_mark=$parallel_mark)
976 if test x$enable_parallel_mark = xyes; then
977         libgc_configure_args="$libgc_configure_args --enable-parallel-mark"
978 fi
979
980 AC_ARG_ENABLE(boehm, [  --disable-boehm            Disable the Boehm GC.], support_boehm=$enableval,support_boehm=${support_boehm:-yes})
981 AM_CONDITIONAL(SUPPORT_BOEHM, test x$support_boehm = xyes)
982
983 dnl
984 dnl Boehm GC configuration
985 dnl
986 LIBGC_CPPFLAGS=
987 LIBGC_LIBS=
988 LIBGC_STATIC_LIBS=
989 libgc_dir=
990 case "x$gc" in
991         xboehm|xbohem|xyes)
992                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
993                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
994
995                 if test "x$found_boehm" != "xyes"; then
996                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
997                 fi
998                 if test "x$gc_headers" != "xyes"; then
999                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
1000                 fi
1001
1002                 LIBGC_LIBS="-lgc $libdl"
1003                 LIBGC_STATIC_LIBS="$LIBGC_LIBS"
1004                 libmono_ldflags="$libmono_ldflags -lgc"
1005                 BOEHM_DEFINES="-DHAVE_BOEHM_GC"
1006
1007                 # AC_CHECK_FUNCS does not work for some reason...
1008                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
1009                 if test "x$found_gcj_malloc" = "xyes"; then
1010                         BOEHM_DEFINES="-DHAVE_GC_GCJ_MALLOC $BOEHM_DEFINES"
1011                         AC_DEFINE_UNQUOTED(DEFAULT_GC_NAME, "System Boehm (with typed GC)", [GC description])
1012                         gc_msg="System Boehm with typed GC"
1013                 else
1014                         AC_DEFINE_UNQUOTED(DEFAULT_GC_NAME, "System Boehm (no typed GC)", [GC description])
1015                         gc_msg="System Boehm (without typed GC)"
1016                 fi
1017                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
1018                 if test "x$found_gc_enable" = "xyes"; then
1019                         BOEHM_DEFINES="-DHAVE_GC_ENABLE $BOEHM_DEFINES"
1020                 fi
1021
1022                 # check whether we need to explicitly allow
1023                 # thread registering
1024                 AC_CHECK_LIB(gc, GC_allow_register_threads, found_allow_register_threads="yes",,$libdl)
1025                 if test "x$found_allow_register_threads" = "xyes"; then
1026                         AC_DEFINE(HAVE_GC_ALLOW_REGISTER_THREADS, 1, [GC requires thread registration])
1027                 fi
1028
1029                 ;;
1030
1031         xincluded)
1032                 use_included_gc=yes
1033                 libgc_dir=libgc
1034
1035                 LIBGC_CPPFLAGS='-I$(top_srcdir)/libgc/include'
1036                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
1037                 LIBGC_STATIC_LIBS='$(top_builddir)/libgc/libmonogc-static.la'
1038
1039                 BOEHM_DEFINES="-DHAVE_BOEHM_GC -DHAVE_GC_H -DUSE_INCLUDED_LIBGC -DHAVE_GC_GCJ_MALLOC -DHAVE_GC_ENABLE"
1040
1041                 gc_msg="bundled Boehm GC with typed GC"
1042                 if test x$enable_parallel_mark = xyes; then
1043                         AC_DEFINE_UNQUOTED(DEFAULT_GC_NAME, "Included Boehm (with typed GC and Parallel Mark)", [GC description])
1044                         gc_msg="$gc_msg and parallel mark"
1045                 else
1046                         AC_DEFINE_UNQUOTED(DEFAULT_GC_NAME, "Included Boehm (with typed GC)", [GC description])
1047                 fi
1048                 ;;
1049
1050         xsgen)
1051                 AC_MSG_WARN("Use --with-sgen instead, --with-gc= controls Boehm configuration")
1052                 ;;
1053
1054         xnone)
1055                 AC_MSG_WARN("Compiling mono without GC.")
1056                 AC_DEFINE_UNQUOTED(DEFAULT_GC_NAME, "none", [GC description])
1057                 AC_DEFINE(HAVE_NULL_GC,1,[No GC support.])
1058                 ;;
1059         *)
1060                 AC_MSG_ERROR([Invalid argument to --with-gc.])
1061                 ;;
1062 esac
1063
1064 AC_ARG_WITH(large-heap, [  --with-large-heap=yes,no       Enable support for GC heaps larger than 3GB (defaults to no)], [large_heap=$withval], [large_heap=no])
1065 if test "x$large_heap" = "xyes"; then
1066    CPPFLAGS="$CPPFLAGS -DLARGE_CONFIG"
1067 fi
1068
1069 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
1070 AC_SUBST(LIBGC_CPPFLAGS)
1071 AC_SUBST(LIBGC_LIBS)
1072 AC_SUBST(LIBGC_STATIC_LIBS)
1073 AC_SUBST(libgc_dir)
1074 AC_SUBST(BOEHM_DEFINES)
1075
1076 dnl
1077 dnl End of libgc checks
1078 dnl
1079
1080 dnl *************************************
1081 dnl *** Checks for zero length arrays ***
1082 dnl *************************************
1083 AC_MSG_CHECKING(whether $CC supports zero length arrays)
1084 AC_TRY_COMPILE([
1085         struct s {
1086                 int  length;
1087                 char data [0];
1088         };
1089 ], [], [
1090         AC_MSG_RESULT(yes)
1091         AC_DEFINE_UNQUOTED(MONO_ZERO_LEN_ARRAY, 0, [Length of zero length arrays])
1092 ], [
1093         AC_MSG_RESULT(no)
1094         AC_DEFINE_UNQUOTED(MONO_ZERO_LEN_ARRAY, 1, [Length of zero length arrays])
1095 ])
1096
1097 AC_CHECK_HEADERS(nacl/nacl_dyncode.h)
1098
1099 if test x$target_win32 = xno; then
1100
1101         dnl hires monotonic clock support
1102         AC_SEARCH_LIBS(clock_gettime, rt)
1103
1104         dnl dynamic loader support
1105         AC_CHECK_FUNC(dlopen, DL_LIB="",
1106                 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", dl_support=no)
1107         )
1108         if test x$dl_support = xno; then
1109                 AC_MSG_WARN([No dynamic loading support available])
1110         else
1111                 LIBS="$LIBS $DL_LIB"
1112                 AC_DEFINE(HAVE_DL_LOADER,1,[dlopen-based dynamic loader available])
1113                 dnl from glib's configure.in
1114                 AC_CACHE_CHECK([for preceeding underscore in symbols],
1115                         mono_cv_uscore,[
1116                         AC_TRY_RUN([#include <dlfcn.h>
1117                         int mono_underscore_test (void) { return 42; }
1118                         int main() {
1119                           void *f1 = (void*)0, *f2 = (void*)0, *handle;
1120                           handle = dlopen ((void*)0, 0);
1121                           if (handle) {
1122                             f1 = dlsym (handle, "mono_underscore_test");
1123                             f2 = dlsym (handle, "_mono_underscore_test");
1124                           } return (!f2 || f1);
1125                         }],
1126                                 [mono_cv_uscore=yes],
1127                                 [mono_cv_uscore=no],
1128                         [])
1129                 ])
1130                 if test "x$mono_cv_uscore" = "xyes"; then
1131                         MONO_DL_NEED_USCORE=1
1132                 else
1133                         MONO_DL_NEED_USCORE=0
1134                 fi
1135                 AC_SUBST(MONO_DL_NEED_USCORE)
1136                 AC_CHECK_FUNC(dlerror)
1137         fi
1138
1139         dnl ******************************************************************
1140         dnl *** Checks for the IKVM JNI interface library                  ***
1141         dnl ******************************************************************
1142         AC_ARG_WITH(ikvm-native, [  --with-ikvm-native=yes,no      build the IKVM JNI interface library (defaults to yes)],[with_ikvm_native=$withval],[with_ikvm_native=$ikvm_native])
1143
1144         ikvm_native_dir=
1145         if test x$with_ikvm_native = xyes; then
1146                 ikvm_native_dir=ikvm-native
1147                 jdk_headers_found="IKVM Native"
1148         fi
1149
1150         AC_SUBST(ikvm_native_dir)
1151
1152         AC_CHECK_HEADERS(execinfo.h)
1153
1154         AC_CHECK_FUNCS(getgrgid_r)
1155         AC_CHECK_FUNCS(getgrnam_r)
1156         AC_CHECK_FUNCS(getpwnam_r)
1157         AC_CHECK_FUNCS(getpwuid_r)
1158         AC_CHECK_FUNCS(getresuid)
1159         AC_CHECK_FUNCS(setresuid)
1160         AC_CHECK_FUNCS(kqueue)
1161         AC_CHECK_FUNCS(backtrace_symbols)
1162         AC_CHECK_FUNCS(mkstemp)
1163         AC_CHECK_FUNCS(mmap)
1164         AC_CHECK_FUNCS(madvise)
1165         AC_CHECK_FUNCS(getrusage)
1166         AC_CHECK_FUNCS(getpriority)
1167         AC_CHECK_FUNCS(setpriority)
1168         AC_CHECK_FUNCS(dl_iterate_phdr)
1169         AC_CHECK_FUNCS(dladdr)
1170         AC_CHECK_FUNCS(sysconf)
1171
1172         AC_CHECK_FUNCS(sched_setaffinity)
1173         AC_CHECK_FUNCS(sched_getcpu)
1174
1175         dnl ****************************************************************
1176         dnl *** Check for sched_setaffinity from glibc versions before   ***
1177         dnl *** 2.3.4. The older versions of the function only take 2    ***
1178         dnl *** parameters, not 3.                                       ***
1179         dnl ***                                                          ***
1180         dnl *** Because the interface change was not made in a minor     ***
1181         dnl *** version rev, the __GLIBC__ and __GLIBC_MINOR__ macros    ***
1182         dnl *** won't always indicate the interface sched_affinity has.  ***
1183         dnl ****************************************************************
1184         AC_MSG_CHECKING(for sched_setaffinity from glibc < 2.3.4)
1185         AC_TRY_COMPILE([#include <sched.h>], [
1186             int mask = 1; 
1187             sched_setaffinity(0, &mask);
1188                         return 0;
1189         ], [
1190                 # Yes, we have it...
1191                 AC_MSG_RESULT(yes)
1192                 AC_DEFINE(GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY, 1, [Have GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY])
1193         ], [
1194                 # We have the new, three-parameter version
1195                 AC_MSG_RESULT(no)
1196         ])
1197
1198
1199         dnl ******************************************************************
1200         dnl *** Check for large file support                               ***
1201         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
1202         dnl ******************************************************************
1203         
1204         # Check that off_t can represent 2**63 - 1 correctly, working around
1205         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
1206         # CPPFLAGS and sets $large_offt to yes if the test succeeds
1207         large_offt=no
1208         AC_DEFUN([LARGE_FILES], [
1209                 large_CPPFLAGS=$CPPFLAGS
1210                 CPPFLAGS="$CPPFLAGS $1"
1211                 AC_TRY_COMPILE([
1212                         #include <sys/types.h>
1213                         #include <limits.h>
1214                 ], [
1215                         /* Lifted this compile time assert method from: http://www.jaggersoft.com/pubs/CVu11_3.html */
1216                         #define COMPILE_TIME_ASSERT(pred) \
1217                                 switch(0){case 0:case pred:;}
1218                         COMPILE_TIME_ASSERT(sizeof(off_t) * CHAR_BIT == 64);
1219                 ], [
1220                         AC_MSG_RESULT(ok)
1221                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT, 1, [Have large file support])
1222                         large_CPPFLAGS="$large_CPPFLAGS $1"
1223                         large_offt=yes
1224                 ], [
1225                         AC_MSG_RESULT(no)
1226                 ])
1227                 CPPFLAGS=$large_CPPFLAGS
1228         ])
1229
1230         AC_MSG_CHECKING(if off_t is 64 bits wide)
1231         LARGE_FILES("")
1232         if test $large_offt = no; then
1233                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
1234                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
1235         fi
1236         if test $large_offt = no; then
1237                 AC_MSG_WARN([No 64 bit file size support available])
1238         fi
1239         
1240         dnl *****************************
1241         dnl *** Checks for libsocket  ***
1242         dnl *****************************
1243         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
1244
1245         case "$host" in
1246                 *-*-*freebsd*)
1247                         dnl *****************************
1248                         dnl *** Checks for libinotify ***
1249                         dnl *****************************
1250                         AC_CHECK_LIB(inotify, inotify_init, LIBS="$LIBS -linotify")
1251         esac
1252
1253         dnl *******************************
1254         dnl *** Checks for MSG_NOSIGNAL ***
1255         dnl *******************************
1256         AC_MSG_CHECKING(for MSG_NOSIGNAL)
1257         AC_TRY_COMPILE([#include <sys/socket.h>], [
1258                 int f = MSG_NOSIGNAL;
1259         ], [
1260                 # Yes, we have it...
1261                 AC_MSG_RESULT(yes)
1262                 AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Have MSG_NOSIGNAL])
1263         ], [
1264                 # We'll have to use signals
1265                 AC_MSG_RESULT(no)
1266         ])
1267
1268         dnl *****************************
1269         dnl *** Checks for IPPROTO_IP ***
1270         dnl *****************************
1271         AC_MSG_CHECKING(for IPPROTO_IP)
1272         AC_TRY_COMPILE([#include <netinet/in.h>], [
1273                 int level = IPPROTO_IP;
1274         ], [
1275                 # Yes, we have it...
1276                 AC_MSG_RESULT(yes)
1277                 AC_DEFINE(HAVE_IPPROTO_IP, 1, [Have IPPROTO_IP])
1278         ], [
1279                 # We'll have to use getprotobyname
1280                 AC_MSG_RESULT(no)
1281         ])
1282
1283         dnl *******************************
1284         dnl *** Checks for IPPROTO_IPV6 ***
1285         dnl *******************************
1286         AC_MSG_CHECKING(for IPPROTO_IPV6)
1287         AC_TRY_COMPILE([#include <netinet/in.h>], [
1288                 int level = IPPROTO_IPV6;
1289         ], [
1290                 # Yes, we have it...
1291                 AC_MSG_RESULT(yes)
1292                 AC_DEFINE(HAVE_IPPROTO_IPV6, 1, [Have IPPROTO_IPV6])
1293         ], [
1294                 # We'll have to use getprotobyname
1295                 AC_MSG_RESULT(no)
1296         ])
1297
1298         dnl ******************************
1299         dnl *** Checks for IPPROTO_TCP ***
1300         dnl ******************************
1301         AC_MSG_CHECKING(for IPPROTO_TCP)
1302         AC_TRY_COMPILE([#include <netinet/in.h>], [
1303                 int level = IPPROTO_TCP;
1304         ], [
1305                 # Yes, we have it...
1306                 AC_MSG_RESULT(yes)
1307                 AC_DEFINE(HAVE_IPPROTO_TCP, 1, [Have IPPROTO_TCP])
1308         ], [
1309                 # We'll have to use getprotobyname
1310                 AC_MSG_RESULT(no)
1311         ])
1312
1313         dnl *****************************
1314         dnl *** Checks for SOL_IP     ***
1315         dnl *****************************
1316         AC_MSG_CHECKING(for SOL_IP)
1317         AC_TRY_COMPILE([#include <netdb.h>], [
1318                 int level = SOL_IP;
1319         ], [
1320                 # Yes, we have it...
1321                 AC_MSG_RESULT(yes)
1322                 AC_DEFINE(HAVE_SOL_IP, 1, [Have SOL_IP])
1323         ], [
1324                 # We'll have to use getprotobyname
1325                 AC_MSG_RESULT(no)
1326         ])
1327
1328         dnl *****************************
1329         dnl *** Checks for SOL_IPV6     ***
1330         dnl *****************************
1331         AC_MSG_CHECKING(for SOL_IPV6)
1332         AC_TRY_COMPILE([#include <netdb.h>], [
1333                 int level = SOL_IPV6;
1334         ], [
1335                 # Yes, we have it...
1336                 AC_MSG_RESULT(yes)
1337                 AC_DEFINE(HAVE_SOL_IPV6, 1, [Have SOL_IPV6])
1338         ], [
1339                 # We'll have to use getprotobyname
1340                 AC_MSG_RESULT(no)
1341         ])
1342
1343         dnl *****************************
1344         dnl *** Checks for SOL_TCP    ***
1345         dnl *****************************
1346         AC_MSG_CHECKING(for SOL_TCP)
1347         AC_TRY_COMPILE([#include <netdb.h>], [
1348                 int level = SOL_TCP;
1349         ], [
1350                 # Yes, we have it...
1351                 AC_MSG_RESULT(yes)
1352                 AC_DEFINE(HAVE_SOL_TCP, 1, [Have SOL_TCP])
1353         ], [
1354                 # We'll have to use getprotobyname
1355                 AC_MSG_RESULT(no)
1356         ])
1357
1358         dnl *****************************
1359         dnl *** Checks for IP_PKTINFO ***
1360         dnl *****************************
1361         AC_MSG_CHECKING(for IP_PKTINFO)
1362         AC_TRY_COMPILE([#include <linux/in.h>], [
1363                 int level = IP_PKTINFO;
1364         ], [
1365                 # Yes, we have it...
1366                 AC_MSG_RESULT(yes)
1367                 AC_DEFINE(HAVE_IP_PKTINFO, 1, [Have IP_PKTINFO])
1368         ], [
1369                 AC_MSG_RESULT(no)
1370         ])
1371
1372         dnl *****************************
1373         dnl *** Checks for IPV6_PKTINFO ***
1374         dnl *****************************
1375         AC_MSG_CHECKING(for IPV6_PKTINFO)
1376         AC_TRY_COMPILE([#include <netdb.h>], [
1377                 int level = IPV6_PKTINFO;
1378         ], [
1379                 # Yes, we have it...
1380                 AC_MSG_RESULT(yes)
1381                 AC_DEFINE(HAVE_IPV6_PKTINFO, 1, [Have IPV6_PKTINFO])
1382         ], [
1383                 AC_MSG_RESULT(no)
1384         ])
1385
1386         dnl **********************************
1387         dnl *** Checks for IP_DONTFRAG     ***
1388         dnl **********************************
1389         AC_MSG_CHECKING(for IP_DONTFRAG)
1390         AC_TRY_COMPILE([#include <netinet/in.h>], [
1391                 int level = IP_DONTFRAG;
1392         ], [
1393                 # Yes, we have it...
1394                 AC_MSG_RESULT(yes)
1395                 AC_DEFINE(HAVE_IP_DONTFRAG, 1, [Have IP_DONTFRAG])
1396         ], [
1397                 AC_MSG_RESULT(no)
1398         ])
1399
1400         dnl **********************************
1401         dnl *** Checks for IP_DONTFRAGMENT ***
1402         dnl **********************************
1403         AC_MSG_CHECKING(for IP_DONTFRAGMENT)
1404         AC_TRY_COMPILE([#include <Ws2ipdef.h>], [
1405                 int level = IP_DONTFRAGMENT;
1406         ], [
1407                 # Yes, we have it...
1408                 AC_MSG_RESULT(yes)
1409                 AC_DEFINE(HAVE_IP_DONTFRAGMENT, 1, [Have IP_DONTFRAGMENT])
1410         ], [
1411                 AC_MSG_RESULT(no)
1412         ])
1413
1414         dnl **********************************
1415         dnl *** Checks for IP_MTU_DISCOVER ***
1416         dnl **********************************
1417         AC_MSG_CHECKING(for IP_MTU_DISCOVER)
1418         AC_TRY_COMPILE([#include <linux/in.h>], [
1419                 int level = IP_MTU_DISCOVER;
1420         ], [
1421                 # Yes, we have it...
1422                 AC_MSG_RESULT(yes)
1423                 AC_DEFINE(HAVE_IP_MTU_DISCOVER, 1, [Have IP_MTU_DISCOVER])
1424         ], [
1425                 AC_MSG_RESULT(no)
1426         ])
1427
1428         dnl **********************************
1429         dnl *** Checks for  IP_PMTUDISC_DO ***
1430         dnl **********************************
1431         AC_MSG_CHECKING(for IP_PMTUDISC_DO)
1432         AC_TRY_COMPILE([#include <linux/in.h>], [
1433                 int level = IP_PMTUDISC_DO;
1434         ], [
1435                 # Yes, we have it...
1436                 AC_MSG_RESULT(yes)
1437                 AC_DEFINE(HAVE_IP_PMTUDISC_DO, 1, [Have IP_PMTUDISC_DO])
1438         ], [
1439                 AC_MSG_RESULT(no)
1440         ])
1441
1442         dnl *********************************
1443         dnl *** Check for struct ip_mreqn ***
1444         dnl *********************************
1445         AC_MSG_CHECKING(for struct ip_mreqn)
1446         AC_TRY_COMPILE([#include <netinet/in.h>], [
1447                 struct ip_mreqn mreq;
1448                 mreq.imr_address.s_addr = 0;
1449         ], [
1450                 # Yes, we have it...
1451                 AC_MSG_RESULT(yes)
1452                 AC_DEFINE(HAVE_STRUCT_IP_MREQN, 1, [Have struct ip_mreqn])
1453         ], [
1454                 # We'll just have to try and use struct ip_mreq
1455                 AC_MSG_RESULT(no)
1456                 AC_MSG_CHECKING(for struct ip_mreq)
1457                 AC_TRY_COMPILE([#include <netinet/in.h>], [
1458                         struct ip_mreq mreq;
1459                         mreq.imr_interface.s_addr = 0;
1460                 ], [
1461                         # Yes, we have it...
1462                         AC_MSG_RESULT(yes)
1463                         AC_DEFINE(HAVE_STRUCT_IP_MREQ, 1, [Have struct ip_mreq])
1464                 ], [
1465                         # No multicast support
1466                         AC_MSG_RESULT(no)
1467                 ])
1468         ])
1469         
1470         dnl **********************************
1471         dnl *** Check for gethostbyname2_r ***
1472         dnl **********************************
1473         AC_MSG_CHECKING(for gethostbyname2_r)
1474                 AC_TRY_LINK([#include <netdb.h>], [
1475                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
1476         ], [
1477                 # Yes, we have it...
1478                 AC_MSG_RESULT(yes)
1479                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R, 1, [Have gethostbyname2_r])
1480         ], [
1481                 AC_MSG_RESULT(no)
1482         ])
1483
1484         dnl *****************************
1485         dnl *** Checks for libnsl     ***
1486         dnl *****************************
1487         AC_CHECK_FUNC(gethostbyaddr, , AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl"))
1488
1489         AC_CHECK_FUNCS(inet_pton inet_aton)
1490
1491         dnl ***********************************************
1492         dnl *** Checks for size of sockaddr_un.sun_path ***
1493         dnl ***********************************************
1494         # AC_CHECK_SIZEOF can't cope with struct members :-(
1495         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
1496         AC_CACHE_VAL(mono_cv_sizeof_sunpath,
1497                 [AC_TRY_RUN([
1498                         #include <sys/types.h>
1499                         #include <stdio.h>
1500                         #include <sys/un.h>
1501
1502                         int main(void) {
1503                                 struct sockaddr_un sock_un;
1504                                 FILE *f=fopen("conftestval", "w");
1505                                 if(!f) exit(1);
1506                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
1507                                 exit(0);
1508                         }
1509                 ], mono_cv_sizeof_sunpath=`cat conftestval`,
1510                    mono_cv_sizeof_sunpath=0,
1511                    mono_cv_sizeof_sunpath=0)])dnl
1512         AC_MSG_RESULT($mono_cv_sizeof_sunpath)
1513         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $mono_cv_sizeof_sunpath, [Sizeof sock_un.sun_path])
1514
1515         dnl *****************************
1516         dnl *** Checks for libxnet    ***
1517         dnl *****************************
1518         case "${host}" in
1519                 *solaris* )
1520                         AC_MSG_CHECKING(for Solaris XPG4 support)
1521                         if test -f /usr/lib/libxnet.so; then
1522                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
1523                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
1524                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
1525                                 LIBS="$LIBS -lxnet"
1526                                 AC_MSG_RESULT(yes)
1527                         else
1528                                 AC_MSG_RESULT(no)
1529                         fi
1530
1531                         if test "$GCC" = "yes"; then
1532                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
1533                         fi
1534                 ;;
1535         esac
1536
1537         dnl *****************************
1538         dnl *** Checks for libpthread ***
1539         dnl *****************************
1540 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
1541 # and libpthread does not exist
1542 #
1543         case "${host}" in
1544                 *-*-*freebsd*)
1545                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
1546                 ;;
1547                 *-*-*openbsd*)
1548                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
1549                 ;;
1550                 *)
1551                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
1552                 ;;
1553         esac
1554         AC_CHECK_HEADERS(pthread.h)
1555         AC_CHECK_HEADERS(pthread_np.h)
1556         AC_CHECK_FUNCS(pthread_mutex_timedlock)
1557         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
1558         AC_CHECK_FUNCS(pthread_kill)
1559         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
1560         AC_TRY_COMPILE([ #include <pthread.h>], [
1561                 pthread_mutexattr_t attr;
1562                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1563         ], [
1564                 AC_MSG_RESULT(ok)
1565         ], [
1566                 AC_MSG_RESULT(no)
1567                 AC_ERROR(Posix system lacks support for recursive mutexes)
1568         ])
1569         AC_CHECK_FUNCS(pthread_attr_setstacksize)
1570         AC_CHECK_FUNCS(pthread_attr_getstack pthread_attr_getstacksize)
1571         AC_CHECK_FUNCS(pthread_get_stacksize_np pthread_get_stackaddr_np)
1572
1573         dnl ***********************************
1574         dnl *** Checks for signals
1575         dnl ***********************************
1576         AC_CHECK_HEADERS(signal.h)
1577         AC_CHECK_FUNCS(sigaction)
1578
1579         dnl ***********************************
1580         dnl *** Checks for working __thread ***
1581         dnl ***********************************
1582         AC_MSG_CHECKING(for working __thread)
1583         if test "x$with_tls" != "x__thread"; then
1584                 AC_MSG_RESULT(disabled)
1585         else
1586                 AC_TRY_RUN([
1587                         #include <pthread.h>
1588                         __thread int i;
1589                         static int res1, res2;
1590
1591                         void thread_main (void *arg)
1592                         {
1593                                 i = arg;
1594                                 sleep (1);
1595                                 if (arg == 1)
1596                                         res1 = (i == arg);
1597                                 else
1598                                         res2 = (i == arg);
1599                         }
1600
1601                         int main () {
1602                                 pthread_t t1, t2;
1603
1604                                 i = 5;
1605
1606                                 pthread_create (&t1, NULL, thread_main, 1);
1607                                 pthread_create (&t2, NULL, thread_main, 2);
1608
1609                                 pthread_join (t1, NULL);
1610                                 pthread_join (t2, NULL);
1611
1612                                 return !(res1 + res2 == 2);
1613                         }
1614                 ], [
1615                                 AC_MSG_RESULT(yes)
1616                 ], [
1617                                 AC_MSG_RESULT(no)
1618                                 with_tls=pthread
1619                 ])
1620         fi
1621
1622         dnl **************************************
1623         dnl *** Checks for working sigaltstack ***
1624         dnl **************************************
1625         AC_MSG_CHECKING(for working sigaltstack)
1626         if test "x$with_sigaltstack" != "xyes"; then
1627                 AC_MSG_RESULT(disabled)
1628         else
1629                 AC_TRY_RUN([
1630                         #include <stdio.h>
1631                         #include <stdlib.h>
1632                         #include <unistd.h>
1633                         #include <signal.h>
1634                         #include <pthread.h>
1635                         #include <sys/wait.h>
1636                         #if defined(__FreeBSD__) || defined(__NetBSD__)
1637                         #define SA_STACK SA_ONSTACK
1638                         #endif
1639                         static void
1640                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
1641                         {
1642                                 exit (0);
1643                         }
1644
1645                         volatile char*__ptr = NULL;
1646                         static void *
1647                         loop (void *ignored)
1648                         {
1649                                 *__ptr = 0;
1650                                 return NULL;
1651                         }
1652
1653                         static void
1654                         child ()
1655                         {
1656                                 struct sigaction sa;
1657                         #ifdef __APPLE__
1658                                 stack_t sas;
1659                         #else
1660                                 struct sigaltstack sas;
1661                         #endif
1662                                 pthread_t id;
1663                                 pthread_attr_t attr;
1664
1665                                 sa.sa_sigaction = sigsegv_signal_handler;
1666                                 sigemptyset (&sa.sa_mask);
1667                                 sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
1668                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
1669                                         perror ("sigaction");
1670                                         return;
1671                                 }
1672
1673                                 /* x86 darwin deliver segfaults using SIGBUS */
1674                                 if (sigaction (SIGBUS, &sa, NULL) == -1) {
1675                                         perror ("sigaction");
1676                                         return;
1677                                 }
1678                                 sas.ss_sp = malloc (SIGSTKSZ);
1679                                 sas.ss_size = SIGSTKSZ;
1680                                 sas.ss_flags = 0;
1681                                 if (sigaltstack (&sas, NULL) == -1) {
1682                                         perror ("sigaltstack");
1683                                         return;
1684                                 }
1685
1686                                 pthread_attr_init (&attr);
1687                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
1688                                         printf ("pthread_create\n");
1689                                         return;
1690                                 }
1691
1692                                 sleep (100);
1693                         }
1694
1695                         int
1696                         main ()
1697                         {
1698                                 pid_t son;
1699                                 int status;
1700                                 int i;
1701
1702                                 son = fork ();
1703                                 if (son == -1) {
1704                                         return 1;
1705                                 }
1706
1707                                 if (son == 0) {
1708                                         child ();
1709                                         return 0;
1710                                 }
1711
1712                                 for (i = 0; i < 300; ++i) {
1713                                         waitpid (son, &status, WNOHANG);
1714                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
1715                                                 return 0;
1716                                         usleep (10000);
1717                                 }
1718
1719                                 kill (son, SIGKILL);
1720                                 return 1;
1721                         }
1722
1723                 ], [
1724                                 AC_MSG_RESULT(yes)
1725                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK, 1, [Have a working sigaltstack])
1726                 ], [
1727                                 with_sigaltstack=no
1728                                 AC_MSG_RESULT(no)
1729                 ])
1730         fi
1731
1732         dnl ********************************
1733         dnl *** Checks for semaphore lib ***
1734         dnl ********************************
1735         # 'Real Time' functions on Solaris
1736         # posix4 on Solaris 2.6
1737         # pthread (first!) on Linux
1738         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
1739
1740         AC_SEARCH_LIBS(shm_open, pthread rt posix4) 
1741         AC_CHECK_FUNCS(shm_open)
1742
1743         dnl ********************************
1744         dnl *** Checks for timezone stuff **
1745         dnl ********************************
1746         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
1747                 AC_TRY_COMPILE([
1748                         #include <time.h>
1749                         ], [
1750                         struct tm tm;
1751                         tm.tm_gmtoff = 1;
1752                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
1753         if test $ac_cv_struct_tm_gmtoff = yes; then
1754                 AC_DEFINE(HAVE_TM_GMTOFF, 1, [Have tm_gmtoff])
1755         else
1756                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
1757                         AC_TRY_COMPILE([
1758                                 #include <time.h>
1759                         ], [
1760                                 timezone = 1;
1761                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
1762                 if test $ac_cv_var_timezone = yes; then
1763                         AC_DEFINE(HAVE_TIMEZONE, 1, [Have timezone variable])
1764                 else
1765                         AC_ERROR(unable to find a way to determine timezone)
1766                 fi
1767         fi
1768
1769         dnl *********************************
1770         dnl *** Checks for math functions ***
1771         dnl *********************************
1772         AC_SEARCH_LIBS(sqrtf, m)
1773         if test "x$has_broken_apple_cpp" != "xyes"; then
1774                 AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
1775                         AC_TRY_LINK([#include <math.h>], 
1776                         [ finite(0.0); ], 
1777                         AC_DEFINE(HAVE_FINITE, 1, [Have finite in -lm]) AC_MSG_RESULT(yes),
1778                         AC_MSG_RESULT(no)))
1779         fi
1780         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
1781                 AC_TRY_LINK([#include <math.h>], 
1782                 [ isfinite(0.0); ], 
1783                 AC_DEFINE(HAVE_ISFINITE, 1, [Have isfinite]) AC_MSG_RESULT(yes),
1784                 AC_MSG_RESULT(no)))
1785
1786         dnl ****************************************************************
1787         dnl *** Checks for working poll() (macosx defines it but doesn't ***
1788         dnl *** have it in the library (duh))                            ***
1789         dnl ****************************************************************
1790         AC_CHECK_FUNCS(poll)
1791
1792         dnl *************************
1793         dnl *** Check for signbit ***
1794         dnl *************************
1795         AC_MSG_CHECKING(for signbit)
1796         AC_TRY_LINK([#include <math.h>], [
1797                 int s = signbit(1.0);
1798         ], [
1799                 AC_MSG_RESULT(yes)
1800                 AC_DEFINE(HAVE_SIGNBIT, 1, [Have signbit])
1801         ], [
1802                 AC_MSG_RESULT(no)
1803         ]) 
1804
1805         dnl **********************************
1806         dnl *** epoll                      ***
1807         dnl **********************************
1808         if test "x$ac_cv_header_nacl_nacl_dyncode_h" = "xno"; then
1809                 AC_CHECK_HEADERS(sys/epoll.h)
1810                 haveepoll=no
1811                 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
1812                 if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes"; then
1813                         AC_DEFINE(HAVE_EPOLL, 1, [epoll supported])
1814                 fi
1815         fi
1816
1817         havekqueue=no
1818         AC_CHECK_FUNCS(kqueue, , AC_MSG_CHECKING(for kqueue in sys/event.h)
1819                 AC_TRY_LINK([#include <sys/event.h>], 
1820                 [ kqueue(); ],[havekqueue=yes],[]))
1821
1822         dnl **************************************
1823         dnl * Darwin has a race that prevents us from using reliably:
1824         dnl * http://lists.apple.com/archives/darwin-dev/2011/Jun/msg00016.html
1825         dnl * Since kqueue is mostly used for scaling large web servers, 
1826         dnl * and very few folks run Mono on large web servers on OSX, falling
1827         dnl * back 
1828         dnl **************************************
1829         if test x$havekqueue = xyes; then
1830                 if x$platform_darwin = xno; then
1831                         AC_DEFINE(USE_KQUEUE_FOR_THREADPOOL, 1, [Use kqueue for the threadpool])
1832                 fi
1833         fi
1834
1835         dnl ******************************
1836         dnl *** Checks for SIOCGIFCONF ***
1837         dnl ******************************
1838         AC_CHECK_HEADERS(sys/ioctl.h)
1839         AC_CHECK_HEADERS(net/if.h, [], [],
1840            [
1841            #ifdef HAVE_SYS_TYPES_H
1842            # include <sys/types.h>
1843            #endif
1844            #ifdef HAVE_SYS_SOCKET_H
1845            # include <sys/socket.h>
1846            #endif
1847            ])
1848         AC_MSG_CHECKING(for ifreq)
1849         AC_TRY_COMPILE([
1850                 #include <stdio.h>
1851                 #include <sys/ioctl.h>
1852                 #include <net/if.h>
1853                 ], [
1854                 struct ifconf ifc;
1855                 struct ifreq *ifr;
1856                 void *x;
1857                 ifc.ifc_len = 0;
1858                 ifc.ifc_buf = NULL;
1859                 x = (void *) &ifr->ifr_addr;
1860                 ],[
1861                         AC_MSG_RESULT(yes)
1862                         AC_DEFINE(HAVE_SIOCGIFCONF, 1, [Can get interface list])
1863                 ], [
1864                         AC_MSG_RESULT(no)
1865                 ])
1866         dnl **********************************
1867         dnl ***     Checks for sin_len     ***
1868         dnl **********************************
1869         AC_MSG_CHECKING(for sockaddr_in.sin_len)
1870         AC_TRY_COMPILE([
1871                 #include <netinet/in.h>
1872                 ], [
1873                 struct sockaddr_in saddr;
1874                 saddr.sin_len = sizeof (saddr);
1875                 ],[
1876                         AC_MSG_RESULT(yes)
1877                         AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1, [sockaddr_in has sin_len])
1878                 ], [
1879                         AC_MSG_RESULT(no)
1880                 ])      
1881         dnl **********************************
1882         dnl ***    Checks for sin6_len     ***
1883         dnl **********************************
1884         AC_MSG_CHECKING(for sockaddr_in6.sin6_len)
1885         AC_TRY_COMPILE([
1886                 #include <netinet/in.h>
1887                 ], [
1888                 struct sockaddr_in6 saddr6;
1889                 saddr6.sin6_len = sizeof (saddr6);
1890                 ],[
1891                         AC_MSG_RESULT(yes)
1892                         AC_DEFINE(HAVE_SOCKADDR_IN6_SIN_LEN, 1, [sockaddr_in6 has sin6_len])
1893                 ], [
1894                         AC_MSG_RESULT(no)
1895                 ])
1896         dnl **********************************
1897         dnl *** Check for getifaddrs       ***
1898         dnl **********************************
1899         AC_MSG_CHECKING(for getifaddrs)
1900                 AC_TRY_LINK([
1901                 #include <stdio.h>
1902                 #include <sys/types.h>
1903                 #include <sys/socket.h>
1904                 #include <ifaddrs.h>
1905         ], [
1906                 getifaddrs(NULL);
1907         ], [
1908                 # Yes, we have it...
1909                 AC_MSG_RESULT(yes)
1910                 AC_DEFINE(HAVE_GETIFADDRS, 1, [Have getifaddrs])
1911         ], [
1912                 AC_MSG_RESULT(no)
1913         ])
1914         dnl **********************************
1915         dnl *** Check for if_nametoindex   ***
1916         dnl **********************************
1917         AC_MSG_CHECKING(for if_nametoindex)
1918                 AC_TRY_LINK([
1919                 #include <stdio.h>
1920                 #include <sys/types.h>
1921                 #include <sys/socket.h>
1922                 #include <net/if.h>
1923         ], [
1924                 if_nametoindex(NULL);
1925         ], [
1926                 # Yes, we have it...
1927                 AC_MSG_RESULT(yes)
1928                 AC_DEFINE(HAVE_IF_NAMETOINDEX, 1, [Have if_nametoindex])
1929         ], [
1930                 AC_MSG_RESULT(no)
1931         ])
1932                         
1933         dnl **********************************
1934         dnl *** Checks for MonoPosixHelper ***
1935         dnl **********************************
1936         AC_CHECK_HEADERS(checklist.h)
1937         AC_CHECK_HEADERS(pathconf.h)
1938         AC_CHECK_HEADERS(fstab.h)
1939         AC_CHECK_HEADERS(attr/xattr.h)
1940         AC_CHECK_HEADERS(sys/extattr.h)
1941         AC_CHECK_HEADERS(sys/sendfile.h)
1942         AC_CHECK_HEADERS(sys/statvfs.h)
1943         AC_CHECK_HEADERS(sys/statfs.h)
1944         AC_CHECK_HEADERS(sys/vfstab.h)
1945         AC_CHECK_HEADERS(sys/xattr.h)
1946         AC_CHECK_HEADERS(sys/mman.h)
1947         AC_CHECK_HEADERS(sys/param.h)
1948         AC_CHECK_HEADERS(sys/mount.h, [], [],
1949                 [
1950                 #ifdef HAVE_SYS_PARAM_H
1951                 # include <sys/param.h>
1952                 #endif
1953                 ])
1954         AC_CHECK_HEADERS(sys/mount.h)
1955         AC_CHECK_FUNCS(confstr)
1956         AC_CHECK_FUNCS(seekdir telldir)
1957         AC_CHECK_FUNCS(getdomainname)
1958         AC_CHECK_FUNCS(setdomainname)
1959         AC_CHECK_FUNCS(endgrent getgrent fgetgrent setgrent)
1960         AC_CHECK_FUNCS(setgroups)
1961         AC_CHECK_FUNCS(endpwent getpwent fgetpwent setpwent)
1962         AC_CHECK_FUNCS(getfsstat)
1963         AC_CHECK_FUNCS(lutimes futimes)
1964         AC_CHECK_FUNCS(mremap)
1965         AC_CHECK_FUNCS(remap_file_pages)
1966         AC_CHECK_FUNCS(posix_fadvise)
1967         AC_CHECK_FUNCS(posix_fallocate)
1968         AC_CHECK_FUNCS(posix_madvise)
1969         AC_CHECK_FUNCS(vsnprintf)
1970         AC_CHECK_FUNCS(sendfile)
1971         AC_CHECK_FUNCS(gethostid sethostid)
1972         AC_CHECK_FUNCS(sethostname)
1973         AC_CHECK_FUNCS(statfs)
1974         AC_CHECK_FUNCS(fstatfs)
1975         AC_CHECK_FUNCS(statvfs)
1976         AC_CHECK_FUNCS(fstatvfs)
1977         AC_CHECK_FUNCS(stime)
1978         AC_CHECK_FUNCS(strerror_r)
1979         AC_CHECK_FUNCS(ttyname_r)
1980         AC_CHECK_FUNCS(psignal)
1981         AC_CHECK_FUNCS(getlogin_r)
1982         AC_CHECK_FUNCS(lockf)
1983         AC_CHECK_FUNCS(swab)
1984         AC_CHECK_FUNCS(setusershell endusershell)
1985         AC_CHECK_FUNCS(futimens utimensat)
1986         AC_CHECK_FUNCS(fstatat mknodat readlinkat)
1987         AC_CHECK_FUNCS(readv writev preadv pwritev)
1988         AC_CHECK_SIZEOF(size_t)
1989         AC_CHECK_TYPES([blksize_t], [AC_DEFINE(HAVE_BLKSIZE_T)], , 
1990                 [#include <sys/types.h>
1991                  #include <sys/stat.h>
1992                  #include <unistd.h>])
1993         AC_CHECK_TYPES([blkcnt_t], [AC_DEFINE(HAVE_BLKCNT_T)], ,
1994                 [#include <sys/types.h>
1995                  #include <sys/stat.h>
1996                  #include <unistd.h>])
1997         AC_CHECK_TYPES([suseconds_t], [AC_DEFINE(HAVE_SUSECONDS_T)], ,
1998                 [#include <sys/time.h>])
1999         AC_CHECK_TYPES([struct flock], [AC_DEFINE(HAVE_STRUCT_FLOCK)], ,
2000                 [#include <unistd.h>
2001                  #include <fcntl.h>])
2002         AC_CHECK_TYPES([struct iovec], [AC_DEFINE(HAVE_STRUCT_IOVEC)], ,
2003                 [#include <sys/uio.h>])
2004         AC_CHECK_TYPES([struct pollfd], [AC_DEFINE(HAVE_STRUCT_POLLFD)], ,
2005                 [#include <sys/poll.h>])
2006         AC_CHECK_TYPES([struct stat], [AC_DEFINE(HAVE_STRUCT_STAT)], ,
2007                 [#include <sys/types.h>
2008                  #include <sys/stat.h>
2009                  #include <unistd.h>])
2010         AC_CHECK_TYPES([struct timespec], [AC_DEFINE(HAVE_STRUCT_TIMESPEC)], ,
2011                 [#include <time.h>])
2012         AC_CHECK_TYPES([struct timeval], [AC_DEFINE(HAVE_STRUCT_TIMEVAL)], ,
2013                 [#include <sys/time.h>
2014                  #include <sys/types.h>
2015                  #include <utime.h>])
2016         AC_CHECK_TYPES([struct timezone], [AC_DEFINE(HAVE_STRUCT_TIMEZONE)], ,
2017                 [#include <sys/time.h>])
2018         AC_CHECK_TYPES([struct utimbuf], [AC_DEFINE(HAVE_STRUCT_UTIMBUF)], ,
2019                 [#include <sys/types.h>
2020                  #include <utime.h>])
2021         AC_CHECK_MEMBERS(
2022                 [struct dirent.d_off, struct dirent.d_reclen, struct dirent.d_type],,, 
2023                 [#include <sys/types.h>
2024                  #include <dirent.h>])
2025         AC_CHECK_MEMBERS(
2026                 [struct passwd.pw_gecos],,, 
2027                 [#include <sys/types.h>
2028                  #include <pwd.h>])
2029         AC_CHECK_MEMBERS(
2030                 [struct statfs.f_flags],,, 
2031                 [#include <sys/types.h>
2032                  #include <sys/vfs.h>])
2033         AC_CHECK_MEMBERS(
2034                 [struct stat.st_atim, struct stat.st_mtim, struct stat.st_ctim],,, 
2035                 [#include <sys/types.h>
2036                  #include <sys/stat.h>
2037                  #include <unistd.h>])
2038
2039         dnl Favour xattr through glibc, but use libattr if we have to
2040         AC_CHECK_FUNC(lsetxattr, ,
2041                 AC_CHECK_LIB(attr, lsetxattr, XATTR_LIB="-lattr",)
2042         )
2043         AC_SUBST(XATTR_LIB)
2044
2045         dnl kinfo_proc.kp_proc works on darwin but fails on other simil-bsds
2046         AC_CHECK_MEMBERS(
2047                 [struct kinfo_proc.kp_proc],,, 
2048                 [#include <sys/types.h>
2049                  #include <sys/param.h>
2050                  #include <sys/sysctl.h>
2051                  #include <sys/proc.h>
2052                  ])
2053
2054         dnl *********************************
2055         dnl *** Checks for Windows compilation ***
2056         dnl *********************************
2057         AC_CHECK_HEADERS(sys/time.h)
2058         AC_CHECK_HEADERS(sys/param.h)
2059         AC_CHECK_HEADERS(dirent.h)
2060
2061         dnl ******************************************
2062         dnl *** Checks for OSX and iOS compilation ***
2063         dnl ******************************************
2064         AC_CHECK_HEADERS(CommonCrypto/CommonDigest.h)
2065
2066         dnl *********************************
2067         dnl *** Check for Console 2.0 I/O ***
2068         dnl *********************************
2069         AC_CHECK_HEADERS([curses.h])
2070         AC_CHECK_HEADERS([term.h], [], [],
2071         [#if HAVE_CURSES_H
2072          #include <curses.h>
2073          #endif
2074         ])
2075         AC_CHECK_HEADERS([termios.h])
2076
2077         dnl * This is provided in io-layer, but on windows it's only available
2078         dnl * on xp+
2079         AC_DEFINE(HAVE_GETPROCESSID, 1, [Define if GetProcessId is available])
2080 else
2081         dnl *********************************
2082         dnl *** Checks for Windows compilation ***
2083         dnl *********************************
2084         AC_CHECK_HEADERS(winternl.h)
2085
2086         jdk_headers_found=no
2087         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
2088         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
2089         AC_CHECK_LIB(ole32, main, LIBS="$LIBS -lole32", AC_ERROR(bad mingw install?))
2090         AC_CHECK_LIB(winmm, main, LIBS="$LIBS -lwinmm", AC_ERROR(bad mingw install?))
2091         AC_CHECK_LIB(oleaut32, main, LIBS="$LIBS -loleaut32", AC_ERROR(bad mingw install?))
2092         AC_CHECK_LIB(advapi32, main, LIBS="$LIBS -ladvapi32", AC_ERROR(bad mingw install?))
2093         AC_CHECK_LIB(version, main, LIBS="$LIBS -lversion", AC_ERROR(bad mingw install?))
2094
2095         dnl *********************************
2096         dnl *** Check for struct ip_mreqn ***
2097         dnl *********************************
2098         AC_MSG_CHECKING(for struct ip_mreqn)
2099         AC_TRY_COMPILE([#include <ws2tcpip.h>], [
2100                 struct ip_mreqn mreq;
2101                 mreq.imr_address.s_addr = 0;
2102         ], [
2103                 # Yes, we have it...
2104                 AC_MSG_RESULT(yes)
2105                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
2106         ], [
2107                 # We'll just have to try and use struct ip_mreq
2108                 AC_MSG_RESULT(no)
2109                 AC_MSG_CHECKING(for struct ip_mreq)
2110                 AC_TRY_COMPILE([#include <ws2tcpip.h>], [
2111                         struct ip_mreq mreq;
2112                         mreq.imr_interface.s_addr = 0;
2113                 ], [
2114                         # Yes, we have it...
2115                         AC_MSG_RESULT(yes)
2116                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
2117                 ], [
2118                         # No multicast support
2119                         AC_MSG_RESULT(no)
2120                 ])
2121         ])
2122         AC_CHECK_FUNCS(GetProcessId)
2123 fi
2124
2125 dnl socklen_t check
2126 AC_MSG_CHECKING(for socklen_t)
2127 AC_TRY_COMPILE([
2128 #include <sys/types.h>
2129 #include <sys/socket.h>
2130 ],[
2131   socklen_t foo;
2132 ],[
2133 ac_cv_c_socklen_t=yes
2134         AC_DEFINE(HAVE_SOCKLEN_T, 1, [Have socklen_t])
2135         AC_MSG_RESULT(yes)
2136 ],[
2137         AC_MSG_RESULT(no)
2138 ])
2139
2140 AC_MSG_CHECKING(for array element initializer support)
2141 AC_TRY_COMPILE([#include <sys/socket.h>], [
2142         const int array[] = {[1] = 2,};
2143 ], [
2144         # Yes, we have it...
2145         AC_MSG_RESULT(yes)
2146         AC_DEFINE(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
2147 ], [
2148         # We'll have to use signals
2149         AC_MSG_RESULT(no)
2150 ])
2151
2152 AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
2153         # Simply calling trunc (0.0) is no good since gcc will optimize the call away
2154         AC_TRY_LINK([#include <math.h>], 
2155         [ static void *p = &trunc; ],
2156         [
2157                 AC_DEFINE(HAVE_TRUNC) 
2158                 AC_MSG_RESULT(yes)
2159                 ac_cv_trunc=yes
2160         ],
2161         AC_MSG_RESULT(no)))
2162
2163 if test "x$ac_cv_truncl" != "xyes"; then
2164    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL, 1, [Has the 'aintl' function]) LIBS="$LIBS -lsunmath"])
2165 fi
2166
2167 AC_CHECK_FUNCS(round)
2168 AC_CHECK_FUNCS(rint)
2169 AC_CHECK_FUNCS(execvp)
2170
2171 dnl ****************************
2172 dnl *** Look for /dev/random ***
2173 dnl ****************************
2174
2175 AC_MSG_CHECKING([if usage of random device is requested])
2176 AC_ARG_ENABLE(dev-random,
2177 [  --disable-dev-random    disable the use of the random device (enabled by default)],
2178 try_dev_random=$enableval, try_dev_random=yes)
2179
2180 AC_MSG_RESULT($try_dev_random)
2181
2182 case "{$build}" in
2183     *-openbsd*)
2184     NAME_DEV_RANDOM="/dev/srandom"
2185     ;;
2186
2187 dnl Win32 does not have /dev/random, they have their own method...
2188
2189     *-mingw*|*-*-cygwin*)
2190     ac_cv_have_dev_random=no
2191     ;;
2192
2193 dnl Everywhere else, it's /dev/random
2194
2195     *)
2196     NAME_DEV_RANDOM="/dev/random"
2197     ;;
2198 esac
2199
2200 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM", [Name of /dev/random])
2201
2202 dnl Now check if the device actually exists
2203
2204 if test "x$try_dev_random" = "xyes"; then
2205     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
2206     [if test -r "$NAME_DEV_RANDOM" ; then
2207         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
2208     if test "x$ac_cv_have_dev_random" = "xyes"; then
2209         AC_DEFINE(HAVE_CRYPT_RNG, 1, [Have /dev/random])
2210     fi
2211 else
2212     AC_MSG_CHECKING(for random device)
2213     ac_cv_have_dev_random=no
2214     AC_MSG_RESULT(has been disabled)
2215 fi
2216
2217 if test "x$host_win32" = "xyes"; then
2218     AC_DEFINE(HAVE_CRYPT_RNG)
2219 fi
2220
2221 if test "x$ac_cv_have_dev_random" = "xno" \
2222     && test "x$host_win32" = "xno"; then
2223     AC_MSG_WARN([[
2224 ***
2225 *** A system-provided entropy source was not found on this system.
2226 *** Because of this, the System.Security.Cryptography random number generator
2227 *** will throw a NotImplemented exception.
2228 ***
2229 *** If you are seeing this message, and you know your system DOES have an
2230 *** entropy collection in place, please contact <crichton@gimp.org> and
2231 *** provide information about the system and how to access the random device.
2232 ***
2233 *** Otherwise you can install either egd or prngd and set the environment
2234 *** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
2235 ***]])
2236 fi
2237  
2238 AC_MSG_CHECKING([if inter-process shared handles are requested])
2239 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
2240 AC_MSG_RESULT($try_shared_handles)
2241 if test "x$try_shared_handles" != "xyes"; then
2242         AC_DEFINE(DISABLE_SHARED_HANDLES, 1, [Disable inter-process shared handles])
2243         AC_SUBST(DISABLE_SHARED_HANDLES)
2244 fi
2245
2246 AC_ARG_ENABLE(bcl-opt, [  --disable-bcl-opt     BCL is compiled with no optimizations (allows accurate BCL debugging)], test_bcl_opt=$enableval, test_bcl_opt=yes)
2247
2248 AC_ARG_ENABLE(nunit-tests, [  --enable-nunit-tests      Run the nunit tests of the class library on 'make check'])
2249 AM_CONDITIONAL(ENABLE_NUNIT_TESTS, [test x$enable_nunit_tests = xyes])
2250
2251 AC_MSG_CHECKING([if big-arrays are to be enabled])
2252 AC_ARG_ENABLE(big-arrays,  [  --enable-big-arrays       Enable the allocation and indexing of arrays greater than Int32.MaxValue], enable_big_arrays=$enableval, enable_big_arrays=no)
2253 if test "x$enable_big_arrays" = "xyes" ; then
2254     if  test "x$ac_cv_sizeof_void_p" = "x8"; then
2255         AC_DEFINE(MONO_BIG_ARRAYS,1,[Enable the allocation and indexing of arrays greater than Int32.MaxValue])
2256     else
2257         AC_MSG_ERROR([The allocation and indexing of arrays greater than Int32.MaxValue is not supported on this platform.])
2258     fi
2259 fi
2260 AC_MSG_RESULT($enable_big_arrays)
2261
2262 dnl **************
2263 dnl *** DTRACE ***
2264 dnl **************
2265
2266 AC_ARG_ENABLE(dtrace,[  --enable-dtrace Enable DTrace probes], enable_dtrace=$enableval, enable_dtrace=$has_dtrace)
2267
2268 if test "x$enable_dtrace" = "xyes"; then
2269    if test "x$has_dtrace" = "xno"; then
2270           AC_MSG_ERROR([DTrace probes are not supported on this platform.])
2271    fi
2272    AC_PATH_PROG(DTRACE, [dtrace], [no], [$PATH:/usr/sbin])
2273    if test "x$DTRACE" = "xno"; then
2274           AC_MSG_RESULT([dtrace utility not found, dtrace support disabled.])
2275           enable_dtrace=no
2276    elif ! $DTRACE -h -s $srcdir/data/mono.d > /dev/null 2>&1; then
2277           AC_MSG_RESULT([dtrace doesn't support -h option, dtrace support disabled.])
2278           enable_dtrace=no
2279    fi
2280 fi
2281
2282 dtrace_g=no
2283 if test "x$enable_dtrace" = "xyes"; then
2284         AC_DEFINE(ENABLE_DTRACE, 1, [Enable DTrace probes])
2285         DTRACEFLAGS=
2286         if test "x$ac_cv_sizeof_void_p" = "x8"; then
2287                 case "$host" in
2288                         powerpc-*-darwin*)
2289                         DTRACEFLAGS="-arch ppc64"
2290                         ;;
2291                         i*86-*-darwin*)
2292                         DTRACEFLAGS="-arch x86_64"
2293                         ;;
2294                         *)
2295                         DTRACEFLAGS=-64
2296                         ;;
2297                 esac
2298         else
2299                 case "$host" in
2300                         powerpc-*-darwin*)
2301                         DTRACEFLAGS="-arch ppc"
2302                         ;;
2303                         i*86-*-darwin*)
2304                         DTRACEFLAGS="-arch i386"
2305                         ;;
2306                         *)
2307                         DTRACEFLAGS=-32
2308                         ;;
2309                 esac
2310         fi
2311         AC_SUBST(DTRACEFLAGS)
2312         case "$host" in
2313                 *-*-solaris*)
2314                 dtrace_g=yes
2315                 ;;
2316         esac
2317         AC_CHECK_HEADERS([sys/sdt.h])
2318 fi
2319 AM_CONDITIONAL(ENABLE_DTRACE, [test x$enable_dtrace = xyes])
2320 AM_CONDITIONAL(DTRACE_G_REQUIRED, [test x$dtrace_g = xyes])
2321
2322 dnl **************
2323 dnl ***  NaCl  ***
2324 dnl **************
2325
2326 AC_ARG_ENABLE(nacl_codegen, [  --enable-nacl-codegen      Enable Native Client code generation], enable_nacl_codegen=$enableval, enable_nacl_codegen=no)
2327 AC_ARG_ENABLE(nacl_gc, [  --enable-nacl-gc           Enable Native Client garbage collection], enable_nacl_gc=$enableval, enable_nacl_gc=no)
2328
2329 AM_CONDITIONAL(NACL_CODEGEN, test x$enable_nacl_codegen != xno)
2330
2331 dnl
2332 dnl Hack to use system mono for operations in build/install not allowed in NaCl.
2333 dnl
2334 nacl_self_host=""
2335 if test "x$ac_cv_header_nacl_nacl_dyncode_h" = "xyes"; then
2336    nacl_self_host="nacl_self_host"
2337 fi
2338 AC_SUBST(nacl_self_host)
2339
2340 if test "x$enable_nacl_codegen" = "xyes"; then
2341    MONO_NACL_ALIGN_MASK_OFF=1
2342    AC_DEFINE(TARGET_NACL, 1, [...])
2343    AC_DEFINE(__native_client_codegen__, 1, [...])
2344 else
2345    MONO_NACL_ALIGN_MASK_OFF=0
2346    AC_DEFINE(__default_codegen__, 1, [...])
2347 fi
2348 if test "x$enable_nacl_gc" = "xyes"; then
2349    if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
2350       INSTRUMENT_CFLAG="-finstrument-for-thread-suspension"
2351    else
2352       # Not yet implemented
2353       INSTRUMENT_CFLAG=""
2354    fi
2355    CPPFLAGS="$CPPFLAGS $INSTRUMENT_CFLAG -D__native_client_gc__"
2356 fi
2357 AC_SUBST(MONO_NACL_ALIGN_MASK_OFF)
2358
2359 dnl **************
2360 dnl ***  LLVM  ***
2361 dnl **************
2362
2363 AC_ARG_ENABLE(llvm,[  --enable-llvm     Enable the LLVM back-end], enable_llvm=$enableval, enable_llvm=no)
2364 AC_ARG_ENABLE(loadedllvm,[  --enable-loadedllvm Load the LLVM back-end dynamically], enable_llvm=$enableval && enable_loadedllvm=$enableval, enable_loadedllvm=no)
2365
2366 if test "x$enable_llvm" = "xyes"; then
2367    AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
2368    if test "x$LLVM_CONFIG" = "xno"; then
2369           AC_MSG_ERROR([llvm-config not found.])
2370    fi
2371
2372    llvm_codegen="x86codegen"
2373    case "$target" in
2374    arm*)
2375                 llvm_codegen="armcodegen"
2376                 ;;
2377    esac
2378
2379
2380    # The output of --cflags seems to include optimizations flags too
2381    LLVM_CFLAGS=`$LLVM_CONFIG --cflags | sed -e 's/-O2//g' | sed -e 's/-O0//g' | sed -e 's/-fomit-frame-pointer//g' | sed -e 's/-fPIC//g'`
2382    # LLVM is compiled with -fno-rtti, so we need this too, since our classes inherit
2383    # from LLVM classes.
2384    LLVM_CXXFLAGS="`$LLVM_CONFIG --cxxflags` -fno-rtti"
2385    LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
2386    LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter jit mcjit $llvm_codegen`
2387    LLVM_LIBS="$LLVM_LDFLAGS $LLVM_LIBS -lstdc++"
2388
2389    # Should be something like '2.6' or '2.7svn'
2390    llvm_version=`$LLVM_CONFIG --version`
2391    major_version=`echo $llvm_version | cut -c 1`
2392    minor_version=`echo $llvm_version | cut -c 3`
2393    AC_MSG_CHECKING(LLVM version)
2394    AC_MSG_RESULT($llvm_version)
2395    if echo $llvm_version | grep -q 'mono'; then
2396           AC_DEFINE(LLVM_MONO_BRANCH, 1, [Whenever we are using the mono branch of LLVM])
2397           LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DLLVM_MONO_BRANCH"       
2398    else
2399           AC_MSG_ERROR([Compiling with stock LLVM is not supported, please use the Mono LLVM repo at https://github.com/mono/llvm, with the GIT branch which matches this version of mono, i.e. 'mono-2-10' for Mono 2.10.])
2400    fi
2401
2402    AC_DEFINE_UNQUOTED(LLVM_MAJOR_VERSION, $major_version, [Major version of LLVM libraries])
2403    AC_DEFINE_UNQUOTED(LLVM_MINOR_VERSION, $minor_version, [Minor version of LLVM libraries])
2404    AC_DEFINE_UNQUOTED(LLVM_VERSION, "$llvm_version", [Full version of LLVM libraties])
2405
2406    # Have to pass these on the command line since mini-llvm-cpp.h already includes
2407    # llvm's config.h
2408    LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DLLVM_MAJOR_VERSION=$major_version -DLLVM_MINOR_VERSION=$minor_version"
2409
2410    AC_SUBST(LLVM_CFLAGS)
2411    AC_SUBST(LLVM_CXXFLAGS)
2412    AC_SUBST(LLVM_LIBS)
2413    AC_SUBST(LLVM_LDFLAGS)
2414    AC_DEFINE(ENABLE_LLVM, 1, [Enable the LLVM back end])
2415 fi
2416
2417 AM_CONDITIONAL(ENABLE_LLVM, [test x$enable_llvm = xyes])
2418 if test "x$enable_loadedllvm" = "xyes"; then
2419    AC_DEFINE(MONO_LLVM_LOADED, 1, [The LLVM back end is dynamically loaded])
2420 fi
2421 AM_CONDITIONAL(LOADED_LLVM, [test x$enable_loadedllvm = xyes])
2422
2423 TARGET="unknown"
2424 ACCESS_UNALIGNED="yes"
2425
2426 JIT_SUPPORTED=no
2427 INTERP_SUPPORTED=no
2428 LIBC="libc.so.6"
2429 INTL="libc.so.6"
2430 SQLITE="libsqlite.so.0"
2431 SQLITE3="libsqlite3.so.0"
2432 X11="libX11.so"
2433
2434 sizeof_register="SIZEOF_VOID_P"
2435
2436 jit_wanted=true
2437 interp_wanted=false
2438 sgen_supported=false
2439 case "$host" in
2440 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
2441 #               TARGET=MIPS;
2442 #               ACCESS_UNALIGNED="no"
2443 #               ;;
2444         mips*)
2445                 TARGET=MIPS;
2446                 arch_target=mips;
2447                 sgen_supported=true
2448                 ACCESS_UNALIGNED="no"
2449                 JIT_SUPPORTED=yes
2450
2451                 AC_MSG_CHECKING(for mips n32)
2452                 AC_TRY_COMPILE([],[
2453                 #if _MIPS_SIM != _ABIN32
2454                 #error Not mips n32
2455                 #endif
2456                 return 0;
2457                 ],[
2458                 AC_MSG_RESULT(yes)
2459                 sizeof_register=8
2460                 ],[
2461                 AC_MSG_RESULT(no)
2462                 ])
2463                 ;;
2464         i*86-*-*)
2465                 TARGET=X86;
2466                 arch_target=x86;
2467                 JIT_SUPPORTED=yes
2468                 case $host_os in
2469                   solaris*)
2470                         LIBC="libc.so"
2471                         INTL="libintl.so"
2472                         if test "x$ac_cv_sizeof_void_p" = "x8"; then
2473                                 TARGET=AMD64
2474                                 arch_target=amd64
2475                         fi
2476
2477                         # On solaris 10 x86, gcc prints a warning saying 'visibility attribute not supported on this configuration; ignored', but linking fails. A test case:
2478                         # int astruct __attribute__ ((visibility ("hidden")));
2479                         # void foo ()
2480                         # {
2481                         #       void *p = &astruct;
2482                         # }
2483                         # gcc -fPIC --shared -o libfoo.so foo.c
2484                         # yields:
2485                         # foo.c:6: warning: visibility attribute not supported in this configuration; ignored
2486                         # ld: fatal: relocation error: R_386_GOTOFF: file /var/tmp//ccxYR96k.o: symbol astruct: relocation must bind locally
2487                         have_visibility_hidden=no
2488                         sgen_supported=true
2489                         ;;
2490                   cygwin*)
2491                         sgen_supported=true
2492                         have_visibility_hidden=no                 
2493                         ;;
2494                   haiku*)
2495                         LIBC=libroot.so
2496                         ;;
2497                   linux*)
2498                         sgen_supported=true
2499                         AOT_SUPPORTED="yes"
2500                         ;;
2501                   darwin*)
2502                         sgen_supported=true
2503                         AOT_SUPPORTED="yes"
2504                         ;;
2505                   darwin*|openbsd*|freebsd*)
2506                         sgen_supported=true
2507                         ;;
2508                 esac
2509                 ;;
2510         x86_64-*-* | amd64-*-*)
2511                 TARGET=AMD64;
2512                 arch_target=amd64;
2513                 JIT_SUPPORTED=yes
2514                 if test "x$ac_cv_sizeof_void_p" = "x4"; then
2515                         AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
2516                         sizeof_register=8
2517                 fi
2518                 case $host_os in
2519                   linux*)
2520                         sgen_supported=true
2521                         AOT_SUPPORTED="yes"
2522                         ;;
2523                   darwin*|openbsd*|freebsd*)
2524                         sgen_supported=true
2525                         ;;
2526                 esac
2527                 case "$host" in
2528                         x86_64-*-nacl*)
2529                                 AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
2530                                 sizeof_register=8
2531                                 ;;
2532                 esac
2533                 ;;
2534         ia64-*-*)
2535                 TARGET=IA64
2536                 arch_target=ia64
2537                 ACCESS_UNALIGNED="no"
2538                 JIT_SUPPORTED=yes
2539                 LIBC="libc.so.6.1"
2540                 INTL="libc.so.6.1"
2541                 AC_CHECK_LIB(unwind, _U_dyn_register, [], [AC_MSG_ERROR(library libunwind not found)])
2542                 libmono_ldflags="-lunwind"
2543                 ;;
2544         sparc*-*-*)
2545                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
2546                    TARGET=SPARC64
2547                 else
2548                         TARGET=SPARC
2549                 fi
2550                 arch_target=sparc;
2551                 JIT_SUPPORTED=yes
2552                 ACCESS_UNALIGNED="no"
2553                 case $host_os in
2554                   linux*) ;;
2555                   *)
2556                         LIBC="libc.so"
2557                         INTL="libintl.so"
2558                 esac
2559                 if test x"$GCC" = xyes; then
2560                         # We don't support v8 cpus
2561                         CFLAGS="$CFLAGS -Wno-cast-align -mcpu=v9"
2562                 fi
2563                 if test x"$AR" = xfalse; then
2564                         AC_MSG_ERROR([The required utility 'ar' is not found in your PATH. Usually it can be found in /usr/ccs/bin.])
2565                 fi
2566                 sgen_supported=true
2567                 ;;
2568         *-mingw*|*-*-cygwin*)
2569                 # When this is enabled, it leads to very strange crashes at runtime (gcc-3.4.4)
2570                 have_visibility_hidden=no
2571                 INTL="intl"
2572                 ;;
2573         macppc-*-openbsd* | powerpc*-*-linux* | powerpc-*-openbsd* | \
2574         powerpc-*-sysv* | powerpc-*-darwin* | powerpc-*-netbsd* | powerpc-*-freebsd* )
2575                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
2576                         TARGET=POWERPC64;
2577                         CPPFLAGS="$CPPFLAGS -D__mono_ppc__ -D__mono_ppc64__"
2578                         CFLAGS="$CFLAGS -mminimal-toc"
2579                 else
2580                         TARGET=POWERPC;
2581                         CPPFLAGS="$CPPFLAGS -D__mono_ppc__"
2582                 fi
2583                 arch_target=ppc;
2584                 JIT_SUPPORTED=yes
2585                 case $host_os in
2586                   linux*|darwin*)
2587                         sgen_supported=true
2588                         ;;
2589                 esac
2590                 ;;
2591         arm*-darwin*)
2592                 TARGET=ARM;
2593                 arch_target=arm;
2594                 ACCESS_UNALIGNED="no"
2595                 JIT_SUPPORTED=yes
2596                 CPPFLAGS="$CPPFLAGS -D__ARM_EABI__ -DHAVE_ARMV6=1"
2597                 # libgc's gc_locks.h depends on this
2598             CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DHAVE_ARMV6"
2599                 sgen_supported=true
2600                 ;;
2601         arm*-linux*)
2602                 TARGET=ARM;
2603                 arch_target=arm;
2604                 ACCESS_UNALIGNED="no"
2605                 JIT_SUPPORTED=yes
2606                 sgen_supported=true
2607                 AOT_SUPPORTED="yes"
2608                 CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
2609                 ;;
2610 # TODO: make proper support for NaCl host.
2611 #        arm*-*nacl)
2612 #               TARGET=ARM;
2613 #               arch_target=arm;
2614 #               ACCESS_UNALIGNED="no"
2615 #               JIT_SUPPORTED=yes
2616 #               sgen_supported=true
2617 #               AOT_SUPPORTED="no"
2618 #               ;;
2619         s390x-*-linux*)
2620                 TARGET=S390x;
2621                 arch_target=s390x;
2622                 ACCESS_UNALIGNED="yes"
2623                 JIT_SUPPORTED=yes
2624                 sgen_supported=true
2625                 CFLAGS="$CFLAGS -mbackchain -D__USE_STRING_INLINES"
2626                 ;;
2627 esac
2628
2629 HOST=$TARGET
2630
2631 if test "x$host" != "x$target"; then
2632    AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
2633    enable_mcs_build=no
2634    case "$target" in
2635    arm*-darwin*)
2636                 TARGET=ARM;
2637                 arch_target=arm;
2638                 ACCESS_UNALIGNED="no"
2639                 JIT_SUPPORTED=yes
2640                 CPPFLAGS="$CPPFLAGS -D__ARM_EABI__ -DHAVE_ARMV6=1"
2641                 jit_wanted=true
2642                 # Can't use tls, since it depends on the runtime detection of tls offsets
2643                 # in mono-compiler.h
2644                 with_tls=pthread
2645                 ;;
2646    powerpc64-ps3-linux-gnu)
2647                 TARGET=POWERPC64
2648                 arch_target=powerpc64
2649                 AC_DEFINE(TARGET_PS3, 1, [...])
2650                 # It would be better to just use TARGET_POWERPC64, but lots of code already
2651                 # uses this define
2652                 AC_DEFINE(__mono_ppc64__, 1, [...])
2653                 AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
2654                 sizeof_register=8
2655                 target_byte_order=G_BIG_ENDIAN
2656                 ;;
2657
2658    powerpc64-xbox360-linux-gnu)
2659                 TARGET=POWERPC64
2660                 arch_target=powerpc64
2661                 AC_DEFINE(TARGET_XBOX360, 1, [...])
2662                 # It would be better to just use TARGET_POWERPC64, but lots of code already
2663                 # uses this define
2664                 sizeof_register=8
2665                 target_byte_order=G_BIG_ENDIAN
2666                 ;;
2667    x86_64-*-nacl)
2668                 TARGET=AMD64
2669                 arch_target=amd64
2670                 AC_DEFINE(TARGET_AMD64, 1, [...])
2671                 AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
2672                 sizeof_register=8
2673                 ;;
2674 # TODO: make proper support for NaCl target.
2675 #   arm*-*nacl)
2676 #               TARGET=ARM
2677 #               arch_target=arm
2678 #               AC_DEFINE(TARGET_ARM, 1, [...])
2679 #               ACCESS_UNALIGNED="no"
2680 #               JIT_SUPPORTED=yes
2681 #               sizeof_register=4
2682 #               CPPFLAGS="$CPPFLAGS \
2683 #                    -D__ARM_EABI__ \
2684 #                    -D__arm__ \
2685 #                    -D__portable_native_client__ \
2686 #                    -Dtimezone=_timezone \
2687 #                    -DDISABLE_SOCKETS \
2688 #                    -DDISABLE_ATTACH \
2689 #                    -DUSE_NEWLIB"
2690 #               jit_wanted=true
2691                 # Can't use tls, since it depends on the runtime detection of tls offsets
2692                 # in mono-compiler.h
2693 #               with_tls=pthread
2694 #               ;;
2695    i686-*-nacl)
2696                 TARGET=X86
2697                 arch_target=x86
2698                 AC_DEFINE(TARGET_X86, 1, [...])
2699                 sizeof_register=4
2700                 ;;
2701    arm*-linux-*)
2702                 TARGET=ARM;
2703                 arch_target=arm;
2704                 AC_DEFINE(TARGET_ARM, 1, [...])
2705                 ACCESS_UNALIGNED="no"
2706                 JIT_SUPPORTED=yes
2707                 CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
2708                 jit_wanted=true
2709                 # Can't use tls, since it depends on the runtime detection of tls offsets
2710                 # in mono-compiler.h
2711                 with_tls=pthread
2712                 target_mach=no
2713                 case "$target" in
2714                 armv7l-unknown-linux-gnueabi*)
2715                         # TEGRA
2716                         CPPFLAGS="$CPPFLAGS"
2717                         ;;
2718                 armv5-*-linux-androideabi*)
2719                         AC_DEFINE(TARGET_ANDROID, 1, [...])
2720                         CPPFLAGS="$CPPFLAGS"
2721                         ;;
2722                 esac
2723                 ;;
2724         *)
2725                 AC_MSG_ERROR([Cross compiling is not supported for target $target])
2726         esac
2727 fi
2728
2729 # FIXME: Define the others as well
2730 case "$TARGET" in
2731 X86)
2732         AC_DEFINE(TARGET_X86, 1, [...])
2733         ;;
2734 AMD64)
2735         AC_DEFINE(TARGET_AMD64, 1, [...])
2736         ;;
2737 ARM)
2738         AC_DEFINE(TARGET_ARM, 1, [...])
2739         ;;
2740 POWERPC)
2741         AC_DEFINE(TARGET_POWERPC, 1, [...])
2742         ;;
2743 POWERPC64)
2744         AC_DEFINE(TARGET_POWERPC, 1, [...])
2745         AC_DEFINE(TARGET_POWERPC64, 1, [...])
2746         ;;
2747 S390x)
2748         AC_DEFINE(TARGET_S390X, 1, [...])
2749         ;;
2750 MIPS)
2751         AC_DEFINE(TARGET_MIPS, 1, [...])
2752         ;;
2753 esac
2754
2755 if test "x$target_mach" = "xyes"; then
2756    if test "x$TARGET" = "xARM"; then
2757           AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
2758           CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_IOS"
2759           CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_IOS"
2760    else
2761        AC_TRY_COMPILE([#include "TargetConditionals.h"],[
2762        #if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1
2763        #error fail this for ios
2764        #endif
2765        return 0;
2766        ], [
2767                   AC_DEFINE(TARGET_OSX,1,[The JIT/AOT targets OSX])
2768           CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_OSX"
2769           CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_OSX"
2770        ], [
2771           AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
2772           CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_IOS"
2773           CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_IOS"
2774        ])
2775         fi
2776    AC_DEFINE(TARGET_MACH,1,[The JIT/AOT targets Apple platforms])
2777 fi
2778
2779 if test "x$sizeof_register" = "x4"; then
2780    AC_DEFINE(SIZEOF_REGISTER,4,[size of machine integer registers])
2781 elif test "x$sizeof_register" = "x8"; then
2782    AC_DEFINE(SIZEOF_REGISTER,8,[size of machine integer registers])
2783 else
2784    AC_DEFINE(SIZEOF_REGISTER,SIZEOF_VOID_P,[size of machine integer registers])
2785 fi
2786
2787 if test "x$target_byte_order" = "xG_BIG_ENDIAN"; then
2788    AC_DEFINE(TARGET_BYTE_ORDER,G_BIG_ENDIAN,[byte order of target])
2789 elif test "x$target_byte_order" = "xG_LITTLE_ENDIAN"; then
2790    AC_DEFINE(TARGET_BYTE_ORDER,G_LITTLE_ENDIAN,[byte order of target])
2791 else
2792    AC_DEFINE(TARGET_BYTE_ORDER,G_BYTE_ORDER,[byte order of target])
2793 fi
2794
2795 if test "x$have_visibility_hidden" = "xyes"; then
2796    AC_DEFINE(HAVE_VISIBILITY_HIDDEN, 1, [Support for the visibility ("hidden") attribute])
2797 fi
2798
2799 if test "x$have_deprecated" = "xyes"; then
2800    AC_DEFINE(HAVE_DEPRECATED, 1, [Support for the deprecated attribute])
2801 fi
2802
2803 dnl 
2804 dnl Simple Generational checks (sgen)
2805 dnl
2806 if $sgen_supported; then
2807    build_sgen_default=yes
2808 else
2809    build_sgen_default=no
2810 fi
2811 SGEN_DEFINES=
2812 AC_ARG_WITH(sgen, [  --with-sgen=yes,no             Extra Generational GC, default=yes],[buildsgen=$with_sgen],[buildsgen=$build_sgen_default])
2813 if test x$buildsgen = xyes; then
2814    if $sgen_supported; then
2815        SGEN_DEFINES="-DHAVE_SGEN_GC -DHAVE_MOVING_COLLECTOR"
2816        gc_msg="sgen and $gc_msg"
2817    else
2818        buildsgen=no
2819        AC_MSG_WARN("Sgen is not supported on this platform")
2820    fi
2821 fi
2822 AC_SUBST(SGEN_DEFINES)
2823 AM_CONDITIONAL(SUPPORT_SGEN, test x$buildsgen = xyes)
2824
2825 USEJIT=false
2826 if test x$JIT_SUPPORTED = xyes; then
2827    if $jit_wanted; then
2828       USEJIT=true
2829       jit_status="Building and using the JIT"
2830    else
2831       if $interp_wanted; then
2832          jit_status="Building the JIT, defaulting to the interpreter"
2833       else
2834          AC_ERROR(No JIT or interpreter support available or selected.)
2835       fi
2836    fi
2837 else
2838    if test x$interp_wanted = xtrue; then
2839       jit_status="interpreter"
2840    else
2841       AC_ERROR(No JIT or interpreter support available or selected.)
2842    fi
2843 fi
2844
2845 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
2846
2847 libsuffix=".so"
2848
2849 case "$host" in
2850      *-*-darwin*)
2851         libsuffix=".dylib"
2852         LIBC="libc.dylib"
2853         INTL="libintl.dylib"
2854         SQLITE="libsqlite.0.dylib"
2855         SQLITE3="libsqlite3.0.dylib"
2856         X11="libX11.dylib"
2857         ;;
2858      *-*-*netbsd*)
2859         LIBC="libc.so.12"
2860         INTL="libintl.so.0"
2861         ;;
2862     *-*-*freebsd*)
2863         LIBC="libc.so"
2864         INTL="libintl.so"
2865         SQLITE="libsqlite.so"
2866         SQLITE3="libsqlite3.so"
2867         ;;
2868     *-*-*openbsd*)
2869         LIBC="libc.so"
2870         INTL="libintl.so"
2871         SQLITE="libsqlite.so"
2872         SQLITE3="libsqlite3.so"
2873         ;;
2874     *-*-*linux*)
2875         AC_PATH_X
2876         AC_MSG_CHECKING(for the soname of libX11.so)
2877         for i in $x_libraries /usr/lib /usr/lib64; do
2878                 for r in 4 5 6; do
2879                         if test -f $i/libX11.so.$r; then
2880                                 X11=libX11.so.$r
2881                                 AC_MSG_RESULT($X11)
2882                         fi
2883                 done
2884         done
2885         
2886         if test "x$X11" = "xlibX11.so"; then
2887                 AC_MSG_WARN([Could not find X development libs. Do you have the -devel package installed? Assuming libX11.so.6...]);
2888                 X11=libX11.so.6
2889         fi
2890         ;;
2891 esac
2892
2893
2894 AC_SUBST(libsuffix)
2895
2896 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
2897         if test "x$with_tls" = "x__thread"; then
2898                 #
2899                 # On some linux distributions, TLS works in executables, but linking 
2900                 # against a shared library containing TLS fails with:
2901                 # undefined reference to `__tls_get_addr'
2902                 #
2903                 rm -f conftest.c conftest.so conftest
2904                 echo "static __thread int foo; int main () { foo = 5; return 0; }" > conftest.c
2905                 $CC -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
2906                 $CC -o conftest conftest.so > /dev/null 2>&1
2907                 if test ! -f conftest; then
2908                    AC_MSG_WARN([Disabling usage of __thread.]);
2909                    with_tls=pthread
2910                 fi
2911                 rm -f conftest.c conftest.so conftest
2912         fi
2913 fi
2914
2915 mono_debugger_supported=no
2916 AC_ARG_ENABLE(mono-debugger, [  --disable-mono-debugger disable support for the mdb debugger], try_mono_debugger=$enableval, try_mono_debugger=yes)
2917 if test "x$try_mono_debugger" = "xyes"; then
2918         if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86" -o "x$TARGET" = "xS390x"; then
2919                 if test x$use_included_gc = xyes; then
2920                         case "$host" in
2921                         *-*-*linux*)
2922                                 mono_debugger_supported=yes
2923                                 ;;
2924                         *86-apple-darwin*)
2925                                 mono_debugger_supported=yes
2926                                 ;;              
2927                         esac
2928                 fi
2929         fi
2930 fi
2931
2932 # disable the debugger entirely when building with moonlight
2933 if test "x$with_moonlight" != "xno"; then
2934         mono_debugger_supported=no
2935 fi
2936
2937 # mdb support for sgen is broken, disable it until further notice.
2938 mono_debugger_supported=no
2939
2940 AC_MSG_CHECKING(if the Mono Debugger is supported on this platform)
2941 if test "x$mono_debugger_supported" = "xyes"; then
2942         BOEHM_DEFINES="$BOEHM_DEFINES -DMONO_DEBUGGER_SUPPORTED"
2943         CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DMONO_DEBUGGER_SUPPORTED"
2944 fi
2945 AM_CONDITIONAL(MONO_DEBUGGER_SUPPORTED, test x$mono_debugger_supported = xyes)
2946 AC_MSG_RESULT($mono_debugger_supported)
2947
2948 AC_ARG_ENABLE(icall-symbol-map,[  --enable-icall-symbol-map Generate tables which map icall functions to their C symbols], icall_symbol_map=$enableval, icall_symbol_map=no)
2949 if test "x$icall_symbol_map" = "xyes"; then
2950    AC_DEFINE(ENABLE_ICALL_SYMBOL_MAP, 1, [Icall symbol map enabled])
2951 fi
2952
2953 AC_ARG_ENABLE(icall-export,[  --enable-icall-export Export icall functions], icall_export=$enableval, icall_export=no)
2954 if test "x$icall_export" = "xyes"; then
2955    AC_DEFINE(ENABLE_ICALL_EXPORT, 1, [Icall export enabled])
2956 fi
2957
2958 AC_ARG_ENABLE(icall-tables,[  --disable-icall-tables Disable the runtime lookup of icalls], icall_tables=$enableval, icall_tables=yes)
2959 if test "x$icall_tables" = "xno"; then
2960    AC_DEFINE(DISABLE_ICALL_TABLES, 1, [Icall tables disabled])
2961 fi
2962
2963 if test "x$mono_cv_clang" = "xyes"; then
2964    # FIXME: This causes many compilation errors
2965    with_tls=pthread
2966 fi
2967
2968 if test "x$with_tls" = "x__thread"; then
2969         AC_DEFINE(HAVE_KW_THREAD, 1, [Have __thread keyword])
2970         # Pass the information to libgc
2971         CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
2972         AC_MSG_CHECKING(if the tls_model attribute is supported)
2973         AC_TRY_COMPILE([static __thread int foo __attribute__((tls_model("initial-exec")));], [
2974                 ], [
2975                         AC_MSG_RESULT(yes)
2976                         # CLANG doesn't support this yet, and it prints warnings about it
2977                         if test "x$mono_cv_clang" = "xno"; then
2978                                 AC_DEFINE(HAVE_TLS_MODEL_ATTR, 1, [tld_model available])
2979                         fi
2980                 ], [
2981                         AC_MSG_RESULT(no)
2982         ])
2983 fi
2984
2985 if test ${TARGET} = ARM; then
2986         dnl ******************************************
2987         dnl *** Check to see what FPU is available ***
2988         dnl ******************************************
2989         AC_MSG_CHECKING(which FPU to use)
2990
2991         #
2992         # This is a bit tricky:
2993         #
2994         # if (__ARM_PCS_VFP) {
2995         #       /* mfloat-abi=hard == VFP with hard ABI */
2996         # } elif (!__SOFTFP__) {
2997         #       /* mfloat-abi=softfp == VFP with soft ABI */
2998         # } else {
2999         #       /* mfloat-abi=soft == no VFP */
3000         # }
3001         #
3002         # The exception is iOS (w/ GCC) where none of the above
3003         # are defined (but iOS always uses the 'softfp' ABI).
3004         #
3005         # No support for FPA.
3006         #
3007
3008         fpu=NONE
3009
3010         # iOS GCC always uses the 'softfp' ABI.
3011         if test x"$GCC" = xyes && test x$platform_darwin = xyes; then
3012                 fpu=VFP
3013         fi
3014
3015         # Are we using the 'hard' ABI?
3016         if test x$fpu = xNONE; then
3017                 AC_TRY_COMPILE([], [
3018                         #ifndef __ARM_PCS_VFP
3019                         #error "Float ABI is not 'hard'"
3020                         #endif
3021                         return 0;
3022                 ], [
3023                         fpu=VFP_HARD
3024                 ], [
3025                         fpu=NONE
3026                 ])
3027         fi
3028
3029         # No 'hard' ABI. 'soft' or 'softfp'?
3030         if test x$fpu = xNONE; then
3031                 AC_TRY_COMPILE([], [
3032                         #ifdef __SOFTFP__
3033                         #error "Float ABI is not 'softfp'"
3034                         #endif
3035                         return 0;
3036                 ], [
3037                         fpu=VFP
3038                 ], [
3039                         fpu=NONE
3040                 ])
3041         fi
3042
3043         AC_MSG_RESULT($fpu)
3044         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu=1"
3045         unset fpu
3046
3047         if test x$cross_compiling = xno; then
3048                 AC_MSG_CHECKING(for ARMV6)
3049                 AC_TRY_RUN([
3050                         int main () { __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); return 0; }
3051                                 ], armv6=yes, armv6=no)
3052
3053                 AC_MSG_RESULT($armv6)
3054                 if test ${armv6} = yes; then
3055                    AC_DEFINE(HAVE_ARMV6, 1, "Host supports ARMV6 instructions")
3056                    # libgc's gc_locks.h depends on this
3057                    CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DHAVE_ARMV6"
3058                 fi
3059         fi
3060 fi
3061
3062 if test ${TARGET} = ARM; then
3063         if test "x${with_jumptables}" = "xyes"; then
3064                 AC_DEFINE(USE_JUMP_TABLES, 1, Use jump tables in JIT)
3065         fi
3066 fi
3067
3068 if test ${TARGET} = unknown; then
3069         CPPFLAGS="$CPPFLAGS -DNO_PORT"
3070         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
3071 fi
3072
3073 if test ${ACCESS_UNALIGNED} = no; then
3074         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
3075 fi
3076
3077 case "x$gc" in
3078         xincluded)
3079                 # Pass CPPFLAGS to libgc configure
3080                 # We should use a separate variable for this to avoid passing useless and
3081                 # potentially problematic defines to libgc (like -D_FILE_OFFSET_BITS=64)
3082                 # This should be executed late so we pick up the final version of CPPFLAGS
3083                 # The problem with this approach, is that during a reconfigure, the main
3084                 # configure scripts gets invoked with these arguments, so we use separate
3085                 # variables understood by libgc's configure to pass CPPFLAGS and CFLAGS.
3086                 TMP_CPPFLAGS="$CPPFLAGS $CPPFLAGS_FOR_LIBGC"
3087                 if test x$TARGET = xSPARC -o x$TARGET = xSPARC64; then
3088                         TMP_CPPFLAGS=`echo $TMP_CPPFLAGS | sed -e 's/-D_FILE_OFFSET_BITS=64//g'`
3089                 fi
3090                 # Don't pass -finstrument-for-thread-suspension in, 
3091                 # if these are instrumented it will be very bad news 
3092                 # (infinite recursion, undefined parking behavior, etc)
3093                 TMP_CPPFLAGS=`echo $TMP_CPPFLAGS | sed -e 's/-finstrument-for-thread-suspension//g'`
3094                 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads $libgc_configure_args \"CPPFLAGS_FOR_LIBGC=$TMP_CPPFLAGS\" \"CFLAGS_FOR_LIBGC=$CFLAGS_FOR_LIBGC\""
3095                 AC_CONFIG_SUBDIRS(libgc)
3096                 ;;
3097 esac
3098
3099 AC_ARG_WITH(profile2,  [  --with-profile2=yes,no          If you want to install the 2.0/3.5 FX (defaults to yes)],            [], [with_profile2=yes])
3100 AC_ARG_WITH(profile4,  [  --with-profile4=yes,no          If you want to install the 4.0 FX (defaults to yes)],                [], [with_profile4=yes])
3101 AC_ARG_WITH(profile4_5,[  --with-profile4_5=yes,no        If you want to install the 4.5 FX (defaults to yes)],                [], [with_profile4_5=yes])
3102 AC_ARG_WITH(monodroid, [  --with-monodroid=yes,no         If you want to build the MonoDroid assemblies (defaults to no)],     [], [with_monodroid=no])
3103 AC_ARG_WITH(monotouch, [  --with-monotouch=yes,no,only    If you want to build the MonoTouch assemblies (defaults to no)],     [], [with_monotouch=no])
3104 AC_ARG_WITH(mobile,    [  --with-mobile=yes,no            If you want to build the Mobile assemblies (defaults to no)],        [], [with_mobile=no])
3105
3106 OPROFILE=no
3107 AC_ARG_WITH(oprofile,[  --with-oprofile=no,<oprofile install dir>   Enable oprofile support (defaults to no)],[
3108         if test x$with_oprofile != xno; then
3109             oprofile_include=$with_oprofile/include
3110             if test ! -f $oprofile_include/opagent.h; then
3111                   AC_MSG_ERROR([oprofile include file not found at $oprofile_include/opagent.h])
3112                 fi
3113             OPROFILE=yes
3114                 OPROFILE_CFLAGS="-I$oprofile_include"
3115             OPROFILE_LIBS="-L$with_oprofile/lib/oprofile -lopagent"
3116             AC_DEFINE(HAVE_OPROFILE,1,[Have oprofile support])
3117         fi
3118 ])
3119
3120 MALLOC_MEMPOOLS=no
3121 AC_ARG_WITH(malloc_mempools,[  --with-malloc-mempools=yes,no  Use malloc for each single mempool allocation (only for runtime debugging, defaults to no)],[
3122         if test x$with_malloc_mempools = xyes; then
3123                 MALLOC_MEMPOOLS=yes
3124                 AC_DEFINE(USE_MALLOC_FOR_MEMPOOLS,1,[Use malloc for each single mempool allocation])
3125         fi
3126 ])
3127
3128
3129 DISABLE_MCS_DOCS=no
3130 AC_ARG_WITH(mcs_docs,[  --with-mcs-docs=yes,no         If you want to build the documentation under mcs (defaults to yes)],[
3131         if test x$with_mcs_docs != xyes; then
3132                 DISABLE_MCS_DOCS=yes
3133         fi
3134 ])
3135 if test x$with_profile4 != xyes; then
3136         DISABLE_MCS_DOCS=yes
3137 fi
3138
3139 MOONLIGHT_DEFINES=
3140 AC_ARG_WITH(moonlight, [  --with-moonlight=yes|no|only         If you want to build Mono for Moonlight (defaults to no)],[
3141         if test x$with_moonlight != xno; then
3142         MOONLIGHT_DEFINES="-DMOONLIGHT -DDISABLE_ASSEMBLY_REMAPPING "
3143         fi
3144 ], [with_moonlight=no])
3145 AC_SUBST(MOONLIGHT_DEFINES)
3146
3147 AC_ARG_WITH(moon_gc, [  --with-moon-gc=boehm,sgen               Select the gc to use with Moonlight (defaults to boehm)],[
3148         if test "x$with_moon_gc" != "xsgen"; then
3149                 with_moon_gc=boehm
3150         fi
3151 ], [with_moon_gc=boehm])
3152
3153 AC_ARG_WITH(lazy_gc_thread_creation, [  --with-lazy-gc-thread-creation=yes|no      Enable lazy runtime thread creation, embedding host must do it explicitly (defaults to no)],[
3154         if test x$with_lazy_gc_thread_creation != xno ; then
3155                 AC_DEFINE(LAZY_GC_THREAD_CREATION,1,[Enable lazy gc thread creation by the embedding host.])
3156         fi
3157 ], [with_lazy_gc_thread_creation=no])
3158
3159 AC_CHECK_HEADER([malloc.h], 
3160                 [AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1], 
3161                         [Define to 1 if you have /usr/include/malloc.h.])],,)
3162
3163 if test x"$GCC" = xyes; then
3164         # Implicit function declarations are not 64 bit safe
3165         # Do this late, since this causes lots of configure tests to fail
3166         CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
3167         # jay has a lot of implicit declarations
3168         JAY_CFLAGS="-Wno-implicit-function-declaration"
3169 fi
3170
3171 # When --disable-shared is used, libtool transforms libmono-2.0.la into libmono-2.0.so
3172 # instead of libmono-static.a
3173 if test "x$enable_shared" = "xno" -a "x$enable_executables" = "xyes"; then
3174    LIBMONO_LA=libmini-static.la
3175 else
3176    LIBMONO_LA=libmonosgen-$API_VER.la
3177 fi
3178 AC_SUBST(LIBMONO_LA)
3179
3180 dnl
3181 dnl Consistency settings
3182 dnl
3183 if test x$cross_compiling = xyes -o x$enable_mcs_build = xno; then
3184    DISABLE_MCS_DOCS=yes
3185    with_profile2=no
3186    with_profile4=no
3187    with_profile4_5=no
3188    with_monodroid=no
3189    with_monotouch=no
3190 fi
3191
3192 if test x$DISABLE_MCS_DOCS = xyes; then
3193    docs_dir=""
3194 else
3195    docs_dir=docs
3196 fi
3197 AC_SUBST(docs_dir)
3198
3199 ## Maybe should also disable if mcsdir is invalid.  Let's punt the issue for now.
3200 AM_CONDITIONAL(BUILD_MCS, [test x$cross_compiling = xno && test x$enable_mcs_build != xno])
3201
3202 AM_CONDITIONAL(HAVE_OPROFILE, test x$OPROFILE = xyes)
3203 AC_SUBST(OPROFILE_CFLAGS)
3204 AC_SUBST(OPROFILE_LIBS)
3205
3206 libmono_ldflags="$libmono_ldflags $LIBS"
3207
3208 AM_CONDITIONAL(MOONLIGHT, [test "x$with_moonlight" != "xno"])
3209
3210 AM_CONDITIONAL(ONLY_MOONLIGHT, [test "x$with_moonlight" = "xonly"])
3211 AM_CONDITIONAL(MOONLIGHT_BOEHM, [test "x$with_moon_gc" = "xboehm"])
3212 AM_CONDITIONAL(MOONLIGHT_SGEN, [test "x$with_moon_gc" = "xsgen"])
3213
3214 AM_CONDITIONAL(INSTALL_2_0, [test "x$with_profile2" = xyes])
3215 AM_CONDITIONAL(INSTALL_4_0, [test "x$with_profile4" = xyes])
3216 AM_CONDITIONAL(INSTALL_4_5, [test "x$with_profile4_5" = xyes])
3217 AM_CONDITIONAL(INSTALL_MONODROID, [test "x$with_monodroid" != "xno"])
3218 AM_CONDITIONAL(INSTALL_MONOTOUCH, [test "x$with_monotouch" != "xno"])
3219 AM_CONDITIONAL(INSTALL_MOBILE, [test "x$with_mobile" = xyes])
3220 AM_CONDITIONAL(ONLY_MONOTOUCH, [test "x$with_monotouch" = "xonly"])
3221
3222 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
3223 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
3224 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
3225 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
3226 AM_CONDITIONAL(X86, test x$TARGET = xX86)
3227 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
3228 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
3229 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
3230 AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
3231 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
3232 AM_CONDITIONAL(POWERPC64, test x$TARGET = xPOWERPC64)
3233 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
3234 AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
3235 AM_CONDITIONAL(HOST_X86, test x$HOST = xX86)
3236 AM_CONDITIONAL(HOST_AMD64, test x$HOST = xAMD64)
3237 AM_CONDITIONAL(HOST_ARM, test x$HOST = xARM)
3238 AM_CONDITIONAL(CROSS_COMPILE, test "x$host" != "x$target")
3239
3240 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
3241 AM_CONDITIONAL(INTERP_SUPPORTED, test x$interp_wanted = xtrue)
3242 AM_CONDITIONAL(INCLUDED_LIBGC, test x$gc = xincluded)
3243
3244 AC_SUBST(LIBC)
3245 AC_SUBST(INTL)
3246 AC_SUBST(SQLITE)
3247 AC_SUBST(SQLITE3)
3248 AC_SUBST(X11)
3249 AC_DEFINE_UNQUOTED(ARCHITECTURE,"$arch_target",[The architecture this is running on])
3250 AC_SUBST(arch_target)
3251 AC_SUBST(CFLAGS)
3252 AC_SUBST(CPPFLAGS)
3253 AC_SUBST(LDFLAGS)
3254
3255 mono_build_root=`pwd`
3256 AC_SUBST(mono_build_root)
3257
3258 if test x$USEJIT = xtrue; then
3259   mono_runtime=mono/mini/mono
3260 else
3261   mono_runtime=mono/interpreter/mint
3262 fi
3263 AC_SUBST(mono_runtime)
3264
3265 mono_cfg_root=$mono_build_root/runtime
3266 if test x$host_win32 = xyes; then
3267   if test "x$cross_compiling" = "xno"; then
3268     mono_cfg_dir=`cygpath -w -a $mono_cfg_root`\\etc
3269   else
3270     mono_cfg_dir=`echo $mono_cfg_root | tr '/' '\\'`\\etc
3271   fi
3272 else
3273   mono_cfg_dir=$mono_cfg_root/etc
3274 fi
3275 AC_SUBST(mono_cfg_dir)
3276
3277 AC_CONFIG_FILES([po/mcs/Makefile.in])
3278
3279 AC_CONFIG_FILES([runtime/mono-wrapper],[chmod +x runtime/mono-wrapper])
3280 AC_CONFIG_FILES([runtime/monodis-wrapper],[chmod +x runtime/monodis-wrapper])
3281
3282 AC_CONFIG_COMMANDS([runtime/etc/mono/1.0/machine.config],
3283 [   depth=../../../..
3284     case $srcdir in
3285     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3286     .) reldir=$depth ;;
3287     *) reldir=$depth/$srcdir ;;
3288     esac
3289     $ac_aux_dir/install-sh -d runtime/etc/mono/1.0
3290     cd runtime/etc/mono/1.0
3291     rm -f machine.config
3292     $LN_S $reldir/data/net_1_1/machine.config machine.config
3293     cd $depth
3294 ],[LN_S='$LN_S'])
3295
3296 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/machine.config],
3297 [   depth=../../../..
3298     case $srcdir in
3299     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3300     .) reldir=$depth ;;
3301     *) reldir=$depth/$srcdir ;;
3302     esac
3303     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
3304     cd runtime/etc/mono/2.0
3305     rm -f machine.config
3306     $LN_S $reldir/data/net_2_0/machine.config machine.config
3307     cd $depth
3308 ],[LN_S='$LN_S'])
3309
3310 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/web.config],
3311 [   depth=../../../..
3312     case $srcdir in
3313     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3314     .) reldir=$depth ;;
3315     *) reldir=$depth/$srcdir ;;
3316     esac
3317     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
3318     cd runtime/etc/mono/2.0
3319     rm -f web.config
3320     $LN_S $reldir/data/net_2_0/web.config web.config
3321     cd $depth
3322 ],[LN_S='$LN_S'])
3323
3324 AC_CONFIG_COMMANDS([runtime/etc/mono/browscap.ini],
3325 [   depth=../../..
3326     case $srcdir in
3327     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3328     .) reldir=$depth ;;
3329     *) reldir=$depth/$srcdir ;;
3330     esac
3331     $ac_aux_dir/install-sh -d runtime/etc/mono/
3332     cd runtime/etc/mono/
3333     rm -f browscap.ini
3334     $LN_S $reldir/data/browscap.ini browscap.ini
3335     cd $depth
3336 ],[LN_S='$LN_S'])
3337
3338 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/Browsers/Compat.browser],
3339 [   depth=../../../../..
3340     case $srcdir in
3341     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3342     .) reldir=$depth ;;
3343     *) reldir=$depth/$srcdir ;;
3344     esac
3345     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0/Browsers/
3346     cd runtime/etc/mono/2.0/Browsers
3347     rm -f Compat.browser
3348     $LN_S $reldir/data/net_2_0/Browsers/Compat.browser Compat.browser
3349     cd $depth
3350 ],[LN_S='$LN_S'])
3351
3352 AC_CONFIG_COMMANDS([runtime/etc/mono/4.0/machine.config],
3353 [   depth=../../../..
3354     case $srcdir in
3355     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3356     .) reldir=$depth ;;
3357     *) reldir=$depth/$srcdir ;;
3358     esac
3359     $ac_aux_dir/install-sh -d runtime/etc/mono/4.0
3360     cd runtime/etc/mono/4.0
3361     rm -f machine.config
3362     $LN_S $reldir/data/net_4_0/machine.config machine.config
3363     cd $depth
3364 ],[LN_S='$LN_S'])
3365
3366 AC_CONFIG_COMMANDS([runtime/etc/mono/4.0/web.config],
3367 [   depth=../../../..
3368     case $srcdir in
3369     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3370     .) reldir=$depth ;;
3371     *) reldir=$depth/$srcdir ;;
3372     esac
3373     $ac_aux_dir/install-sh -d runtime/etc/mono/4.0
3374     cd runtime/etc/mono/4.0
3375     rm -f web.config
3376     $LN_S $reldir/data/net_4_0/web.config web.config
3377     cd $depth
3378 ],[LN_S='$LN_S'])
3379
3380 AC_CONFIG_COMMANDS([runtime/etc/mono/4.5/machine.config],
3381 [   depth=../../../..
3382     case $srcdir in
3383     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3384     .) reldir=$depth ;;
3385     *) reldir=$depth/$srcdir ;;
3386     esac
3387     $ac_aux_dir/install-sh -d runtime/etc/mono/4.5
3388     cd runtime/etc/mono/4.5
3389     rm -f machine.config
3390     $LN_S $reldir/data/net_4_5/machine.config machine.config
3391     cd $depth
3392 ],[LN_S='$LN_S'])
3393
3394 AC_CONFIG_COMMANDS([runtime/etc/mono/4.5/web.config],
3395 [   depth=../../../..
3396     case $srcdir in
3397     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
3398     .) reldir=$depth ;;
3399     *) reldir=$depth/$srcdir ;;
3400     esac
3401     $ac_aux_dir/install-sh -d runtime/etc/mono/4.5
3402     cd runtime/etc/mono/4.5
3403     rm -f web.config
3404     $LN_S $reldir/data/net_4_5/web.config web.config
3405     cd $depth
3406 ],[LN_S='$LN_S'])
3407
3408 AC_CONFIG_COMMANDS([quiet-libtool], [sed -e 's/echo "copying selected/# "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])
3409
3410 AC_OUTPUT([
3411 Makefile
3412 mono-core.spec
3413 mono-uninstalled.pc
3414 scripts/mono-find-provides
3415 scripts/mono-find-requires
3416 mono/Makefile
3417 mono/utils/Makefile
3418 mono/metadata/Makefile
3419 mono/dis/Makefile
3420 mono/cil/Makefile
3421 mono/arch/Makefile
3422 mono/arch/x86/Makefile
3423 mono/arch/amd64/Makefile
3424 mono/arch/ppc/Makefile
3425 mono/arch/sparc/Makefile
3426 mono/arch/s390x/Makefile
3427 mono/arch/arm/Makefile
3428 mono/arch/ia64/Makefile
3429 mono/arch/mips/Makefile
3430 mono/interpreter/Makefile
3431 mono/tests/Makefile
3432 mono/tests/tests-config
3433 mono/tests/assemblyresolve/Makefile
3434 mono/tests/cas/Makefile
3435 mono/tests/cas/assembly/Makefile
3436 mono/tests/cas/demand/Makefile
3437 mono/tests/cas/inheritance/Makefile
3438 mono/tests/cas/linkdemand/Makefile
3439 mono/tests/cas/threads/Makefile
3440 mono/tests/gc-descriptors/Makefile
3441 mono/benchmark/Makefile
3442 mono/monograph/Makefile
3443 mono/io-layer/Makefile
3444 mono/mini/Makefile
3445 mono/profiler/Makefile
3446 m4/Makefile
3447 ikvm-native/Makefile
3448 scripts/Makefile
3449 man/Makefile
3450 docs/Makefile
3451 data/Makefile
3452 data/net_2_0/Makefile
3453 data/net_4_0/Makefile
3454 data/net_4_5/Makefile
3455 data/net_2_0/Browsers/Makefile
3456 data/mint.pc
3457 data/mono-2.pc
3458 data/monosgen-2.pc
3459 data/mono.pc
3460 data/mono-cairo.pc
3461 data/mono-nunit.pc
3462 data/mono-options.pc
3463 data/mono-lineeditor.pc
3464 data/monodoc.pc
3465 data/mono.web.pc
3466 data/dotnet.pc
3467 data/dotnet35.pc
3468 data/wcf.pc
3469 data/cecil.pc
3470 data/system.web.extensions_1.0.pc
3471 data/system.web.extensions.design_1.0.pc
3472 data/system.web.mvc.pc
3473 data/system.web.mvc2.pc
3474 data/system.web.mvc3.pc
3475 data/aspnetwebstack.pc
3476 data/reactive.pc
3477 samples/Makefile
3478 support/Makefile
3479 data/config
3480 tools/Makefile
3481 tools/locale-builder/Makefile
3482 tools/sgen/Makefile
3483 runtime/Makefile
3484 msvc/Makefile
3485 po/Makefile
3486 ])
3487
3488 # Update all submodules recursively to ensure everything is checked out
3489 $srcdir/scripts/update_submodules
3490
3491 if test x$host_win32 = xyes; then
3492    # Get rid of 'cyg' prefixes in library names
3493    sed -e "s/\/cyg\//\/\//" libtool > libtool.new; mv libtool.new libtool; chmod 755 libtool
3494    # libtool seems to inherit -mno-cygwin from our CFLAGS, and uses it to compile its executable
3495    # wrapper scripts which use exec(). gcc has no problem compiling+linking this, but the resulting
3496    # executable doesn't work...
3497    sed -e "s,-mno-cygwin,,g" libtool > libtool.new; mv libtool.new libtool; chmod 755 libtool
3498 fi
3499
3500 if test x$platform_darwin = xyes; then
3501    # This doesn't seem to be required and it slows down parallel builds
3502    sed -e 's,lock_old_archive_extraction=yes,lock_old_archive_extraction=no,g' < libtool > libtool.new && mv libtool.new libtool && chmod +x libtool
3503 fi
3504
3505 (
3506   case $prefix in
3507   NONE) prefix=$ac_default_prefix ;;
3508   esac
3509   case $exec_prefix in
3510   NONE) exec_prefix='${prefix}' ;;
3511   esac
3512
3513   #
3514   # If we are cross compiling, we don't build in the mcs/ tree.  Let us not clobber
3515   # any existing config.make.  This allows people to share the same source tree
3516   # with different build directories, one native and one cross
3517   #
3518   if test x$cross_compiling = xno && test x$enable_mcs_build != xno; then
3519
3520     test -w $mcs_topdir/build || chmod +w $mcs_topdir/build
3521
3522     echo "prefix=$prefix" > $mcs_topdir/build/config.make
3523     echo "exec_prefix=$exec_prefix" >> $mcs_topdir/build/config.make
3524     echo "sysconfdir=$sysconfdir" >> $mcs_topdir/build/config.make
3525     echo 'mono_libdir=${exec_prefix}/lib' >> $mcs_topdir/build/config.make
3526     echo 'IL_FLAGS = /debug' >> $mcs_topdir/build/config.make
3527     echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $mcs_topdir/build/config.make
3528     echo "ILDISASM = $mono_build_root/runtime/monodis-wrapper" >> $mcs_topdir/build/config.make
3529     echo "JAY_CFLAGS = $JAY_CFLAGS" >> $mcs_topdir/build/config.make
3530
3531     case $INSTALL in
3532     [[\\/$]]* | ?:[[\\/]]* ) mcs_INSTALL=$INSTALL ;;
3533     *) mcs_INSTALL=$mono_build_root/$INSTALL ;;
3534     esac
3535
3536     echo "INSTALL = $mcs_INSTALL" >> $mcs_topdir/build/config.make
3537
3538     export VERSION
3539     [myver=$($AWK 'BEGIN {
3540       split (ENVIRON["VERSION"] ".0.0.0", vsplit, ".")
3541       if(length(vsplit [1]) > 4) {
3542         split (substr(ENVIRON["VERSION"], 0, 4) "." substr(ENVIRON["VERSION"], 5) ".0.0", vsplit, ".")
3543       }
3544       print vsplit [1] "." vsplit [2] "." vsplit [3] "." vsplit [4]
3545     }')]
3546
3547     echo "MONO_VERSION = $myver" >> $mcs_topdir/build/config.make
3548
3549     if test x$platform_darwin = xyes; then
3550       echo "PLATFORM = darwin" >> $mcs_topdir/build/config.make
3551     fi
3552
3553         if test x$AOT_SUPPORTED = xyes -a x$enable_system_aot = xdefault; then
3554            enable_system_aot=yes
3555         fi
3556
3557         if test "x$enable_loadedllvm" = "xyes"; then
3558            # This seems to fail on the x86 buildbots
3559            enable_system_aot=no
3560         fi
3561
3562     if test x$host_win32 = xno -a x$enable_system_aot = xyes; then
3563       echo "ENABLE_AOT = 1" >> $mcs_topdir/build/config.make
3564     fi
3565
3566     if test x$DISABLE_MCS_DOCS = xyes; then
3567       echo "DISABLE_MCS_DOCS = yes" >> $mcs_topdir/build/config.make
3568     fi
3569
3570     if test x$with_moonlight != xno; then
3571       echo "MOONLIGHT = 1" >> $srcdir/$mcsdir/build/config.make
3572     fi
3573
3574     if test x$has_extension_module != xno; then
3575         echo "EXTENSION_MODULE = 1" >> $srcdir/$mcsdir/build/config.make
3576     fi
3577
3578         default_profile=net_2_0
3579     if test -z "$INSTALL_4_0_TRUE"; then :
3580                 default_profile=net_4_0
3581     fi
3582     if test -z "$INSTALL_MONODROID_TRUE"; then :
3583                 default_profile=monodroid
3584     fi
3585     if test -z "$INSTALL_MONOTOUCH_TRUE"; then :
3586                 default_profile=monotouch
3587     fi
3588     if test -z "$INSTALL_4_5_TRUE"; then :
3589                 default_profile=net_4_5
3590     fi
3591     
3592     echo "DEFAULT_PROFILE = $default_profile" >> $srcdir/$mcsdir/build/config.make
3593     
3594     if test "x$test_bcl_opt" = "xyes"; then    
3595       echo "BCL_OPTIMIZE = 1" >> $srcdir/$mcsdir/build/config.make
3596     fi
3597
3598   fi
3599
3600   # if we have an olive folder, override the default settings
3601   if test -d $olivedir; then
3602
3603     if test x$cross_compiling = xno && test x$enable_olive_build != xno; then
3604
3605       test -w $srcdir/$olivedir/build || chmod +w $srcdir/$olivedir/build
3606
3607       echo "prefix=$prefix" > $srcdir/$olivedir/build/config.make
3608       echo "exec_prefix=$exec_prefix" >> $srcdir/$olivedir/build/config.make
3609       echo 'mono_libdir=${exec_prefix}/lib' >> $srcdir/$olivedir/build/config.make
3610       echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $srcdir/$olivedir/build/config.make
3611       echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $srcdir/$olivedir/build/config.make
3612       echo "MONO_VERSION = $myver" >> $srcdir/$olivedir/build/config.make
3613     fi
3614   fi
3615
3616 )
3617
3618 libgdiplus_msg=${libgdiplus_loc:-assumed to be installed}
3619
3620 echo "
3621         mcs source:    $mcsdir
3622
3623    Engine:
3624         GC:            $gc_msg 
3625         TLS:           $with_tls
3626         SIGALTSTACK:   $with_sigaltstack
3627         Engine:        $jit_status
3628         oprofile:      $OPROFILE
3629         BigArrays:     $enable_big_arrays
3630         DTrace:        $enable_dtrace
3631         LLVM Back End: $enable_llvm (dynamically loaded: $enable_loadedllvm)
3632
3633    Libraries:
3634         .NET 2.0/3.5:  $with_profile2
3635         .NET 4.0:      $with_profile4
3636         .NET 4.5:      $with_profile4_5
3637         MonoDroid:     $with_monodroid
3638         MonoTouch:     $with_monotouch
3639         JNI support:   $jdk_headers_found
3640         libgdiplus:    $libgdiplus_msg
3641         zlib:          $zlib_msg
3642         $disabled
3643 "
3644 if test x$with_static_mono = xno -a "x$host_win32" != "xyes"; then
3645    AC_MSG_WARN(Turning off static Mono is a risk, you might run into unexpected bugs)
3646 fi