Merge pull request #309 from i59/patch-1
[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([1.9 no-define foreign])
21 AC_CONFIG_SRCDIR(gcj_mlc.c)
22 AC_CONFIG_MACRO_DIR([m4])
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* | *-*-nacl*)
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         AC_DEFINE(THREAD_LOCAL_ALLOC)
126         ;;
127      *-*-solaris*)
128         AC_DEFINE(GC_SOLARIS_THREADS)
129         AC_DEFINE(GC_SOLARIS_PTHREADS)
130         ;;
131      *-*-irix*)
132         AC_DEFINE(GC_IRIX_THREADS)
133         ;;
134      *-*-cygwin*)
135         AC_DEFINE(GC_WIN32_THREADS)
136         ;;
137      *-*-darwin*)
138         AC_DEFINE(GC_DARWIN_THREADS)
139         AC_DEFINE(THREAD_LOCAL_ALLOC)
140         if test "${enable_parallel_mark}" = yes; then
141           AC_DEFINE(PARALLEL_MARK)
142         fi
143         ;;
144      *-*-netbsd*)
145         AC_DEFINE(GC_NETBSD_THREADS)
146         if test "${enable_parallel_mark}" = yes; then
147           AC_DEFINE(PARALLEL_MARK)
148         fi
149         AC_DEFINE(THREAD_LOCAL_ALLOC)
150         ;;
151      *-*-openbsd*)
152         AC_DEFINE(GC_OPENBSD_THREADS)
153         if test "${enable_parallel_mark}" = yes; then
154           AC_DEFINE(PARALLEL_MARK)
155         fi
156         AC_DEFINE(THREAD_LOCAL_ALLOC)
157         ;;
158      *-*-osf*)
159         AC_DEFINE(GC_OSF1_THREADS)
160         if test "${enable_parallel_mark}" = yes; then
161           AC_DEFINE(PARALLEL_MARK)
162           AC_DEFINE(THREAD_LOCAL_ALLOC)
163           # May want to enable it in other cases, too.
164           # Measurements havent yet been done.
165         fi
166         INCLUDES="$INCLUDES -pthread"
167         THREADDLLIBS="-lpthread -lrt"
168         ;;
169       *)
170         AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
171         ;;
172     esac
173     ;;
174  win32)
175     AC_DEFINE(GC_WIN32_THREADS)
176     dnl Wine getenv may not return NULL for missing entry
177     AC_DEFINE(NO_GETENV)
178         if test "${enable_win32_dllmain}" = yes; then
179            AC_DEFINE(GC_INSIDE_DLL)
180         fi
181     ;;
182  dgux386)
183     THREADS=dgux386
184     AC_MSG_RESULT($THREADDLLIBS)
185     # Use pthread GCC  switch
186     THREADDLLIBS=-pthread
187     if test "${enable_parallel_mark}" = yes; then
188         AC_DEFINE(PARALLEL_MARK)
189     fi
190     AC_DEFINE(THREAD_LOCAL_ALLOC)
191     AC_DEFINE(GC_DGUX386_THREADS)
192     AC_DEFINE(DGUX_THREADS)
193     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
194     INCLUDES="-pthread $INCLUDES"
195     ;;
196  aix)
197     THREADS=posix
198     THREADDLLIBS=-lpthread
199     AC_DEFINE(GC_AIX_THREADS)
200     AC_DEFINE(_REENTRANT)
201     ;;
202  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
203     AC_MSG_ERROR(thread package $THREADS not yet supported)
204     ;;
205  *)
206     AC_MSG_ERROR($THREADS is an unknown thread package)
207     ;;
208 esac
209 AC_SUBST(THREADDLLIBS)
210
211 case "$host" in 
212    powerpc-*-darwin*)
213       powerpc_darwin=true
214       ;;
215 esac
216 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
217
218 AC_MSG_CHECKING(for xlc)
219 AC_TRY_COMPILE([],[
220  #ifndef __xlC__
221  # error
222  #endif
223 ], [compiler_xlc=yes], [compiler_xlc=no])
224 AC_MSG_RESULT($compiler_xlc)
225 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
226 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
227   # the darwin stack-frame-walking code is completely broken on xlc
228   AC_DEFINE(DARWIN_DONT_PARSE_STACK)
229 fi
230
231 # We never want libdl on darwin. It is a fake libdl that just ends up making
232 # dyld calls anyway
233 case "$host" in
234   *-*-darwin*) ;;
235   *) 
236     AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
237     ;;
238 esac
239
240 AC_SUBST(EXTRA_TEST_LIBS)
241
242 target_all=libgc.la
243 AC_SUBST(target_all)
244
245 dnl If the target is an eCos system, use the appropriate eCos
246 dnl I/O routines.
247 dnl FIXME: this should not be a local option but a global target
248 dnl system; at present there is no eCos target.
249 TARGET_ECOS="no"
250 AC_ARG_WITH(ecos,
251 [  --with-ecos             enable runtime eCos target support],
252 TARGET_ECOS="$with_ecos"
253 )
254
255 addobjs=
256 addlibs=
257 addincludes=
258 addtests=
259 CXXINCLUDES=
260 case "$TARGET_ECOS" in
261    no)
262       ;;
263    *)
264       AC_DEFINE(ECOS)
265       CXXINCLUDES="-I${TARGET_ECOS}/include"
266       addobjs="$addobjs ecos.lo"
267       ;;
268 esac
269
270 if test "${enable_cplusplus}" = yes; then
271       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
272       addtests="$addtests test_cpp"
273 fi
274
275 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
276
277 AC_SUBST(CXX)
278
279 AC_SUBST(INCLUDES)
280 AC_SUBST(CXXINCLUDES)
281
282 # Configuration of shared libraries
283 #
284 AC_MSG_CHECKING(whether to build shared libraries)
285 AC_ENABLE_SHARED
286
287 case "$host" in
288  alpha-*-openbsd*)
289      enable_shared=no
290      AC_MSG_RESULT(no)
291      ;;
292  *)
293      AC_MSG_RESULT(yes)
294      ;;
295 esac
296
297 # Configuration of machine-dependent 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     AC_DEFINE(NO_EXECUTE_PERMISSION)
329     ;;
330  sparc-*-netbsd*)
331     machdep="sparc_netbsd_mach_dep.lo"
332     ;;
333  sparc-sun-solaris2.3)
334     machdep="sparc_mach_dep.lo"
335     AC_DEFINE(SUNOS53_SHARED_LIB)
336     ;;
337  sparc*-sun-solaris2.*)
338     machdep="sparc_mach_dep.lo"
339     ;;
340  ia64-*-*)
341      machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
342         target_ia64=true
343     ;;
344  *-*-nacl*)
345     AC_DEFINE(NO_EXECUTE_PERMISSION)
346     ;;
347 esac
348 if test x"$machdep" = x; then
349 AC_MSG_RESULT($machdep)
350    machdep="mach_dep.lo"
351 fi
352 addobjs="$addobjs $machdep"
353 #
354 # Adding object files directly to _LIBADD breaks -j builds, so we need to add the sources
355 # instead, but _SOURCES can't contain autoconf substitutions, so add them using automake
356 # conditionals.
357 #
358 #AC_SUBST(addobjs)
359 AC_SUBST(addincludes)
360 AC_SUBST(addlibs)
361 AC_SUBST(addtests)
362
363 AM_CONDITIONAL(TARGET_IA64,test x$target_ia64 = xtrue)
364
365 AC_PROG_LIBTOOL
366 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
367 DOLT
368
369 #
370 # Check for AViiON Machines running DGUX
371 #
372 ac_is_dgux=no
373 AC_CHECK_HEADER(sys/dg_sys_info.h,
374 [ac_is_dgux=yes;])
375
376     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
377 if test $ac_is_dgux = yes; then
378     if test "$enable_full_debug" = "yes"; then
379       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
380       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
381     else
382       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
383       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
384     fi
385     AC_SUBST(CFLAGS)
386     AC_SUBST(CXXFLAGS)
387 fi
388
389 dnl We use these options to decide which functions to include.
390 AC_ARG_WITH(target-subdir,
391 [  --with-target-subdir=SUBDIR
392                           configuring with a cross compiler])
393 AC_ARG_WITH(cross-host,
394 [  --with-cross-host=HOST  configuring with a cross compiler])
395
396 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
397 # it is actually a problem, because the compiler we're passed can't
398 # necessarily do a full link.  So we fool automake here.
399 if false; then
400   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
401   # to nothing, so nothing would remain between `then' and `fi' if it
402   # were not for the `:' below.
403   :
404   AC_EXEEXT
405 fi
406
407 AC_MSG_CHECKING([for threads package to use])
408 AC_MSG_RESULT($THREADS)
409
410 dnl As of 4.13a2, the collector will not properly work on Solaris when
411 dnl built with gcc and -O.  So we remove -O in the appropriate case.
412 dnl Not needed anymore on Solaris.
413 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
414 case "$host" in
415  *aix*)
416     if test "$GCC" = yes; then
417        AC_MSG_RESULT(yes)
418        new_CFLAGS=
419        for i in $CFLAGS; do
420           case "$i" in
421            -O*)
422               ;;
423            *)
424               new_CFLAGS="$new_CFLAGS $i"
425               ;;
426           esac
427        done
428        CFLAGS="$new_CFLAGS"
429     else
430        AC_MSG_RESULT(no)
431     fi
432     ;;
433  *) AC_MSG_RESULT(no) ;;
434 esac
435
436 dnl We need to override the top-level CFLAGS.  This is how we do it.
437 MY_CFLAGS="$CFLAGS"
438 AC_SUBST(MY_CFLAGS)
439
440 dnl Include defines that have become de facto standard.
441 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
442 AC_DEFINE(SILENT)
443 AC_DEFINE(NO_SIGNALS)
444 AC_DEFINE(NO_EXECUTE_PERMISSION)
445 dnl AC_DEFINE(ALL_INTERIOR_POINTERS)
446
447 dnl By default, make the library as general as possible.
448 AC_DEFINE(JAVA_FINALIZATION)
449 AC_DEFINE(GC_GCJ_SUPPORT)
450 AC_DEFINE(ATOMIC_UNCOLLECTABLE)
451
452 dnl This is something of a hack.  When cross-compiling we turn off
453 dnl some functionality.  We also enable the "small" configuration.
454 dnl These is only correct when targetting an embedded system.  FIXME.
455 if test -n "${with_cross_host}"; then
456    AC_DEFINE(NO_SIGSET)
457    AC_DEFINE(NO_CLOCK)
458    AC_DEFINE(SMALL_CONFIG)
459    AC_DEFINE(NO_DEBUGGING)
460 fi
461
462 UNWINDLIBS=
463 AC_ARG_ENABLE(full-debug,
464 [  --enable-full-debug  include full support for pointer backtracing etc.],
465 [ if test "$enable_full_debug" = "yes"; then
466     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
467     AC_DEFINE(KEEP_BACK_PTRS)
468     AC_DEFINE(DBG_HDRS_ALL)
469     case $host in
470       ia64-*-linux* )
471         AC_DEFINE(MAKE_BACK_GRAPH)
472         AC_DEFINE(SAVE_CALL_COUNT, 8)
473         AC_CHECK_LIB(unwind, backtrace, [
474           AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
475           UNWINDLIBS=-lunwind
476           AC_MSG_WARN("Client code may need to link against libunwind.")
477         ])
478       ;;
479       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
480         AC_DEFINE(MAKE_BACK_GRAPH)
481         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
482         AC_DEFINE(SAVE_CALL_COUNT, 8)
483       ;;
484       i[3456]86-*-dgux*)
485         AC_DEFINE(MAKE_BACK_GRAPH)
486       ;;
487     esac ]
488   fi)
489
490 AC_SUBST(UNWINDLIBS)
491
492 AC_ARG_ENABLE(redirect-malloc,
493 [  --enable-redirect-malloc  redirect malloc and friends to GC routines])
494
495 if test "${enable_redirect_malloc}" = yes; then
496     if test "${enable_full_debug}" = yes; then
497         AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement)
498         AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement)
499         AC_DEFINE(REDIRECT_FREE, GC_debug_free)
500     else
501         AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
502     fi
503 fi
504
505 AC_DEFINE(_IN_LIBGC)
506
507 AC_ARG_ENABLE(gc-assertions,
508 [  --enable-gc-assertions  collector-internal assertion checking])
509 if test "${enable_gc_assertions}" = yes; then
510     AC_DEFINE(GC_ASSERTIONS)
511 fi
512
513 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet libgc build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
514 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
515
516 if test "${multilib}" = "yes"; then
517   multilib_arg="--enable-multilib"
518 else
519   multilib_arg=
520 fi
521
522 if test x$enable_quiet_build = xyes; then
523    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])
524    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])
525 fi
526
527 AC_OUTPUT(Makefile
528 m4/Makefile
529 include/Makefile
530 include/private/Makefile
531 doc/Makefile,,
532 srcdir=${srcdir}
533 host=${host}
534 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
535 CC="${CC}"
536 DEFS="$DEFS"
537 )