2007-11-05 Geoff Norton <gnorton@novell.com>
[mono.git] / configure.in
blob443d783748fb9a2cf05a3c93339c995f618f9476
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
4 # Gross hack to enable 'make dist' on automake 1.9+tar 1.14.
5 # The extra brackets are to foil regex-based scans.
6 m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
8 AM_CONFIG_HEADER(config.h)
9 AM_INIT_AUTOMAKE(mono,1.2.5.99)
10 AM_MAINTAINER_MODE
12 API_VER=1.0
13 AC_SUBST(API_VER)
15 AC_PROG_LN_S
17 # In case of cygwin, override LN_S, irrespective of what it determines.
18 # The build uses cygwin, but the actual runtime doesn't.
19 case $host_os in
20 *cygwin* ) LN_S='cp -p';;
21 esac
24 dnl
25 dnl libgc checks
26 dnl
28 gc_headers=no
29 gc=included
30 use_included_gc=no
31 libgc_configure_args=
33 if test -d $srcdir/libgc ; then
34   gc_default=included
35 else
36   gc_default=boehm
40 # These are the flags that need to be stored in the mono.pc file for 
41 # compiling code that will embed Mono
43 libmono_cflags=""
44 libmono_ldflags=""
45 AC_SUBST(libmono_cflags)
46 AC_SUBST(libmono_ldflags)
47 export_ldflags=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
48 AC_SUBST(export_ldflags)
50 # Variable to have relocatable .pc files (lib, or lib64)
51 reloc_libdir=`basename ${libdir}`
52 AC_SUBST(reloc_libdir)
54 dnl if linker handles the version script
55 no_version_script=no
57 # Set to yes if Unix sockets cannot be created in an anonymous namespace
58 need_link_unlink=no
60 # Thread configuration inspired by sleepycat's db
61 AC_MSG_CHECKING([host platform characteristics])
62 libgc_threads=no
63 case "$host" in
64         *-*-mingw*|*-*-cygwin*)
65                 platform_win32=yes
66                 AC_DEFINE(PLATFORM_WIN32,1,[Platform is Win32])
67                 if test "x$cross_compiling" = "xno"; then
68                         CC="gcc -mno-cygwin -g"
69                         # So libgc configure gets -mno-cygwin
70                         export CC
71                 fi
72                 HOST_CC="gcc"
73                 CPPFLAGS="$CPPFLAGS -DWIN32_THREADS -DFD_SETSIZE=1024 -DUNICODE -D_UNICODE"
74                 libmono_cflags="-mno-cygwin"
75                 libmono_ldflags="-mno-cygwin"
76                 libdl=
77                 libgc_threads=win32
78                 gc_default=included
79                 with_sigaltstack=no
80                 LN_S=cp
81                 # This forces libgc to use the DllMain based thread registration code on win32
82                 libgc_configure_args="$libgc_configure_args --enable-win32-dllmain=yes"
83                 ;;
84         *-*-*netbsd*)
85                 platform_win32=no
86                 CPPFLAGS="$CPPFLAGS -D_REENTRANT -DGC_NETBSD_THREADS -D_GNU_SOURCE"
87                 libmono_cflags="-D_REENTRANT"
88                 LDFLAGS="$LDFLAGS -pthread"
89                 CPPFLAGS="$CPPFLAGS -DPLATFORM_BSD"
90                 libmono_ldflags="-pthread"
91                 need_link_unlink=yes
92                 libdl="-ldl"
93                 libgc_threads=pthreads
94                 with_sigaltstack=no
95                 ;;
96 # these flags will work for all versions of -STABLE
98         *-*-*freebsd4*)
99                 platform_win32=no
100                 if test "x$PTHREAD_CFLAGS" = "x"; then
101                         CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
102                         libmono_cflags="-D_THREAD_SAFE"
103                 else
104                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
105                         libmono_cflags="$PTHREAD_CFLAGS"
106                 fi
107                 if test "x$PTHREAD_LIBS" = "x"; then
108                         LDFLAGS="$LDFLAGS -pthread"
109                         libmono_ldflags="-pthread"
110                 else
111                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
112                         libmono_ldflags="$PTHREAD_LIBS"
113                 fi
114                 CPPFLAGS="$CPPFLAGS -DPLATFORM_BSD -DPLATFORM_BSD4"
115                 need_link_unlink=yes
116                 AC_DEFINE(PTHREAD_POINTER_ID)
117                 libdl=
118                 libgc_threads=pthreads
119 # TLS isn't implemented at all on 4-STABLE
120                 with_tls=pthread
121                 ;;
122         *-*-*freebsd5*)
123                 platform_win32=no
124                 if test "x$PTHREAD_CFLAGS" = "x"; then
125                         CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
126                         libmono_cflags=
127                 else
128                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
129                         libmono_cflags="$PTHREAD_CFLAGS"
130                 fi
131                 if test "x$PTHREAD_LIBS" = "x"; then
132                         LDFLAGS="$LDFLAGS -pthread"
133                         libmono_ldflags="-pthread"
134                 else
135                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
136                         libmono_ldflags="$PTHREAD_LIBS"
137                 fi
138                 CPPFLAGS="$CPPFLAGS -DPLATFORM_BSD -DPLATFORM_BSD5"
139                 need_link_unlink=yes
140                 AC_DEFINE(PTHREAD_POINTER_ID)
141                 libdl=
142                 with_sigaltstack=yes
143                 libgc_threads=pthreads
144 # TLS is only partially implemented on 5-STABLE (compiler support
145 # but NOT library support)
147                 with_tls=pthread
148                 ;;
149         *-*-*freebsd6*)
150                 platform_win32=no
151                 if test "x$PTHREAD_CFLAGS" = "x"; then
152                         CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
153                         libmono_cflags=
154                 else
155                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
156                         libmono_cflags="$PTHREAD_CFLAGS"
157                 fi
158                 if test "x$PTHREAD_LIBS" = "x"; then
159                         LDFLAGS="$LDFLAGS -pthread"
160                         libmono_ldflags="-pthread"
161                 else
162                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
163                         libmono_ldflags="$PTHREAD_LIBS"
164                 fi
165                 CPPFLAGS="$CPPFLAGS -DPLATFORM_BSD -DPLATFORM_BSD6"
166                 need_link_unlink=yes
167                 AC_DEFINE(PTHREAD_POINTER_ID)
168                 libdl=
169                 libgc_threads=pthreads
170                 with_sigaltstack=yes
171 # TLS is only partially implemented on -CURRENT (compiler support
172 # but NOT library support)
174                 with_tls=pthread
175                 ;;
176         *-*-*openbsd*)
177                 platform_win32=no
178                 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
179                 libmono_cflags="-D_THREAD_SAFE"
180                 LDFLAGS="$LDFLAGS -pthread"
181                 libmono_ldflags="-pthread"
182                 need_link_unlink=yes
183                 AC_DEFINE(PTHREAD_POINTER_ID)
184                 libdl=
185                 libgc_threads=pthreads
186                 ;;
187         *-*-linux*)
188                 platform_win32=no
189                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP -DUSE_MUNMAP"
190                 libmono_cflags="-D_REENTRANT"
191                 libmono_ldflags="-lpthread"
192                 libdl="-ldl"
193                 libgc_threads=pthreads
194                 ;;
195         *-*-hpux*)
196         platform_win32=no
197                 CPPFLAGS="$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
198                 # +ESdbgasm only valid on bundled cc on RISC
199                 # silently ignored for ia64
200                 if test $GCC != "yes"; then
201                         CFLAGS="$CFLAGS +ESdbgasm"
202                         # Arrange for run-time dereferencing of null
203                         # pointers to produce a SIGSEGV signal.
204                         LDFLAGS="$LDFLAGS -z"
205                 fi
206                 CFLAGS="$CFLAGS +ESdbgasm"
207                 LDFLAGS="$LDFLAGS -z"
208                 libmono_cflags="-D_REENTRANT"
209                 libmono_ldflags="-lpthread"
210                 libgc_threads=pthreads
211                 need_link_unlink=yes
212                 ;;
213         *-*-solaris*)
214                 platform_win32=no
215                 CPPFLAGS="$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP"
216                 need_link_unlink=yes
217                 libmono_cflags="-D_REENTRANT"
218                 libgc_threads=pthreads
219                 # This doesn't seem to work on solaris/x86, but the configure test runs
220                 with_tls=pthread
221                 ;;
222         *-*-darwin*)
223                 platform_win32=no
224                 CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE -DGC_MACOSX_THREADS -DPLATFORM_MACOSX -DUSE_MMAP -DUSE_MUNMAP"
225                 CPPFLAGS="$CPPFLAGS -DGetCurrentProcess=MonoGetCurrentProcess -DGetCurrentThread=MonoGetCurrentThread -DCreateEvent=MonoCreateEvent"
226                 libmono_cflags="-D_THREAD_SAFE"
227                 LDFLAGS="$LDFLAGS -pthread"
228                 libmono_ldflags="-pthread"
229                 need_link_unlink=yes
230                 AC_DEFINE(PTHREAD_POINTER_ID)
231                 AC_DEFINE(USE_MACH_SEMA)
232                 no_version_script=yes
233                 libdl=
234                 libgc_threads=pthreads
235                 ;;
236         *)
237                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
238                 platform_win32=no
239                 libdl="-ldl"
240                 ;;
241 esac
242 AC_MSG_RESULT(ok)
244 if test x$need_link_unlink = xyes; then
245    AC_DEFINE(NEED_LINK_UNLINK, 1, [Define if Unix sockets cannot be created in an anonymous namespace])
248 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
250 AC_CHECK_TOOL(CC, gcc, gcc)
251 AC_PROG_CC
252 AM_PROG_AS
253 AM_PROG_CC_STDC
254 AC_PROG_INSTALL
255 AC_PROG_AWK
256 dnl We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
257 : ${CCAS='$(CC)'}
258 # Set ASFLAGS if not already set.
259 : ${CCASFLAGS='$(CFLAGS)'}
260 AC_SUBST(CCAS)
261 AC_SUBST(CCASFLAGS)
263 AC_CHECK_PROG(BISON, bison,yes,no)
264 if test "x$BISON" = "xno";
265 then
266         AC_MSG_ERROR([You need to install bison])
269 dnl may require a specific autoconf version
270 dnl AC_PROG_CC_FOR_BUILD
271 dnl CC_FOR_BUILD not automatically detected
272 CC_FOR_BUILD=$CC
273 CFLAGS_FOR_BUILD=$CFLAGS
274 BUILD_EXEEXT=
275 if test "x$cross_compiling" = "xyes"; then
276         CC_FOR_BUILD=cc
277         CFLAGS_FOR_BUILD=
278         BUILD_EXEEXT=""
280 AC_SUBST(CC_FOR_BUILD)
281 AC_SUBST(CFLAGS_FOR_BUILD)
282 AC_SUBST(HOST_CC)
283 AC_SUBST(BUILD_EXEEXT)
285 AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
287 # Set STDC_HEADERS
288 AC_HEADER_STDC
289 AC_LIBTOOL_WIN32_DLL
290 # This causes monodis to not link correctly
291 #AC_DISABLE_FAST_INSTALL
292 AM_PROG_LIBTOOL
294 # Test whenever ld supports -version-script
295 AC_PROG_LD
296 AC_PROG_LD_GNU
297 if test "x$lt_cv_prog_gnu_ld" = "xno"; then
298    no_version_script=yes
301 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
303 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h linux/rtc.h sys/syscall.h)
305 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
306 if test x$have_zlib = xyes; then
307    AC_TRY_COMPILE([#include <zlib.h>], [
308    void main () {
309    #if defined(ZLIB_VERNUM) && (ZLIB_VERNUM >= 0x1230)
310    }
311    #else
312    #error No good zlib found
313    #endif
314    ],[
315         AC_MSG_RESULT(Using system zlib)
316         zlib_msg="system zlib"
317    ],[
318         AC_MSG_RESULT(Using embedded zlib)
319         have_zlib=no
320         zlib_msg="bundled zlib"
321    ])
324 AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
325 AC_DEFINE(HAVE_ZLIB,1,[Have system zlib])
327 # for mono/metadata/debug-symfile.c
328 AC_CHECK_HEADERS(elf.h)
330 # for support
331 AC_CHECK_HEADERS(poll.h)
332 AC_CHECK_HEADERS(sys/poll.h)
333 AC_CHECK_HEADERS(sys/wait.h)
334 AC_CHECK_HEADERS(grp.h)
335 AC_CHECK_HEADERS(syslog.h)
337 # for mono/dis
338 AC_CHECK_HEADERS(wchar.h)
339 case "$host" in
340         *-*-*freebsd6*)
341                 AC_CHECK_HEADERS(ieeefp.h)
342         ;;
343         *-*-*freebsd*)
344                 /* Only freebsd6 has a working ieeefp.h */
345         ;;
346         *)
347                 AC_CHECK_HEADERS(ieeefp.h)
348         ;;
349 esac
350 AC_MSG_CHECKING(for isinf)
351 AC_TRY_LINK([#include <math.h>], [
352         int f = isinf (1);
353 ], [
354         AC_MSG_RESULT(yes)
355         AC_DEFINE(HAVE_ISINF, 1, [isinf available])
356 ], [
357         # We'll have to use signals
358         AC_MSG_RESULT(no)
362 # not 64 bit clean in cross-compile
363 AC_CHECK_SIZEOF(void *, 4)
365 WARN=''
366 if test x"$GCC" = xyes; then
367         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
368                 # The runtime code does not respect ANSI C strict aliasing rules
369                 CFLAGS="$CFLAGS -fno-strict-aliasing"
371                 ORIG_CFLAGS=$CFLAGS
372                 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
373                 AC_MSG_CHECKING(for -Wdeclaration-after-statement option to gcc)
374                 AC_TRY_COMPILE([], [
375                                                    void main () { }
376                 ], [
377                    AC_MSG_RESULT(yes)
378                 ], [
379                    AC_MSG_RESULT(no)
380                    CFLAGS=$ORIG_CFLAGS
381                 ])
382 else
383         # The Sun Forte compiler complains about inline functions that access static variables
384         # so disable all inlining.
385         case "$host" in
386         *-*-solaris*)
387                 CFLAGS="$CFLAGS -Dinline="
388                 ;;
389         esac
391 CFLAGS="$CFLAGS -g $WARN"
393 # Where's the 'mcs' source tree?
394 if test -d $srcdir/mcs; then
395   mcsdir=mcs
396 else
397   mcsdir=../mcs
400 mcs_topdir='$(top_srcdir)/'$mcsdir
401 mcs_topdir_from_srcdir='$(top_builddir)/'$mcsdir
403 ## Maybe should also disable if mcsdir is invalid.  Let's punt the issue for now.
404 AM_CONDITIONAL(BUILD_MCS, [test x$cross_compiling = xno && test x$enable_mcs_build != xno])
406 AC_SUBST([mcs_topdir])
407 AC_SUBST([mcs_topdir_from_srcdir])
409 # Where's the 'olive' source tree?
410 if test -d $srcdir/olive; then
411   olivedir=olive
412 else
413   olivedir=../olive
416 if test -d $srcdir/$olivedir; then
417 olive_topdir='$(top_srcdir)/'$olivedir
420 AC_ARG_WITH([libgdiplus], 
421         [  --with-libgdiplus=installed|sibling|<path>   Override the libgdiplus used for System.Drawing tests (defaults to NO)], 
422         [], [with_libgdiplus=installed])
424 case $with_libgdiplus in
425 no|installed) libgdiplus_loc= ;;
426 yes|sibling) libgdiplus_loc=`cd ../libgdiplus && pwd`/src/libgdiplus.la ;;
427 /*) libgdiplus_loc=$with_libgdiplus ;;
428 *) libgdiplus_loc=`pwd`/$with_libgdiplus ;;
429 esac
430 AC_SUBST([libgdiplus_loc])
432 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
433 if test "x$PKG_CONFIG" = "xno"; then
434         AC_MSG_ERROR([You need to install pkg-config])
437 pkg_config_path=
438 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
439         if test x$with_crosspkgdir = "x"; then
440                 if test -s $PKG_CONFIG_PATH; then
441                         pkg_config_path=$PKG_CONFIG_PATH
442                 fi
443         else
444                 pkg_config_path=$with_crosspkgdir
445                 PKG_CONFIG_PATH=$pkg_config_path
446                 export PKG_CONFIG_PATH
447         fi
450 AC_ARG_WITH([glib],
451         [  --with-glib=embedded|system       Choose glib API: system or embedded (default to system)],
452         [], [with_glib=system])
454 case $with_glib in
455 embedded) 
456   GLIB_CFLAGS='-I$(top_srcdir)/eglib/src'
457   GLIB_LIBS='-L$(top_builddir)/eglib/src -leglib -lm'
458   BUILD_GLIB_CFLAGS="$GLIB_CFLAGS"
459   BUILD_GLIB_LIBS="$GLIB_LIBS"
460   GMODULE_CFLAGS="$GLIB_CFLAGS"
461   GMODULE_LIBS="$GLIB_LIBS"
462   AC_CONFIG_SUBDIRS(eglib)
463   ;;
464 system)
465   BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
466   BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
468   ## Versions of dependencies
469   GLIB_REQUIRED_VERSION=1.3.11
470   
471   PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
472   
473   GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
474   GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
475   GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
476   GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
477   ;;
479   AC_MSG_ERROR([Invalid argument to --with-glib.])
480 esac
481 AM_CONDITIONAL(EGLIB_BUILD, test x$with_glib = xembedded)
482   
483 AC_SUBST(GLIB_CFLAGS)
484 AC_SUBST(GLIB_LIBS)
485 AC_SUBST(GMODULE_CFLAGS)
486 AC_SUBST(GMODULE_LIBS)
487 AC_SUBST(BUILD_GLIB_CFLAGS)
488 AC_SUBST(BUILD_GLIB_LIBS)
490 if test x$cross_compiling$platform_win32 = xnoyes; then
491    AC_MSG_CHECKING(for cygwin glib2-dev package)
492    if [ cygcheck --f /usr/lib/libglib-2.0.dll.a | grep -q glib2-devel ]; then
493       AC_MSG_RESULT(found)
494           AC_MSG_ERROR([Mono cannot be built with the cygwin glib2-devel package installed, because that package doesn't work with -mno-cygwin. Please uninstall it then re-run configure.])
495    else
496       AC_MSG_RESULT(not found, ok)
497    fi
499    AC_MSG_CHECKING(for broken gwin32.h)
500    glib_include=`$PKG_CONFIG --cflags-only-I glib-2.0 | sed -e 's/ -I.*//g' | sed -e 's/-I//g'`
501    if test -f $glib_include/glib/gwin32.h; then
502           if [ grep ftruncate $glib_include/glib/gwin32.h | grep -q define ]; then
503                  AC_MSG_RESULT(failed)
504                  hashmark='#'
505                  AC_MSG_ERROR([Your version of gwin32.h is broken and will cause compilation errors when building mono. Please fix it by deleting the line: '$hashmark   define ftruncate...' from '$glib_include/glib/gwin32.h' then re-run configure.])
506           fi
507    fi
508    AC_MSG_RESULT(ok)
511 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
513 # Enable support for fast thread-local storage
514 # Some systems have broken support, so we allow to disable it.
515 AC_ARG_WITH(tls, [  --with-tls=__thread,pthread       select Thread Local Storage implementation],[],[with_tls=__thread])
517 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
518 # This does not work on some platforms (bug #55253)
519 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack],[],[with_sigaltstack=yes])
521 AC_ARG_WITH(static_mono, [  --with-static_mono=yes,no      link mono statically to libmono (faster)],[],[with_static_mono=yes])
523 if test "x$enable_static" = "xno"; then
524    with_static_mono=no
527 if test "x$platform_win32" = "xyes"; then
528    # Boehm GC requires the runtime to be in its own dll
529    with_static_mono=no
532 AM_CONDITIONAL(STATIC_MONO, test x$with_static_mono != xno)
533 AC_ARG_ENABLE(mcs-build, [  --disable-mcs-build disable the build of the mcs directory], try_mcs_build=$enableval, enable_mcs_build=yes)
535 AC_ARG_WITH(xen_opt,   [  --with-xen_opt=yes,no      Enable Xen-specific behaviour],[],[with_xen_opt=yes])
536 if test "x$with_xen_opt" = "xyes"; then
537         AC_DEFINE(MONO_XEN_OPT, 1, [Xen-specific behaviour])
538         ORIG_CFLAGS=$CFLAGS
539         CFLAGS="$CFLAGS -mno-tls-direct-seg-refs"
540         AC_MSG_CHECKING(for -mno-tls-direct-seg-refs option to gcc)
541         AC_TRY_COMPILE([], [
542                                            void main () { }
543         ], [
544            AC_MSG_RESULT(yes)
545         ], [
546            AC_MSG_RESULT(no)
547            CFLAGS=$ORIG_CFLAGS
548         ])
551 DISABLED_FEATURES=none
553 AC_ARG_ENABLE(minimal, [  --enable-minimal=LIST      drop support for LIST subsystems.
554   LIST is a comma-separated list from: aot, profiler, decimal, pinvoke, debug,
555   reflection_emit, large_code, logging, com, ssa, generics.],
557         for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
558                 eval "mono_feature_disable_$feature='yes'"
559                 AC_MSG_NOTICE([Disabled support for feature: $feature])
560         done
561         DISABLED_FEATURES=$enable_minimal
562         disabled="Disabled:    $enable_minimal"
563 ],[])
565 AC_DEFINE_UNQUOTED(DISABLED_FEATURES, "$DISABLED_FEATURES", [String of disabled features])
567 if test "x$mono_feature_disable_aot" = "xyes"; then
568         AC_DEFINE(DISABLE_AOT, 1, [Disable AOT support])
571 if test "x$mono_feature_disable_profiler" = "xyes"; then
572         AC_DEFINE(DISABLE_PROFILER, 1, [Disable default profiler support])
575 if test "x$mono_feature_disable_decimal" = "xyes"; then
576         AC_DEFINE(DISABLE_DECIMAL, 1, [Disable System.Decimal support])
579 if test "x$mono_feature_disable_pinvoke" = "xyes"; then
580         AC_DEFINE(DISABLE_PINVOKE, 1, [Disable P/Invoke support])
583 if test "x$mono_feature_disable_debug" = "xyes"; then
584         AC_DEFINE(DISABLE_DEBUG, 1, [Disable runtime debugging support])
587 if test "x$mono_feature_disable_reflection_emit" = "xyes"; then
588         AC_DEFINE(DISABLE_REFLECTION_EMIT, 1, [Disable reflection emit support])
591 if test "x$mono_feature_disable_large_code" = "xyes"; then
592         AC_DEFINE(DISABLE_LARGE_CODE, 1, [Disable support for huge assemblies])
595 if test "x$mono_feature_disable_logging" = "xyes"; then
596         AC_DEFINE(DISABLE_LOGGING, 1, [Disable support debug logging])
599 if test "x$mono_feature_disable_com" = "xyes"; then
600         AC_DEFINE(DISABLE_COM, 1, [Disable COM support])
603 if test "x$mono_feature_disable_ssa" = "xyes"; then
604         AC_DEFINE(DISABLE_SSA, 1, [Disable advanced SSA JIT optimizations])
607 if test "x$mono_feature_disable_generics" = "xyes"; then
608         AC_DEFINE(DISABLE_GENERICS, 1, [Disable generics support])
611 AC_MSG_CHECKING(for visibility __attribute__)
612 AC_TRY_COMPILE([], [
613    void __attribute__ ((visibility ("hidden"))) doit (void) {}
614    void main () { doit (); }
615 ], [
616    have_visibility_hidden=yes
617    AC_MSG_RESULT(yes)
618 ], [
619    have_visibility_hidden=no
620    AC_MSG_RESULT(no)
623 LIBGC_CFLAGS=
624 LIBGC_LIBS=
625 LIBGC_STATIC_LIBS=
626 libgc_dir=
627 case "x$gc" in
628         xboehm|xbohem|xyes)
629                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
630                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
632                 if test "x$found_boehm" != "xyes"; then
633                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
634                 fi
635                 if test "x$gc_headers" != "xyes"; then
636                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
637                 fi
639                 AC_DEFINE(HAVE_BOEHM_GC)
640                 AC_SUBST(HAVE_BOEHM_GC)
641                 LIBGC_LIBS="-lgc $libdl"
642                 LIBGC_STATIC_LIBS="$LIBGC_LIBS"
644                 # AC_CHECK_FUNCS does not work for some reason...
645                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
646                 if test "x$found_gcj_malloc" = "xyes"; then
647                         AC_DEFINE(HAVE_GC_GCJ_MALLOC)
648                         AC_DEFINE_UNQUOTED(USED_GC_NAME, "System Boehm (with typed GC)", [GC description])
649                 else
650                         AC_DEFINE_UNQUOTED(USED_GC_NAME, "System Boehm (no typed GC)", [GC description])
651                 fi
652                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
653                 if test "x$found_gc_enable" = "xyes"; then
654                         AC_DEFINE(HAVE_GC_ENABLE)
655                 fi
656                 ;;
658         xincluded)
659                 AC_CONFIG_SUBDIRS(libgc)
661                 # Pass CPPFLAGS to libgc configure
662                 # Maybe we should use a separate variable for this to avoid passing useless and
663                 # potentially problematic defines to libgc (like -D_FILE_OFFSET_BITS=64)
664                 export CPPFLAGS
666                 found_boehm=yes
667                 gc_headers=yes
668                 use_included_gc=yes
669                 libgc_dir=libgc
671                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
672                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
673                 LIBGC_STATIC_LIBS='$(top_builddir)/libgc/libmonogc-static.la'
675                 AC_DEFINE(HAVE_BOEHM_GC)
676                 AC_SUBST(HAVE_BOEHM_GC)
678                 AC_DEFINE(HAVE_GC_H)
679                 AC_DEFINE(USE_INCLUDED_LIBGC)
681                 # The included libgc contains GCJ support
682                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
683                 AC_DEFINE(HAVE_GC_ENABLE)
684                 AC_DEFINE_UNQUOTED(USED_GC_NAME, "Included Boehm (with typed GC)", [GC description])
685                 ;;
687         xsgen)
688                 found_boehm=no
689                 gc_headers=no
690                 use_included_gc=no
691                 AC_DEFINE(HAVE_SGEN_GC,1,[Using the simple generational GC.])
692                 AC_DEFINE(HAVE_MOVING_COLLECTOR,1,[The GC can move objects.])
693                 AC_DEFINE(HAVE_WRITE_BARRIERS,1,[The GC needs write barriers.])
694                 AC_DEFINE_UNQUOTED(USED_GC_NAME, "Simple generational", [GC description])
695                 ;;
697         xnone)
698                 AC_MSG_WARN("Compiling mono without GC.")
699                 AC_DEFINE_UNQUOTED(USED_GC_NAME, "none", [GC description])
700                 AC_DEFINE(HAVE_NULL_GC,1,[No GC support.])
701                 ;;
702         *)
703                 AC_MSG_ERROR([Invalid argument to --with-gc.])
704                 ;;
705 esac
707 AC_ARG_WITH(large-heap, [  --with-large-heap=yes,no    Enable support for GC heaps larger than 3GB], [large_heap=$withval], [large_heap=no])
708 if test "x$large_heap" = "xyes"; then
709    echo "FOO"
710    CPPFLAGS="$CPPFLAGS -DLARGE_CONFIG"
713 # tell libgc/configure about what we want
714 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads $libgc_configure_args"
716 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
717 AC_SUBST(LIBGC_CFLAGS)
718 AC_SUBST(LIBGC_LIBS)
719 AC_SUBST(LIBGC_STATIC_LIBS)
720 AC_SUBST(libgc_dir)
723 dnl End of libgc checks
726 if test x$platform_win32 = xno; then
728         dnl dynamic loader support
729         AC_CHECK_FUNC(dlopen, DL_LIB="",
730                 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", dl_support=no)
731         )
732         if test x$dl_support = xno; then
733                 AC_MSG_WARN([No dynamic loading support available])
734         else
735                 LIBS="$LIBS $DL_LIB"
736                 AC_DEFINE(HAVE_DL_LOADER,1,[dlopen-based dynamic loader available])
737                 dnl from glib's configure.in
738                 AC_CACHE_CHECK([for preceeding underscore in symbols],
739                         mono_cv_uscore,[
740                         AC_TRY_RUN([#include <dlfcn.h>
741                         int mono_underscore_test (void) { return 42; }
742                         int main() {
743                           void *f1 = (void*)0, *f2 = (void*)0, *handle;
744                           handle = dlopen ((void*)0, 0);
745                           if (handle) {
746                             f1 = dlsym (handle, "mono_underscore_test");
747                             f2 = dlsym (handle, "_mono_underscore_test");
748                           } return (!f2 || f1);
749                         }],
750                                 [mono_cv_uscore=yes],
751                                 [mono_cv_uscore=no],
752                         [])
753                 ])
754                 if test "x$mono_cv_uscore" = "xyes"; then
755                         MONO_DL_NEED_USCORE=1
756                 else
757                         MONO_DL_NEED_USCORE=0
758                 fi
759                 AC_SUBST(MONO_DL_NEED_USCORE)
760                 AC_CHECK_FUNC(dlerror)
761         fi
763         dnl ******************************************************************
764         dnl *** Checks for the IKVM JNI interface library                  ***
765         dnl ******************************************************************
766         AC_ARG_WITH(ikvm-native, [  --with-ikvm-native=yes,no  build the IKVM JNI interface library],[with_ikvm_native=$withval],[with_ikvm_native=yes])
768         ikvm_native_dir=
769         if test x$with_ikvm_native = xyes; then
770                 ikvm_native_dir=ikvm-native
771                 jdk_headers_found="IKVM Native"
772         fi
774         AC_SUBST(ikvm_native_dir)
776         AC_CHECK_HEADERS(execinfo.h)
778         AC_CHECK_FUNCS(getgrgid_r)
779         AC_CHECK_FUNCS(getgrnam_r)
780         AC_CHECK_FUNCS(getpwnam_r)
781         AC_CHECK_FUNCS(getpwuid_r)
782         AC_CHECK_FUNCS(getresuid)
783         AC_CHECK_FUNCS(setresuid)
784         AC_CHECK_FUNCS(kqueue)
785         AC_CHECK_FUNCS(backtrace_symbols)
786         AC_CHECK_FUNCS(mkstemp)
787         AC_CHECK_FUNCS(mmap)
788         AC_CHECK_FUNCS(madvise)
789         AC_CHECK_FUNCS(getrusage)
790         AC_CHECK_FUNCS(getpriority)
791         AC_CHECK_FUNCS(setpriority)
793         AC_CHECK_FUNCS(sched_setaffinity)
795         dnl ******************************************************************
796         dnl *** Check for large file support                               ***
797         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
798         dnl ******************************************************************
799         
800         # Check that off_t can represent 2**63 - 1 correctly, working around
801         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
802         # CPPFLAGS and sets $large_offt to yes if the test succeeds
803         large_offt=no
804         AC_DEFUN([LARGE_FILES], [
805                 large_CPPFLAGS=$CPPFLAGS
806                 CPPFLAGS="$CPPFLAGS $1"
807                 AC_TRY_RUN([
808                         #include <sys/types.h>
810                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
812                         int main(void) {
813                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
814                                                (BIG_OFF_T%2147483647==1));
815                                 if(big_off_t) {
816                                         exit(0);
817                                 } else {
818                                         exit(1);
819                                 }
820                         }
821                 ], [
822                         AC_MSG_RESULT(ok)
823                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
824                         large_CPPFLAGS="$large_CPPFLAGS $1"
825                         large_offt=yes
826                 ], [
827                         AC_MSG_RESULT(no)
828                 ], "")
829                 CPPFLAGS=$large_CPPFLAGS
830         ])
832         AC_MSG_CHECKING(if off_t is 64 bits wide)
833         LARGE_FILES("")
834         if test $large_offt = no; then
835                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
836                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
837         fi
838         if test $large_offt = no; then
839                 AC_MSG_WARN([No 64 bit file size support available])
840         fi
841         
842         dnl *****************************
843         dnl *** Checks for libsocket  ***
844         dnl *****************************
845         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
847         dnl *******************************
848         dnl *** Checks for MSG_NOSIGNAL ***
849         dnl *******************************
850         AC_MSG_CHECKING(for MSG_NOSIGNAL)
851         AC_TRY_COMPILE([#include <sys/socket.h>], [
852                 int f = MSG_NOSIGNAL;
853         ], [
854                 # Yes, we have it...
855                 AC_MSG_RESULT(yes)
856                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
857         ], [
858                 # We'll have to use signals
859                 AC_MSG_RESULT(no)
860         ])
862         dnl *****************************
863         dnl *** Checks for SOL_IP     ***
864         dnl *****************************
865         AC_MSG_CHECKING(for SOL_IP)
866         AC_TRY_COMPILE([#include <netdb.h>], [
867                 int level = SOL_IP;
868         ], [
869                 # Yes, we have it...
870                 AC_MSG_RESULT(yes)
871                 AC_DEFINE(HAVE_SOL_IP)
872         ], [
873                 # We'll have to use getprotobyname
874                 AC_MSG_RESULT(no)
875         ])
877         dnl *****************************
878         dnl *** Checks for SOL_IPV6     ***
879         dnl *****************************
880         AC_MSG_CHECKING(for SOL_IPV6)
881         AC_TRY_COMPILE([#include <netdb.h>], [
882                 int level = SOL_IPV6;
883         ], [
884                 # Yes, we have it...
885                 AC_MSG_RESULT(yes)
886                 AC_DEFINE(HAVE_SOL_IPV6)
887         ], [
888                 # We'll have to use getprotobyname
889                 AC_MSG_RESULT(no)
890         ])
892         dnl *****************************
893         dnl *** Checks for SOL_TCP    ***
894         dnl *****************************
895         AC_MSG_CHECKING(for SOL_TCP)
896         AC_TRY_COMPILE([#include <netdb.h>], [
897                 int level = SOL_TCP;
898         ], [
899                 # Yes, we have it...
900                 AC_MSG_RESULT(yes)
901                 AC_DEFINE(HAVE_SOL_TCP)
902         ], [
903                 # We'll have to use getprotobyname
904                 AC_MSG_RESULT(no)
905         ])
907         dnl *****************************
908         dnl *** Checks for IP_PKTINFO ***
909         dnl *****************************
910         AC_MSG_CHECKING(for IP_PKTINFO)
911         AC_TRY_COMPILE([#include <netdb.h>], [
912                 int level = IP_PKTINFO;
913         ], [
914                 # Yes, we have it...
915                 AC_MSG_RESULT(yes)
916                 AC_DEFINE(HAVE_IP_PKTINFO)
917         ], [
918                 AC_MSG_RESULT(no)
919         ])
921         dnl *****************************
922         dnl *** Checks for IPV6_PKTINFO ***
923         dnl *****************************
924         AC_MSG_CHECKING(for IPV6_PKTINFO)
925         AC_TRY_COMPILE([#include <netdb.h>], [
926                 int level = IPV6_PKTINFO;
927         ], [
928                 # Yes, we have it...
929                 AC_MSG_RESULT(yes)
930                 AC_DEFINE(HAVE_IPV6_PKTINFO)
931         ], [
932                 AC_MSG_RESULT(no)
933         ])
935         dnl **********************************
936         dnl *** Checks for IP_DONTFRAGMENT ***
937         dnl **********************************
938         AC_MSG_CHECKING(for IP_DONTFRAGMENT)
939         AC_TRY_COMPILE([#include <netdb.h>], [
940                 int level = IP_DONTFRAGMENT;
941         ], [
942                 # Yes, we have it...
943                 AC_MSG_RESULT(yes)
944                 AC_DEFINE(HAVE_IP_DONTFRAGMENT)
945         ], [
946                 AC_MSG_RESULT(no)
947         ])
949         dnl **********************************
950         dnl *** Checks for IP_MTU_DISCOVER ***
951         dnl **********************************
952         AC_MSG_CHECKING(for IP_MTU_DISCOVER)
953         AC_TRY_COMPILE([#include <netdb.h>], [
954                 int level = IP_MTU_DISCOVER;
955         ], [
956                 # Yes, we have it...
957                 AC_MSG_RESULT(yes)
958                 AC_DEFINE(HAVE_IP_MTU_DISCOVER)
959         ], [
960                 AC_MSG_RESULT(no)
961         ])
963         dnl *********************************
964         dnl *** Check for struct ip_mreqn ***
965         dnl *********************************
966         AC_MSG_CHECKING(for struct ip_mreqn)
967         AC_TRY_COMPILE([#include <netinet/in.h>], [
968                 struct ip_mreqn mreq;
969                 mreq.imr_address.s_addr = 0;
970         ], [
971                 # Yes, we have it...
972                 AC_MSG_RESULT(yes)
973                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
974         ], [
975                 # We'll just have to try and use struct ip_mreq
976                 AC_MSG_RESULT(no)
977                 AC_MSG_CHECKING(for struct ip_mreq)
978                 AC_TRY_COMPILE([#include <netinet/in.h>], [
979                         struct ip_mreq mreq;
980                         mreq.imr_interface.s_addr = 0;
981                 ], [
982                         # Yes, we have it...
983                         AC_MSG_RESULT(yes)
984                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
985                 ], [
986                         # No multicast support
987                         AC_MSG_RESULT(no)
988                 ])
989         ])
990         
991         dnl **********************************
992         dnl *** Check for gethostbyname2_r ***
993         dnl **********************************
994         AC_MSG_CHECKING(for gethostbyname2_r)
995                 AC_TRY_LINK([#include <netdb.h>], [
996                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
997         ], [
998                 # Yes, we have it...
999                 AC_MSG_RESULT(yes)
1000                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R)
1001         ], [
1002                 AC_MSG_RESULT(no)
1003         ])
1005         dnl *****************************
1006         dnl *** Checks for libnsl     ***
1007         dnl *****************************
1008         AC_CHECK_FUNC(gethostbyaddr, , AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl"))
1010         AC_CHECK_FUNCS(inet_pton inet_aton)
1012         dnl ***********************************************
1013         dnl *** Checks for size of sockaddr_un.sun_path ***
1014         dnl ***********************************************
1015         # AC_CHECK_SIZEOF can't cope with struct members :-(
1016         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
1017         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
1018                 [AC_TRY_RUN([
1019                         #include <sys/types.h>
1020                         #include <stdio.h>
1021                         #include <sys/un.h>
1023                         int main(void) {
1024                                 struct sockaddr_un sock_un;
1025                                 FILE *f=fopen("conftestval", "w");
1026                                 if(!f) exit(1);
1027                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
1028                                 exit(0);
1029                         }
1030                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
1031                    cv_mono_sizeof_sunpath=0,
1032                    cv_mono_sizeof_sunpath=0)])dnl
1033         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
1034         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
1036         dnl *************************************
1037         dnl *** Checks for zero length arrays ***
1038         dnl *************************************
1039         AC_MSG_CHECKING(whether $CC supports zero length arrays)
1040         AC_TRY_COMPILE([
1041                 struct s {
1042                         int  length;
1043                         char data [0];
1044                 };
1045         ], [], [
1046                 AC_MSG_RESULT(yes)
1047                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 0)
1048         ], [
1049                 AC_MSG_RESULT(no)
1050                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 1)
1051         ])
1053         dnl *****************************
1054         dnl *** Checks for libxnet    ***
1055         dnl *****************************
1056         case "${host}" in
1057                 *solaris* )
1058                         AC_MSG_CHECKING(for Solaris XPG4 support)
1059                         if test -f /usr/lib/libxnet.so; then
1060                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
1061                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
1062                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
1063                                 LIBS="$LIBS -lxnet"
1064                                 AC_MSG_RESULT(yes)
1065                         else
1066                                 AC_MSG_RESULT(no)
1067                         fi
1069                         if test "$GCC" = "yes"; then
1070                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
1071                         fi
1072                 ;;
1073         esac
1075         dnl *****************************
1076         dnl *** Checks for libpthread ***
1077         dnl *****************************
1078 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
1079 # and libpthread does not exist
1081         case "${host}" in
1082                 *-*-*freebsd4*)
1083                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
1084                 ;;
1085                 *-*-*freebsd5*)
1086                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
1087                 ;;
1088                 *-*-*freebsd6*)
1089                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
1090                 ;;
1091                 *)
1092                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
1093                 ;;
1094         esac
1095         AC_CHECK_HEADERS(pthread.h)
1096         AC_CHECK_FUNCS(pthread_mutex_timedlock)
1097         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
1098         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
1099         AC_TRY_COMPILE([ #include <pthread.h>], [
1100                 pthread_mutexattr_t attr;
1101                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1102         ], [
1103                 AC_MSG_RESULT(ok)
1104         ], [
1105                 AC_MSG_RESULT(no)
1106                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
1107                 AC_DEFINE(USE_MONO_MUTEX)
1108         ])
1109         AC_CHECK_FUNCS(pthread_attr_setstacksize)
1110         AC_CHECK_FUNCS(pthread_attr_getstack)
1111         AC_CHECK_FUNCS(pthread_get_stacksize_np pthread_get_stackaddr_np)
1113         dnl ***********************************
1114         dnl *** Checks for working __thread ***
1115         dnl ***********************************
1116         AC_MSG_CHECKING(for working __thread)
1117         if test "x$with_tls" != "x__thread"; then
1118                 AC_MSG_RESULT(disabled)
1119         else
1120                 AC_TRY_RUN([
1121                         #include <pthread.h>
1122                         __thread int i;
1123                         static int res1, res2;
1125                         void thread_main (void *arg)
1126                         {
1127                                 i = arg;
1128                                 sleep (1);
1129                                 if (arg == 1)
1130                                         res1 = (i == arg);
1131                                 else
1132                                         res2 = (i == arg);
1133                         }
1135                         int main () {
1136                                 pthread_t t1, t2;
1138                                 i = 5;
1140                                 pthread_create (&t1, NULL, thread_main, 1);
1141                                 pthread_create (&t2, NULL, thread_main, 2);
1143                                 pthread_join (t1, NULL);
1144                                 pthread_join (t2, NULL);
1146                                 return !(res1 + res2 == 2);
1147                         }
1148                 ], [
1149                                 AC_MSG_RESULT(yes)
1150                 ], [
1151                                 AC_MSG_RESULT(no)
1152                                 with_tls=pthread
1153                 ])
1154         fi
1156         dnl **************************************
1157         dnl *** Checks for working sigaltstack ***
1158         dnl **************************************
1159         AC_MSG_CHECKING(for working sigaltstack)
1160         if test "x$with_sigaltstack" != "xyes"; then
1161                 AC_MSG_RESULT(disabled)
1162         else
1163                 AC_TRY_RUN([
1164                         #include <stdio.h>
1165                         #include <stdlib.h>
1166                         #include <unistd.h>
1167                         #include <signal.h>
1168                         #include <pthread.h>
1169                         #include <sys/wait.h>
1170                         #if defined(__FreeBSD__) || defined(__NetBSD__)
1171                         #define SA_STACK SA_ONSTACK
1172                         #endif
1173                         static void
1174                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
1175                         {
1176                                 exit (0);
1177                         }
1179                         static void *
1180                         loop (void *ignored)
1181                         {
1182                                 char *ptr = NULL;
1184                                 *ptr = 0;
1185                                 return NULL;
1186                         }
1188                         static void
1189                         child ()
1190                         {
1191                                 struct sigaction sa;
1192                                 struct sigaltstack sas;
1193                                 pthread_t id;
1194                                 pthread_attr_t attr;
1196                                 sa.sa_sigaction = sigsegv_signal_handler;
1197                                 sigemptyset (&sa.sa_mask);
1198                                 sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
1199                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
1200                                         perror ("sigaction");
1201                                         return;
1202                                 }
1204                                 sas.ss_sp = malloc (SIGSTKSZ);
1205                                 sas.ss_size = SIGSTKSZ;
1206                                 sas.ss_flags = 0;
1207                                 if (sigaltstack (&sas, NULL) == -1) {
1208                                         perror ("sigaltstack");
1209                                         return;
1210                                 }
1212                                 pthread_attr_init (&attr);
1213                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
1214                                         printf ("pthread_create\n");
1215                                         return;
1216                                 }
1218                                 sleep (100);
1219                         }
1221                         int
1222                         main ()
1223                         {
1224                                 pid_t son;
1225                                 int status;
1226                                 int i;
1228                                 son = fork ();
1229                                 if (son == -1) {
1230                                         return 1;
1231                                 }
1233                                 if (son == 0) {
1234                                         child ();
1235                                         return 0;
1236                                 }
1238                                 for (i = 0; i < 3; ++i) {
1239                                         sleep (1);
1240                                         waitpid (son, &status, WNOHANG);
1241                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
1242                                                 return 0;
1243                                 }
1245                                 kill (son, SIGKILL);
1246                                 return 1;
1247                         }
1249                 ], [
1250                                 AC_MSG_RESULT(yes)
1251                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
1252                 ], [
1253                                 with_sigaltstack=no
1254                                 AC_MSG_RESULT(no)
1255                 ])
1256         fi
1258         dnl ********************************
1259         dnl *** Checks for semaphore lib ***
1260         dnl ********************************
1261         # 'Real Time' functions on Solaris
1262         # posix4 on Solaris 2.6
1263         # pthread (first!) on Linux
1264         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
1266         dnl ********************************
1267         dnl *** Checks for timezone stuff **
1268         dnl ********************************
1269         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
1270                 AC_TRY_COMPILE([
1271                         #include <time.h>
1272                         ], [
1273                         struct tm tm;
1274                         tm.tm_gmtoff = 1;
1275                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
1276         if test $ac_cv_struct_tm_gmtoff = yes; then
1277                 AC_DEFINE(HAVE_TM_GMTOFF)
1278         else
1279                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
1280                         AC_TRY_COMPILE([
1281                                 #include <time.h>
1282                         ], [
1283                                 timezone = 1;
1284                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
1285                 if test $ac_cv_var_timezone = yes; then
1286                         AC_DEFINE(HAVE_TIMEZONE)
1287                 else
1288                         AC_ERROR(unable to find a way to determine timezone)
1289                 fi
1290         fi
1292         dnl *********************************
1293         dnl *** Checks for math functions ***
1294         dnl *********************************
1295         LIBS="$LIBS -lm";
1296         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
1297                 AC_TRY_LINK([#include <math.h>], 
1298                 [ finite(0.0); ], 
1299                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
1300                 AC_MSG_RESULT(no)))
1301         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
1302                 AC_TRY_LINK([#include <math.h>], 
1303                 [ isfinite(0.0); ], 
1304                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
1305                 AC_MSG_RESULT(no)))
1307         dnl ****************************************************************
1308         dnl *** Checks for working poll() (macosx defines it but doesn't ***
1309         dnl *** have it in the library (duh))                            ***
1310         dnl ****************************************************************
1311         AC_CHECK_FUNCS(poll)
1313         dnl *************************
1314         dnl *** Check for signbit ***
1315         dnl *************************
1316         AC_MSG_CHECKING(for signbit)
1317         AC_TRY_LINK([#include <math.h>], [
1318                 int s = signbit(1.0);
1319         ], [
1320                 AC_MSG_RESULT(yes)
1321                 AC_DEFINE(HAVE_SIGNBIT)
1322         ], [
1323                 AC_MSG_RESULT(no)
1324         ]) 
1326         dnl **********************************
1327         dnl *** epoll                      ***
1328         dnl **********************************
1329         AC_CHECK_HEADERS(sys/epoll.h)
1330         haveepoll=no
1331         AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
1332         if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes" ; then
1333                 AC_DEFINE(HAVE_EPOLL, 1, [epoll supported])
1334         fi
1336         dnl ******************************
1337         dnl *** Checks for SIOCGIFCONF ***
1338         dnl ******************************
1339         AC_CHECK_HEADERS(sys/ioctl.h)
1340         AC_CHECK_HEADERS(net/if.h)
1341         AC_MSG_CHECKING(for ifreq)
1342         AC_TRY_COMPILE([
1343                 #include <sys/ioctl.h>
1344                 #include <net/if.h>
1345                 ], [
1346                 struct ifconf ifc;
1347                 struct ifreq *ifr;
1348                 void *x;
1349                 ifc.ifc_len = 0;
1350                 ifc.ifc_buf = NULL;
1351                 x = (void *) &ifr->ifr_addr;
1352                 ],[
1353                         AC_MSG_RESULT(yes)
1354                         AC_DEFINE(HAVE_SIOCGIFCONF, 1, [Can get interface list])
1355                 ], [
1356                         AC_MSG_RESULT(no)
1357                 ])
1358         dnl **********************************
1359         dnl *** Checks for MonoPosixHelper ***
1360         dnl **********************************
1361         AC_CHECK_HEADERS(checklist.h)
1362         AC_CHECK_HEADERS(fstab.h)
1363         AC_CHECK_HEADERS(attr/xattr.h)
1364         AC_CHECK_HEADERS(sys/extattr.h)
1365         AC_CHECK_HEADERS(sys/sendfile.h)
1366         AC_CHECK_HEADERS(sys/statvfs.h)
1367         AC_CHECK_HEADERS(sys/vfstab.h)
1368         AC_CHECK_HEADERS(sys/xattr.h)
1369         AC_CHECK_HEADERS(sys/mman.h)
1370         AC_CHECK_FUNCS(getdomainname)
1371         AC_CHECK_FUNCS(setdomainname)
1372         AC_CHECK_FUNCS(fgetgrent)
1373         AC_CHECK_FUNCS(fgetpwent)
1374         AC_CHECK_FUNCS(fgetpwent)
1375         AC_CHECK_FUNCS(getfsstat)
1376         AC_CHECK_FUNCS(lutimes)
1377         AC_CHECK_FUNCS(mremap)
1378         AC_CHECK_FUNCS(remap_file_pages)
1379         AC_CHECK_FUNCS(posix_fadvise)
1380         AC_CHECK_FUNCS(posix_fallocate)
1381         AC_CHECK_FUNCS(posix_madvise)
1382         AC_CHECK_FUNCS(vsnprintf)
1383         AC_CHECK_FUNCS(sendfile)
1384         AC_CHECK_FUNCS(sethostid)
1385         AC_CHECK_FUNCS(statfs)
1386         AC_CHECK_FUNCS(fstatfs)
1387         AC_CHECK_FUNCS(statvfs)
1388         AC_CHECK_FUNCS(fstatvfs)
1389         AC_CHECK_FUNCS(stime)
1390         AC_CHECK_FUNCS(strerror_r)
1391         AC_CHECK_FUNCS(ttyname_r)
1392         AC_CHECK_SIZEOF(size_t)
1393         AC_CHECK_TYPES([blksize_t], [AC_DEFINE(HAVE_BLKSIZE_T)], , 
1394                 [#include <sys/types.h>
1395                  #include <sys/stat.h>
1396                  #include <unistd.h>])
1397         AC_CHECK_TYPES([blkcnt_t], [AC_DEFINE(HAVE_BLKCNT_T)], ,
1398                 [#include <sys/types.h>
1399                  #include <sys/stat.h>
1400                  #include <unistd.h>])
1401         AC_CHECK_TYPES([suseconds_t], [AC_DEFINE(HAVE_SUSECONDS_T)], ,
1402                 [#include <sys/time.h>])
1403         AC_CHECK_TYPES([struct pollfd], [AC_DEFINE(HAVE_STRUCT_POLLFD)], ,
1404                 [#include <sys/poll.h>])
1405         AC_CHECK_TYPES([struct stat], [AC_DEFINE(HAVE_STRUCT_STAT)], ,
1406                 [#include <sys/types.h>
1407                  #include <sys/stat.h>
1408                  #include <unistd.h>])
1409         AC_CHECK_TYPES([struct timeval], [AC_DEFINE(HAVE_STRUCT_TIMEVAL)], ,
1410                 [#include <sys/time.h>
1411                  #include <sys/types.h>
1412                  #include <utime.h>])
1413         AC_CHECK_TYPES([struct timezone], [AC_DEFINE(HAVE_STRUCT_TIMEZONE)], ,
1414                 [#include <sys/time.h>])
1415         AC_CHECK_TYPES([struct utimbuf], [AC_DEFINE(HAVE_STRUCT_UTIMBUF)], ,
1416                 [#include <sys/types.h>
1417                  #include <utime.h>])
1418         AC_CHECK_MEMBERS(
1419                 [struct dirent.d_off, struct dirent.d_reclen, struct dirent.d_type],,, 
1420                 [#include <sys/types.h>
1421                  #include <dirent.h>])
1423         dnl Favour xattr through glibc, but use libattr if we have to
1424         AC_CHECK_FUNC(lsetxattr, ,
1425                 AC_CHECK_LIB(attr, lsetxattr, XATTR_LIB="-lattr",)
1426         )
1427         AC_SUBST(XATTR_LIB)
1428         
1429         dnl *********************************
1430         dnl *** Checks for Windows compilation ***
1431         dnl *********************************
1432         AC_CHECK_HEADERS(sys/time.h)
1433         AC_CHECK_HEADERS(sys/param.h)
1435         dnl *********************************
1436         dnl *** Check for Console 2.0 I/O ***
1437         dnl *********************************
1438         AC_CHECK_HEADERS([curses.h])
1439         AC_CHECK_HEADERS([term.h], [], [],
1440         [#if HAVE_CURSES_H
1441          #include <curses.h>
1442          #endif
1443         ])
1444         AC_CHECK_HEADERS([termios.h])
1446         dnl * This is provided in io-layer, but on windows it's only available
1447         dnl * on xp+
1448         AC_DEFINE(HAVE_GETPROCESSID, 1, [Define if GetProcessId is available])
1449 else
1450         jdk_headers_found=no
1451         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
1452         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
1453         AC_CHECK_LIB(ole32, main, LIBS="$LIBS -lole32", AC_ERROR(bad mingw install?))
1454         AC_CHECK_LIB(winmm, main, LIBS="$LIBS -lwinmm", AC_ERROR(bad mingw install?))
1455         AC_CHECK_LIB(oleaut32, main, LIBS="$LIBS -loleaut32", AC_ERROR(bad mingw install?))
1456         AC_CHECK_LIB(advapi32, main, LIBS="$LIBS -ladvapi32", AC_ERROR(bad mingw install?))
1458         dnl *********************************
1459         dnl *** Check for struct ip_mreqn ***
1460         dnl *********************************
1461         AC_MSG_CHECKING(for struct ip_mreqn)
1462         AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1463                 struct ip_mreqn mreq;
1464                 mreq.imr_address.s_addr = 0;
1465         ], [
1466                 # Yes, we have it...
1467                 AC_MSG_RESULT(yes)
1468                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
1469         ], [
1470                 # We'll just have to try and use struct ip_mreq
1471                 AC_MSG_RESULT(no)
1472                 AC_MSG_CHECKING(for struct ip_mreq)
1473                 AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1474                         struct ip_mreq mreq;
1475                         mreq.imr_interface.s_addr = 0;
1476                 ], [
1477                         # Yes, we have it...
1478                         AC_MSG_RESULT(yes)
1479                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
1480                 ], [
1481                         # No multicast support
1482                         AC_MSG_RESULT(no)
1483                 ])
1484         ])
1485         AC_CHECK_FUNCS(GetProcessId)
1488 dnl socklen_t check
1489 AC_MSG_CHECKING(for socklen_t)
1490 AC_TRY_COMPILE([
1491 #include <sys/types.h>
1492 #include <sys/socket.h>
1494   socklen_t foo;
1496 ac_cv_c_socklen_t=yes
1497         AC_DEFINE(HAVE_SOCKLEN_T)
1498         AC_MSG_RESULT(yes)
1500         AC_MSG_RESULT(no)
1503 AC_MSG_CHECKING(for array element initalizer support)
1504 AC_TRY_COMPILE([#include <sys/socket.h>], [
1505         const int array[] = {[1] = 2,};
1506 ], [
1507         # Yes, we have it...
1508         AC_MSG_RESULT(yes)
1509         AC_DEFINE(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
1510 ], [
1511         # We'll have to use signals
1512         AC_MSG_RESULT(no)
1515 AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
1516         # Simply calling trunc (0.0) is no good since gcc will optimize the call away
1517         AC_TRY_LINK([#include <math.h>], 
1518         [ static void *p = &trunc; ],
1519         [
1520                 AC_DEFINE(HAVE_TRUNC) 
1521                 AC_MSG_RESULT(yes)
1522                 ac_cv_trunc=yes
1523         ],
1524         AC_MSG_RESULT(no)))
1526 if test "x$ac_cv_truncl" != "xyes"; then
1527    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
1530 dnl ****************************
1531 dnl *** Look for /dev/random ***
1532 dnl ****************************
1534 AC_MSG_CHECKING([if usage of random device is requested])
1535 AC_ARG_ENABLE(dev-random,
1536 [  --disable-dev-random    disable the use of the random device],
1537 try_dev_random=$enableval, try_dev_random=yes)
1538 AC_MSG_RESULT($try_dev_random)
1540 case "{$target}" in
1541     *-openbsd*)
1542     NAME_DEV_RANDOM="/dev/srandom"
1543     ;;
1545 dnl Win32 does not have /dev/random, they have their own method...
1547     *-*-mingw*|*-*-cygwin*)
1548     ac_cv_have_dev_random=no
1549     ;;
1551 dnl Everywhere else, it's /dev/random
1553     *)
1554     NAME_DEV_RANDOM="/dev/random"
1555     ;;
1556 esac
1558 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
1560 dnl Now check if the device actually exists
1562 if test "x$try_dev_random" = "xyes"; then
1563     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1564     [if test -r "$NAME_DEV_RANDOM" ; then
1565         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1566     if test "x$ac_cv_have_dev_random" = "xyes"; then
1567         AC_DEFINE(HAVE_CRYPT_RNG)
1568     fi
1569 else
1570     AC_MSG_CHECKING(for random device)
1571     ac_cv_have_dev_random=no
1572     AC_MSG_RESULT(has been disabled)
1575 if test "x$platform_win32" = "xyes"; then
1576     AC_DEFINE(HAVE_CRYPT_RNG)
1579 if test "x$ac_cv_have_dev_random" = "xno" \
1580     && test "x$platform_win32" = "xno"; then
1581     AC_MSG_WARN([[
1583 *** A system-provided entropy source was not found on this system.
1584 *** Because of this, the System.Security.Cryptography random number generator
1585 *** will throw a NotImplemented exception.
1587 *** If you are seeing this message, and you know your system DOES have an
1588 *** entropy collection in place, please contact <crichton@gimp.org> and
1589 *** provide information about the system and how to access the random device.
1591 *** Otherwise you can install either egd or prngd and set the environment
1592 *** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
1593 ***]])
1596 AC_MSG_CHECKING([if inter-process shared handles are requested])
1597 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
1598 AC_MSG_RESULT($try_shared_handles)
1599 if test "x$try_shared_handles" != "xyes"; then
1600         AC_DEFINE(DISABLE_SHARED_HANDLES)
1601         AC_SUBST(DISABLE_SHARED_HANDLES)
1604 AC_ARG_ENABLE(nunit-tests, [ --enable-nunit-tests       Run the nunit tests of the class library on 'make check'])
1605 AM_CONDITIONAL(ENABLE_NUNIT_TESTS, [test x$enable_nunit_tests = xyes])
1607 TARGET="unknown"
1608 ACCESS_UNALIGNED="yes"
1610 JIT_SUPPORTED=no
1611 INTERP_SUPPORTED=no
1612 LIBC="libc.so.6"
1613 INTL="libc.so.6"
1614 SQLITE="libsqlite.so.0"
1615 SQLITE3="libsqlite3.so.0"
1616 X11="libX11.so"
1618 jit_wanted=false
1619 interp_wanted=false
1620 case "$host" in
1621 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
1622 #               TARGET=MIPS;
1623 #               ACCESS_UNALIGNED="no"
1624 #               ;;
1625         mips*)
1626                 TARGET=MIPS;
1627                 arch_target=mips;
1628                 ACCESS_UNALIGNED="no"
1629                 JIT_SUPPORTED=yes
1630                 jit_wanted=true
1631                 ;;
1632         i*86-*-*)
1633                 TARGET=X86;
1634                 arch_target=x86;
1635                 JIT_SUPPORTED=yes
1636                 jit_wanted=true
1637                 case $host_os in
1638                   solaris*)
1639                         LIBC="libc.so"
1640                         INTL="libintl.so"
1641                         if test "x$ac_cv_sizeof_void_p" = "x8"; then
1642                                 TARGET=AMD64
1643                                 arch_target=amd64
1644                         fi
1646                         # On solaris 10 x86, gcc prints a warning saying 'visibility attribute not supported on this configuration; ignored', but linking fails. A test case:
1647                         # int astruct __attribute__ ((visibility ("hidden")));
1648                         # void foo ()
1649                         # {
1650                         #       void *p = &astruct;
1651                         # }
1652                         # gcc -fPIC --shared -o libfoo.so foo.c
1653                         # yields:
1654                         # foo.c:6: warning: visibility attribute not supported in this configuration; ignored
1655                         # ld: fatal: relocation error: R_386_GOTOFF: file /var/tmp//ccxYR96k.o: symbol astruct: relocation must bind locally
1656                         have_visibility_hidden=no
1658                 esac
1659                 ;;
1660         x86_64-*-* | amd64-*-*)
1661                 TARGET=AMD64;
1662                 arch_target=amd64;
1663                 JIT_SUPPORTED=yes
1664                 jit_wanted=true
1665                 ;;
1666         ia64-*-*)
1667                 TARGET=IA64
1668                 arch_target=ia64
1669                 ACCESS_UNALIGNED="no"
1670                 JIT_SUPPORTED=yes
1671                 jit_wanted=true
1672                 LIBC="libc.so.6.1"
1673                 INTL="libc.so.6.1"
1674                 AC_CHECK_LIB(unwind, _U_dyn_register, [], [AC_MSG_ERROR(library libunwind not found)])
1675                 libmono_ldflags="-lunwind"
1676                 ;;
1677         sparc*-*-*)
1678                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
1679                    TARGET=SPARC64
1680                 else
1681                         TARGET=SPARC
1682                 fi
1683                 arch_target=sparc;
1684                 JIT_SUPPORTED=yes
1685                 ACCESS_UNALIGNED="no"
1686                 case $host_os in
1687                   linux*) ;;
1688                   *)
1689                         LIBC="libc.so"
1690                         INTL="libintl.so"
1691                 esac
1692                 jit_wanted=true
1693                 if test x"$GCC" = xyes; then
1694                         # We don't support v8 cpus
1695                         CFLAGS="$CFLAGS -Wno-cast-align -mcpu=v9"
1696                 fi
1697                 if test x"$AR" = xfalse; then
1698                         AC_MSG_ERROR([The required utility 'ar' is not found in your PATH. Usually it can be found in /usr/ccs/bin.])
1699                 fi
1700                 ;;
1701        alpha*-*-linux* | alpha*-*-osf*)
1702                 TARGET=ALPHA;
1703                 ACCESS_UNALIGNED="no"
1704                 JIT_SUPPORTED=yes
1705                 jit_wanted=true
1706                 arch_target=alpha;
1707                 CFLAGS="$CFLAGS -mieee -O0"
1708                 case $host_os in
1709                   linux*)
1710                         LIBC="libc.so.6.1"
1711                         INTL="libc.so.6.1"
1712                 esac
1713                ;;
1714         *-*-mingw*|*-*-cygwin*)
1715                 # When this is enabled, it leads to very strange crashes at runtime (gcc-3.4.4)
1716                 have_visibility_hidden=no
1717                 INTL="intl"
1718                 ;;
1719         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
1720                 TARGET=HPPA;
1721                 arch_target=hppa; 
1722                 LIBC="libc.sl"
1723                 ACCESS_UNALIGNED="no"
1724                 INTERP_SUPPORTED=yes
1725                 interp_wanted=true
1726                 ;;
1727         hppa*linux*)
1728                 TARGET=HPPA;
1729                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1730                 arch_target=hppa; 
1731                 ACCESS_UNALIGNED="no"
1732                 JIT_SUPPORTED=yes
1733                 jit_wanted=true
1734                 ;;
1735         macppc-*-openbsd* | powerpc*-*-linux* | powerpc-*-openbsd* | \
1736         powerpc-*-sysv* | powerpc-*-darwin* | powerpc-*-netbsd* )
1737                 TARGET=POWERPC;
1738                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1739                 arch_target=ppc;
1740                 JIT_SUPPORTED=yes
1741                 jit_wanted=true
1742                 ;;
1743         arm*-linux*)
1744                 TARGET=ARM;
1745                 arch_target=arm;
1746                 ACCESS_UNALIGNED="no"
1747                 JIT_SUPPORTED=yes
1748                 jit_wanted=true
1749                 ;;
1750         s390-*-linux*)
1751                 TARGET=S390;
1752                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1753                 arch_target=s390;
1754                 ACCESS_UNALIGNED="no"
1755                 JIT_SUPPORTED=yes
1756                 jit_wanted=true
1757                 # Required CFLAGS for s390[x].  USE_STRING_INLINES is automatic with gcc 4.1
1758                 CFLAGS="$CFLAGS -mbackchain -D__USE_STRING_INLINES"
1759                 ;;
1760         s390x-*-linux*)
1761                 TARGET=S390x;
1762                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1763                 arch_target=s390x;
1764                 ACCESS_UNALIGNED="no"
1765                 JIT_SUPPORTED=yes
1766                 jit_wanted=true
1767                 CFLAGS="$CFLAGS -mbackchain -D__USE_STRING_INLINES"
1768                 ;;
1769 esac
1771 if test "x$have_visibility_hidden" = "xyes"; then
1772    AC_DEFINE(HAVE_VISIBILITY_HIDDEN, 1, [Support for the visibility ("hidden") attribute])
1775 AC_ARG_WITH(jit, [  --with-jit=yes,no       If you want to build scripts that default to the JIT],[
1776         if test x$withval = xyes; then
1777            jit_wanted=true
1778         else
1779            jit_wanted=false
1780         fi
1783 AC_ARG_WITH(interp, [  --with-interp=yes,no    If you want to build scripts that default to the interpreter],[
1784         if test x$withval = xyes; then
1785            interp_wanted=true
1786         else
1787            interp_wanted=false
1788         fi
1791 USEJIT=false
1792 if test x$JIT_SUPPORTED = xyes; then
1793    if $jit_wanted; then
1794       USEJIT=true
1795       jit_status="Building and using the JIT"
1796    else
1797       if $interp_wanted; then
1798          jit_status="Building the JIT, defaulting to the interpreter"
1799       else
1800          AC_ERROR(No JIT or interpreter support available or selected.)
1801       fi
1802    fi
1803 else
1804    if test x$interp_wanted = xtrue; then
1805       jit_status="interpreter"
1806    else
1807       AC_ERROR(No JIT or interpreter support available or selected.)
1808    fi
1811 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
1813 libsuffix=".so"
1815 case "$host" in
1816      *-*-darwin*)
1817         libsuffix=".dylib"
1818         LIBC="libc.dylib"
1819         INTL="libintl.dylib"
1820         SQLITE="libsqlite.0.dylib"
1821         SQLITE3="libsqlite3.0.dylib"
1822         X11="libX11.dylib"
1823         ;;
1824      *-*-*netbsd*)
1825         LIBC="libc.so.12"
1826         INTL="libintl.so.0"
1827         ;;
1828     *-*-*freebsd*)
1829         LIBC="libc.so"
1830         INTL="libintl.so"
1831         ;;
1832     *-*-*openbsd*)
1833         LIBC="libc.so"
1834         INTL="libintl.so"
1835         ;;
1836     *-*-*linux*)
1837         AC_PATH_X
1838         AC_MSG_CHECKING(for the soname of libX11.so)
1839         for i in $x_libraries /usr/lib /usr/lib64; do
1840                 for r in 4 5 6; do
1841                         if test -f $i/libX11.so.$r; then
1842                                 X11=libX11.so.$r
1843                                 AC_MSG_RESULT($X11)
1844                         fi
1845                 done
1846         done
1847         
1848         if test "x$X11" = "xlibX11.so"; then
1849                 AC_MSG_WARN([Could not find X development libs. Do you have the -devel package installed? WinForms may not work...]);
1850         fi
1851         ;;
1852 esac
1855 AC_SUBST(libsuffix)
1857 if test "x$TARGET" != "xAMD64"; then
1858    # valgrind headers don't compile under x86-64
1859    AC_CHECK_HEADERS(valgrind/memcheck.h)
1862 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
1863         if test "x$with_tls" = "x__thread"; then
1864                 #
1865                 # On some linux distributions, TLS works in executables, but linking 
1866                 # against a shared library containing TLS fails with:
1867                 # undefined reference to `__tls_get_addr'
1868                 #
1869                 rm -f conftest.c conftest.so conftest
1870                 echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
1871                 $CC -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
1872                 $CC -o conftest conftest.so > /dev/null 2>&1
1873                 if test ! -f conftest; then
1874                    AC_MSG_WARN([Disabling usage of __thread.]);
1875                    with_tls=pthread
1876                 fi
1877                 rm -f conftest.c conftest.so conftest
1878         fi
1881 mono_debugger_supported=no
1882 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86" -o "x$TARGET" = "xALPHA"; then
1883         if test x$use_included_gc = xyes; then
1884                 case "$host" in
1885                 *-*-*linux*)
1886                         mono_debugger_supported=yes
1887                         ;;
1888                 esac
1889         fi
1892 AC_MSG_CHECKING(if the Mono Debugger is supported on this platform)
1893 if test "x$mono_debugger_supported" = "xyes"; then
1894         AC_DEFINE(MONO_DEBUGGER_SUPPORTED,1,[The Mono Debugger is supported on this platform])
1896 AC_MSG_RESULT($mono_debugger_supported)
1897 AM_CONDITIONAL(MONO_DEBUGGER_SUPPORTED, test x$mono_debugger_supported = xyes)
1899 if test "x$with_tls" = "x__thread"; then
1900         AC_DEFINE(HAVE_KW_THREAD)
1901         # Pass the information to libgc
1902         CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
1903         AC_MSG_CHECKING(if the tls_model attribute is supported)
1904         AC_TRY_COMPILE([static __thread int foo __attribute__((tls_model("initial-exec")));], [
1905                 ], [
1906                         AC_MSG_RESULT(yes)
1907                         AC_DEFINE(HAVE_TLS_MODEL_ATTR, 1, [tld_model available])
1908                 ], [
1909                         AC_MSG_RESULT(no)
1910         ])
1913 if test ${TARGET} = ARM; then
1914         dnl ******************************************
1915         dnl *** Check to see what FPU is available ***
1916         dnl ******************************************
1917         AC_MSG_CHECKING(which FPU to use)
1919         AC_TRY_COMPILE([], [
1920                 __asm__ ("ldfd f0, [r0]");
1921                 ], fpu=FPA, fpu=NONE)
1923         AC_MSG_RESULT($fpu)
1924         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu=1"
1925         unset fpu
1928 if test ${TARGET} = unknown; then
1929         CPPFLAGS="$CPPFLAGS -DNO_PORT"
1930         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
1933 if test ${ACCESS_UNALIGNED} = no; then
1934         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
1937 PREVIEW=yes
1938 AC_ARG_WITH(preview,  [ --with-preview=yes,no     If you want to install the 2.0 FX preview],[
1939         if test x$with_preview = xno; then
1940               PREVIEW=no
1941         fi
1944 MOONLIGHT=no
1945 AC_ARG_WITH(moonlight,[ --with-moonlight=yes,no   If you want to build the Moonlight 2.1 assemblies],[
1946         if test x$with_moonlight = xyes; then
1947               MOONLIGHT=yes
1948         fi
1951 libmono_ldflags="$libmono_ldflags $LIBS"
1953 AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
1954 AM_CONDITIONAL(INSTALL_2_1, test x$MOONLIGHT = xyes)
1956 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
1957 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
1958 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
1959 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
1960 AM_CONDITIONAL(X86, test x$TARGET = xX86)
1961 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
1962 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
1963 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
1964 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
1965 AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
1966 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
1967 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
1968 AM_CONDITIONAL(S390, test x$TARGET = xS390)
1969 AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
1970 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
1972 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
1973 AM_CONDITIONAL(INTERP_SUPPORTED, test x$interp_wanted = xtrue)
1974 AM_CONDITIONAL(INCLUDED_LIBGC, test x$gc = xincluded)
1976 AC_SUBST(LIBC)
1977 AC_SUBST(INTL)
1978 AC_SUBST(SQLITE)
1979 AC_SUBST(SQLITE3)
1980 AC_SUBST(X11)
1981 AC_DEFINE_UNQUOTED(ARCHITECTURE,"$arch_target",[The architecture this is running on])
1982 AC_SUBST(arch_target)
1983 AC_SUBST(CFLAGS)
1984 AC_SUBST(CPPFLAGS)
1985 AC_SUBST(LDFLAGS)
1987 mono_build_root=`pwd`
1988 AC_SUBST(mono_build_root)
1990 if test x$USEJIT = xtrue; then
1991   mono_runtime=mono/mini/mono
1992 else
1993   mono_runtime=mono/interpreter/mint
1995 AC_SUBST(mono_runtime)
1997 mono_cfg_root=$mono_build_root/runtime
1998 if test x$platform_win32 = xyes; then
1999   mono_cfg_dir=`cygpath -w -a $mono_cfg_root`\\etc
2000 else
2001   mono_cfg_dir=$mono_cfg_root/etc
2003 AC_SUBST(mono_cfg_dir)
2005 AC_CONFIG_FILES([runtime/mono-wrapper],[chmod +x runtime/mono-wrapper])
2006 AC_CONFIG_FILES([runtime/monodis-wrapper],[chmod +x runtime/monodis-wrapper])
2007 AC_CONFIG_FILES([runtime/semdel-wrapper],[chmod +x runtime/semdel-wrapper])
2009 AC_CONFIG_COMMANDS([runtime/etc/mono/1.0/machine.config],
2010 [   depth=../../../..
2011     case $srcdir in
2012     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2013     .) reldir=$depth ;;
2014     *) reldir=$depth/$srcdir ;;
2015     esac
2016     $ac_aux_dir/install-sh -d runtime/etc/mono/1.0
2017     cd runtime/etc/mono/1.0
2018     rm -f machine.config
2019     $LN_S $reldir/data/net_1_1/machine.config machine.config
2020     cd $depth
2021 ],[LN_S='$LN_S'])
2023 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/machine.config],
2024 [   depth=../../../..
2025     case $srcdir in
2026     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2027     .) reldir=$depth ;;
2028     *) reldir=$depth/$srcdir ;;
2029     esac
2030     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
2031     cd runtime/etc/mono/2.0
2032     rm -f machine.config
2033     $LN_S $reldir/data/net_2_0/machine.config machine.config
2034     cd $depth
2035 ],[LN_S='$LN_S'])
2037 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/web.config],
2038 [   depth=../../../..
2039     case $srcdir in
2040     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2041     .) reldir=$depth ;;
2042     *) reldir=$depth/$srcdir ;;
2043     esac
2044     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
2045     cd runtime/etc/mono/2.0
2046     rm -f web.config
2047     $LN_S $reldir/data/net_2_0/web.config web.config
2048     cd $depth
2049 ],[LN_S='$LN_S'])
2051 AC_CONFIG_COMMANDS([runtime/etc/mono/browscap.ini],
2052 [   depth=../../..
2053     case $srcdir in
2054     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2055     .) reldir=$depth ;;
2056     *) reldir=$depth/$srcdir ;;
2057     esac
2058     $ac_aux_dir/install-sh -d runtime/etc/mono/
2059     cd runtime/etc/mono/
2060     rm -f browscap.ini
2061     $LN_S $reldir/data/browscap.ini browscap.ini
2062     cd $depth
2063 ],[LN_S='$LN_S'])
2065 AC_OUTPUT([
2066 Makefile
2067 mono-uninstalled.pc
2068 scripts/mono-nunit.pc
2069 scripts/mono-find-provides
2070 scripts/mono-find-requires
2071 mono/Makefile
2072 mono/utils/Makefile
2073 mono/metadata/Makefile
2074 mono/dis/Makefile
2075 mono/cil/Makefile
2076 mono/arch/Makefile
2077 mono/os/Makefile
2078 mono/arch/x86/Makefile
2079 mono/arch/amd64/Makefile
2080 mono/arch/hppa/Makefile
2081 mono/arch/ppc/Makefile
2082 mono/arch/sparc/Makefile
2083 mono/arch/s390/Makefile
2084 mono/arch/s390x/Makefile
2085 mono/arch/arm/Makefile
2086 mono/arch/alpha/Makefile
2087 mono/arch/ia64/Makefile
2088 mono/arch/mips/Makefile
2089 mono/interpreter/Makefile
2090 mono/tests/Makefile
2091 mono/tests/tests-config
2092 mono/tests/assemblyresolve/Makefile
2093 mono/tests/cas/Makefile
2094 mono/tests/cas/assembly/Makefile
2095 mono/tests/cas/demand/Makefile
2096 mono/tests/cas/inheritance/Makefile
2097 mono/tests/cas/linkdemand/Makefile
2098 mono/tests/cas/threads/Makefile
2099 mono/benchmark/Makefile
2100 mono/monoburg/Makefile
2101 mono/monograph/Makefile
2102 mono/io-layer/Makefile
2103 mono/mini/Makefile
2104 mono/profiler/Makefile
2105 ikvm-native/Makefile
2106 scripts/Makefile
2107 man/Makefile
2108 web/Makefile
2109 docs/Makefile
2110 data/Makefile
2111 data/net_1_1/Makefile
2112 data/net_2_0/Makefile
2113 data/mint.pc
2114 data/mono.pc
2115 data/mono-cairo.pc
2116 data/dotnet.pc
2117 data/cecil.pc
2118 samples/Makefile
2119 support/Makefile
2120 data/config
2121 tools/Makefile
2122 tools/locale-builder/Makefile
2123 runtime/Makefile
2124 msvc/Makefile
2127 if test x$platform_win32 = xyes; then
2128    # Get rid of 'cyg' prefixes in library names
2129    sed -e "s/\/cyg\//\/\//" libtool > libtool.new; mv libtool.new libtool; chmod 755 libtool
2130    # libtool seems to inherit -mno-cygwin from our CFLAGS, and uses it to compile its executable
2131    # wrapper scripts which use exec(). gcc has no problem compiling+linking this, but the resulting
2132    # executable doesn't work...
2133    sed -e "s,-mno-cygwin,,g" libtool > libtool.new; mv libtool.new libtool; chmod 755 libtool
2137   case $prefix in
2138   NONE) prefix=$ac_default_prefix ;;
2139   esac
2140   case $exec_prefix in
2141   NONE) exec_prefix='${prefix}' ;;
2142   esac
2144   test -w $srcdir/$mcsdir/build || chmod +w $srcdir/$mcsdir/build
2146   #
2147   # If we are cross compiling, we don't build in the mcs/ tree.  Let us not clobber
2148   # any existing config.make.  This allows people to share the same source tree
2149   # with different build directories, one native and one cross
2150   #
2151   if test x$cross_compiling = xno && test x$enable_mcs_build != xno; then
2152     echo "prefix=$prefix" > $srcdir/$mcsdir/build/config.make
2153     echo "exec_prefix=$exec_prefix" >> $srcdir/$mcsdir/build/config.make
2154     echo 'mono_libdir=${exec_prefix}/lib' >> $srcdir/$mcsdir/build/config.make
2155     echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $srcdir/$mcsdir/build/config.make
2156     echo 'IL_FLAGS = /debug' >> $srcdir/$mcsdir/build/config.make
2157     echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $srcdir/$mcsdir/build/config.make
2158     echo "ILDISASM = $mono_build_root/runtime/monodis-wrapper" >> $srcdir/$mcsdir/build/config.make
2160     case $INSTALL in
2161     [[\\/$]]* | ?:[[\\/]]* ) mcs_INSTALL=$INSTALL ;;
2162     *) mcs_INSTALL=$mono_build_root/$INSTALL ;;
2163     esac
2165     echo "INSTALL = $mcs_INSTALL" >> $srcdir/$mcsdir/build/config.make
2167     export VERSION
2168     [myver=$($AWK 'BEGIN {
2169       split (ENVIRON["VERSION"] ".0.0.0", vsplit, ".")
2170       if(length(vsplit [1]) > 4) {
2171         split (substr(ENVIRON["VERSION"], 0, 4) "." substr(ENVIRON["VERSION"], 5) ".0.0", vsplit, ".")
2172       }
2173       print vsplit [1] "." vsplit [2] "." vsplit [3] "." vsplit [4]
2174     }')]
2176     echo "MONO_VERSION = $myver" >> $srcdir/$mcsdir/build/config.make
2177   fi
2179   # if we have an olive folder, override the default settings
2180   if test -d $olivedir; then
2182     test -w $srcdir/$olivedir/build || chmod +w $srcdir/$olivedir/build
2184     if test x$cross_compiling = xno && test x$enable_olive_build != xno; then
2185       echo "prefix=$prefix" > $srcdir/$olivedir/build/config.make
2186       echo "exec_prefix=$exec_prefix" >> $srcdir/$olivedir/build/config.make
2187       echo 'mono_libdir=${exec_prefix}/lib' >> $srcdir/$olivedir/build/config.make
2188       echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $srcdir/$olivedir/build/config.make
2189       echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $srcdir/$olivedir/build/config.make
2190       echo "MONO_VERSION = $myver" >> $srcdir/$olivedir/build/config.make
2191           if test x$with_moonlight = xyes; then
2192         echo "WITH_MOONLIGHT = yes" >> $srcdir/$olivedir/build/config.make
2193       fi
2194     fi
2195   fi
2198 libgdiplus_msg=${libgdiplus_loc:-assumed to be installed}
2200 echo "
2201         mcs source:    $mcs_topdir
2202         olive source:  $olive_topdir
2204         GC:          $gc
2205         TLS:         $with_tls
2206         SIGALTSTACK: $with_sigaltstack
2207         Engine:      $jit_status
2208         2.0 Beta:    $PREVIEW
2209         2.1 Alpha:   $MOONLIGHT
2210         JNI support: $jdk_headers_found
2211         libgdiplus:  $libgdiplus_msg
2212         zlib:        $zlib_msg
2213         $disabled
2216 if test x$with_static_mono = xno -a "x$platform_win32" != "xyes"; then
2217    AC_MSG_WARN(Turning off static Mono is a risk, you might run into unexepcted bugs)
2220 if test x$gc = xsgen; then
2221         echo IMPORTANT:
2222         echo IMPORTANT: You have selected an experimental, work-in-progress 
2223         echo IMPORTANT: GC engine.  This GC engine is currently not supported
2224         echo IMPORTANT: and is not yet ready for use.  
2225         echo IMPORTANT:
2226         echo IMPORTANT: There are known problems with it, use at your own risk.