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