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