[sockets] Fixed reading blocking flag
[mono.git] / libgc / configure.in
1 # Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
2
3 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
4 # OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
5
6 # Permission is hereby granted to use or copy this program
7 # for any purpose,  provided the above notices are retained on all copies.
8 # Permission to modify the code and to distribute modified code is granted,
9 # provided the above notices are retained, and a notice that the code was
10 # modified is included with the above copyright notice.
11 #
12 # Original author: Tom Tromey
13 # Modified by: Grzegorz Jakacki <jakacki at acm dot org>
14
15 dnl Process this file with autoconf to produce configure.
16
17 AC_PREREQ(2.53)
18 AC_INIT(libgc-mono, 6.6, Hans_Boehm@hp.com)
19
20 AM_INIT_AUTOMAKE(libgc-mono, 6.6, no-define)
21
22 AC_CONFIG_SRCDIR(gcj_mlc.c)
23 AC_CANONICAL_HOST
24
25 AC_SUBST(PACKAGE)
26 AC_SUBST(GC_VERSION)
27
28 AC_PROG_CC
29 AC_PROG_CXX
30
31 dnl automake 1.6 and later need the AM_PROG_AS macro.
32 ifdef([AM_PROG_AS],[AM_PROG_AS],[])
33 AC_CHECK_TOOL(AR, ar)
34 AC_CHECK_TOOL(RANLIB, ranlib, :)  # :)
35
36 AC_PROG_INSTALL
37
38 AM_MAINTAINER_MODE
39
40 . [$]{srcdir}/configure.host
41
42 # We use a separate variable to pass down CPPFLAGS and CFLAGS from the main mono 
43 # configure, because of autoconf brokeness
44 if test "x$CPPFLAGS_FOR_LIBGC" != "x"; then
45    CPPFLAGS=$CPPFLAGS_FOR_LIBGC
46 fi
47 if test "x$CFLAGS_FOR_LIBGC" != "x"; then
48    CFLAGS=$CFLAGS_FOR_LIBGC
49 fi
50
51 GC_CFLAGS=${gc_cflags}
52 AC_SUBST(GC_CFLAGS)
53
54 case $enable_embed_check in
55 no) ;;
56 *) AC_MSG_ERROR([This module is now part of 'mono' and cannot be built as a stand-alone module any longer.]) ;;
57 esac
58
59 THREADS=$with_libgc_threads
60
61 AC_ARG_ENABLE(win32-dllmain,
62 [  --enable-win32-dllmain    Define the DllMain function in win32_threads.c even if the collector is not built as a dll],
63 )
64
65 AC_ARG_ENABLE(parallel-mark,
66 [  --enable-parallel-mark       parallelize marking and free list construction],
67    [case "$THREADS" in
68       no | none | single)
69         AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
70         ;;
71     esac]
72 )
73
74 AC_ARG_ENABLE(cplusplus,
75 [  --enable-cplusplus           install C++ support],
76 )
77
78 INCLUDES=-I${srcdir}/include
79 THREADDLLIBS=
80 ## Libraries needed to support dynamic loading and/or threads.
81 case "$THREADS" in
82  no | none | single)
83     THREADS=none
84     ;;
85  posix | pthreads)
86     THREADS=posix
87     AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
88     case "$host" in
89      x86-*-linux* | ia64-*-linux* | i386-*-linux* | i486-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha*-*-linux* | s390*-*-linux* | sparc*-*-linux* | powerpc-*-linux*)
90         AC_DEFINE(GC_LINUX_THREADS)
91         AC_DEFINE(_REENTRANT)
92         if test "${enable_parallel_mark}" = yes; then
93           AC_DEFINE(PARALLEL_MARK)
94         fi
95         AC_DEFINE(THREAD_LOCAL_ALLOC)
96         ;;
97      *-*-linux*)
98         AC_DEFINE(GC_LINUX_THREADS)
99         AC_DEFINE(_REENTRANT)
100         ;;
101      *-*-aix*)
102         AC_DEFINE(GC_AIX_THREADS)
103         AC_DEFINE(_REENTRANT)
104         ;;
105      *-*-hpux*)
106         AC_MSG_WARN("Only HP/UX 11 threads are supported.")
107         AC_DEFINE(GC_HPUX_THREADS)
108         AC_DEFINE(_POSIX_C_SOURCE,199506L)
109         if test "${enable_parallel_mark}" = yes; then
110           AC_DEFINE(PARALLEL_MARK)
111         fi
112         AC_DEFINE(THREAD_LOCAL_ALLOC)
113         THREADDLLIBS="-lpthread -lrt"
114         ;;
115       *-*-freebsd*)
116         AC_DEFINE(GC_FREEBSD_THREADS)
117         if test "x$PTHREAD_CFLAGS" != "x"; then
118                 INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
119         fi
120         if test "x$PTHREAD_LIBS" = "x"; then
121                 THREADDLLIBS=-pthread
122         else
123                 THREADDLLIBS="$PTHREAD_LIBS"
124         fi
125         ;;
126      *-*-solaris*)
127         AC_DEFINE(GC_SOLARIS_THREADS)
128         AC_DEFINE(GC_SOLARIS_PTHREADS)
129         ;;
130      *-*-irix*)
131         AC_DEFINE(GC_IRIX_THREADS)
132         ;;
133      *-*-cygwin*)
134         AC_DEFINE(GC_WIN32_THREADS)
135         ;;
136      *-*-darwin*)
137         AC_DEFINE(GC_DARWIN_THREADS)
138         AC_DEFINE(THREAD_LOCAL_ALLOC)
139         if test "${enable_parallel_mark}" = yes; then
140           AC_DEFINE(PARALLEL_MARK)
141         fi
142         ;;
143      *-*-netbsd*)
144         AC_DEFINE(GC_NETBSD_THREADS)
145         if test "${enable_parallel_mark}" = yes; then
146           AC_DEFINE(PARALLEL_MARK)
147         fi
148         AC_DEFINE(THREAD_LOCAL_ALLOC)
149         ;;
150      *-*-openbsd*)
151         AC_DEFINE(GC_OPENBSD_THREADS)
152         if test "${enable_parallel_mark}" = yes; then
153           AC_DEFINE(PARALLEL_MARK)
154         fi
155         AC_DEFINE(THREAD_LOCAL_ALLOC)
156         ;;
157      *-*-osf*)
158         AC_DEFINE(GC_OSF1_THREADS)
159         if test "${enable_parallel_mark}" = yes; then
160           AC_DEFINE(PARALLEL_MARK)
161           AC_DEFINE(THREAD_LOCAL_ALLOC)
162           # May want to enable it in other cases, too.
163           # Measurements havent yet been done.
164         fi
165         INCLUDES="$INCLUDES -pthread"
166         THREADDLLIBS="-lpthread -lrt"
167         ;;
168       *)
169         AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
170         ;;
171     esac
172     ;;
173  win32)
174     AC_DEFINE(GC_WIN32_THREADS)
175     dnl Wine getenv may not return NULL for missing entry
176     AC_DEFINE(NO_GETENV)
177         if test "${enable_win32_dllmain}" = yes; then
178            AC_DEFINE(GC_INSIDE_DLL)
179         fi
180     ;;
181  dgux386)
182     THREADS=dgux386
183     AC_MSG_RESULT($THREADDLLIBS)
184     # Use pthread GCC  switch
185     THREADDLLIBS=-pthread
186     if test "${enable_parallel_mark}" = yes; then
187         AC_DEFINE(PARALLEL_MARK)
188     fi
189     AC_DEFINE(THREAD_LOCAL_ALLOC)
190     AC_DEFINE(GC_DGUX386_THREADS)
191     AC_DEFINE(DGUX_THREADS)
192     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
193     INCLUDES="-pthread $INCLUDES"
194     ;;
195  aix)
196     THREADS=posix
197     THREADDLLIBS=-lpthread
198     AC_DEFINE(GC_AIX_THREADS)
199     AC_DEFINE(_REENTRANT)
200     ;;
201  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
202     AC_MSG_ERROR(thread package $THREADS not yet supported)
203     ;;
204  *)
205     AC_MSG_ERROR($THREADS is an unknown thread package)
206     ;;
207 esac
208 AC_SUBST(THREADDLLIBS)
209
210 case "$host" in 
211    powerpc-*-darwin*)
212       powerpc_darwin=true
213       ;;
214 esac
215 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
216
217 AC_MSG_CHECKING(for xlc)
218 AC_TRY_COMPILE([],[
219  #ifndef __xlC__
220  # error
221  #endif
222 ], [compiler_xlc=yes], [compiler_xlc=no])
223 AC_MSG_RESULT($compiler_xlc)
224 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
225 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
226   # the darwin stack-frame-walking code is completely broken on xlc
227   AC_DEFINE(DARWIN_DONT_PARSE_STACK)
228 fi
229
230 # We never want libdl on darwin. It is a fake libdl that just ends up making
231 # dyld calls anyway
232 case "$host" in
233   *-*-darwin*) ;;
234   *) 
235     AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
236     ;;
237 esac
238
239 AC_SUBST(EXTRA_TEST_LIBS)
240
241 target_all=libgc.la
242 AC_SUBST(target_all)
243
244 dnl If the target is an eCos system, use the appropriate eCos
245 dnl I/O routines.
246 dnl FIXME: this should not be a local option but a global target
247 dnl system; at present there is no eCos target.
248 TARGET_ECOS="no"
249 AC_ARG_WITH(ecos,
250 [  --with-ecos             enable runtime eCos target support],
251 TARGET_ECOS="$with_ecos"
252 )
253
254 addobjs=
255 addlibs=
256 addincludes=
257 addtests=
258 CXXINCLUDES=
259 case "$TARGET_ECOS" in
260    no)
261       ;;
262    *)
263       AC_DEFINE(ECOS)
264       CXXINCLUDES="-I${TARGET_ECOS}/include"
265       addobjs="$addobjs ecos.lo"
266       ;;
267 esac
268
269 if test "${enable_cplusplus}" = yes; then
270       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
271       addtests="$addtests test_cpp"
272 fi
273
274 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
275
276 AC_SUBST(CXX)
277
278 AC_SUBST(INCLUDES)
279 AC_SUBST(CXXINCLUDES)
280
281 # Configuration of shared libraries
282 #
283 AC_MSG_CHECKING(whether to build shared libraries)
284 AC_ENABLE_SHARED
285
286 case "$host" in
287  alpha-*-openbsd*)
288      enable_shared=no
289      AC_MSG_RESULT(no)
290      ;;
291  *)
292      AC_MSG_RESULT(yes)
293      ;;
294 esac
295
296 # Configuration of machine-dependent code
297 #
298 AC_MSG_CHECKING(which machine-dependent code should be used) 
299 machdep=
300 case "$host" in
301  alpha-*-openbsd*)
302     machdep="alpha_mach_dep.lo"
303     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
304        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
305     fi
306     ;;
307  alpha*-*-linux*)
308     machdep="alpha_mach_dep.lo"
309     ;;
310  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
311     AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
312     ;;
313  mipstx39-*-elf*)
314     machdep="mips_ultrix_mach_dep.lo"
315     AC_DEFINE(STACKBASE, __stackbase)
316     AC_DEFINE(DATASTART_IS_ETEXT)
317     ;;
318  mips-dec-ultrix*)
319     machdep="mips_ultrix_mach-dep.lo"
320     ;;
321  mips-nec-sysv*|mips-unknown-sysv*)
322     ;;
323  mips*-*-linux*) 
324     ;; 
325  mips-*-*)
326     machdep="mips_sgi_mach_dep.lo"
327     AC_DEFINE(NO_EXECUTE_PERMISSION)
328     ;;
329  sparc-*-netbsd*)
330     machdep="sparc_netbsd_mach_dep.lo"
331     ;;
332  sparc-sun-solaris2.3)
333     machdep="sparc_mach_dep.lo"
334     AC_DEFINE(SUNOS53_SHARED_LIB)
335     ;;
336  sparc*-sun-solaris2.*)
337     machdep="sparc_mach_dep.lo"
338     ;;
339  ia64-*-*)
340      machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
341         target_ia64=true
342     ;;
343 esac
344 if test x"$machdep" = x; then
345 AC_MSG_RESULT($machdep)
346    machdep="mach_dep.lo"
347 fi
348 addobjs="$addobjs $machdep"
349 #
350 # Adding object files directly to _LIBADD breaks -j builds, so we need to add the sources
351 # instead, but _SOURCES can't contain autoconf substitutions, so add them using automake
352 # conditionals.
353 #
354 #AC_SUBST(addobjs)
355 AC_SUBST(addincludes)
356 AC_SUBST(addlibs)
357 AC_SUBST(addtests)
358
359 AM_CONDITIONAL(TARGET_IA64,test x$target_ia64 = xtrue)
360
361 AC_PROG_LIBTOOL
362 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
363 DOLT
364
365 #
366 # Check for AViiON Machines running DGUX
367 #
368 ac_is_dgux=no
369 AC_CHECK_HEADER(sys/dg_sys_info.h,
370 [ac_is_dgux=yes;])
371
372     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
373 if test $ac_is_dgux = yes; then
374     if test "$enable_full_debug" = "yes"; then
375       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
376       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
377     else
378       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
379       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
380     fi
381     AC_SUBST(CFLAGS)
382     AC_SUBST(CXXFLAGS)
383 fi
384
385 dnl We use these options to decide which functions to include.
386 AC_ARG_WITH(target-subdir,
387 [  --with-target-subdir=SUBDIR
388                           configuring with a cross compiler])
389 AC_ARG_WITH(cross-host,
390 [  --with-cross-host=HOST  configuring with a cross compiler])
391
392 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
393 # it is actually a problem, because the compiler we're passed can't
394 # necessarily do a full link.  So we fool automake here.
395 if false; then
396   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
397   # to nothing, so nothing would remain between `then' and `fi' if it
398   # were not for the `:' below.
399   :
400   AC_EXEEXT
401 fi
402
403 AC_MSG_CHECKING([for threads package to use])
404 AC_MSG_RESULT($THREADS)
405
406 dnl As of 4.13a2, the collector will not properly work on Solaris when
407 dnl built with gcc and -O.  So we remove -O in the appropriate case.
408 dnl Not needed anymore on Solaris.
409 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
410 case "$host" in
411  *aix*)
412     if test "$GCC" = yes; then
413        AC_MSG_RESULT(yes)
414        new_CFLAGS=
415        for i in $CFLAGS; do
416           case "$i" in
417            -O*)
418               ;;
419            *)
420               new_CFLAGS="$new_CFLAGS $i"
421               ;;
422           esac
423        done
424        CFLAGS="$new_CFLAGS"
425     else
426        AC_MSG_RESULT(no)
427     fi
428     ;;
429  *) AC_MSG_RESULT(no) ;;
430 esac
431
432 dnl We need to override the top-level CFLAGS.  This is how we do it.
433 MY_CFLAGS="$CFLAGS"
434 AC_SUBST(MY_CFLAGS)
435
436 dnl Include defines that have become de facto standard.
437 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
438 AC_DEFINE(SILENT)
439 AC_DEFINE(NO_SIGNALS)
440 AC_DEFINE(NO_EXECUTE_PERMISSION)
441 dnl AC_DEFINE(ALL_INTERIOR_POINTERS)
442
443 dnl By default, make the library as general as possible.
444 AC_DEFINE(JAVA_FINALIZATION)
445 AC_DEFINE(GC_GCJ_SUPPORT)
446 AC_DEFINE(ATOMIC_UNCOLLECTABLE)
447
448 dnl This is something of a hack.  When cross-compiling we turn off
449 dnl some functionality.  We also enable the "small" configuration.
450 dnl These is only correct when targetting an embedded system.  FIXME.
451 if test -n "${with_cross_host}"; then
452    AC_DEFINE(NO_SIGSET)
453    AC_DEFINE(NO_CLOCK)
454    AC_DEFINE(SMALL_CONFIG)
455    AC_DEFINE(NO_DEBUGGING)
456 fi
457
458 UNWINDLIBS=
459 AC_ARG_ENABLE(full-debug,
460 [  --enable-full-debug  include full support for pointer backtracing etc.],
461 [ if test "$enable_full_debug" = "yes"; then
462     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
463     AC_DEFINE(KEEP_BACK_PTRS)
464     AC_DEFINE(DBG_HDRS_ALL)
465     case $host in
466       ia64-*-linux* )
467         AC_DEFINE(MAKE_BACK_GRAPH)
468         AC_DEFINE(SAVE_CALL_COUNT, 8)
469         AC_CHECK_LIB(unwind, backtrace, [
470           AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
471           UNWINDLIBS=-lunwind
472           AC_MSG_WARN("Client code may need to link against libunwind.")
473         ])
474       ;;
475       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
476         AC_DEFINE(MAKE_BACK_GRAPH)
477         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
478         AC_DEFINE(SAVE_CALL_COUNT, 8)
479       ;;
480       i[3456]86-*-dgux*)
481         AC_DEFINE(MAKE_BACK_GRAPH)
482       ;;
483     esac ]
484   fi)
485
486 AC_SUBST(UNWINDLIBS)
487
488 AC_ARG_ENABLE(redirect-malloc,
489 [  --enable-redirect-malloc  redirect malloc and friends to GC routines])
490
491 if test "${enable_redirect_malloc}" = yes; then
492     if test "${enable_full_debug}" = yes; then
493         AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement)
494         AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement)
495         AC_DEFINE(REDIRECT_FREE, GC_debug_free)
496     else
497         AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
498     fi
499 fi
500
501 AC_DEFINE(_IN_LIBGC)
502
503 AC_ARG_ENABLE(gc-assertions,
504 [  --enable-gc-assertions  collector-internal assertion checking])
505 if test "${enable_gc_assertions}" = yes; then
506     AC_DEFINE(GC_ASSERTIONS)
507 fi
508
509 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet libgc build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
510 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
511
512 if test "${multilib}" = "yes"; then
513   multilib_arg="--enable-multilib"
514 else
515   multilib_arg=
516 fi
517
518 if test x$enable_quiet_build = xyes; then
519    AC_CONFIG_COMMANDS([quiet], [for i in `find . -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])
520    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])
521 fi
522
523 AC_OUTPUT(Makefile
524 include/Makefile
525 include/private/Makefile
526 doc/Makefile,,
527 srcdir=${srcdir}
528 host=${host}
529 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
530 CC="${CC}"
531 DEFS="$DEFS"
532 )