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