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