Improve test
[mono.git] / configure.in
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(mono, 0.15)
5 AM_MAINTAINER_MODE
6
7 # Thread configuration inspired by sleepycat's db
8 AC_MSG_CHECKING([host platform characteristics])
9 case "$host" in
10         *-*-mingw*|*-*-cygwin*)
11                 platform_win32=yes
12                 AC_DEFINE(PLATFORM_WIN32)
13                 CC="gcc -mno-cygwin"
14                 HOST_CC="gcc"
15                 libdl=
16                 ;;
17         *-*-*bsd*)
18                 platform_win32=no
19                 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
20                 LDFLAGS="$LDFLAGS -pthread"
21                 libdl=
22                 ;;
23         *-*-linux*)
24                 platform_win32=no
25                 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_REENTRANT"
26                 libdl="-ldl"
27                 ;;
28         *-*-solaris*)
29                 platform_win32=no
30                 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
31                 ;;
32         *)
33                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
34                 platform_win32=no
35                 libdl="-ldl"
36                 ;;
37 esac
38 AC_MSG_RESULT(ok)
39 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
40
41 AC_CHECK_TOOL(CC, gcc, gcc)
42 AC_PROG_CC
43 AM_PROG_CC_STDC
44 AC_PROG_INSTALL
45
46 AC_CHECK_PROG(BISON, bison,yes,no)
47 if test "x$BISON" = "xno";
48 then
49         AC_MSG_ERROR([You need to install bison])
50 fi
51
52 dnl may require a specific autoconf version
53 dnl AC_PROG_CC_FOR_BUILD
54 dnl CC_FOR_BUILD not automatically detected
55 CC_FOR_BUILD=$CC
56 BUILD_EXEEXT=
57 if test "x$cross_compiling" = "xyes"; then
58         CC_FOR_BUILD=cc
59         BUILD_EXEEXT=""
60 fi
61 AC_SUBST(CC_FOR_BUILD)
62 AC_SUBST(HOST_CC)
63 AC_SUBST(BUILD_EXEEXT)
64
65 # Set STDC_HEADERS
66 AC_HEADER_STDC
67 AC_LIBTOOL_WIN32_DLL
68 AM_PROG_LIBTOOL
69
70 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h)
71
72 # for mono/metadata/debug-symfile.c
73 AC_CHECK_HEADERS(elf.h)
74
75 # for mono/dis
76 AC_CHECK_HEADERS(wchar.h)
77
78 # not 64 bit clean in cross-compile
79 AC_CHECK_SIZEOF(void *, 4)
80
81 CFLAGS='-g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
82
83 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
84 if test "x$PKG_CONFIG" = "xno"; then
85         AC_MSG_ERROR([You need to install pkg-config])
86 fi
87
88 dnl for use on the build system
89 dnl pkg-config is stupid
90 BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0`
91 BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0`
92 AC_SUBST(BUILD_GLIB_CFLAGS)
93 AC_SUBST(BUILD_GLIB_LIBS)
94
95 PKG_PATH=
96 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
97         if test x$with_crosspkgdir = "x"; then
98                 if test -s $PKG_CONFIG_PATH; then
99                         PKG_PATH=$PKG_CONFIG_PATH
100                 fi
101         else
102                 PKG_PATH=$with_crosspkgdir
103                 PKG_CONFIG_PATH=$PKG_PATH
104                 export PKG_CONFIG_PATH
105         fi
106 )
107
108 ## Versions of dependencies
109 GLIB_REQUIRED_VERSION=1.3.11
110
111 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
112
113 GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0`
114 GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0`
115 GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
116 GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
117
118 AC_SUBST(GLIB_CFLAGS)
119 AC_SUBST(GLIB_LIBS)
120 AC_SUBST(GMODULE_CFLAGS)
121 AC_SUBST(GMODULE_LIBS)
122
123 AC_CHECK_HEADERS(gc.h gc/gc.h)
124 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
125 gc=auto
126 AC_ARG_WITH(gc, [  --with-gc=boehm,none],[gc=$with_gc])
127
128 case "x$gc" in
129         xboehm|xyes)
130                 if test "x$found_boehm" != "xyes"; then
131                         AC_MSG_ERROR("GC requested but libgc not found!")
132                 fi
133
134                 AC_DEFINE(HAVE_BOEHM_GC)
135                 AC_SUBST(HAVE_BOEHM_GC)
136                 LIBS="$LIBS -lgc $libdl"
137                 ;;
138         xnone)
139                 AC_MSG_WARN("Compiling mono without GC.")
140                 ;;
141         *)
142                 # If libgc was found, use it.  Otherwise just warn.
143                 if test "x$found_boehm" != "xyes"; then
144                         AC_MSG_WARN("Compiling mono without GC.")
145                 else
146                         AC_DEFINE(HAVE_BOEHM_GC)
147                         AC_SUBST(HAVE_BOEHM_GC)
148                         LIBS="$LIBS -lgc $libdl"
149                         gc="boehm"
150                 fi
151                 ;;
152 esac
153
154 if test x$platform_win32 = xno; then
155         dnl ******************************************************************
156         dnl *** Check for large file support                               ***
157         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
158         dnl ******************************************************************
159         
160         # Check that off_t can represent 2**63 - 1 correctly, working around
161         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
162         # CPPFLAGS and sets $large_offt to yes if the test succeeds
163         large_offt=no
164         AC_DEFUN(LARGE_FILES, [
165                 large_CPPFLAGS=$CPPFLAGS
166                 CPPFLAGS="$CPPFLAGS $1"
167                 AC_TRY_RUN([
168                         #include <sys/types.h>
169
170                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
171
172                         int main(void) {
173                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
174                                                (BIG_OFF_T%2147483647==1));
175                                 if(big_off_t) {
176                                         exit(0);
177                                 } else {
178                                         exit(1);
179                                 }
180                         }
181                 ], [
182                         AC_MSG_RESULT(ok)
183                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
184                         large_CPPFLAGS="$large_CPPFLAGS $1"
185                         large_offt=yes
186                 ], [
187                         AC_MSG_RESULT(no)
188                 ], "")
189                 CPPFLAGS=$large_CPPFLAGS
190         ])
191
192         AC_MSG_CHECKING(if off_t is 64 bits wide)
193         LARGE_FILES("")
194         if test $large_offt = no; then
195                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
196                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
197         fi
198         if test $large_offt = no; then
199                 AC_MSG_WARN([No 64 bit file size support available])
200         fi
201         
202         dnl *****************************
203         dnl *** Checks for libsocket  ***
204         dnl *****************************
205         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
206
207         dnl *******************************
208         dnl *** Checks for MSG_NOSIGNAL ***
209         dnl *******************************
210         AC_MSG_CHECKING(for MSG_NOSIGNAL)
211         AC_TRY_COMPILE([#include <sys/socket.h>], [
212                 int f = MSG_NOSIGNAL;
213         ], [
214                 # Yes, we have it...
215                 AC_MSG_RESULT(yes)
216                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
217         ], [
218                 # We'll have to use signals
219                 AC_MSG_RESULT(no)
220         ])
221
222         dnl *****************************
223         dnl *** Checks for SOL_IP     ***
224         dnl *****************************
225         AC_MSG_CHECKING(for SOL_IP)
226         AC_TRY_COMPILE([#include <netdb.h>], [
227                 int level = SOL_IP;
228         ], [
229                 # Yes, we have it...
230                 AC_MSG_RESULT(yes)
231                 AC_DEFINE(HAVE_SOL_IP)
232         ], [
233                 # We'll have to use getprotobyname
234                 AC_MSG_RESULT(no)
235         ])
236
237         dnl *****************************
238         dnl *** Checks for SOL_TCP    ***
239         dnl *****************************
240         AC_MSG_CHECKING(for SOL_TCP)
241         AC_TRY_COMPILE([#include <netdb.h>], [
242                 int level = SOL_TCP;
243         ], [
244                 # Yes, we have it...
245                 AC_MSG_RESULT(yes)
246                 AC_DEFINE(HAVE_SOL_TCP)
247         ], [
248                 # We'll have to use getprotobyname
249                 AC_MSG_RESULT(no)
250         ])
251
252         dnl *****************************
253         dnl *** Checks for IP_PKTINFO ***
254         dnl *****************************
255         AC_MSG_CHECKING(for IP_PKTINFO)
256         AC_TRY_COMPILE([#include <netdb.h>], [
257                 int level = IP_PKTINFO;
258         ], [
259                 # Yes, we have it...
260                 AC_MSG_RESULT(yes)
261                 AC_DEFINE(HAVE_IP_PKTINFO)
262         ], [
263                 AC_MSG_RESULT(no)
264         ])
265
266         dnl *********************************
267         dnl *** Check for struct ip_mreqn ***
268         dnl *********************************
269         AC_MSG_CHECKING(for struct ip_mreqn)
270         AC_TRY_COMPILE([#include <netinet/in.h>], [
271                 struct ip_mreqn mreq;
272                 mreq.imr_address.s_addr = 0;
273         ], [
274                 # Yes, we have it...
275                 AC_MSG_RESULT(yes)
276                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
277         ], [
278                 # We'll just have to use struct ip_mreq
279                 AC_MSG_RESULT(no)
280         ])
281
282         dnl *****************************
283         dnl *** Checks for libnsl     ***
284         dnl *****************************
285         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
286
287         AC_CHECK_FUNCS(inet_pton inet_aton)
288
289         dnl ***********************************************
290         dnl *** Checks for size of sockaddr_un.sun_path ***
291         dnl ***********************************************
292         # AC_CHECK_SIZEOF can't cope with struct members :-(
293         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
294         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
295                 [AC_TRY_RUN([
296                         #include <sys/types.h>
297                         #include <stdio.h>
298                         #include <sys/un.h>
299
300                         int main(void) {
301                                 struct sockaddr_un sock_un;
302                                 FILE *f=fopen("conftestval", "w");
303                                 if(!f) exit(1);
304                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
305                                 exit(0);
306                         }
307                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
308                    cv_mono_sizeof_sunpath=0,
309                    cv_mono_sizeof_sunpath=0)])dnl
310         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
311         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
312
313         dnl *****************************
314         dnl *** Checks for libxnet    ***
315         dnl *****************************
316         case "${host}" in
317                 *solaris* )
318                         AC_MSG_CHECKING(for Solaris XPG4 support)
319                         if test -f /usr/lib/libxnet.so; then
320                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
321                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
322                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
323                                 LIBS="$LIBS -lxnet"
324                                 AC_MSG_RESULT(yes)
325                         else
326                                 AC_MSG_RESULT(no)
327                         fi
328
329                         if test "$GCC" = "yes"; then
330                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
331                         fi
332                 ;;
333         esac
334
335         dnl *****************************
336         dnl *** Checks for libpthread ***
337         dnl *****************************
338         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
339         AC_CHECK_FUNCS(pthread_mutex_timedlock)
340         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
341         AC_TRY_COMPILE([ #include <pthread.h>], [
342                 pthread_mutexattr_t attr;
343                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
344         ], [
345                 AC_MSG_RESULT(ok)
346         ], [
347                 AC_MSG_RESULT(no)
348                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
349                 AC_DEFINE(USE_MONO_MUTEX)
350         ])
351
352         dnl ********************************
353         dnl *** Checks for semaphore lib ***
354         dnl ********************************
355         AC_CHECK_LIB(rt, sem_init, LIBS="$LIBS -lrt")
356
357         dnl ********************************
358         dnl *** Checks for timezone stuff **
359         dnl ********************************
360         AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
361                 AC_TRY_COMPILE([
362                         #include <time.h>
363                 ], [
364                         timezone = 1;
365                 ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
366         if test $ac_cv_var_timezone = yes; then
367                 AC_DEFINE(HAVE_TIMEZONE)
368         else
369                 AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
370                         AC_TRY_COMPILE([
371                                 #include <time.h>
372                                 ], [
373                                 struct tm tm;
374                                 tm.tm_gmtoff = 1;
375                                 ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
376                 if test $ac_cv_struct_tm_gmtoff = yes; then
377                         AC_DEFINE(HAVE_TM_GMTOFF)
378                 else
379                         AC_ERROR(unable to find a way to determine timezone)
380                 fi
381         fi
382 else
383         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
384 fi
385
386 dnl ****************************
387 dnl *** Look for /dev/random ***
388 dnl ****************************
389
390 AC_MSG_CHECKING([if usage of random device is requested])
391 AC_ARG_ENABLE(dev-random,
392 [  --disable-dev-random    disable the use of the random device],
393 try_dev_random=$enableval, try_dev_random=yes)
394 AC_MSG_RESULT($try_dev_random)
395
396 case "{$target}" in
397     *-openbsd*)
398     NAME_DEV_RANDOM="/dev/srandom"
399     ;;
400
401 dnl Win32 does not have /dev/random, they have their own method...
402
403     *-*-mingw*|*-*-cygwin*)
404     ac_cv_have_dev_random = no
405     ;;
406
407 dnl Everywhere else, it's /dev/random
408
409     *)
410     NAME_DEV_RANDOM="/dev/random"
411     ;;
412 esac
413
414 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
415
416 dnl Now check if the device actually exists
417
418 if test "x$try_dev_random" = "xyes"; then
419     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
420     [if test -r "$NAME_DEV_RANDOM" ; then
421         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
422     if test "x$ac_cv_have_dev_random" = "xyes"; then
423         AC_DEFINE(HAVE_CRYPT_RNG)
424     fi
425 else
426     AC_MSG_CHECKING(for random device)
427     ac_cv_have_dev_random=no
428     AC_MSG_RESULT(has been disabled)
429 fi
430
431 if test "x$platform_win32" = "xyes"; then
432     AC_DEFINE(HAVE_CRYPT_RNG)
433 fi
434
435 if test "x$ac_cv_have_dev_random" = "xno" \
436     && test "x$platform_win32" = "xno"; then
437     AC_MSG_WARN([[
438 ***
439 *** A system-provided entropy source was not found on this system.
440 *** Because of this, the System.Security.Cryptography random number generator
441 *** will throw a NotImplemented exception.
442 ***
443 *** If you are seeing this message, and you know your system DOES have an
444 *** entropy collection in place, please contact <crichton@gimp.org> and
445 *** provide information about the system and how to access the random device.
446 ***
447 *** For those systems who lack a random device, EGD support is forthcoming.
448 ***]])
449 fi
450  
451 AC_MSG_CHECKING([if inter-process shared handles are requested])
452 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
453 AC_MSG_RESULT($try_shared_handles)
454 if test "x$try_shared_handles" != "xyes"; then
455         AC_DEFINE(DISABLE_SHARED_HANDLES)
456         AC_SUBST(DISABLE_SHARED_HANDLES)
457 fi
458
459 TARGET="unknown"
460 ACCESS_UNALIGNED="yes"
461
462 case "$host" in
463 #mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS; ACCESS_UNALIGNED="no";;
464 i*86-*-*) TARGET=X86; arch_target=x86;;
465 sparc*-*-*) TARGET=SPARC; arch_target=sparc; ACCESS_UNALIGNED="no";;
466 #alpha*-*-linux* | alpha*-*-osf*) TARGET=ALPHA; ACCESS_UNALIGNED="no";;
467 #m68k-*-linux*) TARGET=M68K;;
468 macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | powerpc-*-sysv*) TARGET=POWERPC; arch_target=ppc;;
469 arm-*-linux-* | armv4l-*-linux-*) TARGET=ARM; arch_target=arm; ACCESS_UNALIGNED="no";;
470 esac
471
472 if test ${TARGET} = unknown; then
473         CPPFLAGS="$CPPFLAGS -DNO_PORT"
474         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
475 fi
476
477 if test ${ACCESS_UNALIGNED} = no; then
478         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
479 fi
480
481 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
482 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
483 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
484 AM_CONDITIONAL(X86, test x$TARGET = xX86)
485 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
486 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
487 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
488 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
489
490 LIBC="libc.so.6"
491 AC_SUBST(LIBC)
492
493 AC_SUBST(arch_target)
494 AC_SUBST(CFLAGS)
495 AC_SUBST(CPPFLAGS)
496
497 AC_OUTPUT([
498 Makefile
499 mono.pc
500 mono/Makefile
501 mono/utils/Makefile
502 mono/metadata/Makefile
503 mono/dis/Makefile
504 mono/cil/Makefile
505 mono/arch/Makefile
506 mono/os/Makefile
507 mono/os/win32/Makefile
508 mono/os/unix/Makefile
509 mono/arch/x86/Makefile
510 mono/arch/ppc/Makefile
511 mono/arch/sparc/Makefile
512 mono/arch/arm/Makefile
513 mono/interpreter/Makefile
514 mono/tests/Makefile
515 mono/benchmark/Makefile
516 mono/monoburg/Makefile
517 mono/monograph/Makefile
518 mono/jit/Makefile
519 mono/io-layer/Makefile
520 mono/handles/Makefile
521 runtime/Makefile
522 scripts/Makefile
523 man/Makefile
524 doc/Makefile
525 docs/Makefile
526 data/Makefile
527 mono.spec
528 ])
529
530 echo "
531
532         GC:     $gc
533
534 "