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