OSDN Git Service

38a9c31eeeccf21dc454381188da0e0981f5deba
[pf3gnuchains/gcc-fork.git] / boehm-gc / configure.in
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.13)
19 AC_INIT(gcj_mlc.c)
20
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 dnl Can't be done in GC_CONFIGURE because that confuses automake.
28 AC_CONFIG_AUX_DIR(.)
29
30 dnl Default to --enable-multilib
31 AC_ARG_ENABLE(multilib,
32 [  --enable-multilib       build many library versions (default)],
33 [case "${enableval}" in
34   yes) multilib=yes ;;
35   no)  multilib=no ;;
36   *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
37  esac], [multilib=yes])dnl
38
39 dnl We may get other options which we don't document:
40 dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
41
42 dnl I needed to add the -n test to allow configuration in src directory - HB
43 if test "[$]{srcdir}" = "."; then
44   if test "[$]{with_target_subdir}" != "." -a -n "[$]{with_target_subdir}"; then
45     gc_basedir="[$]{srcdir}/[$]{with_multisrctop}../."
46   else
47     gc_basedir="[$]{srcdir}/[$]{with_multisrctop}."
48   fi
49 else
50   gc_basedir="[$]{srcdir}/."
51 fi
52 AC_SUBST(gc_basedir)
53 AC_CONFIG_AUX_DIR($gc_basedir/..)
54 if :; then :; else
55   # This overrides the previous occurrence for automake, but not for
56   # autoconf, which is exactly what we want.
57   AC_CONFIG_AUX_DIR(..)
58 fi
59
60 AC_CANONICAL_SYSTEM
61
62 # Get the 'noncanonical' system names.
63 sinclude(../config/acx.m4)
64 _GCC_TOPLEV_NONCANONICAL_BUILD
65 _GCC_TOPLEV_NONCANONICAL_HOST
66 _GCC_TOPLEV_NONCANONICAL_TARGET
67
68 # This works around an automake problem.
69 mkinstalldirs="`cd $ac_aux_dir && ${PWDCMD-pwd}`/mkinstalldirs"
70 AC_SUBST(mkinstalldirs)
71
72 GC_CONFIGURE(.)
73
74 AM_PROG_LIBTOOL
75
76 dnl We use these options to decide which functions to include.
77 AC_ARG_WITH(target-subdir,
78 [  --with-target-subdir=SUBDIR
79                           configuring with a cross compiler])
80 AC_ARG_WITH(cross-host,
81 [  --with-cross-host=HOST  configuring with a cross compiler])
82
83 AM_MAINTAINER_MODE
84 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
85 # it is actually a problem, because the compiler we're passed can't
86 # necessarily do a full link.  So we fool automake here.
87 if false; then
88   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
89   # to nothing, so nothing would remain between `then' and `fi' if it
90   # were not for the `:' below.
91   :
92   AC_EXEEXT
93 fi
94
95 AC_MSG_CHECKING([for thread model used by GCC])
96 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
97 if test -z "$THREADS"; then
98    THREADS=no
99 fi
100 AC_MSG_RESULT([$THREADS])
101
102 AC_ARG_ENABLE(parallel-mark,
103 [  --enable-parallel-mark       parallelize marking and free list construction],
104    [case "$THREADS" in
105       no | none | single)
106         AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
107         ;;
108     esac]
109 )
110
111 INCLUDES="-I`cd $srcdir && ${PWDCMD-pwd}`/include"
112 THREADLIBS=
113 case "$THREADS" in
114  no | none | single)
115     THREADS=none
116     ;;
117  posix | pthreads)
118     THREADS=posix
119     THREADLIBS=-lpthread
120     case "$host" in
121      x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha-*-linux*)
122         AC_DEFINE(GC_LINUX_THREADS)
123         AC_DEFINE(_REENTRANT)
124         if test "${enable_parallel_mark}" = yes; then
125           AC_DEFINE(PARALLEL_MARK)
126         fi
127         AC_DEFINE(THREAD_LOCAL_ALLOC)
128         ;;
129      *-*-linux*)
130         AC_DEFINE(GC_LINUX_THREADS)
131         AC_DEFINE(_REENTRANT)
132         ;;
133      *-*-aix*)
134         AC_DEFINE(GC_AIX_THREADS)
135         AC_DEFINE(_REENTRANT)
136         ;;
137      *-*-hpux*)
138         AC_MSG_WARN("Only HP/UX 11 threads are supported.")
139         AC_DEFINE(GC_HPUX_THREADS)
140         AC_DEFINE(_POSIX_C_SOURCE,199506L)
141         if test "${enable_parallel_mark}" = yes; then
142           AC_DEFINE(PARALLEL_MARK)
143         fi
144         AC_DEFINE(THREAD_LOCAL_ALLOC)
145         THREADLIBS="-lpthread -lrt"
146         ;;
147      *-*-freebsd*)
148         AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
149         AC_DEFINE(GC_FREEBSD_THREADS)
150         INCLUDES="$INCLUDES -pthread"
151         THREADLIBS=-pthread
152         ;;
153      *-*-solaris*)
154         AC_DEFINE(GC_SOLARIS_THREADS)
155         AC_DEFINE(GC_SOLARIS_PTHREADS)
156         ;;
157      *-*-irix*)
158         AC_DEFINE(GC_IRIX_THREADS)
159         ;;
160      *-*-cygwin*)
161         AC_DEFINE(GC_WIN32_THREADS)
162         ;;
163      *-*-darwin*)
164         AC_DEFINE(GC_DARWIN_THREADS)
165         AC_DEFINE(THREAD_LOCAL_ALLOC)
166         if test "${enable_parallel_mark}" = yes; then
167           AC_DEFINE(PARALLEL_MARK)
168         fi
169         ;;
170      *-*-osf*)
171         AC_DEFINE(GC_OSF1_THREADS)
172         if test "${enable_parallel_mark}" = yes; then
173           AC_DEFINE(PARALLEL_MARK)
174           AC_DEFINE(THREAD_LOCAL_ALLOC)
175           # May want to enable it in other cases, too.
176           # Measurements havent yet been done.
177         fi
178         INCLUDES="$INCLUDES -pthread"
179         THREADLIBS="-lpthread -lrt"
180         ;;
181     esac
182     ;;
183  win32)
184     AC_DEFINE(GC_WIN32_THREADS)
185     dnl Old wine getenv may not return NULL for missing entry.
186     dnl Define EMPTY_GETENV_RESULTS here to work around the bug.
187     ;;
188  dgux386)
189     THREADS=dgux386
190 AC_MSG_RESULT($THREADLIBS)
191     # Use pthread GCC  switch
192     THREADLIBS=-pthread
193     if test "${enable_parallel_mark}" = yes; then
194         AC_DEFINE(PARALLEL_MARK)
195     fi
196     AC_DEFINE(THREAD_LOCAL_ALLOC)
197     AC_DEFINE(GC_DGUX386_THREADS)
198     AC_DEFINE(DGUX_THREADS)
199     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
200     INCLUDES="-pthread $INCLUDES"
201     ;;
202  aix)
203     THREADS=posix
204     THREADLIBS=-lpthread
205     AC_DEFINE(GC_AIX_THREADS)
206     AC_DEFINE(_REENTRANT)
207     ;;
208  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
209     AC_MSG_ERROR(thread package $THREADS not yet supported)
210     ;;
211  *)
212     AC_MSG_ERROR($THREADS is an unknown thread package)
213     ;;
214 esac
215 AC_SUBST(THREADLIBS)
216
217 case "$host" in 
218    powerpc-*-darwin*)
219       powerpc_darwin=true
220       ;;
221 esac
222 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
223
224 # We never want libdl on darwin. It is a fake libdl that just ends up making
225 # dyld calls anyway
226 case "$host" in
227   *-*-darwin*) ;;
228   *) 
229     AC_CHECK_LIB(dl, dlopen, EXTRA_TEST_LIBS="$EXTRA_TEST_LIBS -ldl")
230     ;;
231 esac
232
233 AC_SUBST(EXTRA_TEST_LIBS)
234
235 target_all=libgcjgc.la
236 AC_SUBST(target_all)
237 AC_SUBST(target_noncanonical)
238
239 dnl If the target is an eCos system, use the appropriate eCos
240 dnl I/O routines.
241 dnl FIXME: this should not be a local option but a global target
242 dnl system; at present there is no eCos target.
243 TARGET_ECOS="no"
244 AC_ARG_WITH(ecos,
245 [  --with-ecos             enable runtime eCos target support],
246 TARGET_ECOS="$with_ecos"
247 )
248
249 addobjs=
250 addlibs=
251 addincludes=
252 addtests=
253 CXXINCLUDES=
254 case "$TARGET_ECOS" in
255    no)
256       ;;
257    *)
258       AC_DEFINE(ECOS)
259       CXXINCLUDES="-I${TARGET_ECOS}/include"
260       addobjs="$addobjs ecos.lo"
261       ;;
262 esac
263
264 if test "${enable_cplusplus}" = yes; then
265       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
266       addtests="$addtests test_cpp"
267 fi
268
269 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
270
271 AC_SUBST(CXX)
272
273 AC_SUBST(INCLUDES)
274 AC_SUBST(CXXINCLUDES)
275
276 # Configuration of shared libraries
277 #
278 AC_MSG_CHECKING(whether to build shared libraries)
279 AC_ENABLE_SHARED
280
281 case "$host" in
282  alpha-*-openbsd*)
283      enable_shared=no
284      AC_MSG_RESULT(no)
285      ;;
286  *)
287      AC_MSG_RESULT(yes)
288      ;;
289 esac
290
291 # Configuration of machine-dependent code
292 #
293 # We don't set NO_EXECUTE_PERMISSION by default because gcj (and
294 # anything else that creates trampolines in gc-allocated memory)
295 # always needs exec permission.  The exceptions to this are IA-64 and
296 # some variations of Power PC, where trampolines don't contain
297 # executable code.
298 #
299 AC_MSG_CHECKING(which machine-dependent code should be used) 
300 machdep=
301 case "$host" in
302  alpha*-*-openbsd*)
303     machdep="alpha_mach_dep.lo"
304     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
305        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
306     fi
307     ;;
308  alpha*-*-linux*)
309     machdep="alpha_mach_dep.lo"
310     ;;
311  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
312     AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
313     ;;
314  mipstx39-*-elf*)
315     machdep="mips_ultrix_mach_dep.lo"
316     AC_DEFINE(STACKBASE, __stackbase)
317     AC_DEFINE(DATASTART_IS_ETEXT)
318     ;;
319  mips-dec-ultrix*)
320     machdep="mips_ultrix_mach-dep.lo"
321     ;;
322  mips-nec-sysv*|mips-unknown-sysv*)
323     ;;
324  mips*-*-linux*) 
325     ;; 
326  mips-*-*)
327     machdep="mips_sgi_mach_dep.lo"
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     AC_DEFINE(NO_EXECUTE_PERMISSION)
341     machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
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 AC_SUBST(addobjs)
350 AC_SUBST(addincludes)
351 AC_SUBST(addlibs)
352 AC_SUBST(addtests)
353
354 AC_PROG_LIBTOOL
355
356 #
357 # Check for AViiON Machines running DGUX
358 #
359 AC_MSG_CHECKING(if host is AViiON running DGUX)
360 ac_is_dgux=no
361 AC_CHECK_HEADER(sys/dg_sys_info.h,
362 [ac_is_dgux=yes;])
363
364 AC_MSG_RESULT($ac_is_dgux) 
365     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
366 if test $ac_is_dgux = yes; then
367     if test "$enable_full_debug" = "yes"; then
368       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
369       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
370     else
371       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
372       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
373     fi
374     AC_SUBST(CFLAGS)
375     AC_SUBST(CXXFLAGS)
376 fi
377
378 dnl We use these options to decide which functions to include.
379 AC_ARG_WITH(target-subdir,
380 [  --with-target-subdir=SUBDIR
381                           configuring with a cross compiler])
382 AC_ARG_WITH(cross-host,
383 [  --with-cross-host=HOST  configuring with a cross compiler])
384
385 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
386 # it is actually a problem, because the compiler we're passed can't
387 # necessarily do a full link.  So we fool automake here.
388 if false; then
389   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
390   # to nothing, so nothing would remain between `then' and `fi' if it
391   # were not for the `:' below.
392   :
393   AC_EXEEXT
394 fi
395
396 dnl As of 4.13a2, the collector will not properly work on Solaris when
397 dnl built with gcc and -O.  So we remove -O in the appropriate case.
398 dnl
399 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
400 case "$host" in
401  sparc-sun-solaris2*|*aix*)
402     if test "$GCC" = yes; then
403        AC_MSG_RESULT(yes)
404        new_CFLAGS=
405        for i in $CFLAGS; do
406           case "$i" in
407            -O*)
408               ;;
409            *)
410               new_CFLAGS="$new_CFLAGS $i"
411               ;;
412           esac
413        done
414        CFLAGS="$new_CFLAGS"
415     else
416        AC_MSG_RESULT(no)
417     fi
418     ;;
419  *) AC_MSG_RESULT(no) ;;
420 esac
421
422 dnl We need to override the top-level CFLAGS.  This is how we do it.
423 MY_CFLAGS="$CFLAGS"
424 AC_SUBST(MY_CFLAGS)
425
426 dnl Include defines that have become de facto standard.
427 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
428 AC_DEFINE(SILENT)
429 AC_DEFINE(NO_SIGNALS)
430 AC_DEFINE(ALL_INTERIOR_POINTERS)
431
432 dnl By default, make the library as general as possible.
433 AC_DEFINE(JAVA_FINALIZATION)
434 AC_DEFINE(GC_GCJ_SUPPORT)
435 AC_DEFINE(ATOMIC_UNCOLLECTABLE)
436
437 dnl This is something of a hack.  When cross-compiling we turn off
438 dnl some functionality. These is only correct when targetting an
439 dnl embedded system.  FIXME.
440 if test -n "${with_cross_host}"; then
441    AC_DEFINE(NO_SIGSET)
442    AC_DEFINE(NO_DEBUGGING)
443 fi
444
445 AC_ARG_ENABLE(full-debug,
446 [  --enable-full-debug  include full support for pointer backtracing etc.],
447 [ if test "$enable_full_debug" = "yes"; then
448     AC_MSG_WARN("Must define GC_DEBUG and use debug alloc. in clients.")
449     AC_DEFINE(KEEP_BACK_PTRS)
450     AC_DEFINE(DBG_HDRS_ALL)
451     case $host in
452       ia64-*-linux* )
453         AC_DEFINE(MAKE_BACK_GRAPH)
454       ;;
455       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
456         AC_DEFINE(MAKE_BACK_GRAPH)
457         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
458         AC_DEFINE(SAVE_CALL_COUNT, 8)
459       ;;
460       i[3456]86-*-dgux*)
461         AC_DEFINE(MAKE_BACK_GRAPH)
462       ;;
463     esac ]
464   fi)
465
466 if test -n "$with_cross_host" &&
467    test x"$with_cross_host" != x"no"; then
468   toolexecdir='$(exec_prefix)/$(target_noncanonical)'
469   toolexeclibdir='$(toolexecdir)/lib'
470 else
471   toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
472   toolexeclibdir='$(libdir)'
473 fi
474 multi_os_directory=`$CC -print-multi-os-directory`
475 case $multi_os_directory in
476   .) ;; # Avoid trailing /.
477   *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
478 esac
479 AC_SUBST(toolexecdir)
480 AC_SUBST(toolexeclibdir)
481
482 if test "${multilib}" = "yes"; then
483   multilib_arg="--enable-multilib"
484 else
485   multilib_arg=
486 fi
487
488 AC_OUTPUT(Makefile include/Makefile, [
489 dnl Put all the -I and -D options in a file.
490 echo "$INCLUDES $DEFS" > boehm-cflags
491
492 if test -n "$CONFIG_FILES"; then
493   LD="${ORIGINAL_LD_FOR_MULTILIBS}"
494   ac_file=Makefile . ${gc_basedir}/../config-ml.in
495 fi],
496 srcdir=${srcdir}
497 host=${host}
498 target=${target}
499 with_multisubdir=${with_multisubdir}
500 ac_configure_args="${multilib_arg} ${ac_configure_args}"
501 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
502 gc_basedir=${gc_basedir}
503 CC="${CC}"
504 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
505 DEFS="$DEFS"
506 INCLUDES="$INCLUDES"
507 )