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