Cleanup exception s390 handling; fix prolog length setting; correct test
[mono.git] / configure.in
blob956b2054122d9f15fa566ff4f0009c90b1965642
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(mono,1.1.2)
5 AM_MAINTAINER_MODE
7 AC_PROG_LN_S
9 dnl
10 dnl libgc checks
11 dnl
13 gc_headers=no
14 gc=included
15 use_included_gc=no
17 if test -d $srcdir/libgc ; then
18   gc_default=included
19 else
20   gc_default=boehm
24 # These are the flags that need to be stored in the mono.pc file for 
25 # compiling code that will embed Mono
27 libmono_cflags=""
28 libmono_ldflags=""
29 AC_SUBST(libmono_cflags)
30 AC_SUBST(libmono_ldflags)
32 dnl if linker handles the version script
33 no_version_script=no
35 # Set to yes if Unix sockets cannot be created in an anonymous namespace
36 need_link_unlink=no
38 # Thread configuration inspired by sleepycat's db
39 AC_MSG_CHECKING([host platform characteristics])
40 libgc_threads=no
41 case "$host" in
42         *-*-mingw*|*-*-cygwin*)
43                 platform_win32=yes
44                 AC_DEFINE(PLATFORM_WIN32,1,[Platform is Win32])
45                 CC="gcc -mno-cygwin -g"
46                 HOST_CC="gcc"
47                 # So libgc configure gets -mno-cygwin
48                 export CC
49 # latest libgc already defines GC_WIN32_THREADS
50 #               CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS -DWIN32_THREADS"
51                 CPPFLAGS="$CPPFLAGS -DWIN32_THREADS"
52                 libdl=
53                 libgc_threads=win32
54                 gc_default=included
55                 with_nptl=default
56                 with_sigaltstack=no
57                 LN_S=cp
58                 ;;
59         *-*-*netbsd*)
60                 platform_win32=no
61                 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
62                 libmono_cflags="-D_REENTRANT"
63                 LDFLAGS="$LDFLAGS -pthread"
64                 libmono_ldflags="-pthread"
65                 need_link_unlink=yes
66                 libdl=
67                 libgc_threads=no
68                 ;;
69 # these flags will work for all versions of -STABLE
71         *-*-*freebsd4*)
72                 platform_win32=no
73                 if test "x$PTHREAD_CFLAGS" = "x"; then
74                         CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
75                         libmono_cflags="-D_THREAD_SAFE"
76                 else
77                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
78                         libmono_cflags="$PTHREAD_CFLAGS"
79                 fi
80                 if test "x$PTHREAD_LIBS" = "x"; then
81                         LDFLAGS="$LDFLAGS -pthread"
82                         libmono_ldflags="-pthread"
83                 else
84                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
85                         libmono_ldflags="$PTHREAD_LIBS"
86                 fi
87                 need_link_unlink=yes
88                 AC_DEFINE(PTHREAD_POINTER_ID)
89                 libdl=
90                 libgc_threads=pthreads
91 # TLS isn't implemented at all on -STABLE
92                 with_nptl=no
93                 with_tls=pthread
94                 ;;
95 # older versions of -CURRENT will break with these flags but testing
96 # indicates these older versions won't run Mono anyway
98         *-*-*freebsd5*)
99                 platform_win32=no
100                 if test "x$PTHREAD_CFLAGS" = "x"; then
101                         CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
102                         libmono_cflags=
103                 else
104                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
105                         libmono_cflags="$PTHREAD_CFLAGS"
106                 fi
107                 if test "x$PTHREAD_LIBS" = "x"; then
108                         LDFLAGS="$LDFLAGS -lpthread"
109                         libmono_ldflags="-lpthread"
110                 else
111                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
112                         libmono_ldflags="$PTHREAD_LIBS"
113                 fi
114                 need_link_unlink=yes
115                 AC_DEFINE(PTHREAD_POINTER_ID)
116                 libdl=
117                 libgc_threads=pthreads
118 # TLS is only partially implemented on -CURRENT (compiler support
119 # but NOT library support)
121                 with_nptl=no
122                 with_tls=pthread
123                 ;;
124         *-*-*openbsd*)
125                 platform_win32=no
126                 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
127                 libmono_cflags="-D_THREAD_SAFE"
128                 LDFLAGS="$LDFLAGS -pthread"
129                 libmono_ldflags="-pthread"
130                 need_link_unlink=yes
131                 AC_DEFINE(PTHREAD_POINTER_ID)
132                 libdl=
133                 libgc_threads=pthreads
134                 ;;
135         *-*-linux*)
136                 platform_win32=no
137                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT"
138                 libmono_cflags="-D_REENTRANT"
139                 libmono_ldflags="-lpthread"
140                 libdl="-ldl"
141                 libgc_threads=pthreads
142                 ;;
143         *-*-hpux*)
144                 platform_win32=no
145                 CPPFLAGS="$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
146                 CFLAGS="$CFLAGS +ESdbgasm"
147                 LDFLAGS="$LDFLAGS -z"
148                 libmono_cflags="-D_REENTRANT"
149                 libmono_ldflags="-lpthread"
150                 libgc_threads=pthreads
151                 need_link_unlink=yes
152                 ;;
153         *-*-solaris*)
154                 platform_win32=no
155                 CPPFLAGS="$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT"
156                 need_link_unlink=yes
157                 libmono_cflags="-D_REENTRANT"
158                 libgc_threads=pthreads
159                 ;;
160         *-*-darwin*)
161                 platform_win32=no
162                 CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE -DGC_MACOSX_THREADS"
163                 libmono_cflags="-D_THREAD_SAFE"
164                 LDFLAGS="$LDFLAGS -pthread"
165                 libmono_ldflags="-pthread"
166                 need_link_unlink=yes
167                 AC_DEFINE(PTHREAD_POINTER_ID)
168                 AC_DEFINE(USE_MACH_SEMA)
169                 no_version_script=yes
170                 libdl=
171                 libgc_threads=pthreads
172                 ;;
173         *)
174                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
175                 platform_win32=no
176                 libdl="-ldl"
177                 ;;
178 esac
179 AC_MSG_RESULT(ok)
181 if test x$need_link_unlink = xyes; then
182    AC_DEFINE(NEED_LINK_UNLINK, 1, [Define if Unix sockets cannot be created in an anonymous namespace])
185 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
187 AC_CHECK_TOOL(CC, gcc, gcc)
188 AC_PROG_CC
189 AM_PROG_CC_STDC
190 AC_PROG_INSTALL
191 dnl We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
192 : ${CCAS='$(CC)'}
193 # Set ASFLAGS if not already set.
194 : ${CCASFLAGS='$(CFLAGS)'}
195 AC_SUBST(CCAS)
196 AC_SUBST(CCASFLAGS)
198 AC_CHECK_PROG(BISON, bison,yes,no)
199 if test "x$BISON" = "xno";
200 then
201         AC_MSG_ERROR([You need to install bison])
204 dnl may require a specific autoconf version
205 dnl AC_PROG_CC_FOR_BUILD
206 dnl CC_FOR_BUILD not automatically detected
207 CC_FOR_BUILD=$CC
208 BUILD_EXEEXT=
209 if test "x$cross_compiling" = "xyes"; then
210         CC_FOR_BUILD=cc
211         BUILD_EXEEXT=""
213 AC_SUBST(CC_FOR_BUILD)
214 AC_SUBST(HOST_CC)
215 AC_SUBST(BUILD_EXEEXT)
217 # Set STDC_HEADERS
218 AC_HEADER_STDC
219 AC_LIBTOOL_WIN32_DLL
220 AM_PROG_LIBTOOL
222 # Test whenever ld supports -version-script
223 AC_PROG_LD
224 AC_PROG_LD_GNU
225 if test "x$lt_cv_prog_gnu_ld" = "xno"; then
226    no_version_script=yes
229 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
231 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h)
233 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
235 AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
237 # for mono/metadata/debug-symfile.c
238 AC_CHECK_HEADERS(elf.h)
240 # for mono/dis
241 AC_CHECK_HEADERS(wchar.h)
243 # not 64 bit clean in cross-compile
244 AC_CHECK_SIZEOF(void *, 4)
246 WARN=''
247 if test x"$GCC" = xyes; then
248         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
249                 # The runtime code does not respect ANSI C strict aliasing rules
250                 CFLAGS="$CFLAGS -fno-strict-aliasing"
251 else
252         # The Sun Forte compiler complains about inline functions that access static variables
253         # so disable all inlining.
254         case "$host" in
255         *-*-solaris*)
256                 CFLAGS="$CFLAGS -Dinline="
257                 ;;
258         esac
260 CFLAGS="$CFLAGS -g $WARN"
262 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
263 if test "x$PKG_CONFIG" = "xno"; then
264         AC_MSG_ERROR([You need to install pkg-config])
267 dnl for use on the build system
268 dnl pkg-config is stupid
269 BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
270 BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
271 AC_SUBST(BUILD_GLIB_CFLAGS)
272 AC_SUBST(BUILD_GLIB_LIBS)
274 PKG_PATH=
275 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
276         if test x$with_crosspkgdir = "x"; then
277                 if test -s $PKG_CONFIG_PATH; then
278                         PKG_PATH=$PKG_CONFIG_PATH
279                 fi
280         else
281                 PKG_PATH=$with_crosspkgdir
282                 PKG_CONFIG_PATH=$PKG_PATH
283                 export PKG_CONFIG_PATH
284         fi
287 ## Versions of dependencies
288 GLIB_REQUIRED_VERSION=1.3.11
290 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
292 GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
293 GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
294 GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
295 GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
297 AC_SUBST(GLIB_CFLAGS)
298 AC_SUBST(GLIB_LIBS)
299 AC_SUBST(GMODULE_CFLAGS)
300 AC_SUBST(GMODULE_LIBS)
302 if test x$platform_win32 = xyes; then   
303    AC_MSG_CHECKING(for cygwin glib2-dev package)
304    if [ cygcheck --f /usr/lib/libglib-2.0.dll.a | grep -q glib2-devel ]; then
305       AC_MSG_RESULT(found)
306           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.])
307    else
308       AC_MSG_RESULT(not found, ok)
309    fi
311    AC_MSG_CHECKING(for broken gwin32.h)
312    glib_include=`$PKG_CONFIG --cflags-only-I glib-2.0 | sed -e 's/ -I.*//g' | sed -e 's/-I//g'`
313    if test -f $glib_include/glib/gwin32.h; then
314           if [ grep ftruncate $glib_include/glib/gwin32.h | grep -q define ]; then
315                  AC_MSG_RESULT(failed)
316                  hashmark='#'
317                  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.])
318           fi
319    fi
320    AC_MSG_RESULT(ok)
323 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
325 # Enable support for fast thread-local storage
326 # Some systems have broken support, so we allow to disable it.
327 AC_ARG_WITH(tls, [  --with-tls=__thread,pthread       select Thread Local Storage implementation],[],[with_tls=__thread])
329 # Kept for compatibility
330 AC_ARG_WITH(nptl, [  --with-nptl=yes,no      deprecated, use --with-tls instead],[],[with_nptl=default])
332 if test "x$with_nptl" != "xdefault"; then
333    if test "x$with_nptl" = "xyes"; then
334       AC_MSG_WARN([--with-nptl=yes is deprecated, use --with-tls=__thread option instead.])
335           with_tls=__thread
336    fi
337    if test "x$with_nptl" = "xno"; then
338       AC_MSG_WARN([--with-nptl=no is deprecated, use --with-tls=pthread option instead.])
339           with_tls=pthread
340    fi
343 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
344 # This does not work on some platforms (bug #55253)
345 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack],[],[with_sigaltstack=no])
347 # assembly bundle support, see metadata/make-bundle.pl for more info
348 AC_ARG_WITH(bundle, [  --with-bundle=bundle_template],[
349         BUNDLE_FILE=$with_bundle
350         AC_SUBST(BUNDLE_FILE)
351         AC_DEFINE(WITH_BUNDLE)
352 ],[with_bundle=no])
353 AM_CONDITIONAL(WITH_BUNDLE, test x$with_bundle != xno)
355 LIBGC_CFLAGS=
356 LIBGC_LIBS=
357 LIBGC_STATIC_LIBS=
358 libgc_dir=
359 case "x$gc" in
360         xboehm|xbohem|xyes)
361                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
362                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
364                 if test "x$found_boehm" != "xyes"; then
365                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
366                 fi
367                 if test "x$gc_headers" != "xyes"; then
368                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
369                 fi
371                 AC_DEFINE(HAVE_BOEHM_GC)
372                 AC_SUBST(HAVE_BOEHM_GC)
373                 LIBGC_LIBS="-lgc $libdl"
374                 LIBGC_STATIC_LIBS="$LIBGC_LIBS"
376                 # AC_CHECK_FUNCS does not work for some reason...
377                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
378                 if test "x$found_gcj_malloc" = "xyes"; then
379                         AC_DEFINE(HAVE_GC_GCJ_MALLOC)
380                 fi
381                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
382                 if test "x$found_gc_enable" = "xyes"; then
383                         AC_DEFINE(HAVE_GC_ENABLE)
384                 fi
385                 ;;
387         xincluded)
388                 AC_CONFIG_SUBDIRS(libgc)
390                 found_boehm=yes
391                 gc_headers=yes
392                 use_included_gc=yes
393                 libgc_dir=libgc
395                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
396                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
397                 LIBGC_STATIC_LIBS='$(top_builddir)/libgc/libmonogc-static.la'
399                 AC_DEFINE(HAVE_BOEHM_GC)
400                 AC_SUBST(HAVE_BOEHM_GC)
402                 AC_DEFINE(HAVE_GC_H)
403                 AC_DEFINE(USE_INCLUDED_LIBGC)
405                 # The included libgc contains GCJ support
406                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
407                 AC_DEFINE(HAVE_GC_ENABLE)
408                 ;;
410         xnone)
411                 AC_MSG_WARN("Compiling mono without GC.")
412                 ;;
413         *)
414                 AC_MSG_ERROR([Invalid argument to --with-gc.])
415                 ;;
416 esac
419 # tell libgc/configure about what we want
420 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
422 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
423 AC_SUBST(LIBGC_CFLAGS)
424 AC_SUBST(LIBGC_LIBS)
425 AC_SUBST(LIBGC_STATIC_LIBS)
426 AC_SUBST(libgc_dir)
429 dnl End of libgc checks
432 if test x$platform_win32 = xno; then
434         dnl ******************************************************************
435         dnl *** Checks for the IKVM JNI interface library                  ***
436         dnl ******************************************************************
437         AC_ARG_WITH(ikvm-jni, [  --with-ikvm-jni=yes,no  build the IKVM JNI interface library],[with_ikvm_jni=$withval],[with_ikvm_jni=yes])
438         AC_ARG_WITH(jdk, [  --with-jdk=DIRECTORY    Use JDK from DIRECTORY],[with_jdk_dir=$withval],[with_jdk_dir=])
440         ikvm_jni_dir=
441         if test x$with_ikvm_jni = xyes; then
442                 AC_MSG_CHECKING([JDK headers])
444                 if test x$with_jdk_dir = x; then
445                         # Try JAVA_HOME variable
446                         if test x$JAVA_HOME != x; then
447                                 with_jdk_dir=$JAVA_HOME
448                         fi
449                 fi
450         
451                 jdk_platform=
452                 if test -d $with_jdk_dir/include; then
453                         jdk_headers_found=yes
455                         if test -d $with_jdk_dir/include/linux; then
456                                 jdk_platform=linux
457                         else
458                         if test -d $with_jdk_dir/include/solaris; then
459                                 jdk_platform=solaris
460                         else
461                         if test -f $with_jdk_dir/include/jni_md.h; then
462                                 # GNU Classpath sources
463                                 jdk_platform=
464                         else
465                                 jdk_headers_found=no
466                         fi
467                         fi
468                         fi
469                 else
470                         jdk_headers_found=no
471                 fi
473                 if test x$jdk_headers_found = xyes; then
474                         AC_MSG_RESULT($with_jdk_dir/include $with_jdk_dir/include/$jdk_platform)
475                 else
476                         AC_MSG_RESULT(not found)
477                 fi
479                 if test x$jdk_headers_found = xyes; then
480                         ikvm_jni_dir=ikvm-jni
481                         IKVM_JNI_CFLAGS="-I$with_jdk_dir/include -I$with_jdk_dir/include/$jdk_platform"
482                 fi
483         fi
485         AC_SUBST(ikvm_jni_dir)
486         AC_SUBST(IKVM_JNI_CFLAGS)
488         AC_CHECK_FUNCS(getgrgid_r)
489         AC_CHECK_FUNCS(getgrnam_r)
490         AC_CHECK_FUNCS(getpwnam_r)
491         AC_CHECK_FUNCS(getpwuid_r)
492         AC_CHECK_FUNCS(getresuid)
493         AC_CHECK_FUNCS(setresuid)
494         AC_CHECK_FUNCS(kqueue)
496         dnl ******************************************************************
497         dnl *** Check for large file support                               ***
498         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
499         dnl ******************************************************************
500         
501         # Check that off_t can represent 2**63 - 1 correctly, working around
502         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
503         # CPPFLAGS and sets $large_offt to yes if the test succeeds
504         large_offt=no
505         AC_DEFUN(LARGE_FILES, [
506                 large_CPPFLAGS=$CPPFLAGS
507                 CPPFLAGS="$CPPFLAGS $1"
508                 AC_TRY_RUN([
509                         #include <sys/types.h>
511                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
513                         int main(void) {
514                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
515                                                (BIG_OFF_T%2147483647==1));
516                                 if(big_off_t) {
517                                         exit(0);
518                                 } else {
519                                         exit(1);
520                                 }
521                         }
522                 ], [
523                         AC_MSG_RESULT(ok)
524                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
525                         large_CPPFLAGS="$large_CPPFLAGS $1"
526                         large_offt=yes
527                 ], [
528                         AC_MSG_RESULT(no)
529                 ], "")
530                 CPPFLAGS=$large_CPPFLAGS
531         ])
533         AC_MSG_CHECKING(if off_t is 64 bits wide)
534         LARGE_FILES("")
535         if test $large_offt = no; then
536                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
537                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
538         fi
539         if test $large_offt = no; then
540                 AC_MSG_WARN([No 64 bit file size support available])
541         fi
542         
543         dnl *****************************
544         dnl *** Checks for libsocket  ***
545         dnl *****************************
546         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
548         dnl *******************************
549         dnl *** Checks for MSG_NOSIGNAL ***
550         dnl *******************************
551         AC_MSG_CHECKING(for MSG_NOSIGNAL)
552         AC_TRY_COMPILE([#include <sys/socket.h>], [
553                 int f = MSG_NOSIGNAL;
554         ], [
555                 # Yes, we have it...
556                 AC_MSG_RESULT(yes)
557                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
558         ], [
559                 # We'll have to use signals
560                 AC_MSG_RESULT(no)
561         ])
563         dnl *****************************
564         dnl *** Checks for SOL_IP     ***
565         dnl *****************************
566         AC_MSG_CHECKING(for SOL_IP)
567         AC_TRY_COMPILE([#include <netdb.h>], [
568                 int level = SOL_IP;
569         ], [
570                 # Yes, we have it...
571                 AC_MSG_RESULT(yes)
572                 AC_DEFINE(HAVE_SOL_IP)
573         ], [
574                 # We'll have to use getprotobyname
575                 AC_MSG_RESULT(no)
576         ])
578         dnl *****************************
579         dnl *** Checks for SOL_IPV6     ***
580         dnl *****************************
581         AC_MSG_CHECKING(for SOL_IPV6)
582         AC_TRY_COMPILE([#include <netdb.h>], [
583                 int level = SOL_IPV6;
584         ], [
585                 # Yes, we have it...
586                 AC_MSG_RESULT(yes)
587                 AC_DEFINE(HAVE_SOL_IPV6)
588         ], [
589                 # We'll have to use getprotobyname
590                 AC_MSG_RESULT(no)
591         ])
593         dnl *****************************
594         dnl *** Checks for SOL_TCP    ***
595         dnl *****************************
596         AC_MSG_CHECKING(for SOL_TCP)
597         AC_TRY_COMPILE([#include <netdb.h>], [
598                 int level = SOL_TCP;
599         ], [
600                 # Yes, we have it...
601                 AC_MSG_RESULT(yes)
602                 AC_DEFINE(HAVE_SOL_TCP)
603         ], [
604                 # We'll have to use getprotobyname
605                 AC_MSG_RESULT(no)
606         ])
608         dnl *****************************
609         dnl *** Checks for IP_PKTINFO ***
610         dnl *****************************
611         AC_MSG_CHECKING(for IP_PKTINFO)
612         AC_TRY_COMPILE([#include <netdb.h>], [
613                 int level = IP_PKTINFO;
614         ], [
615                 # Yes, we have it...
616                 AC_MSG_RESULT(yes)
617                 AC_DEFINE(HAVE_IP_PKTINFO)
618         ], [
619                 AC_MSG_RESULT(no)
620         ])
622         dnl *********************************
623         dnl *** Check for struct ip_mreqn ***
624         dnl *********************************
625         AC_MSG_CHECKING(for struct ip_mreqn)
626         AC_TRY_COMPILE([#include <netinet/in.h>], [
627                 struct ip_mreqn mreq;
628                 mreq.imr_address.s_addr = 0;
629         ], [
630                 # Yes, we have it...
631                 AC_MSG_RESULT(yes)
632                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
633         ], [
634                 # We'll just have to try and use struct ip_mreq
635                 AC_MSG_RESULT(no)
636                 AC_MSG_CHECKING(for struct ip_mreq)
637                 AC_TRY_COMPILE([#include <netinet/in.h>], [
638                         struct ip_mreq mreq;
639                         mreq.imr_interface.s_addr = 0;
640                 ], [
641                         # Yes, we have it...
642                         AC_MSG_RESULT(yes)
643                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
644                 ], [
645                         # No multicast support
646                         AC_MSG_RESULT(no)
647                 ])
648         ])
649         
650         dnl **********************************
651         dnl *** Check for gethostbyname2_r ***
652         dnl **********************************
653         AC_MSG_CHECKING(for gethostbyname2_r)
654                 AC_TRY_LINK([#include <netdb.h>], [
655                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
656         ], [
657                 # Yes, we have it...
658                 AC_MSG_RESULT(yes)
659                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R)
660         ], [
661                 AC_MSG_RESULT(no)
662         ])
664         dnl *****************************
665         dnl *** Checks for libnsl     ***
666         dnl *****************************
667         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
669         AC_CHECK_FUNCS(inet_pton inet_aton)
671         dnl ***********************************************
672         dnl *** Checks for size of sockaddr_un.sun_path ***
673         dnl ***********************************************
674         # AC_CHECK_SIZEOF can't cope with struct members :-(
675         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
676         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
677                 [AC_TRY_RUN([
678                         #include <sys/types.h>
679                         #include <stdio.h>
680                         #include <sys/un.h>
682                         int main(void) {
683                                 struct sockaddr_un sock_un;
684                                 FILE *f=fopen("conftestval", "w");
685                                 if(!f) exit(1);
686                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
687                                 exit(0);
688                         }
689                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
690                    cv_mono_sizeof_sunpath=0,
691                    cv_mono_sizeof_sunpath=0)])dnl
692         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
693         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
695         dnl *************************************
696         dnl *** Checks for zero length arrays ***
697         dnl *************************************
698         AC_MSG_CHECKING(whether $CC supports zero length arrays)
699         AC_TRY_COMPILE([
700                 struct s {
701                         int  length;
702                         char data [0];
703                 };
704         ], [], [
705                 AC_MSG_RESULT(yes)
706                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 0)
707         ], [
708                 AC_MSG_RESULT(no)
709                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 1)
710         ])
712         dnl *****************************
713         dnl *** Checks for libxnet    ***
714         dnl *****************************
715         case "${host}" in
716                 *solaris* )
717                         AC_MSG_CHECKING(for Solaris XPG4 support)
718                         if test -f /usr/lib/libxnet.so; then
719                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
720                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
721                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
722                                 LIBS="$LIBS -lxnet"
723                                 AC_MSG_RESULT(yes)
724                         else
725                                 AC_MSG_RESULT(no)
726                         fi
728                         if test "$GCC" = "yes"; then
729                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
730                         fi
731                 ;;
732         esac
734         dnl *****************************
735         dnl *** Checks for libpthread ***
736         dnl *****************************
737 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
738 # and libpthread does not exist
740         case "${host}" in
741                 *-*-*freebsd4*)
742                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
743                 ;;
744                 *)
745                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
746                 ;;
747         esac
748         AC_CHECK_HEADERS(pthread.h)
749         AC_CHECK_FUNCS(pthread_mutex_timedlock)
750         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
751         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
752         AC_TRY_COMPILE([ #include <pthread.h>], [
753                 pthread_mutexattr_t attr;
754                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
755         ], [
756                 AC_MSG_RESULT(ok)
757         ], [
758                 AC_MSG_RESULT(no)
759                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
760                 AC_DEFINE(USE_MONO_MUTEX)
761         ])
762         AC_CHECK_FUNCS(pthread_attr_setstacksize)
764         dnl ***********************************
765         dnl *** Checks for working __thread ***
766         dnl ***********************************
767         AC_MSG_CHECKING(for working __thread)
768         if test "x$with_tls" != "x__thread"; then
769                 AC_MSG_RESULT(disabled)
770         else
771                 AC_TRY_RUN([
772                         #include <pthread.h>
774                         __thread int i;
775                         static int res1, res2;
777                         void thread_main (void *arg)
778                         {
779                                 i = arg;
780                                 sleep (1);
781                                 if (arg == 1)
782                                         res1 = (i == arg);
783                                 else
784                                         res2 = (i == arg);
785                         }
787                         int main () {
788                                 pthread_t t1, t2;
790                                 i = 5;
792                                 pthread_create (&t1, NULL, thread_main, 1);
793                                 pthread_create (&t2, NULL, thread_main, 2);
795                                 pthread_join (t1, NULL);
796                                 pthread_join (t2, NULL);
798                                 return !(res1 + res2 == 2);
799                         }
800                 ], [
801                                 AC_MSG_RESULT(yes)
802                 ], [
803                                 AC_MSG_RESULT(no)
804                                 with_tls=pthread
805                 ])
806         fi
808         dnl **************************************
809         dnl *** Checks for working sigaltstack ***
810         dnl **************************************
811         AC_MSG_CHECKING(for working sigaltstack)
812         if test "x$with_sigaltstack" != "xyes"; then
813                 AC_MSG_RESULT(disabled)
814         else
815                 AC_TRY_RUN([
816                         #include <stdio.h>
817                         #include <stdlib.h>
818                         #include <unistd.h>
819                         #include <signal.h>
820                         #include <pthread.h>
821                         #include <sys/wait.h>
823                         static void
824                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
825                         {
826                                 exit (0);
827                         }
829                         static void *
830                         loop (void *ignored)
831                         {
832                                 char *ptr = NULL;
834                                 *ptr = 0;
835                                 return NULL;
836                         }
838                         static void
839                         child ()
840                         {
841                                 struct sigaction sa;
842                                 struct sigaltstack sas;
843                                 pthread_t id;
844                                 pthread_attr_t attr;
846                                 sa.sa_sigaction = sigsegv_signal_handler;
847                                 sigemptyset (&sa.sa_mask);
848                                 sa.sa_flags = SA_SIGINFO | SA_STACK;
849                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
850                                         perror ("lala");
851                                         return;
852                                 }
854                                 sas.ss_sp = malloc (SIGSTKSZ);
855                                 sas.ss_size = SIGSTKSZ;
856                                 sas.ss_flags = SS_ONSTACK;
857                                 if (sigaltstack (&sas, NULL) == -1) {
858                                         perror ("lala");
859                                         return;
860                                 }
862                                 pthread_attr_init (&attr);
863                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
864                                         printf ("failed\n");
865                                         return;
866                                 }
868                                 sleep (100);
869                         }
871                         int
872                         main ()
873                         {
874                                 pid_t son;
875                                 int status;
876                                 int i;
878                                 son = fork ();
879                                 if (son == -1) {
880                                         return 1;
881                                 }
883                                 if (son == 0) {
884                                         child ();
885                                         return 0;
886                                 }
888                                 for (i = 0; i < 3; ++i) {
889                                         sleep (1);
890                                         waitpid (son, &status, WNOHANG);
891                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
892                                                 return 0;
893                                 }
895                                 kill (son, SIGKILL);
896                                 return 1;
897                         }
899                 ], [
900                                 AC_MSG_RESULT(yes)
901                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
902                 ], [
903                                 with_sigaltstack=no
904                                 AC_MSG_RESULT(no)
905                 ])
906         fi
908         dnl ********************************
909         dnl *** Checks for semaphore lib ***
910         dnl ********************************
911         # 'Real Time' functions on Solaris
912         # posix4 on Solaris 2.6
913         # pthread (first!) on Linux
914         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
916         dnl ********************************
917         dnl *** Checks for timezone stuff **
918         dnl ********************************
919         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
920                 AC_TRY_COMPILE([
921                         #include <time.h>
922                         ], [
923                         struct tm tm;
924                         tm.tm_gmtoff = 1;
925                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
926         if test $ac_cv_struct_tm_gmtoff = yes; then
927                 AC_DEFINE(HAVE_TM_GMTOFF)
928         else
929                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
930                         AC_TRY_COMPILE([
931                                 #include <time.h>
932                         ], [
933                                 timezone = 1;
934                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
935                 if test $ac_cv_var_timezone = yes; then
936                         AC_DEFINE(HAVE_TIMEZONE)
937                 else
938                         AC_ERROR(unable to find a way to determine timezone)
939                 fi
940         fi
942         dnl *********************************
943         dnl *** Checks for math functions ***
944         dnl *********************************
945         LIBS="$LIBS -lm";
946         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
947                 AC_TRY_LINK([#include <math.h>], 
948                 [ finite(0.0); ], 
949                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
950                 AC_MSG_RESULT(no)))
951         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
952                 AC_TRY_LINK([#include <math.h>], 
953                 [ isfinite(0.0); ], 
954                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
955                 AC_MSG_RESULT(no)))
957         dnl ****************************************************************
958         dnl *** Checks for working poll() (macosx defines it but doesn't ***
959         dnl *** have it in the library (duh))                            ***
960         dnl ****************************************************************
961         AC_CHECK_FUNCS(poll)
963         dnl *************************
964         dnl *** Check for signbit ***
965         dnl *************************
966         AC_MSG_CHECKING(for signbit)
967         AC_TRY_LINK([#include <math.h>], [
968                 int s = signbit(1.0);
969         ], [
970                 AC_MSG_RESULT(yes)
971                 AC_DEFINE(HAVE_SIGNBIT)
972         ], [
973                 AC_MSG_RESULT(no)
974         ]) 
976         dnl *********************
977         dnl *** Check for AIO ***
978         dnl *********************
979         AC_MSG_CHECKING([for SIGEV_THREAD definition])
980         dnl Some systems (FreeBSD at least) may have aio_read
981         dnl but don't support/define SIGEV_THREAD.
982         AC_TRY_COMPILE([
983         #include <sys/signal.h>
984         ],[
985         int x = SIGEV_THREAD;
986         ],[
987                 ac_cv_c_sigev_thread=yes
988                 AC_MSG_RESULT(yes)
989         ],[
990                 AC_MSG_RESULT(no)
991         ])
993         if test "$ac_cv_c_sigev_thread" = "yes" ; then
994                 AC_CHECK_HEADERS(aio.h sys/aio.h)
995                 AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
996                 SIGVAL_PTR="undefined"
997                 if test "$ac_cv_header_aio_h" = "yes" -o "$ac_cv_header_sys_aio_h" = "yes" ; then
998                         AC_CHECK_MEMBER(union sigval.sigval_ptr,SIGVAL_PTR="sigval_ptr",, [
999                                         #include <sys/signal.h>
1000                                         ])
1001                         AC_CHECK_MEMBER(union sigval.sival_ptr,SIGVAL_PTR="sival_ptr",, [
1002                                         #include <sys/signal.h>
1003                                         ])
1004                         if test "$SIGVAL_PTR" = "undefined" ; then
1005                                 AC_MSG_ERROR([Unable to detect field name in 'union sigval'])
1006                         fi
1007                 fi
1008                 AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
1009         fi
1010 else
1011         jdk_headers_found=no
1012         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
1013         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
1014         AC_CHECK_LIB(ole32, main, LIBS="$LIBS -lole32", AC_ERROR(bad mingw install?))
1016         dnl *********************************
1017         dnl *** Check for struct ip_mreqn ***
1018         dnl *********************************
1019         AC_MSG_CHECKING(for struct ip_mreqn)
1020         AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1021                 struct ip_mreqn mreq;
1022                 mreq.imr_address.s_addr = 0;
1023         ], [
1024                 # Yes, we have it...
1025                 AC_MSG_RESULT(yes)
1026                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
1027         ], [
1028                 # We'll just have to try and use struct ip_mreq
1029                 AC_MSG_RESULT(no)
1030                 AC_MSG_CHECKING(for struct ip_mreq)
1031                 AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1032                         struct ip_mreq mreq;
1033                         mreq.imr_interface.s_addr = 0;
1034                 ], [
1035                         # Yes, we have it...
1036                         AC_MSG_RESULT(yes)
1037                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
1038                 ], [
1039                         # No multicast support
1040                         AC_MSG_RESULT(no)
1041                 ])
1042         ])
1045 dnl socklen_t check
1046 AC_MSG_CHECKING(for socklen_t)
1047 AC_TRY_COMPILE([
1048 #include <sys/types.h>
1049 #include <sys/socket.h>
1051   socklen_t foo;
1053 ac_cv_c_socklen_t=yes
1054         AC_DEFINE(HAVE_SOCKLEN_T)
1055         AC_MSG_RESULT(yes)
1057         AC_MSG_RESULT(no)
1060 AC_MSG_CHECKING(for array element initalizer support)
1061 AC_TRY_COMPILE([#include <sys/socket.h>], [
1062         const int array[] = {[1] = 2,};
1063 ], [
1064         # Yes, we have it...
1065         AC_MSG_RESULT(yes)
1066         AC_DEFINE(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
1067 ], [
1068         # We'll have to use signals
1069         AC_MSG_RESULT(no)
1072 AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
1073         # Simply calling trunc (0.0) is no good since gcc will optimize the call away
1074         AC_TRY_LINK([#include <math.h>], 
1075         [ static void *p = &trunc; ],
1076         [
1077                 AC_DEFINE(HAVE_TRUNC) 
1078                 AC_MSG_RESULT(yes)
1079                 ac_cv_trunc=yes
1080         ],
1081         AC_MSG_RESULT(no)))
1083 if test "x$ac_cv_truncl" != "xyes"; then
1084    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
1087 dnl ****************************
1088 dnl *** Look for /dev/random ***
1089 dnl ****************************
1091 AC_MSG_CHECKING([if usage of random device is requested])
1092 AC_ARG_ENABLE(dev-random,
1093 [  --disable-dev-random    disable the use of the random device],
1094 try_dev_random=$enableval, try_dev_random=yes)
1095 AC_MSG_RESULT($try_dev_random)
1097 case "{$target}" in
1098     *-openbsd*)
1099     NAME_DEV_RANDOM="/dev/srandom"
1100     ;;
1102 dnl Win32 does not have /dev/random, they have their own method...
1104     *-*-mingw*|*-*-cygwin*)
1105     ac_cv_have_dev_random=no
1106     ;;
1108 dnl Everywhere else, it's /dev/random
1110     *)
1111     NAME_DEV_RANDOM="/dev/random"
1112     ;;
1113 esac
1115 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
1117 dnl Now check if the device actually exists
1119 if test "x$try_dev_random" = "xyes"; then
1120     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1121     [if test -r "$NAME_DEV_RANDOM" ; then
1122         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1123     if test "x$ac_cv_have_dev_random" = "xyes"; then
1124         AC_DEFINE(HAVE_CRYPT_RNG)
1125     fi
1126 else
1127     AC_MSG_CHECKING(for random device)
1128     ac_cv_have_dev_random=no
1129     AC_MSG_RESULT(has been disabled)
1132 if test "x$platform_win32" = "xyes"; then
1133     AC_DEFINE(HAVE_CRYPT_RNG)
1136 if test "x$ac_cv_have_dev_random" = "xno" \
1137     && test "x$platform_win32" = "xno"; then
1138     AC_MSG_WARN([[
1140 *** A system-provided entropy source was not found on this system.
1141 *** Because of this, the System.Security.Cryptography random number generator
1142 *** will throw a NotImplemented exception.
1144 *** If you are seeing this message, and you know your system DOES have an
1145 *** entropy collection in place, please contact <crichton@gimp.org> and
1146 *** provide information about the system and how to access the random device.
1148 *** Otherwise you can install either egd or prngd and set the environment
1149 *** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
1150 ***]])
1153 AC_MSG_CHECKING([if inter-process shared handles are requested])
1154 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
1155 AC_MSG_RESULT($try_shared_handles)
1156 if test "x$try_shared_handles" != "xyes"; then
1157         AC_DEFINE(DISABLE_SHARED_HANDLES)
1158         AC_SUBST(DISABLE_SHARED_HANDLES)
1162 # ICU 
1164 ICU_CFLAGS=""
1165 ICU_LIBS=""
1166 enable_icu=no
1168 probe_icu=true
1169 AC_ARG_WITH(icu, [  --with-icu=yes/no],
1170         if test x$with_icu = xno; then
1171            probe_icu=false;
1172            AC_MSG_RESULT(Will not probe for ICU)
1173         fi
1176 if $probe_icu; then
1177         AC_PATH_PROG(ICU_CONFIG, icu-config, no)
1178         if test "x$ICU_CONFIG" = "xno" -o ! -x "$ICU_CONFIG"; then
1179                 AC_MSG_WARN([Only invariant locale available; install ICU for I18N support])
1180                 enable_icu="no, if you want full i18n support download it from: http://oss.software.ibm.com/icu/index.html"
1181         else
1182                 enable_icu="yes. Version: `$ICU_CONFIG --version`"
1183                 AC_DEFINE(HAVE_ICU)
1184                 ICU_CFLAGS=`$ICU_CONFIG --cppflags`
1185                 ICU_LIBS=`$ICU_CONFIG --ldflags`
1186         fi
1188 AC_SUBST(ICU_CFLAGS)
1189 AC_SUBST(ICU_LIBS)
1191 TARGET="unknown"
1192 ACCESS_UNALIGNED="yes"
1194 JIT_SUPPORTED=no
1195 LIBC="libc.so.6"
1196 INTL="libc.so.6"
1198 jit_wanted=false
1199 case "$host" in
1200 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
1201 #               TARGET=MIPS;
1202 #               ACCESS_UNALIGNED="no"
1203 #               ;;
1204         i*86-*-*)
1205                 TARGET=X86;
1206                 arch_target=x86;
1207                 JIT_SUPPORTED=yes
1208                 jit_wanted=true
1209                 ;;
1210         x86_64-*-* | amd64-*-*)
1211                 TARGET=AMD64;
1212                 arch_target=amd64;
1213                 JIT_SUPPORTED=yes
1214                 jit_wanted=true
1215                 ;;
1216         sparc*-*-*)
1217                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
1218                    TARGET=SPARC64
1219                 else
1220                         TARGET=SPARC
1221                 fi
1222                 arch_target=sparc;
1223                 JIT_SUPPORTED=yes
1224                 ACCESS_UNALIGNED="no"
1225                 LIBC="libc.so"
1226                 INTL="libintl.so"
1227                 jit_wanted=true
1228                 ;;
1229        alpha*-*-linux* | alpha*-*-osf*)
1230                 TARGET=ALPHA;
1231                 ACCESS_UNALIGNED="no"
1232                 JIT_SUPPORTED=no
1233                 arch_target=alpha;
1234                ;;
1235 #       ia64-*-linux* | ia64-*-hpux*)
1236 #               TARGET=IA64;
1237 #               arch_target=ia64;
1238 #               JIT_SUPPORTED=no;
1239 #               ACCESS_UNALIGNED="no";
1240 #               case "$host_os" in
1241 #                       linux*) LIBC="libc.so.6.1";;
1242 #                       hpux*)  LIBC="libc.so.1";;
1243 #               esac
1244 #               ;;
1245 #       m68k-*-linux*)
1246 #               TARGET=M68K
1247 #               ;;
1248         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
1249                 TARGET=HPPA;
1250                 arch_target=hppa; 
1251                 LIBC="libc.sl"
1252                 ACCESS_UNALIGNED="no"
1253                 ;;
1254         hppa*linux*)
1255                 TARGET=HPPA;
1256                 arch_target=hppa; 
1257                 ACCESS_UNALIGNED="no"
1258                 ;;
1259         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
1260         powerpc-*-sysv* | powerpc-*-darwin*)
1261                 TARGET=POWERPC;
1262                 arch_target=ppc;
1263                 JIT_SUPPORTED=yes
1264                 jit_wanted=true
1265                 ;;
1266         arm-*-linux-* | armv4l-*-linux-*)
1267                 TARGET=ARM;
1268                 arch_target=arm;
1269                 ACCESS_UNALIGNED="no"
1270                 ;;
1271         s390-*-linux*)
1272                 TARGET=S390;
1273                 arch_target=s390;
1274                 ACCESS_UNALIGNED="no"
1275                 JIT_SUPPORTED=yes
1276                 ;;
1277         s390x-*-linux*)
1278                 TARGET=S390x;
1279                 arch_target=s390x;
1280                 ACCESS_UNALIGNED="no"
1281                 JIT_SUPPORTED=yes
1282                 ;;
1283 esac
1285 AC_ARG_WITH(jit, [  --with-jit=yes,no       If you want to build scripts that default to the JIT],[
1286         jit_wanted=true
1289 USEJIT=false
1290 if test x$JIT_SUPPORTED = xyes; then
1291    if $jit_wanted; then
1292       USEJIT=true
1293       jit_status="Building and using the JIT"
1294    else
1295       jit_status="Building the JIT, defaulting to the interpreter"
1296    fi
1297 else
1298    jit_status="interpreter"
1301 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
1303 libsuffix=".so"
1305 case "$host" in
1306      powerpc-*-darwin*)
1307         libsuffix=".dylib"
1308         LIBC="libc.dylib"
1309         INTL="libintl.dylib"
1310         ;;
1311      *-*-*netbsd*)
1312         LIBC="libc.so.12"
1313         INTL="libintl.so.0"
1314         ;;
1315     *-*-*freebsd*)
1316         LIBC="libc.so"
1317         INTL="libintl.so"
1318         ;;
1319     *-*-*openbsd*)
1320         LIBC="libc.so"
1321         INTL="libintl.so"
1322         ;;
1323 esac
1324 AC_SUBST(libsuffix)
1326 if test "x$TARGET" != "xAMD64"; then
1327    # valgrind headers don't compile under x86-64
1328    AC_CHECK_HEADERS(valgrind/memcheck.h)
1331 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
1332         if test "x$with_tls" = "x__thread"; then
1333                 #
1334                 # On some linux distributions, TLS works in executables, but linking 
1335                 # against a shared library containing TLS fails with:
1336                 # undefined reference to `__tls_get_addr'
1337                 #
1338                 rm -f conftest.c conftest.so conftest
1339                 echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
1340                 gcc -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
1341                 gcc -o conftest conftest.so > /dev/null 2>&1
1342                 if test ! -f conftest; then
1343                    AC_MSG_WARN([Disabling usage of __thread.]);
1344                    with_tls=pthread
1345                 fi
1346                 rm -f conftest.c conftest.so conftest
1347         fi
1350 if test "x$with_tls" = "x__thread"; then
1351         AC_DEFINE(HAVE_KW_THREAD)
1352    # Pass the information to libgc
1353         CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
1354         export CPPFLAGS
1357 if test ${TARGET} = ARM; then
1358         dnl ******************************************
1359         dnl *** Check to see what FPU is available ***
1360         dnl ******************************************
1361         AC_MSG_CHECKING(which FPU to use)
1363         AC_TRY_COMPILE([], [
1364                 __asm__ ("ldfd f0, [r0]");
1365                 ], fpu=FPA, [
1366                         AC_TRY_COMPILE([], [
1367                                 __asm__ ("fldd d0, [r0]");
1368                         ], fpu=VFP, fpu=NONE)
1369                 ])
1371         AC_MSG_RESULT($fpu)
1372         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
1373         unset fpu
1376 if test ${TARGET} = unknown; then
1377         CPPFLAGS="$CPPFLAGS -DNO_PORT"
1378         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
1381 if test ${ACCESS_UNALIGNED} = no; then
1382         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
1385 PREVIEW=no
1386 AC_ARG_WITH(preview, [ --with-preview=yes,no     If you want to install the 2.0 FX preview],[
1387         if test x$with_preview = xyes; then
1388               PREVIEW=yes
1389         fi
1392 AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
1394 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
1395 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
1396 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
1397 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
1398 AM_CONDITIONAL(X86, test x$TARGET = xX86)
1399 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
1400 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
1401 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
1402 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
1403 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
1404 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
1405 AM_CONDITIONAL(S390, test x$TARGET = xS390)
1406 AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
1407 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
1409 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
1410 AM_CONDITIONAL(INCLUDED_LIBGC, test x$gc = xincluded)
1412 AC_SUBST(LIBC)
1413 AC_SUBST(INTL)
1415 AC_SUBST(arch_target)
1416 AC_SUBST(CFLAGS)
1417 AC_SUBST(CPPFLAGS)
1418 AC_SUBST(LDFLAGS)
1420 AC_OUTPUT([
1421 Makefile
1422 mint.pc
1423 mono.pc
1424 mono/Makefile
1425 mono/utils/Makefile
1426 mono/metadata/Makefile
1427 mono/dis/Makefile
1428 mono/cil/Makefile
1429 mono/arch/Makefile
1430 mono/os/Makefile
1431 mono/os/win32/Makefile
1432 mono/os/unix/Makefile
1433 mono/arch/x86/Makefile
1434 mono/arch/amd64/Makefile
1435 mono/arch/hppa/Makefile
1436 mono/arch/ppc/Makefile
1437 mono/arch/sparc/Makefile
1438 mono/arch/s390/Makefile
1439 mono/arch/s390x/Makefile
1440 mono/arch/arm/Makefile
1441 mono/arch/alpha/Makefile
1442 mono/interpreter/Makefile
1443 mono/tests/Makefile
1444 mono/tests/tests-config
1445 mono/benchmark/Makefile
1446 mono/monoburg/Makefile
1447 mono/monograph/Makefile
1448 mono/io-layer/Makefile
1449 mono/handles/Makefile
1450 mono/mini/Makefile
1451 mono/profiler/Makefile
1452 ikvm-jni/Makefile
1453 runtime/Makefile
1454 runtime/net_1_1/Makefile
1455 runtime/net_2_0/Makefile
1456 scripts/Makefile
1457 man/Makefile
1458 web/Makefile
1459 docs/Makefile
1460 data/Makefile
1461 data/net_1_1/Makefile
1462 data/net_2_0/Makefile
1463 samples/Makefile
1464 support/Makefile
1465 data/config
1466 mono.spec
1467 tools/Makefile
1468 tools/locale-builder/Makefile
1471 echo "
1473         GC:          $gc
1474         ICU:         $enable_icu
1475         TLS:         $with_tls
1476         SIGALTSTACK: $with_sigaltstack
1477         Engine:      $jit_status
1478         2.0 Alpha:   $PREVIEW
1479         JNI support: $jdk_headers_found