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