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