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