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