OSDN Git Service

2008-04-18 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / boehm-gc / configure.ac
1 # Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006 by Red Hat, Inc. All rights reserved.
2 # Copyright 2004 Nathanael Nerode
3
4 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
5 # OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
6
7 # Permission is hereby granted to use or copy this program
8 # for any purpose,  provided the above notices are retained on all copies.
9 # Permission to modify the code and to distribute modified code is granted,
10 # provided the above notices are retained, and a notice that the code was
11 # modified is included with the above copyright notice.
12 #
13 # Original author: Tom Tromey
14 # Modified by Nathanael Nerode
15
16 dnl Process this file with autoconf to produce configure.
17
18 AC_PREREQ(2.59)
19 AC_INIT
20 AC_CONFIG_SRCDIR(gcj_mlc.c)
21 # This works around the fact that libtool configuration may change LD
22 # for this particular configuration, but some shells, instead of
23 # keeping the changes in LD private, export them just because LD is
24 # exported.
25 ORIGINAL_LD_FOR_MULTILIBS=$LD
26
27 AM_ENABLE_MULTILIB(, ..)
28
29 AC_CANONICAL_HOST
30 AC_CANONICAL_TARGET
31
32 # Get the 'noncanonical' system names.
33 ACX_NONCANONICAL_TARGET
34
35 # This works around an automake problem.
36 mkinstalldirs="`cd $ac_aux_dir && ${PWDCMD-pwd}`/mkinstalldirs"
37 AC_SUBST(mkinstalldirs)
38
39 AM_INIT_AUTOMAKE(gc, 6.6, no-define)
40
41 # The autoconf 2.5x version of the no-executables hack.
42 GCC_NO_EXECUTABLES
43
44 # Yak.  We must force CC and CXX to /not/ be precious variables; otherwise
45 # the wrong, non-multilib-adjusted value will be used in multilibs.
46 # As a side effect, we have to subst CFLAGS and CXXFLAGS ourselves.
47
48 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
49 m4_define([_AC_ARG_VAR_PRECIOUS],[])
50 AC_PROG_CC
51 AC_PROG_CXX
52 m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
53
54 AM_PROG_CC_C_O
55
56 AC_SUBST(CFLAGS)
57 AC_SUBST(CXXFLAGS)
58
59 # Newer automakes demand CCAS and CCASFLAGS.
60 : ${CCAS='$(CC)'}
61 : ${CCASFLAGS='$(CFLAGS)'}
62 AC_SUBST(CCAS)
63 AC_SUBST(CCASFLAGS)
64
65 AC_CHECK_TOOL(AS, as)
66 AC_CHECK_TOOL(AR, ar)
67 AC_CHECK_TOOL(RANLIB, ranlib, :)
68
69 AC_PROG_INSTALL
70
71 AM_MAINTAINER_MODE
72
73 . ${srcdir}/configure.host
74
75 case ${gc_basedir} in
76 /* | [A-Za-z]:[/\\]*) gc_flagbasedir=${gc_basedir} ;;
77 *) gc_flagbasedir='$(top_builddir)/'${gc_basedir} ;;
78 esac
79
80 gc_cflags="${gc_cflags} -Iinclude -I"'$(top_builddir)'"/./targ-include -I${gc_flagbasedir}/libc/include"
81 case "${host}" in
82   *-*-cygwin32*)
83     gc_cflags="${gc_cflags} -I${gc_flagbasedir}/../winsup/include"
84     ;;
85 esac
86
87 dnl gc_cflags="${gc_cflags} -fno-builtin"
88
89 GC_CFLAGS=${gc_cflags}
90 AC_SUBST(GC_CFLAGS)
91
92 AC_PROG_LIBTOOL
93
94 dnl We use these options to decide which functions to include.
95 AC_ARG_WITH(target-subdir,
96 [  --with-target-subdir=SUBDIR
97                           configuring with a cross compiler])
98 AC_ARG_WITH(cross-host,
99 [  --with-cross-host=HOST  configuring with a cross compiler])
100
101 AC_MSG_CHECKING([for thread model used by GCC])
102 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
103 if test -z "$THREADS"; then
104    THREADS=no
105 fi
106 AC_MSG_RESULT([$THREADS])
107
108 AC_ARG_ENABLE(parallel-mark,
109 [  --enable-parallel-mark       parallelize marking and free list construction],
110    [case "$THREADS" in
111       no | none | single)
112         AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
113         ;;
114     esac]
115 )
116
117 AM_CPPFLAGS="-I`cd $srcdir && ${PWDCMD-pwd}`/include"
118 THREADLIBS=
119 case "$THREADS" in
120  no | none | single)
121     THREADS=none
122     ;;
123  posix | posix95 | pthreads)
124     THREADS=posix
125     THREADLIBS=-lpthread
126     case "$host" in
127      x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha-*-linux*)
128         AC_DEFINE(GC_LINUX_THREADS,1,[support for Xavier Leroy's Linux threads])
129         AC_DEFINE(_REENTRANT,1,[Use reentrant code])
130         if test "${enable_parallel_mark}" = yes; then
131           AC_DEFINE(PARALLEL_MARK,1,[allow the marker to run in multiple threads])
132         fi
133         AC_DEFINE(THREAD_LOCAL_ALLOC,1,[define GC_local_malloc() & GC_local_malloc_atomic()])
134         ;;
135      *-*-linux*)
136         AC_DEFINE(GC_LINUX_THREADS,1)
137         AC_DEFINE(_REENTRANT,1)
138         ;;
139      *-*-aix*)
140         AC_DEFINE(GC_AIX_THREADS,1,[support AIX threads])
141         AC_DEFINE(_REENTRANT,1)
142         ;;
143      *-*-hpux11*)
144         AC_MSG_WARN("Only HP-UX 11 POSIX threads are supported.")
145         AC_DEFINE(GC_HPUX_THREADS,1,[enables support for HP/UX 11 pthreads])
146         AC_DEFINE(_POSIX_C_SOURCE,199506L,[POSIX version of C Source])
147         if test "${enable_parallel_mark}" = yes; then
148           AC_DEFINE(PARALLEL_MARK,1)
149         fi
150         AC_DEFINE(THREAD_LOCAL_ALLOC,1)
151         THREADLIBS="-lpthread -lrt"
152         # HPUX needs REENTRANT for the _r calls.
153         AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
154         ;;
155      *-*-hpux10*)
156         AC_MSG_WARN("Only HP-UX 11 POSIX threads are supported.")
157         ;;
158       *-*-kfreebsd*-gnu)
159        AC_DEFINE(GC_FREEBSD_THREADS)
160        INCLUDES="$INCLUDES -pthread"
161        THREADDLLIBS=-pthread
162        AC_DEFINE(_REENTRANT)
163          if test "${enable_parallel_mark}" = yes; then
164          AC_DEFINE(PARALLEL_MARK)
165        fi
166        AC_DEFINE(THREAD_LOCAL_ALLOC)
167        AC_DEFINE(USE_COMPILER_TLS, 1,[use tls for boehm])
168                ;;
169      *-*-freebsd*)
170         AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
171         AC_DEFINE(GC_FREEBSD_THREADS,1,[support FreeBSD threads])
172         AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
173         THREADLIBS=-pthread
174         ;;
175      *-*-solaris*)
176         AC_DEFINE(GC_SOLARIS_PTHREADS,1,[support for Solaris pthreads])
177         # Need to use alternate thread library, otherwise gctest hangs
178         # on Solaris 8.
179         multi_os_directory=`$CC -print-multi-os-directory`
180         THREADLIBS="-L/usr/lib/lwp/$multi_os_directory \
181                     -R/usr/lib/lwp/$multi_os_directory -lpthread -lthread -lrt"
182         ;;
183      *-*-irix*)
184         AC_DEFINE(GC_IRIX_THREADS,1,[support for Irix pthreads])
185         ;;
186      *-*-cygwin*)
187         AC_DEFINE(GC_WIN32_THREADS,1,[support for win32 threads])
188         ;;
189      *-*-darwin*)
190         AC_DEFINE(GC_DARWIN_THREADS,1,[support for Mac OS X pthreads])
191         AC_DEFINE(THREAD_LOCAL_ALLOC,1)
192         if test "${enable_parallel_mark}" = yes; then
193           AC_DEFINE(PARALLEL_MARK,1)
194         fi
195         ;;
196      *-*-osf*)
197         AC_DEFINE(GC_OSF1_THREADS,1,[support for Tru64 pthreads])
198         if test "${enable_parallel_mark}" = yes; then
199           AC_DEFINE(PARALLEL_MARK,1)
200           AC_DEFINE(THREAD_LOCAL_ALLOC,1)
201           # May want to enable it in other cases, too.
202           # Measurements havent yet been done.
203         fi
204         AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
205         THREADLIBS="-lpthread -lrt"
206         ;;
207     esac
208     ;;
209  win32)
210     AC_DEFINE(GC_WIN32_THREADS,1)
211     dnl Old wine getenv may not return NULL for missing entry.
212     dnl Define EMPTY_GETENV_RESULTS here to work around the bug.
213     ;;
214  dgux386)
215     THREADS=dgux386
216 AC_MSG_RESULT($THREADLIBS)
217     # Use pthread GCC  switch
218     THREADLIBS=-pthread
219     if test "${enable_parallel_mark}" = yes; then
220         AC_DEFINE(PARALLEL_MARK,1)
221     fi
222     AC_DEFINE(THREAD_LOCAL_ALLOC,1)
223     AC_DEFINE(GC_DGUX386_THREADS,1,[support for DB/UX on I386 threads])
224     AC_DEFINE(DGUX_THREADS,1,[No description])
225     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
226     AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
227     ;;
228  aix)
229     THREADS=posix
230     THREADLIBS=-lpthread
231     AC_DEFINE(GC_AIX_THREADS,1)
232     AC_DEFINE(_REENTRANT,1)
233     ;;
234  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
235     AC_MSG_ERROR(thread package $THREADS not yet supported)
236     ;;
237  *)
238     AC_MSG_ERROR($THREADS is an unknown thread package)
239     ;;
240 esac
241 AC_SUBST(THREADLIBS)
242
243 case "$host" in
244    powerpc-*-darwin*)
245       powerpc_darwin=true
246       ;;
247 esac
248 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
249
250 # Darwin needs a few extra special tests to deal with variation in the
251 # system headers.
252 case "$host" in
253   powerpc*-*-darwin*)
254     AC_CHECK_MEMBER(ppc_thread_state_t.r0,
255       AC_DEFINE(HAS_PPC_THREAD_STATE_R0,1,
256         [ppc_thread_state_t has field r0]),,
257       [#include <mach/thread_status.h>])
258     AC_CHECK_MEMBER(ppc_thread_state_t.__r0,
259       AC_DEFINE(HAS_PPC_THREAD_STATE___R0,1,dnl
260         [ppc_thread_state_t has field __r0]),,
261       [#include <mach/thread_status.h>])
262     AC_CHECK_MEMBER(ppc_thread_state64_t.r0,
263       AC_DEFINE(HAS_PPC_THREAD_STATE64_R0,1,dnl
264         [ppc_thread_state64_t has field r0]),,
265       [#include <mach/thread_status.h>])
266     AC_CHECK_MEMBER(ppc_thread_state64_t.__r0,
267       AC_DEFINE(HAS_PPC_THREAD_STATE64___R0,1,dnl
268         [ppc_thread_state64_t has field __r0]),,
269       [#include <mach/thread_status.h>])
270     ;;
271   i?86*-*-darwin*)
272     AC_CHECK_MEMBER(x86_thread_state32_t.eax,
273       AC_DEFINE(HAS_X86_THREAD_STATE32_EAX,1,dnl
274         [x86_thread_state32_t has field eax]),,
275       [#include <sys/cdefs.h>
276       #include <mach/thread_status.h>])
277     AC_CHECK_MEMBER(x86_thread_state32_t.__eax,
278       AC_DEFINE(HAS_X86_THREAD_STATE32___EAX,1,dnl
279         [x86_thread_state32_t has field __eax]),,
280       [#include <sys/cdefs.h>
281       #include <mach/thread_status.h>])
282     ;;
283   x86_64-*-darwin*)
284     AC_CHECK_MEMBER(x86_thread_state64_t.rax,
285       AC_DEFINE(HAS_X86_THREAD_STATE64_RAX,1,dnl
286         [x86_thread_state64_t has field rax]),,
287       [#include <sys/cdefs.h>
288       #include <mach/thread_status.h>])
289     AC_CHECK_MEMBER(x86_thread_state64_t.__rax,
290       AC_DEFINE(HAS_X86_THREAD_STATE64___RAX,1,dnl
291         [x86_thread_state64_t has field __rax]),,
292       [#include <sys/cdefs.h>
293       #include <mach/thread_status.h>])
294      ;;
295   *) ;;
296 esac
297
298 # We never want libdl on darwin. It is a fake libdl that just ends up making
299 # dyld calls anyway
300 case "$host" in
301   *-*-darwin*) ;;
302   *)
303     AC_CHECK_LIB(dl, dlopen, EXTRA_TEST_LIBS="$EXTRA_TEST_LIBS -ldl")
304     ;;
305 esac
306
307 # extra LD Flags which are required for targets
308 case "${host}" in
309   *-*-darwin*)
310     extra_ldflags_libgc=-Wl,-single_module
311     ;;
312 esac
313 AC_SUBST(extra_ldflags_libgc)
314
315 AC_SUBST(EXTRA_TEST_LIBS)
316
317 target_all=libgcjgc.la
318 AC_SUBST(target_all)
319
320 dnl If the target is an eCos system, use the appropriate eCos
321 dnl I/O routines.
322 dnl FIXME: this should not be a local option but a global target
323 dnl system; at present there is no eCos target.
324 TARGET_ECOS="no"
325 AC_ARG_WITH(ecos,
326 [  --with-ecos             enable runtime eCos target support],
327 TARGET_ECOS="$with_ecos"
328 )
329
330 addobjs=
331 addlibs=
332 addincludes=
333 addtests=
334 case "$TARGET_ECOS" in
335    no)
336       ;;
337    *)
338       AC_DEFINE(ECOS,1,[Target is ECOS])
339       AM_CPPFLAGS="${AM_CPPFLAGS} -I${TARGET_ECOS}/include"
340       addobjs="$addobjs ecos.lo"
341       ;;
342 esac
343
344 if test "${enable_cplusplus}" = yes; then
345       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
346       addtests="$addtests test_cpp"
347 fi
348
349 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
350
351 AC_SUBST(CXX)
352
353 AC_SUBST(AM_CPPFLAGS)
354
355 # Configuration of shared libraries
356 #
357 AC_MSG_CHECKING(whether to build shared libraries)
358 AC_ENABLE_SHARED
359
360 case "$host" in
361  alpha-*-openbsd*)
362      enable_shared=no
363      AC_MSG_RESULT(no)
364      ;;
365  *)
366      AC_MSG_RESULT(yes)
367      ;;
368 esac
369
370 # Checks for pthreads functions
371 #
372 oldLIBS="$LIBS"
373 LIBS="$LIBS $THREADLIBS"
374 AC_CHECK_FUNCS([pthread_getattr_np])
375 LIBS="$oldLIBS"
376
377 # Configuration of machine-dependent code
378 #
379 # Set NO_EXECUTE_PERMISSION by default because gcj already uses
380 # ffi_closure_{alloc,free} which takes care of allocating trampolines
381 # in executable memory.
382 #
383 AC_MSG_CHECKING(which machine-dependent code should be used)
384 machdep=
385 case "$host" in
386  alpha*-*-openbsd*)
387     machdep="alpha_mach_dep.lo"
388     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
389        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
390     fi
391     ;;
392  alpha*-*-linux*)
393     machdep="alpha_mach_dep.lo"
394     ;;
395  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
396     AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED,1,[PROC_VDB in Solaris 2.5 gives wrong values for dirty bits])
397     ;;
398  mipstx39-*-elf*)
399     machdep="mips_ultrix_mach_dep.lo"
400     AC_DEFINE(STACKBASE, __stackbase,[No description])
401     AC_DEFINE(DATASTART_IS_ETEXT,1,[No description])
402     ;;
403  mips-dec-ultrix*)
404     machdep="mips_ultrix_mach-dep.lo"
405     ;;
406  mips-nec-sysv*|mips-unknown-sysv*)
407     ;;
408  mips*-*-linux*)
409     ;;
410  mips-*-*)
411     machdep="mips_sgi_mach_dep.lo"
412     ;;
413  sparc-*-netbsd*)
414     machdep="sparc_netbsd_mach_dep.lo"
415     ;;
416  sparc-sun-solaris2.3)
417     machdep="sparc_mach_dep.lo"
418     AC_DEFINE(SUNOS53_SHARED_LIB,1,[Avoid Solaris 5.3 dynamic library bug])
419     ;;
420  sparc*-sun-solaris2.*)
421     machdep="sparc_mach_dep.lo"
422     ;;
423  ia64-*-*)
424     machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
425     ;;
426 esac
427 AC_DEFINE(NO_EXECUTE_PERMISSION,1,[cause some or all of the heap to not have execute permission])
428 if test x"$machdep" = x; then
429 AC_MSG_RESULT($machdep)
430    machdep="mach_dep.lo"
431 fi
432 addobjs="$addobjs $machdep"
433 AC_SUBST(addobjs)
434 AC_SUBST(addincludes)
435 AC_SUBST(addlibs)
436 AC_SUBST(addtests)
437
438 #
439 # Check for AViiON Machines running DGUX
440 #
441 AC_MSG_CHECKING(if host is AViiON running DGUX)
442 ac_is_dgux=no
443 AC_CHECK_HEADER(sys/dg_sys_info.h,
444 [ac_is_dgux=yes;])
445
446 AC_MSG_RESULT($ac_is_dgux)
447     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
448 if test $ac_is_dgux = yes; then
449     if test "$enable_full_debug" = "yes"; then
450       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
451       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
452     else
453       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
454       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
455     fi
456     AC_SUBST(CFLAGS)
457     AC_SUBST(CXXFLAGS)
458 fi
459
460 dnl As of 4.13a2, the collector will not properly work on Solaris when
461 dnl built with gcc and -O.  So we remove -O in the appropriate case.
462 dnl Not needed anymore on Solaris.
463 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
464 case "$host" in
465  *aix*)
466     if test "$GCC" = yes; then
467        AC_MSG_RESULT(yes)
468        new_CFLAGS=
469        for i in $CFLAGS; do
470           case "$i" in
471            -O*)
472               ;;
473            *)
474               new_CFLAGS="$new_CFLAGS $i"
475               ;;
476           esac
477        done
478        CFLAGS="$new_CFLAGS"
479     else
480        AC_MSG_RESULT(no)
481     fi
482     ;;
483  *) AC_MSG_RESULT(no) ;;
484 esac
485
486 dnl We need to override the top-level CFLAGS.  This is how we do it.
487 MY_CFLAGS="$CFLAGS"
488 AC_SUBST(MY_CFLAGS)
489
490 dnl Include defines that have become de facto standard.
491 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
492 AC_DEFINE(SILENT,1,[disables statistics printing])
493 AC_DEFINE(NO_SIGNALS,1,[does not disable signals])
494 AC_DEFINE(ALL_INTERIOR_POINTERS,1,[allows all pointers to the interior of objects to be recognized])
495
496 dnl By default, make the library as general as possible.
497 AC_DEFINE(JAVA_FINALIZATION,1,[make it somewhat safer to finalize objects out of order])
498 AC_DEFINE(GC_GCJ_SUPPORT,1,[include support for gcj])
499 AC_DEFINE(ATOMIC_UNCOLLECTABLE,1,[include code for GC_malloc_atomic_uncollectable])
500
501 AC_ARG_ENABLE(gc-debug,
502 [  --enable-gc-debug    include full support for pointer backtracing etc.],
503 [ if test "$enable_gc_debug" = "yes"; then
504     AC_MSG_WARN("Must define GC_DEBUG and use debug alloc. in clients.")
505     AC_DEFINE(KEEP_BACK_PTRS,1,[Add code to save back pointers])
506     AC_DEFINE(DBG_HDRS_ALL,1,[Make sure that all objects have debug headers])
507     case $host in
508       ia64-*-linux* )
509         AC_DEFINE(MAKE_BACK_GRAPH,1,[Enable GC_PRINT_BACK_HEIGHT environment variable])
510       ;;
511       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
512         AC_DEFINE(MAKE_BACK_GRAPH,1)
513         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
514         AC_DEFINE(SAVE_CALL_COUNT, 8, [number of call frames saved with objects allocated through the debugging interface])
515       ;;
516       i[3456]86-*-dgux*)
517         AC_DEFINE(MAKE_BACK_GRAPH,1)
518       ;;
519     esac 
520   fi])
521
522 if test "${gc_use_mmap}" = "yes"; then
523   AC_DEFINE(USE_MMAP, 1, [use MMAP instead of sbrk to get new memory])
524 fi
525
526 if test -n "$with_cross_host" &&
527    test x"$with_cross_host" != x"no"; then
528   toolexecdir='$(exec_prefix)/$(target_noncanonical)'
529   toolexeclibdir='$(toolexecdir)/lib'
530 else
531   toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
532   toolexeclibdir='$(libdir)'
533 fi
534 multi_os_directory=`$CC -print-multi-os-directory`
535 case $multi_os_directory in
536   .) ;; # Avoid trailing /.
537   *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
538 esac
539 AC_SUBST(toolexecdir)
540 AC_SUBST(toolexeclibdir)
541
542 if test "${multilib}" = "yes"; then
543   multilib_arg="--enable-multilib"
544 else
545   multilib_arg=
546 fi
547
548 AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
549
550 AC_CONFIG_FILES(Makefile include/Makefile)
551 AC_OUTPUT