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