* Environment.cs: Increase corlib version number.
[mono.git] / configure.in
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(mono,0.31.99)
5 AM_MAINTAINER_MODE
6
7 dnl
8 dnl libgc checks
9 dnl
10
11 gc_headers=no
12 gc=included
13 use_included_gc=no
14
15 if test -d $srcdir/libgc ; then
16   gc_default=included
17 else
18   gc_default=boehm
19 fi
20
21 #
22 # These are the flags that need to be stored in the mono.pc file for 
23 # compiling code that will embed Mono
24 #
25 libmono_cflags=""
26 libmono_ldflags=""
27 AC_SUBST(libmono_cflags)
28 AC_SUBST(libmono_ldflags)
29
30 dnl if linker handles the version script
31 no_version_script=no
32
33 # Thread configuration inspired by sleepycat's db
34 AC_MSG_CHECKING([host platform characteristics])
35 libgc_threads=no
36 case "$host" in
37         *-*-mingw*|*-*-cygwin*)
38                 platform_win32=yes
39                 AC_DEFINE(PLATFORM_WIN32)
40                 CC="gcc -mno-cygwin"
41                 HOST_CC="gcc"
42 # latest libgc already defines GC_WIN32_THREADS
43 #               CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS -DWIN32_THREADS"
44                 CPPFLAGS="$CPPFLAGS -DWIN32_THREADS"
45                 libdl=
46                 libgc_threads=win32
47                 gc_default=boehm 
48                 ;;
49         *-*-*netbsd*)
50                 platform_win32=no
51                 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
52                 libmono_cflags="-D_REENTRANT"
53                 LDFLAGS="$LDFLAGS -pthread"
54                 libmono_ldflags="-pthread"
55                 AC_DEFINE(NEED_LINK_UNLINK)
56                 libdl=
57                 libgc_threads=pthreads
58                 ;;
59         *-*-*freebsd*|*-*-*openbsd*)
60                 platform_win32=no
61                 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
62                 libmono_cflags="-D_THREAD_SAFE"
63                 LDFLAGS="$LDFLAGS -pthread"
64                 libmono_ldflags="-pthread"
65                 AC_DEFINE(NEED_LINK_UNLINK)
66                 AC_DEFINE(PTHREAD_POINTER_ID)
67                 libdl=
68                 libgc_threads=pthreads
69                 ;;
70         *-*-linux*)
71                 platform_win32=no
72                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -DMONO_USE_EXC_TABLES -D_GNU_SOURCE -D_REENTRANT -fexceptions"
73                 libmono_cflags="-DMONO_USE_EXC_TABLES -fexceptions -D_REENTRANT"
74                 libmono_ldflags="-lpthread"
75                 libdl="-ldl"
76                 libgc_threads=pthreads
77                 ;;
78         *-*-hpux*)
79                 platform_win32=no
80                 CPPFLAGS="$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
81                 CFLAGS="$CFLAGS +ESdbgasm"
82                 LDFLAGS="$LDFLAGS -z"
83                 libmono_cflags="-D_REENTRANT"
84                 libmono_ldflags="-lpthread"
85                 libgc_threads=pthreads
86                 AC_DEFINE(NEED_LINK_UNLINK)
87                 ;;
88         *-*-solaris*)
89                 platform_win32=no
90                 CPPFLAGS="$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT"
91                 AC_DEFINE(NEED_LINK_UNLINK)
92                 libmono_cflags="-D_REENTRANT"
93                 libgc_threads=pthreads
94                 ;;
95         *-*-darwin*)
96                 platform_win32=no
97                 CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE"
98                 libmono_cflags="-D_THREAD_SAFE"
99                 LDFLAGS="$LDFLAGS -pthread"
100                 libmono_ldflags="-pthread"
101                 AC_DEFINE(NEED_LINK_UNLINK)
102                 AC_DEFINE(PTHREAD_POINTER_ID)
103                 AC_DEFINE(USE_MACH_SEMA)
104                 no_version_script=yes
105                 libdl=
106                 libgc_threads=no
107                 gc_default=none 
108                 ;;
109         *)
110                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
111                 platform_win32=no
112                 libdl="-ldl"
113                 ;;
114 esac
115 AC_MSG_RESULT(ok)
116 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
117
118 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
119
120 AC_CHECK_TOOL(CC, gcc, gcc)
121 AC_PROG_CC
122 AM_PROG_CC_STDC
123 AC_PROG_INSTALL
124 dnl We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
125 : ${CCAS='$(CC)'}
126 # Set ASFLAGS if not already set.
127 : ${CCASFLAGS='$(CFLAGS)'}
128 AC_SUBST(CCAS)
129 AC_SUBST(CCASFLAGS)
130
131 AC_CHECK_PROG(BISON, bison,yes,no)
132 if test "x$BISON" = "xno";
133 then
134         AC_MSG_ERROR([You need to install bison])
135 fi
136
137 dnl may require a specific autoconf version
138 dnl AC_PROG_CC_FOR_BUILD
139 dnl CC_FOR_BUILD not automatically detected
140 CC_FOR_BUILD=$CC
141 BUILD_EXEEXT=
142 if test "x$cross_compiling" = "xyes"; then
143         CC_FOR_BUILD=cc
144         BUILD_EXEEXT=""
145 fi
146 AC_SUBST(CC_FOR_BUILD)
147 AC_SUBST(HOST_CC)
148 AC_SUBST(BUILD_EXEEXT)
149
150 # Set STDC_HEADERS
151 AC_HEADER_STDC
152 AC_LIBTOOL_WIN32_DLL
153 AM_PROG_LIBTOOL
154
155 # Test whenever ld supports -version-script
156 AC_PROG_LD
157 AC_PROG_LD_GNU
158 if test "x$lt_cv_prog_gnu_ld" = "xno"; then
159    no_version_script=yes
160 fi
161
162 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h)
163
164 # for mono/mini/tramp-x86.c
165 AC_CHECK_HEADERS(valgrind/memcheck.h)
166
167 # for mono/metadata/debug-symfile.c
168 AC_CHECK_HEADERS(elf.h)
169
170 # for mono/dis
171 AC_CHECK_HEADERS(wchar.h)
172
173 # not 64 bit clean in cross-compile
174 AC_CHECK_SIZEOF(void *, 4)
175
176 WARN=''
177 if test x"$GCC" = xyes; then
178         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
179                 # The runtime code does not respect ANSI C strict aliasing rules
180                 CFLAGS="$CFLAGS -fno-strict-aliasing"
181 else
182         # The Sun Forte compiler complains about inline functions that access static variables
183         # so disable all inlining.
184         case "$host" in
185         *-*-solaris*)
186                 CFLAGS="$CFLAGS -Dinline="
187                 ;;
188         esac
189 fi
190 CFLAGS="$CFLAGS -g $WARN"
191
192 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
193 if test "x$PKG_CONFIG" = "xno"; then
194         AC_MSG_ERROR([You need to install pkg-config])
195 fi
196
197 dnl for use on the build system
198 dnl pkg-config is stupid
199 BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
200 BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
201 AC_SUBST(BUILD_GLIB_CFLAGS)
202 AC_SUBST(BUILD_GLIB_LIBS)
203
204 PKG_PATH=
205 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
206         if test x$with_crosspkgdir = "x"; then
207                 if test -s $PKG_CONFIG_PATH; then
208                         PKG_PATH=$PKG_CONFIG_PATH
209                 fi
210         else
211                 PKG_PATH=$with_crosspkgdir
212                 PKG_CONFIG_PATH=$PKG_PATH
213                 export PKG_CONFIG_PATH
214         fi
215 )
216
217 ## Versions of dependencies
218 GLIB_REQUIRED_VERSION=1.3.11
219
220 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
221
222 GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
223 GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
224 GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
225 GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
226
227 AC_SUBST(GLIB_CFLAGS)
228 AC_SUBST(GLIB_LIBS)
229 AC_SUBST(GMODULE_CFLAGS)
230 AC_SUBST(GMODULE_LIBS)
231
232 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
233
234 # Enable support for NPTL only features like fast thread-local storage
235 # We can't reliably detect nptl at compile & run time
236 # so this option will stay until nptl becomes more widespread
237 AC_ARG_WITH(nptl, [  --with-nptl=yes,no      enable/disable support for NPTL],[],[with_nptl=yes])
238
239 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
240 # This does not work on some platforms (bug #55253)
241 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack],[],[with_sigaltstack=yes])
242
243 # assembly bundle support, see metadata/make-bundle.pl for more info
244 AC_ARG_WITH(bundle, [  --with-bundle=bundle_template],[
245         BUNDLE_FILE=$with_bundle
246         AC_SUBST(BUNDLE_FILE)
247         AC_DEFINE(WITH_BUNDLE)
248 ],[with_bundle=no])
249 AM_CONDITIONAL(WITH_BUNDLE, test x$with_bundle != xno)
250
251 LIBGC_CFLAGS=
252 LIBGC_LIBS=
253 libgc_dir=
254 case "x$gc" in
255         xboehm|xbohem|xyes)
256                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
257                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
258
259                 if test "x$found_boehm" != "xyes"; then
260                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
261                 fi
262                 if test "x$gc_headers" != "xyes"; then
263                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
264                 fi
265
266                 AC_DEFINE(HAVE_BOEHM_GC)
267                 AC_SUBST(HAVE_BOEHM_GC)
268                 LIBGC_LIBS="-lgc $libdl"
269
270                 # AC_CHECK_FUNCS does not work for some reason...
271                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
272                 if test "x$found_gcj_malloc" = "xyes"; then
273                         AC_DEFINE(HAVE_GC_GCJ_MALLOC)
274                 fi
275                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
276                 if test "x$found_gc_enable" = "xyes"; then
277                         AC_DEFINE(HAVE_GC_ENABLE)
278                 fi
279                 ;;
280
281         xincluded)
282                 AC_CONFIG_SUBDIRS(libgc)
283
284                 found_boehm=yes
285                 gc_headers=yes
286                 use_included_gc=yes
287                 libgc_dir=libgc
288
289                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
290                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
291
292                 AC_DEFINE(HAVE_BOEHM_GC)
293                 AC_SUBST(HAVE_BOEHM_GC)
294
295                 AC_DEFINE(HAVE_GC_H)
296                 AC_DEFINE(USE_INCLUDED_LIBGC)
297
298                 # The included libgc contains GCJ support
299                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
300                 AC_DEFINE(HAVE_GC_ENABLE)
301                 ;;
302
303         xnone)
304                 AC_MSG_WARN("Compiling mono without GC.")
305                 ;;
306         *)
307                 AC_MSG_ERROR([Invalid argument to --with-gc.])
308                 ;;
309 esac
310
311 we_are_embedded_in_mono=yes
312 export we_are_embedded_in_mono
313 export libgc_threads
314
315 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
316 AC_SUBST(LIBGC_CFLAGS)
317 AC_SUBST(LIBGC_LIBS)
318 AC_SUBST(libgc_dir)
319
320 dnl
321 dnl End of libgc checks
322 dnl
323
324 if test x$platform_win32 = xno; then
325
326         dnl ******************************************************************
327         dnl *** Checks for the IKVM JNI interface library                  ***
328         dnl ******************************************************************
329         AC_ARG_WITH(ikvm-jni, [  --with-ikvm-jni=yes,no  build the IKVM JNI interface library],[with_ikvm_jni=$withval],[with_ikvm_jni=yes])
330         AC_ARG_WITH(jdk, [  --with-jdk=DIRECTORY  use JDK from DIRECTORY],[with_jdk_dir=$withval],[with_jdk_dir=])
331
332         ikvm_jni_dir=
333         if test x$with_ikvm_jni = xyes; then
334                 AC_MSG_CHECKING([JDK headers])
335
336                 if test x$with_jdk_dir = x; then
337                         # Try JAVA_HOME variable
338                         if test x$JAVA_HOME != x; then
339                                 with_jdk_dir=$JAVA_HOME
340                         fi
341                 fi
342         
343                 jdk_platform=
344                 if test -d $with_jdk_dir/include; then
345                         jdk_headers_found=yes
346
347                         if test -d $with_jdk_dir/include/linux; then
348                                 jdk_platform=linux
349                         else
350                         if test -d $with_jdk_dir/include/solaris; then
351                                 jdk_platform=solaris
352                         else
353                                 jdk_headers_found=no
354                         fi
355                         fi
356                 else
357                         jdk_headers_found=no
358                 fi
359
360                 if test x$jdk_headers_found = xyes; then
361                         AC_MSG_RESULT($with_jdk_dir/include $with_jdk_dir/include/$jdk_platform)
362                 else
363                         AC_MSG_RESULT(not found)
364                 fi
365
366                 if test x$jdk_headers_found = xyes; then
367                         ikvm_jni_dir=ikvm-jni
368                         IKVM_JNI_CFLAGS="-I$with_jdk_dir/include -I$with_jdk_dir/include/$jdk_platform"
369                 fi
370         fi
371
372         AC_SUBST(ikvm_jni_dir)
373         AC_SUBST(IKVM_JNI_CFLAGS)
374
375         AC_CHECK_FUNCS(getpwuid_r)
376         dnl ******************************************************************
377         dnl *** Check for large file support                               ***
378         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
379         dnl ******************************************************************
380         
381         # Check that off_t can represent 2**63 - 1 correctly, working around
382         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
383         # CPPFLAGS and sets $large_offt to yes if the test succeeds
384         large_offt=no
385         AC_DEFUN(LARGE_FILES, [
386                 large_CPPFLAGS=$CPPFLAGS
387                 CPPFLAGS="$CPPFLAGS $1"
388                 AC_TRY_RUN([
389                         #include <sys/types.h>
390
391                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
392
393                         int main(void) {
394                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
395                                                (BIG_OFF_T%2147483647==1));
396                                 if(big_off_t) {
397                                         exit(0);
398                                 } else {
399                                         exit(1);
400                                 }
401                         }
402                 ], [
403                         AC_MSG_RESULT(ok)
404                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
405                         large_CPPFLAGS="$large_CPPFLAGS $1"
406                         large_offt=yes
407                 ], [
408                         AC_MSG_RESULT(no)
409                 ], "")
410                 CPPFLAGS=$large_CPPFLAGS
411         ])
412
413         AC_MSG_CHECKING(if off_t is 64 bits wide)
414         LARGE_FILES("")
415         if test $large_offt = no; then
416                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
417                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
418         fi
419         if test $large_offt = no; then
420                 AC_MSG_WARN([No 64 bit file size support available])
421         fi
422         
423         dnl *****************************
424         dnl *** Checks for libsocket  ***
425         dnl *****************************
426         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
427
428         dnl *******************************
429         dnl *** Checks for MSG_NOSIGNAL ***
430         dnl *******************************
431         AC_MSG_CHECKING(for MSG_NOSIGNAL)
432         AC_TRY_COMPILE([#include <sys/socket.h>], [
433                 int f = MSG_NOSIGNAL;
434         ], [
435                 # Yes, we have it...
436                 AC_MSG_RESULT(yes)
437                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
438         ], [
439                 # We'll have to use signals
440                 AC_MSG_RESULT(no)
441         ])
442
443         dnl *****************************
444         dnl *** Checks for SOL_IP     ***
445         dnl *****************************
446         AC_MSG_CHECKING(for SOL_IP)
447         AC_TRY_COMPILE([#include <netdb.h>], [
448                 int level = SOL_IP;
449         ], [
450                 # Yes, we have it...
451                 AC_MSG_RESULT(yes)
452                 AC_DEFINE(HAVE_SOL_IP)
453         ], [
454                 # We'll have to use getprotobyname
455                 AC_MSG_RESULT(no)
456         ])
457
458         dnl *****************************
459         dnl *** Checks for SOL_IPV6     ***
460         dnl *****************************
461         AC_MSG_CHECKING(for SOL_IPV6)
462         AC_TRY_COMPILE([#include <netdb.h>], [
463                 int level = SOL_IPV6;
464         ], [
465                 # Yes, we have it...
466                 AC_MSG_RESULT(yes)
467                 AC_DEFINE(HAVE_SOL_IPV6)
468         ], [
469                 # We'll have to use getprotobyname
470                 AC_MSG_RESULT(no)
471         ])
472
473         dnl *****************************
474         dnl *** Checks for SOL_TCP    ***
475         dnl *****************************
476         AC_MSG_CHECKING(for SOL_TCP)
477         AC_TRY_COMPILE([#include <netdb.h>], [
478                 int level = SOL_TCP;
479         ], [
480                 # Yes, we have it...
481                 AC_MSG_RESULT(yes)
482                 AC_DEFINE(HAVE_SOL_TCP)
483         ], [
484                 # We'll have to use getprotobyname
485                 AC_MSG_RESULT(no)
486         ])
487
488         dnl *****************************
489         dnl *** Checks for IP_PKTINFO ***
490         dnl *****************************
491         AC_MSG_CHECKING(for IP_PKTINFO)
492         AC_TRY_COMPILE([#include <netdb.h>], [
493                 int level = IP_PKTINFO;
494         ], [
495                 # Yes, we have it...
496                 AC_MSG_RESULT(yes)
497                 AC_DEFINE(HAVE_IP_PKTINFO)
498         ], [
499                 AC_MSG_RESULT(no)
500         ])
501
502         dnl *********************************
503         dnl *** Check for struct ip_mreqn ***
504         dnl *********************************
505         AC_MSG_CHECKING(for struct ip_mreqn)
506         AC_TRY_COMPILE([#include <netinet/in.h>], [
507                 struct ip_mreqn mreq;
508                 mreq.imr_address.s_addr = 0;
509         ], [
510                 # Yes, we have it...
511                 AC_MSG_RESULT(yes)
512                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
513         ], [
514                 # We'll just have to try and use struct ip_mreq
515                 AC_MSG_RESULT(no)
516                 AC_MSG_CHECKING(for struct ip_mreq)
517                 AC_TRY_COMPILE([#include <netinet/in.h>], [
518                         struct ip_mreq mreq;
519                         mreq.imr_interface.s_addr = 0;
520                 ], [
521                         # Yes, we have it...
522                         AC_MSG_RESULT(yes)
523                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
524                 ], [
525                         # No multicast support
526                         AC_MSG_RESULT(no)
527                 ])
528         ])
529         
530         dnl **********************************
531         dnl *** Check for gethostbyname2_r ***
532         dnl **********************************
533         AC_MSG_CHECKING(for gethostbyname2_r)
534                 AC_TRY_LINK([#include <netdb.h>], [
535                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
536         ], [
537                 # Yes, we have it...
538                 AC_MSG_RESULT(yes)
539                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R)
540         ], [
541                 AC_MSG_RESULT(no)
542         ])
543
544         dnl *****************************
545         dnl *** Checks for libnsl     ***
546         dnl *****************************
547         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
548
549         AC_CHECK_FUNCS(inet_pton inet_aton)
550
551         dnl ***********************************************
552         dnl *** Checks for size of sockaddr_un.sun_path ***
553         dnl ***********************************************
554         # AC_CHECK_SIZEOF can't cope with struct members :-(
555         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
556         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
557                 [AC_TRY_RUN([
558                         #include <sys/types.h>
559                         #include <stdio.h>
560                         #include <sys/un.h>
561
562                         int main(void) {
563                                 struct sockaddr_un sock_un;
564                                 FILE *f=fopen("conftestval", "w");
565                                 if(!f) exit(1);
566                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
567                                 exit(0);
568                         }
569                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
570                    cv_mono_sizeof_sunpath=0,
571                    cv_mono_sizeof_sunpath=0)])dnl
572         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
573         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
574
575         dnl *************************************
576         dnl *** Checks for zero length arrays ***
577         dnl *************************************
578         AC_MSG_CHECKING(whether $CC supports zero length arrays)
579         AC_TRY_COMPILE([
580                 struct s {
581                         int  length;
582                         char data [0];
583                 };
584         ], [], [
585                 AC_MSG_RESULT(yes)
586                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 0)
587         ], [
588                 AC_MSG_RESULT(no)
589                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 1)
590         ])
591
592         dnl *****************************
593         dnl *** Checks for libxnet    ***
594         dnl *****************************
595         case "${host}" in
596                 *solaris* )
597                         AC_MSG_CHECKING(for Solaris XPG4 support)
598                         if test -f /usr/lib/libxnet.so; then
599                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
600                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
601                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
602                                 LIBS="$LIBS -lxnet"
603                                 AC_MSG_RESULT(yes)
604                         else
605                                 AC_MSG_RESULT(no)
606                         fi
607
608                         if test "$GCC" = "yes"; then
609                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
610                         fi
611                 ;;
612         esac
613
614         dnl *****************************
615         dnl *** Checks for libpthread ***
616         dnl *****************************
617         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
618         AC_CHECK_HEADERS(pthread.h)
619         AC_CHECK_FUNCS(pthread_mutex_timedlock)
620         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
621         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
622         AC_TRY_COMPILE([ #include <pthread.h>], [
623                 pthread_mutexattr_t attr;
624                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
625         ], [
626                 AC_MSG_RESULT(ok)
627         ], [
628                 AC_MSG_RESULT(no)
629                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
630                 AC_DEFINE(USE_MONO_MUTEX)
631         ])
632         AC_CHECK_FUNCS(pthread_attr_setstacksize)
633
634         dnl ***********************************
635         dnl *** Checks for working __thread ***
636         dnl ***********************************
637         AC_MSG_CHECKING(for working __thread)
638         if test "x$with_nptl" != "xyes"; then
639                 AC_MSG_RESULT(disabled)
640         else
641                 AC_TRY_RUN([
642                         #include <pthread.h>
643
644                         __thread int i;
645                         static int res1, res2;
646
647                         void thread_main (void *arg)
648                         {
649                                 i = arg;
650                                 sleep (1);
651                                 if (arg == 1)
652                                         res1 = (i == arg);
653                                 else
654                                         res2 = (i == arg);
655                         }
656
657                         int main () {
658                                 pthread_t t1, t2;
659
660                                 i = 5;
661
662                                 pthread_create (&t1, NULL, thread_main, 1);
663                                 pthread_create (&t2, NULL, thread_main, 2);
664
665                                 pthread_join (t1, NULL);
666                                 pthread_join (t2, NULL);
667
668                                 return !(res1 + res2 == 2);
669                         }
670                 ], [
671                                 AC_MSG_RESULT(yes)
672                                 AC_DEFINE(HAVE_KW_THREAD)
673                 ], [
674                                 AC_MSG_RESULT(no)
675                 ])
676         fi
677
678         dnl **************************************
679         dnl *** Checks for working sigaltstack ***
680         dnl **************************************
681         AC_MSG_CHECKING(for working sigaltstack)
682         if test "x$with_sigaltstack" != "xyes"; then
683                 AC_MSG_RESULT(disabled)
684         else
685                 AC_TRY_RUN([
686                         #include <stdio.h>
687                         #include <stdlib.h>
688                         #include <unistd.h>
689                         #include <signal.h>
690                         #include <pthread.h>
691                         #include <sys/wait.h>
692
693                         static void
694                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
695                         {
696                                 exit (0);
697                         }
698
699                         static void *
700                         loop (void *ignored)
701                         {
702                                 char *ptr = NULL;
703
704                                 *ptr = 0;
705                                 return NULL;
706                         }
707
708                         static void
709                         child ()
710                         {
711                                 struct sigaction sa;
712                                 struct sigaltstack sas;
713                                 pthread_t id;
714                                 pthread_attr_t attr;
715
716                                 sa.sa_sigaction = sigsegv_signal_handler;
717                                 sigemptyset (&sa.sa_mask);
718                                 sa.sa_flags = SA_SIGINFO | SA_STACK;
719                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
720                                         perror ("lala");
721                                         return;
722                                 }
723
724                                 sas.ss_sp = malloc (SIGSTKSZ);
725                                 sas.ss_size = SIGSTKSZ;
726                                 sas.ss_flags = SS_ONSTACK;
727                                 if (sigaltstack (&sas, NULL) == -1) {
728                                         perror ("lala");
729                                         return;
730                                 }
731
732                                 pthread_attr_init (&attr);
733                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
734                                         printf ("failed\n");
735                                         return;
736                                 }
737
738                                 sleep (100);
739                         }
740
741                         int
742                         main ()
743                         {
744                                 pid_t son;
745                                 int status;
746                                 int i;
747
748                                 son = fork ();
749                                 if (son == -1) {
750                                         return 1;
751                                 }
752
753                                 if (son == 0) {
754                                         child ();
755                                         return 0;
756                                 }
757
758                                 for (i = 0; i < 3; ++i) {
759                                         sleep (1);
760                                         waitpid (son, &status, WNOHANG);
761                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
762                                                 return 0;
763                                 }
764
765                                 kill (son, SIGKILL);
766                                 return 1;
767                         }
768
769                 ], [
770                                 AC_MSG_RESULT(yes)
771                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
772                 ], [
773                                 with_sigaltstack=no
774                                 AC_MSG_RESULT(no)
775                 ])
776         fi
777
778         dnl ********************************
779         dnl *** Checks for semaphore lib ***
780         dnl ********************************
781         # 'Real Time' functions on Solaris
782         # posix4 on Solaris 2.6
783         # pthread (first!) on Linux
784         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
785
786         dnl ********************************
787         dnl *** Checks for timezone stuff **
788         dnl ********************************
789         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
790                 AC_TRY_COMPILE([
791                         #include <time.h>
792                         ], [
793                         struct tm tm;
794                         tm.tm_gmtoff = 1;
795                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
796         if test $ac_cv_struct_tm_gmtoff = yes; then
797                 AC_DEFINE(HAVE_TM_GMTOFF)
798         else
799                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
800                         AC_TRY_COMPILE([
801                                 #include <time.h>
802                         ], [
803                                 timezone = 1;
804                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
805                 if test $ac_cv_var_timezone = yes; then
806                         AC_DEFINE(HAVE_TIMEZONE)
807                 else
808                         AC_ERROR(unable to find a way to determine timezone)
809                 fi
810         fi
811
812         dnl *********************************
813         dnl *** Checks for math functions ***
814         dnl *********************************
815         LIBS="$LIBS -lm";
816         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
817                 AC_TRY_LINK([#include <math.h>], 
818                 [ finite(0.0); ], 
819                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
820                 AC_MSG_RESULT(no)))
821         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
822                 AC_TRY_LINK([#include <math.h>], 
823                 [ isfinite(0.0); ], 
824                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
825                 AC_MSG_RESULT(no)))
826
827         dnl ****************************************************************
828         dnl *** Checks for working poll() (macosx defines it but doesn't ***
829         dnl *** have it in the library (duh))                            ***
830         dnl ****************************************************************
831         AC_CHECK_FUNCS(poll)
832
833         dnl *************************
834         dnl *** Check for signbit ***
835         dnl *************************
836         AC_MSG_CHECKING(for signbit)
837         AC_TRY_LINK([#include <math.h>], [
838                 int s = signbit(1.0);
839         ], [
840                 AC_MSG_RESULT(yes)
841                 AC_DEFINE(HAVE_SIGNBIT)
842         ], [
843                 AC_MSG_RESULT(no)
844         ]) 
845
846         dnl *********************
847         dnl *** Check for AIO ***
848         dnl *********************
849         AC_CHECK_HEADERS(aio.h)
850         AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
851 else
852         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
853         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
854 fi
855
856 dnl socklen_t check
857 AC_MSG_CHECKING(for socklen_t)
858 AC_TRY_COMPILE([
859 #include <sys/types.h>
860 #include <sys/socket.h>
861 ],[
862   socklen_t foo;
863 ],[
864 ac_cv_c_socklen_t=yes
865         AC_DEFINE(HAVE_SOCKLEN_T)
866         AC_MSG_RESULT(yes)
867 ],[
868         AC_MSG_RESULT(no)
869 ])
870
871 AC_CHECK_FUNCS(truncl, , AC_MSG_CHECKING(for truncl in math.h)
872         AC_TRY_LINK([#include <math.h>], 
873         [ truncl(0.0); ], 
874         [
875                 AC_DEFINE(HAVE_TRUNCL) 
876                 AC_MSG_RESULT(yes)
877                 ac_cv_truncl=yes
878         ],
879         AC_MSG_RESULT(no)))
880
881 if test "x$ac_cv_truncl" != "xyes"; then
882    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
883 fi
884
885 dnl ****************************
886 dnl *** Look for /dev/random ***
887 dnl ****************************
888
889 AC_MSG_CHECKING([if usage of random device is requested])
890 AC_ARG_ENABLE(dev-random,
891 [  --disable-dev-random    disable the use of the random device],
892 try_dev_random=$enableval, try_dev_random=yes)
893 AC_MSG_RESULT($try_dev_random)
894
895 case "{$target}" in
896     *-openbsd*)
897     NAME_DEV_RANDOM="/dev/srandom"
898     ;;
899
900 dnl Win32 does not have /dev/random, they have their own method...
901
902     *-*-mingw*|*-*-cygwin*)
903     ac_cv_have_dev_random = no
904     ;;
905
906 dnl Everywhere else, it's /dev/random
907
908     *)
909     NAME_DEV_RANDOM="/dev/random"
910     ;;
911 esac
912
913 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
914
915 dnl Now check if the device actually exists
916
917 if test "x$try_dev_random" = "xyes"; then
918     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
919     [if test -r "$NAME_DEV_RANDOM" ; then
920         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
921     if test "x$ac_cv_have_dev_random" = "xyes"; then
922         AC_DEFINE(HAVE_CRYPT_RNG)
923     fi
924 else
925     AC_MSG_CHECKING(for random device)
926     ac_cv_have_dev_random=no
927     AC_MSG_RESULT(has been disabled)
928 fi
929
930 if test "x$platform_win32" = "xyes"; then
931     AC_DEFINE(HAVE_CRYPT_RNG)
932 fi
933
934 if test "x$ac_cv_have_dev_random" = "xno" \
935     && test "x$platform_win32" = "xno"; then
936     AC_MSG_WARN([[
937 ***
938 *** A system-provided entropy source was not found on this system.
939 *** Because of this, the System.Security.Cryptography random number generator
940 *** will throw a NotImplemented exception.
941 ***
942 *** If you are seeing this message, and you know your system DOES have an
943 *** entropy collection in place, please contact <crichton@gimp.org> and
944 *** provide information about the system and how to access the random device.
945 ***
946 *** For those systems who lack a random device, EGD support is forthcoming.
947 ***]])
948 fi
949  
950 AC_MSG_CHECKING([if inter-process shared handles are requested])
951 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
952 AC_MSG_RESULT($try_shared_handles)
953 if test "x$try_shared_handles" != "xyes"; then
954         AC_DEFINE(DISABLE_SHARED_HANDLES)
955         AC_SUBST(DISABLE_SHARED_HANDLES)
956 fi
957
958 ICU_CFLAGS=""
959 ICU_LIBS=""
960 enable_icu=no
961 AC_PATH_PROG(ICU_CONFIG, icu-config, no)
962 if test "x$ICU_CONFIG" = "xno" -o ! -x "$ICU_CONFIG"; then
963         AC_MSG_WARN([Only invariant locale available; install ICU for I18N support])
964         enable_icu="no, if you want full i18n support download it from: http://oss.software.ibm.com/icu/index.html"
965 else
966         enable_icu="yes. Version: `$ICU_CONFIG --version`"
967         AC_DEFINE(HAVE_ICU)
968         ICU_CFLAGS=`$ICU_CONFIG --cppflags`
969         ICU_LIBS=`$ICU_CONFIG --ldflags`
970 fi
971 AC_SUBST(ICU_CFLAGS)
972 AC_SUBST(ICU_LIBS)
973
974 TARGET="unknown"
975 ACCESS_UNALIGNED="yes"
976
977 JIT_SUPPORTED=no
978 LIBC="libc.so.6"
979
980 jit_wanted=false
981 case "$host" in
982 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
983 #               TARGET=MIPS;
984 #               ACCESS_UNALIGNED="no"
985 #               ;;
986         i*86-*-*)
987                 TARGET=X86;
988                 arch_target=x86;
989                 JIT_SUPPORTED=yes
990                 jit_wanted=true
991                 ;;
992         x86_64-*-* | amd64-*-*)
993                 TARGET=AMD64;
994                 arch_target=amd64;
995                 JIT_SUPPORTED=no
996                 ;;
997         sparc*-*-*)
998                 TARGET=SPARC;
999                 arch_target=sparc;
1000                 JIT_SUPPORTED=yes
1001                 ACCESS_UNALIGNED="no"
1002                 jit_wanted=true
1003                 ;;
1004 #       alpha*-*-linux* | alpha*-*-osf*)
1005 #               TARGET=ALPHA;
1006 #               ACCESS_UNALIGNED="no"
1007 #              ;;
1008 #       ia64-*-linux* | ia64-*-hpux*)
1009 #               TARGET=IA64;
1010 #               arch_target=ia64;
1011 #               JIT_SUPPORTED=no;
1012 #               ACCESS_UNALIGNED="no";
1013 #               case "$host_os" in
1014 #                       linux*) LIBC="libc.so.6.1";;
1015 #                       hpux*)  LIBC="libc.so.1";;
1016 #               esac
1017 #               ;;
1018 #       m68k-*-linux*)
1019 #               TARGET=M68K
1020 #               ;;
1021         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
1022                 TARGET=HPPA;
1023                 arch_target=hppa; 
1024                 ACCESS_UNALIGNED="no"
1025                 ;;
1026         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
1027         powerpc-*-sysv* | powerpc-*-darwin*)
1028                 TARGET=POWERPC;
1029                 arch_target=ppc;
1030                 JIT_SUPPORTED=yes
1031                 ;;
1032         arm-*-linux-* | armv4l-*-linux-*)
1033                 TARGET=ARM;
1034                 arch_target=arm;
1035                 ACCESS_UNALIGNED="no"
1036                 ;;
1037         s390-*-linux*)
1038                 TARGET=S390;
1039                 arch_target=s390;
1040                 ACCESS_UNALIGNED="no"
1041                 ;;
1042 esac
1043
1044 AC_ARG_WITH(jit, [  --with-jit=yes,no    If you want to build scripts that default to the JIT],[
1045         jit_wanted=true
1046 ])
1047
1048 USEJIT=false
1049 if test x$JIT_SUPPORTED = xyes; then
1050    if $jit_wanted; then
1051       USEJIT=true
1052       jit_status="Building and using the JIT"
1053    else
1054       jit_status="Building the JIT, defaulting to the interpreter"
1055    fi
1056 else
1057    jit_status="interpreter"
1058 fi
1059
1060 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
1061
1062 libsuffix=".so"
1063
1064 case "$host" in
1065      powerpc-*-darwin*)
1066         libsuffix=".dylib"
1067         ;;
1068 esac
1069 AC_SUBST(libsuffix)
1070
1071 if test ${TARGET} = ARM; then
1072         dnl ******************************************
1073         dnl *** Check to see what FPU is available ***
1074         dnl ******************************************
1075         AC_MSG_CHECKING(which FPU to use)
1076
1077         AC_TRY_COMPILE([], [
1078                 __asm__ ("ldfd f0, [r0]");
1079                 ], fpu=FPA, [
1080                         AC_TRY_COMPILE([], [
1081                                 __asm__ ("fldd d0, [r0]");
1082                         ], fpu=VFP, fpu=NONE)
1083                 ])
1084
1085         AC_MSG_RESULT($fpu)
1086         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
1087         unset fpu
1088 fi
1089
1090 if test ${TARGET} = unknown; then
1091         CPPFLAGS="$CPPFLAGS -DNO_PORT"
1092         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
1093 fi
1094
1095 if test ${ACCESS_UNALIGNED} = no; then
1096         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
1097 fi
1098
1099 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
1100 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
1101 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
1102 AM_CONDITIONAL(X86, test x$TARGET = xX86)
1103 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
1104 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
1105 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
1106 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
1107 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
1108 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
1109 AM_CONDITIONAL(S390, test x$TARGET = xS390)
1110 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
1111
1112 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
1113
1114 AC_SUBST(LIBC)
1115
1116 AC_SUBST(arch_target)
1117 AC_SUBST(CFLAGS)
1118 AC_SUBST(CPPFLAGS)
1119 AC_SUBST(LDFLAGS)
1120
1121 AC_OUTPUT([
1122 Makefile
1123 mint.pc
1124 mono.pc
1125 mono/Makefile
1126 mono/utils/Makefile
1127 mono/metadata/Makefile
1128 mono/dis/Makefile
1129 mono/cil/Makefile
1130 mono/arch/Makefile
1131 mono/os/Makefile
1132 mono/os/win32/Makefile
1133 mono/os/unix/Makefile
1134 mono/arch/x86/Makefile
1135 mono/arch/amd64/Makefile
1136 mono/arch/hppa/Makefile
1137 mono/arch/ppc/Makefile
1138 mono/arch/sparc/Makefile
1139 mono/arch/s390/Makefile
1140 mono/arch/arm/Makefile
1141 mono/arch/alpha/Makefile
1142 mono/interpreter/Makefile
1143 mono/tests/Makefile
1144 mono/tests/tests-config
1145 mono/benchmark/Makefile
1146 mono/monoburg/Makefile
1147 mono/monograph/Makefile
1148 mono/io-layer/Makefile
1149 mono/handles/Makefile
1150 mono/mini/Makefile
1151 mono/profiler/Makefile
1152 ikvm-jni/Makefile
1153 runtime/Makefile
1154 scripts/Makefile
1155 man/Makefile
1156 web/Makefile
1157 docs/Makefile
1158 data/Makefile
1159 samples/Makefile
1160 support/Makefile
1161 data/config
1162 mono.spec
1163 ])
1164
1165 echo "
1166
1167         GC:          $gc
1168         ICU:         $enable_icu
1169         NPTL:        $with_nptl
1170         SIGALTSTACK: $with_sigaltstack
1171         Engine:      $jit_status
1172         
1173 "