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