new test + update
[mono.git] / configure.in
1 AC_INIT(README)
2 AC_CANONICAL_SYSTEM
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(mono,1.1.1)
5 AM_MAINTAINER_MODE
6
7 AC_PROG_LN_S
8
9 dnl
10 dnl libgc checks
11 dnl
12
13 gc_headers=no
14 gc=included
15 use_included_gc=no
16
17 if test -d $srcdir/libgc ; then
18   gc_default=included
19 else
20   gc_default=boehm
21 fi
22
23 #
24 # These are the flags that need to be stored in the mono.pc file for 
25 # compiling code that will embed Mono
26 #
27 libmono_cflags=""
28 libmono_ldflags=""
29 AC_SUBST(libmono_cflags)
30 AC_SUBST(libmono_ldflags)
31
32 dnl if linker handles the version script
33 no_version_script=no
34
35 # Set to yes if Unix sockets cannot be created in an anonymous namespace
36 need_link_unlink=no
37
38 # Thread configuration inspired by sleepycat's db
39 AC_MSG_CHECKING([host platform characteristics])
40 libgc_threads=no
41 case "$host" in
42         *-*-mingw*|*-*-cygwin*)
43                 platform_win32=yes
44                 AC_DEFINE(PLATFORM_WIN32,1,[Platform is Win32])
45                 CC="gcc -mno-cygwin -g"
46                 HOST_CC="gcc"
47                 # So libgc configure gets -mno-cygwin
48                 export CC
49 # latest libgc already defines GC_WIN32_THREADS
50 #               CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS -DWIN32_THREADS"
51                 CPPFLAGS="$CPPFLAGS -DWIN32_THREADS"
52                 libdl=
53                 libgc_threads=win32
54                 gc_default=included
55                 with_nptl=default
56                 with_sigaltstack=no
57                 LN_S=cp
58
59                 ;;
60         *-*-*netbsd*)
61                 platform_win32=no
62                 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
63                 libmono_cflags="-D_REENTRANT"
64                 LDFLAGS="$LDFLAGS -pthread"
65                 libmono_ldflags="-pthread"
66                 need_link_unlink=yes
67                 libdl=
68                 libgc_threads=no
69                 ;;
70 # these flags will work for all versions of -STABLE
71 #
72         *-*-*freebsd4*)
73                 platform_win32=no
74                 if test "x$PTHREAD_CFLAGS" = "x"; then
75                         CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
76                         libmono_cflags="-D_THREAD_SAFE"
77                 else
78                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
79                         libmono_cflags="$PTHREAD_CFLAGS"
80                 fi
81                 if test "x$PTHREAD_LIBS" = "x"; then
82                         LDFLAGS="$LDFLAGS -pthread"
83                         libmono_ldflags="-pthread"
84                 else
85                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
86                         libmono_ldflags="$PTHREAD_LIBS"
87                 fi
88                 need_link_unlink=yes
89                 AC_DEFINE(PTHREAD_POINTER_ID)
90                 libdl=
91                 libgc_threads=pthreads
92 # TLS isn't implemented at all on -STABLE
93                 with_nptl=no
94                 with_tls=pthread
95                 ;;
96 # older versions of -CURRENT will break with these flags but testing
97 # indicates these older versions won't run Mono anyway
98 #
99         *-*-*freebsd5*)
100                 platform_win32=no
101                 if test "x$PTHREAD_CFLAGS" = "x"; then
102                         CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
103                         libmono_cflags=
104                 else
105                         CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
106                         libmono_cflags="$PTHREAD_CFLAGS"
107                 fi
108                 if test "x$PTHREAD_LIBS" = "x"; then
109                         LDFLAGS="$LDFLAGS -lpthread"
110                         libmono_ldflags="-lpthread"
111                 else
112                         LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
113                         libmono_ldflags="$PTHREAD_LIBS"
114                 fi
115                 need_link_unlink=yes
116                 AC_DEFINE(PTHREAD_POINTER_ID)
117                 libdl=
118                 libgc_threads=pthreads
119 # TLS is only partially implemented on -CURRENT (compiler support
120 # but NOT library support)
121 #
122                 with_nptl=no
123                 with_tls=pthread
124                 ;;
125         *-*-*openbsd*)
126                 platform_win32=no
127                 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
128                 libmono_cflags="-D_THREAD_SAFE"
129                 LDFLAGS="$LDFLAGS -pthread"
130                 libmono_ldflags="-pthread"
131                 need_link_unlink=yes
132                 AC_DEFINE(PTHREAD_POINTER_ID)
133                 libdl=
134                 libgc_threads=pthreads
135                 ;;
136         *-*-linux*)
137                 platform_win32=no
138                 CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT"
139                 libmono_cflags="-D_REENTRANT"
140                 libmono_ldflags="-lpthread"
141                 libdl="-ldl"
142                 libgc_threads=pthreads
143                 ;;
144         *-*-hpux*)
145                 platform_win32=no
146                 CPPFLAGS="$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
147                 CFLAGS="$CFLAGS +ESdbgasm"
148                 LDFLAGS="$LDFLAGS -z"
149                 libmono_cflags="-D_REENTRANT"
150                 libmono_ldflags="-lpthread"
151                 libgc_threads=pthreads
152                 need_link_unlink=yes
153                 ;;
154         *-*-solaris*)
155                 platform_win32=no
156                 CPPFLAGS="$CPPFLAGS -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT"
157                 need_link_unlink=yes
158                 libmono_cflags="-D_REENTRANT"
159                 libgc_threads=pthreads
160                 ;;
161         *-*-darwin*)
162                 platform_win32=no
163                 CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE -DGC_MACOSX_THREADS"
164                 libmono_cflags="-D_THREAD_SAFE"
165                 LDFLAGS="$LDFLAGS -pthread"
166                 libmono_ldflags="-pthread"
167                 need_link_unlink=yes
168                 AC_DEFINE(PTHREAD_POINTER_ID)
169                 AC_DEFINE(USE_MACH_SEMA)
170                 no_version_script=yes
171                 libdl=
172                 libgc_threads=pthreads
173                 ;;
174         *)
175                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
176                 platform_win32=no
177                 libdl="-ldl"
178                 ;;
179 esac
180 AC_MSG_RESULT(ok)
181
182 if test x$need_link_unlink = xyes; then
183    AC_DEFINE(NEED_LINK_UNLINK, 1, [Define if Unix sockets cannot be created in an anonymous namespace])
184 fi
185
186 AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
187
188 AC_CHECK_TOOL(CC, gcc, gcc)
189 AC_PROG_CC
190 AM_PROG_CC_STDC
191 AC_PROG_INSTALL
192 dnl We should use AM_PROG_AS, but it's not available on automake/aclocal 1.4
193 : ${CCAS='$(CC)'}
194 # Set ASFLAGS if not already set.
195 : ${CCASFLAGS='$(CFLAGS)'}
196 AC_SUBST(CCAS)
197 AC_SUBST(CCASFLAGS)
198
199 AC_CHECK_PROG(BISON, bison,yes,no)
200 if test "x$BISON" = "xno";
201 then
202         AC_MSG_ERROR([You need to install bison])
203 fi
204
205 dnl may require a specific autoconf version
206 dnl AC_PROG_CC_FOR_BUILD
207 dnl CC_FOR_BUILD not automatically detected
208 CC_FOR_BUILD=$CC
209 BUILD_EXEEXT=
210 if test "x$cross_compiling" = "xyes"; then
211         CC_FOR_BUILD=cc
212         BUILD_EXEEXT=""
213 fi
214 AC_SUBST(CC_FOR_BUILD)
215 AC_SUBST(HOST_CC)
216 AC_SUBST(BUILD_EXEEXT)
217
218 # Set STDC_HEADERS
219 AC_HEADER_STDC
220 AC_LIBTOOL_WIN32_DLL
221 AM_PROG_LIBTOOL
222
223 # Test whenever ld supports -version-script
224 AC_PROG_LD
225 AC_PROG_LD_GNU
226 if test "x$lt_cv_prog_gnu_ld" = "xno"; then
227    no_version_script=yes
228 fi
229
230 AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
231
232 AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h)
233
234 # for mono/metadata/debug-symfile.c
235 AC_CHECK_HEADERS(elf.h)
236
237 # for mono/dis
238 AC_CHECK_HEADERS(wchar.h)
239
240 # not 64 bit clean in cross-compile
241 AC_CHECK_SIZEOF(void *, 4)
242
243 WARN=''
244 if test x"$GCC" = xyes; then
245         WARN='-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings'
246                 # The runtime code does not respect ANSI C strict aliasing rules
247                 CFLAGS="$CFLAGS -fno-strict-aliasing"
248 else
249         # The Sun Forte compiler complains about inline functions that access static variables
250         # so disable all inlining.
251         case "$host" in
252         *-*-solaris*)
253                 CFLAGS="$CFLAGS -Dinline="
254                 ;;
255         esac
256 fi
257 CFLAGS="$CFLAGS -g $WARN"
258
259 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
260 if test "x$PKG_CONFIG" = "xno"; then
261         AC_MSG_ERROR([You need to install pkg-config])
262 fi
263
264 dnl for use on the build system
265 dnl pkg-config is stupid
266 BUILD_GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
267 BUILD_GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
268 AC_SUBST(BUILD_GLIB_CFLAGS)
269 AC_SUBST(BUILD_GLIB_LIBS)
270
271 PKG_PATH=
272 AC_ARG_WITH(crosspkgdir, [  --with-crosspkgdir=/path/to/pkg-config/dir],
273         if test x$with_crosspkgdir = "x"; then
274                 if test -s $PKG_CONFIG_PATH; then
275                         PKG_PATH=$PKG_CONFIG_PATH
276                 fi
277         else
278                 PKG_PATH=$with_crosspkgdir
279                 PKG_CONFIG_PATH=$PKG_PATH
280                 export PKG_CONFIG_PATH
281         fi
282 )
283
284 ## Versions of dependencies
285 GLIB_REQUIRED_VERSION=1.3.11
286
287 PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
288
289 GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0`
290 GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0 gthread-2.0`
291 GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
292 GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
293
294 AC_SUBST(GLIB_CFLAGS)
295 AC_SUBST(GLIB_LIBS)
296 AC_SUBST(GMODULE_CFLAGS)
297 AC_SUBST(GMODULE_LIBS)
298
299 AC_ARG_WITH(gc, [  --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default])
300
301 # Enable support for fast thread-local storage
302 # Some systems have broken support, so we allow to disable it.
303 AC_ARG_WITH(tls, [  --with-tls=__thread,pthread       select Thread Local Storage implementation],[],[with_tls=__thread])
304
305 # Kept for compatibility
306 AC_ARG_WITH(nptl, [  --with-nptl=yes,no      deprecated, use --with-tls instead],[],[with_nptl=default])
307
308 if test "x$with_nptl" != "xdefault"; then
309    if test "x$with_nptl" = "xyes"; then
310       AC_MSG_WARN([--with-nptl=yes is deprecated, use --with-tls=__thread option instead.])
311           with_tls=__thread
312    fi
313    if test "x$with_nptl" = "xno"; then
314       AC_MSG_WARN([--with-nptl=no is deprecated, use --with-tls=pthread option instead.])
315           with_tls=pthread
316    fi
317 fi
318
319 # Enable support for using sigaltstack for SIGSEGV and stack overflow handling
320 # This does not work on some platforms (bug #55253)
321 AC_ARG_WITH(sigaltstack, [  --with-sigaltstack=yes,no      enable/disable support for sigaltstack],[],[with_sigaltstack=no])
322
323 # assembly bundle support, see metadata/make-bundle.pl for more info
324 AC_ARG_WITH(bundle, [  --with-bundle=bundle_template],[
325         BUNDLE_FILE=$with_bundle
326         AC_SUBST(BUNDLE_FILE)
327         AC_DEFINE(WITH_BUNDLE)
328 ],[with_bundle=no])
329 AM_CONDITIONAL(WITH_BUNDLE, test x$with_bundle != xno)
330
331 LIBGC_CFLAGS=
332 LIBGC_LIBS=
333 LIBGC_STATIC_LIBS=
334 libgc_dir=
335 case "x$gc" in
336         xboehm|xbohem|xyes)
337                 AC_CHECK_HEADERS(gc.h gc/gc.h, gc_headers=yes)
338                 AC_CHECK_LIB(gc, GC_malloc, found_boehm="yes",,$libdl)
339
340                 if test "x$found_boehm" != "xyes"; then
341                         AC_MSG_ERROR("GC requested but libgc not found! Install libgc or run configure with --with-gc=none.")
342                 fi
343                 if test "x$gc_headers" != "xyes"; then
344                         AC_MSG_ERROR("GC requested but header files not found! You may need to install them by hand.")
345                 fi
346
347                 AC_DEFINE(HAVE_BOEHM_GC)
348                 AC_SUBST(HAVE_BOEHM_GC)
349                 LIBGC_LIBS="-lgc $libdl"
350                 LIBGC_STATIC_LIBS="$LIBGC_LIBS"
351
352                 # AC_CHECK_FUNCS does not work for some reason...
353                 AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
354                 if test "x$found_gcj_malloc" = "xyes"; then
355                         AC_DEFINE(HAVE_GC_GCJ_MALLOC)
356                 fi
357                 AC_CHECK_LIB(gc, GC_enable, found_gc_enable="yes",,$libdl)
358                 if test "x$found_gc_enable" = "xyes"; then
359                         AC_DEFINE(HAVE_GC_ENABLE)
360                 fi
361                 ;;
362
363         xincluded)
364                 AC_CONFIG_SUBDIRS(libgc)
365
366                 found_boehm=yes
367                 gc_headers=yes
368                 use_included_gc=yes
369                 libgc_dir=libgc
370
371                 LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
372                 LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
373                 LIBGC_STATIC_LIBS='$(top_builddir)/libgc/libmonogc-static.la'
374
375                 AC_DEFINE(HAVE_BOEHM_GC)
376                 AC_SUBST(HAVE_BOEHM_GC)
377
378                 AC_DEFINE(HAVE_GC_H)
379                 AC_DEFINE(USE_INCLUDED_LIBGC)
380
381                 # The included libgc contains GCJ support
382                 AC_DEFINE(HAVE_GC_GCJ_MALLOC)
383                 AC_DEFINE(HAVE_GC_ENABLE)
384                 ;;
385
386         xnone)
387                 AC_MSG_WARN("Compiling mono without GC.")
388                 ;;
389         *)
390                 AC_MSG_ERROR([Invalid argument to --with-gc.])
391                 ;;
392 esac
393
394
395 # tell libgc/configure about what we want
396 ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads"
397
398 AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
399 AC_SUBST(LIBGC_CFLAGS)
400 AC_SUBST(LIBGC_LIBS)
401 AC_SUBST(LIBGC_STATIC_LIBS)
402 AC_SUBST(libgc_dir)
403
404 dnl
405 dnl End of libgc checks
406 dnl
407
408 if test x$platform_win32 = xno; then
409
410         dnl ******************************************************************
411         dnl *** Checks for the IKVM JNI interface library                  ***
412         dnl ******************************************************************
413         AC_ARG_WITH(ikvm-jni, [  --with-ikvm-jni=yes,no  build the IKVM JNI interface library],[with_ikvm_jni=$withval],[with_ikvm_jni=yes])
414         AC_ARG_WITH(jdk, [  --with-jdk=DIRECTORY    Use JDK from DIRECTORY],[with_jdk_dir=$withval],[with_jdk_dir=])
415
416         ikvm_jni_dir=
417         if test x$with_ikvm_jni = xyes; then
418                 AC_MSG_CHECKING([JDK headers])
419
420                 if test x$with_jdk_dir = x; then
421                         # Try JAVA_HOME variable
422                         if test x$JAVA_HOME != x; then
423                                 with_jdk_dir=$JAVA_HOME
424                         fi
425                 fi
426         
427                 jdk_platform=
428                 if test -d $with_jdk_dir/include; then
429                         jdk_headers_found=yes
430
431                         if test -d $with_jdk_dir/include/linux; then
432                                 jdk_platform=linux
433                         else
434                         if test -d $with_jdk_dir/include/solaris; then
435                                 jdk_platform=solaris
436                         else
437                         if test -f $with_jdk_dir/include/jni_md.h; then
438                                 # GNU Classpath sources
439                                 jdk_platform=
440                         else
441                                 jdk_headers_found=no
442                         fi
443                         fi
444                         fi
445                 else
446                         jdk_headers_found=no
447                 fi
448
449                 if test x$jdk_headers_found = xyes; then
450                         AC_MSG_RESULT($with_jdk_dir/include $with_jdk_dir/include/$jdk_platform)
451                 else
452                         AC_MSG_RESULT(not found)
453                 fi
454
455                 if test x$jdk_headers_found = xyes; then
456                         ikvm_jni_dir=ikvm-jni
457                         IKVM_JNI_CFLAGS="-I$with_jdk_dir/include -I$with_jdk_dir/include/$jdk_platform"
458                 fi
459         fi
460
461         AC_SUBST(ikvm_jni_dir)
462         AC_SUBST(IKVM_JNI_CFLAGS)
463
464         AC_CHECK_FUNCS(getgrgid_r)
465         AC_CHECK_FUNCS(getgrnam_r)
466         AC_CHECK_FUNCS(getpwnam_r)
467         AC_CHECK_FUNCS(getpwuid_r)
468         AC_CHECK_FUNCS(getresuid)
469         AC_CHECK_FUNCS(setresuid)
470         AC_CHECK_FUNCS(kqueue)
471
472         dnl ******************************************************************
473         dnl *** Check for large file support                               ***
474         dnl *** (If we were using autoconf 2.50 we'd use AC_SYS_LARGEFILE) ***
475         dnl ******************************************************************
476         
477         # Check that off_t can represent 2**63 - 1 correctly, working around
478         # potential compiler bugs.  Defines LARGE_FILE_SUPPORT, adds $1 to
479         # CPPFLAGS and sets $large_offt to yes if the test succeeds
480         large_offt=no
481         AC_DEFUN(LARGE_FILES, [
482                 large_CPPFLAGS=$CPPFLAGS
483                 CPPFLAGS="$CPPFLAGS $1"
484                 AC_TRY_RUN([
485                         #include <sys/types.h>
486
487                         #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
488
489                         int main(void) {
490                                 int big_off_t=((BIG_OFF_T%2147483629==721) &&
491                                                (BIG_OFF_T%2147483647==1));
492                                 if(big_off_t) {
493                                         exit(0);
494                                 } else {
495                                         exit(1);
496                                 }
497                         }
498                 ], [
499                         AC_MSG_RESULT(ok)
500                         AC_DEFINE(HAVE_LARGE_FILE_SUPPORT)
501                         large_CPPFLAGS="$large_CPPFLAGS $1"
502                         large_offt=yes
503                 ], [
504                         AC_MSG_RESULT(no)
505                 ], "")
506                 CPPFLAGS=$large_CPPFLAGS
507         ])
508
509         AC_MSG_CHECKING(if off_t is 64 bits wide)
510         LARGE_FILES("")
511         if test $large_offt = no; then
512                 AC_MSG_CHECKING(if _FILE_OFFSET_BITS=64 gives 64 bit off_t)
513                 LARGE_FILES("-D_FILE_OFFSET_BITS=64")
514         fi
515         if test $large_offt = no; then
516                 AC_MSG_WARN([No 64 bit file size support available])
517         fi
518         
519         dnl *****************************
520         dnl *** Checks for libsocket  ***
521         dnl *****************************
522         AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
523
524         dnl *******************************
525         dnl *** Checks for MSG_NOSIGNAL ***
526         dnl *******************************
527         AC_MSG_CHECKING(for MSG_NOSIGNAL)
528         AC_TRY_COMPILE([#include <sys/socket.h>], [
529                 int f = MSG_NOSIGNAL;
530         ], [
531                 # Yes, we have it...
532                 AC_MSG_RESULT(yes)
533                 AC_DEFINE(HAVE_MSG_NOSIGNAL)
534         ], [
535                 # We'll have to use signals
536                 AC_MSG_RESULT(no)
537         ])
538
539         dnl *****************************
540         dnl *** Checks for SOL_IP     ***
541         dnl *****************************
542         AC_MSG_CHECKING(for SOL_IP)
543         AC_TRY_COMPILE([#include <netdb.h>], [
544                 int level = SOL_IP;
545         ], [
546                 # Yes, we have it...
547                 AC_MSG_RESULT(yes)
548                 AC_DEFINE(HAVE_SOL_IP)
549         ], [
550                 # We'll have to use getprotobyname
551                 AC_MSG_RESULT(no)
552         ])
553
554         dnl *****************************
555         dnl *** Checks for SOL_IPV6     ***
556         dnl *****************************
557         AC_MSG_CHECKING(for SOL_IPV6)
558         AC_TRY_COMPILE([#include <netdb.h>], [
559                 int level = SOL_IPV6;
560         ], [
561                 # Yes, we have it...
562                 AC_MSG_RESULT(yes)
563                 AC_DEFINE(HAVE_SOL_IPV6)
564         ], [
565                 # We'll have to use getprotobyname
566                 AC_MSG_RESULT(no)
567         ])
568
569         dnl *****************************
570         dnl *** Checks for SOL_TCP    ***
571         dnl *****************************
572         AC_MSG_CHECKING(for SOL_TCP)
573         AC_TRY_COMPILE([#include <netdb.h>], [
574                 int level = SOL_TCP;
575         ], [
576                 # Yes, we have it...
577                 AC_MSG_RESULT(yes)
578                 AC_DEFINE(HAVE_SOL_TCP)
579         ], [
580                 # We'll have to use getprotobyname
581                 AC_MSG_RESULT(no)
582         ])
583
584         dnl *****************************
585         dnl *** Checks for IP_PKTINFO ***
586         dnl *****************************
587         AC_MSG_CHECKING(for IP_PKTINFO)
588         AC_TRY_COMPILE([#include <netdb.h>], [
589                 int level = IP_PKTINFO;
590         ], [
591                 # Yes, we have it...
592                 AC_MSG_RESULT(yes)
593                 AC_DEFINE(HAVE_IP_PKTINFO)
594         ], [
595                 AC_MSG_RESULT(no)
596         ])
597
598         dnl *********************************
599         dnl *** Check for struct ip_mreqn ***
600         dnl *********************************
601         AC_MSG_CHECKING(for struct ip_mreqn)
602         AC_TRY_COMPILE([#include <netinet/in.h>], [
603                 struct ip_mreqn mreq;
604                 mreq.imr_address.s_addr = 0;
605         ], [
606                 # Yes, we have it...
607                 AC_MSG_RESULT(yes)
608                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
609         ], [
610                 # We'll just have to try and use struct ip_mreq
611                 AC_MSG_RESULT(no)
612                 AC_MSG_CHECKING(for struct ip_mreq)
613                 AC_TRY_COMPILE([#include <netinet/in.h>], [
614                         struct ip_mreq mreq;
615                         mreq.imr_interface.s_addr = 0;
616                 ], [
617                         # Yes, we have it...
618                         AC_MSG_RESULT(yes)
619                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
620                 ], [
621                         # No multicast support
622                         AC_MSG_RESULT(no)
623                 ])
624         ])
625         
626         dnl **********************************
627         dnl *** Check for gethostbyname2_r ***
628         dnl **********************************
629         AC_MSG_CHECKING(for gethostbyname2_r)
630                 AC_TRY_LINK([#include <netdb.h>], [
631                 gethostbyname2_r(NULL,0,NULL,NULL,0,NULL,NULL);
632         ], [
633                 # Yes, we have it...
634                 AC_MSG_RESULT(yes)
635                 AC_DEFINE(HAVE_GETHOSTBYNAME2_R)
636         ], [
637                 AC_MSG_RESULT(no)
638         ])
639
640         dnl *****************************
641         dnl *** Checks for libnsl     ***
642         dnl *****************************
643         AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="$LIBS -lnsl")
644
645         AC_CHECK_FUNCS(inet_pton inet_aton)
646
647         dnl ***********************************************
648         dnl *** Checks for size of sockaddr_un.sun_path ***
649         dnl ***********************************************
650         # AC_CHECK_SIZEOF can't cope with struct members :-(
651         AC_MSG_CHECKING(size of sockaddr_un.sun_path)
652         AC_CACHE_VAL(cv_mono_sizeof_sunpath,
653                 [AC_TRY_RUN([
654                         #include <sys/types.h>
655                         #include <stdio.h>
656                         #include <sys/un.h>
657
658                         int main(void) {
659                                 struct sockaddr_un sock_un;
660                                 FILE *f=fopen("conftestval", "w");
661                                 if(!f) exit(1);
662                                 fprintf(f, "%d\n", sizeof(sock_un.sun_path));
663                                 exit(0);
664                         }
665                 ], cv_mono_sizeof_sunpath=`cat conftestval`,
666                    cv_mono_sizeof_sunpath=0,
667                    cv_mono_sizeof_sunpath=0)])dnl
668         AC_MSG_RESULT($cv_mono_sizeof_sunpath)
669         AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
670
671         dnl *************************************
672         dnl *** Checks for zero length arrays ***
673         dnl *************************************
674         AC_MSG_CHECKING(whether $CC supports zero length arrays)
675         AC_TRY_COMPILE([
676                 struct s {
677                         int  length;
678                         char data [0];
679                 };
680         ], [], [
681                 AC_MSG_RESULT(yes)
682                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 0)
683         ], [
684                 AC_MSG_RESULT(no)
685                 AC_DEFINE_UNQUOTED(MONO_ZERO_ARRAY_LENGTH, 1)
686         ])
687
688         dnl *****************************
689         dnl *** Checks for libxnet    ***
690         dnl *****************************
691         case "${host}" in
692                 *solaris* )
693                         AC_MSG_CHECKING(for Solaris XPG4 support)
694                         if test -f /usr/lib/libxnet.so; then
695                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
696                                 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
697                                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
698                                 LIBS="$LIBS -lxnet"
699                                 AC_MSG_RESULT(yes)
700                         else
701                                 AC_MSG_RESULT(no)
702                         fi
703
704                         if test "$GCC" = "yes"; then
705                                 CFLAGS="$CFLAGS -Wno-char-subscripts"
706                         fi
707                 ;;
708         esac
709
710         dnl *****************************
711         dnl *** Checks for libpthread ***
712         dnl *****************************
713 # on FreeBSD -STABLE, the pthreads functions all reside in libc_r
714 # and libpthread does not exist
715 #
716         case "${host}" in
717                 *-*-*freebsd4*)
718                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
719                 ;;
720                 *)
721                         AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
722                 ;;
723         esac
724         AC_CHECK_HEADERS(pthread.h)
725         AC_CHECK_FUNCS(pthread_mutex_timedlock)
726         AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
727         AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
728         AC_TRY_COMPILE([ #include <pthread.h>], [
729                 pthread_mutexattr_t attr;
730                 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
731         ], [
732                 AC_MSG_RESULT(ok)
733         ], [
734                 AC_MSG_RESULT(no)
735                 AC_MSG_WARN(Using mono_mutex_t for recursive mutexes)
736                 AC_DEFINE(USE_MONO_MUTEX)
737         ])
738         AC_CHECK_FUNCS(pthread_attr_setstacksize)
739
740         dnl ***********************************
741         dnl *** Checks for working __thread ***
742         dnl ***********************************
743         AC_MSG_CHECKING(for working __thread)
744         if test "x$with_tls" != "x__thread"; then
745                 AC_MSG_RESULT(disabled)
746         else
747                 AC_TRY_RUN([
748                         #include <pthread.h>
749
750                         __thread int i;
751                         static int res1, res2;
752
753                         void thread_main (void *arg)
754                         {
755                                 i = arg;
756                                 sleep (1);
757                                 if (arg == 1)
758                                         res1 = (i == arg);
759                                 else
760                                         res2 = (i == arg);
761                         }
762
763                         int main () {
764                                 pthread_t t1, t2;
765
766                                 i = 5;
767
768                                 pthread_create (&t1, NULL, thread_main, 1);
769                                 pthread_create (&t2, NULL, thread_main, 2);
770
771                                 pthread_join (t1, NULL);
772                                 pthread_join (t2, NULL);
773
774                                 return !(res1 + res2 == 2);
775                         }
776                 ], [
777                                 AC_MSG_RESULT(yes)
778                 ], [
779                                 AC_MSG_RESULT(no)
780                                 with_tls=pthread
781                 ])
782         fi
783
784         dnl **************************************
785         dnl *** Checks for working sigaltstack ***
786         dnl **************************************
787         AC_MSG_CHECKING(for working sigaltstack)
788         if test "x$with_sigaltstack" != "xyes"; then
789                 AC_MSG_RESULT(disabled)
790         else
791                 AC_TRY_RUN([
792                         #include <stdio.h>
793                         #include <stdlib.h>
794                         #include <unistd.h>
795                         #include <signal.h>
796                         #include <pthread.h>
797                         #include <sys/wait.h>
798
799                         static void
800                         sigsegv_signal_handler (int _dummy, siginfo_t *info, void *context)
801                         {
802                                 exit (0);
803                         }
804
805                         static void *
806                         loop (void *ignored)
807                         {
808                                 char *ptr = NULL;
809
810                                 *ptr = 0;
811                                 return NULL;
812                         }
813
814                         static void
815                         child ()
816                         {
817                                 struct sigaction sa;
818                                 struct sigaltstack sas;
819                                 pthread_t id;
820                                 pthread_attr_t attr;
821
822                                 sa.sa_sigaction = sigsegv_signal_handler;
823                                 sigemptyset (&sa.sa_mask);
824                                 sa.sa_flags = SA_SIGINFO | SA_STACK;
825                                 if (sigaction (SIGSEGV, &sa, NULL) == -1) {
826                                         perror ("lala");
827                                         return;
828                                 }
829
830                                 sas.ss_sp = malloc (SIGSTKSZ);
831                                 sas.ss_size = SIGSTKSZ;
832                                 sas.ss_flags = SS_ONSTACK;
833                                 if (sigaltstack (&sas, NULL) == -1) {
834                                         perror ("lala");
835                                         return;
836                                 }
837
838                                 pthread_attr_init (&attr);
839                                 if (pthread_create(&id, &attr, loop, &attr) != 0) {
840                                         printf ("failed\n");
841                                         return;
842                                 }
843
844                                 sleep (100);
845                         }
846
847                         int
848                         main ()
849                         {
850                                 pid_t son;
851                                 int status;
852                                 int i;
853
854                                 son = fork ();
855                                 if (son == -1) {
856                                         return 1;
857                                 }
858
859                                 if (son == 0) {
860                                         child ();
861                                         return 0;
862                                 }
863
864                                 for (i = 0; i < 3; ++i) {
865                                         sleep (1);
866                                         waitpid (son, &status, WNOHANG);
867                                         if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
868                                                 return 0;
869                                 }
870
871                                 kill (son, SIGKILL);
872                                 return 1;
873                         }
874
875                 ], [
876                                 AC_MSG_RESULT(yes)
877                                 AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
878                 ], [
879                                 with_sigaltstack=no
880                                 AC_MSG_RESULT(no)
881                 ])
882         fi
883
884         dnl ********************************
885         dnl *** Checks for semaphore lib ***
886         dnl ********************************
887         # 'Real Time' functions on Solaris
888         # posix4 on Solaris 2.6
889         # pthread (first!) on Linux
890         AC_SEARCH_LIBS(sem_init, pthread rt posix4) 
891
892         dnl ********************************
893         dnl *** Checks for timezone stuff **
894         dnl ********************************
895         AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
896                 AC_TRY_COMPILE([
897                         #include <time.h>
898                         ], [
899                         struct tm tm;
900                         tm.tm_gmtoff = 1;
901                         ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
902         if test $ac_cv_struct_tm_gmtoff = yes; then
903                 AC_DEFINE(HAVE_TM_GMTOFF)
904         else
905                 AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
906                         AC_TRY_COMPILE([
907                                 #include <time.h>
908                         ], [
909                                 timezone = 1;
910                         ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
911                 if test $ac_cv_var_timezone = yes; then
912                         AC_DEFINE(HAVE_TIMEZONE)
913                 else
914                         AC_ERROR(unable to find a way to determine timezone)
915                 fi
916         fi
917
918         dnl *********************************
919         dnl *** Checks for math functions ***
920         dnl *********************************
921         LIBS="$LIBS -lm";
922         AC_CHECK_FUNCS(finite, , AC_MSG_CHECKING(for finite in math.h)
923                 AC_TRY_LINK([#include <math.h>], 
924                 [ finite(0.0); ], 
925                 AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
926                 AC_MSG_RESULT(no)))
927         AC_CHECK_FUNCS(isfinite, , AC_MSG_CHECKING(for isfinite in math.h)
928                 AC_TRY_LINK([#include <math.h>], 
929                 [ isfinite(0.0); ], 
930                 AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
931                 AC_MSG_RESULT(no)))
932
933         dnl ****************************************************************
934         dnl *** Checks for working poll() (macosx defines it but doesn't ***
935         dnl *** have it in the library (duh))                            ***
936         dnl ****************************************************************
937         AC_CHECK_FUNCS(poll)
938
939         dnl *************************
940         dnl *** Check for signbit ***
941         dnl *************************
942         AC_MSG_CHECKING(for signbit)
943         AC_TRY_LINK([#include <math.h>], [
944                 int s = signbit(1.0);
945         ], [
946                 AC_MSG_RESULT(yes)
947                 AC_DEFINE(HAVE_SIGNBIT)
948         ], [
949                 AC_MSG_RESULT(no)
950         ]) 
951
952         dnl *********************
953         dnl *** Check for AIO ***
954         dnl *********************
955         AC_MSG_CHECKING([for SIGEV_THREAD definition])
956         dnl Some systems (FreeBSD at least) may have aio_read
957         dnl but don't support/define SIGEV_THREAD.
958         AC_TRY_COMPILE([
959         #include <sys/signal.h>
960         ],[
961         int x = SIGEV_THREAD;
962         ],[
963                 ac_cv_c_sigev_thread=yes
964                 AC_MSG_RESULT(yes)
965         ],[
966                 AC_MSG_RESULT(no)
967         ])
968
969         if test "$ac_cv_c_sigev_thread" = "yes" ; then
970                 AC_CHECK_HEADERS(aio.h sys/aio.h)
971                 AC_CHECK_LIB(rt, aio_read, [ LIBS="$LIBS -lrt" ],)
972                 SIGVAL_PTR="undefined"
973                 if test "$ac_cv_header_aio_h" = "yes" -o "$ac_cv_header_sys_aio_h" = "yes" ; then
974                         AC_CHECK_MEMBER(union sigval.sigval_ptr,SIGVAL_PTR="sigval_ptr",, [
975                                         #include <sys/signal.h>
976                                         ])
977                         AC_CHECK_MEMBER(union sigval.sival_ptr,SIGVAL_PTR="sival_ptr",, [
978                                         #include <sys/signal.h>
979                                         ])
980                         if test "$SIGVAL_PTR" = "undefined" ; then
981                                 AC_MSG_ERROR([Unable to detect field name in 'union sigval'])
982                         fi
983                 fi
984                 AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
985         fi
986 else
987         jdk_headers_found=no
988         AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
989         AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
990
991         dnl *********************************
992         dnl *** Check for struct ip_mreqn ***
993         dnl *********************************
994         AC_MSG_CHECKING(for struct ip_mreqn)
995         AC_TRY_COMPILE([#include <ws2tcpip.h>], [
996                 struct ip_mreqn mreq;
997                 mreq.imr_address.s_addr = 0;
998         ], [
999                 # Yes, we have it...
1000                 AC_MSG_RESULT(yes)
1001                 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
1002         ], [
1003                 # We'll just have to try and use struct ip_mreq
1004                 AC_MSG_RESULT(no)
1005                 AC_MSG_CHECKING(for struct ip_mreq)
1006                 AC_TRY_COMPILE([#include <ws2tcpip.h>], [
1007                         struct ip_mreq mreq;
1008                         mreq.imr_interface.s_addr = 0;
1009                 ], [
1010                         # Yes, we have it...
1011                         AC_MSG_RESULT(yes)
1012                         AC_DEFINE(HAVE_STRUCT_IP_MREQ)
1013                 ], [
1014                         # No multicast support
1015                         AC_MSG_RESULT(no)
1016                 ])
1017         ])
1018 fi
1019
1020 dnl socklen_t check
1021 AC_MSG_CHECKING(for socklen_t)
1022 AC_TRY_COMPILE([
1023 #include <sys/types.h>
1024 #include <sys/socket.h>
1025 ],[
1026   socklen_t foo;
1027 ],[
1028 ac_cv_c_socklen_t=yes
1029         AC_DEFINE(HAVE_SOCKLEN_T)
1030         AC_MSG_RESULT(yes)
1031 ],[
1032         AC_MSG_RESULT(no)
1033 ])
1034
1035 AC_MSG_CHECKING(for array element initalizer support)
1036 AC_TRY_COMPILE([#include <sys/socket.h>], [
1037         const int array[] = {[1] = 2,};
1038 ], [
1039         # Yes, we have it...
1040         AC_MSG_RESULT(yes)
1041         AC_DEFINE(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
1042 ], [
1043         # We'll have to use signals
1044         AC_MSG_RESULT(no)
1045 ])
1046
1047 AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
1048         # Simply calling trunc (0.0) is no good since gcc will optimize the call away
1049         AC_TRY_LINK([#include <math.h>], 
1050         [ static void *p = &trunc; ],
1051         [
1052                 AC_DEFINE(HAVE_TRUNC) 
1053                 AC_MSG_RESULT(yes)
1054                 ac_cv_trunc=yes
1055         ],
1056         AC_MSG_RESULT(no)))
1057
1058 if test "x$ac_cv_truncl" != "xyes"; then
1059    AC_CHECK_LIB(sunmath, aintl, [ AC_DEFINE(HAVE_AINTL) LIBS="$LIBS -lsunmath"])
1060 fi
1061
1062 dnl ****************************
1063 dnl *** Look for /dev/random ***
1064 dnl ****************************
1065
1066 AC_MSG_CHECKING([if usage of random device is requested])
1067 AC_ARG_ENABLE(dev-random,
1068 [  --disable-dev-random    disable the use of the random device],
1069 try_dev_random=$enableval, try_dev_random=yes)
1070 AC_MSG_RESULT($try_dev_random)
1071
1072 case "{$target}" in
1073     *-openbsd*)
1074     NAME_DEV_RANDOM="/dev/srandom"
1075     ;;
1076
1077 dnl Win32 does not have /dev/random, they have their own method...
1078
1079     *-*-mingw*|*-*-cygwin*)
1080     ac_cv_have_dev_random=no
1081     ;;
1082
1083 dnl Everywhere else, it's /dev/random
1084
1085     *)
1086     NAME_DEV_RANDOM="/dev/random"
1087     ;;
1088 esac
1089
1090 AC_DEFINE_UNQUOTED(NAME_DEV_RANDOM, "$NAME_DEV_RANDOM")
1091
1092 dnl Now check if the device actually exists
1093
1094 if test "x$try_dev_random" = "xyes"; then
1095     AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1096     [if test -r "$NAME_DEV_RANDOM" ; then
1097         ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1098     if test "x$ac_cv_have_dev_random" = "xyes"; then
1099         AC_DEFINE(HAVE_CRYPT_RNG)
1100     fi
1101 else
1102     AC_MSG_CHECKING(for random device)
1103     ac_cv_have_dev_random=no
1104     AC_MSG_RESULT(has been disabled)
1105 fi
1106
1107 if test "x$platform_win32" = "xyes"; then
1108     AC_DEFINE(HAVE_CRYPT_RNG)
1109 fi
1110
1111 if test "x$ac_cv_have_dev_random" = "xno" \
1112     && test "x$platform_win32" = "xno"; then
1113     AC_MSG_WARN([[
1114 ***
1115 *** A system-provided entropy source was not found on this system.
1116 *** Because of this, the System.Security.Cryptography random number generator
1117 *** will throw a NotImplemented exception.
1118 ***
1119 *** If you are seeing this message, and you know your system DOES have an
1120 *** entropy collection in place, please contact <crichton@gimp.org> and
1121 *** provide information about the system and how to access the random device.
1122 ***
1123 *** Otherwise you can install either egd or prngd and set the environment
1124 *** variable MONO_EGD_SOCKET to point to the daemon's socket to use that.
1125 ***]])
1126 fi
1127  
1128 AC_MSG_CHECKING([if inter-process shared handles are requested])
1129 AC_ARG_ENABLE(shared-handles, [  --disable-shared-handles disable inter-process shared handles], try_shared_handles=$enableval, try_shared_handles=yes)
1130 AC_MSG_RESULT($try_shared_handles)
1131 if test "x$try_shared_handles" != "xyes"; then
1132         AC_DEFINE(DISABLE_SHARED_HANDLES)
1133         AC_SUBST(DISABLE_SHARED_HANDLES)
1134 fi
1135
1136 #
1137 # ICU 
1138 #
1139 ICU_CFLAGS=""
1140 ICU_LIBS=""
1141 enable_icu=no
1142
1143 probe_icu=true
1144 AC_ARG_WITH(icu, [  --with-icu=yes/no],
1145         if test x$with_icu = xno; then
1146            probe_icu=false;
1147            AC_MSG_RESULT(Will not probe for ICU)
1148         fi
1149 )
1150
1151 if $probe_icu; then
1152         AC_PATH_PROG(ICU_CONFIG, icu-config, no)
1153         if test "x$ICU_CONFIG" = "xno" -o ! -x "$ICU_CONFIG"; then
1154                 AC_MSG_WARN([Only invariant locale available; install ICU for I18N support])
1155                 enable_icu="no, if you want full i18n support download it from: http://oss.software.ibm.com/icu/index.html"
1156         else
1157                 enable_icu="yes. Version: `$ICU_CONFIG --version`"
1158                 AC_DEFINE(HAVE_ICU)
1159                 ICU_CFLAGS=`$ICU_CONFIG --cppflags`
1160                 ICU_LIBS=`$ICU_CONFIG --ldflags`
1161         fi
1162 fi
1163 AC_SUBST(ICU_CFLAGS)
1164 AC_SUBST(ICU_LIBS)
1165
1166 TARGET="unknown"
1167 ACCESS_UNALIGNED="yes"
1168
1169 JIT_SUPPORTED=no
1170 LIBC="libc.so.6"
1171 INTL="libc.so.6"
1172
1173 jit_wanted=false
1174 case "$host" in
1175 #       mips-sgi-irix5.* | mips-sgi-irix6.*)
1176 #               TARGET=MIPS;
1177 #               ACCESS_UNALIGNED="no"
1178 #               ;;
1179         i*86-*-*)
1180                 TARGET=X86;
1181                 arch_target=x86;
1182                 JIT_SUPPORTED=yes
1183                 jit_wanted=true
1184                 ;;
1185         x86_64-*-* | amd64-*-*)
1186                 TARGET=AMD64;
1187                 arch_target=amd64;
1188                 JIT_SUPPORTED=yes
1189                 jit_wanted=true
1190                 ;;
1191         sparc*-*-*)
1192                 if test "x$ac_cv_sizeof_void_p" = "x8"; then
1193                    TARGET=SPARC64
1194                 else
1195                         TARGET=SPARC
1196                 fi
1197                 arch_target=sparc;
1198                 JIT_SUPPORTED=yes
1199                 ACCESS_UNALIGNED="no"
1200                 LIBC="libc.so"
1201                 INTL="libintl.so"
1202                 jit_wanted=true
1203                 ;;
1204        alpha*-*-linux* | alpha*-*-osf*)
1205                 TARGET=ALPHA;
1206                 ACCESS_UNALIGNED="no"
1207                 JIT_SUPPORTED=no
1208                 arch_target=alpha;
1209                ;;
1210 #       ia64-*-linux* | ia64-*-hpux*)
1211 #               TARGET=IA64;
1212 #               arch_target=ia64;
1213 #               JIT_SUPPORTED=no;
1214 #               ACCESS_UNALIGNED="no";
1215 #               case "$host_os" in
1216 #                       linux*) LIBC="libc.so.6.1";;
1217 #                       hpux*)  LIBC="libc.so.1";;
1218 #               esac
1219 #               ;;
1220 #       m68k-*-linux*)
1221 #               TARGET=M68K
1222 #               ;;
1223         hppa2.0w-hp-hpux11.00 | hppa64-hp-hpux11.00)
1224                 TARGET=HPPA;
1225                 arch_target=hppa; 
1226                 LIBC="libc.sl"
1227                 ACCESS_UNALIGNED="no"
1228                 ;;
1229         hppa*linux*)
1230                 TARGET=HPPA;
1231                 arch_target=hppa; 
1232                 ACCESS_UNALIGNED="no"
1233                 ;;
1234         macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
1235         powerpc-*-sysv* | powerpc-*-darwin*)
1236                 TARGET=POWERPC;
1237                 arch_target=ppc;
1238                 JIT_SUPPORTED=yes
1239                 jit_wanted=true
1240                 ;;
1241         arm-*-linux-* | armv4l-*-linux-*)
1242                 TARGET=ARM;
1243                 arch_target=arm;
1244                 ACCESS_UNALIGNED="no"
1245                 ;;
1246         s390-*-linux*)
1247                 TARGET=S390;
1248                 arch_target=s390;
1249                 ACCESS_UNALIGNED="no"
1250                 JIT_SUPPORTED=yes
1251                 ;;
1252         s390x-*-linux*)
1253                 TARGET=S390x;
1254                 arch_target=s390x;
1255                 ACCESS_UNALIGNED="no"
1256                 JIT_SUPPORTED=yes
1257                 ;;
1258 esac
1259
1260 AC_ARG_WITH(jit, [  --with-jit=yes,no       If you want to build scripts that default to the JIT],[
1261         jit_wanted=true
1262 ])
1263
1264 USEJIT=false
1265 if test x$JIT_SUPPORTED = xyes; then
1266    if $jit_wanted; then
1267       USEJIT=true
1268       jit_status="Building and using the JIT"
1269    else
1270       jit_status="Building the JIT, defaulting to the interpreter"
1271    fi
1272 else
1273    jit_status="interpreter"
1274 fi
1275
1276 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
1277
1278 libsuffix=".so"
1279
1280 case "$host" in
1281      powerpc-*-darwin*)
1282         libsuffix=".dylib"
1283         LIBC="libc.dylib"
1284         INTL="libintl.dylib"
1285         ;;
1286      *-*-*netbsd*)
1287         LIBC="libc.so.12"
1288         INTL="libintl.so.0"
1289         ;;
1290     *-*-*freebsd*)
1291         LIBC="libc.so"
1292         INTL="libintl.so"
1293         ;;
1294     *-*-*openbsd*)
1295         LIBC="libc.so"
1296         INTL="libintl.so"
1297         ;;
1298 esac
1299 AC_SUBST(libsuffix)
1300
1301 if test "x$TARGET" != "xAMD64"; then
1302    # valgrind headers don't compile under x86-64
1303    AC_CHECK_HEADERS(valgrind/memcheck.h)
1304 fi
1305
1306 if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
1307         if test "x$with_tls" = "x__thread"; then
1308                 #
1309                 # On some linux distributions, TLS works in executables, but linking 
1310                 # against a shared library containing TLS fails with:
1311                 # undefined reference to `__tls_get_addr'
1312                 #
1313                 rm -f conftest.c conftest.so conftest
1314                 echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
1315                 gcc -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
1316                 gcc -o conftest conftest.so > /dev/null 2>&1
1317                 if test ! -f conftest; then
1318                    AC_MSG_WARN([Disabling usage of __thread.]);
1319                    with_tls=pthread
1320                 fi
1321                 rm -f conftest.c conftest.so conftest
1322         fi
1323 fi
1324
1325 if test "x$with_tls" = "x__thread"; then
1326         AC_DEFINE(HAVE_KW_THREAD)
1327    # Pass the information to libgc
1328         CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
1329         export CPPFLAGS
1330 fi
1331
1332 if test ${TARGET} = ARM; then
1333         dnl ******************************************
1334         dnl *** Check to see what FPU is available ***
1335         dnl ******************************************
1336         AC_MSG_CHECKING(which FPU to use)
1337
1338         AC_TRY_COMPILE([], [
1339                 __asm__ ("ldfd f0, [r0]");
1340                 ], fpu=FPA, [
1341                         AC_TRY_COMPILE([], [
1342                                 __asm__ ("fldd d0, [r0]");
1343                         ], fpu=VFP, fpu=NONE)
1344                 ])
1345
1346         AC_MSG_RESULT($fpu)
1347         CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu"
1348         unset fpu
1349 fi
1350
1351 if test ${TARGET} = unknown; then
1352         CPPFLAGS="$CPPFLAGS -DNO_PORT"
1353         AC_MSG_WARN("mono has not been ported to $host: some things may not work.")
1354 fi
1355
1356 if test ${ACCESS_UNALIGNED} = no; then
1357         CPPFLAGS="$CPPFLAGS -DNO_UNALIGNED_ACCESS"
1358 fi
1359
1360 PREVIEW=no
1361 AC_ARG_WITH(preview, [ --with-preview=yes,no     If you want to install the 2.0 FX preview],[
1362         if test x$with_preview = xyes; then
1363               PREVIEW=yes
1364         fi
1365 ])
1366
1367 AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
1368
1369 AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
1370 AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
1371 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
1372 AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
1373 AM_CONDITIONAL(X86, test x$TARGET = xX86)
1374 AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
1375 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
1376 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
1377 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
1378 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
1379 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
1380 AM_CONDITIONAL(S390, test x$TARGET = xS390)
1381 AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
1382 AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
1383
1384 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
1385
1386 AC_SUBST(LIBC)
1387 AC_SUBST(INTL)
1388
1389 AC_SUBST(arch_target)
1390 AC_SUBST(CFLAGS)
1391 AC_SUBST(CPPFLAGS)
1392 AC_SUBST(LDFLAGS)
1393
1394 AC_OUTPUT([
1395 Makefile
1396 mint.pc
1397 mono.pc
1398 mono/Makefile
1399 mono/utils/Makefile
1400 mono/metadata/Makefile
1401 mono/dis/Makefile
1402 mono/cil/Makefile
1403 mono/arch/Makefile
1404 mono/os/Makefile
1405 mono/os/win32/Makefile
1406 mono/os/unix/Makefile
1407 mono/arch/x86/Makefile
1408 mono/arch/amd64/Makefile
1409 mono/arch/hppa/Makefile
1410 mono/arch/ppc/Makefile
1411 mono/arch/sparc/Makefile
1412 mono/arch/s390/Makefile
1413 mono/arch/s390x/Makefile
1414 mono/arch/arm/Makefile
1415 mono/arch/alpha/Makefile
1416 mono/interpreter/Makefile
1417 mono/tests/Makefile
1418 mono/tests/tests-config
1419 mono/benchmark/Makefile
1420 mono/monoburg/Makefile
1421 mono/monograph/Makefile
1422 mono/io-layer/Makefile
1423 mono/handles/Makefile
1424 mono/mini/Makefile
1425 mono/profiler/Makefile
1426 ikvm-jni/Makefile
1427 runtime/Makefile
1428 runtime/net_1_1/Makefile
1429 runtime/net_2_0/Makefile
1430 scripts/Makefile
1431 man/Makefile
1432 web/Makefile
1433 docs/Makefile
1434 data/Makefile
1435 data/net_1_1/Makefile
1436 data/net_2_0/Makefile
1437 samples/Makefile
1438 support/Makefile
1439 data/config
1440 mono.spec
1441 tools/Makefile
1442 tools/locale-builder/Makefile
1443 ])
1444
1445 echo "
1446
1447         GC:          $gc
1448         ICU:         $enable_icu
1449         TLS:         $with_tls
1450         SIGALTSTACK: $with_sigaltstack
1451         Engine:      $jit_status
1452         2.0 Alpha:   $PREVIEW
1453         JNI support: $jdk_headers_found
1454
1455 "