2004-10-26 Gonzalo Paniagua Javier <gonzalo@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.0.3)
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/mini/tramp-x86.c
235 AC_CHECK_HEADERS(valgrind/memcheck.h)
236
237 # for mono/metadata/debug-symfile.c
238 AC_CHECK_HEADERS(elf.h)
239
240 # for mono/dis
241 AC_CHECK_HEADERS(wchar.h)
242
243 # not 64 bit clean in cross-compile
244 AC_CHECK_SIZEOF(void *, 4)
245
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
259 fi
260 CFLAGS="$CFLAGS -g $WARN"
261
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])
265 fi
266
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)
273
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
285 )
286
287 ## Versions of dependencies
288 GLIB_REQUIRED_VERSION=1.3.11
289
290 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
291
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`
296
297 AC_SUBST(GLIB_CFLAGS)
298 AC_SUBST(GLIB_LIBS)
299 AC_SUBST(GMODULE_CFLAGS)
300 AC_SUBST(GMODULE_LIBS)
301
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
310
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)
321 fi
322
323 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
324
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])
328
329 # Kept for compatibility
330 AC_ARG_WITH(nptl, [  --with-nptl=yes,no      deprecated, use --with-tls instead],[],[with_nptl=default])
331
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
341 fi
342
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])
346
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)
354
355 LIBGC_CFLAGS=
356 LIBGC_LIBS=
357 libgc_dir=
358 case "x$gc" in
359         xboehm|xbohem|xyes)
360                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
361                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
362
363                 if test "x$found_boehm" != "xyes"; then
364                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
365                 fi
366                 if test "x$gc_headers" != "xyes"; then
367                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
368                 fi
369
370                 AC_DEFINE(HAVE_BOEHM_GC)
371                 AC_SUBST(HAVE_BOEHM_GC)
372                 LIBGC_LIBS="-lgc $libdl"
373
374                 # AC_CHECK_FUNCS does not work for some reason...
375                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
376                 if test "x$found_gcj_malloc" = "xyes"; then
377                         AC_DEFINE(HAVE_GC_GCJ_MALLOC)
378                 fi
379                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
380                 if test "x$found_gc_enable" = "xyes"; then
381                         AC_DEFINE(HAVE_GC_ENABLE)
382                 fi
383                 ;;
384
385         xincluded)
386                 AC_CONFIG_SUBDIRS(libgc)
387
388                 found_boehm=yes
389                 gc_headers=yes
390                 use_included_gc=yes
391                 libgc_dir=libgc
392
393                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
394                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
395
396                 AC_DEFINE(HAVE_BOEHM_GC)
397                 AC_SUBST(HAVE_BOEHM_GC)
398
399                 AC_DEFINE(HAVE_GC_H)
400                 AC_DEFINE(USE_INCLUDED_LIBGC)
401
402                 # The included libgc contains GCJ support
403                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
404                 AC_DEFINE(HAVE_GC_ENABLE)
405                 ;;
406
407         xnone)
408                 AC_MSG_WARN("Compiling mono without GC.")
409                 ;;
410         *)
411                 AC_MSG_ERROR([Invalid argument to --with-gc.])
412                 ;;
413 esac
414
415
416 # tell libgc/configure about what we want
417 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
418
419 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
420 AC_SUBST(LIBGC_CFLAGS)
421 AC_SUBST(LIBGC_LIBS)
422 AC_SUBST(libgc_dir)
423
424 dnl
425 dnl End of libgc checks
426 dnl
427
428 if test x$platform_win32 = xno; then
429
430         dnl ******************************************************************
431         dnl *** Checks for the IKVM JNI interface library                  ***
432         dnl ******************************************************************
433         AC_ARG_WITH(ikvm-jni, [  --with-ikvm-jni=yes,no  build the IKVM JNI interface library],[with_ikvm_jni=$withval],[with_ikvm_jni=yes])
434         AC_ARG_WITH(jdk, [  --with-jdk=DIRECTORY    Use JDK from DIRECTORY],[with_jdk_dir=$withval],[with_jdk_dir=])
435
436         ikvm_jni_dir=
437         if test x$with_ikvm_jni = xyes; then
438                 AC_MSG_CHECKING([JDK headers])
439
440                 if test x$with_jdk_dir = x; then
441                         # Try JAVA_HOME variable
442                         if test x$JAVA_HOME != x; then
443                                 with_jdk_dir=$JAVA_HOME
444                         fi
445                 fi
446         
447                 jdk_platform=
448                 if test -d $with_jdk_dir/include; then
449                         jdk_headers_found=yes
450
451                         if test -d $with_jdk_dir/include/linux; then
452                                 jdk_platform=linux
453                         else
454                         if test -d $with_jdk_dir/include/solaris; then
455                                 jdk_platform=solaris
456                         else
457                         if test -f $with_jdk_dir/include/jni_md.h; then
458                                 # GNU Classpath sources
459                                 jdk_platform=
460                         else
461                                 jdk_headers_found=no
462                         fi
463                         fi
464                         fi
465                 else
466                         jdk_headers_found=no
467                 fi
468
469                 if test x$jdk_headers_found = xyes; then
470                         AC_MSG_RESULT($with_jdk_dir/include $with_jdk_dir/include/$jdk_platform)
471                 else
472                         AC_MSG_RESULT(not found)
473                 fi
474
475                 if test x$jdk_headers_found = xyes; then
476                         ikvm_jni_dir=ikvm-jni
477                         IKVM_JNI_CFLAGS="-I$with_jdk_dir/include -I$with_jdk_dir/include/$jdk_platform"
478                 fi
479         fi
480
481         AC_SUBST(ikvm_jni_dir)
482         AC_SUBST(IKVM_JNI_CFLAGS)
483
484         AC_CHECK_FUNCS(getgrgid_r)
485         AC_CHECK_FUNCS(getgrnam_r)
486         AC_CHECK_FUNCS(getpwnam_r)
487         AC_CHECK_FUNCS(getpwuid_r)
488         AC_CHECK_FUNCS(getresuid)
489         AC_CHECK_FUNCS(setresuid)
490         AC_CHECK_FUNCS(kqueue)
491
492         dnl ******************************************************************
493         dnl *** Check for large file support                               ***
494         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
495         dnl ******************************************************************
496         
497         # Check that off_t can represent 2**63 - 1 correctly, working around
498         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
499         # CPPFLAGS and sets $large_offt to yes if the test succeeds
500         large_offt=no
501         AC_DEFUN(LARGE_FILES, [
502                 large_CPPFLAGS=$CPPFLAGS
503                 CPPFLAGS="$CPPFLAGS $1"
504                 AC_TRY_RUN([
505                         #include <sys/types.h>
506
507                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
508
509                         int main(void) {
510                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
511                                                (BIG_OFF_T%2147483647==1));
512                                 if(big_off_t) {
513                                         exit(0);
514                                 } else {
515                                         exit(1);
516                                 }
517                         }
518                 ], [
519                         AC_MSG_RESULT(ok)
520                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
521                         large_CPPFLAGS="$large_CPPFLAGS $1"
522                         large_offt=yes
523                 ], [
524                         AC_MSG_RESULT(no)
525                 ], "")
526                 CPPFLAGS=$large_CPPFLAGS
527         ])
528
529         AC_MSG_CHECKING(if off_t is 64 bits wide)
530         LARGE_FILES("")
531         if test $large_offt = no; then
532                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
533                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
534         fi
535         if test $large_offt = no; then
536                 AC_MSG_WARN([No 64 bit file size support available])
537         fi
538         
539         dnl *****************************
540         dnl *** Checks for libsocket  ***
541         dnl *****************************
542         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
543
544         dnl *******************************
545         dnl *** Checks for MSG_NOSIGNAL ***
546         dnl *******************************
547         AC_MSG_CHECKING(for MSG_NOSIGNAL)
548         AC_TRY_COMPILE([#include <sys/socket.h>], [
549                 int f = MSG_NOSIGNAL;
550         ], [
551                 # Yes, we have it...
552                 AC_MSG_RESULT(yes)
553                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
554         ], [
555                 # We'll have to use signals
556                 AC_MSG_RESULT(no)
557         ])
558
559         dnl *****************************
560         dnl *** Checks for SOL_IP     ***
561         dnl *****************************
562         AC_MSG_CHECKING(for SOL_IP)
563         AC_TRY_COMPILE([#include <netdb.h>], [
564                 int level = SOL_IP;
565         ], [
566                 # Yes, we have it...
567                 AC_MSG_RESULT(yes)
568                 AC_DEFINE(HAVE_SOL_IP)
569         ], [
570                 # We'll have to use getprotobyname
571                 AC_MSG_RESULT(no)
572         ])
573
574         dnl *****************************
575         dnl *** Checks for SOL_IPV6     ***
576         dnl *****************************
577         AC_MSG_CHECKING(for SOL_IPV6)
578         AC_TRY_COMPILE([#include <netdb.h>], [
579                 int level = SOL_IPV6;
580         ], [
581                 # Yes, we have it...
582                 AC_MSG_RESULT(yes)
583                 AC_DEFINE(HAVE_SOL_IPV6)
584         ], [
585                 # We'll have to use getprotobyname
586                 AC_MSG_RESULT(no)
587         ])
588
589         dnl *****************************
590         dnl *** Checks for SOL_TCP    ***
591         dnl *****************************
592         AC_MSG_CHECKING(for SOL_TCP)
593         AC_TRY_COMPILE([#include <netdb.h>], [
594                 int level = SOL_TCP;
595         ], [
596                 # Yes, we have it...
597                 AC_MSG_RESULT(yes)
598                 AC_DEFINE(HAVE_SOL_TCP)
599         ], [
600                 # We'll have to use getprotobyname
601                 AC_MSG_RESULT(no)
602         ])
603
604         dnl *****************************
605         dnl *** Checks for IP_PKTINFO ***
606         dnl *****************************
607         AC_MSG_CHECKING(for IP_PKTINFO)
608         AC_TRY_COMPILE([#include <netdb.h>], [
609                 int level = IP_PKTINFO;
610         ], [
611                 # Yes, we have it...
612                 AC_MSG_RESULT(yes)
613                 AC_DEFINE(HAVE_IP_PKTINFO)
614         ], [
615                 AC_MSG_RESULT(no)
616         ])
617
618         dnl *********************************
619         dnl *** Check for struct ip_mreqn ***
620         dnl *********************************
621         AC_MSG_CHECKING(for struct ip_mreqn)
622         AC_TRY_COMPILE([#include <netinet/in.h>], [
623                 struct ip_mreqn mreq;
624                 mreq.imr_address.s_addr = 0;
625         ], [
626                 # Yes, we have it...
627                 AC_MSG_RESULT(yes)
628                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
629         ], [
630                 # We'll just have to try and use struct ip_mreq
631                 AC_MSG_RESULT(no)
632                 AC_MSG_CHECKING(for struct ip_mreq)
633                 AC_TRY_COMPILE([#include <netinet/in.h>], [
634                         struct ip_mreq mreq;
635                         mreq.imr_interface.s_addr = 0;
636                 ], [
637                         # Yes, we have it...
638                         AC_MSG_RESULT(yes)
639                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
640                 ], [
641                         # No multicast support
642                         AC_MSG_RESULT(no)
643                 ])
644         ])
645         
646         dnl **********************************
647         dnl *** Check for gethostbyname2_r ***
648         dnl **********************************
649         AC_MSG_CHECKING(for gethostbyname2_r)
650                 AC_TRY_LINK([#include <netdb.h>], [
651                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
652         ], [
653                 # Yes, we have it...
654                 AC_MSG_RESULT(yes)
655                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R)
656         ], [
657                 AC_MSG_RESULT(no)
658         ])
659
660         dnl *****************************
661         dnl *** Checks for libnsl     ***
662         dnl *****************************
663         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
664
665         AC_CHECK_FUNCS(inet_pton inet_aton)
666
667         dnl ***********************************************
668         dnl *** Checks for size of sockaddr_un.sun_path ***
669         dnl ***********************************************
670         # AC_CHECK_SIZEOF can't cope with struct members :-(
671         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
672         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
673                 [AC_TRY_RUN([
674                         #include <sys/types.h>
675                         #include <stdio.h>
676                         #include <sys/un.h>
677
678                         int main(void) {
679                                 struct sockaddr_un sock_un;
680                                 FILE *f=fopen("conftestval", "w");
681                                 if(!f) exit(1);
682                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
683                                 exit(0);
684                         }
685                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
686                    cv_mono_sizeof_sunpath=0,
687                    cv_mono_sizeof_sunpath=0)])dnl
688         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
689         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
690
691         dnl *************************************
692         dnl *** Checks for zero length arrays ***
693         dnl *************************************
694         AC_MSG_CHECKING(whether $CC supports zero length arrays)
695         AC_TRY_COMPILE([
696                 struct s {
697                         int  length;
698                         char data [0];
699                 };
700         ], [], [
701                 AC_MSG_RESULT(yes)
702                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 0)
703         ], [
704                 AC_MSG_RESULT(no)
705                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 1)
706         ])
707
708         dnl *****************************
709         dnl *** Checks for libxnet    ***
710         dnl *****************************
711         case "${host}" in
712                 *solaris* )
713                         AC_MSG_CHECKING(for Solaris XPG4 support)
714                         if test -f /usr/lib/libxnet.so; then
715                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
716                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
717                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
718                                 LIBS="$LIBS -lxnet"
719                                 AC_MSG_RESULT(yes)
720                         else
721                                 AC_MSG_RESULT(no)
722                         fi
723
724                         if test "$GCC" = "yes"; then
725                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
726                         fi
727                 ;;
728         esac
729
730         dnl *****************************
731         dnl *** Checks for libpthread ***
732         dnl *****************************
733 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
734 # and libpthread does not exist
735 #
736         case "${host}" in
737                 *-*-*freebsd4*)
738                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
739                 ;;
740                 *)
741                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
742                 ;;
743         esac
744         AC_CHECK_HEADERS(pthread.h)
745         AC_CHECK_FUNCS(pthread_mutex_timedlock)
746         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
747         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
748         AC_TRY_COMPILE([ #include <pthread.h>], [
749                 pthread_mutexattr_t attr;
750                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
751         ], [
752                 AC_MSG_RESULT(ok)
753         ], [
754                 AC_MSG_RESULT(no)
755                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
756                 AC_DEFINE(USE_MONO_MUTEX)
757         ])
758         AC_CHECK_FUNCS(pthread_attr_setstacksize)
759
760         dnl ***********************************
761         dnl *** Checks for working __thread ***
762         dnl ***********************************
763         AC_MSG_CHECKING(for working __thread)
764         if test "x$with_tls" != "x__thread"; then
765                 AC_MSG_RESULT(disabled)
766         else
767                 AC_TRY_RUN([
768                         #include <pthread.h>
769
770                         __thread int i;
771                         static int res1, res2;
772
773                         void thread_main (void *arg)
774                         {
775                                 i = arg;
776                                 sleep (1);
777                                 if (arg == 1)
778                                         res1 = (i == arg);
779                                 else
780                                         res2 = (i == arg);
781                         }
782
783                         int main () {
784                                 pthread_t t1, t2;
785
786                                 i = 5;
787
788                                 pthread_create (&t1, NULL, thread_main, 1);
789                                 pthread_create (&t2, NULL, thread_main, 2);
790
791                                 pthread_join (t1, NULL);
792                                 pthread_join (t2, NULL);
793
794                                 return !(res1 + res2 == 2);
795                         }
796                 ], [
797                                 AC_MSG_RESULT(yes)
798                                 AC_DEFINE(HAVE_KW_THREAD)
799                 ], [
800                                 AC_MSG_RESULT(no)
801                 ])
802         fi
803
804         dnl **************************************
805         dnl *** Checks for working sigaltstack ***
806         dnl **************************************
807         AC_MSG_CHECKING(for working sigaltstack)
808         if test "x$with_sigaltstack" != "xyes"; then
809                 AC_MSG_RESULT(disabled)
810         else
811                 AC_TRY_RUN([
812                         #include <stdio.h>
813                         #include <stdlib.h>
814                         #include <unistd.h>
815                         #include <signal.h>
816                         #include <pthread.h>
817                         #include <sys/wait.h>
818
819                         static void
820                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
821                         {
822                                 exit (0);
823                         }
824
825                         static void *
826                         loop (void *ignored)
827                         {
828                                 char *ptr = NULL;
829
830                                 *ptr = 0;
831                                 return NULL;
832                         }
833
834                         static void
835                         child ()
836                         {
837                                 struct sigaction sa;
838                                 struct sigaltstack sas;
839                                 pthread_t id;
840                                 pthread_attr_t attr;
841
842                                 sa.sa_sigaction = sigsegv_signal_handler;
843                                 sigemptyset (&sa.sa_mask);
844                                 sa.sa_flags = SA_SIGINFO | SA_STACK;
845                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
846                                         perror ("lala");
847                                         return;
848                                 }
849
850                                 sas.ss_sp = malloc (SIGSTKSZ);
851                                 sas.ss_size = SIGSTKSZ;
852                                 sas.ss_flags = SS_ONSTACK;
853                                 if (sigaltstack (&sas, NULL) == -1) {
854                                         perror ("lala");
855                                         return;
856                                 }
857
858                                 pthread_attr_init (&attr);
859                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
860                                         printf ("failed\n");
861                                         return;
862                                 }
863
864                                 sleep (100);
865                         }
866
867                         int
868                         main ()
869                         {
870                                 pid_t son;
871                                 int status;
872                                 int i;
873
874                                 son = fork ();
875                                 if (son == -1) {
876                                         return 1;
877                                 }
878
879                                 if (son == 0) {
880                                         child ();
881                                         return 0;
882                                 }
883
884                                 for (i = 0; i < 3; ++i) {
885                                         sleep (1);
886                                         waitpid (son, &status, WNOHANG);
887                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
888                                                 return 0;
889                                 }
890
891                                 kill (son, SIGKILL);
892                                 return 1;
893                         }
894
895                 ], [
896                                 AC_MSG_RESULT(yes)
897                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
898                 ], [
899                                 with_sigaltstack=no
900                                 AC_MSG_RESULT(no)
901                 ])
902         fi
903
904         dnl ********************************
905         dnl *** Checks for semaphore lib ***
906         dnl ********************************
907         # 'Real Time' functions on Solaris
908         # posix4 on Solaris 2.6
909         # pthread (first!) on Linux
910         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
911
912         dnl ********************************
913         dnl *** Checks for timezone stuff **
914         dnl ********************************
915         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
916                 AC_TRY_COMPILE([
917                         #include <time.h>
918                         ], [
919                         struct tm tm;
920                         tm.tm_gmtoff = 1;
921                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
922         if test $ac_cv_struct_tm_gmtoff = yes; then
923                 AC_DEFINE(HAVE_TM_GMTOFF)
924         else
925                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
926                         AC_TRY_COMPILE([
927                                 #include <time.h>
928                         ], [
929                                 timezone = 1;
930                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
931                 if test $ac_cv_var_timezone = yes; then
932                         AC_DEFINE(HAVE_TIMEZONE)
933                 else
934                         AC_ERROR(unable to find a way to determine timezone)
935                 fi
936         fi
937
938         dnl *********************************
939         dnl *** Checks for math functions ***
940         dnl *********************************
941         LIBS="$LIBS -lm";
942         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
943                 AC_TRY_LINK([#include <math.h>], 
944                 [ finite(0.0); ], 
945                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
946                 AC_MSG_RESULT(no)))
947         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
948                 AC_TRY_LINK([#include <math.h>], 
949                 [ isfinite(0.0); ], 
950                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
951                 AC_MSG_RESULT(no)))
952
953         dnl ****************************************************************
954         dnl *** Checks for working poll() (macosx defines it but doesn't ***
955         dnl *** have it in the library (duh))                            ***
956         dnl ****************************************************************
957         AC_CHECK_FUNCS(poll)
958
959         dnl *************************
960         dnl *** Check for signbit ***
961         dnl *************************
962         AC_MSG_CHECKING(for signbit)
963         AC_TRY_LINK([#include <math.h>], [
964                 int s = signbit(1.0);
965         ], [
966                 AC_MSG_RESULT(yes)
967                 AC_DEFINE(HAVE_SIGNBIT)
968         ], [
969                 AC_MSG_RESULT(no)
970         ]) 
971
972         dnl *********************
973         dnl *** Check for AIO ***
974         dnl *********************
975         AC_MSG_CHECKING([for SIGEV_THREAD definition])
976         dnl Some systems (FreeBSD at least) may have aio_read
977         dnl but don't support/define SIGEV_THREAD.
978         AC_TRY_COMPILE([
979         #include <sys/signal.h>
980         ],[
981         int x = SIGEV_THREAD;
982         ],[
983                 ac_cv_c_sigev_thread=yes
984                 AC_MSG_RESULT(yes)
985         ],[
986                 AC_MSG_RESULT(no)
987         ])
988
989         if test "$ac_cv_c_sigev_thread" = "yes" ; then
990                 AC_CHECK_HEADERS(aio.h sys/aio.h)
991                 AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
992                 SIGVAL_PTR="undefined"
993                 if test "$ac_cv_header_aio_h" = "yes" -o "$ac_cv_header_sys_aio_h" = "yes" ; then
994                         AC_CHECK_MEMBER(union sigval.sigval_ptr,SIGVAL_PTR="sigval_ptr",, [
995                                         #include <sys/signal.h>
996                                         ])
997                         AC_CHECK_MEMBER(union sigval.sival_ptr,SIGVAL_PTR="sival_ptr",, [
998                                         #include <sys/signal.h>
999                                         ])
1000                         if test "$SIGVAL_PTR" = "undefined" ; then
1001                                 AC_MSG_ERROR([Unable to detect field name in 'union sigval'])
1002                         fi
1003                 fi
1004                 AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
1005         fi
1006 else
1007         jdk_headers_found=no
1008         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
1009         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
1010
1011         dnl *********************************
1012         dnl *** Check for struct ip_mreqn ***
1013         dnl *********************************
1014         AC_MSG_CHECKING(for struct ip_mreqn)
1015         AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1016                 struct ip_mreqn mreq;
1017                 mreq.imr_address.s_addr = 0;
1018         ], [
1019                 # Yes, we have it...
1020                 AC_MSG_RESULT(yes)
1021                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
1022         ], [
1023                 # We'll just have to try and use struct ip_mreq
1024                 AC_MSG_RESULT(no)
1025                 AC_MSG_CHECKING(for struct ip_mreq)
1026                 AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1027                         struct ip_mreq mreq;
1028                         mreq.imr_interface.s_addr = 0;
1029                 ], [
1030                         # Yes, we have it...
1031                         AC_MSG_RESULT(yes)
1032                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
1033                 ], [
1034                         # No multicast support
1035                         AC_MSG_RESULT(no)
1036                 ])
1037         ])
1038 fi
1039
1040 dnl socklen_t check
1041 AC_MSG_CHECKING(for socklen_t)
1042 AC_TRY_COMPILE([
1043 #include <sys/types.h>
1044 #include <sys/socket.h>
1045 ],[
1046   socklen_t foo;
1047 ],[
1048 ac_cv_c_socklen_t=yes
1049         AC_DEFINE(HAVE_SOCKLEN_T)
1050         AC_MSG_RESULT(yes)
1051 ],[
1052         AC_MSG_RESULT(no)
1053 ])
1054
1055 AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
1056         # Simply calling trunc (0.0) is no good since gcc will optimize the call away
1057         AC_TRY_LINK([#include <math.h>], 
1058         [ static void *p = &trunc; ],
1059         [
1060                 AC_DEFINE(HAVE_TRUNC) 
1061                 AC_MSG_RESULT(yes)
1062                 ac_cv_trunc=yes
1063         ],
1064         AC_MSG_RESULT(no)))
1065
1066 if test "x$ac_cv_truncl" != "xyes"; then
1067    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
1068 fi
1069
1070 dnl ****************************
1071 dnl *** Look for /dev/random ***
1072 dnl ****************************
1073
1074 AC_MSG_CHECKING([if usage of random device is requested])
1075 AC_ARG_ENABLE(dev-random,
1076 [  --disable-dev-random    disable the use of the random device],
1077 try_dev_random=$enableval, try_dev_random=yes)
1078 AC_MSG_RESULT($try_dev_random)
1079
1080 case "{$target}" in
1081     *-openbsd*)
1082     NAME_DEV_RANDOM="/dev/srandom"
1083     ;;
1084
1085 dnl Win32 does not have /dev/random, they have their own method...
1086
1087     *-*-mingw*|*-*-cygwin*)
1088     ac_cv_have_dev_random=no
1089     ;;
1090
1091 dnl Everywhere else, it's /dev/random
1092
1093     *)
1094     NAME_DEV_RANDOM="/dev/random"
1095     ;;
1096 esac
1097
1098 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
1099
1100 dnl Now check if the device actually exists
1101
1102 if test "x$try_dev_random" = "xyes"; then
1103     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1104     [if test -r "$NAME_DEV_RANDOM" ; then
1105         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1106     if test "x$ac_cv_have_dev_random" = "xyes"; then
1107         AC_DEFINE(HAVE_CRYPT_RNG)
1108     fi
1109 else
1110     AC_MSG_CHECKING(for random device)
1111     ac_cv_have_dev_random=no
1112     AC_MSG_RESULT(has been disabled)
1113 fi
1114
1115 if test "x$platform_win32" = "xyes"; then
1116     AC_DEFINE(HAVE_CRYPT_RNG)
1117 fi
1118
1119 if test "x$ac_cv_have_dev_random" = "xno" \
1120     && test "x$platform_win32" = "xno"; then
1121     AC_MSG_WARN([[
1122 ***
1123 *** A system-provided entropy source was not found on this system.
1124 *** Because of this, the System.Security.Cryptography random number generator
1125 *** will throw a NotImplemented exception.
1126 ***
1127 *** If you are seeing this message, and you know your system DOES have an
1128 *** entropy collection in place, please contact <crichton@gimp.org> and
1129 *** provide information about the system and how to access the random device.
1130 ***
1131 *** Otherwise you can install either egd or prngd and set the environment
1132 *** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
1133 ***]])
1134 fi
1135  
1136 AC_MSG_CHECKING([if inter-process shared handles are requested])
1137 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
1138 AC_MSG_RESULT($try_shared_handles)
1139 if test "x$try_shared_handles" != "xyes"; then
1140         AC_DEFINE(DISABLE_SHARED_HANDLES)
1141         AC_SUBST(DISABLE_SHARED_HANDLES)
1142 fi
1143
1144 #
1145 # ICU 
1146 #
1147 ICU_CFLAGS=""
1148 ICU_LIBS=""
1149 enable_icu=no
1150
1151 probe_icu=true
1152 AC_ARG_WITH(icu, [  --with-icu=yes/no],
1153         if test x$with_icu = xno; then
1154            probe_icu=false;
1155            AC_MSG_RESULT(Will not probe for ICU)
1156         fi
1157 )
1158
1159 if $probe_icu; then
1160         AC_PATH_PROG(ICU_CONFIG, icu-config, no)
1161         if test "x$ICU_CONFIG" = "xno" -o ! -x "$ICU_CONFIG"; then
1162                 AC_MSG_WARN([Only invariant locale available; install ICU for I18N support])
1163                 enable_icu="no, if you want full i18n support download it from: http://oss.software.ibm.com/icu/index.html"
1164         else
1165                 enable_icu="yes. Version: `$ICU_CONFIG --version`"
1166                 AC_DEFINE(HAVE_ICU)
1167                 ICU_CFLAGS=`$ICU_CONFIG --cppflags`
1168                 ICU_LIBS=`$ICU_CONFIG --ldflags`
1169         fi
1170 fi
1171 AC_SUBST(ICU_CFLAGS)
1172 AC_SUBST(ICU_LIBS)
1173
1174 TARGET="unknown"
1175 ACCESS_UNALIGNED="yes"
1176
1177 JIT_SUPPORTED=no
1178 LIBC="libc.so.6"
1179 INTL="libc.so.6"
1180
1181 jit_wanted=false
1182 case "$host" in
1183 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
1184 #               TARGET=MIPS;
1185 #               ACCESS_UNALIGNED="no"
1186 #               ;;
1187         i*86-*-*)
1188                 TARGET=X86;
1189                 arch_target=x86;
1190                 JIT_SUPPORTED=yes
1191                 jit_wanted=true
1192                 ;;
1193         x86_64-*-* | amd64-*-*)
1194                 TARGET=AMD64;
1195                 arch_target=amd64;
1196                 JIT_SUPPORTED=no
1197                 ;;
1198         sparc*-*-*)
1199                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
1200                    TARGET=SPARC64
1201                 else
1202                         TARGET=SPARC
1203                 fi
1204                 arch_target=sparc;
1205                 JIT_SUPPORTED=yes
1206                 ACCESS_UNALIGNED="no"
1207                 LIBC="libc.so"
1208                 INTL="libintl.so"
1209                 jit_wanted=true
1210                 ;;
1211        alpha*-*-linux* | alpha*-*-osf*)
1212                 TARGET=ALPHA;
1213                 ACCESS_UNALIGNED="no"
1214                 JIT_SUPPORTED=no
1215                 arch_target=alpha;
1216                ;;
1217 #       ia64-*-linux* | ia64-*-hpux*)
1218 #               TARGET=IA64;
1219 #               arch_target=ia64;
1220 #               JIT_SUPPORTED=no;
1221 #               ACCESS_UNALIGNED="no";
1222 #               case "$host_os" in
1223 #                       linux*) LIBC="libc.so.6.1";;
1224 #                       hpux*)  LIBC="libc.so.1";;
1225 #               esac
1226 #               ;;
1227 #       m68k-*-linux*)
1228 #               TARGET=M68K
1229 #               ;;
1230         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
1231                 TARGET=HPPA;
1232                 arch_target=hppa; 
1233                 LIBC="libc.sl"
1234                 ACCESS_UNALIGNED="no"
1235                 ;;
1236         hppa*linux*)
1237                 TARGET=HPPA;
1238                 arch_target=hppa; 
1239                 ACCESS_UNALIGNED="no"
1240                 ;;
1241         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
1242         powerpc-*-sysv* | powerpc-*-darwin*)
1243                 TARGET=POWERPC;
1244                 arch_target=ppc;
1245                 JIT_SUPPORTED=yes
1246                 jit_wanted=true
1247                 ;;
1248         arm-*-linux-* | armv4l-*-linux-*)
1249                 TARGET=ARM;
1250                 arch_target=arm;
1251                 ACCESS_UNALIGNED="no"
1252                 ;;
1253         s390-*-linux*)
1254                 TARGET=S390;
1255                 arch_target=s390;
1256                 ACCESS_UNALIGNED="no"
1257                 JIT_SUPPORTED=yes
1258                 ;;
1259 esac
1260
1261 AC_ARG_WITH(jit, [  --with-jit=yes,no       If you want to build scripts that default to the JIT],[
1262         jit_wanted=true
1263 ])
1264
1265 USEJIT=false
1266 if test x$JIT_SUPPORTED = xyes; then
1267    if $jit_wanted; then
1268       USEJIT=true
1269       jit_status="Building and using the JIT"
1270    else
1271       jit_status="Building the JIT, defaulting to the interpreter"
1272    fi
1273 else
1274    jit_status="interpreter"
1275 fi
1276
1277 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
1278
1279 libsuffix=".so"
1280
1281 case "$host" in
1282      powerpc-*-darwin*)
1283         libsuffix=".dylib"
1284         LIBC="libc.dylib"
1285         INTL="libintl.dylib"
1286         ;;
1287      *-*-*netbsd*)
1288         LIBC="libc.so.12"
1289         INTL="libintl.so.0"
1290         ;;
1291     *-*-*freebsd*)
1292         LIBC="libc.so"
1293         INTL="libintl.so"
1294         ;;
1295     *-*-*openbsd*)
1296         LIBC="libc.so"
1297         INTL="libintl.so"
1298         ;;
1299 esac
1300 AC_SUBST(libsuffix)
1301
1302 if test ${TARGET} = ARM; then
1303         dnl ******************************************
1304         dnl *** Check to see what FPU is available ***
1305         dnl ******************************************
1306         AC_MSG_CHECKING(which FPU to use)
1307
1308         AC_TRY_COMPILE([], [
1309                 __asm__ ("ldfd f0, [r0]");
1310                 ], fpu=FPA, [
1311                         AC_TRY_COMPILE([], [
1312                                 __asm__ ("fldd d0, [r0]");
1313                         ], fpu=VFP, fpu=NONE)
1314                 ])
1315
1316         AC_MSG_RESULT($fpu)
1317         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
1318         unset fpu
1319 fi
1320
1321 if test ${TARGET} = unknown; then
1322         CPPFLAGS="$CPPFLAGS -DNO_PORT"
1323         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
1324 fi
1325
1326 if test ${ACCESS_UNALIGNED} = no; then
1327         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
1328 fi
1329
1330 PREVIEW=no
1331 AC_ARG_WITH(preview, [ --with-preview=yes,no     If you want to install the 2.0 FX preview],[
1332         if test x$with_preview = xyes; then
1333               PREVIEW=yes
1334         fi
1335 ])
1336
1337 AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
1338
1339 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
1340 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
1341 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
1342 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
1343 AM_CONDITIONAL(X86, test x$TARGET = xX86)
1344 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
1345 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
1346 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
1347 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
1348 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
1349 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
1350 AM_CONDITIONAL(S390, test x$TARGET = xS390)
1351 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
1352
1353 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
1354
1355 AC_SUBST(LIBC)
1356 AC_SUBST(INTL)
1357
1358 AC_SUBST(arch_target)
1359 AC_SUBST(CFLAGS)
1360 AC_SUBST(CPPFLAGS)
1361 AC_SUBST(LDFLAGS)
1362
1363 AC_OUTPUT([
1364 Makefile
1365 mint.pc
1366 mono.pc
1367 mono/Makefile
1368 mono/utils/Makefile
1369 mono/metadata/Makefile
1370 mono/dis/Makefile
1371 mono/cil/Makefile
1372 mono/arch/Makefile
1373 mono/os/Makefile
1374 mono/os/win32/Makefile
1375 mono/os/unix/Makefile
1376 mono/arch/x86/Makefile
1377 mono/arch/amd64/Makefile
1378 mono/arch/hppa/Makefile
1379 mono/arch/ppc/Makefile
1380 mono/arch/sparc/Makefile
1381 mono/arch/s390/Makefile
1382 mono/arch/arm/Makefile
1383 mono/arch/alpha/Makefile
1384 mono/interpreter/Makefile
1385 mono/tests/Makefile
1386 mono/tests/tests-config
1387 mono/benchmark/Makefile
1388 mono/monoburg/Makefile
1389 mono/monograph/Makefile
1390 mono/io-layer/Makefile
1391 mono/handles/Makefile
1392 mono/mini/Makefile
1393 mono/profiler/Makefile
1394 ikvm-jni/Makefile
1395 runtime/Makefile
1396 runtime/net_1_1/Makefile
1397 runtime/net_2_0/Makefile
1398 scripts/Makefile
1399 man/Makefile
1400 web/Makefile
1401 docs/Makefile
1402 data/Makefile
1403 samples/Makefile
1404 support/Makefile
1405 data/config
1406 mono.spec
1407 tools/Makefile
1408 tools/locale-builder/Makefile
1409 ])
1410
1411 echo "
1412
1413         GC:          $gc
1414         ICU:         $enable_icu
1415         TLS:         $with_tls
1416         SIGALTSTACK: $with_sigaltstack
1417         Engine:      $jit_status
1418         2.0 Alpha:   $PREVIEW
1419         JNI support: $jdk_headers_found
1420
1421 "