2005-01-03 Ben Maurer <bmaurer@ximian.com>
[mono-project.git] / configure.in
blob81659ea9362f2df447b2882fbdeff63279bbaebe
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
4 # Gross hack to enable 'make dist' on automake 1.9+tar 1.14.
5 # The extra brackets are to foil regex-based scans.
6 m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
8 AM_CONFIG_HEADER(config.h)
9 AM_INIT_AUTOMAKE(mono,1.1.3)
10 AM_MAINTAINER_MODE
12 AC_PROG_LN_S
14 # In case of cygwin, override LN_S, irrespective of what it determines.
15 # The build uses cygwin, but the actual runtime doesn't.
16 case $host_os in
17 *cygwin* ) LN_S='cp -p';;
18 esac
21 dnl
22 dnl libgc checks
23 dnl
25 gc_headers=no
26 gc=included
27 use_included_gc=no
29 if test -d $srcdir/libgc ; then
30   gc_default=included
31 else
32   gc_default=boehm
36 # These are the flags that need to be stored in the mono.pc file for 
37 # compiling code that will embed Mono
39 libmono_cflags=""
40 libmono_ldflags=""
41 AC_SUBST(libmono_cflags)
42 AC_SUBST(libmono_ldflags)
44 dnl if linker handles the version script
45 no_version_script=no
47 # Set to yes if Unix sockets cannot be created in an anonymous namespace
48 need_link_unlink=no
50 # Thread configuration inspired by sleepycat's db
51 AC_MSG_CHECKING([host platform characteristics])
52 libgc_threads=no
53 case "$host" in
54         *-*-mingw*|*-*-cygwin*)
55                 platform_win32=yes
56                 AC_DEFINE(PLATFORM_WIN32,1,[Platform is Win32])
57                 CC="gcc -mno-cygwin -g"
58                 HOST_CC="gcc"
59                 # So libgc configure gets -mno-cygwin
60                 export CC
61 # latest libgc already defines GC_WIN32_THREADS
62 #               CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS -DWIN32_THREADS"
63                 CPPFLAGS="$CPPFLAGS -DWIN32_THREADS"
64                 libdl=
65                 libgc_threads=win32
66                 gc_default=included
67                 with_nptl=default
68                 with_sigaltstack=no
69                 LN_S=cp
70                 ;;
71         *-*-*netbsd*)
72                 platform_win32=no
73                 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
74                 libmono_cflags="-D_REENTRANT"
75                 LDFLAGS="$LDFLAGS -pthread"
76                 libmono_ldflags="-pthread"
77                 need_link_unlink=yes
78                 libdl=
79                 libgc_threads=no
80                 ;;
81 # these flags will work for all versions of -STABLE
83         *-*-*freebsd4*)
84                 platform_win32=no
85                 if test "x$PTHREAD_CFLAGS" = "x"; then
86                         CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
87                         libmono_cflags="-D_THREAD_SAFE"
88                 else
89                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
90                         libmono_cflags="$PTHREAD_CFLAGS"
91                 fi
92                 if test "x$PTHREAD_LIBS" = "x"; then
93                         LDFLAGS="$LDFLAGS -pthread"
94                         libmono_ldflags="-pthread"
95                 else
96                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
97                         libmono_ldflags="$PTHREAD_LIBS"
98                 fi
99                 need_link_unlink=yes
100                 AC_DEFINE(PTHREAD_POINTER_ID)
101                 libdl=
102                 libgc_threads=pthreads
103 # TLS isn't implemented at all on -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
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)
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)
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])
197 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
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)
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])
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=""
225 AC_SUBST(CC_FOR_BUILD)
226 AC_SUBST(HOST_CC)
227 AC_SUBST(BUILD_EXEEXT)
229 # Set STDC_HEADERS
230 AC_HEADER_STDC
231 AC_LIBTOOL_WIN32_DLL
232 AM_PROG_LIBTOOL
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
241 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
243 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h)
245 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
247 AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
249 # for mono/metadata/debug-symfile.c
250 AC_CHECK_HEADERS(elf.h)
252 # for mono/dis
253 AC_CHECK_HEADERS(wchar.h)
254 AC_CHECK_HEADERS(ieeefp.h)
255 AC_MSG_CHECKING(for isinf)
256 AC_TRY_COMPILE([#include <math.h>], [
257         int f = isinf (1);
258 ], [
259         AC_MSG_RESULT(yes)
260         AC_DEFINE(HAVE_ISINF, 1, [isinf available])
261 ], [
262         # We'll have to use signals
263         AC_MSG_RESULT(no)
267 # not 64 bit clean in cross-compile
268 AC_CHECK_SIZEOF(void *, 4)
270 WARN=''
271 if test x"$GCC" = xyes; then
272         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
273                 # The runtime code does not respect ANSI C strict aliasing rules
274                 CFLAGS="$CFLAGS -fno-strict-aliasing"
275 else
276         # The Sun Forte compiler complains about inline functions that access static variables
277         # so disable all inlining.
278         case "$host" in
279         *-*-solaris*)
280                 CFLAGS="$CFLAGS -Dinline="
281                 ;;
282         esac
284 CFLAGS="$CFLAGS -g $WARN"
286 # Where's the 'mcs' source tree?
287 if test -d $srcdir/mcs; then
288   mcsdir=mcs
289 else
290   mcsdir=../mcs
293 mcs_topdir='$(top_srcdir)/'$mcsdir
294 mcs_topdir_from_srcdir='$(top_builddir)/'$mcsdir
296 AC_SUBST([mcs_topdir])
297 AC_SUBST([mcs_topdir_from_srcdir])
299 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
300 if test "x$PKG_CONFIG" = "xno"; then
301         AC_MSG_ERROR([You need to install pkg-config])
304 dnl for use on the build system
305 dnl pkg-config is stupid
306 BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
307 BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
308 AC_SUBST(BUILD_GLIB_CFLAGS)
309 AC_SUBST(BUILD_GLIB_LIBS)
311 PKG_PATH=
312 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
313         if test x$with_crosspkgdir = "x"; then
314                 if test -s $PKG_CONFIG_PATH; then
315                         PKG_PATH=$PKG_CONFIG_PATH
316                 fi
317         else
318                 PKG_PATH=$with_crosspkgdir
319                 PKG_CONFIG_PATH=$PKG_PATH
320                 export PKG_CONFIG_PATH
321         fi
324 ## Versions of dependencies
325 GLIB_REQUIRED_VERSION=1.3.11
327 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
329 GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
330 GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
331 GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
332 GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
334 AC_SUBST(GLIB_CFLAGS)
335 AC_SUBST(GLIB_LIBS)
336 AC_SUBST(GMODULE_CFLAGS)
337 AC_SUBST(GMODULE_LIBS)
339 if test x$platform_win32 = xyes; then   
340    AC_MSG_CHECKING(for cygwin glib2-dev package)
341    if [ cygcheck --f /usr/lib/libglib-2.0.dll.a | grep -q glib2-devel ]; then
342       AC_MSG_RESULT(found)
343           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.])
344    else
345       AC_MSG_RESULT(not found, ok)
346    fi
348    AC_MSG_CHECKING(for broken gwin32.h)
349    glib_include=`$PKG_CONFIG --cflags-only-I glib-2.0 | sed -e 's/ -I.*//g' | sed -e 's/-I//g'`
350    if test -f $glib_include/glib/gwin32.h; then
351           if [ grep ftruncate $glib_include/glib/gwin32.h | grep -q define ]; then
352                  AC_MSG_RESULT(failed)
353                  hashmark='#'
354                  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.])
355           fi
356    fi
357    AC_MSG_RESULT(ok)
360 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
362 # Enable support for fast thread-local storage
363 # Some systems have broken support, so we allow to disable it.
364 AC_ARG_WITH(tls, [  --with-tls=__thread,pthread       select Thread Local Storage implementation],[],[with_tls=__thread])
366 # Kept for compatibility
367 AC_ARG_WITH(nptl, [  --with-nptl=yes,no      deprecated, use --with-tls instead],[],[with_nptl=default])
369 if test "x$with_nptl" != "xdefault"; then
370    if test "x$with_nptl" = "xyes"; then
371       AC_MSG_WARN([--with-nptl=yes is deprecated, use --with-tls=__thread option instead.])
372           with_tls=__thread
373    fi
374    if test "x$with_nptl" = "xno"; then
375       AC_MSG_WARN([--with-nptl=no is deprecated, use --with-tls=pthread option instead.])
376           with_tls=pthread
377    fi
380 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
381 # This does not work on some platforms (bug #55253)
382 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack],[],[with_sigaltstack=no])
384 AC_ARG_WITH(static_mono, [  --with-static_mono=yes,no      link mono statically to libmono (faster)],[],[with_static_mono=yes])
386 if test "x$enable_static" = "xno"; then
387    with_static_mono=no
390 AM_CONDITIONAL(STATIC_MONO, test x$with_static_mono != xno)
392 AC_ARG_ENABLE(minimal, [  --enable-minimal=LIST      drop support for LIST subsystems.
393   LIST is a comma-separated list from: aot, profiler, decimal, pinvoke, debug, reflection_emit.],
395         for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
396                 eval "mono_feature_disable_$feature='yes'"
397                 AC_MSG_NOTICE([Disabled support for feature: $feature])
398         done
399         disabled="Disabled:    $enable_minimal"
400 ],[])
402 if test "x$mono_feature_disable_aot" = "xyes"; then
403         AC_DEFINE(DISABLE_AOT, 1, [Disable AOT support])
406 if test "x$mono_feature_disable_profiler" = "xyes"; then
407         AC_DEFINE(DISABLE_PROFILER, 1, [Disable default profiler support])
410 if test "x$mono_feature_disable_decimal" = "xyes"; then
411         AC_DEFINE(DISABLE_DECIMAL, 1, [Disable System.Decimal support])
414 if test "x$mono_feature_disable_pinvoke" = "xyes"; then
415         AC_DEFINE(DISABLE_PINVOKE, 1, [Disable P/Invoke support])
418 if test "x$mono_feature_disable_debug" = "xyes"; then
419         AC_DEFINE(DISABLE_DEBUG, 1, [Disable runtime debugging support])
422 if test "x$mono_feature_disable_reflection_emit" = "xyes"; then
423         AC_DEFINE(DISABLE_REFLECTION_EMIT, 1, [Disable reflection emit support])
426 LIBGC_CFLAGS=
427 LIBGC_LIBS=
428 LIBGC_STATIC_LIBS=
429 libgc_dir=
430 case "x$gc" in
431         xboehm|xbohem|xyes)
432                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
433                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
435                 if test "x$found_boehm" != "xyes"; then
436                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
437                 fi
438                 if test "x$gc_headers" != "xyes"; then
439                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
440                 fi
442                 AC_DEFINE(HAVE_BOEHM_GC)
443                 AC_SUBST(HAVE_BOEHM_GC)
444                 LIBGC_LIBS="-lgc $libdl"
445                 LIBGC_STATIC_LIBS="$LIBGC_LIBS"
447                 # AC_CHECK_FUNCS does not work for some reason...
448                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
449                 if test "x$found_gcj_malloc" = "xyes"; then
450                         AC_DEFINE(HAVE_GC_GCJ_MALLOC)
451                 fi
452                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
453                 if test "x$found_gc_enable" = "xyes"; then
454                         AC_DEFINE(HAVE_GC_ENABLE)
455                 fi
456                 ;;
458         xincluded)
459                 AC_CONFIG_SUBDIRS(libgc)
461                 found_boehm=yes
462                 gc_headers=yes
463                 use_included_gc=yes
464                 libgc_dir=libgc
466                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
467                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
468                 LIBGC_STATIC_LIBS='$(top_builddir)/libgc/libmonogc-static.la'
470                 AC_DEFINE(HAVE_BOEHM_GC)
471                 AC_SUBST(HAVE_BOEHM_GC)
473                 AC_DEFINE(HAVE_GC_H)
474                 AC_DEFINE(USE_INCLUDED_LIBGC)
476                 # The included libgc contains GCJ support
477                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
478                 AC_DEFINE(HAVE_GC_ENABLE)
479                 ;;
481         xnone)
482                 AC_MSG_WARN("Compiling mono without GC.")
483                 ;;
484         *)
485                 AC_MSG_ERROR([Invalid argument to --with-gc.])
486                 ;;
487 esac
490 # tell libgc/configure about what we want
491 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
493 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
494 AC_SUBST(LIBGC_CFLAGS)
495 AC_SUBST(LIBGC_LIBS)
496 AC_SUBST(LIBGC_STATIC_LIBS)
497 AC_SUBST(libgc_dir)
500 dnl End of libgc checks
503 if test x$platform_win32 = xno; then
505         AC_CHECK_FUNCS(getgrgid_r)
506         AC_CHECK_FUNCS(getgrnam_r)
507         AC_CHECK_FUNCS(getpwnam_r)
508         AC_CHECK_FUNCS(getpwuid_r)
509         AC_CHECK_FUNCS(getresuid)
510         AC_CHECK_FUNCS(setresuid)
511         AC_CHECK_FUNCS(kqueue)
513         dnl ******************************************************************
514         dnl *** Check for large file support                               ***
515         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
516         dnl ******************************************************************
517         
518         # Check that off_t can represent 2**63 - 1 correctly, working around
519         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
520         # CPPFLAGS and sets $large_offt to yes if the test succeeds
521         large_offt=no
522         AC_DEFUN(LARGE_FILES, [
523                 large_CPPFLAGS=$CPPFLAGS
524                 CPPFLAGS="$CPPFLAGS $1"
525                 AC_TRY_RUN([
526                         #include <sys/types.h>
528                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
530                         int main(void) {
531                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
532                                                (BIG_OFF_T%2147483647==1));
533                                 if(big_off_t) {
534                                         exit(0);
535                                 } else {
536                                         exit(1);
537                                 }
538                         }
539                 ], [
540                         AC_MSG_RESULT(ok)
541                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
542                         large_CPPFLAGS="$large_CPPFLAGS $1"
543                         large_offt=yes
544                 ], [
545                         AC_MSG_RESULT(no)
546                 ], "")
547                 CPPFLAGS=$large_CPPFLAGS
548         ])
550         AC_MSG_CHECKING(if off_t is 64 bits wide)
551         LARGE_FILES("")
552         if test $large_offt = no; then
553                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
554                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
555         fi
556         if test $large_offt = no; then
557                 AC_MSG_WARN([No 64 bit file size support available])
558         fi
559         
560         dnl *****************************
561         dnl *** Checks for libsocket  ***
562         dnl *****************************
563         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
565         dnl *******************************
566         dnl *** Checks for MSG_NOSIGNAL ***
567         dnl *******************************
568         AC_MSG_CHECKING(for MSG_NOSIGNAL)
569         AC_TRY_COMPILE([#include <sys/socket.h>], [
570                 int f = MSG_NOSIGNAL;
571         ], [
572                 # Yes, we have it...
573                 AC_MSG_RESULT(yes)
574                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
575         ], [
576                 # We'll have to use signals
577                 AC_MSG_RESULT(no)
578         ])
580         dnl *****************************
581         dnl *** Checks for SOL_IP     ***
582         dnl *****************************
583         AC_MSG_CHECKING(for SOL_IP)
584         AC_TRY_COMPILE([#include <netdb.h>], [
585                 int level = SOL_IP;
586         ], [
587                 # Yes, we have it...
588                 AC_MSG_RESULT(yes)
589                 AC_DEFINE(HAVE_SOL_IP)
590         ], [
591                 # We'll have to use getprotobyname
592                 AC_MSG_RESULT(no)
593         ])
595         dnl *****************************
596         dnl *** Checks for SOL_IPV6     ***
597         dnl *****************************
598         AC_MSG_CHECKING(for SOL_IPV6)
599         AC_TRY_COMPILE([#include <netdb.h>], [
600                 int level = SOL_IPV6;
601         ], [
602                 # Yes, we have it...
603                 AC_MSG_RESULT(yes)
604                 AC_DEFINE(HAVE_SOL_IPV6)
605         ], [
606                 # We'll have to use getprotobyname
607                 AC_MSG_RESULT(no)
608         ])
610         dnl *****************************
611         dnl *** Checks for SOL_TCP    ***
612         dnl *****************************
613         AC_MSG_CHECKING(for SOL_TCP)
614         AC_TRY_COMPILE([#include <netdb.h>], [
615                 int level = SOL_TCP;
616         ], [
617                 # Yes, we have it...
618                 AC_MSG_RESULT(yes)
619                 AC_DEFINE(HAVE_SOL_TCP)
620         ], [
621                 # We'll have to use getprotobyname
622                 AC_MSG_RESULT(no)
623         ])
625         dnl *****************************
626         dnl *** Checks for IP_PKTINFO ***
627         dnl *****************************
628         AC_MSG_CHECKING(for IP_PKTINFO)
629         AC_TRY_COMPILE([#include <netdb.h>], [
630                 int level = IP_PKTINFO;
631         ], [
632                 # Yes, we have it...
633                 AC_MSG_RESULT(yes)
634                 AC_DEFINE(HAVE_IP_PKTINFO)
635         ], [
636                 AC_MSG_RESULT(no)
637         ])
639         dnl *********************************
640         dnl *** Check for struct ip_mreqn ***
641         dnl *********************************
642         AC_MSG_CHECKING(for struct ip_mreqn)
643         AC_TRY_COMPILE([#include <netinet/in.h>], [
644                 struct ip_mreqn mreq;
645                 mreq.imr_address.s_addr = 0;
646         ], [
647                 # Yes, we have it...
648                 AC_MSG_RESULT(yes)
649                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
650         ], [
651                 # We'll just have to try and use struct ip_mreq
652                 AC_MSG_RESULT(no)
653                 AC_MSG_CHECKING(for struct ip_mreq)
654                 AC_TRY_COMPILE([#include <netinet/in.h>], [
655                         struct ip_mreq mreq;
656                         mreq.imr_interface.s_addr = 0;
657                 ], [
658                         # Yes, we have it...
659                         AC_MSG_RESULT(yes)
660                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
661                 ], [
662                         # No multicast support
663                         AC_MSG_RESULT(no)
664                 ])
665         ])
666         
667         dnl **********************************
668         dnl *** Check for gethostbyname2_r ***
669         dnl **********************************
670         AC_MSG_CHECKING(for gethostbyname2_r)
671                 AC_TRY_LINK([#include <netdb.h>], [
672                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
673         ], [
674                 # Yes, we have it...
675                 AC_MSG_RESULT(yes)
676                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R)
677         ], [
678                 AC_MSG_RESULT(no)
679         ])
681         dnl *****************************
682         dnl *** Checks for libnsl     ***
683         dnl *****************************
684         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
686         AC_CHECK_FUNCS(inet_pton inet_aton)
688         dnl ***********************************************
689         dnl *** Checks for size of sockaddr_un.sun_path ***
690         dnl ***********************************************
691         # AC_CHECK_SIZEOF can't cope with struct members :-(
692         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
693         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
694                 [AC_TRY_RUN([
695                         #include <sys/types.h>
696                         #include <stdio.h>
697                         #include <sys/un.h>
699                         int main(void) {
700                                 struct sockaddr_un sock_un;
701                                 FILE *f=fopen("conftestval", "w");
702                                 if(!f) exit(1);
703                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
704                                 exit(0);
705                         }
706                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
707                    cv_mono_sizeof_sunpath=0,
708                    cv_mono_sizeof_sunpath=0)])dnl
709         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
710         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
712         dnl *************************************
713         dnl *** Checks for zero length arrays ***
714         dnl *************************************
715         AC_MSG_CHECKING(whether $CC supports zero length arrays)
716         AC_TRY_COMPILE([
717                 struct s {
718                         int  length;
719                         char data [0];
720                 };
721         ], [], [
722                 AC_MSG_RESULT(yes)
723                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 0)
724         ], [
725                 AC_MSG_RESULT(no)
726                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 1)
727         ])
729         dnl *****************************
730         dnl *** Checks for libxnet    ***
731         dnl *****************************
732         case "${host}" in
733                 *solaris* )
734                         AC_MSG_CHECKING(for Solaris XPG4 support)
735                         if test -f /usr/lib/libxnet.so; then
736                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
737                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
738                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
739                                 LIBS="$LIBS -lxnet"
740                                 AC_MSG_RESULT(yes)
741                         else
742                                 AC_MSG_RESULT(no)
743                         fi
745                         if test "$GCC" = "yes"; then
746                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
747                         fi
748                 ;;
749         esac
751         dnl *****************************
752         dnl *** Checks for libpthread ***
753         dnl *****************************
754 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
755 # and libpthread does not exist
757         case "${host}" in
758                 *-*-*freebsd4*)
759                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
760                 ;;
761                 *)
762                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
763                 ;;
764         esac
765         AC_CHECK_HEADERS(pthread.h)
766         AC_CHECK_FUNCS(pthread_mutex_timedlock)
767         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
768         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
769         AC_TRY_COMPILE([ #include <pthread.h>], [
770                 pthread_mutexattr_t attr;
771                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
772         ], [
773                 AC_MSG_RESULT(ok)
774         ], [
775                 AC_MSG_RESULT(no)
776                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
777                 AC_DEFINE(USE_MONO_MUTEX)
778         ])
779         AC_CHECK_FUNCS(pthread_attr_setstacksize)
781         dnl ***********************************
782         dnl *** Checks for working __thread ***
783         dnl ***********************************
784         AC_MSG_CHECKING(for working __thread)
785         if test "x$with_tls" != "x__thread"; then
786                 AC_MSG_RESULT(disabled)
787         else
788                 AC_TRY_RUN([
789                         #include <pthread.h>
791                         __thread int i;
792                         static int res1, res2;
794                         void thread_main (void *arg)
795                         {
796                                 i = arg;
797                                 sleep (1);
798                                 if (arg == 1)
799                                         res1 = (i == arg);
800                                 else
801                                         res2 = (i == arg);
802                         }
804                         int main () {
805                                 pthread_t t1, t2;
807                                 i = 5;
809                                 pthread_create (&t1, NULL, thread_main, 1);
810                                 pthread_create (&t2, NULL, thread_main, 2);
812                                 pthread_join (t1, NULL);
813                                 pthread_join (t2, NULL);
815                                 return !(res1 + res2 == 2);
816                         }
817                 ], [
818                                 AC_MSG_RESULT(yes)
819                 ], [
820                                 AC_MSG_RESULT(no)
821                                 with_tls=pthread
822                 ])
823         fi
825         dnl **************************************
826         dnl *** Checks for working sigaltstack ***
827         dnl **************************************
828         AC_MSG_CHECKING(for working sigaltstack)
829         if test "x$with_sigaltstack" != "xyes"; then
830                 AC_MSG_RESULT(disabled)
831         else
832                 AC_TRY_RUN([
833                         #include <stdio.h>
834                         #include <stdlib.h>
835                         #include <unistd.h>
836                         #include <signal.h>
837                         #include <pthread.h>
838                         #include <sys/wait.h>
840                         static void
841                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
842                         {
843                                 exit (0);
844                         }
846                         static void *
847                         loop (void *ignored)
848                         {
849                                 char *ptr = NULL;
851                                 *ptr = 0;
852                                 return NULL;
853                         }
855                         static void
856                         child ()
857                         {
858                                 struct sigaction sa;
859                                 struct sigaltstack sas;
860                                 pthread_t id;
861                                 pthread_attr_t attr;
863                                 sa.sa_sigaction = sigsegv_signal_handler;
864                                 sigemptyset (&sa.sa_mask);
865                                 sa.sa_flags = SA_SIGINFO | SA_STACK;
866                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
867                                         perror ("lala");
868                                         return;
869                                 }
871                                 sas.ss_sp = malloc (SIGSTKSZ);
872                                 sas.ss_size = SIGSTKSZ;
873                                 sas.ss_flags = SS_ONSTACK;
874                                 if (sigaltstack (&sas, NULL) == -1) {
875                                         perror ("lala");
876                                         return;
877                                 }
879                                 pthread_attr_init (&attr);
880                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
881                                         printf ("failed\n");
882                                         return;
883                                 }
885                                 sleep (100);
886                         }
888                         int
889                         main ()
890                         {
891                                 pid_t son;
892                                 int status;
893                                 int i;
895                                 son = fork ();
896                                 if (son == -1) {
897                                         return 1;
898                                 }
900                                 if (son == 0) {
901                                         child ();
902                                         return 0;
903                                 }
905                                 for (i = 0; i < 3; ++i) {
906                                         sleep (1);
907                                         waitpid (son, &status, WNOHANG);
908                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
909                                                 return 0;
910                                 }
912                                 kill (son, SIGKILL);
913                                 return 1;
914                         }
916                 ], [
917                                 AC_MSG_RESULT(yes)
918                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
919                 ], [
920                                 with_sigaltstack=no
921                                 AC_MSG_RESULT(no)
922                 ])
923         fi
925         dnl ********************************
926         dnl *** Checks for semaphore lib ***
927         dnl ********************************
928         # 'Real Time' functions on Solaris
929         # posix4 on Solaris 2.6
930         # pthread (first!) on Linux
931         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
933         dnl ********************************
934         dnl *** Checks for timezone stuff **
935         dnl ********************************
936         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
937                 AC_TRY_COMPILE([
938                         #include <time.h>
939                         ], [
940                         struct tm tm;
941                         tm.tm_gmtoff = 1;
942                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
943         if test $ac_cv_struct_tm_gmtoff = yes; then
944                 AC_DEFINE(HAVE_TM_GMTOFF)
945         else
946                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
947                         AC_TRY_COMPILE([
948                                 #include <time.h>
949                         ], [
950                                 timezone = 1;
951                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
952                 if test $ac_cv_var_timezone = yes; then
953                         AC_DEFINE(HAVE_TIMEZONE)
954                 else
955                         AC_ERROR(unable to find a way to determine timezone)
956                 fi
957         fi
959         dnl *********************************
960         dnl *** Checks for math functions ***
961         dnl *********************************
962         LIBS="$LIBS -lm";
963         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
964                 AC_TRY_LINK([#include <math.h>], 
965                 [ finite(0.0); ], 
966                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
967                 AC_MSG_RESULT(no)))
968         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
969                 AC_TRY_LINK([#include <math.h>], 
970                 [ isfinite(0.0); ], 
971                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
972                 AC_MSG_RESULT(no)))
974         dnl ****************************************************************
975         dnl *** Checks for working poll() (macosx defines it but doesn't ***
976         dnl *** have it in the library (duh))                            ***
977         dnl ****************************************************************
978         AC_CHECK_FUNCS(poll)
980         dnl *************************
981         dnl *** Check for signbit ***
982         dnl *************************
983         AC_MSG_CHECKING(for signbit)
984         AC_TRY_LINK([#include <math.h>], [
985                 int s = signbit(1.0);
986         ], [
987                 AC_MSG_RESULT(yes)
988                 AC_DEFINE(HAVE_SIGNBIT)
989         ], [
990                 AC_MSG_RESULT(no)
991         ]) 
993         dnl *********************
994         dnl *** Check for AIO ***
995         dnl *********************
996         AC_MSG_CHECKING([for SIGEV_THREAD definition])
997         dnl Some systems (FreeBSD at least) may have aio_read
998         dnl but don't support/define SIGEV_THREAD.
999         AC_TRY_COMPILE([
1000         #include <sys/signal.h>
1001         ],[
1002         int x = SIGEV_THREAD;
1003         ],[
1004                 ac_cv_c_sigev_thread=yes
1005                 AC_MSG_RESULT(yes)
1006         ],[
1007                 AC_MSG_RESULT(no)
1008         ])
1010         if test "$ac_cv_c_sigev_thread" = "yes" ; then
1011                 AC_CHECK_HEADERS(aio.h sys/aio.h)
1012                 AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
1013                 SIGVAL_PTR="undefined"
1014                 if test "$ac_cv_header_aio_h" = "yes" -o "$ac_cv_header_sys_aio_h" = "yes" ; then
1015                         AC_CHECK_MEMBER(union sigval.sigval_ptr,SIGVAL_PTR="sigval_ptr",, [
1016                                         #include <sys/signal.h>
1017                                         ])
1018                         AC_CHECK_MEMBER(union sigval.sival_ptr,SIGVAL_PTR="sival_ptr",, [
1019                                         #include <sys/signal.h>
1020                                         ])
1021                         if test "$SIGVAL_PTR" = "undefined" ; then
1022                                 AC_MSG_ERROR([Unable to detect field name in 'union sigval'])
1023                         fi
1024                 fi
1025                 AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
1026         fi
1028         dnl **********************************
1029         dnl *** Checks for MonoPosixHelper ***
1030         dnl **********************************
1031         AC_CHECK_HEADERS(fstab.h)
1032         AC_CHECK_HEADERS(sys/sendfile.h)
1033         AC_CHECK_HEADERS(sys/statvfs.h)
1034         AC_CHECK_HEADERS(sys/vfstab.h)
1035         AC_CHECK_FUNCS(getdomainname)
1036         AC_CHECK_FUNCS(setdomainname)
1037         AC_CHECK_FUNCS(fgetgrent)
1038         AC_CHECK_FUNCS(fgetpwent)
1039         AC_CHECK_FUNCS(fgetpwent)
1040         AC_CHECK_FUNCS(getfsstat)
1041         AC_CHECK_FUNCS(posix_fadvise)
1042         AC_CHECK_FUNCS(posix_fallocate)
1043         AC_CHECK_FUNCS(posix_madvise)
1044         AC_CHECK_FUNCS(sendfile)
1045         AC_CHECK_FUNCS(sethostid)
1046         AC_CHECK_FUNCS(statfs)
1047         AC_CHECK_FUNCS(fstatfs)
1048         AC_CHECK_FUNCS(statvfs)
1049         AC_CHECK_FUNCS(fstatvfs)
1050         AC_CHECK_FUNCS(stime)
1051         AC_CHECK_FUNCS(strerror_r)
1052         AC_CHECK_FUNCS(ttyname_r)
1053         AC_CHECK_SIZEOF(size_t)
1054         AC_CHECK_MEMBERS(
1055                 [struct dirent.d_off, struct dirent.d_reclen, struct dirent.d_type],,, 
1056                 [#include <sys/types.h>
1057                  #include <dirent.h>])
1058 else
1059         jdk_headers_found=no
1060         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
1061         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
1062         AC_CHECK_LIB(ole32, main, LIBS="$LIBS -lole32", AC_ERROR(bad mingw install?))
1064         dnl *********************************
1065         dnl *** Check for struct ip_mreqn ***
1066         dnl *********************************
1067         AC_MSG_CHECKING(for struct ip_mreqn)
1068         AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1069                 struct ip_mreqn mreq;
1070                 mreq.imr_address.s_addr = 0;
1071         ], [
1072                 # Yes, we have it...
1073                 AC_MSG_RESULT(yes)
1074                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
1075         ], [
1076                 # We'll just have to try and use struct ip_mreq
1077                 AC_MSG_RESULT(no)
1078                 AC_MSG_CHECKING(for struct ip_mreq)
1079                 AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1080                         struct ip_mreq mreq;
1081                         mreq.imr_interface.s_addr = 0;
1082                 ], [
1083                         # Yes, we have it...
1084                         AC_MSG_RESULT(yes)
1085                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
1086                 ], [
1087                         # No multicast support
1088                         AC_MSG_RESULT(no)
1089                 ])
1090         ])
1093 dnl socklen_t check
1094 AC_MSG_CHECKING(for socklen_t)
1095 AC_TRY_COMPILE([
1096 #include <sys/types.h>
1097 #include <sys/socket.h>
1099   socklen_t foo;
1101 ac_cv_c_socklen_t=yes
1102         AC_DEFINE(HAVE_SOCKLEN_T)
1103         AC_MSG_RESULT(yes)
1105         AC_MSG_RESULT(no)
1108 AC_MSG_CHECKING(for array element initalizer support)
1109 AC_TRY_COMPILE([#include <sys/socket.h>], [
1110         const int array[] = {[1] = 2,};
1111 ], [
1112         # Yes, we have it...
1113         AC_MSG_RESULT(yes)
1114         AC_DEFINE(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
1115 ], [
1116         # We'll have to use signals
1117         AC_MSG_RESULT(no)
1120 AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
1121         # Simply calling trunc (0.0) is no good since gcc will optimize the call away
1122         AC_TRY_LINK([#include <math.h>], 
1123         [ static void *p = &trunc; ],
1124         [
1125                 AC_DEFINE(HAVE_TRUNC) 
1126                 AC_MSG_RESULT(yes)
1127                 ac_cv_trunc=yes
1128         ],
1129         AC_MSG_RESULT(no)))
1131 if test "x$ac_cv_truncl" != "xyes"; then
1132    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
1135 dnl ****************************
1136 dnl *** Look for /dev/random ***
1137 dnl ****************************
1139 AC_MSG_CHECKING([if usage of random device is requested])
1140 AC_ARG_ENABLE(dev-random,
1141 [  --disable-dev-random    disable the use of the random device],
1142 try_dev_random=$enableval, try_dev_random=yes)
1143 AC_MSG_RESULT($try_dev_random)
1145 case "{$target}" in
1146     *-openbsd*)
1147     NAME_DEV_RANDOM="/dev/srandom"
1148     ;;
1150 dnl Win32 does not have /dev/random, they have their own method...
1152     *-*-mingw*|*-*-cygwin*)
1153     ac_cv_have_dev_random=no
1154     ;;
1156 dnl Everywhere else, it's /dev/random
1158     *)
1159     NAME_DEV_RANDOM="/dev/random"
1160     ;;
1161 esac
1163 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
1165 dnl Now check if the device actually exists
1167 if test "x$try_dev_random" = "xyes"; then
1168     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1169     [if test -r "$NAME_DEV_RANDOM" ; then
1170         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1171     if test "x$ac_cv_have_dev_random" = "xyes"; then
1172         AC_DEFINE(HAVE_CRYPT_RNG)
1173     fi
1174 else
1175     AC_MSG_CHECKING(for random device)
1176     ac_cv_have_dev_random=no
1177     AC_MSG_RESULT(has been disabled)
1180 if test "x$platform_win32" = "xyes"; then
1181     AC_DEFINE(HAVE_CRYPT_RNG)
1184 if test "x$ac_cv_have_dev_random" = "xno" \
1185     && test "x$platform_win32" = "xno"; then
1186     AC_MSG_WARN([[
1188 *** A system-provided entropy source was not found on this system.
1189 *** Because of this, the System.Security.Cryptography random number generator
1190 *** will throw a NotImplemented exception.
1192 *** If you are seeing this message, and you know your system DOES have an
1193 *** entropy collection in place, please contact <crichton@gimp.org> and
1194 *** provide information about the system and how to access the random device.
1196 *** Otherwise you can install either egd or prngd and set the environment
1197 *** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
1198 ***]])
1201 AC_MSG_CHECKING([if inter-process shared handles are requested])
1202 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
1203 AC_MSG_RESULT($try_shared_handles)
1204 if test "x$try_shared_handles" != "xyes"; then
1205         AC_DEFINE(DISABLE_SHARED_HANDLES)
1206         AC_SUBST(DISABLE_SHARED_HANDLES)
1210 # ICU 
1212 ICU_CFLAGS=""
1213 ICU_LIBS=""
1214 enable_icu="no;  default"
1216 probe_icu=false
1217 AC_ARG_WITH(icu, [  --with-icu=yes/no],
1218         if test x$with_icu = xno; then
1219            probe_icu=false;
1220            AC_MSG_RESULT(Will not probe for ICU)
1221         fi
1222         if test x$with_icu = xyes; then
1223            probe_icu=true;
1224         fi
1227 if $probe_icu; then
1228         AC_PATH_PROG(ICU_CONFIG, icu-config, no)
1229         if test "x$ICU_CONFIG" = "xno" -o ! -x "$ICU_CONFIG"; then
1230                 AC_MSG_WARN([Only invariant locale available; install ICU for I18N support])
1231                 enable_icu="no, if you want full i18n support download it from: http://oss.software.ibm.com/icu/index.html"
1232         else
1233                 enable_icu="yes. Version: `$ICU_CONFIG --version`"
1234                 AC_DEFINE(HAVE_ICU)
1235                 ICU_CFLAGS=`$ICU_CONFIG --cppflags`
1236                 ICU_LIBS=`$ICU_CONFIG --ldflags`
1237         fi
1239 AC_SUBST(ICU_CFLAGS)
1240 AC_SUBST(ICU_LIBS)
1242 AC_ARG_ENABLE(nunit-tests, [ --enable-nunit-tests       Run the nunit tests of the class library on 'make check'])
1243 AM_CONDITIONAL(ENABLE_NUNIT_TESTS, [test x$enable_nunit_tests = xyes])
1245 TARGET="unknown"
1246 ACCESS_UNALIGNED="yes"
1248 JIT_SUPPORTED=no
1249 INTERP_SUPPORTED=no
1250 LIBC="libc.so.6"
1251 INTL="libc.so.6"
1253 jit_wanted=false
1254 interp_wanted=false
1255 case "$host" in
1256 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
1257 #               TARGET=MIPS;
1258 #               ACCESS_UNALIGNED="no"
1259 #               ;;
1260         i*86-*-*)
1261                 TARGET=X86;
1262                 arch_target=x86;
1263                 JIT_SUPPORTED=yes
1264                 jit_wanted=true
1265                 ;;
1266         x86_64-*-* | amd64-*-*)
1267                 TARGET=AMD64;
1268                 arch_target=amd64;
1269                 JIT_SUPPORTED=yes
1270                 jit_wanted=true
1271                 ;;
1272         sparc*-*-*)
1273                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
1274                    TARGET=SPARC64
1275                 else
1276                         TARGET=SPARC
1277                 fi
1278                 arch_target=sparc;
1279                 JIT_SUPPORTED=yes
1280                 ACCESS_UNALIGNED="no"
1281                 LIBC="libc.so"
1282                 INTL="libintl.so"
1283                 jit_wanted=true
1284                 if test x"$GCC" = xyes; then
1285                         CFLAGS="$CFLAGS -Wno-cast-align"
1286                 fi
1287                 ;;
1288        alpha*-*-linux* | alpha*-*-osf*)
1289                 TARGET=ALPHA;
1290                 ACCESS_UNALIGNED="no"
1291                 JIT_SUPPORTED=no
1292                 INTERP_SUPPORTED=yes
1293                 interp_wanted=true
1294                 arch_target=alpha;
1295                ;;
1296 #       ia64-*-linux* | ia64-*-hpux*)
1297 #               TARGET=IA64;
1298 #               arch_target=ia64;
1299 #               JIT_SUPPORTED=no;
1300 #               ACCESS_UNALIGNED="no";
1301 #               case "$host_os" in
1302 #                       linux*) LIBC="libc.so.6.1";;
1303 #                       hpux*)  LIBC="libc.so.1";;
1304 #               esac
1305 #               ;;
1306 #       m68k-*-linux*)
1307 #               TARGET=M68K
1308 #               ;;
1309         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
1310                 TARGET=HPPA;
1311                 arch_target=hppa; 
1312                 LIBC="libc.sl"
1313                 ACCESS_UNALIGNED="no"
1314                 INTERP_SUPPORTED=yes
1315                 interp_wanted=true
1316                 ;;
1317         hppa*linux*)
1318                 TARGET=HPPA;
1319                 arch_target=hppa; 
1320                 ACCESS_UNALIGNED="no"
1321                 INTERP_SUPPORTED=yes
1322                 interp_wanted=true
1323                 ;;
1324         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
1325         powerpc-*-sysv* | powerpc-*-darwin*)
1326                 TARGET=POWERPC;
1327                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1328                 arch_target=ppc;
1329                 JIT_SUPPORTED=yes
1330                 jit_wanted=true
1331                 ;;
1332         arm-*-linux-* | armv4l-*-linux-*)
1333                 TARGET=ARM;
1334                 arch_target=arm;
1335                 ACCESS_UNALIGNED="no"
1336                 INTERP_SUPPORTED=yes
1337                 interp_wanted=true
1338                 ;;
1339         s390-*-linux*)
1340                 TARGET=S390;
1341                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1342                 arch_target=s390;
1343                 ACCESS_UNALIGNED="no"
1344                 JIT_SUPPORTED=yes
1345                 ;;
1346         s390x-*-linux*)
1347                 TARGET=S390x;
1348                 AC_DEFINE(MONO_ARCH_REGPARMS,1,[Architecture uses registers for Parameters])
1349                 arch_target=s390x;
1350                 ACCESS_UNALIGNED="no"
1351                 JIT_SUPPORTED=yes
1352                 ;;
1353 esac
1355 AC_ARG_WITH(jit, [  --with-jit=yes,no       If you want to build scripts that default to the JIT],[
1356         if test x$withval = xyes; then
1357            jit_wanted=true
1358         else
1359            jit_wanted=false
1360         fi
1363 AC_ARG_WITH(interp, [  --with-interp=yes,no    If you want to build scripts that default to the interpreter],[
1364         if test x$withval = xyes; then
1365            interp_wanted=true
1366         else
1367            interp_wanted=false
1368         fi
1371 USEJIT=false
1372 if test x$JIT_SUPPORTED = xyes; then
1373    if $jit_wanted; then
1374       USEJIT=true
1375       jit_status="Building and using the JIT"
1376    else
1377       if $interp_wanted; then
1378          jit_status="Building the JIT, defaulting to the interpreter"
1379       else
1380          AC_ERROR(No JIT or interpreter support available or selected.)
1381       fi
1382    fi
1383 else
1384    if $interp_wanted; then
1385       jit_status="interpreter"
1386    else
1387       AC_ERROR(No JIT or interpreter support available or selected.)
1388    fi
1391 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
1393 libsuffix=".so"
1395 case "$host" in
1396      powerpc-*-darwin*)
1397         libsuffix=".dylib"
1398         LIBC="libc.dylib"
1399         INTL="libintl.dylib"
1400         ;;
1401      *-*-*netbsd*)
1402         LIBC="libc.so.12"
1403         INTL="libintl.so.0"
1404         ;;
1405     *-*-*freebsd*)
1406         LIBC="libc.so"
1407         INTL="libintl.so"
1408         ;;
1409     *-*-*openbsd*)
1410         LIBC="libc.so"
1411         INTL="libintl.so"
1412         ;;
1413 esac
1414 AC_SUBST(libsuffix)
1416 if test "x$TARGET" != "xAMD64"; then
1417    # valgrind headers don't compile under x86-64
1418    AC_CHECK_HEADERS(valgrind/memcheck.h)
1421 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
1422         if test "x$with_tls" = "x__thread"; then
1423                 #
1424                 # On some linux distributions, TLS works in executables, but linking 
1425                 # against a shared library containing TLS fails with:
1426                 # undefined reference to `__tls_get_addr'
1427                 #
1428                 rm -f conftest.c conftest.so conftest
1429                 echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
1430                 gcc -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
1431                 gcc -o conftest conftest.so > /dev/null 2>&1
1432                 if test ! -f conftest; then
1433                    AC_MSG_WARN([Disabling usage of __thread.]);
1434                    with_tls=pthread
1435                 fi
1436                 rm -f conftest.c conftest.so conftest
1437         fi
1440 if test "x$with_tls" = "x__thread"; then
1441         AC_DEFINE(HAVE_KW_THREAD)
1442    # Pass the information to libgc
1443         CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
1444         export CPPFLAGS
1447 if test ${TARGET} = ARM; then
1448         dnl ******************************************
1449         dnl *** Check to see what FPU is available ***
1450         dnl ******************************************
1451         AC_MSG_CHECKING(which FPU to use)
1453         AC_TRY_COMPILE([], [
1454                 __asm__ ("ldfd f0, [r0]");
1455                 ], fpu=FPA, [
1456                         AC_TRY_COMPILE([], [
1457                                 __asm__ ("fldd d0, [r0]");
1458                         ], fpu=VFP, fpu=NONE)
1459                 ])
1461         AC_MSG_RESULT($fpu)
1462         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
1463         unset fpu
1466 if test ${TARGET} = unknown; then
1467         CPPFLAGS="$CPPFLAGS -DNO_PORT"
1468         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
1471 if test ${ACCESS_UNALIGNED} = no; then
1472         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
1475 PREVIEW=no
1476 AC_ARG_WITH(preview, [ --with-preview=yes,no     If you want to install the 2.0 FX preview],[
1477         if test x$with_preview = xyes; then
1478               PREVIEW=yes
1479         fi
1482 AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
1484 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
1485 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
1486 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
1487 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
1488 AM_CONDITIONAL(X86, test x$TARGET = xX86)
1489 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
1490 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
1491 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
1492 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
1493 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
1494 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
1495 AM_CONDITIONAL(S390, test x$TARGET = xS390)
1496 AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
1497 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
1499 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
1500 AM_CONDITIONAL(INTERP_SUPPORTED, test x$interp_wanted = xtrue)
1501 AM_CONDITIONAL(INCLUDED_LIBGC, test x$gc = xincluded)
1503 AC_SUBST(LIBC)
1504 AC_SUBST(INTL)
1506 AC_SUBST(arch_target)
1507 AC_SUBST(CFLAGS)
1508 AC_SUBST(CPPFLAGS)
1509 AC_SUBST(LDFLAGS)
1511 mono_build_root=`pwd`
1512 AC_SUBST(mono_build_root)
1514 if test x$USEJIT = xtrue; then
1515   mono_runtime=mono/mini/mono
1516 else
1517   mono_runtime=mono/interpreter/mint
1519 AC_SUBST(mono_runtime)
1521 mono_cfg_root=$mono_build_root/runtime
1522 if test x$platform_win32 = xyes; then
1523   mono_cfg_dir=`cygpath -w -a $mono_cfg_root`\\etc
1524 else
1525   mono_cfg_dir=$mono_cfg_root/etc
1527 AC_SUBST(mono_cfg_dir)
1529 AC_CONFIG_FILES([runtime/mono-wrapper],[chmod +x runtime/mono-wrapper])
1531 AC_CONFIG_COMMANDS([runtime/etc/mono/1.0/machine.config],
1532 [   depth=../../../..
1533     case $srcdir in
1534     [\\/$]* | ?:[\\/]* ) reldir=$srcdir ;;
1535     .) reldir=$depth ;;
1536     *) reldir=$depth/$srcdir ;;
1537     esac
1538     $ac_aux_dir/install-sh -d runtime/etc/mono/1.0
1539     cd runtime/etc/mono/1.0
1540     rm -f machine.config
1541     $LN_S $reldir/data/net_1_1/machine.config machine.config
1542     cd $depth
1543 ],[LN_S='$LN_S'])
1545 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/machine.config],
1546 [   depth=../../../..
1547     case $srcdir in
1548     [\\/$]* | ?:[\\/]* ) reldir=$srcdir ;;
1549     .) reldir=$depth ;;
1550     *) reldir=$depth/$srcdir ;;
1551     esac
1552     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
1553     cd runtime/etc/mono/2.0
1554     rm -f machine.config
1555     $LN_S $reldir/data/net_2_0/machine.config machine.config
1556     cd $depth
1557 ],[LN_S='$LN_S'])
1559 AC_OUTPUT([
1560 Makefile
1561 mint.pc
1562 mono.pc
1563 scripts/mono-nunit.pc
1564 mono/Makefile
1565 mono/utils/Makefile
1566 mono/metadata/Makefile
1567 mono/dis/Makefile
1568 mono/cil/Makefile
1569 mono/arch/Makefile
1570 mono/os/Makefile
1571 mono/os/win32/Makefile
1572 mono/os/unix/Makefile
1573 mono/arch/x86/Makefile
1574 mono/arch/amd64/Makefile
1575 mono/arch/hppa/Makefile
1576 mono/arch/ppc/Makefile
1577 mono/arch/sparc/Makefile
1578 mono/arch/s390/Makefile
1579 mono/arch/s390x/Makefile
1580 mono/arch/arm/Makefile
1581 mono/arch/alpha/Makefile
1582 mono/interpreter/Makefile
1583 mono/tests/Makefile
1584 mono/tests/tests-config
1585 mono/benchmark/Makefile
1586 mono/monoburg/Makefile
1587 mono/monograph/Makefile
1588 mono/io-layer/Makefile
1589 mono/handles/Makefile
1590 mono/mini/Makefile
1591 mono/profiler/Makefile
1592 scripts/Makefile
1593 man/Makefile
1594 web/Makefile
1595 docs/Makefile
1596 data/Makefile
1597 data/net_1_1/Makefile
1598 data/net_2_0/Makefile
1599 samples/Makefile
1600 support/Makefile
1601 data/config
1602 mono.spec
1603 tools/Makefile
1604 tools/locale-builder/Makefile
1605 runtime/Makefile
1609   case $prefix in
1610   NONE) prefix=/usr/local ;;
1611   esac
1612   case $exec_prefix in
1613   NONE | '${prefix}') exec_prefix=$prefix ;;
1614   esac
1616   echo "prefix=$exec_prefix" > $srcdir/$mcsdir/build/config.make
1617   echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $srcdir/$mcsdir/build/config.make
1620 echo "
1621         mcs source:  $mcs_topdir
1622         GC:          $gc
1623         ICU:         $enable_icu
1624         TLS:         $with_tls
1625         SIGALTSTACK: $with_sigaltstack
1626         Engine:      $jit_status
1627         2.0 Alpha:   $PREVIEW
1628         JNI support: $jdk_headers_found
1629         $disabled