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