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