OSDN Git Service

Index: gcc/ChangeLog
[pf3gnuchains/gcc-fork.git] / boehm-gc / configure.ac
1 # Copyright (c) 1999, 2000, 2001, 2002, 2003 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      *-*-freebsd*)
159         AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
160         AC_DEFINE(GC_FREEBSD_THREADS,1,[support FreeBSD threads])
161         AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
162         THREADLIBS=-pthread
163         ;;
164      *-*-solaris*)
165         AC_DEFINE(GC_SOLARIS_THREADS,1,[support for Solaris (thr_) threads])
166         AC_DEFINE(GC_SOLARIS_PTHREADS,1,[support for Solaris pthreads])
167         ;;
168      *-*-irix*)
169         AC_DEFINE(GC_IRIX_THREADS,1,[support for Irix pthreads])
170         ;;
171      *-*-cygwin*)
172         AC_DEFINE(GC_WIN32_THREADS,1,[support for win32 threads])
173         ;;
174      *-*-darwin*)
175         AC_DEFINE(GC_DARWIN_THREADS,1,[support for Mac OS X pthreads])
176         AC_DEFINE(THREAD_LOCAL_ALLOC,1)
177         if test "${enable_parallel_mark}" = yes; then
178           AC_DEFINE(PARALLEL_MARK,1)
179         fi
180         ;;
181      *-*-osf*)
182         AC_DEFINE(GC_OSF1_THREADS,1,[support for Tru64 pthreads])
183         if test "${enable_parallel_mark}" = yes; then
184           AC_DEFINE(PARALLEL_MARK,1)
185           AC_DEFINE(THREAD_LOCAL_ALLOC,1)
186           # May want to enable it in other cases, too.
187           # Measurements havent yet been done.
188         fi
189         AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
190         THREADLIBS="-lpthread -lrt"
191         ;;
192     esac
193     ;;
194  win32)
195     AC_DEFINE(GC_WIN32_THREADS,1)
196     dnl Old wine getenv may not return NULL for missing entry.
197     dnl Define EMPTY_GETENV_RESULTS here to work around the bug.
198     ;;
199  dgux386)
200     THREADS=dgux386
201 AC_MSG_RESULT($THREADLIBS)
202     # Use pthread GCC  switch
203     THREADLIBS=-pthread
204     if test "${enable_parallel_mark}" = yes; then
205         AC_DEFINE(PARALLEL_MARK,1)
206     fi
207     AC_DEFINE(THREAD_LOCAL_ALLOC,1)
208     AC_DEFINE(GC_DGUX386_THREADS,1,[support for DB/UX on I386 threads])
209     AC_DEFINE(DGUX_THREADS,1,[No description])
210     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
211     AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
212     ;;
213  aix)
214     THREADS=posix
215     THREADLIBS=-lpthread
216     AC_DEFINE(GC_AIX_THREADS,1)
217     AC_DEFINE(_REENTRANT,1)
218     ;;
219  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
220     AC_MSG_ERROR(thread package $THREADS not yet supported)
221     ;;
222  *)
223     AC_MSG_ERROR($THREADS is an unknown thread package)
224     ;;
225 esac
226 AC_SUBST(THREADLIBS)
227
228 case "$host" in
229    powerpc-*-darwin*)
230       powerpc_darwin=true
231       ;;
232 esac
233 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
234
235 # Darwin needs a few extra special tests to deal with variation in the
236 # system headers.
237 case "$host" in
238   powerpc*-*-darwin*)
239     AC_CHECK_MEMBER(ppc_thread_state_t.r0,
240       AC_DEFINE(HAS_PPC_THREAD_STATE_R0,,[ppc_thread_state_t has field r0]),,
241       [#include <mach/thread_status.h>])
242     AC_CHECK_MEMBER(ppc_thread_state_t.__r0,
243       AC_DEFINE(HAS_PPC_THREAD_STATE___R0,,dnl
244         [ppc_thread_state_t has field __r0]),,
245       [#include <mach/thread_status.h>])
246     AC_CHECK_MEMBER(ppc_thread_state64_t.r0,
247       AC_DEFINE(HAS_PPC_THREAD_STATE64_R0,,dnl
248         [ppc_thread_state64_t has field r0]),,
249       [#include <mach/thread_status.h>])
250     AC_CHECK_MEMBER(ppc_thread_state64_t.__r0,
251       AC_DEFINE(HAS_PPC_THREAD_STATE64___R0,,dnl
252         [ppc_thread_state64_t has field __r0]),,
253       [#include <mach/thread_status.h>])
254     ;;
255   i?86*-*-darwin*)
256     AC_CHECK_MEMBER(i386_thread_state_t.eax,
257       AC_DEFINE(HAS_I386_THREAD_STATE_EAX,,dnl
258         [i386_thread_state_t has field eax]),,
259       [#include <mach/thread_status.h>])
260     AC_CHECK_MEMBER(i386_thread_state_t.__eax,
261       AC_DEFINE(HAS_I386_THREAD_STATE___EAX,,dnl
262         [i386_thread_state_t has field __eax]),,
263       [#include <mach/thread_status.h>])
264     ;;
265   *) ;;
266 esac
267
268 # We never want libdl on darwin. It is a fake libdl that just ends up making
269 # dyld calls anyway
270 case "$host" in
271   *-*-darwin*) ;;
272   *)
273     AC_CHECK_LIB(dl, dlopen, EXTRA_TEST_LIBS="$EXTRA_TEST_LIBS -ldl")
274     ;;
275 esac
276
277 AC_SUBST(EXTRA_TEST_LIBS)
278
279 target_all=libgcjgc.la
280 AC_SUBST(target_all)
281
282 dnl If the target is an eCos system, use the appropriate eCos
283 dnl I/O routines.
284 dnl FIXME: this should not be a local option but a global target
285 dnl system; at present there is no eCos target.
286 TARGET_ECOS="no"
287 AC_ARG_WITH(ecos,
288 [  --with-ecos             enable runtime eCos target support],
289 TARGET_ECOS="$with_ecos"
290 )
291
292 addobjs=
293 addlibs=
294 addincludes=
295 addtests=
296 case "$TARGET_ECOS" in
297    no)
298       ;;
299    *)
300       AC_DEFINE(ECOS,1,[Target is ECOS])
301       AM_CPPFLAGS="${AM_CPPFLAGS} -I${TARGET_ECOS}/include"
302       addobjs="$addobjs ecos.lo"
303       ;;
304 esac
305
306 if test "${enable_cplusplus}" = yes; then
307       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
308       addtests="$addtests test_cpp"
309 fi
310
311 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
312
313 AC_SUBST(CXX)
314
315 AC_SUBST(AM_CPPFLAGS)
316
317 # Configuration of shared libraries
318 #
319 AC_MSG_CHECKING(whether to build shared libraries)
320 AC_ENABLE_SHARED
321
322 case "$host" in
323  alpha-*-openbsd*)
324      enable_shared=no
325      AC_MSG_RESULT(no)
326      ;;
327  *)
328      AC_MSG_RESULT(yes)
329      ;;
330 esac
331
332 # Configuration of machine-dependent code
333 #
334 # We don't set NO_EXECUTE_PERMISSION by default because gcj (and
335 # anything else that creates trampolines in gc-allocated memory)
336 # always needs exec permission.  The exceptions to this are IA-64 and
337 # some variations of Power PC, where trampolines don't contain
338 # executable code.
339 #
340 AC_MSG_CHECKING(which machine-dependent code should be used)
341 machdep=
342 case "$host" in
343  alpha*-*-openbsd*)
344     machdep="alpha_mach_dep.lo"
345     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
346        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
347     fi
348     ;;
349  alpha*-*-linux*)
350     machdep="alpha_mach_dep.lo"
351     ;;
352  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
353     AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED,1,[PROC_VDB in Solaris 2.5 gives wrong values for dirty bits])
354     ;;
355  mipstx39-*-elf*)
356     machdep="mips_ultrix_mach_dep.lo"
357     AC_DEFINE(STACKBASE, __stackbase,[No description])
358     AC_DEFINE(DATASTART_IS_ETEXT,1,[No description])
359     ;;
360  mips-dec-ultrix*)
361     machdep="mips_ultrix_mach-dep.lo"
362     ;;
363  mips-nec-sysv*|mips-unknown-sysv*)
364     ;;
365  mips*-*-linux*)
366     ;;
367  mips-*-*)
368     machdep="mips_sgi_mach_dep.lo"
369     ;;
370  sparc-*-netbsd*)
371     machdep="sparc_netbsd_mach_dep.lo"
372     ;;
373  sparc-sun-solaris2.3)
374     machdep="sparc_mach_dep.lo"
375     AC_DEFINE(SUNOS53_SHARED_LIB,1,[Avoid Solaris 5.3 dynamic library bug])
376     ;;
377  sparc*-sun-solaris2.*)
378     machdep="sparc_mach_dep.lo"
379     ;;
380  ia64-*-*)
381     AC_DEFINE(NO_EXECUTE_PERMISSION,1,[cause some or all of the heap to not have execute permission])
382     machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
383     ;;
384 esac
385 if test x"$machdep" = x; then
386 AC_MSG_RESULT($machdep)
387    machdep="mach_dep.lo"
388 fi
389 addobjs="$addobjs $machdep"
390 AC_SUBST(addobjs)
391 AC_SUBST(addincludes)
392 AC_SUBST(addlibs)
393 AC_SUBST(addtests)
394
395 #
396 # Check for AViiON Machines running DGUX
397 #
398 AC_MSG_CHECKING(if host is AViiON running DGUX)
399 ac_is_dgux=no
400 AC_CHECK_HEADER(sys/dg_sys_info.h,
401 [ac_is_dgux=yes;])
402
403 AC_MSG_RESULT($ac_is_dgux)
404     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
405 if test $ac_is_dgux = yes; then
406     if test "$enable_full_debug" = "yes"; then
407       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
408       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
409     else
410       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
411       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
412     fi
413     AC_SUBST(CFLAGS)
414     AC_SUBST(CXXFLAGS)
415 fi
416
417 dnl As of 4.13a2, the collector will not properly work on Solaris when
418 dnl built with gcc and -O.  So we remove -O in the appropriate case.
419 dnl Not needed anymore on Solaris.
420 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
421 case "$host" in
422  *aix*)
423     if test "$GCC" = yes; then
424        AC_MSG_RESULT(yes)
425        new_CFLAGS=
426        for i in $CFLAGS; do
427           case "$i" in
428            -O*)
429               ;;
430            *)
431               new_CFLAGS="$new_CFLAGS $i"
432               ;;
433           esac
434        done
435        CFLAGS="$new_CFLAGS"
436     else
437        AC_MSG_RESULT(no)
438     fi
439     ;;
440  *) AC_MSG_RESULT(no) ;;
441 esac
442
443 dnl We need to override the top-level CFLAGS.  This is how we do it.
444 MY_CFLAGS="$CFLAGS"
445 AC_SUBST(MY_CFLAGS)
446
447 dnl Include defines that have become de facto standard.
448 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
449 AC_DEFINE(SILENT,1,[disables statistics printing])
450 AC_DEFINE(NO_SIGNALS,1,[does not disable signals])
451 AC_DEFINE(ALL_INTERIOR_POINTERS,1,[allows all pointers to the interior of objects to be recognized])
452
453 dnl By default, make the library as general as possible.
454 AC_DEFINE(JAVA_FINALIZATION,1,[make it somewhat safer to finalize objects out of order])
455 AC_DEFINE(GC_GCJ_SUPPORT,1,[include support for gcj])
456 AC_DEFINE(ATOMIC_UNCOLLECTABLE,1,[include code for GC_malloc_atomic_uncollectable])
457
458 dnl This is something of a hack.  When cross-compiling we turn off
459 dnl some functionality. These is only correct when targetting an
460 dnl embedded system.  FIXME.
461 if test -n "${with_cross_host}"; then
462    AC_DEFINE(NO_SIGSET,1,[use empty GC_disable_signals and GC_enable_signals])
463    AC_DEFINE(NO_DEBUGGING,1,[removes GC_dump])
464 fi
465
466 AC_ARG_ENABLE(gc-debug,
467 [  --enable-gc-debug    include full support for pointer backtracing etc.],
468 [ if test "$enable_gc_debug" = "yes"; then
469     AC_MSG_WARN("Must define GC_DEBUG and use debug alloc. in clients.")
470     AC_DEFINE(KEEP_BACK_PTRS,1,[Add code to save back pointers])
471     AC_DEFINE(DBG_HDRS_ALL,1,[Make sure that all objects have debug headers])
472     case $host in
473       ia64-*-linux* )
474         AC_DEFINE(MAKE_BACK_GRAPH,1,[Enable GC_PRINT_BACK_HEIGHT environment variable])
475       ;;
476       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
477         AC_DEFINE(MAKE_BACK_GRAPH,1)
478         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
479         AC_DEFINE(SAVE_CALL_COUNT, 8, [number of call frames saved with objects allocated through the debugging interface])
480       ;;
481       i[3456]86-*-dgux*)
482         AC_DEFINE(MAKE_BACK_GRAPH,1)
483       ;;
484     esac 
485   fi])
486
487 if test "${gc_use_mmap}" = "yes"; then
488   AC_DEFINE(USE_MMAP, 1, [use MMAP instead of sbrk to get new memory])
489 fi
490
491 symver=
492 case "$target" in
493   *-*-linux* )
494     cat > conftest.c <<EOF
495 #include <pthread.h>
496 void *tf (void *arg) { (void) arg; return NULL; }
497 int main (void) { pthread_t th; pthread_create (&th, NULL, tf, NULL); return 0; }
498 EOF
499     if $CC $CFLAGS -pthread -o conftest conftest.c > /dev/null 2>&1; then
500       symver=`readelf -s conftest 2> /dev/null | sed -n '/UND pthread_create@/{s/^.*@//;s/ .*$//;p;q}'`
501     fi
502     rm -f conftest conftest.c
503     ;;
504 esac
505 if test -n "$symver"; then
506   AC_DEFINE_UNQUOTED(GC_PTHREAD_SYM_VERSION, "$symver", [symbol version of pthread_create])
507 fi
508
509
510 if test -n "$with_cross_host" &&
511    test x"$with_cross_host" != x"no"; then
512   toolexecdir='$(exec_prefix)/$(target_noncanonical)'
513   toolexeclibdir='$(toolexecdir)/lib'
514 else
515   toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
516   toolexeclibdir='$(libdir)'
517 fi
518 multi_os_directory=`$CC -print-multi-os-directory`
519 case $multi_os_directory in
520   .) ;; # Avoid trailing /.
521   *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
522 esac
523 AC_SUBST(toolexecdir)
524 AC_SUBST(toolexeclibdir)
525
526 if test "${multilib}" = "yes"; then
527   multilib_arg="--enable-multilib"
528 else
529   multilib_arg=
530 fi
531
532 AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
533
534 AC_CONFIG_FILES(Makefile include/Makefile)
535 AC_OUTPUT