Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libobjc / configure.ac
blobb2796a3595b4eddd0e3e4a2da4d731a422a017c8
1 # Process this file with autoconf to produce a configure script.
2 #   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004
3 #   Free Software Foundation, Inc.
4 #   Originally contributed by Dave Love (d.love@dl.ac.uk).
6 #This file is part of GCC.
8 #GCC is free software; you can redistribute it and/or modify
9 #it under the terms of the GNU General Public License as published by
10 #the Free Software Foundation; either version 2, or (at your option)
11 #any later version.
13 #GCC is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #GNU General Public License for more details.
18 #You should have received a copy of the GNU General Public License
19 #along with GCC; see the file COPYING.  If not, write to
20 #the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 #02111-1307, USA.
23 AC_PREREQ(2.59)
24 AC_INIT(package-unused, version-unused,, libobjc)
25 AC_CONFIG_SRCDIR([objc/objc.h])
27 # We need the following definitions because AC_PROG_LIBTOOL relies on them
28 PACKAGE=libobjc
29 # Version is pulled out to make it a bit easier to change using sed.
30 VERSION=1:0:0
31 AC_SUBST(VERSION)
33 # This works around the fact that libtool configuration may change LD
34 # for this particular configuration, but some shells, instead of
35 # keeping the changes in LD private, export them just because LD is
36 # exported.
37 ORIGINAL_LD_FOR_MULTILIBS=$LD
39 # -------
40 # Options
41 # -------
43 # Default to --enable-multilib
44 AC_ARG_ENABLE(multilib,
45   [  --enable-multilib       build hella library versions (default)],
46   [case "${enableval}" in
47     yes) multilib=yes ;;
48     no)  multilib=no ;;
49     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
50    esac],
51   [multilib=yes])
53 # We use these options to decide which functions to include.
54 AC_ARG_WITH(target-subdir,
55 [  --with-target-subdir=SUBDIR
56                            configuring in a subdirectory])
57 AC_ARG_WITH(cross-host,
58 [  --with-cross-host=HOST  configuring with a cross compiler])
60 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
61 AC_ARG_ENABLE(version-specific-runtime-libs,
62 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
63 [case "$enableval" in
64  yes) version_specific_libs=yes ;;
65  no)  version_specific_libs=no ;;
66  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
67  esac],
68 [version_specific_libs=no])
69 AC_MSG_RESULT($version_specific_libs)
71 AC_ARG_ENABLE(objc-gc,
72 [  --enable-objc-gc       enable the use of Boehm's garbage collector with
73                           the GNU Objective-C runtime.],
74 [case $enable_objc_gc in
75   no) OBJC_BOEHM_GC='' ;;
76   *) OBJC_BOEHM_GC=libobjc_gc.la ;;
77 esac],
78 [OBJC_BOEHM_GC=''])
79 AC_SUBST(OBJC_BOEHM_GC)
81 # -----------
82 # Directories
83 # -----------
85 # When building with srcdir == objdir, links to the source files will
86 # be created in directories within the target_subdir.  We have to
87 # adjust toplevel_srcdir accordingly, so that configure finds
88 # install-sh and other auxiliary files that live in the top-level
89 # source directory.
90 if test "${srcdir}" = "."; then
91   if test -z "${with_target_subdir}"; then
92     toprel=".."
93   else
94     if test "${with_target_subdir}" != "."; then
95       toprel="${with_multisrctop}../.."
96     else
97       toprel="${with_multisrctop}.."
98     fi
99   fi
100 else
101   toprel=".."
103 AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
104 toplevel_srcdir=\${srcdir}/$toprel
105 AC_SUBST(toplevel_srcdir)
107 AC_CANONICAL_SYSTEM
108 ACX_NONCANONICAL_TARGET
110 # Export source directory.
111 # These need to be absolute paths, yet at the same time need to
112 # canonicalize only relative paths, because then amd will not unmount
113 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
114 case $srcdir in
115   [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
116   *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
117 esac
118 AC_SUBST(glibcpp_srcdir)
120 TL_AC_GCC_VERSION([$srcdir/..])
122 # Calculate toolexeclibdir
123 # Also toolexecdir, though it's only used in toolexeclibdir
124 case ${version_specific_libs} in
125   yes)
126     # Need the gcc compiler version to know where to install libraries
127     # and header files if --enable-version-specific-runtime-libs option
128     # is selected.
129     toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
130     toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
131     ;;
132   no)
133     if test -n "$with_cross_host" &&
134        test x"$with_cross_host" != x"no"; then
135       # Install a library built with a cross compiler in tooldir, not libdir.
136       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
137       toolexeclibdir='$(toolexecdir)/lib'
138     else
139       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
140       toolexeclibdir='$(libdir)'
141     fi
142     multi_os_directory=`$CC -print-multi-os-directory`
143     case $multi_os_directory in
144       .) ;; # Avoid trailing /.
145       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
146     esac
147     ;;
148 esac
149 AC_SUBST(toolexecdir)
150 AC_SUBST(toolexeclibdir)
152 # Figure out if we want to name the include directory and the
153 #  library name changes differently.
154 includedirname=include
155 libext=
156 case "${host}" in
157   *-darwin*)
158     # Darwin is the only target so far that needs a different include directory.
159     includedirname=include-gnu-runtime
160     libext=-gnu
161     ;;
162 esac
163 AC_SUBST(includedirname)
164 AC_SUBST(libext)
166 AC_CONFIG_HEADERS(config.h)
168 # --------
169 # Programs
170 # --------
172 GCC_NO_EXECUTABLES
174 # We must force CC to /not/ be a precious variable; otherwise
175 # the wrong, non-multilib-adjusted value will be used in multilibs.
176 # As a side effect, we have to subst CFLAGS ourselves.
177 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
178 m4_define([_AC_ARG_VAR_PRECIOUS],[])
179 AC_PROG_CC
180 m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
182 AC_SUBST(CFLAGS)
184 AC_CHECK_TOOL(AS, as)
185 AC_CHECK_TOOL(AR, ar)
186 AC_CHECK_TOOL(RANLIB, ranlib, :)
187 AC_PROG_INSTALL
189 AM_MAINTAINER_MODE
191 # Enable Win32 DLL on MS Windows - FIXME
192 AC_LIBTOOL_WIN32_DLL
194 AC_PROG_LIBTOOL
196 AM_PROG_CC_C_O
198 AC_PROG_MAKE_SET
200 # -------
201 # Headers
202 # -------
204 # Sanity check for the cross-compilation case:
205 AC_CHECK_HEADER(stdio.h,:,
206   [AC_MSG_ERROR([Can't find stdio.h.
207 You must have a usable C system for the target already installed, at least
208 including headers and, preferably, the library, before you can configure
209 the Objective C runtime system.  If necessary, install gcc now with 
210 \`LANGUAGES=c', then the target library, then build with \`LANGUAGES=objc'.])])
212 AC_HEADER_STDC
214 AC_CHECK_HEADERS(sched.h)
216 # -----------
217 # Miscellanea
218 # -----------
220 # Determine CFLAGS for gthread.
221 # FIXME: the current implementation is dependent on the 'r' variable
222 # passed down from the top level
223 AC_CACHE_CHECK([for gthread cflags],objc_cv_gthread_flags,
224 [if test -f "$r"/gcc/Makefile
225 then
226   objc_cv_gthread_flags=`grep \^GTHREAD_FLAGS "$r"/gcc/Makefile | awk -F= '{ print $2 }'`
227 else
228   AC_MSG_ERROR([not found])
229 fi])
230 GTHREAD_FLAGS=$objc_cv_gthread_flags
231 AC_SUBST(GTHREAD_FLAGS)
233 AC_MSG_CHECKING([for exception model to use])
234 AC_LANG_PUSH(C)
235 AC_ARG_ENABLE(sjlj-exceptions,
236   AS_HELP_STRING([--enable-sjlj-exceptions],
237                  [force use of builtin_setjmp for exceptions]),
238 [:],
239 [dnl Botheration.  Now we've got to detect the exception model.
240 dnl Link tests against libgcc.a are problematic since -- at least
241 dnl as of this writing -- we've not been given proper -L bits for
242 dnl single-tree newlib and libgloss.
244 dnl This is what AC_TRY_COMPILE would do if it didn't delete the
245 dnl conftest files before we got a change to grep them first.
246 cat > conftest.$ac_ext << EOF
247 [#]line __oline__ "configure"
248 @interface Frob
249 @end
250 @implementation Frob
251 @end
252 int proc();
253 int foo()
255   @try {
256    return proc();
257   }
258   @catch (Frob* ex) {
259     return 0;
260   }
263 old_CFLAGS="$CFLAGS" 
264 dnl work around that we don't have Objective-C support in autoconf
265 CFLAGS="-x objective-c -fgnu-runtime -fobjc-exceptions -S"
266 if AC_TRY_EVAL(ac_compile); then
267   if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
268     enable_sjlj_exceptions=yes
269   elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
270     enable_sjlj_exceptions=no
271   fi
273 CFLAGS="$old_CFLAGS"
274 rm -f conftest*])
275 if test x$enable_sjlj_exceptions = xyes; then
276   AC_DEFINE(SJLJ_EXCEPTIONS, 1,
277         [Define if the compiler is configured for setjmp/longjmp exceptions.])
278   ac_exception_model_name=sjlj
279 elif test x$enable_sjlj_exceptions = xno; then
280   ac_exception_model_name="call frame"
281 else
282   AC_MSG_ERROR([unable to detect exception model])
284 AC_LANG_POP(C)
285 AC_MSG_RESULT($ac_exception_model_name)
287 # ------
288 # Output
289 # ------
291 AC_CONFIG_FILES([Makefile])
293 AC_CONFIG_COMMANDS([default],
294 [[if test -n "$CONFIG_FILES"; then
295   if test -n "${with_target_subdir}"; then
296     # FIXME: We shouldn't need to set ac_file
297     ac_file=Makefile
298     LD="${ORIGINAL_LD_FOR_MULTILIBS}"
299     . ${toplevel_srcdir}/config-ml.in
300   fi
301 fi]],
302 [[srcdir=${srcdir}
303 host=${host}
304 target=${target}
305 with_target_subdir=${with_target_subdir}
306 with_multisubdir=${with_multisubdir}
307 ac_configure_args="--enable-multilib ${ac_configure_args}"
308 toplevel_srcdir=${toplevel_srcdir}
309 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
310 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
313 AC_OUTPUT