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