merging the Mainsoft branch to the trunk
[mono.git] / configure.in
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
3
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])])
7
8 AM_CONFIG_HEADER(config.h)
9 AM_INIT_AUTOMAKE(mono,1.1.7.99)
10 AM_MAINTAINER_MODE
11
12 AC_PROG_LN_S
13
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
19
20
21 dnl
22 dnl libgc checks
23 dnl
24
25 gc_headers=no
26 gc=included
27 use_included_gc=no
28
29 if test -d $srcdir/libgc ; then
30   gc_default=included
31 else
32   gc_default=boehm
33 fi
34
35 #
36 # These are the flags that need to be stored in the mono.pc file for 
37 # compiling code that will embed Mono
38 #
39 libmono_cflags=""
40 libmono_ldflags=""
41 AC_SUBST(libmono_cflags)
42 AC_SUBST(libmono_ldflags)
43
44 dnl if linker handles the version script
45 no_version_script=no
46
47 # Set to yes if Unix sockets cannot be created in an anonymous namespace
48 need_link_unlink=no
49
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
82 #
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)
130 #
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)
156 #
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)
215
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])
218 fi
219
220 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
221
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)
232
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])
237 fi
238
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=""
247 fi
248 AC_SUBST(CC_FOR_BUILD)
249 AC_SUBST(HOST_CC)
250 AC_SUBST(BUILD_EXEEXT)
251
252 # Set STDC_HEADERS
253 AC_HEADER_STDC
254 AC_LIBTOOL_WIN32_DLL
255 AC_DISABLE_FAST_INSTALL
256 AM_PROG_LIBTOOL
257
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
263 fi
264
265 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
266
267 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h linux/rtc.h)
268
269 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
270
271 AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
272
273 # for mono/metadata/debug-symfile.c
274 AC_CHECK_HEADERS(elf.h)
275
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)
282
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)
305 ])
306
307
308 # not 64 bit clean in cross-compile
309 AC_CHECK_SIZEOF(void *, 4)
310
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"
316
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
336 fi
337 CFLAGS="$CFLAGS -g $WARN"
338
339 # Where's the 'mcs' source tree?
340 if test -d $srcdir/mcs; then
341   mcsdir=mcs
342 else
343   mcsdir=../mcs
344 fi
345
346 mcs_topdir='$(top_srcdir)/'$mcsdir
347 mcs_topdir_from_srcdir='$(top_builddir)/'$mcsdir
348
349 AC_SUBST([mcs_topdir])
350 AC_SUBST([mcs_topdir_from_srcdir])
351
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])
355
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])
363
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])
367 fi
368
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)
375
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
387 )
388
389 ## Versions of dependencies
390 GLIB_REQUIRED_VERSION=1.3.11
391
392 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
393
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`
398
399 AC_SUBST(GLIB_CFLAGS)
400 AC_SUBST(GLIB_LIBS)
401 AC_SUBST(GMODULE_CFLAGS)
402 AC_SUBST(GMODULE_LIBS)
403
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
412
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)
423 fi
424
425 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
426
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])
430
431 # Kept for compatibility
432 AC_ARG_WITH(nptl, [  --with-nptl=yes,no      deprecated, use --with-tls instead],[],[with_nptl=default])
433
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
443 fi
444
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])
448
449 AC_ARG_WITH(static_mono, [  --with-static_mono=yes,no      link mono statically to libmono (faster)],[],[with_static_mono=yes])
450
451 if test "x$enable_static" = "xno"; then
452    with_static_mono=no
453 fi
454
455 AM_CONDITIONAL(STATIC_MONO, test x$with_static_mono != xno)
456
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.],
459 [
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 ],[])
466
467 if test "x$mono_feature_disable_aot" = "xyes"; then
468         AC_DEFINE(DISABLE_AOT, 1, [Disable AOT support])
469 fi
470
471 if test "x$mono_feature_disable_profiler" = "xyes"; then
472         AC_DEFINE(DISABLE_PROFILER, 1, [Disable default profiler support])
473 fi
474
475 if test "x$mono_feature_disable_decimal" = "xyes"; then
476         AC_DEFINE(DISABLE_DECIMAL, 1, [Disable System.Decimal support])
477 fi
478
479 if test "x$mono_feature_disable_pinvoke" = "xyes"; then
480         AC_DEFINE(DISABLE_PINVOKE, 1, [Disable P/Invoke support])
481 fi
482
483 if test "x$mono_feature_disable_debug" = "xyes"; then
484         AC_DEFINE(DISABLE_DEBUG, 1, [Disable runtime debugging support])
485 fi
486
487 if test "x$mono_feature_disable_reflection_emit" = "xyes"; then
488         AC_DEFINE(DISABLE_REFLECTION_EMIT, 1, [Disable reflection emit support])
489 fi
490
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)
499
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
506
507                 AC_DEFINE(HAVE_BOEHM_GC)
508                 AC_SUBST(HAVE_BOEHM_GC)
509                 LIBGC_LIBS="-lgc $libdl"
510                 LIBGC_STATIC_LIBS="$LIBGC_LIBS"
511
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                 ;;
522
523         xincluded)
524                 AC_CONFIG_SUBDIRS(libgc)
525
526                 found_boehm=yes
527                 gc_headers=yes
528                 use_included_gc=yes
529                 libgc_dir=libgc
530
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'
534
535                 AC_DEFINE(HAVE_BOEHM_GC)
536                 AC_SUBST(HAVE_BOEHM_GC)
537
538                 AC_DEFINE(HAVE_GC_H)
539                 AC_DEFINE(USE_INCLUDED_LIBGC)
540
541                 # The included libgc contains GCJ support
542                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
543                 AC_DEFINE(HAVE_GC_ENABLE)
544                 ;;
545
546         xnone)
547                 AC_MSG_WARN("Compiling mono without GC.")
548                 ;;
549         *)
550                 AC_MSG_ERROR([Invalid argument to --with-gc.])
551                 ;;
552 esac
553
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"
558 fi
559
560 # tell libgc/configure about what we want
561 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
562
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)
568
569 dnl
570 dnl End of libgc checks
571 dnl
572
573 if test x$platform_win32 = xno; then
574
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])
579
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
585
586         AC_SUBST(ikvm_native_dir)
587
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)
596
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>
611
612                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
613
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         ])
633
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")
648
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         ])
663
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         ])
678
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         ])
693
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         ])
708
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         ])
722
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         ])
764
765         dnl *****************************
766         dnl *** Checks for libnsl     ***
767         dnl *****************************
768         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
769
770         AC_CHECK_FUNCS(inet_pton inet_aton)
771
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>
782
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)
795
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         ])
812
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
828
829                         if test "$GCC" = "yes"; then
830                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
831                         fi
832                 ;;
833         esac
834
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
840 #
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)
870
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;
882
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                         }
892
893                         int main () {
894                                 pthread_t t1, t2;
895
896                                 i = 5;
897
898                                 pthread_create (&t1, NULL, thread_main, 1);
899                                 pthread_create (&t2, NULL, thread_main, 2);
900
901                                 pthread_join (t1, NULL);
902                                 pthread_join (t2, NULL);
903
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
913
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                         }
936
937                         static void *
938                         loop (void *ignored)
939                         {
940                                 char *ptr = NULL;
941
942                                 *ptr = 0;
943                                 return NULL;
944                         }
945
946                         static void
947                         child ()
948                         {
949                                 struct sigaction sa;
950                                 struct sigaltstack sas;
951                                 pthread_t id;
952                                 pthread_attr_t attr;
953
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                                 }
961
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                                 }
969
970                                 pthread_attr_init (&attr);
971                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
972                                         printf ("pthread_create\n");
973                                         return;
974                                 }
975
976                                 sleep (100);
977                         }
978
979                         int
980                         main ()
981                         {
982                                 pid_t son;
983                                 int status;
984                                 int i;
985
986                                 son = fork ();
987                                 if (son == -1) {
988                                         return 1;
989                                 }
990
991                                 if (son == 0) {
992                                         child ();
993                                         return 0;
994                                 }
995
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                                 }
1002
1003                                 kill (son, SIGKILL);
1004                                 return 1;
1005                         }
1006
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
1015
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) 
1023
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
1049
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)))
1064
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)
1070
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         ]) 
1083
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         ])
1100
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
1118
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
1128
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>])
1162
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?))
1178
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         ])
1206 fi
1207
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>
1213 ],[
1214   socklen_t foo;
1215 ],[
1216 ac_cv_c_socklen_t=yes
1217         AC_DEFINE(HAVE_SOCKLEN_T)
1218         AC_MSG_RESULT(yes)
1219 ],[
1220         AC_MSG_RESULT(no)
1221 ])
1222
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)
1233 ])
1234
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)))
1245
1246 if test "x$ac_cv_truncl" != "xyes"; then
1247    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
1248 fi
1249
1250 dnl ****************************
1251 dnl *** Look for /dev/random ***
1252 dnl ****************************
1253
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)
1259
1260 case "{$target}" in
1261     *-openbsd*)
1262     NAME_DEV_RANDOM="/dev/srandom"
1263     ;;
1264
1265 dnl Win32 does not have /dev/random, they have their own method...
1266
1267     *-*-mingw*|*-*-cygwin*)
1268     ac_cv_have_dev_random=no
1269     ;;
1270
1271 dnl Everywhere else, it's /dev/random
1272
1273     *)
1274     NAME_DEV_RANDOM="/dev/random"
1275     ;;
1276 esac
1277
1278 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
1279
1280 dnl Now check if the device actually exists
1281
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)
1293 fi
1294
1295 if test "x$platform_win32" = "xyes"; then
1296     AC_DEFINE(HAVE_CRYPT_RNG)
1297 fi
1298
1299 if test "x$ac_cv_have_dev_random" = "xno" \
1300     && test "x$platform_win32" = "xno"; then
1301     AC_MSG_WARN([[
1302 ***
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.
1306 ***
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.
1310 ***
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 ***]])
1314 fi
1315  
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)
1322 fi
1323
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])
1326
1327 TARGET="unknown"
1328 ACCESS_UNALIGNED="yes"
1329
1330 JIT_SUPPORTED=no
1331 INTERP_SUPPORTED=no
1332 LIBC="libc.so.6"
1333 INTL="libc.so.6"
1334
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                 case $host_os in
1364                   linux*) ;;
1365                   *)
1366                         LIBC="libc.so"
1367                         INTL="libintl.so"
1368                 esac
1369                 jit_wanted=true
1370                 if test x"$GCC" = xyes; then
1371                         CFLAGS="$CFLAGS -Wno-cast-align"
1372                 fi
1373                 ;;
1374        alpha*-*-linux* | alpha*-*-osf*)
1375                 TARGET=ALPHA;
1376                 ACCESS_UNALIGNED="no"
1377                 JIT_SUPPORTED=no
1378                 INTERP_SUPPORTED=yes
1379                 interp_wanted=true
1380                 arch_target=alpha;
1381                 case $host_os in
1382                   linux*)
1383                         LIBC="libc.so.6.1"
1384                         INTL="libc.so.6.1"
1385                 esac
1386                ;;
1387         *-*-mingw*|*-*-cygwin*)
1388                 INTL="intl"
1389                 ;;
1390 #       ia64-*-linux* | ia64-*-hpux*)
1391 #               TARGET=IA64;
1392 #               arch_target=ia64;
1393 #               JIT_SUPPORTED=no;
1394 #               ACCESS_UNALIGNED="no";
1395 #               case "$host_os" in
1396 #                       linux*) LIBC="libc.so.6.1";;
1397 #                       hpux*)  LIBC="libc.so.1";;
1398 #               esac
1399 #               ;;
1400 #       m68k-*-linux*)
1401 #               TARGET=M68K
1402 #               ;;
1403         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
1404                 TARGET=HPPA;
1405                 arch_target=hppa; 
1406                 LIBC="libc.sl"
1407                 ACCESS_UNALIGNED="no"
1408                 INTERP_SUPPORTED=yes
1409                 interp_wanted=true
1410                 ;;
1411         hppa*linux*)
1412                 TARGET=HPPA;
1413                 arch_target=hppa; 
1414                 ACCESS_UNALIGNED="no"
1415                 INTERP_SUPPORTED=yes
1416                 interp_wanted=true
1417                 ;;
1418         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
1419         powerpc-*-sysv* | powerpc-*-darwin*)
1420                 TARGET=POWERPC;
1421                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1422                 arch_target=ppc;
1423                 JIT_SUPPORTED=yes
1424                 jit_wanted=true
1425                 ;;
1426         arm-*-linux-* | armv4l-*-linux-*)
1427                 TARGET=ARM;
1428                 arch_target=arm;
1429                 ACCESS_UNALIGNED="no"
1430                 INTERP_SUPPORTED=yes
1431                 interp_wanted=true
1432                 ;;
1433         s390-*-linux*)
1434                 TARGET=S390;
1435                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1436                 arch_target=s390;
1437                 ACCESS_UNALIGNED="no"
1438                 JIT_SUPPORTED=yes
1439                 ;;
1440         s390x-*-linux*)
1441                 TARGET=S390x;
1442                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1443                 arch_target=s390x;
1444                 ACCESS_UNALIGNED="no"
1445                 JIT_SUPPORTED=yes
1446                 ;;
1447 esac
1448
1449 AC_ARG_WITH(jit, [  --with-jit=yes,no       If you want to build scripts that default to the JIT],[
1450         if test x$withval = xyes; then
1451            jit_wanted=true
1452         else
1453            jit_wanted=false
1454         fi
1455 ])
1456
1457 AC_ARG_WITH(interp, [  --with-interp=yes,no    If you want to build scripts that default to the interpreter],[
1458         if test x$withval = xyes; then
1459            interp_wanted=true
1460         else
1461            interp_wanted=false
1462         fi
1463 ])
1464
1465 USEJIT=false
1466 if test x$JIT_SUPPORTED = xyes; then
1467    if $jit_wanted; then
1468       USEJIT=true
1469       jit_status="Building and using the JIT"
1470    else
1471       if $interp_wanted; then
1472          jit_status="Building the JIT, defaulting to the interpreter"
1473       else
1474          AC_ERROR(No JIT or interpreter support available or selected.)
1475       fi
1476    fi
1477 else
1478    if $interp_wanted; then
1479       jit_status="interpreter"
1480    else
1481       AC_ERROR(No JIT or interpreter support available or selected.)
1482    fi
1483 fi
1484
1485 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
1486
1487 libsuffix=".so"
1488
1489 case "$host" in
1490      powerpc-*-darwin*)
1491         libsuffix=".dylib"
1492         LIBC="libc.dylib"
1493         INTL="libintl.dylib"
1494         ;;
1495      *-*-*netbsd*)
1496         LIBC="libc.so.12"
1497         INTL="libintl.so.0"
1498         ;;
1499     *-*-*freebsd*)
1500         LIBC="libc.so"
1501         INTL="libintl.so"
1502         ;;
1503     *-*-*openbsd*)
1504         LIBC="libc.so"
1505         INTL="libintl.so"
1506         ;;
1507 esac
1508 AC_SUBST(libsuffix)
1509
1510 if test "x$TARGET" != "xAMD64"; then
1511    # valgrind headers don't compile under x86-64
1512    AC_CHECK_HEADERS(valgrind/memcheck.h)
1513 fi
1514
1515 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
1516         if test "x$with_tls" = "x__thread"; then
1517                 #
1518                 # On some linux distributions, TLS works in executables, but linking 
1519                 # against a shared library containing TLS fails with:
1520                 # undefined reference to `__tls_get_addr'
1521                 #
1522                 rm -f conftest.c conftest.so conftest
1523                 echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
1524                 gcc -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
1525                 gcc -o conftest conftest.so > /dev/null 2>&1
1526                 if test ! -f conftest; then
1527                    AC_MSG_WARN([Disabling usage of __thread.]);
1528                    with_tls=pthread
1529                 fi
1530                 rm -f conftest.c conftest.so conftest
1531         fi
1532 fi
1533
1534 if test "x$with_tls" = "x__thread"; then
1535         AC_DEFINE(HAVE_KW_THREAD)
1536    # Pass the information to libgc
1537         CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
1538         export CPPFLAGS
1539         AC_MSG_CHECKING(if the tls_model attribute is supported)
1540         AC_TRY_COMPILE([static __thread int foo __attribute__((tls_model("initial-exec")));], [
1541                 ], [
1542                         AC_MSG_RESULT(yes)
1543                         AC_DEFINE(HAVE_TLS_MODEL_ATTR, 1, [tld_model available])
1544                 ], [
1545                         AC_MSG_RESULT(no)
1546         ])
1547 fi
1548
1549 if test ${TARGET} = ARM; then
1550         dnl ******************************************
1551         dnl *** Check to see what FPU is available ***
1552         dnl ******************************************
1553         AC_MSG_CHECKING(which FPU to use)
1554
1555         AC_TRY_COMPILE([], [
1556                 __asm__ ("ldfd f0, [r0]");
1557                 ], fpu=FPA, [
1558                         AC_TRY_COMPILE([], [
1559                                 __asm__ ("fldd d0, [r0]");
1560                         ], fpu=VFP, fpu=NONE)
1561                 ])
1562
1563         AC_MSG_RESULT($fpu)
1564         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
1565         unset fpu
1566 fi
1567
1568 if test ${TARGET} = unknown; then
1569         CPPFLAGS="$CPPFLAGS -DNO_PORT"
1570         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
1571 fi
1572
1573 if test ${ACCESS_UNALIGNED} = no; then
1574         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
1575 fi
1576
1577 PREVIEW=yes
1578 AC_ARG_WITH(preview, [ --with-preview=yes,no     If you want to install the 2.0 FX preview],[
1579         if test x$with_preview = xno; then
1580               PREVIEW=no
1581         fi
1582 ])
1583
1584 AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
1585
1586 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
1587 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
1588 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
1589 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
1590 AM_CONDITIONAL(X86, test x$TARGET = xX86)
1591 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
1592 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
1593 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
1594 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
1595 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
1596 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
1597 AM_CONDITIONAL(S390, test x$TARGET = xS390)
1598 AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
1599 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
1600
1601 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
1602 AM_CONDITIONAL(INTERP_SUPPORTED, test x$interp_wanted = xtrue)
1603 AM_CONDITIONAL(INCLUDED_LIBGC, test x$gc = xincluded)
1604
1605 AC_SUBST(LIBC)
1606 AC_SUBST(INTL)
1607
1608 AC_SUBST(arch_target)
1609 AC_SUBST(CFLAGS)
1610 AC_SUBST(CPPFLAGS)
1611 AC_SUBST(LDFLAGS)
1612
1613 mono_build_root=`pwd`
1614 AC_SUBST(mono_build_root)
1615
1616 if test x$USEJIT = xtrue; then
1617   mono_runtime=mono/mini/mono
1618 else
1619   mono_runtime=mono/interpreter/mint
1620 fi
1621 AC_SUBST(mono_runtime)
1622
1623 mono_cfg_root=$mono_build_root/runtime
1624 if test x$platform_win32 = xyes; then
1625   mono_cfg_dir=`cygpath -w -a $mono_cfg_root`\\etc
1626 else
1627   mono_cfg_dir=$mono_cfg_root/etc
1628 fi
1629 AC_SUBST(mono_cfg_dir)
1630
1631 AC_CONFIG_FILES([runtime/mono-wrapper],[chmod +x runtime/mono-wrapper])
1632 AC_CONFIG_FILES([runtime/monodis-wrapper],[chmod +x runtime/monodis-wrapper])
1633
1634 AC_CONFIG_COMMANDS([runtime/etc/mono/1.0/machine.config],
1635 [   depth=../../../..
1636     case $srcdir in
1637     [\\/$]* | ?:[\\/]* ) reldir=$srcdir ;;
1638     .) reldir=$depth ;;
1639     *) reldir=$depth/$srcdir ;;
1640     esac
1641     $ac_aux_dir/install-sh -d runtime/etc/mono/1.0
1642     cd runtime/etc/mono/1.0
1643     rm -f machine.config
1644     $LN_S $reldir/data/net_1_1/machine.config machine.config
1645     cd $depth
1646 ],[LN_S='$LN_S'])
1647
1648 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/machine.config],
1649 [   depth=../../../..
1650     case $srcdir in
1651     [\\/$]* | ?:[\\/]* ) reldir=$srcdir ;;
1652     .) reldir=$depth ;;
1653     *) reldir=$depth/$srcdir ;;
1654     esac
1655     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
1656     cd runtime/etc/mono/2.0
1657     rm -f machine.config
1658     $LN_S $reldir/data/net_2_0/machine.config machine.config
1659     cd $depth
1660 ],[LN_S='$LN_S'])
1661
1662 AC_OUTPUT([
1663 Makefile
1664 mint.pc
1665 mono.pc
1666 scripts/mono-nunit.pc
1667 mono/Makefile
1668 mono/utils/Makefile
1669 mono/metadata/Makefile
1670 mono/dis/Makefile
1671 mono/cil/Makefile
1672 mono/arch/Makefile
1673 mono/os/Makefile
1674 mono/os/win32/Makefile
1675 mono/os/unix/Makefile
1676 mono/arch/x86/Makefile
1677 mono/arch/amd64/Makefile
1678 mono/arch/hppa/Makefile
1679 mono/arch/ppc/Makefile
1680 mono/arch/sparc/Makefile
1681 mono/arch/s390/Makefile
1682 mono/arch/s390x/Makefile
1683 mono/arch/arm/Makefile
1684 mono/arch/alpha/Makefile
1685 mono/interpreter/Makefile
1686 mono/tests/Makefile
1687 mono/tests/tests-config
1688 mono/benchmark/Makefile
1689 mono/monoburg/Makefile
1690 mono/monograph/Makefile
1691 mono/io-layer/Makefile
1692 mono/mini/Makefile
1693 mono/handles/Makefile
1694 mono/profiler/Makefile
1695 ikvm-native/Makefile
1696 scripts/Makefile
1697 man/Makefile
1698 web/Makefile
1699 docs/Makefile
1700 data/Makefile
1701 data/net_1_1/Makefile
1702 data/net_2_0/Makefile
1703 samples/Makefile
1704 support/Makefile
1705 data/config
1706 mono.spec
1707 tools/Makefile
1708 tools/locale-builder/Makefile
1709 runtime/Makefile
1710 ])
1711
1712 (
1713   case $prefix in
1714   NONE) prefix=$ac_default_prefix ;;
1715   esac
1716   case $exec_prefix in
1717   NONE) exec_prefix='${prefix}' ;;
1718   esac
1719
1720   test -w $srcdir/$mcsdir/build || chmod +w $srcdir/$mcsdir/build
1721
1722   echo "prefix=$prefix" > $srcdir/$mcsdir/build/config.make
1723   echo "exec_prefix=$exec_prefix" >> $srcdir/$mcsdir/build/config.make
1724   echo 'mono_libdir=${exec_prefix}/lib' >> $srcdir/$mcsdir/build/config.make
1725   echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $srcdir/$mcsdir/build/config.make
1726   echo 'IL_FLAGS = /debug' >> $srcdir/$mcsdir/build/config.make
1727   echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $srcdir/$mcsdir/build/config.make
1728   echo "ILDISASM = $mono_build_root/runtime/monodis-wrapper" >> $srcdir/$mcsdir/build/config.make
1729   echo "INSTALL = $INSTALL" >> $srcdir/$mcsdir/build/config.make
1730 )
1731
1732 libgdiplus_msg=${libgdiplus_loc:-assumed to be installed}
1733
1734 echo "
1735         mcs source:  $mcs_topdir
1736         GC:          $gc
1737         Globalization:     $enable_glob
1738         TLS:         $with_tls
1739         SIGALTSTACK: $with_sigaltstack
1740         Engine:      $jit_status
1741         2.0 Alpha:   $PREVIEW
1742         JNI support: $jdk_headers_found
1743         libgdiplus:  $libgdiplus_msg
1744         $disabled
1745
1746 "