OSDN Git Service

2005-08-17 Kelley Cook <kcook@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / libobjc / configure.ac
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).
5 #
6 #This file is part of GCC.
7 #
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.
12 #
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.
17 #
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, 51 Franklin Street, Fifth Floor, Boston, MA
21 #02110-1301, USA.
22
23 AC_PREREQ(2.59)
24 AC_INIT(package-unused, version-unused,, libobjc)
25 AC_CONFIG_SRCDIR([objc/objc.h])
26 GCC_TOPLEV_SUBDIRS
27
28 # We need the following definitions because AC_PROG_LIBTOOL relies on them
29 PACKAGE=libobjc
30 # Version is pulled out to make it a bit easier to change using sed.
31 VERSION=1:0:0
32 AC_SUBST(VERSION)
33
34 # This works around the fact that libtool configuration may change LD
35 # for this particular configuration, but some shells, instead of
36 # keeping the changes in LD private, export them just because LD is
37 # exported.
38 ORIGINAL_LD_FOR_MULTILIBS=$LD
39
40 # -------
41 # Options
42 # -------
43
44 # Default to --enable-multilib
45 AC_ARG_ENABLE(multilib,
46   [  --enable-multilib       build hella library versions (default)],
47   [case "${enableval}" in
48     yes) multilib=yes ;;
49     no)  multilib=no ;;
50     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
51    esac],
52   [multilib=yes])
53
54 # We use these options to decide which functions to include.
55 AC_ARG_WITH(target-subdir,
56 [  --with-target-subdir=SUBDIR
57                            configuring in a subdirectory])
58 AC_ARG_WITH(cross-host,
59 [  --with-cross-host=HOST  configuring with a cross compiler])
60
61 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
62 AC_ARG_ENABLE(version-specific-runtime-libs,
63 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
64 [case "$enableval" in
65  yes) version_specific_libs=yes ;;
66  no)  version_specific_libs=no ;;
67  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
68  esac],
69 [version_specific_libs=no])
70 AC_MSG_RESULT($version_specific_libs)
71
72 AC_ARG_ENABLE(objc-gc,
73 [  --enable-objc-gc       enable the use of Boehm's garbage collector with
74                           the GNU Objective-C runtime.],
75 [case $enable_objc_gc in
76   no) OBJC_BOEHM_GC='' ;;
77   *) OBJC_BOEHM_GC=libobjc_gc.la ;;
78 esac],
79 [OBJC_BOEHM_GC=''])
80 AC_SUBST(OBJC_BOEHM_GC)
81
82 # -----------
83 # Directories
84 # -----------
85
86 # When building with srcdir == objdir, links to the source files will
87 # be created in directories within the target_subdir.  We have to
88 # adjust toplevel_srcdir accordingly, so that configure finds
89 # install-sh and other auxiliary files that live in the top-level
90 # source directory.
91 if test "${srcdir}" = "."; then
92   if test -z "${with_target_subdir}"; then
93     toprel=".."
94   else
95     if test "${with_target_subdir}" != "."; then
96       toprel="${with_multisrctop}../.."
97     else
98       toprel="${with_multisrctop}.."
99     fi
100   fi
101 else
102   toprel=".."
103 fi
104 AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
105 toplevel_srcdir=\${srcdir}/$toprel
106 AC_SUBST(toplevel_srcdir)
107
108 AC_CANONICAL_SYSTEM
109 ACX_NONCANONICAL_TARGET
110
111 # Export source directory.
112 # These need to be absolute paths, yet at the same time need to
113 # canonicalize only relative paths, because then amd will not unmount
114 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
115 case $srcdir in
116   [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
117   *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
118 esac
119 AC_SUBST(glibcpp_srcdir)
120
121 # Calculate toolexeclibdir
122 # Also toolexecdir, though it's only used in toolexeclibdir
123 case ${version_specific_libs} in
124   yes)
125     # Need the gcc compiler version to know where to install libraries
126     # and header files if --enable-version-specific-runtime-libs option
127     # is selected.
128     toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
129     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
130     ;;
131   no)
132     if test -n "$with_cross_host" &&
133        test x"$with_cross_host" != x"no"; then
134       # Install a library built with a cross compiler in tooldir, not libdir.
135       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
136       toolexeclibdir='$(toolexecdir)/lib'
137     else
138       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
139       toolexeclibdir='$(libdir)'
140     fi
141     multi_os_directory=`$CC -print-multi-os-directory`
142     case $multi_os_directory in
143       .) ;; # Avoid trailing /.
144       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
145     esac
146     ;;
147 esac
148 AC_SUBST(toolexecdir)
149 AC_SUBST(toolexeclibdir)
150
151 # Figure out if we want to name the include directory and the
152 #  library name changes differently.
153 includedirname=include
154 libext=
155 case "${host}" in
156   *-darwin*)
157     # Darwin is the only target so far that needs a different include directory.
158     includedirname=include-gnu-runtime
159     libext=-gnu
160     ;;
161 esac
162 AC_SUBST(includedirname)
163 AC_SUBST(libext)
164
165 AC_CONFIG_HEADERS(config.h)
166
167 # --------
168 # Programs
169 # --------
170
171 GCC_NO_EXECUTABLES
172
173 # We must force CC to /not/ be a precious variable; otherwise
174 # the wrong, non-multilib-adjusted value will be used in multilibs.
175 # As a side effect, we have to subst CFLAGS ourselves.
176 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
177 m4_define([_AC_ARG_VAR_PRECIOUS],[])
178 AC_PROG_CC
179 m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
180
181 # extra LD Flags which are required for targets
182 case "${host}" in
183   *-darwin*)
184     # Darwin needs -single_module when linking libobjc
185     extra_ldflags_libobjc=-Wl,-single_module
186     ;;
187 esac
188 AC_SUBST(extra_ldflags_libobjc)
189
190 AC_SUBST(CFLAGS)
191
192 AC_CHECK_TOOL(AS, as)
193 AC_CHECK_TOOL(AR, ar)
194 AC_CHECK_TOOL(RANLIB, ranlib, :)
195 AC_PROG_INSTALL
196
197 AM_MAINTAINER_MODE
198
199 # Enable Win32 DLL on MS Windows - FIXME
200 AC_LIBTOOL_WIN32_DLL
201
202 AC_PROG_LIBTOOL
203
204 AM_PROG_CC_C_O
205
206 AC_PROG_MAKE_SET
207
208 # -------
209 # Headers
210 # -------
211
212 # Sanity check for the cross-compilation case:
213 AC_CHECK_HEADER(stdio.h,:,
214   [AC_MSG_ERROR([Can't find stdio.h.
215 You must have a usable C system for the target already installed, at least
216 including headers and, preferably, the library, before you can configure
217 the Objective C runtime system.  If necessary, install gcc now with 
218 \`LANGUAGES=c', then the target library, then build with \`LANGUAGES=objc'.])])
219
220 AC_HEADER_STDC
221
222 AC_CHECK_HEADERS(sched.h)
223
224 # -----------
225 # Miscellanea
226 # -----------
227
228 AC_MSG_CHECKING([for thread model used by GCC])
229 target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
230 AC_MSG_RESULT([$target_thread_file]) 
231
232 if test $target_thread_file != single; then
233   AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
234         [Define if the compiler has a thread header that is non single.])
235 fi 
236
237
238 AC_MSG_CHECKING([for exception model to use])
239 AC_LANG_PUSH(C)
240 AC_ARG_ENABLE(sjlj-exceptions,
241   AS_HELP_STRING([--enable-sjlj-exceptions],
242                  [force use of builtin_setjmp for exceptions]),
243 [:],
244 [dnl Botheration.  Now we've got to detect the exception model.
245 dnl Link tests against libgcc.a are problematic since -- at least
246 dnl as of this writing -- we've not been given proper -L bits for
247 dnl single-tree newlib and libgloss.
248 dnl
249 dnl This is what AC_TRY_COMPILE would do if it didn't delete the
250 dnl conftest files before we got a change to grep them first.
251 cat > conftest.$ac_ext << EOF
252 [#]line __oline__ "configure"
253 @interface Frob
254 @end
255 @implementation Frob
256 @end
257 int proc();
258 int foo()
259 {
260   @try {
261    return proc();
262   }
263   @catch (Frob* ex) {
264     return 0;
265   }
266 }
267 EOF
268 old_CFLAGS="$CFLAGS" 
269 dnl work around that we don't have Objective-C support in autoconf
270 CFLAGS="-x objective-c -fgnu-runtime -fobjc-exceptions -S"
271 if AC_TRY_EVAL(ac_compile); then
272   if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
273     enable_sjlj_exceptions=yes
274   elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
275     enable_sjlj_exceptions=no
276   fi
277 fi
278 CFLAGS="$old_CFLAGS"
279 rm -f conftest*])
280 if test x$enable_sjlj_exceptions = xyes; then
281   AC_DEFINE(SJLJ_EXCEPTIONS, 1,
282         [Define if the compiler is configured for setjmp/longjmp exceptions.])
283   ac_exception_model_name=sjlj
284 elif test x$enable_sjlj_exceptions = xno; then
285   ac_exception_model_name="call frame"
286 else
287   AC_MSG_ERROR([unable to detect exception model])
288 fi
289 AC_LANG_POP(C)
290 AC_MSG_RESULT($ac_exception_model_name)
291
292 # ------
293 # Output
294 # ------
295
296 AC_CONFIG_FILES([Makefile])
297
298 AC_CONFIG_COMMANDS([default],
299 [[if test -n "$CONFIG_FILES"; then
300   if test -n "${with_target_subdir}"; then
301     # FIXME: We shouldn't need to set ac_file
302     ac_file=Makefile
303     LD="${ORIGINAL_LD_FOR_MULTILIBS}"
304     . ${toplevel_srcdir}/config-ml.in
305   fi
306 fi]],
307 [[srcdir=${srcdir}
308 host=${host}
309 target=${target}
310 with_target_subdir=${with_target_subdir}
311 with_multisubdir=${with_multisubdir}
312 ac_configure_args="--enable-multilib ${ac_configure_args}"
313 toplevel_srcdir=${toplevel_srcdir}
314 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
315 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
316 ]])
317
318 AC_OUTPUT