44385674927a7a0474f0c2ef193dd1060811da2d
[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_HEADERS(pthread.h)
536         AC_CHECK_FUNCS(pthread_mutex_timedlock)
537         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
538         AC_TRY_COMPILE([ #include <pthread.h>], [
539                 pthread_mutexattr_t attr;
540                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
541         ], [
542                 AC_MSG_RESULT(ok)
543         ], [
544                 AC_MSG_RESULT(no)
545                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
546                 AC_DEFINE(USE_MONO_MUTEX)
547         ])
548         AC_CHECK_FUNCS(pthread_attr_setstacksize)
549
550         dnl ***********************************
551         dnl *** Checks for working __thread ***
552         dnl ***********************************
553         AC_MSG_CHECKING(for working __thread)
554         AC_TRY_RUN([
555                 #include <pthread.h>
556
557                 __thread int i;
558                 static int res1, res2;
559
560                 void thread_main (void *arg)
561                 {
562                         i = arg;
563                         sleep (1);
564                         if (arg == 1)
565                                 res1 = (i == arg);
566                         else
567                                 res2 = (i == arg);
568                 }
569
570                 int main () {
571                         pthread_t t1, t2;
572
573                         i = 5;
574
575                         pthread_create (&t1, NULL, thread_main, 1);
576                         pthread_create (&t2, NULL, thread_main, 2);
577
578                         pthread_join (t1, NULL);
579                         pthread_join (t2, NULL);
580
581                         return !(res1 + res2 == 2);
582                 }
583         ], [
584                         AC_MSG_RESULT(yes)
585                         AC_DEFINE(HAVE_KW_THREAD)
586         ], [
587                         AC_MSG_RESULT(no)
588         ])
589
590         dnl ********************************
591         dnl *** Checks for semaphore lib ***
592         dnl ********************************
593         AC_CHECK_LIB(rt, sem_init, LIBS="$LIBS -lrt")
594
595         dnl ********************************
596         dnl *** Checks for timezone stuff **
597         dnl ********************************
598         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
599                 AC_TRY_COMPILE([
600                         #include <time.h>
601                         ], [
602                         struct tm tm;
603                         tm.tm_gmtoff = 1;
604                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
605         if test $ac_cv_struct_tm_gmtoff = yes; then
606                 AC_DEFINE(HAVE_TM_GMTOFF)
607         else
608                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
609                         AC_TRY_COMPILE([
610                                 #include <time.h>
611                         ], [
612                                 timezone = 1;
613                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
614                 if test $ac_cv_var_timezone = yes; then
615                         AC_DEFINE(HAVE_TIMEZONE)
616                 else
617                         AC_ERROR(unable to find a way to determine timezone)
618                 fi
619         fi
620
621         dnl *********************************
622         dnl *** Checks for math functions ***
623         dnl *********************************
624         LIBS="$LIBS -lm";
625         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
626                 AC_TRY_LINK([#include <math.h>], 
627                 [ finite(0.0); ], 
628                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
629                 AC_MSG_RESULT(no)))
630         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
631                 AC_TRY_LINK([#include <math.h>], 
632                 [ isfinite(0.0); ], 
633                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
634                 AC_MSG_RESULT(no)))
635
636         dnl ****************************************************************
637         dnl *** Checks for working poll() (macosx defines it but doesn't ***
638         dnl *** have it in the library (duh))                            ***
639         dnl ****************************************************************
640         AC_CHECK_FUNCS(poll)
641 else
642         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
643         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
644 fi
645
646 dnl ****************************
647 dnl *** Look for /dev/random ***
648 dnl ****************************
649
650 AC_MSG_CHECKING([if usage of random device is requested])
651 AC_ARG_ENABLE(dev-random,
652 [  --disable-dev-random    disable the use of the random device],
653 try_dev_random=$enableval, try_dev_random=yes)
654 AC_MSG_RESULT($try_dev_random)
655
656 case "{$target}" in
657     *-openbsd*)
658     NAME_DEV_RANDOM="/dev/srandom"
659     ;;
660
661 dnl Win32 does not have /dev/random, they have their own method...
662
663     *-*-mingw*|*-*-cygwin*)
664     ac_cv_have_dev_random = no
665     ;;
666
667 dnl Everywhere else, it's /dev/random
668
669     *)
670     NAME_DEV_RANDOM="/dev/random"
671     ;;
672 esac
673
674 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
675
676 dnl Now check if the device actually exists
677
678 if test "x$try_dev_random" = "xyes"; then
679     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
680     [if test -r "$NAME_DEV_RANDOM" ; then
681         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
682     if test "x$ac_cv_have_dev_random" = "xyes"; then
683         AC_DEFINE(HAVE_CRYPT_RNG)
684     fi
685 else
686     AC_MSG_CHECKING(for random device)
687     ac_cv_have_dev_random=no
688     AC_MSG_RESULT(has been disabled)
689 fi
690
691 if test "x$platform_win32" = "xyes"; then
692     AC_DEFINE(HAVE_CRYPT_RNG)
693 fi
694
695 if test "x$ac_cv_have_dev_random" = "xno" \
696     && test "x$platform_win32" = "xno"; then
697     AC_MSG_WARN([[
698 ***
699 *** A system-provided entropy source was not found on this system.
700 *** Because of this, the System.Security.Cryptography random number generator
701 *** will throw a NotImplemented exception.
702 ***
703 *** If you are seeing this message, and you know your system DOES have an
704 *** entropy collection in place, please contact <crichton@gimp.org> and
705 *** provide information about the system and how to access the random device.
706 ***
707 *** For those systems who lack a random device, EGD support is forthcoming.
708 ***]])
709 fi
710  
711 AC_MSG_CHECKING([if inter-process shared handles are requested])
712 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
713 AC_MSG_RESULT($try_shared_handles)
714 if test "x$try_shared_handles" != "xyes"; then
715         AC_DEFINE(DISABLE_SHARED_HANDLES)
716         AC_SUBST(DISABLE_SHARED_HANDLES)
717 fi
718
719 ICU_CFLAGS=""
720 ICU_LIBS=""
721 enable_icu=no
722 AC_PATH_PROG(ICU_CONFIG, icu-config, no)
723 if test "x$ICU_CONFIG" = "xno" -o ! -x "$ICU_CONFIG"; then
724         AC_MSG_WARN([Only invariant locale available; install ICU for I18N support])
725 else
726         enable_icu="yes. Version: `$ICU_CONFIG --version`"
727         AC_DEFINE(HAVE_ICU)
728         ICU_CFLAGS=`$ICU_CONFIG --cppflags`
729         ICU_LIBS=`$ICU_CONFIG --ldflags`
730 fi
731 AC_SUBST(ICU_CFLAGS)
732 AC_SUBST(ICU_LIBS)
733
734 TARGET="unknown"
735 ACCESS_UNALIGNED="yes"
736
737 JIT_SUPPORTED=no
738 LIBC="libc.so.6"
739
740 case "$host" in
741 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
742 #               TARGET=MIPS;
743 #               ACCESS_UNALIGNED="no"
744 #               ;;
745         i*86-*-*)
746                 TARGET=X86;
747                 arch_target=x86;
748                 JIT_SUPPORTED=yes
749                 ;;
750         sparc*-*-*)
751                 TARGET=SPARC;
752                 arch_target=sparc;
753                 ACCESS_UNALIGNED="no"
754                 ;;
755 #       alpha*-*-linux* | alpha*-*-osf*)
756 #               TARGET=ALPHA;
757 #               ACCESS_UNALIGNED="no"
758 #              ;;
759 #       ia64-*-linux* | ia64-*-hpux*)
760 #               TARGET=IA64;
761 #               arch_target=ia64;
762 #               JIT_SUPPORTED=no;
763 #               ACCESS_UNALIGNED="no";
764 #               case "$host_os" in
765 #                       linux*) LIBC="libc.so.6.1";;
766 #                       hpux*)  LIBC="libc.so.1";;
767 #               esac
768 #               ;;
769 #       m68k-*-linux*)
770 #               TARGET=M68K
771 #               ;;
772         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
773                 TARGET=HPPA;
774                 arch_target=hppa; 
775                 ACCESS_UNALIGNED="no"
776                 ;;
777         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
778         powerpc-*-sysv* | powerpc-*-darwin*)
779                 TARGET=POWERPC;
780                 arch_target=ppc;
781                 JIT_SUPPORTED=yes
782                 ;;
783         arm-*-linux-* | armv4l-*-linux-*)
784                 TARGET=ARM;
785                 arch_target=arm;
786                 ACCESS_UNALIGNED="no"
787                 ;;
788         s390-*-linux*)
789                 TARGET=S390;
790                 arch_target=s390;
791                 ACCESS_UNALIGNED="no"
792                 ;;
793 esac
794
795 if test ${TARGET} = ARM; then
796         dnl ******************************************
797         dnl *** Check to see what FPU is available ***
798         dnl ******************************************
799         AC_MSG_CHECKING(which FPU to use)
800
801         AC_TRY_COMPILE([], [
802                 __asm__ ("ldfd f0, [r0]");
803                 ], fpu=FPA, [
804                         AC_TRY_COMPILE([], [
805                                 __asm__ ("fldd d0, [r0]");
806                         ], fpu=VFP, fpu=NONE)
807                 ])
808
809         AC_MSG_RESULT($fpu)
810         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
811         unset fpu
812 fi
813
814 if test ${TARGET} = unknown; then
815         CPPFLAGS="$CPPFLAGS -DNO_PORT"
816         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
817 fi
818
819 if test ${ACCESS_UNALIGNED} = no; then
820         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
821 fi
822
823 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
824 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
825 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
826 AM_CONDITIONAL(X86, test x$TARGET = xX86)
827 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
828 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
829 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
830 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
831 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
832 AM_CONDITIONAL(S390, test x$TARGET = xS390)
833 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
834
835 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
836
837 AC_SUBST(LIBC)
838
839 AC_SUBST(arch_target)
840 AC_SUBST(CFLAGS)
841 AC_SUBST(CPPFLAGS)
842 AC_SUBST(LDFLAGS)
843
844 AC_OUTPUT([
845 Makefile
846 mono.pc
847 mono/Makefile
848 mono/utils/Makefile
849 mono/metadata/Makefile
850 mono/dis/Makefile
851 mono/cil/Makefile
852 mono/arch/Makefile
853 mono/os/Makefile
854 mono/os/win32/Makefile
855 mono/os/unix/Makefile
856 mono/arch/x86/Makefile
857 mono/arch/hppa/Makefile
858 mono/arch/ppc/Makefile
859 mono/arch/sparc/Makefile
860 mono/arch/s390/Makefile
861 mono/arch/arm/Makefile
862 mono/arch/alpha/Makefile
863 mono/interpreter/Makefile
864 mono/tests/Makefile
865 mono/tests/tests-config
866 mono/benchmark/Makefile
867 mono/monoburg/Makefile
868 mono/monograph/Makefile
869 mono/io-layer/Makefile
870 mono/handles/Makefile
871 mono/mini/Makefile
872 mono/profiler/Makefile
873 runtime/Makefile
874 scripts/Makefile
875 man/Makefile
876 doc/Makefile
877 docs/Makefile
878 data/Makefile
879 samples/Makefile
880 data/config
881 mono.spec
882 ])
883
884 echo "
885
886         GC:     $gc
887         ICU:    $enable_icu
888 "