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