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