2010-05-05 Jonathan Chambers <joncham@gmail.com>
[mono.git] / configure.in
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
3
4 # Gross hack to enable 'make dist' on automake 1.9+tar 1.14.
5 # The extra brackets are to foil regex-based scans.
6 m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
7
8 AM_CONFIG_HEADER(config.h)
9 AM_INIT_AUTOMAKE(mono,2.7)
10 AM_MAINTAINER_MODE
11
12 API_VER=2.0
13 AC_SUBST(API_VER)
14
15 AC_PROG_LN_S
16
17 # In case of cygwin, override LN_S, irrespective of what it determines.
18 # The build uses cygwin, but the actual runtime doesn't.
19 case $host_os in
20 *cygwin* ) LN_S='cp -p';;
21 esac
22
23 dnl
24 dnl libgc checks
25 dnl
26
27 gc_headers=no
28 gc=included
29 use_included_gc=no
30 libgc_configure_args=
31
32 if test -d $srcdir/libgc ; then
33   gc_default=included
34 else
35   gc_default=boehm
36 fi
37
38 # These variables are the CPPFLAGS/CFLAGS passed to libgc's configure
39 # libgc should inherit the original CFLAGS/CPPFLAGS passed to configure, i.e. -O0
40 CPPFLAGS_FOR_LIBGC=$CPPFLAGS
41 CFLAGS_FOR_LIBGC=$CFLAGS
42 CPPFLAGS_FOR_EGLIB=$CPPFLAGS
43 CFLAGS_FOR_EGLIB=$CFLAGS
44
45 #
46 # These are the flags that need to be stored in the mono.pc file for 
47 # compiling code that will embed Mono
48 #
49 libmono_cflags=""
50 libmono_ldflags=""
51 AC_SUBST(libmono_cflags)
52 AC_SUBST(libmono_ldflags)
53
54 # Variable to have relocatable .pc files (lib, or lib64)
55 reloc_libdir=`basename ${libdir}`
56 AC_SUBST(reloc_libdir)
57
58 dnl if linker handles the version script
59 no_version_script=no
60
61 # Set to yes if Unix sockets cannot be created in an anonymous namespace
62 need_link_unlink=no
63
64 # Thread configuration inspired by sleepycat's db
65 AC_MSG_CHECKING([host platform characteristics])
66 libgc_threads=no
67 has_dtrace=no
68 parallel_mark=yes
69
70 case "$host" in
71         powerpc*-*-linux*)
72                 # https://bugzilla.novell.com/show_bug.cgi?id=504411
73                 disable_munmap=yes
74         ;;
75 esac
76
77 host_win32=no
78 target_win32=no
79 case "$host" in
80         *-mingw*|*-*-cygwin*)
81                 AC_DEFINE(HOST_WIN32,1,[Host Platform is Win32])
82                 AC_DEFINE(DISABLE_PORTABILITY,1,[Disable the io-portability layer])
83                 AC_DEFINE(PLATFORM_NO_SYMLINKS,1,[This platform does not support symlinks])
84                 host_win32=yes
85                 if test "x$cross_compiling" = "xno"; then
86                         target_win32=yes
87                         if test "x$host" == "x$target"; then
88                                 AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32])
89                         fi
90                         CC="gcc -mno-cygwin -g"
91                         CXX="g++ -mno-cygwin -g"
92                         # So libgc configure gets -mno-cygwin
93                         export CC
94                         export CXX
95                 else
96                         target_win32=yes
97                         AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32/MinGW])
98                         AC_DEFINE(MINGW_CROSS_COMPILE,1,[Cross-compiling using MinGW])
99                 fi
100                 HOST_CC="gcc"
101                 # Windows 2000 is required that includes Internet Explorer 5.01
102                 CPPFLAGS="$CPPFLAGS -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0501 -D_UNICODE -DUNICODE -DWIN32_THREADS -DFD_SETSIZE=1024"
103                 LDFLAGS="$LDFLAGS -lmswsock -lws2_32 -lole32 -loleaut32 -lpsapi -lversion -ladvapi32 -lwinmm -lkernel32"
104                 libmono_cflags="-mno-cygwin -mms-bitfields -mwindows"
105                 libmono_ldflags="-mno-cygwin -mms-bitfields -mwindows"
106                 libdl=
107                 libgc_threads=win32
108                 gc_default=included
109                 with_sigaltstack=no
110                 LN_S=cp
111                 # This forces libgc to use the DllMain based thread registration code on win32
112                 libgc_configure_args="$libgc_configure_args --enable-win32-dllmain=yes"
113                 ;;
114         *-*-*netbsd*)
115                 host_win32=no
116                 CPPFLAGS="$CPPFLAGS -D_REENTRANT -DGC_NETBSD_THREADS -D_GNU_SOURCE"
117                 libmono_cflags="-D_REENTRANT"
118                 LDFLAGS="$LDFLAGS -pthread"
119                 CPPFLAGS="$CPPFLAGS -DPLATFORM_BSD"
120                 libmono_ldflags="-pthread"
121                 need_link_unlink=yes
122                 libdl="-ldl"
123                 libgc_threads=pthreads
124                 with_sigaltstack=no
125                 use_sigposix=yes
126                 ;;
127         *-*-*freebsd*)
128                 host_win32=no
129                 if test "x$PTHREAD_CFLAGS" = "x"; then
130                         CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
131                         libmono_cflags=
132                 else
133                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
134                         libmono_cflags="$PTHREAD_CFLAGS"
135                 fi
136                 if test "x$PTHREAD_LIBS" = "x"; then
137                         LDFLAGS="$LDFLAGS -pthread"
138                         libmono_ldflags="-pthread"
139                 else
140                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
141                         libmono_ldflags="$PTHREAD_LIBS"
142                 fi
143                 CPPFLAGS="$CPPFLAGS -DPLATFORM_BSD"
144                 need_link_unlink=yes
145                 AC_DEFINE(PTHREAD_POINTER_ID, 1, [pthread is a pointer])
146                 libdl=
147                 libgc_threads=pthreads
148                 # This doesn't seem to work as of 7.0 on amd64
149                 with_sigaltstack=no
150 # TLS is only partially implemented on -CURRENT (compiler support
151 # but NOT library support)
152 #
153                 with_tls=pthread
154                 use_sigposix=yes
155                 ;;
156         *-*-*openbsd*)
157                 host_win32=no
158                 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_OPENBSD_THREADS -DPLATFORM_BSD -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
159                 if test "x$disable_munmap" != "xyes"; then
160                 CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
161                 fi
162                 libmono_cflags="-D_THREAD_SAFE -D_REENTRANT"
163                 LDFLAGS="$LDFLAGS -pthread"
164                 need_link_unlink=yes
165                 AC_DEFINE(PTHREAD_POINTER_ID)
166                 libdl=
167                 gc_default=boehm
168                 libgc_threads=pthreads
169                 with_sigaltstack=no
170                 use_sigposix=yes
171                 ;;
172         *-*-linux*)
173                 host_win32=no
174                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
175                 if test "x$disable_munmap" != "xyes"; then
176                         CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
177                 fi
178                 libmono_cflags="-D_REENTRANT"
179                 libdl="-ldl"
180                 libgc_threads=pthreads
181                 AOT_SUPPORTED="yes"
182                 use_sigposix=yes
183                 ;;
184         *-*-hpux*)
185                 host_win32=no
186                 CPPFLAGS="$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
187                 # +ESdbgasm only valid on bundled cc on RISC
188                 # silently ignored for ia64
189                 if test $GCC != "yes"; then
190                         CFLAGS="$CFLAGS +ESdbgasm"
191                         # Arrange for run-time dereferencing of null
192                         # pointers to produce a SIGSEGV signal.
193                         LDFLAGS="$LDFLAGS -z"
194                 fi
195                 CFLAGS="$CFLAGS +ESdbgasm"
196                 LDFLAGS="$LDFLAGS -z"
197                 libmono_cflags="-D_REENTRANT"
198                 libmono_ldflags="-lpthread"
199                 libgc_threads=pthreads
200                 need_link_unlink=yes
201                 use_sigposix=yes
202                 ;;
203         *-*-solaris*)
204                 host_win32=no
205                 CPPFLAGS="$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP -DPLATFORM_SOLARIS"
206                 need_link_unlink=yes
207                 libmono_cflags="-D_REENTRANT"
208                 libgc_threads=pthreads
209                 # This doesn't seem to work on solaris/x86, but the configure test runs
210                 with_tls=pthread
211                 has_dtrace=yes
212                 use_sigposix=yes
213                 enable_solaris_tar_check=yes
214                 ;;
215         *-*-darwin*)
216                 parallel_mark="Disabled_Currently_Hangs_On_MacOSX"
217                 host_win32=no
218                 platform_darwin=yes
219                 CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE -DGC_MACOSX_THREADS -DPLATFORM_MACOSX -DUSE_MMAP -DUSE_MUNMAP"
220                 CPPFLAGS="$CPPFLAGS -DGetCurrentProcess=MonoGetCurrentProcess -DGetCurrentThread=MonoGetCurrentThread -DCreateEvent=MonoCreateEvent"
221                 libmono_cflags="-D_THREAD_SAFE"
222                 LDFLAGS="$LDFLAGS -pthread"
223                 libmono_ldflags="-pthread"
224                 need_link_unlink=yes
225                 AC_DEFINE(PTHREAD_POINTER_ID)
226                 AC_DEFINE(USE_MACH_SEMA, 1, [...])
227                 no_version_script=yes
228                 libdl=
229                 libgc_threads=pthreads
230                 has_dtrace=yes
231                 if test "x$cross_compiling" = "xyes"; then
232                         has_broken_apple_cpp=yes
233                 fi
234                 dnl Snow Leopard is horribly broken -- it reports itself as i386-apple-darwin10.0.0, but
235                 dnl its gcc defaults to 64-bit mode.  They have also deprecated the usage of ucontext
236                 dnl we need to set some flags to build our 32-bit binaries on 10.6 properly
237                 case "$host" in
238                         dnl Snow Leopard config.guess reports as this
239                         i*86-*-darwin10*)
240                                 BROKEN_DARWIN_FLAGS="-arch i386 -D_XOPEN_SOURCE -mmacosx-version-min=10.5"
241                                 CPPFLAGS="$CPPFLAGS $BROKEN_DARWIN_FLAGS"
242                                 CFLAGS="$CFLAGS $BROKEN_DARWIN_FLAGS"
243                                 CXXFLAGS="$CXXFLAGS $BROKEN_DARWIN_FLAGS"
244                                 CCASFLAGS="$CCASFLAGS $BROKEN_DARWIN_FLAGS"
245                                 CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC $BROKEN_DARWIN_FLAGS"
246                                 CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC $BROKEN_DARWIN_FLAGS"
247                                 CPPFLAGS_FOR_EGLIB="$CPPFLAGS_FOR_EGLIB $BROKEN_DARWIN_FLAGS"
248                                 CFLAGS_FOR_EGLIB="$CFLAGS_FOR_EGLIB $BROKEN_DARWIN_FLAGS"
249                                 ;;
250                 esac
251                 ;;
252         *-*-haiku*)
253                 host_win32=no
254                 CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
255                 libmono_cflags="-D_REENTRANT -D_THREAD_SAFE"
256                 libdl=
257                 LIBS="$LIBS -lnetwork"
258                 need_link_unlink=yes
259                 AC_DEFINE(PTHREAD_POINTER_ID)
260                 libgc_threads=pthreads
261                 use_sigposix=yes
262                 ;;
263         *)
264                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
265                 host_win32=no
266                 libdl="-ldl"
267                 ;;
268 esac
269 AC_MSG_RESULT(ok)
270
271 if test x$need_link_unlink = xyes; then
272    AC_DEFINE(NEED_LINK_UNLINK, 1, [Define if Unix sockets cannot be created in an anonymous namespace])
273 fi
274
275 AM_CONDITIONAL(HOST_WIN32, test x$host_win32 = xyes)
276 AM_CONDITIONAL(TARGET_WIN32, test x$target_win32 = xyes)
277 AM_CONDITIONAL(PLATFORM_LINUX, echo x$target_os | grep -q linux)
278 AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
279 AM_CONDITIONAL(PLATFORM_SIGPOSIX, test x$use_sigposix = xyes)
280
281 AC_CHECK_TOOL(CC, gcc, gcc)
282 AC_PROG_CC
283 AC_CHECK_TOOL(CXX, g++, g++)
284 AC_PROG_CXX
285 AM_PROG_AS
286 AM_PROG_CC_STDC
287 AC_PROG_INSTALL
288 AC_PROG_AWK
289 dnl We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
290 : ${CCAS='$(CC)'}
291 # Set ASFLAGS if not already set.
292 : ${CCASFLAGS='$(CFLAGS)'}
293 AC_SUBST(CCAS)
294 AC_SUBST(CCASFLAGS)
295
296 # AC_PROG_CXX helpfully sets CXX to g++ even if no c++ compiler is found so check
297 # GXX instead. See http://lists.gnu.org/archive/html/bug-autoconf/2002-04/msg00056.html
298 if test "x$CXX" = "xg++"; then
299         if test "x$GXX" != "xyes"; then
300                 # automake/libtool is so broken, it requires g++ even if the c++ sources
301                 # are inside automake conditionals
302                 AC_MSG_ERROR([You need to install g++])
303         fi
304 fi
305
306 AC_CHECK_PROG(BISON, bison,yes,no)
307 if test "x$BISON" = "xno";
308 then
309         AC_MSG_ERROR([You need to install bison])
310 fi
311
312 dnl may require a specific autoconf version
313 dnl AC_PROG_CC_FOR_BUILD
314 dnl CC_FOR_BUILD not automatically detected
315 CC_FOR_BUILD=$CC
316 CFLAGS_FOR_BUILD=$CFLAGS
317 BUILD_EXEEXT=
318 if test "x$cross_compiling" = "xyes"; then
319         CC_FOR_BUILD=cc
320         CFLAGS_FOR_BUILD=
321         BUILD_EXEEXT=""
322 fi
323 AC_SUBST(CC_FOR_BUILD)
324 AC_SUBST(CFLAGS_FOR_BUILD)
325 AC_SUBST(HOST_CC)
326 AC_SUBST(BUILD_EXEEXT)
327
328 AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
329 AM_CONDITIONAL(USE_BATCH_FILES, [test x$host_win32 = xyes -a x$cross_compiling = xyes])
330
331 # Set STDC_HEADERS
332 AC_HEADER_STDC
333 AC_LIBTOOL_WIN32_DLL
334 # This causes monodis to not link correctly
335 #AC_DISABLE_FAST_INSTALL
336 AM_PROG_LIBTOOL
337 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
338 DOLT
339
340 export_ldflags=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
341 AC_SUBST(export_ldflags)
342
343 # Test whenever ld supports -version-script
344 AC_PROG_LD
345 AC_PROG_LD_GNU
346 if test "x$lt_cv_prog_gnu_ld" = "xno"; then
347    no_version_script=yes
348 fi
349
350 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
351
352 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h sys/utime.h semaphore.h sys/un.h linux/rtc.h sys/syscall.h sys/mkdev.h sys/uio.h)
353 AC_CHECK_HEADERS(sys/param.h sys/socket.h sys/ipc.h sys/sem.h sys/utsname.h alloca.h ucontext.h pwd.h sys/select.h netinet/tcp.h netinet/in.h unistd.h sys/types.h link.h asm/sigcontext.h)
354
355 AC_CHECK_HEADERS(sys/user.h, [], [],
356 [
357 #ifdef HAVE_SYS_PARAM_H
358 # include <sys/param.h>
359 #endif
360 ])
361
362 AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
363 if test x$have_zlib = xyes; then
364    AC_TRY_COMPILE([#include <zlib.h>], [
365    void main () {
366    #if defined(ZLIB_VERNUM) && (ZLIB_VERNUM >= 0x1230)
367    }
368    #else
369    #error No good zlib found
370    #endif
371    ],[
372         AC_MSG_RESULT(Using system zlib)
373         zlib_msg="system zlib"
374    ],[
375         AC_MSG_RESULT(Using embedded zlib)
376         have_zlib=no
377         zlib_msg="bundled zlib"
378    ])
379 fi
380
381 AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
382 AC_DEFINE(HAVE_ZLIB,1,[Have system zlib])
383
384 # for mono/metadata/debug-symfile.c
385 AC_CHECK_HEADERS(elf.h)
386
387 # for support
388 AC_CHECK_HEADERS(poll.h)
389 AC_CHECK_HEADERS(sys/poll.h)
390 AC_CHECK_HEADERS(sys/wait.h)
391 AC_CHECK_HEADERS(grp.h)
392 AC_CHECK_HEADERS(syslog.h)
393
394 # for mono/dis
395 AC_CHECK_HEADERS(wchar.h)
396 AC_CHECK_HEADERS(ieeefp.h)
397 AC_MSG_CHECKING(for isinf)
398 AC_TRY_LINK([#include <math.h>], [
399         int f = isinf (1);
400 ], [
401         AC_MSG_RESULT(yes)
402         AC_DEFINE(HAVE_ISINF, 1, [isinf available])
403 ], [
404         # We'll have to use signals
405         AC_MSG_RESULT(no)
406 ])
407
408
409 # not 64 bit clean in cross-compile
410 AC_CHECK_SIZEOF(void *, 4)
411
412 WARN=''
413 if test x"$GCC" = xyes; then
414         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wwrite-strings'
415                 # The runtime code does not respect ANSI C strict aliasing rules
416                 CFLAGS="$CFLAGS -fno-strict-aliasing"
417
418                 ORIG_CFLAGS=$CFLAGS
419                 CFLAGS="$CFLAGS -Wdeclaration-after-statement"
420                 AC_MSG_CHECKING(for -Wdeclaration-after-statement option to gcc)
421                 AC_TRY_COMPILE([], [
422                                                    void main () { }
423                 ], [
424                    AC_MSG_RESULT(yes)
425                 ], [
426                    AC_MSG_RESULT(no)
427                    CFLAGS=$ORIG_CFLAGS
428                 ])
429 else
430         # The Sun Forte compiler complains about inline functions that access static variables
431         # so disable all inlining.
432         case "$host" in
433         *-*-solaris*)
434                 CFLAGS="$CFLAGS -Dinline="
435                 ;;
436         esac
437 fi
438 CFLAGS="$CFLAGS -g $WARN"
439 CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -g"
440
441 # Where's the 'mcs' source tree?
442 if test -d $srcdir/mcs; then
443   mcsdir=mcs
444 else
445   mcsdir=../mcs
446 fi
447
448 AC_ARG_WITH(mcs-path, [  --with-mcs-path=/path/to/mcs      Specify an alternate mcs source tree],
449         if test x$with_mcs_path != "x" -a -d $with_mcs_path ; then
450                 mcsdir=$with_mcs_path
451         fi
452 )
453
454 #
455 # A sanity check to catch cases where the package was unpacked
456 # with an ancient tar program (Solaris)
457 #
458 AC_ARG_ENABLE(solaris-tar-check,
459 [  --disable-solaris-tar-check    disable solaris tar check],
460    do_solaris_tar_check=no, do_solaris_tar_check=yes)
461
462 if test x"$do_solaris_tar_check" = xyes -a x"$enable_solaris_tar_check" = xyes; then
463         AC_MSG_CHECKING(integrity of package)
464         if test -f $mcsdir/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapTypeMapper.cs
465         then
466                 AC_MSG_RESULT(ok)
467         else
468                 errorm="Your mono distribution is incomplete;  if unpacking from a tar file, make sure you use GNU tar;  see http://www.mono-project.com/IncompletePackage for more details"
469                 AC_MSG_ERROR([$errorm])
470         fi
471 fi
472
473 if test "x$with_mcs_path" != "x"; then
474 mcs_topdir=$(cd "$mcsdir" && pwd)
475 mcs_topdir_from_srcdir=$mcs_topdir
476 else
477 mcs_topdir=$(cd "$srcdir/$mcsdir" && pwd)
478 mcs_topdir_from_srcdir='$(top_builddir)'/$mcsdir
479 fi
480
481 ## Maybe should also disable if mcsdir is invalid.  Let's punt the issue for now.
482 AM_CONDITIONAL(BUILD_MCS, [test x$cross_compiling = xno && test x$enable_mcs_build != xno])
483
484 AC_SUBST([mcs_topdir])
485 AC_SUBST([mcs_topdir_from_srcdir])
486
487 # Where's the 'olive' source tree?
488 if test -d $srcdir/olive; then
489   olivedir=olive
490 else
491   olivedir=../olive
492 fi
493
494 if test -d $srcdir/$olivedir; then
495 olive_topdir='$(top_srcdir)/'$olivedir
496 fi
497
498 # gettext: prepare the translation directories. 
499 # we do not configure the full gettext, as we consume it dynamically from C#
500 AM_PO_SUBDIRS
501
502 if test "x$USE_NLS" = "xyes"; then
503    AC_CHECK_PROG(HAVE_MSGFMT, msgfmt,yes,no)
504
505    if test "x$HAVE_MSGFMT" = "xno"; then
506           AC_MSG_ERROR([msgfmt not found. You need to install the 'gettext' package, or pass --enable-nls=no to configure.])
507    fi
508 fi
509
510 AC_ARG_WITH([libgdiplus], 
511         [  --with-libgdiplus=installed|sibling|<path>   Override the libgdiplus used for System.Drawing tests (defaults to installed)], 
512         [], [with_libgdiplus=installed])
513
514 case $with_libgdiplus in
515 no|installed) libgdiplus_loc= ;;
516 yes|sibling) libgdiplus_loc=`cd ../libgdiplus && pwd`/src/libgdiplus.la ;;
517 /*) libgdiplus_loc=$with_libgdiplus ;;
518 *) libgdiplus_loc=`pwd`/$with_libgdiplus ;;
519 esac
520 AC_SUBST([libgdiplus_loc])
521
522 PKG_PROG_PKG_CONFIG()
523 if test "x$PKG_CONFIG" = "x"; then
524         AC_MSG_ERROR([You need to install pkg-config])
525 fi
526
527 pkg_config_path=
528 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir      Change pkg-config dir to custom dir],
529         if test x$with_crosspkgdir = "x"; then
530                 if test -s $PKG_CONFIG_PATH; then
531                         pkg_config_path=$PKG_CONFIG_PATH
532                 fi
533         else
534                 pkg_config_path=$with_crosspkgdir
535                 PKG_CONFIG_PATH=$pkg_config_path
536                 export PKG_CONFIG_PATH
537         fi
538 )
539
540 AC_ARG_WITH([glib],
541         [  --with-glib=embedded|system    Choose glib API: system or embedded (default to embedded)],
542         [], [with_glib=embedded])
543
544 eglib_dir=
545
546 ac_configure_args="$ac_configure_args \"CPPFLAGS_FOR_EGLIB=$EGLIB_CPPFLAGS\" \"CFLAGS_FOR_EGLIB=$CFLAGS_FOR_EGLIB\""
547 AC_CONFIG_SUBDIRS(eglib)
548
549 case $with_glib in
550 embedded) 
551   GLIB_CFLAGS='-I$(top_srcdir)/eglib/src -I$(top_builddir)/eglib/src'
552   GLIB_LIBS='-L$(top_builddir)/eglib/src -leglib -lm'
553   BUILD_GLIB_CFLAGS="$GLIB_CFLAGS"
554   BUILD_GLIB_LIBS="$GLIB_LIBS"
555   GMODULE_CFLAGS="$GLIB_CFLAGS"
556   GMODULE_LIBS="$GLIB_LIBS"
557   eglib_dir=eglib
558   ;;
559 system)
560     echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
561     echo "cross_compiling=$cross_compiling"
562   BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
563   BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
564   
565   ## Versions of dependencies
566   GLIB_REQUIRED_VERSION=2.4.0
567
568   dnl
569   dnl No, you will not replace this check with a pkg.m4 check
570   dnl
571   if $PKG_CONFIG --atleast-version=$GLIB_REQUIRED_VERSION glib-2.0; then
572       GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
573       GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
574       GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
575       GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
576   else
577         AC_MSG_ERROR([You need at least glib-2.0 $GLIB_REQUIRED_VERSION])
578   fi
579   ;;
580 *)
581   AC_MSG_ERROR([Invalid argument to --with-glib.])
582 esac
583 AM_CONDITIONAL(EGLIB_BUILD, test x$with_glib = xembedded)
584   
585 AC_SUBST(GLIB_CFLAGS)
586 AC_SUBST(GLIB_LIBS)
587 AC_SUBST(GMODULE_CFLAGS)
588 AC_SUBST(GMODULE_LIBS)
589 AC_SUBST(BUILD_GLIB_CFLAGS)
590 AC_SUBST(BUILD_GLIB_LIBS)
591 AC_SUBST(eglib_dir)
592
593 if test x$cross_compiling$host_win32 = xnoyes; then
594    AC_MSG_CHECKING(for cygwin glib2-dev package)
595    if [ cygcheck --f /usr/lib/libglib-2.0.dll.a | grep -q glib2-devel ]; then
596       AC_MSG_RESULT(found)
597           AC_MSG_ERROR([Mono cannot be built with the cygwin glib2-devel package installed, because that package doesn't work with -mno-cygwin. Please uninstall it then re-run configure.])
598    else
599       AC_MSG_RESULT(not found, ok)
600    fi
601
602    AC_MSG_CHECKING(for broken gwin32.h)
603    glib_include=`$PKG_CONFIG --cflags-only-I glib-2.0 | sed -e 's/ -I.*//g' | sed -e 's/-I//g'`
604    if test -f $glib_include/glib/gwin32.h; then
605           if [ grep ftruncate $glib_include/glib/gwin32.h | grep -q define ]; then
606                  AC_MSG_RESULT(failed)
607                  hashmark='#'
608                  AC_MSG_ERROR([Your version of gwin32.h is broken and will cause compilation errors when building mono. Please fix it by deleting the line: '$hashmark   define ftruncate...' from '$glib_include/glib/gwin32.h' then re-run configure.])
609           fi
610    fi
611    AC_MSG_RESULT(ok)
612 fi
613
614 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none  Defaults to included],[gc=$with_gc],[gc=$gc_default])
615
616 # Enable support for fast thread-local storage
617 # Some systems have broken support, so we allow to disable it.
618 AC_ARG_WITH(tls, [  --with-tls=__thread,pthread    select Thread Local Storage implementation (defaults to __thread)],[],[with_tls=__thread])
619
620 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
621 # This does not work on some platforms (bug #55253)
622 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack (defaults to yes)],[],[with_sigaltstack=yes])
623
624 AC_ARG_WITH(static_mono, [  --with-static_mono=yes,no      link mono statically to libmono (faster) (defaults to yes)],[],[with_static_mono=yes])
625
626 if test "x$enable_static" = "xno"; then
627    with_static_mono=no
628 fi
629
630 if test "x$host_win32" = "xyes"; then
631    # Boehm GC requires the runtime to be in its own dll
632    with_static_mono=no
633 fi
634
635 AM_CONDITIONAL(STATIC_MONO, test x$with_static_mono != xno)
636 AC_ARG_ENABLE(mcs-build, [  --disable-mcs-build disable the build of the mcs directory], try_mcs_build=$enableval, enable_mcs_build=yes)
637
638 AC_ARG_WITH(xen_opt,   [  --with-xen_opt=yes,no          Enable Xen-specific behaviour (defaults to yes)],[],[with_xen_opt=yes])
639 if test "x$with_xen_opt" = "xyes"; then
640         AC_DEFINE(MONO_XEN_OPT, 1, [Xen-specific behaviour])
641         ORIG_CFLAGS=$CFLAGS
642         CFLAGS="$CFLAGS -mno-tls-direct-seg-refs"
643         AC_MSG_CHECKING(for -mno-tls-direct-seg-refs option to gcc)
644         AC_TRY_COMPILE([], [
645                                            void main () { }
646         ], [
647            AC_MSG_RESULT(yes)
648            # Pass it to libgc as well
649            CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -mno-tls-direct-seg-refs"
650         ], [
651            AC_MSG_RESULT(no)
652            CFLAGS=$ORIG_CFLAGS
653         ])
654 fi
655
656 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet runtime build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
657 AC_ARG_ENABLE(small-config, [  --enable-small-config Enable tweaks to reduce requirements (and capabilities)], enable_small_config=$enableval, enable_small_config=no)
658
659 if test x$enable_small_config = xyes; then
660         AC_DEFINE(MONO_SMALL_CONFIG,1,[Reduce runtime requirements (and capabilities)])
661         CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DSMALL_CONFIG"
662 fi
663
664 if test x$AOT_SUPPORTED != xyes; then
665    AOT_SUPPORTED=no
666 fi
667
668 AC_ARG_ENABLE(system-aot, [  --enable-system-aot  Enable the Ahead-Of-Time compilation of system assemblies during the build (on by default on some platforms)], enable_system_aot=$enableval, enable_system_aot=$AOT_SUPPORTED)
669
670 DISABLED_FEATURES=none
671
672 AC_ARG_ENABLE(minimal, [  --enable-minimal=LIST      drop support for LIST subsystems.
673      LIST is a comma-separated list from: aot, profiler, decimal, pinvoke, debug,
674      reflection_emit, reflection_emit_save, large_code, logging, com, ssa, generics, attach, jit, simd, soft_debug, normalization.],
675 [
676         for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
677                 eval "mono_feature_disable_$feature='yes'"
678         done
679         DISABLED_FEATURES=$enable_minimal
680         disabled="Disabled:    $enable_minimal"
681 ],[])
682
683 AC_DEFINE_UNQUOTED(DISABLED_FEATURES, "$DISABLED_FEATURES", [String of disabled features])
684
685 if test "x$mono_feature_disable_aot" = "xyes"; then
686         AC_DEFINE(DISABLE_AOT_COMPILER, 1, [Disable AOT Compiler])
687         AC_MSG_NOTICE([Disabled AOT compiler])
688 fi
689
690 if test "x$mono_feature_disable_profiler" = "xyes"; then
691         AC_DEFINE(DISABLE_PROFILER, 1, [Disable default profiler support])
692         AC_MSG_NOTICE([Disabled support for the profiler])
693 fi
694 AM_CONDITIONAL(DISABLE_PROFILER, test x$mono_feature_disable_profiler = xyes)
695
696 if test "x$mono_feature_disable_decimal" = "xyes"; then
697         AC_DEFINE(DISABLE_DECIMAL, 1, [Disable System.Decimal support])
698         AC_MSG_NOTICE([Disabled support for decimal])
699 fi
700
701 if test "x$mono_feature_disable_pinvoke" = "xyes"; then
702         AC_DEFINE(DISABLE_PINVOKE, 1, [Disable P/Invoke support])
703         AC_MSG_NOTICE([Disabled support for P/Invoke])
704 fi
705
706 if test "x$mono_feature_disable_debug" = "xyes"; then
707         AC_DEFINE(DISABLE_DEBUG, 1, [Disable runtime debugging support])
708         AC_MSG_NOTICE([Disabled support for runtime debugging])
709 fi
710
711 if test "x$mono_feature_disable_reflection_emit" = "xyes"; then
712         AC_DEFINE(DISABLE_REFLECTION_EMIT, 1, [Disable reflection emit support])
713         mono_feature_disable_reflection_emit_save=yes
714         AC_MSG_NOTICE([Disabled support for Reflection.Emit])
715 fi
716
717 if test "x$mono_feature_disable_reflection_emit_save" = "xyes"; then
718         AC_DEFINE(DISABLE_REFLECTION_EMIT_SAVE, 1, [Disable assembly saving support in reflection emit])
719         AC_MSG_NOTICE([Disabled support for Reflection.Emit.Save])
720 fi
721
722 if test "x$mono_feature_disable_large_code" = "xyes"; then
723         AC_DEFINE(DISABLE_LARGE_CODE, 1, [Disable support for huge assemblies])
724         AC_MSG_NOTICE([Disabled support for large assemblies])
725 fi
726
727 if test "x$mono_feature_disable_logging" = "xyes"; then
728         AC_DEFINE(DISABLE_LOGGING, 1, [Disable support debug logging])
729         AC_MSG_NOTICE([Disabled support for logging])
730 fi
731
732 if test "x$mono_feature_disable_com" = "xyes"; then
733         AC_DEFINE(DISABLE_COM, 1, [Disable COM support])
734         AC_MSG_NOTICE([Disabled COM support])
735 fi
736
737 if test "x$mono_feature_disable_ssa" = "xyes"; then
738         AC_DEFINE(DISABLE_SSA, 1, [Disable advanced SSA JIT optimizations])
739         AC_MSG_NOTICE([Disabled SSA JIT optimizations])
740 fi
741
742 if test "x$mono_feature_disable_generics" = "xyes"; then
743         AC_DEFINE(DISABLE_GENERICS, 1, [Disable generics support])
744         AC_MSG_NOTICE([Disabled Generics Support])
745 fi
746
747 if test "x$mono_feature_disable_shadowcopy" = "xyes"; then
748         AC_DEFINE(DISABLE_SHADOW_COPY, 1, [Disable Shadow Copy for AppDomains])
749         AC_MSG_NOTICE([Disabled Shadow copy for AppDomains])
750 fi
751
752 if test "x$mono_feature_disable_portability" = "xyes"; then
753         AC_DEFINE(DISABLE_PORTABILITY, 1, [Disables the IO portability layer])
754         AC_MSG_NOTICE([Disabled IO Portability layer])
755 fi
756
757 if test "x$mono_feature_disable_attach" = "xyes"; then
758         AC_DEFINE(DISABLE_ATTACH, 1, [Disable agent attach support])
759         AC_MSG_NOTICE([Disabled agent attach])
760 fi
761
762 if test "x$mono_feature_disable_full_messages" = "xyes"; then
763         AC_DEFINE(DISABLE_FULL_MESSAGES, 1, [Disables building in the full table of WAPI messages])
764         AC_MSG_NOTICE([Disabled full messages for Win32 errors, only core message strings shipped])
765 fi
766
767 if test "x$mono_feature_disable_verifier" = "xyes"; then
768         AC_DEFINE(DISABLE_VERIFIER, 1, [Disables the verifier])
769         AC_MSG_NOTICE([Disabled the metadata and IL verifiers])
770 fi
771
772 if test "x$mono_feature_disable_jit" = "xyes"; then
773         AC_DEFINE(DISABLE_JIT, 1, [Disable the JIT, only full-aot mode will be supported by the runtime.])
774         AC_MSG_NOTICE([Disabled the JIT engine, only full AOT will be supported])
775 fi
776
777 AM_CONDITIONAL(DISABLE_JIT, test x$mono_feature_disable_jit = xyes)
778
779 if test "x$mono_feature_disable_simd" = "xyes"; then
780         AC_DEFINE(DISABLE_SIMD, 1, [Disable SIMD intrinsics related optimizations.])
781         AC_MSG_NOTICE([Disabled SIMD support])
782 fi
783
784 if test "x$mono_feature_disable_soft_debug" = "xyes"; then
785         AC_DEFINE(DISABLE_SOFT_DEBUG, 1, [Disable Soft Debugger Agent.])
786         AC_MSG_NOTICE([Disabled Soft Debugger.])
787 fi
788
789 if test "x$mono_feature_disable_normalization" = "xyes"; then
790         AC_DEFINE(DISABLE_NORMALIZATION, 1, [Disable String normalization support.])
791         AC_MSG_NOTICE([Disabled String normalization support.])
792 fi
793
794 AC_MSG_CHECKING(for visibility __attribute__)
795 AC_TRY_COMPILE([], [
796    void __attribute__ ((visibility ("hidden"))) doit (void) {}
797    void main () { doit (); }
798 ], [
799    have_visibility_hidden=yes
800    AC_MSG_RESULT(yes)
801 ], [
802    have_visibility_hidden=no
803    AC_MSG_RESULT(no)
804 ])
805
806 AC_MSG_CHECKING(for deprecated __attribute__)
807 AC_TRY_COMPILE([
808      int doit (void) __attribute__ ((deprecated));
809      int doit (void) { return 0; }
810 ], [
811         return 0;
812 ], [
813    have_deprecated=yes
814    AC_MSG_RESULT(yes)
815 ], [
816    have_deprecated=no
817    AC_MSG_RESULT(no)
818 ])
819
820 AC_ARG_ENABLE(parallel-mark, [  --enable-parallel-mark     Enables GC Parallel Marking], enable_parallel_mark=$enableval, enable_parallel_mark=$parallel_mark)
821 if test x$enable_parallel_mark = xyes; then
822         libgc_configure_args="$libgc_configure_args --enable-parallel-mark"
823 fi
824
825 LIBGC_CFLAGS=
826 LIBGC_LIBS=
827 LIBGC_STATIC_LIBS=
828 libgc_dir=
829 case "x$gc" in
830         xboehm|xbohem|xyes)
831                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
832                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
833
834                 if test "x$found_boehm" != "xyes"; then
835                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
836                 fi
837                 if test "x$gc_headers" != "xyes"; then
838                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
839                 fi
840
841                 AC_DEFINE(HAVE_BOEHM_GC, 1, [Have Boehm GC])
842                 AC_SUBST(HAVE_BOEHM_GC)
843                 LIBGC_LIBS="-lgc $libdl"
844                 LIBGC_STATIC_LIBS="$LIBGC_LIBS"
845                 libmono_ldflags="$libmono_ldflags -lgc"
846
847                 # AC_CHECK_FUNCS does not work for some reason...
848                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
849                 if test "x$found_gcj_malloc" = "xyes"; then
850                         AC_DEFINE(HAVE_GC_GCJ_MALLOC, 1, [Have GC_gcj_malloc])
851                         AC_DEFINE_UNQUOTED(USED_GC_NAME, "System Boehm (with typed GC)", [GC description])
852                 else
853                         AC_DEFINE_UNQUOTED(USED_GC_NAME, "System Boehm (no typed GC)", [GC description])
854                 fi
855                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
856                 if test "x$found_gc_enable" = "xyes"; then
857                         AC_DEFINE(HAVE_GC_ENABLE, 1, [Have 'GC_enable'])
858                 fi
859                 ;;
860
861         xincluded)
862                 found_boehm=yes
863                 gc_headers=yes
864                 use_included_gc=yes
865                 libgc_dir=libgc
866
867                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
868                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
869                 LIBGC_STATIC_LIBS='$(top_builddir)/libgc/libmonogc-static.la'
870
871                 AC_DEFINE(HAVE_BOEHM_GC, 1, [Have Boehm GC])
872                 AC_SUBST(HAVE_BOEHM_GC)
873
874                 AC_DEFINE(HAVE_GC_H, 1, [Have gc.h])
875                 AC_DEFINE(USE_INCLUDED_LIBGC, 1, [Use included libgc])
876
877                 # The included libgc contains GCJ support
878                 AC_DEFINE(HAVE_GC_GCJ_MALLOC, 1, [Have GC_gcj_malloc])
879                 AC_DEFINE(HAVE_GC_ENABLE, 1, [Have GC_enable])
880                 if test x$enable_parallel_mark = xyes; then
881                         AC_DEFINE_UNQUOTED(USED_GC_NAME, "Included Boehm (with typed GC and Parallel Mark)", [GC description])
882                 else
883                         AC_DEFINE_UNQUOTED(USED_GC_NAME, "Included Boehm (with typed GC)", [GC description])
884                 fi
885                 ;;
886
887         xsgen)
888                 found_boehm=no
889                 gc_headers=no
890                 use_included_gc=no
891                 AC_DEFINE(HAVE_SGEN_GC,1,[Using the simple generational GC.])
892                 AC_DEFINE(HAVE_MOVING_COLLECTOR,1,[The GC can move objects.])
893                 AC_DEFINE(HAVE_WRITE_BARRIERS,1,[The GC needs write barriers.])
894                 AC_DEFINE_UNQUOTED(USED_GC_NAME, "Simple generational", [GC description])
895                 ;;
896
897         xnone)
898                 AC_MSG_WARN("Compiling mono without GC.")
899                 AC_DEFINE_UNQUOTED(USED_GC_NAME, "none", [GC description])
900                 AC_DEFINE(HAVE_NULL_GC,1,[No GC support.])
901                 ;;
902         *)
903                 AC_MSG_ERROR([Invalid argument to --with-gc.])
904                 ;;
905 esac
906
907 AC_ARG_WITH(large-heap, [  --with-large-heap=yes,no       Enable support for GC heaps larger than 3GB (defaults to no)], [large_heap=$withval], [large_heap=no])
908 if test "x$large_heap" = "xyes"; then
909    echo "FOO"
910    CPPFLAGS="$CPPFLAGS -DLARGE_CONFIG"
911 fi
912
913 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
914 AC_SUBST(LIBGC_CFLAGS)
915 AC_SUBST(LIBGC_LIBS)
916 AC_SUBST(LIBGC_STATIC_LIBS)
917 AC_SUBST(libgc_dir)
918
919 dnl
920 dnl End of libgc checks
921 dnl
922
923 dnl *************************************
924 dnl *** Checks for zero length arrays ***
925 dnl *************************************
926 AC_MSG_CHECKING(whether $CC supports zero length arrays)
927 AC_TRY_COMPILE([
928         struct s {
929                 int  length;
930                 char data [0];
931         };
932 ], [], [
933         AC_MSG_RESULT(yes)
934         AC_DEFINE_UNQUOTED(MONO_ZERO_LEN_ARRAY, 0, [Length of zero length arrays])
935 ], [
936         AC_MSG_RESULT(no)
937         AC_DEFINE_UNQUOTED(MONO_ZERO_LEN_ARRAY, 1, [Length of zero length arrays])
938 ])
939
940 if test x$target_win32 = xno; then
941
942         dnl hires monotonic clock support
943         AC_SEARCH_LIBS(clock_gettime, rt)
944
945         dnl dynamic loader support
946         AC_CHECK_FUNC(dlopen, DL_LIB="",
947                 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", dl_support=no)
948         )
949         if test x$dl_support = xno; then
950                 AC_MSG_WARN([No dynamic loading support available])
951         else
952                 LIBS="$LIBS $DL_LIB"
953                 AC_DEFINE(HAVE_DL_LOADER,1,[dlopen-based dynamic loader available])
954                 dnl from glib's configure.in
955                 AC_CACHE_CHECK([for preceeding underscore in symbols],
956                         mono_cv_uscore,[
957                         AC_TRY_RUN([#include <dlfcn.h>
958                         int mono_underscore_test (void) { return 42; }
959                         int main() {
960                           void *f1 = (void*)0, *f2 = (void*)0, *handle;
961                           handle = dlopen ((void*)0, 0);
962                           if (handle) {
963                             f1 = dlsym (handle, "mono_underscore_test");
964                             f2 = dlsym (handle, "_mono_underscore_test");
965                           } return (!f2 || f1);
966                         }],
967                                 [mono_cv_uscore=yes],
968                                 [mono_cv_uscore=no],
969                         [])
970                 ])
971                 if test "x$mono_cv_uscore" = "xyes"; then
972                         MONO_DL_NEED_USCORE=1
973                 else
974                         MONO_DL_NEED_USCORE=0
975                 fi
976                 AC_SUBST(MONO_DL_NEED_USCORE)
977                 AC_CHECK_FUNC(dlerror)
978         fi
979
980         dnl ******************************************************************
981         dnl *** Checks for the IKVM JNI interface library                  ***
982         dnl ******************************************************************
983         AC_ARG_WITH(ikvm-native, [  --with-ikvm-native=yes,no      build the IKVM JNI interface library (defaults to yes)],[with_ikvm_native=$withval],[with_ikvm_native=yes])
984
985         ikvm_native_dir=
986         if test x$with_ikvm_native = xyes; then
987                 ikvm_native_dir=ikvm-native
988                 jdk_headers_found="IKVM Native"
989         fi
990
991         AC_SUBST(ikvm_native_dir)
992
993         AC_CHECK_HEADERS(execinfo.h)
994
995         AC_CHECK_FUNCS(getgrgid_r)
996         AC_CHECK_FUNCS(getgrnam_r)
997         AC_CHECK_FUNCS(getpwnam_r)
998         AC_CHECK_FUNCS(getpwuid_r)
999         AC_CHECK_FUNCS(getresuid)
1000         AC_CHECK_FUNCS(setresuid)
1001         AC_CHECK_FUNCS(kqueue)
1002         AC_CHECK_FUNCS(backtrace_symbols)
1003         AC_CHECK_FUNCS(mkstemp)
1004         AC_CHECK_FUNCS(mmap)
1005         AC_CHECK_FUNCS(madvise)
1006         AC_CHECK_FUNCS(getrusage)
1007         AC_CHECK_FUNCS(getpriority)
1008         AC_CHECK_FUNCS(setpriority)
1009         AC_CHECK_FUNCS(dl_iterate_phdr)
1010         AC_CHECK_FUNCS(sysconf)
1011
1012         AC_CHECK_FUNCS(sched_setaffinity)
1013
1014         dnl ****************************************************************
1015         dnl *** Check for sched_setaffinity from glibc versions before   ***
1016         dnl *** 2.3.4. The older versions of the function only take 2    ***
1017         dnl *** parameters, not 3.                                       ***
1018         dnl ***                                                          ***
1019         dnl *** Because the interface change was not made in a minor     ***
1020         dnl *** version rev, the __GLIBC__ and __GLIBC_MINOR__ macros    ***
1021         dnl *** won't always indicate the interface sched_affinity has.  ***
1022         dnl ****************************************************************
1023         AC_MSG_CHECKING(for sched_setaffinity from glibc < 2.3.4)
1024         AC_TRY_COMPILE([#include <sched.h>], [
1025                 int main() {
1026             int mask = 1; 
1027             sched_setaffinity(0, &mask);
1028         }
1029         ], [
1030                 # Yes, we have it...
1031                 AC_MSG_RESULT(yes)
1032                 AC_DEFINE(GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY, 1, [Have GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY])
1033         ], [
1034                 # We have the new, three-parameter version
1035                 AC_MSG_RESULT(no)
1036         ])
1037
1038
1039         dnl ******************************************************************
1040         dnl *** Check for large file support                               ***
1041         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
1042         dnl ******************************************************************
1043         
1044         # Check that off_t can represent 2**63 - 1 correctly, working around
1045         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
1046         # CPPFLAGS and sets $large_offt to yes if the test succeeds
1047         large_offt=no
1048         AC_DEFUN([LARGE_FILES], [
1049                 large_CPPFLAGS=$CPPFLAGS
1050                 CPPFLAGS="$CPPFLAGS $1"
1051                 AC_TRY_RUN([
1052                         #include <sys/types.h>
1053
1054                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
1055
1056                         int main(void) {
1057                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
1058                                                (BIG_OFF_T%2147483647==1));
1059                                 if(big_off_t) {
1060                                         exit(0);
1061                                 } else {
1062                                         exit(1);
1063                                 }
1064                         }
1065                 ], [
1066                         AC_MSG_RESULT(ok)
1067                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT, 1, [Have large file support])
1068                         large_CPPFLAGS="$large_CPPFLAGS $1"
1069                         large_offt=yes
1070                 ], [
1071                         AC_MSG_RESULT(no)
1072                 ], "")
1073                 CPPFLAGS=$large_CPPFLAGS
1074         ])
1075
1076         AC_MSG_CHECKING(if off_t is 64 bits wide)
1077         LARGE_FILES("")
1078         if test $large_offt = no; then
1079                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
1080                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
1081         fi
1082         if test $large_offt = no; then
1083                 AC_MSG_WARN([No 64 bit file size support available])
1084         fi
1085         
1086         dnl *****************************
1087         dnl *** Checks for libsocket  ***
1088         dnl *****************************
1089         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
1090
1091         dnl *******************************
1092         dnl *** Checks for MSG_NOSIGNAL ***
1093         dnl *******************************
1094         AC_MSG_CHECKING(for MSG_NOSIGNAL)
1095         AC_TRY_COMPILE([#include <sys/socket.h>], [
1096                 int f = MSG_NOSIGNAL;
1097         ], [
1098                 # Yes, we have it...
1099                 AC_MSG_RESULT(yes)
1100                 AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Have MSG_NOSIGNAL])
1101         ], [
1102                 # We'll have to use signals
1103                 AC_MSG_RESULT(no)
1104         ])
1105
1106         dnl *****************************
1107         dnl *** Checks for SOL_IP     ***
1108         dnl *****************************
1109         AC_MSG_CHECKING(for SOL_IP)
1110         AC_TRY_COMPILE([#include <netdb.h>], [
1111                 int level = SOL_IP;
1112         ], [
1113                 # Yes, we have it...
1114                 AC_MSG_RESULT(yes)
1115                 AC_DEFINE(HAVE_SOL_IP, 1, [Have SOL_IP])
1116         ], [
1117                 # We'll have to use getprotobyname
1118                 AC_MSG_RESULT(no)
1119         ])
1120
1121         dnl *****************************
1122         dnl *** Checks for SOL_IPV6     ***
1123         dnl *****************************
1124         AC_MSG_CHECKING(for SOL_IPV6)
1125         AC_TRY_COMPILE([#include <netdb.h>], [
1126                 int level = SOL_IPV6;
1127         ], [
1128                 # Yes, we have it...
1129                 AC_MSG_RESULT(yes)
1130                 AC_DEFINE(HAVE_SOL_IPV6, 1, [Have SOL_IPV6])
1131         ], [
1132                 # We'll have to use getprotobyname
1133                 AC_MSG_RESULT(no)
1134         ])
1135
1136         dnl *****************************
1137         dnl *** Checks for SOL_TCP    ***
1138         dnl *****************************
1139         AC_MSG_CHECKING(for SOL_TCP)
1140         AC_TRY_COMPILE([#include <netdb.h>], [
1141                 int level = SOL_TCP;
1142         ], [
1143                 # Yes, we have it...
1144                 AC_MSG_RESULT(yes)
1145                 AC_DEFINE(HAVE_SOL_TCP, 1, [Have SOL_TCP])
1146         ], [
1147                 # We'll have to use getprotobyname
1148                 AC_MSG_RESULT(no)
1149         ])
1150
1151         dnl *****************************
1152         dnl *** Checks for IP_PKTINFO ***
1153         dnl *****************************
1154         AC_MSG_CHECKING(for IP_PKTINFO)
1155         AC_TRY_COMPILE([#include <netdb.h>], [
1156                 int level = IP_PKTINFO;
1157         ], [
1158                 # Yes, we have it...
1159                 AC_MSG_RESULT(yes)
1160                 AC_DEFINE(HAVE_IP_PKTINFO, 1, [Have IP_PKTINFO])
1161         ], [
1162                 AC_MSG_RESULT(no)
1163         ])
1164
1165         dnl *****************************
1166         dnl *** Checks for IPV6_PKTINFO ***
1167         dnl *****************************
1168         AC_MSG_CHECKING(for IPV6_PKTINFO)
1169         AC_TRY_COMPILE([#include <netdb.h>], [
1170                 int level = IPV6_PKTINFO;
1171         ], [
1172                 # Yes, we have it...
1173                 AC_MSG_RESULT(yes)
1174                 AC_DEFINE(HAVE_IPV6_PKTINFO, 1, [Have IPV6_PKTINFO])
1175         ], [
1176                 AC_MSG_RESULT(no)
1177         ])
1178
1179         dnl **********************************
1180         dnl *** Checks for IP_DONTFRAGMENT ***
1181         dnl **********************************
1182         AC_MSG_CHECKING(for IP_DONTFRAGMENT)
1183         AC_TRY_COMPILE([#include <netdb.h>], [
1184                 int level = IP_DONTFRAGMENT;
1185         ], [
1186                 # Yes, we have it...
1187                 AC_MSG_RESULT(yes)
1188                 AC_DEFINE(HAVE_IP_DONTFRAGMENT, 1, [Have IP_DONTFRAGMENT])
1189         ], [
1190                 AC_MSG_RESULT(no)
1191         ])
1192
1193         dnl **********************************
1194         dnl *** Checks for IP_MTU_DISCOVER ***
1195         dnl **********************************
1196         AC_MSG_CHECKING(for IP_MTU_DISCOVER)
1197         AC_TRY_COMPILE([#include <netdb.h>], [
1198                 int level = IP_MTU_DISCOVER;
1199         ], [
1200                 # Yes, we have it...
1201                 AC_MSG_RESULT(yes)
1202                 AC_DEFINE(HAVE_IP_MTU_DISCOVER, 1, [Have IP_MTU_DISCOVER])
1203         ], [
1204                 AC_MSG_RESULT(no)
1205         ])
1206
1207         dnl *********************************
1208         dnl *** Check for struct ip_mreqn ***
1209         dnl *********************************
1210         AC_MSG_CHECKING(for struct ip_mreqn)
1211         AC_TRY_COMPILE([#include <netinet/in.h>], [
1212                 struct ip_mreqn mreq;
1213                 mreq.imr_address.s_addr = 0;
1214         ], [
1215                 # Yes, we have it...
1216                 AC_MSG_RESULT(yes)
1217                 AC_DEFINE(HAVE_STRUCT_IP_MREQN, 1, [Have struct ip_mreqn])
1218         ], [
1219                 # We'll just have to try and use struct ip_mreq
1220                 AC_MSG_RESULT(no)
1221                 AC_MSG_CHECKING(for struct ip_mreq)
1222                 AC_TRY_COMPILE([#include <netinet/in.h>], [
1223                         struct ip_mreq mreq;
1224                         mreq.imr_interface.s_addr = 0;
1225                 ], [
1226                         # Yes, we have it...
1227                         AC_MSG_RESULT(yes)
1228                         AC_DEFINE(HAVE_STRUCT_IP_MREQ, 1, [Have struct ip_mreq])
1229                 ], [
1230                         # No multicast support
1231                         AC_MSG_RESULT(no)
1232                 ])
1233         ])
1234         
1235         dnl **********************************
1236         dnl *** Check for gethostbyname2_r ***
1237         dnl **********************************
1238         AC_MSG_CHECKING(for gethostbyname2_r)
1239                 AC_TRY_LINK([#include <netdb.h>], [
1240                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
1241         ], [
1242                 # Yes, we have it...
1243                 AC_MSG_RESULT(yes)
1244                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R, 1, [Have gethostbyname2_r])
1245         ], [
1246                 AC_MSG_RESULT(no)
1247         ])
1248
1249         dnl *****************************
1250         dnl *** Checks for libnsl     ***
1251         dnl *****************************
1252         AC_CHECK_FUNC(gethostbyaddr, , AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl"))
1253
1254         AC_CHECK_FUNCS(inet_pton inet_aton)
1255
1256         dnl ***********************************************
1257         dnl *** Checks for size of sockaddr_un.sun_path ***
1258         dnl ***********************************************
1259         # AC_CHECK_SIZEOF can't cope with struct members :-(
1260         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
1261         AC_CACHE_VAL(mono_cv_sizeof_sunpath,
1262                 [AC_TRY_RUN([
1263                         #include <sys/types.h>
1264                         #include <stdio.h>
1265                         #include <sys/un.h>
1266
1267                         int main(void) {
1268                                 struct sockaddr_un sock_un;
1269                                 FILE *f=fopen("conftestval", "w");
1270                                 if(!f) exit(1);
1271                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
1272                                 exit(0);
1273                         }
1274                 ], mono_cv_sizeof_sunpath=`cat conftestval`,
1275                    mono_cv_sizeof_sunpath=0,
1276                    mono_cv_sizeof_sunpath=0)])dnl
1277         AC_MSG_RESULT($mono_cv_sizeof_sunpath)
1278         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $mono_cv_sizeof_sunpath, [Sizeof sock_un.sun_path])
1279
1280         dnl *****************************
1281         dnl *** Checks for libxnet    ***
1282         dnl *****************************
1283         case "${host}" in
1284                 *solaris* )
1285                         AC_MSG_CHECKING(for Solaris XPG4 support)
1286                         if test -f /usr/lib/libxnet.so; then
1287                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
1288                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
1289                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
1290                                 LIBS="$LIBS -lxnet"
1291                                 AC_MSG_RESULT(yes)
1292                         else
1293                                 AC_MSG_RESULT(no)
1294                         fi
1295
1296                         if test "$GCC" = "yes"; then
1297                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
1298                         fi
1299                 ;;
1300         esac
1301
1302         dnl *****************************
1303         dnl *** Checks for libpthread ***
1304         dnl *****************************
1305 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
1306 # and libpthread does not exist
1307 #
1308         case "${host}" in
1309                 *-*-*freebsd*)
1310                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
1311                 ;;
1312                 *-*-*openbsd*)
1313                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
1314                 ;;
1315                 *)
1316                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
1317                 ;;
1318         esac
1319         AC_CHECK_HEADERS(pthread.h)
1320         AC_CHECK_FUNCS(pthread_mutex_timedlock)
1321         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
1322         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
1323         AC_TRY_COMPILE([ #include <pthread.h>], [
1324                 pthread_mutexattr_t attr;
1325                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1326         ], [
1327                 AC_MSG_RESULT(ok)
1328         ], [
1329                 AC_MSG_RESULT(no)
1330                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
1331                 AC_DEFINE(USE_MONO_MUTEX, 1, [Use mono_mutex_t])
1332         ])
1333         AC_CHECK_FUNCS(pthread_attr_setstacksize)
1334         AC_CHECK_FUNCS(pthread_attr_getstack pthread_attr_getstacksize)
1335         AC_CHECK_FUNCS(pthread_get_stacksize_np pthread_get_stackaddr_np)
1336
1337         dnl ***********************************
1338         dnl *** Checks for signals
1339         dnl ***********************************
1340         AC_CHECK_HEADERS(signal.h)
1341         AC_CHECK_FUNCS(sigaction)
1342
1343         dnl ***********************************
1344         dnl *** Checks for working __thread ***
1345         dnl ***********************************
1346         AC_MSG_CHECKING(for working __thread)
1347         if test "x$with_tls" != "x__thread"; then
1348                 AC_MSG_RESULT(disabled)
1349         else
1350                 AC_TRY_RUN([
1351                         #include <pthread.h>
1352                         __thread int i;
1353                         static int res1, res2;
1354
1355                         void thread_main (void *arg)
1356                         {
1357                                 i = arg;
1358                                 sleep (1);
1359                                 if (arg == 1)
1360                                         res1 = (i == arg);
1361                                 else
1362                                         res2 = (i == arg);
1363                         }
1364
1365                         int main () {
1366                                 pthread_t t1, t2;
1367
1368                                 i = 5;
1369
1370                                 pthread_create (&t1, NULL, thread_main, 1);
1371                                 pthread_create (&t2, NULL, thread_main, 2);
1372
1373                                 pthread_join (t1, NULL);
1374                                 pthread_join (t2, NULL);
1375
1376                                 return !(res1 + res2 == 2);
1377                         }
1378                 ], [
1379                                 AC_MSG_RESULT(yes)
1380                 ], [
1381                                 AC_MSG_RESULT(no)
1382                                 with_tls=pthread
1383                 ])
1384         fi
1385
1386         dnl **************************************
1387         dnl *** Checks for working sigaltstack ***
1388         dnl **************************************
1389         AC_MSG_CHECKING(for working sigaltstack)
1390         if test "x$with_sigaltstack" != "xyes"; then
1391                 AC_MSG_RESULT(disabled)
1392         else
1393                 AC_TRY_RUN([
1394                         #include <stdio.h>
1395                         #include <stdlib.h>
1396                         #include <unistd.h>
1397                         #include <signal.h>
1398                         #include <pthread.h>
1399                         #include <sys/wait.h>
1400                         #if defined(__FreeBSD__) || defined(__NetBSD__)
1401                         #define SA_STACK SA_ONSTACK
1402                         #endif
1403                         static void
1404                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
1405                         {
1406                                 exit (0);
1407                         }
1408
1409                         static void *
1410                         loop (void *ignored)
1411                         {
1412                                 char *ptr = NULL;
1413
1414                                 *ptr = 0;
1415                                 return NULL;
1416                         }
1417
1418                         static void
1419                         child ()
1420                         {
1421                                 struct sigaction sa;
1422                                 struct sigaltstack sas;
1423                                 pthread_t id;
1424                                 pthread_attr_t attr;
1425
1426                                 sa.sa_sigaction = sigsegv_signal_handler;
1427                                 sigemptyset (&sa.sa_mask);
1428                                 sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
1429                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
1430                                         perror ("sigaction");
1431                                         return;
1432                                 }
1433
1434                                 sas.ss_sp = malloc (SIGSTKSZ);
1435                                 sas.ss_size = SIGSTKSZ;
1436                                 sas.ss_flags = 0;
1437                                 if (sigaltstack (&sas, NULL) == -1) {
1438                                         perror ("sigaltstack");
1439                                         return;
1440                                 }
1441
1442                                 pthread_attr_init (&attr);
1443                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
1444                                         printf ("pthread_create\n");
1445                                         return;
1446                                 }
1447
1448                                 sleep (100);
1449                         }
1450
1451                         int
1452                         main ()
1453                         {
1454                                 pid_t son;
1455                                 int status;
1456                                 int i;
1457
1458                                 son = fork ();
1459                                 if (son == -1) {
1460                                         return 1;
1461                                 }
1462
1463                                 if (son == 0) {
1464                                         child ();
1465                                         return 0;
1466                                 }
1467
1468                                 for (i = 0; i < 3; ++i) {
1469                                         sleep (1);
1470                                         waitpid (son, &status, WNOHANG);
1471                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
1472                                                 return 0;
1473                                 }
1474
1475                                 kill (son, SIGKILL);
1476                                 return 1;
1477                         }
1478
1479                 ], [
1480                                 AC_MSG_RESULT(yes)
1481                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK, 1, [Have a working sigaltstack])
1482                 ], [
1483                                 with_sigaltstack=no
1484                                 AC_MSG_RESULT(no)
1485                 ])
1486         fi
1487
1488         dnl ********************************
1489         dnl *** Checks for semaphore lib ***
1490         dnl ********************************
1491         # 'Real Time' functions on Solaris
1492         # posix4 on Solaris 2.6
1493         # pthread (first!) on Linux
1494         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
1495
1496         AC_SEARCH_LIBS(shm_open, pthread rt posix4) 
1497         AC_CHECK_FUNCS(shm_open)
1498
1499         dnl ********************************
1500         dnl *** Checks for timezone stuff **
1501         dnl ********************************
1502         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
1503                 AC_TRY_COMPILE([
1504                         #include <time.h>
1505                         ], [
1506                         struct tm tm;
1507                         tm.tm_gmtoff = 1;
1508                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
1509         if test $ac_cv_struct_tm_gmtoff = yes; then
1510                 AC_DEFINE(HAVE_TM_GMTOFF, 1, [Have tm_gmtoff])
1511         else
1512                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
1513                         AC_TRY_COMPILE([
1514                                 #include <time.h>
1515                         ], [
1516                                 timezone = 1;
1517                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
1518                 if test $ac_cv_var_timezone = yes; then
1519                         AC_DEFINE(HAVE_TIMEZONE, 1, [Have timezone variable])
1520                 else
1521                         AC_ERROR(unable to find a way to determine timezone)
1522                 fi
1523         fi
1524
1525         dnl *********************************
1526         dnl *** Checks for math functions ***
1527         dnl *********************************
1528         AC_SEARCH_LIBS(sqrtf, m)
1529         if test "x$has_broken_apple_cpp" != "xyes"; then
1530                 AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
1531                         AC_TRY_LINK([#include <math.h>], 
1532                         [ finite(0.0); ], 
1533                         AC_DEFINE(HAVE_FINITE, 1, [Have finite]) AC_MSG_RESULT(yes),
1534                         AC_MSG_RESULT(no)))
1535         fi
1536         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
1537                 AC_TRY_LINK([#include <math.h>], 
1538                 [ isfinite(0.0); ], 
1539                 AC_DEFINE(HAVE_ISFINITE, 1, [Have isfinite]) AC_MSG_RESULT(yes),
1540                 AC_MSG_RESULT(no)))
1541
1542         dnl ****************************************************************
1543         dnl *** Checks for working poll() (macosx defines it but doesn't ***
1544         dnl *** have it in the library (duh))                            ***
1545         dnl ****************************************************************
1546         AC_CHECK_FUNCS(poll)
1547
1548         dnl *************************
1549         dnl *** Check for signbit ***
1550         dnl *************************
1551         AC_MSG_CHECKING(for signbit)
1552         AC_TRY_LINK([#include <math.h>], [
1553                 int s = signbit(1.0);
1554         ], [
1555                 AC_MSG_RESULT(yes)
1556                 AC_DEFINE(HAVE_SIGNBIT, 1, [Have signbit])
1557         ], [
1558                 AC_MSG_RESULT(no)
1559         ]) 
1560
1561         dnl **********************************
1562         dnl *** epoll                      ***
1563         dnl **********************************
1564         AC_CHECK_HEADERS(sys/epoll.h)
1565         haveepoll=no
1566         AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
1567         if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes" ; then
1568                 AC_DEFINE(HAVE_EPOLL, 1, [epoll supported])
1569         fi
1570
1571         dnl ******************************
1572         dnl *** Checks for SIOCGIFCONF ***
1573         dnl ******************************
1574         AC_CHECK_HEADERS(sys/ioctl.h)
1575         AC_CHECK_HEADERS(net/if.h, [], [],
1576            [
1577            #ifdef HAVE_SYS_TYPES_H
1578            # include <sys/types.h>
1579            #endif
1580            #ifdef HAVE_SYS_SOCKET_H
1581            # include <sys/socket.h>
1582            #endif
1583            ])
1584         AC_MSG_CHECKING(for ifreq)
1585         AC_TRY_COMPILE([
1586                 #include <stdio.h>
1587                 #include <sys/ioctl.h>
1588                 #include <net/if.h>
1589                 ], [
1590                 struct ifconf ifc;
1591                 struct ifreq *ifr;
1592                 void *x;
1593                 ifc.ifc_len = 0;
1594                 ifc.ifc_buf = NULL;
1595                 x = (void *) &ifr->ifr_addr;
1596                 ],[
1597                         AC_MSG_RESULT(yes)
1598                         AC_DEFINE(HAVE_SIOCGIFCONF, 1, [Can get interface list])
1599                 ], [
1600                         AC_MSG_RESULT(no)
1601                 ])
1602         dnl **********************************
1603         dnl ***     Checks for sin_len     ***
1604         dnl **********************************
1605         AC_MSG_CHECKING(for sockaddr_in.sin_len)
1606         AC_TRY_COMPILE([
1607                 #include <netinet/in.h>
1608                 ], [
1609                 struct sockaddr_in saddr;
1610                 saddr.sin_len = sizeof (saddr);
1611                 ],[
1612                         AC_MSG_RESULT(yes)
1613                         AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1, [sockaddr_in has sin_len])
1614                 ], [
1615                         AC_MSG_RESULT(no)
1616                 ])      
1617         dnl **********************************
1618         dnl ***    Checks for sin6_len     ***
1619         dnl **********************************
1620         AC_MSG_CHECKING(for sockaddr_in6.sin6_len)
1621         AC_TRY_COMPILE([
1622                 #include <netinet/in.h>
1623                 ], [
1624                 struct sockaddr_in6 saddr6;
1625                 saddr6.sin6_len = sizeof (saddr6);
1626                 ],[
1627                         AC_MSG_RESULT(yes)
1628                         AC_DEFINE(HAVE_SOCKADDR_IN6_SIN_LEN, 1, [sockaddr_in6 has sin6_len])
1629                 ], [
1630                         AC_MSG_RESULT(no)
1631                 ])      
1632         dnl **********************************
1633         dnl *** Checks for MonoPosixHelper ***
1634         dnl **********************************
1635         AC_CHECK_HEADERS(checklist.h)
1636         AC_CHECK_HEADERS(pathconf.h)
1637         AC_CHECK_HEADERS(fstab.h)
1638         AC_CHECK_HEADERS(attr/xattr.h)
1639         AC_CHECK_HEADERS(sys/extattr.h)
1640         AC_CHECK_HEADERS(sys/sendfile.h)
1641         AC_CHECK_HEADERS(sys/statvfs.h)
1642         AC_CHECK_HEADERS(sys/statfs.h)
1643         AC_CHECK_HEADERS(sys/vfstab.h)
1644         AC_CHECK_HEADERS(sys/xattr.h)
1645         AC_CHECK_HEADERS(sys/mman.h)
1646         AC_CHECK_HEADERS(sys/param.h)
1647         AC_CHECK_HEADERS(sys/mount.h, [], [],
1648                 [
1649                 #ifdef HAVE_SYS_PARAM_H
1650                 # include <sys/param.h>
1651                 #endif
1652                 ])
1653         AC_CHECK_HEADERS(sys/mount.h)
1654         AC_CHECK_FUNCS(confstr)
1655         AC_CHECK_FUNCS(seekdir telldir)
1656         AC_CHECK_FUNCS(getdomainname)
1657         AC_CHECK_FUNCS(setdomainname)
1658         AC_CHECK_FUNCS(endgrent getgrent fgetgrent setgrent)
1659         AC_CHECK_FUNCS(setgroups)
1660         AC_CHECK_FUNCS(endpwent getpwent fgetpwent setpwent)
1661         AC_CHECK_FUNCS(getfsstat)
1662         AC_CHECK_FUNCS(lutimes futimes)
1663         AC_CHECK_FUNCS(mremap)
1664         AC_CHECK_FUNCS(remap_file_pages)
1665         AC_CHECK_FUNCS(posix_fadvise)
1666         AC_CHECK_FUNCS(posix_fallocate)
1667         AC_CHECK_FUNCS(posix_madvise)
1668         AC_CHECK_FUNCS(vsnprintf)
1669         AC_CHECK_FUNCS(sendfile)
1670         AC_CHECK_FUNCS(gethostid sethostid)
1671         AC_CHECK_FUNCS(sethostname)
1672         AC_CHECK_FUNCS(statfs)
1673         AC_CHECK_FUNCS(fstatfs)
1674         AC_CHECK_FUNCS(statvfs)
1675         AC_CHECK_FUNCS(fstatvfs)
1676         AC_CHECK_FUNCS(stime)
1677         AC_CHECK_FUNCS(strerror_r)
1678         AC_CHECK_FUNCS(ttyname_r)
1679         AC_CHECK_FUNCS(psignal)
1680         AC_CHECK_FUNCS(getlogin_r)
1681         AC_CHECK_FUNCS(lockf)
1682         AC_CHECK_FUNCS(swab)
1683         AC_CHECK_FUNCS(setusershell endusershell)
1684         AC_CHECK_SIZEOF(size_t)
1685         AC_CHECK_TYPES([blksize_t], [AC_DEFINE(HAVE_BLKSIZE_T)], , 
1686                 [#include <sys/types.h>
1687                  #include <sys/stat.h>
1688                  #include <unistd.h>])
1689         AC_CHECK_TYPES([blkcnt_t], [AC_DEFINE(HAVE_BLKCNT_T)], ,
1690                 [#include <sys/types.h>
1691                  #include <sys/stat.h>
1692                  #include <unistd.h>])
1693         AC_CHECK_TYPES([suseconds_t], [AC_DEFINE(HAVE_SUSECONDS_T)], ,
1694                 [#include <sys/time.h>])
1695         AC_CHECK_TYPES([struct flock], [AC_DEFINE(HAVE_STRUCT_FLOCK)], ,
1696                 [#include <unistd.h>
1697                  #include <fcntl.h>])
1698         AC_CHECK_TYPES([struct pollfd], [AC_DEFINE(HAVE_STRUCT_POLLFD)], ,
1699                 [#include <sys/poll.h>])
1700         AC_CHECK_TYPES([struct stat], [AC_DEFINE(HAVE_STRUCT_STAT)], ,
1701                 [#include <sys/types.h>
1702                  #include <sys/stat.h>
1703                  #include <unistd.h>])
1704         AC_CHECK_TYPES([struct timespec], [AC_DEFINE(HAVE_STRUCT_TIMESPEC)], ,
1705                 [#include <time.h>])
1706         AC_CHECK_TYPES([struct timeval], [AC_DEFINE(HAVE_STRUCT_TIMEVAL)], ,
1707                 [#include <sys/time.h>
1708                  #include <sys/types.h>
1709                  #include <utime.h>])
1710         AC_CHECK_TYPES([struct timezone], [AC_DEFINE(HAVE_STRUCT_TIMEZONE)], ,
1711                 [#include <sys/time.h>])
1712         AC_CHECK_TYPES([struct utimbuf], [AC_DEFINE(HAVE_STRUCT_UTIMBUF)], ,
1713                 [#include <sys/types.h>
1714                  #include <utime.h>])
1715         AC_CHECK_MEMBERS(
1716                 [struct dirent.d_off, struct dirent.d_reclen, struct dirent.d_type],,, 
1717                 [#include <sys/types.h>
1718                  #include <dirent.h>])
1719         AC_CHECK_MEMBERS(
1720                 [struct passwd.pw_gecos],,, 
1721                 [#include <sys/types.h>
1722                  #include <pwd.h>])
1723         AC_CHECK_MEMBERS(
1724                 [struct statfs.f_flags],,, 
1725                 [#include <sys/types.h>
1726                  #include <sys/vfs.h>])
1727
1728         dnl Favour xattr through glibc, but use libattr if we have to
1729         AC_CHECK_FUNC(lsetxattr, ,
1730                 AC_CHECK_LIB(attr, lsetxattr, XATTR_LIB="-lattr",)
1731         )
1732         AC_SUBST(XATTR_LIB)
1733
1734         dnl kinfo_proc.kp_proc works on darwin but fails on other simil-bsds
1735         AC_CHECK_MEMBERS(
1736                 [struct kinfo_proc.kp_proc],,, 
1737                 [#include <sys/types.h>
1738                  #include <sys/param.h>
1739                  #include <sys/sysctl.h>
1740                  #include <sys/proc.h>
1741                  ])
1742
1743         dnl *********************************
1744         dnl *** Checks for Windows compilation ***
1745         dnl *********************************
1746         AC_CHECK_HEADERS(sys/time.h)
1747         AC_CHECK_HEADERS(sys/param.h)
1748         AC_CHECK_HEADERS(dirent.h)
1749
1750         dnl *********************************
1751         dnl *** Check for Console 2.0 I/O ***
1752         dnl *********************************
1753         AC_CHECK_HEADERS([curses.h])
1754         AC_CHECK_HEADERS([term.h], [], [],
1755         [#if HAVE_CURSES_H
1756          #include <curses.h>
1757          #endif
1758         ])
1759         AC_CHECK_HEADERS([termios.h])
1760
1761         dnl * This is provided in io-layer, but on windows it's only available
1762         dnl * on xp+
1763         AC_DEFINE(HAVE_GETPROCESSID, 1, [Define if GetProcessId is available])
1764 else
1765         jdk_headers_found=no
1766         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
1767         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
1768         AC_CHECK_LIB(ole32, main, LIBS="$LIBS -lole32", AC_ERROR(bad mingw install?))
1769         AC_CHECK_LIB(winmm, main, LIBS="$LIBS -lwinmm", AC_ERROR(bad mingw install?))
1770         AC_CHECK_LIB(oleaut32, main, LIBS="$LIBS -loleaut32", AC_ERROR(bad mingw install?))
1771         AC_CHECK_LIB(advapi32, main, LIBS="$LIBS -ladvapi32", AC_ERROR(bad mingw install?))
1772         AC_CHECK_LIB(version, main, LIBS="$LIBS -lversion", AC_ERROR(bad mingw install?))
1773
1774         dnl *********************************
1775         dnl *** Check for struct ip_mreqn ***
1776         dnl *********************************
1777         AC_MSG_CHECKING(for struct ip_mreqn)
1778         AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1779                 struct ip_mreqn mreq;
1780                 mreq.imr_address.s_addr = 0;
1781         ], [
1782                 # Yes, we have it...
1783                 AC_MSG_RESULT(yes)
1784                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
1785         ], [
1786                 # We'll just have to try and use struct ip_mreq
1787                 AC_MSG_RESULT(no)
1788                 AC_MSG_CHECKING(for struct ip_mreq)
1789                 AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1790                         struct ip_mreq mreq;
1791                         mreq.imr_interface.s_addr = 0;
1792                 ], [
1793                         # Yes, we have it...
1794                         AC_MSG_RESULT(yes)
1795                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
1796                 ], [
1797                         # No multicast support
1798                         AC_MSG_RESULT(no)
1799                 ])
1800         ])
1801         AC_CHECK_FUNCS(GetProcessId)
1802 fi
1803
1804 dnl socklen_t check
1805 AC_MSG_CHECKING(for socklen_t)
1806 AC_TRY_COMPILE([
1807 #include <sys/types.h>
1808 #include <sys/socket.h>
1809 ],[
1810   socklen_t foo;
1811 ],[
1812 ac_cv_c_socklen_t=yes
1813         AC_DEFINE(HAVE_SOCKLEN_T, 1, [Have socklen_t])
1814         AC_MSG_RESULT(yes)
1815 ],[
1816         AC_MSG_RESULT(no)
1817 ])
1818
1819 AC_MSG_CHECKING(for array element initializer support)
1820 AC_TRY_COMPILE([#include <sys/socket.h>], [
1821         const int array[] = {[1] = 2,};
1822 ], [
1823         # Yes, we have it...
1824         AC_MSG_RESULT(yes)
1825         AC_DEFINE(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
1826 ], [
1827         # We'll have to use signals
1828         AC_MSG_RESULT(no)
1829 ])
1830
1831 AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
1832         # Simply calling trunc (0.0) is no good since gcc will optimize the call away
1833         AC_TRY_LINK([#include <math.h>], 
1834         [ static void *p = &trunc; ],
1835         [
1836                 AC_DEFINE(HAVE_TRUNC) 
1837                 AC_MSG_RESULT(yes)
1838                 ac_cv_trunc=yes
1839         ],
1840         AC_MSG_RESULT(no)))
1841
1842 if test "x$ac_cv_truncl" != "xyes"; then
1843    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL, 1, [Has the 'aintl' function]) LIBS="$LIBS -lsunmath"])
1844 fi
1845
1846 AC_CHECK_FUNCS(round)
1847 AC_CHECK_FUNCS(rint)
1848
1849 dnl ****************************
1850 dnl *** Look for /dev/random ***
1851 dnl ****************************
1852
1853 AC_MSG_CHECKING([if usage of random device is requested])
1854 AC_ARG_ENABLE(dev-random,
1855 [  --disable-dev-random    disable the use of the random device (enabled by default)],
1856 try_dev_random=$enableval, try_dev_random=yes)
1857
1858 AC_MSG_RESULT($try_dev_random)
1859
1860 case "{$target}" in
1861     *-openbsd*)
1862     NAME_DEV_RANDOM="/dev/srandom"
1863     ;;
1864
1865 dnl Win32 does not have /dev/random, they have their own method...
1866
1867     *-mingw*|*-*-cygwin*)
1868     ac_cv_have_dev_random=no
1869     ;;
1870
1871 dnl Everywhere else, it's /dev/random
1872
1873     *)
1874     NAME_DEV_RANDOM="/dev/random"
1875     ;;
1876 esac
1877
1878 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM", [Name of /dev/random])
1879
1880 dnl Now check if the device actually exists
1881
1882 if test "x$try_dev_random" = "xyes"; then
1883     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1884     [if test -r "$NAME_DEV_RANDOM" ; then
1885         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1886     if test "x$ac_cv_have_dev_random" = "xyes"; then
1887         AC_DEFINE(HAVE_CRYPT_RNG, 1, [Have /dev/random])
1888     fi
1889 else
1890     AC_MSG_CHECKING(for random device)
1891     ac_cv_have_dev_random=no
1892     AC_MSG_RESULT(has been disabled)
1893 fi
1894
1895 if test "x$host_win32" = "xyes"; then
1896     AC_DEFINE(HAVE_CRYPT_RNG)
1897 fi
1898
1899 if test "x$ac_cv_have_dev_random" = "xno" \
1900     && test "x$host_win32" = "xno"; then
1901     AC_MSG_WARN([[
1902 ***
1903 *** A system-provided entropy source was not found on this system.
1904 *** Because of this, the System.Security.Cryptography random number generator
1905 *** will throw a NotImplemented exception.
1906 ***
1907 *** If you are seeing this message, and you know your system DOES have an
1908 *** entropy collection in place, please contact <crichton@gimp.org> and
1909 *** provide information about the system and how to access the random device.
1910 ***
1911 *** Otherwise you can install either egd or prngd and set the environment
1912 *** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
1913 ***]])
1914 fi
1915  
1916 AC_MSG_CHECKING([if inter-process shared handles are requested])
1917 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
1918 AC_MSG_RESULT($try_shared_handles)
1919 if test "x$try_shared_handles" != "xyes"; then
1920         AC_DEFINE(DISABLE_SHARED_HANDLES, 1, [Disable inter-process shared handles])
1921         AC_SUBST(DISABLE_SHARED_HANDLES)
1922 fi
1923
1924 AC_ARG_ENABLE(nunit-tests, [  --enable-nunit-tests      Run the nunit tests of the class library on 'make check'])
1925 AM_CONDITIONAL(ENABLE_NUNIT_TESTS, [test x$enable_nunit_tests = xyes])
1926
1927 AC_MSG_CHECKING([if big-arrays are to be enabled])
1928 AC_ARG_ENABLE(big-arrays,  [  --enable-big-arrays       Enable the allocation and indexing of arrays greater than Int32.MaxValue], enable_big_arrays=$enableval, enable_big_arrays=no)
1929 if test "x$enable_big_arrays" = "xyes" ; then
1930     if  test "x$ac_cv_sizeof_void_p" = "x8"; then
1931         AC_DEFINE(MONO_BIG_ARRAYS,1,[Enable the allocation and indexing of arrays greater than Int32.MaxValue])
1932     else
1933         AC_MSG_ERROR([The allocation and indexing of arrays greater than Int32.MaxValue is not supported on this platform.])
1934     fi
1935 fi
1936 AC_MSG_RESULT($enable_big_arrays)
1937
1938 dnl **************
1939 dnl *** DTRACE ***
1940 dnl **************
1941
1942 AC_ARG_ENABLE(dtrace,[  --enable-dtrace Enable DTrace probes], enable_dtrace=$enableval, enable_dtrace=$has_dtrace)
1943
1944 if test "x$enable_dtrace" = "xyes"; then
1945    if test "x$has_dtrace" = "xno"; then
1946           AC_MSG_ERROR([DTrace probes are not supported on this platform.])
1947    fi
1948    AC_PATH_PROG(DTRACE, [dtrace], [no], [$PATH:/usr/sbin])
1949    if test "x$DTRACE" = "xno"; then
1950           AC_MSG_RESULT([dtrace utility not found, dtrace support disabled.])
1951           enable_dtrace=no
1952    elif ! $DTRACE -h -s $srcdir/data/mono.d > /dev/null 2>&1; then
1953           AC_MSG_RESULT([dtrace doesn't support -h option, dtrace support disabled.])
1954           enable_dtrace=no
1955    fi
1956 fi
1957
1958 dtrace_g=no
1959 if test "x$enable_dtrace" = "xyes"; then
1960         AC_DEFINE(ENABLE_DTRACE, 1, [Enable DTrace probes])
1961         DTRACEFLAGS=
1962         if test "x$ac_cv_sizeof_void_p" = "x8"; then
1963                 case "$host" in
1964                         powerpc-*-darwin*)
1965                         DTRACEFLAGS="-arch ppc64"
1966                         ;;
1967                         i*86-*-darwin*)
1968                         DTRACEFLAGS="-arch x86_64"
1969                         ;;
1970                         *)
1971                         DTRACEFLAGS=-64
1972                         ;;
1973                 esac
1974         else
1975                 case "$host" in
1976                         powerpc-*-darwin*)
1977                         DTRACEFLAGS="-arch ppc"
1978                         ;;
1979                         i*86-*-darwin*)
1980                         DTRACEFLAGS="-arch i386"
1981                         ;;
1982                         *)
1983                         DTRACEFLAGS=-32
1984                         ;;
1985                 esac
1986         fi
1987         AC_SUBST(DTRACEFLAGS)
1988         case "$host" in
1989                 *-*-solaris*)
1990                 dtrace_g=yes
1991                 ;;
1992         esac
1993         AC_CHECK_HEADERS([sys/sdt.h])
1994 fi
1995 AM_CONDITIONAL(ENABLE_DTRACE, [test x$enable_dtrace = xyes])
1996 AM_CONDITIONAL(DTRACE_G_REQUIRED, [test x$dtrace_g = xyes])
1997
1998 dnl **************
1999 dnl ***  LLVM  ***
2000 dnl **************
2001
2002 AC_ARG_ENABLE(llvm,[  --enable-llvm     Enable the experimental LLVM back-end], enable_llvm=$enableval, enable_llvm=no)
2003
2004 if test "x$enable_llvm" = "xyes"; then
2005    AC_PATH_PROG(LLVM_CONFIG, llvm-config, no)
2006    if test "x$LLVM_CONFIG" = "xno"; then
2007           AC_MSG_ERROR([llvm-config not found.])
2008    fi
2009
2010    # The output of --cflags seems to include optimizations flags too
2011    LLVM_CFLAGS=`$LLVM_CONFIG --cflags | sed -e 's/-O2//g' | sed -e 's/-O0//g' | sed -e 's/-fomit-frame-pointer//g' | sed -e 's/-fPIC//g'`
2012    # LLVM is compiled with -fno-rtti, so we need this too, since our classes inherit
2013    # from LLVM classes.
2014    LLVM_CXXFLAGS="`$LLVM_CONFIG --cxxflags` -fno-rtti"
2015    LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
2016    LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter jit x86codegen`
2017    LLVM_LIBS="$LLVM_LDFLAGS $LLVM_LIBS -lstdc++"
2018
2019    # Should be something like '2.6' or '2.7svn'
2020    llvm_version=`$LLVM_CONFIG --version`
2021    major_version=`echo $llvm_version | cut -c 1`
2022    minor_version=`echo $llvm_version | cut -c 3`
2023
2024    AC_DEFINE_UNQUOTED(LLVM_MAJOR_VERSION, $major_version, [Major version of LLVM libraries])
2025    AC_DEFINE_UNQUOTED(LLVM_MINOR_VERSION, $minor_version, [Minor version of LLVM libraries])
2026
2027    # Have to pass these on the command line since mini-llvm-cpp.h already includes
2028    # llvm's config.h
2029    LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DLLVM_MAJOR_VERSION=$major_version -DLLVM_MINOR_VERSION=$minor_version"
2030
2031    AC_SUBST(LLVM_CFLAGS)
2032    AC_SUBST(LLVM_CXXFLAGS)
2033    AC_SUBST(LLVM_LIBS)
2034    AC_SUBST(LLVM_LDFLAGS)
2035    AC_DEFINE(ENABLE_LLVM, 1, [Enable the LLVM back end])
2036 fi
2037
2038 AM_CONDITIONAL(ENABLE_LLVM, [test x$enable_llvm = xyes])
2039
2040 TARGET="unknown"
2041 ACCESS_UNALIGNED="yes"
2042
2043 JIT_SUPPORTED=no
2044 INTERP_SUPPORTED=no
2045 LIBC="libc.so.6"
2046 INTL="libc.so.6"
2047 SQLITE="libsqlite.so.0"
2048 SQLITE3="libsqlite3.so.0"
2049 X11="libX11.so"
2050
2051 sizeof_register="SIZEOF_VOID_P"
2052
2053 jit_wanted=false
2054 interp_wanted=false
2055 case "$host" in
2056 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
2057 #               TARGET=MIPS;
2058 #               ACCESS_UNALIGNED="no"
2059 #               ;;
2060         mips*)
2061                 TARGET=MIPS;
2062                 arch_target=mips;
2063                 ACCESS_UNALIGNED="no"
2064                 JIT_SUPPORTED=yes
2065                 jit_wanted=true
2066
2067                 AC_MSG_CHECKING(for mips n32)
2068                 AC_TRY_COMPILE([], [
2069                 void main () {
2070                 #if _MIPS_SIM != _ABIN32
2071                 #error Not mips n32
2072                 #endif
2073                 }
2074                 ],[
2075                 AC_MSG_RESULT(yes)
2076                 sizeof_register=8
2077                 ],[
2078                 AC_MSG_RESULT(no)
2079                 ])
2080                 ;;
2081         i*86-*-*)
2082                 TARGET=X86;
2083                 arch_target=x86;
2084                 JIT_SUPPORTED=yes
2085                 jit_wanted=true
2086                 case $host_os in
2087                   solaris*)
2088                         LIBC="libc.so"
2089                         INTL="libintl.so"
2090                         if test "x$ac_cv_sizeof_void_p" = "x8"; then
2091                                 TARGET=AMD64
2092                                 arch_target=amd64
2093                         fi
2094
2095                         # On solaris 10 x86, gcc prints a warning saying 'visibility attribute not supported on this configuration; ignored', but linking fails. A test case:
2096                         # int astruct __attribute__ ((visibility ("hidden")));
2097                         # void foo ()
2098                         # {
2099                         #       void *p = &astruct;
2100                         # }
2101                         # gcc -fPIC --shared -o libfoo.so foo.c
2102                         # yields:
2103                         # foo.c:6: warning: visibility attribute not supported in this configuration; ignored
2104                         # ld: fatal: relocation error: R_386_GOTOFF: file /var/tmp//ccxYR96k.o: symbol astruct: relocation must bind locally
2105                         have_visibility_hidden=no
2106                         ;;
2107                   cygwin*)
2108                         have_visibility_hidden=no                 
2109                         ;;
2110                   haiku*)
2111                         LIBC=libroot.so
2112                         ;;
2113                 esac
2114                 ;;
2115         x86_64-*-* | amd64-*-*)
2116                 TARGET=AMD64;
2117                 arch_target=amd64;
2118                 JIT_SUPPORTED=yes
2119                 jit_wanted=true
2120                 ;;
2121         ia64-*-*)
2122                 TARGET=IA64
2123                 arch_target=ia64
2124                 ACCESS_UNALIGNED="no"
2125                 JIT_SUPPORTED=yes
2126                 jit_wanted=true
2127                 LIBC="libc.so.6.1"
2128                 INTL="libc.so.6.1"
2129                 AC_CHECK_LIB(unwind, _U_dyn_register, [], [AC_MSG_ERROR(library libunwind not found)])
2130                 libmono_ldflags="-lunwind"
2131                 ;;
2132         sparc*-*-*)
2133                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
2134                    TARGET=SPARC64
2135                 else
2136                         TARGET=SPARC
2137                 fi
2138                 arch_target=sparc;
2139                 JIT_SUPPORTED=yes
2140                 ACCESS_UNALIGNED="no"
2141                 case $host_os in
2142                   linux*) ;;
2143                   *)
2144                         LIBC="libc.so"
2145                         INTL="libintl.so"
2146                 esac
2147                 jit_wanted=true
2148                 if test x"$GCC" = xyes; then
2149                         # We don't support v8 cpus
2150                         CFLAGS="$CFLAGS -Wno-cast-align -mcpu=v9"
2151                 fi
2152                 if test x"$AR" = xfalse; then
2153                         AC_MSG_ERROR([The required utility 'ar' is not found in your PATH. Usually it can be found in /usr/ccs/bin.])
2154                 fi
2155                 ;;
2156        alpha*-*-linux* | alpha*-*-osf*)
2157                 TARGET=ALPHA;
2158                 ACCESS_UNALIGNED="no"
2159                 JIT_SUPPORTED=yes
2160                 jit_wanted=true
2161                 arch_target=alpha;
2162                 CFLAGS="$CFLAGS -mieee -O0"
2163                 case $host_os in
2164                   linux*)
2165                         LIBC="libc.so.6.1"
2166                         INTL="libc.so.6.1"
2167                 esac
2168                ;;
2169         *-mingw*|*-*-cygwin*)
2170                 # When this is enabled, it leads to very strange crashes at runtime (gcc-3.4.4)
2171                 have_visibility_hidden=no
2172                 INTL="intl"
2173                 ;;
2174         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
2175                 TARGET=HPPA;
2176                 arch_target=hppa; 
2177                 LIBC="libc.sl"
2178                 ACCESS_UNALIGNED="no"
2179                 INTERP_SUPPORTED=yes
2180                 interp_wanted=true
2181                 ;;
2182         hppa*linux*)
2183                 TARGET=HPPA;
2184                 arch_target=hppa; 
2185                 ACCESS_UNALIGNED="no"
2186                 JIT_SUPPORTED=yes
2187                 jit_wanted=true
2188                 ;;
2189         macppc-*-openbsd* | powerpc*-*-linux* | powerpc-*-openbsd* | \
2190         powerpc-*-sysv* | powerpc-*-darwin* | powerpc-*-netbsd* | powerpc-*-freebsd* )
2191                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
2192                         TARGET=POWERPC64;
2193                         CPPFLAGS="$CPPFLAGS -D__mono_ppc__ -D__mono_ppc64__"
2194                         CFLAGS="$CFLAGS -mminimal-toc"
2195                 else
2196                         TARGET=POWERPC;
2197                         CPPFLAGS="$CPPFLAGS -D__mono_ppc__"
2198                 fi
2199                 arch_target=ppc;
2200                 JIT_SUPPORTED=yes
2201                 jit_wanted=true
2202                 ;;
2203         arm*-darwin*)
2204                 TARGET=ARM;
2205                 arch_target=arm;
2206                 ACCESS_UNALIGNED="no"
2207                 JIT_SUPPORTED=yes
2208                 CPPFLAGS="$CPPFLAGS -DARM_FPU_NONE=1"
2209                 jit_wanted=true
2210                 ;;
2211         arm*-linux*)
2212                 TARGET=ARM;
2213                 arch_target=arm;
2214                 ACCESS_UNALIGNED="no"
2215                 JIT_SUPPORTED=yes
2216                 jit_wanted=true
2217                 ;;
2218         s390-*-linux*)
2219                 TARGET=S390;
2220                 arch_target=s390;
2221                 ACCESS_UNALIGNED="yes"
2222                 JIT_SUPPORTED=yes
2223                 jit_wanted=true
2224                 # Required CFLAGS for s390[x].  USE_STRING_INLINES is automatic with gcc 4.1
2225                 CFLAGS="$CFLAGS -mbackchain -D__USE_STRING_INLINES"
2226                 ;;
2227         s390x-*-linux*)
2228                 TARGET=S390x;
2229                 arch_target=s390x;
2230                 ACCESS_UNALIGNED="yes"
2231                 JIT_SUPPORTED=yes
2232                 jit_wanted=true
2233                 CFLAGS="$CFLAGS -mbackchain -D__USE_STRING_INLINES"
2234                 ;;
2235 esac
2236
2237 if test "x$host" != "x$target"; then
2238    case "$target" in
2239    powerpc64-ps3-linux-gnu)
2240                 TARGET=POWERPC64
2241                 arch_target=powerpc64
2242                 AC_DEFINE(TARGET_PS3, 1, [...])
2243                 AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
2244                 # It would be better to just use TARGET_POWERPC64, but lots of code already
2245                 # uses this define
2246                 AC_DEFINE(__mono_ppc64__, 1, [...])
2247                 AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
2248                 sizeof_register=8
2249                 target_byte_order=G_BIG_ENDIAN
2250                 ;;
2251
2252    powerpc64-xbox360-linux-gnu)
2253                 TARGET=POWERPC64
2254                 arch_target=powerpc64
2255                 AC_DEFINE(TARGET_XBOX360, 1, [...])
2256                 AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
2257                 # It would be better to just use TARGET_POWERPC64, but lots of code already
2258                 # uses this define
2259                 sizeof_register=8
2260                 target_byte_order=G_BIG_ENDIAN
2261                 ;;
2262         *)
2263                 AC_MSG_WARN([Cross compiling is only supported for targets matching 'powerpc64-{ps3,xbox360}-linux-gnu'])
2264         esac
2265 fi
2266
2267 # FIXME: Define the others as well
2268 case "$TARGET" in
2269 X86)
2270         AC_DEFINE(TARGET_X86, 1, [...])
2271         ;;
2272 AMD64)
2273         AC_DEFINE(TARGET_AMD64, 1, [...])
2274         ;;
2275 ARM)
2276         AC_DEFINE(TARGET_ARM, 1, [...])
2277         ;;
2278 POWERPC)
2279         AC_DEFINE(TARGET_POWERPC, 1, [...])
2280         ;;
2281 POWERPC64)
2282         AC_DEFINE(TARGET_POWERPC, 1, [...])
2283         AC_DEFINE(TARGET_POWERPC64, 1, [...])
2284         ;;
2285 esac
2286
2287 if test "x$sizeof_register" = "x4"; then
2288    AC_DEFINE(SIZEOF_REGISTER,4,[size of machine integer registers])
2289 elif test "x$sizeof_register" = "x8"; then
2290    AC_DEFINE(SIZEOF_REGISTER,8,[size of machine integer registers])
2291 else
2292    AC_DEFINE(SIZEOF_REGISTER,SIZEOF_VOID_P,[size of machine integer registers])
2293 fi
2294
2295 if test "x$target_byte_order" = "xG_BIG_ENDIAN"; then
2296    AC_DEFINE(TARGET_BYTE_ORDER,G_BIG_ENDIAN,[byte order of target])
2297 elif test "x$target_byte_order" = "xG_LITTLE_ENDIAN"; then
2298    AC_DEFINE(TARGET_BYTE_ORDER,G_LITTLE_ENDIAN,[byte order of target])
2299 else
2300    AC_DEFINE(TARGET_BYTE_ORDER,G_BYTE_ORDER,[byte order of target])
2301 fi
2302
2303 if test "x$have_visibility_hidden" = "xyes"; then
2304    AC_DEFINE(HAVE_VISIBILITY_HIDDEN, 1, [Support for the visibility ("hidden") attribute])
2305 fi
2306
2307 if test "x$have_deprecated" = "xyes"; then
2308    AC_DEFINE(HAVE_DEPRECATED, 1, [Support for the deprecated attribute])
2309 fi
2310
2311 AC_ARG_WITH(jit, [  --with-jit=yes,no              If you want to build scripts that default to the JIT (defaults to no)],[
2312         if test x$withval = xyes; then
2313            jit_wanted=true
2314         else
2315            jit_wanted=false
2316         fi
2317 ])
2318
2319 AC_ARG_WITH(interp, [  --with-interp=yes,no           If you want to build scripts that default to the interpreter (defaults to no)],[
2320         if test x$withval = xyes; then
2321            interp_wanted=true
2322         else
2323            interp_wanted=false
2324         fi
2325 ])
2326
2327 USEJIT=false
2328 if test x$JIT_SUPPORTED = xyes; then
2329    if $jit_wanted; then
2330       USEJIT=true
2331       jit_status="Building and using the JIT"
2332    else
2333       if $interp_wanted; then
2334          jit_status="Building the JIT, defaulting to the interpreter"
2335       else
2336          AC_ERROR(No JIT or interpreter support available or selected.)
2337       fi
2338    fi
2339 else
2340    if test x$interp_wanted = xtrue; then
2341       jit_status="interpreter"
2342    else
2343       AC_ERROR(No JIT or interpreter support available or selected.)
2344    fi
2345 fi
2346
2347 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
2348
2349 libsuffix=".so"
2350
2351 case "$host" in
2352      *-*-darwin*)
2353         libsuffix=".dylib"
2354         LIBC="libc.dylib"
2355         INTL="libintl.dylib"
2356         SQLITE="libsqlite.0.dylib"
2357         SQLITE3="libsqlite3.0.dylib"
2358         X11="libX11.dylib"
2359         ;;
2360      *-*-*netbsd*)
2361         LIBC="libc.so.12"
2362         INTL="libintl.so.0"
2363         ;;
2364     *-*-*freebsd*)
2365         LIBC="libc.so"
2366         INTL="libintl.so"
2367         SQLITE="libsqlite.so"
2368         SQLITE3="libsqlite3.so"
2369         ;;
2370     *-*-*openbsd*)
2371         LIBC="libc.so"
2372         INTL="libintl.so"
2373         SQLITE="libsqlite.so"
2374         SQLITE3="libsqlite3.so"
2375         ;;
2376     *-*-*linux*)
2377         AC_PATH_X
2378         AC_MSG_CHECKING(for the soname of libX11.so)
2379         for i in $x_libraries /usr/lib /usr/lib64; do
2380                 for r in 4 5 6; do
2381                         if test -f $i/libX11.so.$r; then
2382                                 X11=libX11.so.$r
2383                                 AC_MSG_RESULT($X11)
2384                         fi
2385                 done
2386         done
2387         
2388         if test "x$X11" = "xlibX11.so"; then
2389                 AC_MSG_WARN([Could not find X development libs. Do you have the -devel package installed? WinForms may not work...]);
2390         fi
2391         ;;
2392 esac
2393
2394
2395 AC_SUBST(libsuffix)
2396
2397 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
2398         if test "x$with_tls" = "x__thread"; then
2399                 #
2400                 # On some linux distributions, TLS works in executables, but linking 
2401                 # against a shared library containing TLS fails with:
2402                 # undefined reference to `__tls_get_addr'
2403                 #
2404                 rm -f conftest.c conftest.so conftest
2405                 echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
2406                 $CC -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
2407                 $CC -o conftest conftest.so > /dev/null 2>&1
2408                 if test ! -f conftest; then
2409                    AC_MSG_WARN([Disabling usage of __thread.]);
2410                    with_tls=pthread
2411                 fi
2412                 rm -f conftest.c conftest.so conftest
2413         fi
2414 fi
2415
2416 mono_debugger_supported=no
2417 AC_ARG_ENABLE(mono-debugger, [  --disable-mono-debugger disable support for the mdb debugger], try_mono_debugger=$enableval, try_mono_debugger=yes)
2418 if test "x$try_mono_debugger" = "xyes"; then
2419         if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86" -o "x$TARGET" = "xALPHA"; then
2420                 if test x$use_included_gc = xyes; then
2421                         case "$host" in
2422                         *-*-*linux*)
2423                                 mono_debugger_supported=yes
2424                                 ;;
2425                         *86-apple-darwin*)
2426                                 mono_debugger_supported=yes
2427                                 ;;              
2428                         esac
2429                 fi
2430         fi
2431 fi
2432
2433 AC_MSG_CHECKING(if the Mono Debugger is supported on this platform)
2434 if test "x$mono_debugger_supported" = "xyes"; then
2435         AC_DEFINE(MONO_DEBUGGER_SUPPORTED,1,[The Mono Debugger is supported on this platform])
2436 fi
2437 AC_MSG_RESULT($mono_debugger_supported)
2438 AM_CONDITIONAL(MONO_DEBUGGER_SUPPORTED, test x$mono_debugger_supported = xyes)
2439
2440 if test "x$with_tls" = "x__thread"; then
2441         AC_DEFINE(HAVE_KW_THREAD, 1, [Have __thread keyword])
2442         # Pass the information to libgc
2443         CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
2444         AC_MSG_CHECKING(if the tls_model attribute is supported)
2445         AC_TRY_COMPILE([static __thread int foo __attribute__((tls_model("initial-exec")));], [
2446                 ], [
2447                         AC_MSG_RESULT(yes)
2448                         AC_DEFINE(HAVE_TLS_MODEL_ATTR, 1, [tld_model available])
2449                 ], [
2450                         AC_MSG_RESULT(no)
2451         ])
2452 fi
2453
2454 if test ${TARGET} = ARM && test x$cross_compiling = xno && test x$enable_mcs_build != xno; then
2455         dnl ******************************************
2456         dnl *** Check to see what FPU is available ***
2457         dnl ******************************************
2458         AC_MSG_CHECKING(which FPU to use)
2459
2460         AC_TRY_COMPILE([], [
2461                 __asm__ ("ldfd f0, [r0]");
2462                 ], fpu=FPA, fpu=NONE)
2463
2464         AC_MSG_RESULT($fpu)
2465         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu=1"
2466         unset fpu
2467 fi
2468
2469 if test ${TARGET} = unknown; then
2470         CPPFLAGS="$CPPFLAGS -DNO_PORT"
2471         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
2472 fi
2473
2474 if test ${ACCESS_UNALIGNED} = no; then
2475         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
2476 fi
2477
2478 case "x$gc" in
2479         xincluded)
2480                 # Pass CPPFLAGS to libgc configure
2481                 # We should use a separate variable for this to avoid passing useless and
2482                 # potentially problematic defines to libgc (like -D_FILE_OFFSET_BITS=64)
2483                 # This should be executed late so we pick up the final version of CPPFLAGS
2484                 # The problem with this approach, is that during a reconfigure, the main
2485                 # configure scripts gets invoked with these arguments, so we use separate
2486                 # variables understood by libgc's configure to pass CPPFLAGS and CFLAGS.
2487                 LIBGC_CPPFLAGS=$CPPFLAGS
2488                 if test x$TARGET = xSPARC -o x$TARGET = xSPARC64; then
2489                         LIBGC_CPPFLAGS=`echo $LIBGC_CPPFLAGS | sed -e 's/-D_FILE_OFFSET_BITS=64//g'`
2490                 fi
2491                 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads $libgc_configure_args \"CPPFLAGS_FOR_LIBGC=$LIBGC_CPPFLAGS\" \"CFLAGS_FOR_LIBGC=$CFLAGS_FOR_LIBGC\""
2492                 AC_CONFIG_SUBDIRS(libgc)
2493                 ;;
2494 esac
2495
2496 #AC_ARG_WITH(profile2,  [  --with-profile2=yes,no          If you want to install the 2.0 FX (defaults to yes)],                 [], [with_profile2=yes])
2497 AC_ARG_WITH(profile4,  [  --with-profile4=yes,no          If you want to install the 4.0 FX (defaults to yes)],                  [], [with_profile4=yes])
2498 AC_ARG_WITH(monotouch, [  --with-monotouch=yes,no         If you want to build the raw MonoTouch 2.1 assemblies (defaults to no)], [], [with_monotouch=no])
2499
2500 OPROFILE=no
2501 AC_ARG_WITH(oprofile,[  --with-oprofile=no,<oprofile install dir>   Enable oprofile support (defaults to no)],[
2502         if test x$with_oprofile != xno; then
2503             oprofile_include=$with_oprofile/include
2504             if test ! -f $oprofile_include/opagent.h; then
2505                   AC_MSG_ERROR([oprofile include file not found at $oprofile_include/opagent.h])
2506                 fi
2507             OPROFILE=yes
2508                 OPROFILE_CFLAGS="-I$oprofile_include"
2509             OPROFILE_LIBS="-L$with_oprofile/lib/oprofile -lopagent"
2510             AC_DEFINE(HAVE_OPROFILE,1,[Have oprofile support])
2511         fi
2512 ])
2513
2514 MALLOC_MEMPOOLS=no
2515 AC_ARG_WITH(malloc_mempools,[  --with-malloc-mempools=yes,no  Use malloc for each single mempool allocation (only for runtime debugging, defaults to no)],[
2516         if test x$with_malloc_mempools = xyes; then
2517                 MALLOC_MEMPOOLS=yes
2518                 AC_DEFINE(USE_MALLOC_FOR_MEMPOOLS,1,[Use malloc for each single mempool allocation])
2519         fi
2520 ])
2521
2522
2523 DISABLE_MCS_DOCS=no
2524 AC_ARG_WITH(mcs_docs,[  --with-mcs-docs=yes,no         If you want to build the documentation under mcs (defaults to yes)],[
2525         if test x$with_mcs_docs != xyes; then
2526                 DISABLE_MCS_DOCS=yes
2527         fi
2528 ])
2529
2530 AC_ARG_WITH(moonlight, [  --with-moonlight=yes|no|only         If you want to build Mono for Moonlight (defaults to no)],[
2531         if test "x$with_moonlight" = "xyes"; then
2532                 AC_DEFINE(MOONLIGHT,1,[Building for Moonlight])
2533         elif test "x$with_moonlight" = "xonly"; then
2534                 AC_DEFINE(MOONLIGHT,1,[Building for Moonlight])
2535         fi
2536 ], [with_moonlight=no])
2537
2538
2539
2540 AC_CHECK_HEADER([malloc.h], 
2541                 [AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1], 
2542                         [Define to 1 if you have /usr/include/malloc.h.])],,)
2543
2544 dnl
2545 dnl Consistency settings
2546 dnl
2547 if test x$cross_compiling = xyes -o x$enable_mcs_build = xno; then
2548    DISABLE_MCS_DOCS=yes
2549 fi
2550
2551 if test x$DISABLE_MCS_DOCS = xyes; then
2552    docs_dir=""
2553 else
2554    docs_dir=docs
2555 fi
2556 AC_SUBST(docs_dir)
2557
2558 AM_CONDITIONAL(HAVE_OPROFILE, test x$OPROFILE = xyes)
2559 AC_SUBST(OPROFILE_CFLAGS)
2560 AC_SUBST(OPROFILE_LIBS)
2561
2562 libmono_ldflags="$libmono_ldflags $LIBS"
2563
2564 AM_CONDITIONAL(MOONLIGHT, [test "x$with_moonlight" != "xno"])
2565 AM_CONDITIONAL(ONLY_MOONLIGHT, [test "x$with_moonlight" = "xonly"])
2566 AM_CONDITIONAL(INSTALL_4_0, [test "x$with_profile4" = xyes])
2567 AM_CONDITIONAL(INSTALL_MONOTOUCH, [test "x$with_monotouch" = xyes])
2568
2569 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
2570 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
2571 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
2572 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
2573 AM_CONDITIONAL(X86, test x$TARGET = xX86)
2574 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
2575 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
2576 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
2577 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
2578 AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
2579 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
2580 AM_CONDITIONAL(POWERPC64, test x$TARGET = xPOWERPC64)
2581 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
2582 AM_CONDITIONAL(S390, test x$TARGET = xS390)
2583 AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
2584 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
2585
2586 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
2587 AM_CONDITIONAL(INTERP_SUPPORTED, test x$interp_wanted = xtrue)
2588 AM_CONDITIONAL(INCLUDED_LIBGC, test x$gc = xincluded)
2589
2590 AC_SUBST(LIBC)
2591 AC_SUBST(INTL)
2592 AC_SUBST(SQLITE)
2593 AC_SUBST(SQLITE3)
2594 AC_SUBST(X11)
2595 AC_DEFINE_UNQUOTED(ARCHITECTURE,"$arch_target",[The architecture this is running on])
2596 AC_SUBST(arch_target)
2597 AC_SUBST(CFLAGS)
2598 AC_SUBST(CPPFLAGS)
2599 AC_SUBST(LDFLAGS)
2600
2601 mono_build_root=`pwd`
2602 AC_SUBST(mono_build_root)
2603
2604 if test x$USEJIT = xtrue; then
2605   mono_runtime=mono/mini/mono
2606 else
2607   mono_runtime=mono/interpreter/mint
2608 fi
2609 AC_SUBST(mono_runtime)
2610
2611 mono_cfg_root=$mono_build_root/runtime
2612 if test x$host_win32 = xyes; then
2613   if test "x$cross_compiling" = "xno"; then
2614     mono_cfg_dir=`cygpath -w -a $mono_cfg_root`\\etc
2615   else
2616     mono_cfg_dir=`echo $mono_cfg_root | tr '/' '\\'`\\etc
2617   fi
2618 else
2619   mono_cfg_dir=$mono_cfg_root/etc
2620 fi
2621 AC_SUBST(mono_cfg_dir)
2622
2623 AC_CONFIG_FILES([po/mcs/Makefile.in])
2624
2625 AC_CONFIG_FILES([runtime/mono-wrapper],[chmod +x runtime/mono-wrapper])
2626 AC_CONFIG_FILES([runtime/monodis-wrapper],[chmod +x runtime/monodis-wrapper])
2627
2628 AC_CONFIG_COMMANDS([runtime/etc/mono/1.0/machine.config],
2629 [   depth=../../../..
2630     case $srcdir in
2631     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2632     .) reldir=$depth ;;
2633     *) reldir=$depth/$srcdir ;;
2634     esac
2635     $ac_aux_dir/install-sh -d runtime/etc/mono/1.0
2636     cd runtime/etc/mono/1.0
2637     rm -f machine.config
2638     $LN_S $reldir/data/net_1_1/machine.config machine.config
2639     cd $depth
2640 ],[LN_S='$LN_S'])
2641
2642 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/machine.config],
2643 [   depth=../../../..
2644     case $srcdir in
2645     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2646     .) reldir=$depth ;;
2647     *) reldir=$depth/$srcdir ;;
2648     esac
2649     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
2650     cd runtime/etc/mono/2.0
2651     rm -f machine.config
2652     $LN_S $reldir/data/net_2_0/machine.config machine.config
2653     cd $depth
2654 ],[LN_S='$LN_S'])
2655
2656 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/web.config],
2657 [   depth=../../../..
2658     case $srcdir in
2659     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2660     .) reldir=$depth ;;
2661     *) reldir=$depth/$srcdir ;;
2662     esac
2663     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0
2664     cd runtime/etc/mono/2.0
2665     rm -f web.config
2666     $LN_S $reldir/data/net_2_0/web.config web.config
2667     cd $depth
2668 ],[LN_S='$LN_S'])
2669
2670 AC_CONFIG_COMMANDS([runtime/etc/mono/browscap.ini],
2671 [   depth=../../..
2672     case $srcdir in
2673     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2674     .) reldir=$depth ;;
2675     *) reldir=$depth/$srcdir ;;
2676     esac
2677     $ac_aux_dir/install-sh -d runtime/etc/mono/
2678     cd runtime/etc/mono/
2679     rm -f browscap.ini
2680     $LN_S $reldir/data/browscap.ini browscap.ini
2681     cd $depth
2682 ],[LN_S='$LN_S'])
2683
2684 AC_CONFIG_COMMANDS([runtime/etc/mono/2.0/Browsers/Compat.browser],
2685 [   depth=../../../../..
2686     case $srcdir in
2687     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2688     .) reldir=$depth ;;
2689     *) reldir=$depth/$srcdir ;;
2690     esac
2691     $ac_aux_dir/install-sh -d runtime/etc/mono/2.0/Browsers/
2692     cd runtime/etc/mono/2.0/Browsers
2693     rm -f Compat.browser
2694     $LN_S $reldir/data/net_2_0/Browsers/Compat.browser Compat.browser
2695     cd $depth
2696 ],[LN_S='$LN_S'])
2697
2698 AC_CONFIG_COMMANDS([runtime/etc/mono/4.0/machine.config],
2699 [   depth=../../../..
2700     case $srcdir in
2701     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2702     .) reldir=$depth ;;
2703     *) reldir=$depth/$srcdir ;;
2704     esac
2705     $ac_aux_dir/install-sh -d runtime/etc/mono/4.0
2706     cd runtime/etc/mono/4.0
2707     rm -f machine.config
2708     $LN_S $reldir/data/net_4_0/machine.config machine.config
2709     cd $depth
2710 ],[LN_S='$LN_S'])
2711
2712 AC_CONFIG_COMMANDS([runtime/etc/mono/4.0/web.config],
2713 [   depth=../../../..
2714     case $srcdir in
2715     [[\\/$]]* | ?:[[\\/]]* ) reldir=$srcdir ;;
2716     .) reldir=$depth ;;
2717     *) reldir=$depth/$srcdir ;;
2718     esac
2719     $ac_aux_dir/install-sh -d runtime/etc/mono/4.0
2720     cd runtime/etc/mono/4.0
2721     rm -f web.config
2722     $LN_S $reldir/data/net_4_0/web.config web.config
2723     cd $depth
2724 ],[LN_S='$LN_S'])
2725
2726 if test x$enable_quiet_build = xyes; then
2727    AC_CONFIG_COMMANDS([quiet], [for i in `find mono libgc support -name Makefile.in | sed -e 's/Makefile.in/Makefile/g'`; do if test -f $i; then $srcdir/scripts/patch-quiet.sh $i; fi; done], [shell=$SHELL])
2728    AC_CONFIG_COMMANDS([quiet-libtool], [sed -e 's/$echo "copying selected/$show "copying selected/g' < libtool > libtool.tmp && mv libtool.tmp libtool && chmod a+x libtool; sed -e 's/$ECHO "copying selected/# "copying selected/g' < libtool > libtool.tmp && mv libtool.tmp libtool && chmod a+x libtool])
2729 fi
2730
2731 AC_OUTPUT([
2732 Makefile
2733 mono-core.spec
2734 mono-uninstalled.pc
2735 scripts/mono-find-provides
2736 scripts/mono-find-requires
2737 mono/Makefile
2738 mono/utils/Makefile
2739 mono/metadata/Makefile
2740 mono/dis/Makefile
2741 mono/cil/Makefile
2742 mono/arch/Makefile
2743 mono/arch/x86/Makefile
2744 mono/arch/amd64/Makefile
2745 mono/arch/hppa/Makefile
2746 mono/arch/ppc/Makefile
2747 mono/arch/sparc/Makefile
2748 mono/arch/s390/Makefile
2749 mono/arch/s390x/Makefile
2750 mono/arch/arm/Makefile
2751 mono/arch/alpha/Makefile
2752 mono/arch/ia64/Makefile
2753 mono/arch/mips/Makefile
2754 mono/interpreter/Makefile
2755 mono/tests/Makefile
2756 mono/tests/tests-config
2757 mono/tests/assemblyresolve/Makefile
2758 mono/tests/cas/Makefile
2759 mono/tests/cas/assembly/Makefile
2760 mono/tests/cas/demand/Makefile
2761 mono/tests/cas/inheritance/Makefile
2762 mono/tests/cas/linkdemand/Makefile
2763 mono/tests/cas/threads/Makefile
2764 mono/benchmark/Makefile
2765 mono/monograph/Makefile
2766 mono/io-layer/Makefile
2767 mono/mini/Makefile
2768 mono/profiler/Makefile
2769 ikvm-native/Makefile
2770 scripts/Makefile
2771 man/Makefile
2772 web/Makefile
2773 docs/Makefile
2774 data/Makefile
2775 data/net_2_0/Makefile
2776 data/net_4_0/Makefile
2777 data/net_2_0/Browsers/Makefile
2778 data/mint.pc
2779 data/mono-2.pc
2780 data/mono.pc
2781 data/mono-cairo.pc
2782 data/mono-nunit.pc
2783 data/mono-options.pc
2784 data/mono-lineeditor.pc
2785 data/monodoc.pc
2786 data/mono.web.pc
2787 data/dotnet.pc
2788 data/dotnet35.pc
2789 data/wcf.pc
2790 data/cecil.pc
2791 data/system.web.extensions_1.0.pc
2792 data/system.web.extensions.design_1.0.pc
2793 data/system.web.mvc.pc
2794 data/system.web.mvc2.pc
2795 samples/Makefile
2796 support/Makefile
2797 data/config
2798 tools/Makefile
2799 tools/locale-builder/Makefile
2800 tools/sgen/Makefile
2801 runtime/Makefile
2802 msvc/Makefile
2803 po/Makefile
2804 ])
2805
2806 if test x$host_win32 = xyes; then
2807    # Get rid of 'cyg' prefixes in library names
2808    sed -e "s/\/cyg\//\/\//" libtool > libtool.new; mv libtool.new libtool; chmod 755 libtool
2809    # libtool seems to inherit -mno-cygwin from our CFLAGS, and uses it to compile its executable
2810    # wrapper scripts which use exec(). gcc has no problem compiling+linking this, but the resulting
2811    # executable doesn't work...
2812    sed -e "s,-mno-cygwin,,g" libtool > libtool.new; mv libtool.new libtool; chmod 755 libtool
2813 fi
2814
2815 (
2816   case $prefix in
2817   NONE) prefix=$ac_default_prefix ;;
2818   esac
2819   case $exec_prefix in
2820   NONE) exec_prefix='${prefix}' ;;
2821   esac
2822
2823   #
2824   # If we are cross compiling, we don't build in the mcs/ tree.  Let us not clobber
2825   # any existing config.make.  This allows people to share the same source tree
2826   # with different build directories, one native and one cross
2827   #
2828   if test x$cross_compiling = xno && test x$enable_mcs_build != xno; then
2829
2830     test -w $mcs_topdir/build || chmod +w $mcs_topdir/build
2831
2832     echo "prefix=$prefix" > $mcs_topdir/build/config.make
2833     echo "exec_prefix=$exec_prefix" >> $mcs_topdir/build/config.make
2834     echo "sysconfdir=$sysconfdir" >> $mcs_topdir/build/config.make
2835     echo 'mono_libdir=${exec_prefix}/lib' >> $mcs_topdir/build/config.make
2836     echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $mcs_topdir/build/config.make
2837     echo 'IL_FLAGS = /debug' >> $mcs_topdir/build/config.make
2838     echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $mcs_topdir/build/config.make
2839     echo "ILDISASM = $mono_build_root/runtime/monodis-wrapper" >> $mcs_topdir/build/config.make
2840
2841     case $INSTALL in
2842     [[\\/$]]* | ?:[[\\/]]* ) mcs_INSTALL=$INSTALL ;;
2843     *) mcs_INSTALL=$mono_build_root/$INSTALL ;;
2844     esac
2845
2846     echo "INSTALL = $mcs_INSTALL" >> $mcs_topdir/build/config.make
2847
2848     export VERSION
2849     [myver=$($AWK 'BEGIN {
2850       split (ENVIRON["VERSION"] ".0.0.0", vsplit, ".")
2851       if(length(vsplit [1]) > 4) {
2852         split (substr(ENVIRON["VERSION"], 0, 4) "." substr(ENVIRON["VERSION"], 5) ".0.0", vsplit, ".")
2853       }
2854       print vsplit [1] "." vsplit [2] "." vsplit [3] "." vsplit [4]
2855     }')]
2856
2857     echo "MONO_VERSION = $myver" >> $mcs_topdir/build/config.make
2858
2859     if test x$platform_darwin = xyes; then
2860       echo "PLATFORM = darwin" >> $mcs_topdir/build/config.make
2861     fi
2862
2863     if test x$TARGET = xAMD64 -a x$host_win32 = xno -a "x$AOT_SUPPORTED" = "xyes" -a x$enable_system_aot = xyes; then
2864       echo "ENABLE_AOT = 1" >> $mcs_topdir/build/config.make
2865     fi
2866
2867     if test x$DISABLE_MCS_DOCS = xyes; then
2868       echo "DISABLE_MCS_DOCS = yes" >> $mcs_topdir/build/config.make
2869     fi
2870
2871     if test x$with_moonlight != xno; then
2872       echo "MOONLIGHT = 1" >> $srcdir/$mcsdir/build/config.make
2873     fi
2874
2875   fi
2876
2877   # if we have an olive folder, override the default settings
2878   if test -d $olivedir; then
2879
2880     if test x$cross_compiling = xno && test x$enable_olive_build != xno; then
2881
2882       test -w $srcdir/$olivedir/build || chmod +w $srcdir/$olivedir/build
2883
2884       echo "prefix=$prefix" > $srcdir/$olivedir/build/config.make
2885       echo "exec_prefix=$exec_prefix" >> $srcdir/$olivedir/build/config.make
2886       echo 'mono_libdir=${exec_prefix}/lib' >> $srcdir/$olivedir/build/config.make
2887       echo 'MCS_FLAGS = $(PLATFORM_DEBUG_FLAGS)' >> $srcdir/$olivedir/build/config.make
2888       echo "RUNTIME = $mono_build_root/runtime/mono-wrapper" >> $srcdir/$olivedir/build/config.make
2889       echo "MONO_VERSION = $myver" >> $srcdir/$olivedir/build/config.make
2890     fi
2891   fi
2892
2893 )
2894
2895 libgdiplus_msg=${libgdiplus_loc:-assumed to be installed}
2896
2897 echo "
2898         mcs source:    $mcsdir
2899         olive source:  $olive_topdir
2900
2901    Engine:
2902         GC:            $gc
2903         GLIB:          $with_glib
2904         TLS:           $with_tls
2905         SIGALTSTACK:   $with_sigaltstack
2906         Engine:        $jit_status
2907         oprofile:      $OPROFILE
2908         BigArrays:     $enable_big_arrays
2909         DTrace:        $enable_dtrace
2910         Parallel Mark: $enable_parallel_mark
2911         LLVM Back End: $enable_llvm
2912
2913     Libraries:
2914         Moon Profile:  $with_moonlight
2915         MonoTouch:     $with_monotouch
2916         JNI support:   $jdk_headers_found
2917         libgdiplus:    $libgdiplus_msg
2918         zlib:          $zlib_msg
2919         $disabled
2920 "
2921 if test x$with_static_mono = xno -a "x$host_win32" != "xyes"; then
2922    AC_MSG_WARN(Turning off static Mono is a risk, you might run into unexpected bugs)
2923 fi
2924
2925 if test x$gc = xsgen; then
2926         echo IMPORTANT:
2927         echo IMPORTANT: You have selected an experimental, work-in-progress 
2928         echo IMPORTANT: GC engine.  This GC engine is currently not supported
2929         echo IMPORTANT: and is not yet ready for use.  
2930         echo IMPORTANT:
2931         echo IMPORTANT: There are known problems with it, use at your own risk.
2932 fi
2933
2934 if test x$enable_llvm = xyes; then
2935    echo IMPORTANT:
2936    echo IMPORTANT: The LLVM Back End is experimental and has known problems.
2937    echo IMPORTANT:
2938 fi