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