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