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