Bump revision
[mono-project.git] / configure.in
blob75fd8c68b6517e33d038ceb3a456848d6593ccc4
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.1.7.7)
10 AM_MAINTAINER_MODE
12 AC_PROG_LN_S
14 # In case of cygwin, override LN_S, irrespective of what it determines.
15 # The build uses cygwin, but the actual runtime doesn't.
16 case $host_os in
17 *cygwin* ) LN_S='cp -p';;
18 esac
21 dnl
22 dnl libgc checks
23 dnl
25 gc_headers=no
26 gc=included
27 use_included_gc=no
29 if test -d $srcdir/libgc ; then
30   gc_default=included
31 else
32   gc_default=boehm
36 # These are the flags that need to be stored in the mono.pc file for 
37 # compiling code that will embed Mono
39 libmono_cflags=""
40 libmono_ldflags=""
41 AC_SUBST(libmono_cflags)
42 AC_SUBST(libmono_ldflags)
44 dnl if linker handles the version script
45 no_version_script=no
47 # Set to yes if Unix sockets cannot be created in an anonymous namespace
48 need_link_unlink=no
50 # Thread configuration inspired by sleepycat's db
51 AC_MSG_CHECKING([host platform characteristics])
52 libgc_threads=no
53 case "$host" in
54         *-*-mingw*|*-*-cygwin*)
55                 platform_win32=yes
56                 AC_DEFINE(PLATFORM_WIN32,1,[Platform is Win32])
57                 CC="gcc -mno-cygwin -g"
58                 HOST_CC="gcc"
59                 # So libgc configure gets -mno-cygwin
60                 export CC
61 # latest libgc already defines GC_WIN32_THREADS
62 #               CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS -DWIN32_THREADS"
63                 CPPFLAGS="$CPPFLAGS -DWIN32_THREADS -DFD_SETSIZE=1024"
64                 libdl=
65                 libgc_threads=win32
66                 gc_default=included
67                 with_nptl=default
68                 with_sigaltstack=no
69                 LN_S=cp
70                 ;;
71         *-*-*netbsd*)
72                 platform_win32=no
73                 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
74                 libmono_cflags="-D_REENTRANT"
75                 LDFLAGS="$LDFLAGS -pthread"
76                 libmono_ldflags="-pthread"
77                 need_link_unlink=yes
78                 libdl=
79                 libgc_threads=no
80                 ;;
81 # these flags will work for all versions of -STABLE
83         *-*-*freebsd4*)
84                 platform_win32=no
85                 if test "x$PTHREAD_CFLAGS" = "x"; then
86                         CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
87                         libmono_cflags="-D_THREAD_SAFE"
88                 else
89                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
90                         libmono_cflags="$PTHREAD_CFLAGS"
91                 fi
92                 if test "x$PTHREAD_LIBS" = "x"; then
93                         LDFLAGS="$LDFLAGS -pthread"
94                         libmono_ldflags="-pthread"
95                 else
96                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
97                         libmono_ldflags="$PTHREAD_LIBS"
98                 fi
99                 need_link_unlink=yes
100                 AC_DEFINE(PTHREAD_POINTER_ID)
101                 libdl=
102                 libgc_threads=pthreads
103 # TLS isn't implemented at all on 4-STABLE
104                 with_nptl=no
105                 with_tls=pthread
106                 ;;
107         *-*-*freebsd5*)
108                 platform_win32=no
109                 if test "x$PTHREAD_CFLAGS" = "x"; then
110                         CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
111                         libmono_cflags=
112                 else
113                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
114                         libmono_cflags="$PTHREAD_CFLAGS"
115                 fi
116                 if test "x$PTHREAD_LIBS" = "x"; then
117                         LDFLAGS="$LDFLAGS -pthread"
118                         libmono_ldflags="-pthread"
119                 else
120                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
121                         libmono_ldflags="$PTHREAD_LIBS"
122                 fi
123                 need_link_unlink=yes
124                 AC_DEFINE(PTHREAD_POINTER_ID)
125                 libdl=
126                 with_sigaltstack=yes
127                 libgc_threads=pthreads
128 # TLS is only partially implemented on 5-STABLE (compiler support
129 # but NOT library support)
131                 with_tls=pthread
132                 ;;
133         *-*-*freebsd6*)
134                 platform_win32=no
135                 if test "x$PTHREAD_CFLAGS" = "x"; then
136                         CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
137                         libmono_cflags=
138                 else
139                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
140                         libmono_cflags="$PTHREAD_CFLAGS"
141                 fi
142                 if test "x$PTHREAD_LIBS" = "x"; then
143                         LDFLAGS="$LDFLAGS -pthread"
144                         libmono_ldflags="-pthread"
145                 else
146                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
147                         libmono_ldflags="$PTHREAD_LIBS"
148                 fi
149                 need_link_unlink=yes
150                 AC_DEFINE(PTHREAD_POINTER_ID)
151                 libdl=
152                 libgc_threads=pthreads
153                 with_sigaltstack=yes
154 # TLS is only partially implemented on -CURRENT (compiler support
155 # but NOT library support)
157                 with_tls=pthread
158                 ;;
159         *-*-*openbsd*)
160                 platform_win32=no
161                 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
162                 libmono_cflags="-D_THREAD_SAFE"
163                 LDFLAGS="$LDFLAGS -pthread"
164                 libmono_ldflags="-pthread"
165                 need_link_unlink=yes
166                 AC_DEFINE(PTHREAD_POINTER_ID)
167                 libdl=
168                 libgc_threads=pthreads
169                 ;;
170         *-*-linux*)
171                 platform_win32=no
172                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT"
173                 libmono_cflags="-D_REENTRANT"
174                 libmono_ldflags="-lpthread"
175                 libdl="-ldl"
176                 libgc_threads=pthreads
177                 ;;
178         *-*-hpux*)
179                 platform_win32=no
180                 CPPFLAGS="$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
181                 CFLAGS="$CFLAGS +ESdbgasm"
182                 LDFLAGS="$LDFLAGS -z"
183                 libmono_cflags="-D_REENTRANT"
184                 libmono_ldflags="-lpthread"
185                 libgc_threads=pthreads
186                 need_link_unlink=yes
187                 ;;
188         *-*-solaris*)
189                 platform_win32=no
190                 CPPFLAGS="$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
191                 need_link_unlink=yes
192                 libmono_cflags="-D_REENTRANT"
193                 libgc_threads=pthreads
194                 ;;
195         *-*-darwin*)
196                 platform_win32=no
197                 CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE -DGC_MACOSX_THREADS"
198                 libmono_cflags="-D_THREAD_SAFE"
199                 LDFLAGS="$LDFLAGS -pthread"
200                 libmono_ldflags="-pthread"
201                 need_link_unlink=yes
202                 AC_DEFINE(PTHREAD_POINTER_ID)
203                 AC_DEFINE(USE_MACH_SEMA)
204                 no_version_script=yes
205                 libdl=
206                 libgc_threads=pthreads
207                 ;;
208         *)
209                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
210                 platform_win32=no
211                 libdl="-ldl"
212                 ;;
213 esac
214 AC_MSG_RESULT(ok)
216 if test x$need_link_unlink = xyes; then
217    AC_DEFINE(NEED_LINK_UNLINK, 1, [Define if Unix sockets cannot be created in an anonymous namespace])
220 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
222 AC_CHECK_TOOL(CC, gcc, gcc)
223 AC_PROG_CC
224 AM_PROG_CC_STDC
225 AC_PROG_INSTALL
226 dnl We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
227 : ${CCAS='$(CC)'}
228 # Set ASFLAGS if not already set.
229 : ${CCASFLAGS='$(CFLAGS)'}
230 AC_SUBST(CCAS)
231 AC_SUBST(CCASFLAGS)
233 AC_CHECK_PROG(BISON, bison,yes,no)
234 if test "x$BISON" = "xno";
235 then
236         AC_MSG_ERROR([You need to install bison])
239 dnl may require a specific autoconf version
240 dnl AC_PROG_CC_FOR_BUILD
241 dnl CC_FOR_BUILD not automatically detected
242 CC_FOR_BUILD=$CC
243 BUILD_EXEEXT=
244 if test "x$cross_compiling" = "xyes"; then
245         CC_FOR_BUILD=cc
246         BUILD_EXEEXT=""
248 AC_SUBST(CC_FOR_BUILD)
249 AC_SUBST(HOST_CC)
250 AC_SUBST(BUILD_EXEEXT)
252 # Set STDC_HEADERS
253 AC_HEADER_STDC
254 AC_LIBTOOL_WIN32_DLL
255 AC_DISABLE_FAST_INSTALL
256 AM_PROG_LIBTOOL
258 # Test whenever ld supports -version-script
259 AC_PROG_LD
260 AC_PROG_LD_GNU
261 if test "x$lt_cv_prog_gnu_ld" = "xno"; then
262    no_version_script=yes
265 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
267 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h linux/rtc.h)
269 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
271 AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
273 # for mono/metadata/debug-symfile.c
274 AC_CHECK_HEADERS(elf.h)
276 # for support
277 AC_CHECK_HEADERS(poll.h)
278 AC_CHECK_HEADERS(sys/poll.h)
279 AC_CHECK_HEADERS(sys/wait.h)
280 AC_CHECK_HEADERS(grp.h)
281 AC_CHECK_HEADERS(syslog.h)
283 # for mono/dis
284 AC_CHECK_HEADERS(wchar.h)
285 case "$host" in
286         *-*-*freebsd6*)
287                 AC_CHECK_HEADERS(ieeefp.h)
288         ;;
289         *-*-*freebsd*)
290                 /* Only freebsd6 has a working ieeefp.h */
291         ;;
292         *)
293                 AC_CHECK_HEADERS(ieeefp.h)
294         ;;
295 esac
296 AC_MSG_CHECKING(for isinf)
297 AC_TRY_LINK([#include <math.h>], [
298         int f = isinf (1);
299 ], [
300         AC_MSG_RESULT(yes)
301         AC_DEFINE(HAVE_ISINF, 1, [isinf available])
302 ], [
303         # We'll have to use signals
304         AC_MSG_RESULT(no)
308 # not 64 bit clean in cross-compile
309 AC_CHECK_SIZEOF(void *, 4)
311 WARN=''
312 if test x"$GCC" = xyes; then
313         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
314                 # The runtime code does not respect ANSI C strict aliasing rules
315                 CFLAGS="$CFLAGS -fno-strict-aliasing"
317                 ORIG_CFLAGS=$CFLAGS
318                 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
319                 AC_MSG_CHECKING(for -Wdeclaration-after-statement option to gcc)
320                 AC_TRY_COMPILE([], [
321                                                    void main () { }
322                 ], [
323                    AC_MSG_RESULT(yes)
324                 ], [
325                    AC_MSG_RESULT(no)
326                    CFLAGS=$ORIG_CFLAGS
327                 ])
328 else
329         # The Sun Forte compiler complains about inline functions that access static variables
330         # so disable all inlining.
331         case "$host" in
332         *-*-solaris*)
333                 CFLAGS="$CFLAGS -Dinline="
334                 ;;
335         esac
337 CFLAGS="$CFLAGS -g $WARN"
339 # Where's the 'mcs' source tree?
340 if test -d $srcdir/mcs; then
341   mcsdir=mcs
342 else
343   mcsdir=../mcs
346 mcs_topdir='$(top_srcdir)/'$mcsdir
347 mcs_topdir_from_srcdir='$(top_builddir)/'$mcsdir
349 AC_SUBST([mcs_topdir])
350 AC_SUBST([mcs_topdir_from_srcdir])
352 AC_ARG_WITH([libgdiplus], 
353         [  --with-libgdiplus=installed|sibling|<path>   Override the libgdiplus used for System.Drawing tests (defaults to NO)], 
354         [], [with_libgdiplus=installed])
356 case $with_libgdiplus in
357 no|installed) libgdiplus_loc= ;;
358 yes|sibling) libgdiplus_loc=`cd ../libgdiplus && pwd`/src/libgdiplus.la ;;
359 /*) libgdiplus_loc=$with_libgdiplus ;;
360 *) libgdiplus_loc=`pwd`/$with_libgdiplus ;;
361 esac
362 AC_SUBST([libgdiplus_loc])
364 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
365 if test "x$PKG_CONFIG" = "xno"; then
366         AC_MSG_ERROR([You need to install pkg-config])
369 dnl for use on the build system
370 dnl pkg-config is stupid
371 BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
372 BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
373 AC_SUBST(BUILD_GLIB_CFLAGS)
374 AC_SUBST(BUILD_GLIB_LIBS)
376 pkg_config_path=
377 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
378         if test x$with_crosspkgdir = "x"; then
379                 if test -s $PKG_CONFIG_PATH; then
380                         pkg_config_path=$PKG_CONFIG_PATH
381                 fi
382         else
383                 pkg_config_path=$with_crosspkgdir
384                 PKG_CONFIG_PATH=$pkg_config_path
385                 export PKG_CONFIG_PATH
386         fi
389 ## Versions of dependencies
390 GLIB_REQUIRED_VERSION=1.3.11
392 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
394 GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
395 GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
396 GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
397 GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
399 AC_SUBST(GLIB_CFLAGS)
400 AC_SUBST(GLIB_LIBS)
401 AC_SUBST(GMODULE_CFLAGS)
402 AC_SUBST(GMODULE_LIBS)
404 if test x$platform_win32 = xyes; then   
405    AC_MSG_CHECKING(for cygwin glib2-dev package)
406    if [ cygcheck --f /usr/lib/libglib-2.0.dll.a | grep -q glib2-devel ]; then
407       AC_MSG_RESULT(found)
408           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.])
409    else
410       AC_MSG_RESULT(not found, ok)
411    fi
413    AC_MSG_CHECKING(for broken gwin32.h)
414    glib_include=`$PKG_CONFIG --cflags-only-I glib-2.0 | sed -e 's/ -I.*//g' | sed -e 's/-I//g'`
415    if test -f $glib_include/glib/gwin32.h; then
416           if [ grep ftruncate $glib_include/glib/gwin32.h | grep -q define ]; then
417                  AC_MSG_RESULT(failed)
418                  hashmark='#'
419                  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.])
420           fi
421    fi
422    AC_MSG_RESULT(ok)
425 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
427 # Enable support for fast thread-local storage
428 # Some systems have broken support, so we allow to disable it.
429 AC_ARG_WITH(tls, [  --with-tls=__thread,pthread       select Thread Local Storage implementation],[],[with_tls=__thread])
431 # Kept for compatibility
432 AC_ARG_WITH(nptl, [  --with-nptl=yes,no      deprecated, use --with-tls instead],[],[with_nptl=default])
434 if test "x$with_nptl" != "xdefault"; then
435    if test "x$with_nptl" = "xyes"; then
436       AC_MSG_WARN([--with-nptl=yes is deprecated, use --with-tls=__thread option instead.])
437           with_tls=__thread
438    fi
439    if test "x$with_nptl" = "xno"; then
440       AC_MSG_WARN([--with-nptl=no is deprecated, use --with-tls=pthread option instead.])
441           with_tls=pthread
442    fi
445 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
446 # This does not work on some platforms (bug #55253)
447 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack],[],[with_sigaltstack=no])
449 AC_ARG_WITH(static_mono, [  --with-static_mono=yes,no      link mono statically to libmono (faster)],[],[with_static_mono=yes])
451 if test "x$enable_static" = "xno"; then
452    with_static_mono=no
455 AM_CONDITIONAL(STATIC_MONO, test x$with_static_mono != xno)
457 AC_ARG_ENABLE(minimal, [  --enable-minimal=LIST      drop support for LIST subsystems.
458   LIST is a comma-separated list from: aot, profiler, decimal, pinvoke, debug, reflection_emit.],
460         for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
461                 eval "mono_feature_disable_$feature='yes'"
462                 AC_MSG_NOTICE([Disabled support for feature: $feature])
463         done
464         disabled="Disabled:    $enable_minimal"
465 ],[])
467 if test "x$mono_feature_disable_aot" = "xyes"; then
468         AC_DEFINE(DISABLE_AOT, 1, [Disable AOT support])
471 if test "x$mono_feature_disable_profiler" = "xyes"; then
472         AC_DEFINE(DISABLE_PROFILER, 1, [Disable default profiler support])
475 if test "x$mono_feature_disable_decimal" = "xyes"; then
476         AC_DEFINE(DISABLE_DECIMAL, 1, [Disable System.Decimal support])
479 if test "x$mono_feature_disable_pinvoke" = "xyes"; then
480         AC_DEFINE(DISABLE_PINVOKE, 1, [Disable P/Invoke support])
483 if test "x$mono_feature_disable_debug" = "xyes"; then
484         AC_DEFINE(DISABLE_DEBUG, 1, [Disable runtime debugging support])
487 if test "x$mono_feature_disable_reflection_emit" = "xyes"; then
488         AC_DEFINE(DISABLE_REFLECTION_EMIT, 1, [Disable reflection emit support])
491 LIBGC_CFLAGS=
492 LIBGC_LIBS=
493 LIBGC_STATIC_LIBS=
494 libgc_dir=
495 case "x$gc" in
496         xboehm|xbohem|xyes)
497                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
498                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
500                 if test "x$found_boehm" != "xyes"; then
501                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
502                 fi
503                 if test "x$gc_headers" != "xyes"; then
504                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
505                 fi
507                 AC_DEFINE(HAVE_BOEHM_GC)
508                 AC_SUBST(HAVE_BOEHM_GC)
509                 LIBGC_LIBS="-lgc $libdl"
510                 LIBGC_STATIC_LIBS="$LIBGC_LIBS"
512                 # AC_CHECK_FUNCS does not work for some reason...
513                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
514                 if test "x$found_gcj_malloc" = "xyes"; then
515                         AC_DEFINE(HAVE_GC_GCJ_MALLOC)
516                 fi
517                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
518                 if test "x$found_gc_enable" = "xyes"; then
519                         AC_DEFINE(HAVE_GC_ENABLE)
520                 fi
521                 ;;
523         xincluded)
524                 AC_CONFIG_SUBDIRS(libgc)
526                 found_boehm=yes
527                 gc_headers=yes
528                 use_included_gc=yes
529                 libgc_dir=libgc
531                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
532                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
533                 LIBGC_STATIC_LIBS='$(top_builddir)/libgc/libmonogc-static.la'
535                 AC_DEFINE(HAVE_BOEHM_GC)
536                 AC_SUBST(HAVE_BOEHM_GC)
538                 AC_DEFINE(HAVE_GC_H)
539                 AC_DEFINE(USE_INCLUDED_LIBGC)
541                 # The included libgc contains GCJ support
542                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
543                 AC_DEFINE(HAVE_GC_ENABLE)
544                 ;;
546         xnone)
547                 AC_MSG_WARN("Compiling mono without GC.")
548                 ;;
549         *)
550                 AC_MSG_ERROR([Invalid argument to --with-gc.])
551                 ;;
552 esac
554 AC_ARG_WITH(large-heap, [  --with-large-heap=yes,no    Enable support for GC heaps larger than 3GB], [large_heap=$withval], [large_heap=no])
555 if test "x$large_heap" = "xyes"; then
556    echo "FOO"
557    CPPFLAGS="$CPPFLAGS -DLARGE_CONFIG"
560 # tell libgc/configure about what we want
561 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
563 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
564 AC_SUBST(LIBGC_CFLAGS)
565 AC_SUBST(LIBGC_LIBS)
566 AC_SUBST(LIBGC_STATIC_LIBS)
567 AC_SUBST(libgc_dir)
570 dnl End of libgc checks
573 if test x$platform_win32 = xno; then
575         dnl ******************************************************************
576         dnl *** Checks for the IKVM JNI interface library                  ***
577         dnl ******************************************************************
578         AC_ARG_WITH(ikvm-native, [  --with-ikvm-native=yes,no  build the IKVM JNI interface library],[with_ikvm_native=$withval],[with_ikvm_native=yes])
580         ikvm_native_dir=
581         if test x$with_ikvm_native = xyes; then
582                 ikvm_native_dir=ikvm-native
583                 jdk_headers_found="IKVM Native"
584         fi
586         AC_SUBST(ikvm_native_dir)
588         AC_CHECK_FUNCS(getgrgid_r)
589         AC_CHECK_FUNCS(getgrnam_r)
590         AC_CHECK_FUNCS(getpwnam_r)
591         AC_CHECK_FUNCS(getpwuid_r)
592         AC_CHECK_FUNCS(getresuid)
593         AC_CHECK_FUNCS(setresuid)
594         AC_CHECK_FUNCS(kqueue)
595         AC_CHECK_FUNCS(backtrace_symbols)
597         dnl ******************************************************************
598         dnl *** Check for large file support                               ***
599         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
600         dnl ******************************************************************
601         
602         # Check that off_t can represent 2**63 - 1 correctly, working around
603         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
604         # CPPFLAGS and sets $large_offt to yes if the test succeeds
605         large_offt=no
606         AC_DEFUN(LARGE_FILES, [
607                 large_CPPFLAGS=$CPPFLAGS
608                 CPPFLAGS="$CPPFLAGS $1"
609                 AC_TRY_RUN([
610                         #include <sys/types.h>
612                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
614                         int main(void) {
615                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
616                                                (BIG_OFF_T%2147483647==1));
617                                 if(big_off_t) {
618                                         exit(0);
619                                 } else {
620                                         exit(1);
621                                 }
622                         }
623                 ], [
624                         AC_MSG_RESULT(ok)
625                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
626                         large_CPPFLAGS="$large_CPPFLAGS $1"
627                         large_offt=yes
628                 ], [
629                         AC_MSG_RESULT(no)
630                 ], "")
631                 CPPFLAGS=$large_CPPFLAGS
632         ])
634         AC_MSG_CHECKING(if off_t is 64 bits wide)
635         LARGE_FILES("")
636         if test $large_offt = no; then
637                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
638                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
639         fi
640         if test $large_offt = no; then
641                 AC_MSG_WARN([No 64 bit file size support available])
642         fi
643         
644         dnl *****************************
645         dnl *** Checks for libsocket  ***
646         dnl *****************************
647         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
649         dnl *******************************
650         dnl *** Checks for MSG_NOSIGNAL ***
651         dnl *******************************
652         AC_MSG_CHECKING(for MSG_NOSIGNAL)
653         AC_TRY_COMPILE([#include <sys/socket.h>], [
654                 int f = MSG_NOSIGNAL;
655         ], [
656                 # Yes, we have it...
657                 AC_MSG_RESULT(yes)
658                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
659         ], [
660                 # We'll have to use signals
661                 AC_MSG_RESULT(no)
662         ])
664         dnl *****************************
665         dnl *** Checks for SOL_IP     ***
666         dnl *****************************
667         AC_MSG_CHECKING(for SOL_IP)
668         AC_TRY_COMPILE([#include <netdb.h>], [
669                 int level = SOL_IP;
670         ], [
671                 # Yes, we have it...
672                 AC_MSG_RESULT(yes)
673                 AC_DEFINE(HAVE_SOL_IP)
674         ], [
675                 # We'll have to use getprotobyname
676                 AC_MSG_RESULT(no)
677         ])
679         dnl *****************************
680         dnl *** Checks for SOL_IPV6     ***
681         dnl *****************************
682         AC_MSG_CHECKING(for SOL_IPV6)
683         AC_TRY_COMPILE([#include <netdb.h>], [
684                 int level = SOL_IPV6;
685         ], [
686                 # Yes, we have it...
687                 AC_MSG_RESULT(yes)
688                 AC_DEFINE(HAVE_SOL_IPV6)
689         ], [
690                 # We'll have to use getprotobyname
691                 AC_MSG_RESULT(no)
692         ])
694         dnl *****************************
695         dnl *** Checks for SOL_TCP    ***
696         dnl *****************************
697         AC_MSG_CHECKING(for SOL_TCP)
698         AC_TRY_COMPILE([#include <netdb.h>], [
699                 int level = SOL_TCP;
700         ], [
701                 # Yes, we have it...
702                 AC_MSG_RESULT(yes)
703                 AC_DEFINE(HAVE_SOL_TCP)
704         ], [
705                 # We'll have to use getprotobyname
706                 AC_MSG_RESULT(no)
707         ])
709         dnl *****************************
710         dnl *** Checks for IP_PKTINFO ***
711         dnl *****************************
712         AC_MSG_CHECKING(for IP_PKTINFO)
713         AC_TRY_COMPILE([#include <netdb.h>], [
714                 int level = IP_PKTINFO;
715         ], [
716                 # Yes, we have it...
717                 AC_MSG_RESULT(yes)
718                 AC_DEFINE(HAVE_IP_PKTINFO)
719         ], [
720                 AC_MSG_RESULT(no)
721         ])
723         dnl *********************************
724         dnl *** Check for struct ip_mreqn ***
725         dnl *********************************
726         AC_MSG_CHECKING(for struct ip_mreqn)
727         AC_TRY_COMPILE([#include <netinet/in.h>], [
728                 struct ip_mreqn mreq;
729                 mreq.imr_address.s_addr = 0;
730         ], [
731                 # Yes, we have it...
732                 AC_MSG_RESULT(yes)
733                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
734         ], [
735                 # We'll just have to try and use struct ip_mreq
736                 AC_MSG_RESULT(no)
737                 AC_MSG_CHECKING(for struct ip_mreq)
738                 AC_TRY_COMPILE([#include <netinet/in.h>], [
739                         struct ip_mreq mreq;
740                         mreq.imr_interface.s_addr = 0;
741                 ], [
742                         # Yes, we have it...
743                         AC_MSG_RESULT(yes)
744                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
745                 ], [
746                         # No multicast support
747                         AC_MSG_RESULT(no)
748                 ])
749         ])
750         
751         dnl **********************************
752         dnl *** Check for gethostbyname2_r ***
753         dnl **********************************
754         AC_MSG_CHECKING(for gethostbyname2_r)
755                 AC_TRY_LINK([#include <netdb.h>], [
756                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
757         ], [
758                 # Yes, we have it...
759                 AC_MSG_RESULT(yes)
760                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R)
761         ], [
762                 AC_MSG_RESULT(no)
763         ])
765         dnl *****************************
766         dnl *** Checks for libnsl     ***
767         dnl *****************************
768         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
770         AC_CHECK_FUNCS(inet_pton inet_aton)
772         dnl ***********************************************
773         dnl *** Checks for size of sockaddr_un.sun_path ***
774         dnl ***********************************************
775         # AC_CHECK_SIZEOF can't cope with struct members :-(
776         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
777         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
778                 [AC_TRY_RUN([
779                         #include <sys/types.h>
780                         #include <stdio.h>
781                         #include <sys/un.h>
783                         int main(void) {
784                                 struct sockaddr_un sock_un;
785                                 FILE *f=fopen("conftestval", "w");
786                                 if(!f) exit(1);
787                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
788                                 exit(0);
789                         }
790                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
791                    cv_mono_sizeof_sunpath=0,
792                    cv_mono_sizeof_sunpath=0)])dnl
793         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
794         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
796         dnl *************************************
797         dnl *** Checks for zero length arrays ***
798         dnl *************************************
799         AC_MSG_CHECKING(whether $CC supports zero length arrays)
800         AC_TRY_COMPILE([
801                 struct s {
802                         int  length;
803                         char data [0];
804                 };
805         ], [], [
806                 AC_MSG_RESULT(yes)
807                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 0)
808         ], [
809                 AC_MSG_RESULT(no)
810                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 1)
811         ])
813         dnl *****************************
814         dnl *** Checks for libxnet    ***
815         dnl *****************************
816         case "${host}" in
817                 *solaris* )
818                         AC_MSG_CHECKING(for Solaris XPG4 support)
819                         if test -f /usr/lib/libxnet.so; then
820                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
821                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
822                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
823                                 LIBS="$LIBS -lxnet"
824                                 AC_MSG_RESULT(yes)
825                         else
826                                 AC_MSG_RESULT(no)
827                         fi
829                         if test "$GCC" = "yes"; then
830                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
831                         fi
832                 ;;
833         esac
835         dnl *****************************
836         dnl *** Checks for libpthread ***
837         dnl *****************************
838 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
839 # and libpthread does not exist
841         case "${host}" in
842                 *-*-*freebsd4*)
843                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
844                 ;;
845                 *-*-*freebsd5*)
846                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
847                 ;;
848                 *-*-*freebsd6*)
849                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
850                 ;;
851                 *)
852                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
853                 ;;
854         esac
855         AC_CHECK_HEADERS(pthread.h)
856         AC_CHECK_FUNCS(pthread_mutex_timedlock)
857         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
858         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
859         AC_TRY_COMPILE([ #include <pthread.h>], [
860                 pthread_mutexattr_t attr;
861                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
862         ], [
863                 AC_MSG_RESULT(ok)
864         ], [
865                 AC_MSG_RESULT(no)
866                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
867                 AC_DEFINE(USE_MONO_MUTEX)
868         ])
869         AC_CHECK_FUNCS(pthread_attr_setstacksize)
871         dnl ***********************************
872         dnl *** Checks for working __thread ***
873         dnl ***********************************
874         AC_MSG_CHECKING(for working __thread)
875         if test "x$with_tls" != "x__thread"; then
876                 AC_MSG_RESULT(disabled)
877         else
878                 AC_TRY_RUN([
879                         #include <pthread.h>
880                         __thread int i;
881                         static int res1, res2;
883                         void thread_main (void *arg)
884                         {
885                                 i = arg;
886                                 sleep (1);
887                                 if (arg == 1)
888                                         res1 = (i == arg);
889                                 else
890                                         res2 = (i == arg);
891                         }
893                         int main () {
894                                 pthread_t t1, t2;
896                                 i = 5;
898                                 pthread_create (&t1, NULL, thread_main, 1);
899                                 pthread_create (&t2, NULL, thread_main, 2);
901                                 pthread_join (t1, NULL);
902                                 pthread_join (t2, NULL);
904                                 return !(res1 + res2 == 2);
905                         }
906                 ], [
907                                 AC_MSG_RESULT(yes)
908                 ], [
909                                 AC_MSG_RESULT(no)
910                                 with_tls=pthread
911                 ])
912         fi
914         dnl **************************************
915         dnl *** Checks for working sigaltstack ***
916         dnl **************************************
917         AC_MSG_CHECKING(for working sigaltstack)
918         if test "x$with_sigaltstack" != "xyes"; then
919                 AC_MSG_RESULT(disabled)
920         else
921                 AC_TRY_RUN([
922                         #include <stdio.h>
923                         #include <stdlib.h>
924                         #include <unistd.h>
925                         #include <signal.h>
926                         #include <pthread.h>
927                         #include <sys/wait.h>
928                         #if defined(__FreeBSD__) || defined(__NetBSD__)
929                         #define SA_STACK SA_ONSTACK
930                         #endif
931                         static void
932                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
933                         {
934                                 exit (0);
935                         }
937                         static void *
938                         loop (void *ignored)
939                         {
940                                 char *ptr = NULL;
942                                 *ptr = 0;
943                                 return NULL;
944                         }
946                         static void
947                         child ()
948                         {
949                                 struct sigaction sa;
950                                 struct sigaltstack sas;
951                                 pthread_t id;
952                                 pthread_attr_t attr;
954                                 sa.sa_sigaction = sigsegv_signal_handler;
955                                 sigemptyset (&sa.sa_mask);
956                                 sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
957                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
958                                         perror ("sigaction");
959                                         return;
960                                 }
962                                 sas.ss_sp = malloc (SIGSTKSZ);
963                                 sas.ss_size = SIGSTKSZ;
964                                 sas.ss_flags = 0;
965                                 if (sigaltstack (&sas, NULL) == -1) {
966                                         perror ("sigaltstack");
967                                         return;
968                                 }
970                                 pthread_attr_init (&attr);
971                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
972                                         printf ("pthread_create\n");
973                                         return;
974                                 }
976                                 sleep (100);
977                         }
979                         int
980                         main ()
981                         {
982                                 pid_t son;
983                                 int status;
984                                 int i;
986                                 son = fork ();
987                                 if (son == -1) {
988                                         return 1;
989                                 }
991                                 if (son == 0) {
992                                         child ();
993                                         return 0;
994                                 }
996                                 for (i = 0; i < 3; ++i) {
997                                         sleep (1);
998                                         waitpid (son, &status, WNOHANG);
999                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
1000                                                 return 0;
1001                                 }
1003                                 kill (son, SIGKILL);
1004                                 return 1;
1005                         }
1007                 ], [
1008                                 AC_MSG_RESULT(yes)
1009                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
1010                 ], [
1011                                 with_sigaltstack=no
1012                                 AC_MSG_RESULT(no)
1013                 ])
1014         fi
1016         dnl ********************************
1017         dnl *** Checks for semaphore lib ***
1018         dnl ********************************
1019         # 'Real Time' functions on Solaris
1020         # posix4 on Solaris 2.6
1021         # pthread (first!) on Linux
1022         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
1024         dnl ********************************
1025         dnl *** Checks for timezone stuff **
1026         dnl ********************************
1027         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
1028                 AC_TRY_COMPILE([
1029                         #include <time.h>
1030                         ], [
1031                         struct tm tm;
1032                         tm.tm_gmtoff = 1;
1033                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
1034         if test $ac_cv_struct_tm_gmtoff = yes; then
1035                 AC_DEFINE(HAVE_TM_GMTOFF)
1036         else
1037                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
1038                         AC_TRY_COMPILE([
1039                                 #include <time.h>
1040                         ], [
1041                                 timezone = 1;
1042                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
1043                 if test $ac_cv_var_timezone = yes; then
1044                         AC_DEFINE(HAVE_TIMEZONE)
1045                 else
1046                         AC_ERROR(unable to find a way to determine timezone)
1047                 fi
1048         fi
1050         dnl *********************************
1051         dnl *** Checks for math functions ***
1052         dnl *********************************
1053         LIBS="$LIBS -lm";
1054         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
1055                 AC_TRY_LINK([#include <math.h>], 
1056                 [ finite(0.0); ], 
1057                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
1058                 AC_MSG_RESULT(no)))
1059         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
1060                 AC_TRY_LINK([#include <math.h>], 
1061                 [ isfinite(0.0); ], 
1062                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
1063                 AC_MSG_RESULT(no)))
1065         dnl ****************************************************************
1066         dnl *** Checks for working poll() (macosx defines it but doesn't ***
1067         dnl *** have it in the library (duh))                            ***
1068         dnl ****************************************************************
1069         AC_CHECK_FUNCS(poll)
1071         dnl *************************
1072         dnl *** Check for signbit ***
1073         dnl *************************
1074         AC_MSG_CHECKING(for signbit)
1075         AC_TRY_LINK([#include <math.h>], [
1076                 int s = signbit(1.0);
1077         ], [
1078                 AC_MSG_RESULT(yes)
1079                 AC_DEFINE(HAVE_SIGNBIT)
1080         ], [
1081                 AC_MSG_RESULT(no)
1082         ]) 
1084         dnl *********************
1085         dnl *** Check for AIO ***
1086         dnl *********************
1087         AC_MSG_CHECKING([for SIGEV_THREAD definition])
1088         dnl Some systems (FreeBSD at least) may have aio_read
1089         dnl but don't support/define SIGEV_THREAD.
1090         AC_TRY_COMPILE([
1091         #include <sys/signal.h>
1092         ],[
1093         int x = SIGEV_THREAD;
1094         ],[
1095                 ac_cv_c_sigev_thread=yes
1096                 AC_MSG_RESULT(yes)
1097         ],[
1098                 AC_MSG_RESULT(no)
1099         ])
1101         if test "$ac_cv_c_sigev_thread" = "yes" ; then
1102                 AC_CHECK_HEADERS(aio.h sys/aio.h)
1103                 AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
1104                 SIGVAL_PTR="undefined"
1105                 if test "$ac_cv_header_aio_h" = "yes" -o "$ac_cv_header_sys_aio_h" = "yes" ; then
1106                         AC_CHECK_MEMBER(union sigval.sigval_ptr,SIGVAL_PTR="sigval_ptr",, [
1107                                         #include <sys/signal.h>
1108                                         ])
1109                         AC_CHECK_MEMBER(union sigval.sival_ptr,SIGVAL_PTR="sival_ptr",, [
1110                                         #include <sys/signal.h>
1111                                         ])
1112                         if test "$SIGVAL_PTR" = "undefined" ; then
1113                                 AC_MSG_ERROR([Unable to detect field name in 'union sigval'])
1114                         fi
1115                 fi
1116                 AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
1117         fi
1119         dnl **********************************
1120         dnl *** epoll                      ***
1121         dnl **********************************
1122         AC_CHECK_HEADERS(sys/epoll.h)
1123         haveepoll=no
1124         AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
1125         if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes" ; then
1126                 AC_DEFINE(HAVE_EPOLL, 1, [epoll supported])
1127         fi
1129         dnl **********************************
1130         dnl *** Checks for MonoPosixHelper ***
1131         dnl **********************************
1132         AC_CHECK_HEADERS(checklist.h)
1133         AC_CHECK_HEADERS(fstab.h)
1134         AC_CHECK_HEADERS(sys/sendfile.h)
1135         AC_CHECK_HEADERS(sys/statvfs.h)
1136         AC_CHECK_HEADERS(sys/vfstab.h)
1137         AC_CHECK_HEADERS(sys/xattr.h)
1138         AC_CHECK_FUNCS(getdomainname)
1139         AC_CHECK_FUNCS(setdomainname)
1140         AC_CHECK_FUNCS(fgetgrent)
1141         AC_CHECK_FUNCS(fgetpwent)
1142         AC_CHECK_FUNCS(fgetpwent)
1143         AC_CHECK_FUNCS(getfsstat)
1144         AC_CHECK_FUNCS(posix_fadvise)
1145         AC_CHECK_FUNCS(posix_fallocate)
1146         AC_CHECK_FUNCS(posix_madvise)
1147         AC_CHECK_FUNCS(vsnprintf)
1148         AC_CHECK_FUNCS(sendfile)
1149         AC_CHECK_FUNCS(sethostid)
1150         AC_CHECK_FUNCS(statfs)
1151         AC_CHECK_FUNCS(fstatfs)
1152         AC_CHECK_FUNCS(statvfs)
1153         AC_CHECK_FUNCS(fstatvfs)
1154         AC_CHECK_FUNCS(stime)
1155         AC_CHECK_FUNCS(strerror_r)
1156         AC_CHECK_FUNCS(ttyname_r)
1157         AC_CHECK_SIZEOF(size_t)
1158         AC_CHECK_MEMBERS(
1159                 [struct dirent.d_off, struct dirent.d_reclen, struct dirent.d_type],,, 
1160                 [#include <sys/types.h>
1161                  #include <dirent.h>])
1163         dnl *********************************
1164         dnl *** Check for Console 2.0 I/O ***
1165         dnl *********************************
1166         AC_CHECK_HEADERS([curses.h])
1167         AC_CHECK_HEADERS([term.h], [], [],
1168         [#if HAVE_CURSES_H
1169          #include <curses.h>
1170          #endif
1171         ])
1172         AC_CHECK_HEADERS([termios.h])
1173 else
1174         jdk_headers_found=no
1175         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
1176         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
1177         AC_CHECK_LIB(ole32, main, LIBS="$LIBS -lole32", AC_ERROR(bad mingw install?))
1179         dnl *********************************
1180         dnl *** Check for struct ip_mreqn ***
1181         dnl *********************************
1182         AC_MSG_CHECKING(for struct ip_mreqn)
1183         AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1184                 struct ip_mreqn mreq;
1185                 mreq.imr_address.s_addr = 0;
1186         ], [
1187                 # Yes, we have it...
1188                 AC_MSG_RESULT(yes)
1189                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
1190         ], [
1191                 # We'll just have to try and use struct ip_mreq
1192                 AC_MSG_RESULT(no)
1193                 AC_MSG_CHECKING(for struct ip_mreq)
1194                 AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1195                         struct ip_mreq mreq;
1196                         mreq.imr_interface.s_addr = 0;
1197                 ], [
1198                         # Yes, we have it...
1199                         AC_MSG_RESULT(yes)
1200                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
1201                 ], [
1202                         # No multicast support
1203                         AC_MSG_RESULT(no)
1204                 ])
1205         ])
1208 dnl socklen_t check
1209 AC_MSG_CHECKING(for socklen_t)
1210 AC_TRY_COMPILE([
1211 #include <sys/types.h>
1212 #include <sys/socket.h>
1214   socklen_t foo;
1216 ac_cv_c_socklen_t=yes
1217         AC_DEFINE(HAVE_SOCKLEN_T)
1218         AC_MSG_RESULT(yes)
1220         AC_MSG_RESULT(no)
1223 AC_MSG_CHECKING(for array element initalizer support)
1224 AC_TRY_COMPILE([#include <sys/socket.h>], [
1225         const int array[] = {[1] = 2,};
1226 ], [
1227         # Yes, we have it...
1228         AC_MSG_RESULT(yes)
1229         AC_DEFINE(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
1230 ], [
1231         # We'll have to use signals
1232         AC_MSG_RESULT(no)
1235 AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
1236         # Simply calling trunc (0.0) is no good since gcc will optimize the call away
1237         AC_TRY_LINK([#include <math.h>], 
1238         [ static void *p = &trunc; ],
1239         [
1240                 AC_DEFINE(HAVE_TRUNC) 
1241                 AC_MSG_RESULT(yes)
1242                 ac_cv_trunc=yes
1243         ],
1244         AC_MSG_RESULT(no)))
1246 if test "x$ac_cv_truncl" != "xyes"; then
1247    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
1250 dnl ****************************
1251 dnl *** Look for /dev/random ***
1252 dnl ****************************
1254 AC_MSG_CHECKING([if usage of random device is requested])
1255 AC_ARG_ENABLE(dev-random,
1256 [  --disable-dev-random    disable the use of the random device],
1257 try_dev_random=$enableval, try_dev_random=yes)
1258 AC_MSG_RESULT($try_dev_random)
1260 case "{$target}" in
1261     *-openbsd*)
1262     NAME_DEV_RANDOM="/dev/srandom"
1263     ;;
1265 dnl Win32 does not have /dev/random, they have their own method...
1267     *-*-mingw*|*-*-cygwin*)
1268     ac_cv_have_dev_random=no
1269     ;;
1271 dnl Everywhere else, it's /dev/random
1273     *)
1274     NAME_DEV_RANDOM="/dev/random"
1275     ;;
1276 esac
1278 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
1280 dnl Now check if the device actually exists
1282 if test "x$try_dev_random" = "xyes"; then
1283     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1284     [if test -r "$NAME_DEV_RANDOM" ; then
1285         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1286     if test "x$ac_cv_have_dev_random" = "xyes"; then
1287         AC_DEFINE(HAVE_CRYPT_RNG)
1288     fi
1289 else
1290     AC_MSG_CHECKING(for random device)
1291     ac_cv_have_dev_random=no
1292     AC_MSG_RESULT(has been disabled)
1295 if test "x$platform_win32" = "xyes"; then
1296     AC_DEFINE(HAVE_CRYPT_RNG)
1299 if test "x$ac_cv_have_dev_random" = "xno" \
1300     && test "x$platform_win32" = "xno"; then
1301     AC_MSG_WARN([[
1303 *** A system-provided entropy source was not found on this system.
1304 *** Because of this, the System.Security.Cryptography random number generator
1305 *** will throw a NotImplemented exception.
1307 *** If you are seeing this message, and you know your system DOES have an
1308 *** entropy collection in place, please contact <crichton@gimp.org> and
1309 *** provide information about the system and how to access the random device.
1311 *** Otherwise you can install either egd or prngd and set the environment
1312 *** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
1313 ***]])
1316 AC_MSG_CHECKING([if inter-process shared handles are requested])
1317 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
1318 AC_MSG_RESULT($try_shared_handles)
1319 if test "x$try_shared_handles" != "xyes"; then
1320         AC_DEFINE(DISABLE_SHARED_HANDLES)
1321         AC_SUBST(DISABLE_SHARED_HANDLES)
1324 AC_ARG_ENABLE(nunit-tests, [ --enable-nunit-tests       Run the nunit tests of the class library on 'make check'])
1325 AM_CONDITIONAL(ENABLE_NUNIT_TESTS, [test x$enable_nunit_tests = xyes])
1327 TARGET="unknown"
1328 ACCESS_UNALIGNED="yes"
1330 JIT_SUPPORTED=no
1331 INTERP_SUPPORTED=no
1332 LIBC="libc.so.6"
1333 INTL="libc.so.6"
1335 jit_wanted=false
1336 interp_wanted=false
1337 case "$host" in
1338 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
1339 #               TARGET=MIPS;
1340 #               ACCESS_UNALIGNED="no"
1341 #               ;;
1342         i*86-*-*)
1343                 TARGET=X86;
1344                 arch_target=x86;
1345                 JIT_SUPPORTED=yes
1346                 jit_wanted=true
1347                 ;;
1348         x86_64-*-* | amd64-*-*)
1349                 TARGET=AMD64;
1350                 arch_target=amd64;
1351                 JIT_SUPPORTED=yes
1352                 jit_wanted=true
1353                 ;;
1354         sparc*-*-*)
1355                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
1356                    TARGET=SPARC64
1357                 else
1358                         TARGET=SPARC
1359                 fi
1360                 arch_target=sparc;
1361                 JIT_SUPPORTED=yes
1362                 ACCESS_UNALIGNED="no"
1363                 LIBC="libc.so"
1364                 INTL="libintl.so"
1365                 jit_wanted=true
1366                 if test x"$GCC" = xyes; then
1367                         CFLAGS="$CFLAGS -Wno-cast-align"
1368                 fi
1369                 ;;
1370        alpha*-*-linux* | alpha*-*-osf*)
1371                 TARGET=ALPHA;
1372                 ACCESS_UNALIGNED="no"
1373                 JIT_SUPPORTED=no
1374                 INTERP_SUPPORTED=yes
1375                 interp_wanted=true
1376                 arch_target=alpha;
1377                ;;
1378         *-*-mingw*|*-*-cygwin*)
1379                 INTL="intl"
1380                 ;;
1381 #       ia64-*-linux* | ia64-*-hpux*)
1382 #               TARGET=IA64;
1383 #               arch_target=ia64;
1384 #               JIT_SUPPORTED=no;
1385 #               ACCESS_UNALIGNED="no";
1386 #               case "$host_os" in
1387 #                       linux*) LIBC="libc.so.6.1";;
1388 #                       hpux*)  LIBC="libc.so.1";;
1389 #               esac
1390 #               ;;
1391 #       m68k-*-linux*)
1392 #               TARGET=M68K
1393 #               ;;
1394         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
1395                 TARGET=HPPA;
1396                 arch_target=hppa; 
1397                 LIBC="libc.sl"
1398                 ACCESS_UNALIGNED="no"
1399                 INTERP_SUPPORTED=yes
1400                 interp_wanted=true
1401                 ;;
1402         hppa*linux*)
1403                 TARGET=HPPA;
1404                 arch_target=hppa; 
1405                 ACCESS_UNALIGNED="no"
1406                 INTERP_SUPPORTED=yes
1407                 interp_wanted=true
1408                 ;;
1409         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
1410         powerpc-*-sysv* | powerpc-*-darwin*)
1411                 TARGET=POWERPC;
1412                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1413                 arch_target=ppc;
1414                 JIT_SUPPORTED=yes
1415                 jit_wanted=true
1416                 ;;
1417         arm-*-linux-* | armv4l-*-linux-*)
1418                 TARGET=ARM;
1419                 arch_target=arm;
1420                 ACCESS_UNALIGNED="no"
1421                 INTERP_SUPPORTED=yes
1422                 interp_wanted=true
1423                 ;;
1424         s390-*-linux*)
1425                 TARGET=S390;
1426                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1427                 arch_target=s390;
1428                 ACCESS_UNALIGNED="no"
1429                 JIT_SUPPORTED=yes
1430                 ;;
1431         s390x-*-linux*)
1432                 TARGET=S390x;
1433                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1434                 arch_target=s390x;
1435                 ACCESS_UNALIGNED="no"
1436                 JIT_SUPPORTED=yes
1437                 ;;
1438 esac
1440 AC_ARG_WITH(jit, [  --with-jit=yes,no       If you want to build scripts that default to the JIT],[
1441         if test x$withval = xyes; then
1442            jit_wanted=true
1443         else
1444            jit_wanted=false
1445         fi
1448 AC_ARG_WITH(interp, [  --with-interp=yes,no    If you want to build scripts that default to the interpreter],[
1449         if test x$withval = xyes; then
1450            interp_wanted=true
1451         else
1452            interp_wanted=false
1453         fi
1456 USEJIT=false
1457 if test x$JIT_SUPPORTED = xyes; then
1458    if $jit_wanted; then
1459       USEJIT=true
1460       jit_status="Building and using the JIT"
1461    else
1462       if $interp_wanted; then
1463          jit_status="Building the JIT, defaulting to the interpreter"
1464       else
1465          AC_ERROR(No JIT or interpreter support available or selected.)
1466       fi
1467    fi
1468 else
1469    if $interp_wanted; then
1470       jit_status="interpreter"
1471    else
1472       AC_ERROR(No JIT or interpreter support available or selected.)
1473    fi
1476 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
1478 libsuffix=".so"
1480 case "$host" in
1481      powerpc-*-darwin*)
1482         libsuffix=".dylib"
1483         LIBC="libc.dylib"
1484         INTL="libintl.dylib"
1485         ;;
1486      *-*-*netbsd*)
1487         LIBC="libc.so.12"
1488         INTL="libintl.so.0"
1489         ;;
1490     *-*-*freebsd*)
1491         LIBC="libc.so"
1492         INTL="libintl.so"
1493         ;;
1494     *-*-*openbsd*)
1495         LIBC="libc.so"
1496         INTL="libintl.so"
1497         ;;
1498 esac
1499 AC_SUBST(libsuffix)
1501 if test "x$TARGET" != "xAMD64"; then
1502    # valgrind headers don't compile under x86-64
1503    AC_CHECK_HEADERS(valgrind/memcheck.h)
1506 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
1507         if test "x$with_tls" = "x__thread"; then
1508                 #
1509                 # On some linux distributions, TLS works in executables, but linking 
1510                 # against a shared library containing TLS fails with:
1511                 # undefined reference to `__tls_get_addr'
1512                 #
1513                 rm -f conftest.c conftest.so conftest
1514                 echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
1515                 gcc -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
1516                 gcc -o conftest conftest.so > /dev/null 2>&1
1517                 if test ! -f conftest; then
1518                    AC_MSG_WARN([Disabling usage of __thread.]);
1519                    with_tls=pthread
1520                 fi
1521                 rm -f conftest.c conftest.so conftest
1522         fi
1525 if test "x$with_tls" = "x__thread"; then
1526         AC_DEFINE(HAVE_KW_THREAD)
1527    # Pass the information to libgc
1528         CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
1529         export CPPFLAGS
1530         AC_MSG_CHECKING(if the tls_model attribute is supported)
1531         AC_TRY_COMPILE([static __thread int foo __attribute__((tls_model("initial-exec")));], [
1532                 ], [
1533                         AC_MSG_RESULT(yes)
1534                         AC_DEFINE(HAVE_TLS_MODEL_ATTR, 1, [tld_model available])
1535                 ], [
1536                         AC_MSG_RESULT(no)
1537         ])
1540 if test ${TARGET} = ARM; then
1541         dnl ******************************************
1542         dnl *** Check to see what FPU is available ***
1543         dnl ******************************************
1544         AC_MSG_CHECKING(which FPU to use)
1546         AC_TRY_COMPILE([], [
1547                 __asm__ ("ldfd f0, [r0]");
1548                 ], fpu=FPA, [
1549                         AC_TRY_COMPILE([], [
1550                                 __asm__ ("fldd d0, [r0]");
1551                         ], fpu=VFP, fpu=NONE)
1552                 ])
1554         AC_MSG_RESULT($fpu)
1555         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
1556         unset fpu
1559 if test ${TARGET} = unknown; then
1560         CPPFLAGS="$CPPFLAGS -DNO_PORT"
1561         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
1564 if test ${ACCESS_UNALIGNED} = no; then
1565         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
1568 PREVIEW=yes
1569 AC_ARG_WITH(preview, [ --with-preview=yes,no     If you want to install the 2.0 FX preview],[
1570         if test x$with_preview = xno; then
1571               PREVIEW=no
1572         fi
1575 AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
1577 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
1578 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
1579 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
1580 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
1581 AM_CONDITIONAL(X86, test x$TARGET = xX86)
1582 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
1583 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
1584 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
1585 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
1586 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
1587 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
1588 AM_CONDITIONAL(S390, test x$TARGET = xS390)
1589 AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
1590 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
1592 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
1593 AM_CONDITIONAL(INTERP_SUPPORTED, test x$interp_wanted = xtrue)
1594 AM_CONDITIONAL(INCLUDED_LIBGC, test x$gc = xincluded)
1596 AC_SUBST(LIBC)
1597 AC_SUBST(INTL)
1599 AC_SUBST(arch_target)
1600 AC_SUBST(CFLAGS)
1601 AC_SUBST(CPPFLAGS)
1602 AC_SUBST(LDFLAGS)
1604 mono_build_root=`pwd`
1605 AC_SUBST(mono_build_root)
1607 if test x$USEJIT = xtrue; then
1608   mono_runtime=mono/mini/mono
1609 else
1610   mono_runtime=mono/interpreter/mint
1612 AC_SUBST(mono_runtime)
1614 mono_cfg_root=$mono_build_root/runtime
1615 if test x$platform_win32 = xyes; then
1616   mono_cfg_dir=`cygpath -w -a $mono_cfg_root`\\etc
1617 else
1618   mono_cfg_dir=$mono_cfg_root/etc
1620 AC_SUBST(mono_cfg_dir)
1622 AC_CONFIG_FILES([runtime/mono-wrapper],[chmod +x runtime/mono-wrapper])
1623 AC_CONFIG_FILES([runtime/monodis-wrapper],[chmod +x runtime/monodis-wrapper])
1625 AC_CONFIG_COMMANDS([runtime/etc/mono/1.0/machine.config],
1626 [   depth=../../../..
1627     case $srcdir in
1628     [\\/$]* | ?:[\\/]* ) reldir=$srcdir ;;
1629     .) reldir=$depth ;;
1630     *) reldir=$depth/$srcdir ;;
1631     esac
1632     $ac_aux_dir/install-sh -d runtime/etc/mono/1.0
1633     cd runtime/etc/mono/1.0
1634     rm -f machine.config
1635     $LN_S $reldir/data/net_1_1/machine.config machine.config
1636     cd $depth
1637 ],[LN_S='$LN_S'])
1639 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/machine.config],
1640 [   depth=../../../..
1641     case $srcdir in
1642     [\\/$]* | ?:[\\/]* ) reldir=$srcdir ;;
1643     .) reldir=$depth ;;
1644     *) reldir=$depth/$srcdir ;;
1645     esac
1646     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
1647     cd runtime/etc/mono/2.0
1648     rm -f machine.config
1649     $LN_S $reldir/data/net_2_0/machine.config machine.config
1650     cd $depth
1651 ],[LN_S='$LN_S'])
1653 AC_OUTPUT([
1654 Makefile
1655 mint.pc
1656 mono.pc
1657 scripts/mono-nunit.pc
1658 mono/Makefile
1659 mono/utils/Makefile
1660 mono/metadata/Makefile
1661 mono/dis/Makefile
1662 mono/cil/Makefile
1663 mono/arch/Makefile
1664 mono/os/Makefile
1665 mono/os/win32/Makefile
1666 mono/os/unix/Makefile
1667 mono/arch/x86/Makefile
1668 mono/arch/amd64/Makefile
1669 mono/arch/hppa/Makefile
1670 mono/arch/ppc/Makefile
1671 mono/arch/sparc/Makefile
1672 mono/arch/s390/Makefile
1673 mono/arch/s390x/Makefile
1674 mono/arch/arm/Makefile
1675 mono/arch/alpha/Makefile
1676 mono/interpreter/Makefile
1677 mono/tests/Makefile
1678 mono/tests/tests-config
1679 mono/benchmark/Makefile
1680 mono/monoburg/Makefile
1681 mono/monograph/Makefile
1682 mono/io-layer/Makefile
1683 mono/mini/Makefile
1684 mono/handles/Makefile
1685 mono/profiler/Makefile
1686 ikvm-native/Makefile
1687 scripts/Makefile
1688 man/Makefile
1689 web/Makefile
1690 docs/Makefile
1691 data/Makefile
1692 data/net_1_1/Makefile
1693 data/net_2_0/Makefile
1694 samples/Makefile
1695 support/Makefile
1696 data/config
1697 mono.spec
1698 tools/Makefile
1699 tools/locale-builder/Makefile
1700 runtime/Makefile
1704   case $prefix in
1705   NONE) prefix=$ac_default_prefix ;;
1706   esac
1707   case $exec_prefix in
1708   NONE) exec_prefix='${prefix}' ;;
1709   esac
1711   test -w $srcdir/$mcsdir/build || chmod +w $srcdir/$mcsdir/build
1713   echo "prefix=$prefix" > $srcdir/$mcsdir/build/config.make
1714   echo "exec_prefix=$exec_prefix" >> $srcdir/$mcsdir/build/config.make
1715   echo 'mono_libdir=${exec_prefix}/lib' >> $srcdir/$mcsdir/build/config.make
1716   echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $srcdir/$mcsdir/build/config.make
1717   echo 'IL_FLAGS = /debug' >> $srcdir/$mcsdir/build/config.make
1718   echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $srcdir/$mcsdir/build/config.make
1719   echo "ILDISASM = $mono_build_root/runtime/monodis-wrapper" >> $srcdir/$mcsdir/build/config.make
1720   echo "INSTALL = $INSTALL" >> $srcdir/$mcsdir/build/config.make
1723 libgdiplus_msg=${libgdiplus_loc:-assumed to be installed}
1725 echo "
1726         mcs source:  $mcs_topdir
1727         GC:          $gc
1728         Globalization:     $enable_glob
1729         TLS:         $with_tls
1730         SIGALTSTACK: $with_sigaltstack
1731         Engine:      $jit_status
1732         2.0 Alpha:   $PREVIEW
1733         JNI support: $jdk_headers_found
1734         libgdiplus:  $libgdiplus_msg
1735         $disabled