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