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