2004-03-17 Jesper Pedersen <jep@itplus.dk>
[mono.git] / configure.in
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(mono,0.30.99.3)
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 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
118
119 AC_CHECK_TOOL(CC, gcc, gcc)
120 AC_PROG_CC
121 AM_PROG_CC_STDC
122 AC_PROG_INSTALL
123 dnl We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
124 : ${CCAS='$(CC)'}
125 # Set ASFLAGS if not already set.
126 : ${CCASFLAGS='$(CFLAGS)'}
127 AC_SUBST(CCAS)
128 AC_SUBST(CCASFLAGS)
129
130 AC_CHECK_PROG(BISON, bison,yes,no)
131 if test "x$BISON" = "xno";
132 then
133         AC_MSG_ERROR([You need to install bison])
134 fi
135
136 dnl may require a specific autoconf version
137 dnl AC_PROG_CC_FOR_BUILD
138 dnl CC_FOR_BUILD not automatically detected
139 CC_FOR_BUILD=$CC
140 BUILD_EXEEXT=
141 if test "x$cross_compiling" = "xyes"; then
142         CC_FOR_BUILD=cc
143         BUILD_EXEEXT=""
144 fi
145 AC_SUBST(CC_FOR_BUILD)
146 AC_SUBST(HOST_CC)
147 AC_SUBST(BUILD_EXEEXT)
148
149 # Set STDC_HEADERS
150 AC_HEADER_STDC
151 AC_LIBTOOL_WIN32_DLL
152 AM_PROG_LIBTOOL
153
154 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h)
155
156 # for mono/mini/tramp-x86.c
157 AC_CHECK_HEADERS(valgrind/memcheck.h)
158
159 # for mono/metadata/debug-symfile.c
160 AC_CHECK_HEADERS(elf.h)
161
162 # for mono/dis
163 AC_CHECK_HEADERS(wchar.h)
164
165 # not 64 bit clean in cross-compile
166 AC_CHECK_SIZEOF(void *, 4)
167
168 WARN=''
169 if test x"$GCC" = xyes; then
170         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
171                 # The runtime code does not respect ANSI C strict aliasing rules
172                 CFLAGS="$CFLAGS -fno-strict-aliasing"
173 else
174         # The Sun Forte compiler complains about inline functions that access static variables
175         # so disable all inlining.
176         case "$host" in
177         *-*-solaris*)
178                 CFLAGS="$CFLAGS -Dinline="
179                 ;;
180         esac
181 fi
182 CFLAGS="$CFLAGS -g $WARN"
183
184 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
185 if test "x$PKG_CONFIG" = "xno"; then
186         AC_MSG_ERROR([You need to install pkg-config])
187 fi
188
189 dnl for use on the build system
190 dnl pkg-config is stupid
191 BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
192 BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
193 AC_SUBST(BUILD_GLIB_CFLAGS)
194 AC_SUBST(BUILD_GLIB_LIBS)
195
196 PKG_PATH=
197 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
198         if test x$with_crosspkgdir = "x"; then
199                 if test -s $PKG_CONFIG_PATH; then
200                         PKG_PATH=$PKG_CONFIG_PATH
201                 fi
202         else
203                 PKG_PATH=$with_crosspkgdir
204                 PKG_CONFIG_PATH=$PKG_PATH
205                 export PKG_CONFIG_PATH
206         fi
207 )
208
209 ## Versions of dependencies
210 GLIB_REQUIRED_VERSION=1.3.11
211
212 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
213
214 GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
215 GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
216 GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
217 GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
218
219 AC_SUBST(GLIB_CFLAGS)
220 AC_SUBST(GLIB_LIBS)
221 AC_SUBST(GMODULE_CFLAGS)
222 AC_SUBST(GMODULE_LIBS)
223
224 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
225
226 # Enable support for NPTL only features like fast thread-local storage
227 # We can't reliably detect nptl at compile & run time
228 # so this option will stay until nptl becomes more widespread
229 AC_ARG_WITH(nptl, [  --with-nptl=yes,no      enable/disable support for NPTL],[],[with_nptl=yes])
230
231 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
232 # This does not work on some platforms (bug #55253)
233 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack],[],[with_sigaltstack=yes])
234
235 if test x$with_sigaltstack = "xyes"; then
236         AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
237 fi
238
239 # assembly bundle support, see metadata/make-bundle.pl for more info
240 AC_ARG_WITH(bundle, [  --with-bundle=bundle_template],[
241         BUNDLE_FILE=$with_bundle
242         AC_SUBST(BUNDLE_FILE)
243         AC_DEFINE(WITH_BUNDLE)
244 ],[with_bundle=no])
245 AM_CONDITIONAL(WITH_BUNDLE, test x$with_bundle != xno)
246
247 LIBGC_CFLAGS=
248 LIBGC_LIBS=
249 libgc_dir=
250 case "x$gc" in
251         xboehm|xbohem|xyes)
252                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
253                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
254
255                 if test "x$found_boehm" != "xyes"; then
256                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
257                 fi
258                 if test "x$gc_headers" != "xyes"; then
259                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
260                 fi
261
262                 AC_DEFINE(HAVE_BOEHM_GC)
263                 AC_SUBST(HAVE_BOEHM_GC)
264                 LIBGC_LIBS="-lgc $libdl"
265
266                 # AC_CHECK_FUNCS does not work for some reason...
267                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
268                 if test "x$found_gcj_malloc" = "xyes"; then
269                         AC_DEFINE(HAVE_GC_GCJ_MALLOC)
270                 fi
271                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
272                 if test "x$found_gc_enable" = "xyes"; then
273                         AC_DEFINE(HAVE_GC_ENABLE)
274                 fi
275                 ;;
276
277         xincluded)
278                 AC_CONFIG_SUBDIRS(libgc)
279
280                 found_boehm=yes
281                 gc_headers=yes
282                 use_included_gc=yes
283                 libgc_dir=libgc
284
285                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
286                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
287
288                 AC_DEFINE(HAVE_BOEHM_GC)
289                 AC_SUBST(HAVE_BOEHM_GC)
290
291                 AC_DEFINE(HAVE_GC_H)
292                 AC_DEFINE(USE_INCLUDED_LIBGC)
293
294                 # The included libgc contains GCJ support
295                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
296                 AC_DEFINE(HAVE_GC_ENABLE)
297                 ;;
298
299         xnone)
300                 AC_MSG_WARN("Compiling mono without GC.")
301                 ;;
302         *)
303                 AC_MSG_ERROR([Invalid argument to --with-gc.])
304                 ;;
305 esac
306
307 we_are_embedded_in_mono=yes
308 export we_are_embedded_in_mono
309 export libgc_threads
310
311 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
312 AC_SUBST(LIBGC_CFLAGS)
313 AC_SUBST(LIBGC_LIBS)
314 AC_SUBST(libgc_dir)
315
316 dnl
317 dnl End of libgc checks
318 dnl
319
320 if test x$platform_win32 = xno; then
321         dnl ******************************************************************
322         dnl *** Check for large file support                               ***
323         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
324         dnl ******************************************************************
325         
326         # Check that off_t can represent 2**63 - 1 correctly, working around
327         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
328         # CPPFLAGS and sets $large_offt to yes if the test succeeds
329         large_offt=no
330         AC_DEFUN(LARGE_FILES, [
331                 large_CPPFLAGS=$CPPFLAGS
332                 CPPFLAGS="$CPPFLAGS $1"
333                 AC_TRY_RUN([
334                         #include <sys/types.h>
335
336                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
337
338                         int main(void) {
339                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
340                                                (BIG_OFF_T%2147483647==1));
341                                 if(big_off_t) {
342                                         exit(0);
343                                 } else {
344                                         exit(1);
345                                 }
346                         }
347                 ], [
348                         AC_MSG_RESULT(ok)
349                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
350                         large_CPPFLAGS="$large_CPPFLAGS $1"
351                         large_offt=yes
352                 ], [
353                         AC_MSG_RESULT(no)
354                 ], "")
355                 CPPFLAGS=$large_CPPFLAGS
356         ])
357
358         AC_MSG_CHECKING(if off_t is 64 bits wide)
359         LARGE_FILES("")
360         if test $large_offt = no; then
361                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
362                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
363         fi
364         if test $large_offt = no; then
365                 AC_MSG_WARN([No 64 bit file size support available])
366         fi
367         
368         dnl *****************************
369         dnl *** Checks for libsocket  ***
370         dnl *****************************
371         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
372
373         dnl *******************************
374         dnl *** Checks for MSG_NOSIGNAL ***
375         dnl *******************************
376         AC_MSG_CHECKING(for MSG_NOSIGNAL)
377         AC_TRY_COMPILE([#include <sys/socket.h>], [
378                 int f = MSG_NOSIGNAL;
379         ], [
380                 # Yes, we have it...
381                 AC_MSG_RESULT(yes)
382                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
383         ], [
384                 # We'll have to use signals
385                 AC_MSG_RESULT(no)
386         ])
387
388         dnl *****************************
389         dnl *** Checks for SOL_IP     ***
390         dnl *****************************
391         AC_MSG_CHECKING(for SOL_IP)
392         AC_TRY_COMPILE([#include <netdb.h>], [
393                 int level = SOL_IP;
394         ], [
395                 # Yes, we have it...
396                 AC_MSG_RESULT(yes)
397                 AC_DEFINE(HAVE_SOL_IP)
398         ], [
399                 # We'll have to use getprotobyname
400                 AC_MSG_RESULT(no)
401         ])
402
403         dnl *****************************
404         dnl *** Checks for SOL_IPV6     ***
405         dnl *****************************
406         AC_MSG_CHECKING(for SOL_IPV6)
407         AC_TRY_COMPILE([#include <netdb.h>], [
408                 int level = SOL_IPV6;
409         ], [
410                 # Yes, we have it...
411                 AC_MSG_RESULT(yes)
412                 AC_DEFINE(HAVE_SOL_IPV6)
413         ], [
414                 # We'll have to use getprotobyname
415                 AC_MSG_RESULT(no)
416         ])
417
418         dnl *****************************
419         dnl *** Checks for SOL_TCP    ***
420         dnl *****************************
421         AC_MSG_CHECKING(for SOL_TCP)
422         AC_TRY_COMPILE([#include <netdb.h>], [
423                 int level = SOL_TCP;
424         ], [
425                 # Yes, we have it...
426                 AC_MSG_RESULT(yes)
427                 AC_DEFINE(HAVE_SOL_TCP)
428         ], [
429                 # We'll have to use getprotobyname
430                 AC_MSG_RESULT(no)
431         ])
432
433         dnl *****************************
434         dnl *** Checks for IP_PKTINFO ***
435         dnl *****************************
436         AC_MSG_CHECKING(for IP_PKTINFO)
437         AC_TRY_COMPILE([#include <netdb.h>], [
438                 int level = IP_PKTINFO;
439         ], [
440                 # Yes, we have it...
441                 AC_MSG_RESULT(yes)
442                 AC_DEFINE(HAVE_IP_PKTINFO)
443         ], [
444                 AC_MSG_RESULT(no)
445         ])
446
447         dnl *********************************
448         dnl *** Check for struct ip_mreqn ***
449         dnl *********************************
450         AC_MSG_CHECKING(for struct ip_mreqn)
451         AC_TRY_COMPILE([#include <netinet/in.h>], [
452                 struct ip_mreqn mreq;
453                 mreq.imr_address.s_addr = 0;
454         ], [
455                 # Yes, we have it...
456                 AC_MSG_RESULT(yes)
457                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
458         ], [
459                 # We'll just have to try and use struct ip_mreq
460                 AC_MSG_RESULT(no)
461                 AC_MSG_CHECKING(for struct ip_mreq)
462                 AC_TRY_COMPILE([#include <netinet/in.h>], [
463                         struct ip_mreq mreq;
464                         mreq.imr_interface.s_addr = 0;
465                 ], [
466                         # Yes, we have it...
467                         AC_MSG_RESULT(yes)
468                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
469                 ], [
470                         # No multicast support
471                         AC_MSG_RESULT(no)
472                 ])
473         ])
474         
475         dnl **********************************
476         dnl *** Check for gethostbyname2_r ***
477         dnl **********************************
478         AC_MSG_CHECKING(for gethostbyname2_r)
479                 AC_TRY_LINK([#include <netdb.h>], [
480                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
481         ], [
482                 # Yes, we have it...
483                 AC_MSG_RESULT(yes)
484                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R)
485         ], [
486                 AC_MSG_RESULT(no)
487         ])
488
489         dnl *****************************
490         dnl *** Checks for libnsl     ***
491         dnl *****************************
492         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
493
494         AC_CHECK_FUNCS(inet_pton inet_aton)
495
496         dnl ***********************************************
497         dnl *** Checks for size of sockaddr_un.sun_path ***
498         dnl ***********************************************
499         # AC_CHECK_SIZEOF can't cope with struct members :-(
500         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
501         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
502                 [AC_TRY_RUN([
503                         #include <sys/types.h>
504                         #include <stdio.h>
505                         #include <sys/un.h>
506
507                         int main(void) {
508                                 struct sockaddr_un sock_un;
509                                 FILE *f=fopen("conftestval", "w");
510                                 if(!f) exit(1);
511                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
512                                 exit(0);
513                         }
514                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
515                    cv_mono_sizeof_sunpath=0,
516                    cv_mono_sizeof_sunpath=0)])dnl
517         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
518         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
519
520         dnl *************************************
521         dnl *** Checks for zero length arrays ***
522         dnl *************************************
523         AC_MSG_CHECKING(whether $CC supports zero length arrays)
524         AC_TRY_COMPILE([
525                 struct s {
526                         int  length;
527                         char data [0];
528                 };
529         ], [], [
530                 AC_MSG_RESULT(yes)
531                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 0)
532         ], [
533                 AC_MSG_RESULT(no)
534                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 1)
535         ])
536
537         dnl *****************************
538         dnl *** Checks for libxnet    ***
539         dnl *****************************
540         case "${host}" in
541                 *solaris* )
542                         AC_MSG_CHECKING(for Solaris XPG4 support)
543                         if test -f /usr/lib/libxnet.so; then
544                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
545                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
546                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
547                                 LIBS="$LIBS -lxnet"
548                                 AC_MSG_RESULT(yes)
549                         else
550                                 AC_MSG_RESULT(no)
551                         fi
552
553                         if test "$GCC" = "yes"; then
554                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
555                         fi
556                 ;;
557         esac
558
559         dnl *****************************
560         dnl *** Checks for libpthread ***
561         dnl *****************************
562         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
563         AC_CHECK_HEADERS(pthread.h)
564         AC_CHECK_FUNCS(pthread_mutex_timedlock)
565         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
566         AC_TRY_COMPILE([ #include <pthread.h>], [
567                 pthread_mutexattr_t attr;
568                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
569         ], [
570                 AC_MSG_RESULT(ok)
571         ], [
572                 AC_MSG_RESULT(no)
573                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
574                 AC_DEFINE(USE_MONO_MUTEX)
575         ])
576         AC_CHECK_FUNCS(pthread_attr_setstacksize)
577
578         dnl ***********************************
579         dnl *** Checks for working __thread ***
580         dnl ***********************************
581         AC_MSG_CHECKING(for working __thread)
582         AC_TRY_RUN([
583                 #include <pthread.h>
584
585                 __thread int i;
586                 static int res1, res2;
587
588                 void thread_main (void *arg)
589                 {
590                         i = arg;
591                         sleep (1);
592                         if (arg == 1)
593                                 res1 = (i == arg);
594                         else
595                                 res2 = (i == arg);
596                 }
597
598                 int main () {
599                         pthread_t t1, t2;
600
601                         i = 5;
602
603                         pthread_create (&t1, NULL, thread_main, 1);
604                         pthread_create (&t2, NULL, thread_main, 2);
605
606                         pthread_join (t1, NULL);
607                         pthread_join (t2, NULL);
608
609                         return !(res1 + res2 == 2);
610                 }
611         ], [
612                         if test "x$with_nptl" != "xyes"; then
613                                 AC_MSG_RESULT(disabled)
614                         else
615                                 AC_MSG_RESULT(yes)
616                                 AC_DEFINE(HAVE_KW_THREAD)
617                         fi
618         ], [
619                         AC_MSG_RESULT(no)
620         ])
621
622         dnl ********************************
623         dnl *** Checks for semaphore lib ***
624         dnl ********************************
625         # 'Real Time' functions on Solaris
626         # posix4 on Solaris 2.6
627         # pthread (first!) on Linux
628         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
629
630         dnl ********************************
631         dnl *** Checks for timezone stuff **
632         dnl ********************************
633         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
634                 AC_TRY_COMPILE([
635                         #include <time.h>
636                         ], [
637                         struct tm tm;
638                         tm.tm_gmtoff = 1;
639                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
640         if test $ac_cv_struct_tm_gmtoff = yes; then
641                 AC_DEFINE(HAVE_TM_GMTOFF)
642         else
643                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
644                         AC_TRY_COMPILE([
645                                 #include <time.h>
646                         ], [
647                                 timezone = 1;
648                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
649                 if test $ac_cv_var_timezone = yes; then
650                         AC_DEFINE(HAVE_TIMEZONE)
651                 else
652                         AC_ERROR(unable to find a way to determine timezone)
653                 fi
654         fi
655
656         dnl *********************************
657         dnl *** Checks for math functions ***
658         dnl *********************************
659         LIBS="$LIBS -lm";
660         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
661                 AC_TRY_LINK([#include <math.h>], 
662                 [ finite(0.0); ], 
663                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
664                 AC_MSG_RESULT(no)))
665         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
666                 AC_TRY_LINK([#include <math.h>], 
667                 [ isfinite(0.0); ], 
668                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
669                 AC_MSG_RESULT(no)))
670
671         dnl ****************************************************************
672         dnl *** Checks for working poll() (macosx defines it but doesn't ***
673         dnl *** have it in the library (duh))                            ***
674         dnl ****************************************************************
675         AC_CHECK_FUNCS(poll)
676
677         dnl *************************
678         dnl *** Check for signbit ***
679         dnl *************************
680         AC_MSG_CHECKING(for signbit)
681         AC_TRY_LINK([#include <math.h>], [
682                 int s = signbit(1.0);
683         ], [
684                 AC_MSG_RESULT(yes)
685                 AC_DEFINE(HAVE_SIGNBIT)
686         ], [
687                 AC_MSG_RESULT(no)
688         ]) 
689
690         dnl *********************
691         dnl *** Check for AIO ***
692         dnl *********************
693         AC_CHECK_HEADERS(aio.h)
694         AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
695 else
696         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
697         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
698 fi
699
700 dnl socklen_t check
701 AC_MSG_CHECKING(for socklen_t)
702 AC_TRY_COMPILE([
703 #include <sys/types.h>
704 #include <sys/socket.h>
705 ],[
706   socklen_t foo;
707 ],[
708 ac_cv_c_socklen_t=yes
709         AC_DEFINE(HAVE_SOCKLEN_T)
710         AC_MSG_RESULT(yes)
711 ],[
712         AC_MSG_RESULT(no)
713 ])
714
715 AC_CHECK_FUNCS(truncl, , AC_MSG_CHECKING(for truncl in math.h)
716         AC_TRY_LINK([#include <math.h>], 
717         [ truncl(0.0); ], 
718         [
719                 AC_DEFINE(HAVE_TRUNCL) 
720                 AC_MSG_RESULT(yes)
721                 ac_cv_truncl=yes
722         ],
723         AC_MSG_RESULT(no)))
724
725 if test "x$ac_cv_truncl" != "xyes"; then
726    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
727 fi
728
729 dnl ****************************
730 dnl *** Look for /dev/random ***
731 dnl ****************************
732
733 AC_MSG_CHECKING([if usage of random device is requested])
734 AC_ARG_ENABLE(dev-random,
735 [  --disable-dev-random    disable the use of the random device],
736 try_dev_random=$enableval, try_dev_random=yes)
737 AC_MSG_RESULT($try_dev_random)
738
739 case "{$target}" in
740     *-openbsd*)
741     NAME_DEV_RANDOM="/dev/srandom"
742     ;;
743
744 dnl Win32 does not have /dev/random, they have their own method...
745
746     *-*-mingw*|*-*-cygwin*)
747     ac_cv_have_dev_random = no
748     ;;
749
750 dnl Everywhere else, it's /dev/random
751
752     *)
753     NAME_DEV_RANDOM="/dev/random"
754     ;;
755 esac
756
757 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
758
759 dnl Now check if the device actually exists
760
761 if test "x$try_dev_random" = "xyes"; then
762     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
763     [if test -r "$NAME_DEV_RANDOM" ; then
764         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
765     if test "x$ac_cv_have_dev_random" = "xyes"; then
766         AC_DEFINE(HAVE_CRYPT_RNG)
767     fi
768 else
769     AC_MSG_CHECKING(for random device)
770     ac_cv_have_dev_random=no
771     AC_MSG_RESULT(has been disabled)
772 fi
773
774 if test "x$platform_win32" = "xyes"; then
775     AC_DEFINE(HAVE_CRYPT_RNG)
776 fi
777
778 if test "x$ac_cv_have_dev_random" = "xno" \
779     && test "x$platform_win32" = "xno"; then
780     AC_MSG_WARN([[
781 ***
782 *** A system-provided entropy source was not found on this system.
783 *** Because of this, the System.Security.Cryptography random number generator
784 *** will throw a NotImplemented exception.
785 ***
786 *** If you are seeing this message, and you know your system DOES have an
787 *** entropy collection in place, please contact <crichton@gimp.org> and
788 *** provide information about the system and how to access the random device.
789 ***
790 *** For those systems who lack a random device, EGD support is forthcoming.
791 ***]])
792 fi
793  
794 AC_MSG_CHECKING([if inter-process shared handles are requested])
795 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
796 AC_MSG_RESULT($try_shared_handles)
797 if test "x$try_shared_handles" != "xyes"; then
798         AC_DEFINE(DISABLE_SHARED_HANDLES)
799         AC_SUBST(DISABLE_SHARED_HANDLES)
800 fi
801
802 ICU_CFLAGS=""
803 ICU_LIBS=""
804 enable_icu=no
805 AC_PATH_PROG(ICU_CONFIG, icu-config, no)
806 if test "x$ICU_CONFIG" = "xno" -o ! -x "$ICU_CONFIG"; then
807         AC_MSG_WARN([Only invariant locale available; install ICU for I18N support])
808         enable_icu="no, if you want full i18n support download it from: http://oss.software.ibm.com/icu/index.html"
809 else
810         enable_icu="yes. Version: `$ICU_CONFIG --version`"
811         AC_DEFINE(HAVE_ICU)
812         ICU_CFLAGS=`$ICU_CONFIG --cppflags`
813         ICU_LIBS=`$ICU_CONFIG --ldflags`
814 fi
815 AC_SUBST(ICU_CFLAGS)
816 AC_SUBST(ICU_LIBS)
817
818 TARGET="unknown"
819 ACCESS_UNALIGNED="yes"
820
821 JIT_SUPPORTED=no
822 LIBC="libc.so.6"
823
824 case "$host" in
825 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
826 #               TARGET=MIPS;
827 #               ACCESS_UNALIGNED="no"
828 #               ;;
829         i*86-*-*)
830                 TARGET=X86;
831                 arch_target=x86;
832                 JIT_SUPPORTED=yes
833                 ;;
834         x86_64-*-* | amd64-*-*)
835                 TARGET=AMD64;
836                 arch_target=x86-64;
837                 JIT_SUPPORTED=no
838                 ;;
839         sparc*-*-*)
840                 TARGET=SPARC;
841                 arch_target=sparc;
842                 JIT_SUPPORTED=yes
843                 ACCESS_UNALIGNED="no"
844                 ;;
845 #       alpha*-*-linux* | alpha*-*-osf*)
846 #               TARGET=ALPHA;
847 #               ACCESS_UNALIGNED="no"
848 #              ;;
849 #       ia64-*-linux* | ia64-*-hpux*)
850 #               TARGET=IA64;
851 #               arch_target=ia64;
852 #               JIT_SUPPORTED=no;
853 #               ACCESS_UNALIGNED="no";
854 #               case "$host_os" in
855 #                       linux*) LIBC="libc.so.6.1";;
856 #                       hpux*)  LIBC="libc.so.1";;
857 #               esac
858 #               ;;
859 #       m68k-*-linux*)
860 #               TARGET=M68K
861 #               ;;
862         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
863                 TARGET=HPPA;
864                 arch_target=hppa; 
865                 ACCESS_UNALIGNED="no"
866                 ;;
867         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
868         powerpc-*-sysv* | powerpc-*-darwin*)
869                 TARGET=POWERPC;
870                 arch_target=ppc;
871                 JIT_SUPPORTED=yes
872                 ;;
873         arm-*-linux-* | armv4l-*-linux-*)
874                 TARGET=ARM;
875                 arch_target=arm;
876                 ACCESS_UNALIGNED="no"
877                 ;;
878         s390-*-linux*)
879                 TARGET=S390;
880                 arch_target=s390;
881                 ACCESS_UNALIGNED="no"
882                 ;;
883 esac
884
885 libsuffix=".so"
886
887 case "$host" in
888      powerpc-*-darwin*)
889         libsuffix=".dylib"
890         ;;
891 esac
892 AC_SUBST(libsuffix)
893
894 if test ${TARGET} = ARM; then
895         dnl ******************************************
896         dnl *** Check to see what FPU is available ***
897         dnl ******************************************
898         AC_MSG_CHECKING(which FPU to use)
899
900         AC_TRY_COMPILE([], [
901                 __asm__ ("ldfd f0, [r0]");
902                 ], fpu=FPA, [
903                         AC_TRY_COMPILE([], [
904                                 __asm__ ("fldd d0, [r0]");
905                         ], fpu=VFP, fpu=NONE)
906                 ])
907
908         AC_MSG_RESULT($fpu)
909         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
910         unset fpu
911 fi
912
913 if test ${TARGET} = unknown; then
914         CPPFLAGS="$CPPFLAGS -DNO_PORT"
915         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
916 fi
917
918 if test ${ACCESS_UNALIGNED} = no; then
919         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
920 fi
921
922 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
923 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
924 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
925 AM_CONDITIONAL(X86, test x$TARGET = xX86)
926 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
927 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
928 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
929 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
930 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
931 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
932 AM_CONDITIONAL(S390, test x$TARGET = xS390)
933 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
934
935 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
936
937 AC_SUBST(LIBC)
938
939 AC_SUBST(arch_target)
940 AC_SUBST(CFLAGS)
941 AC_SUBST(CPPFLAGS)
942 AC_SUBST(LDFLAGS)
943
944 AC_OUTPUT([
945 Makefile
946 mint.pc
947 mono.pc
948 mono/Makefile
949 mono/utils/Makefile
950 mono/metadata/Makefile
951 mono/dis/Makefile
952 mono/cil/Makefile
953 mono/arch/Makefile
954 mono/os/Makefile
955 mono/os/win32/Makefile
956 mono/os/unix/Makefile
957 mono/arch/x86/Makefile
958 mono/arch/amd64/Makefile
959 mono/arch/hppa/Makefile
960 mono/arch/ppc/Makefile
961 mono/arch/sparc/Makefile
962 mono/arch/s390/Makefile
963 mono/arch/arm/Makefile
964 mono/arch/alpha/Makefile
965 mono/interpreter/Makefile
966 mono/tests/Makefile
967 mono/tests/tests-config
968 mono/benchmark/Makefile
969 mono/monoburg/Makefile
970 mono/monograph/Makefile
971 mono/io-layer/Makefile
972 mono/handles/Makefile
973 mono/mini/Makefile
974 mono/profiler/Makefile
975 runtime/Makefile
976 scripts/Makefile
977 man/Makefile
978 web/Makefile
979 docs/Makefile
980 data/Makefile
981 samples/Makefile
982 support/Makefile
983 data/config
984 mono.spec
985 ])
986
987 echo "
988
989         GC:     $gc
990         ICU:    $enable_icu
991         NPTL:   $with_nptl
992         SIGALTSTACK: $with_sigaltstack
993 "