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