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