1 # Process this file with autoconf to produce a configure script.
2 # Copyright (C) 1994-2025 Free Software Foundation, Inc.
3 # Originally contributed by Dave Love (d.love@dl.ac.uk).
5 #This file is part of GCC.
7 #GCC is free software; you can redistribute it and/or modify
8 #it under the terms of the GNU General Public License as published by
9 #the Free Software Foundation; either version 3, or (at your option)
12 #GCC is distributed in the hope that it will be useful,
13 #but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 #GNU General Public License for more details.
17 #You should have received a copy of the GNU General Public License
18 #along with GCC; see the file COPYING3. If not see
19 #<http://www.gnu.org/licenses/>.
21 AC_INIT(package-unused, version-unused,, libobjc)
22 AC_CONFIG_SRCDIR([objc/objc.h])
23 AC_CONFIG_MACRO_DIRS([../config] [..])
26 # We need the following definitions because AC_PROG_LIBTOOL relies on them
28 # Version is pulled out to make it a bit easier to change using sed.
32 # This works around the fact that libtool configuration may change LD
33 # for this particular configuration, but some shells, instead of
34 # keeping the changes in LD private, export them just because LD is
36 ORIGINAL_LD_FOR_MULTILIBS=$LD
42 # We use these options to decide which functions to include.
43 AC_ARG_WITH(target-subdir,
44 [ --with-target-subdir=SUBDIR
45 configuring in a subdirectory])
46 AC_ARG_WITH(cross-host,
47 [ --with-cross-host=HOST configuring with a cross compiler])
49 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
50 AC_ARG_ENABLE(version-specific-runtime-libs,
51 [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
53 yes) version_specific_libs=yes ;;
54 no) version_specific_libs=no ;;
55 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
57 [version_specific_libs=no])
58 AC_MSG_RESULT($version_specific_libs)
64 # Find the rest of the source tree framework.
65 AM_ENABLE_MULTILIB(, ..)
68 ACX_NONCANONICAL_TARGET
70 # Export source directory.
71 # These need to be absolute paths, yet at the same time need to
72 # canonicalize only relative paths, because then amd will not unmount
73 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
75 [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
76 *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
78 AC_SUBST(glibcpp_srcdir)
80 GCC_WITH_TOOLEXECLIBDIR
82 # Calculate toolexeclibdir
83 # Also toolexecdir, though it's only used in toolexeclibdir
84 case ${version_specific_libs} in
86 # Need the gcc compiler version to know where to install libraries
87 # and header files if --enable-version-specific-runtime-libs option
89 toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
90 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
93 if test -n "$with_cross_host" &&
94 test x"$with_cross_host" != x"no"; then
95 # Install a library built with a cross compiler in tooldir, not libdir.
96 toolexecdir='$(exec_prefix)/$(target_noncanonical)'
97 case ${with_toolexeclibdir} in
99 toolexeclibdir='$(toolexecdir)/lib'
102 toolexeclibdir=${with_toolexeclibdir}
106 toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
107 toolexeclibdir='$(libdir)'
109 multi_os_directory=`$CC -print-multi-os-directory`
110 case $multi_os_directory in
111 .) ;; # Avoid trailing /.
112 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
116 AC_SUBST(toolexecdir)
117 AC_SUBST(toolexeclibdir)
119 # Figure out if we want to name the include directory and the
120 # library name changes differently.
121 includedirname=include
125 # Darwin is the only target so far that needs a different include directory.
126 includedirname=include-gnu-runtime
130 AC_SUBST(includedirname)
133 AC_CONFIG_HEADERS(config.h)
141 # We must force CC to /not/ be a precious variable; otherwise
142 # the wrong, non-multilib-adjusted value will be used in multilibs.
143 # As a side effect, we have to subst CFLAGS ourselves.
144 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
145 m4_define([_AC_ARG_VAR_PRECIOUS],[])
147 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
149 # extra LD Flags which are required for targets
152 # Add CET specific flags if CET is enabled
153 GCC_CET_FLAGS(CET_FLAGS)
154 XCFLAGS="$XCFLAGS $CET_FLAGS"
159 AC_CHECK_TOOL(AS, as)
160 AC_CHECK_TOOL(AR, ar)
161 AC_CHECK_TOOL(RANLIB, ranlib, :)
166 # Enable Win32 DLL on MS Windows - FIXME
175 AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
177 # Must come after libtool is initialized.
180 # Earlier Darwin versions need -single_module when linking libobjc; they
181 # do not support @rpath.
182 extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
185 # Otherwise, single_module is the default and multi-module is ignored and
187 extra_ldflags_libobjc='$(lt_host_flags)'
188 if test "x$enable_darwin_at_rpath" = "xyes"; then
189 extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wc,-nodefaultrpaths"
190 extra_ldflags_libobjc="${extra_ldflags_libobjc} -Wl,-rpath,@loader_path"
194 # Tell libtool to build DLLs on Windows
195 extra_ldflags_libobjc='$(lt_host_flags)'
198 AC_SUBST(extra_ldflags_libobjc)
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'.])])
214 AC_CHECK_HEADERS(sched.h)
220 # Check if we have thread-local storage
223 gt_BITFIELD_TYPE_MATTERS
229 AC_ARG_ENABLE(objc-gc,
230 [AS_HELP_STRING([--enable-objc-gc],
231 [enable use of Boehm's garbage collector with the
232 GNU Objective-C runtime])],,enable_objc_gc=no)
233 AC_ARG_WITH([target-bdw-gc],
234 [AS_HELP_STRING([--with-target-bdw-gc=PATHLIST],
235 [specify prefix directory for installed bdw-gc package.
236 Equivalent to --with-target-bdw-gc-include=PATH/include
237 plus --with-target-bdw-gc-lib=PATH/lib])])
238 AC_ARG_WITH([target-bdw-gc-include],
239 [AS_HELP_STRING([--with-target-bdw-gc-include=PATHLIST],
240 [specify directories for installed bdw-gc include files])])
241 AC_ARG_WITH([target-bdw-gc-lib],
242 [AS_HELP_STRING([--with-target-bdw-gc-lib=PATHLIST],
243 [specify directories for installed bdw-gc library])])
245 case "$enable_objc_gc" in
250 AC_MSG_CHECKING([for bdw garbage collector])
251 if test "x$with_target_bdw_gc$with_target_bdw_gc_include$with_target_bdw_gc_lib" = x; then
252 dnl no bdw-gw options, assuming bdw-gc in default locations
256 dnl bdw-gw options passed by configure flags
257 if test "x$with_target_bdw_gc_include" = x && test "x$with_target_bdw_gc_lib" != x; then
258 AC_MSG_ERROR([found --with-target-bdw-gc-lib but --with-target-bdw-gc-include missing])
259 elif test "x$with_target_bdw_gc_include" != x && test "x$with_target_bdw_gc_lib" = x; then
260 AC_MSG_ERROR([found --with-target-bdw-gc-include but --with-target-bdw-gc-lib missing])
262 AC_MSG_RESULT([using paths configured with --with-target-bdw-gc options])
264 mldir=`${CC-gcc} --print-multi-directory 2>/dev/null`
266 if test "x$with_target_bdw_gc" != x; then
267 for i in `echo $with_target_bdw_gc | tr ',' ' '`; do
269 *=*) sd=${i%%=*}; d=${i#*=} ;;
272 if test "$mldir" = "$sd"; then
276 if test "x$bdw_val" = x; then
277 AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc])
279 bdw_inc_dir="$bdw_val/include"
280 bdw_lib_dir="$bdw_val/lib"
283 if test "x$with_target_bdw_gc_include" != x; then
284 for i in `echo $with_target_bdw_gc_include | tr ',' ' '`; do
286 *=*) sd=${i%%=*}; d=${i#*=} ;;
287 *) sd=.; d=$i; fallback=$i ;;
289 if test "$mldir" = "$sd"; then
293 if test "x$bdw_val" = x && test "x$bdw_inc_dir" = x && test "x$fallback" != x; then
294 bdw_inc_dir="$fallback"
295 elif test "x$bdw_val" = x; then
296 AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-include])
298 bdw_inc_dir="$bdw_val"
302 if test "x$with_target_bdw_gc_lib" != x; then
303 for i in `echo $with_target_bdw_gc_lib | tr ',' ' '`; do
305 *=*) sd=${i%%=*}; d=${i#*=} ;;
308 if test "$mldir" = "$sd"; then
312 if test "x$bdw_val" = x; then
313 AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-lib])
315 bdw_lib_dir="$bdw_val"
317 if test "x$bdw_inc_dir" = x; then
318 AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-include])
320 if test "x$bdw_lib_dir" = x; then
321 AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-lib])
323 BDW_GC_CFLAGS="-I$bdw_inc_dir"
324 if test -f $bdw_lib_dir/libgc.la; then
325 BDW_GC_LIBS="$bdw_lib_dir/libgc.la"
327 BDW_GC_LIBS="-L$bdw_lib_dir -lgc"
329 AC_MSG_RESULT([found])
332 case "$BDW_GC_LIBS" in
337 AC_MSG_CHECKING([for system boehm-gc])
340 CFLAGS="$CFLAGS $BDW_GC_CFLAGS"
341 LIBS="$LIBS $BDW_GC_LIBS"
342 dnl the link test is not good enough for ARM32 multilib detection,
343 dnl first check to link, then to run
345 [AC_LANG_PROGRAM([#include <gc/gc.h>],[GC_init()])],
347 AC_RUN_IFELSE([AC_LANG_SOURCE([[
354 [system_bdw_gc_found=yes],
355 [system_bdw_gc_found=no],
356 dnl assume no system boehm-gc for cross builds ...
357 [system_bdw_gc_found=no]
360 [system_bdw_gc_found=no])
363 if test x$enable_objc_gc = xauto && test x$system_bdw_gc_found = xno; then
364 AC_MSG_WARN([system bdw-gc not found, not building libobjc_gc])
366 elif test x$enable_objc_gc = xyes && test x$system_bdw_gc_found = xno; then
367 AC_MSG_ERROR([system bdw-gc required but not found])
370 AC_MSG_RESULT([found])
375 if test "$use_bdw_gc" = no; then
378 OBJC_BOEHM_GC_INCLUDES=''
379 OBJC_BOEHM_GC_LIBS=''
381 OBJC_GCFLAGS='-DOBJC_WITH_GC=1'
382 OBJC_BOEHM_GC='libobjc_gc$(libsuffix).la'
383 OBJC_BOEHM_GC_INCLUDES=$BDW_GC_CFLAGS
384 OBJC_BOEHM_GC_LIBS=$BDW_GC_LIBS
386 AC_SUBST(OBJC_GCFLAGS)
387 AC_SUBST(OBJC_BOEHM_GC)
388 AC_SUBST(OBJC_BOEHM_GC_INCLUDES)
389 AC_SUBST(OBJC_BOEHM_GC_LIBS)
391 # Determine what GCC version number to use in filesystem paths.
398 if test ${multilib} = yes; then
399 multilib_arg="--enable-multilib"
404 AC_CONFIG_FILES([Makefile])