]> git.ipfire.org Git - thirdparty/gcc.git/blame - libatomic/configure.ac
cprop: Change return type of predicate functions from int to bool
[thirdparty/gcc.git] / libatomic / configure.ac
CommitLineData
48310492 1# Process this file with autoreconf to produce a configure script.
83ffe9cd 2# Copyright (C) 2012-2023 Free Software Foundation, Inc.
48310492
RH
3#
4# This file is part of the GNU Atomic Library (libatomic).
5#
6# Libatomic is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
12# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14# more details.
15#
16# Under Section 7 of GPL version 3, you are granted additional
17# permissions described in the GCC Runtime Library Exception, version
18# 3.1, as published by the Free Software Foundation.
19#
20# You should have received a copy of the GNU General Public License and
21# a copy of the GCC Runtime Library Exception along with this program;
22# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23# <http://www.gnu.org/licenses/>.
24
48310492
RH
25AC_INIT([GNU Atomic Library], 1.0,,[libatomic])
26AC_CONFIG_HEADER(auto-config.h)
27
28# -------
29# Options
30# -------
31
32AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
33LIBAT_ENABLE(version-specific-runtime-libs, no, ,
34 [Specify that runtime libraries should be installed in a compiler-specific directory],
35 permit yes|no)
36AC_MSG_RESULT($enable_version_specific_runtime_libs)
37
38# We would like our source tree to be readonly. However when releases or
39# pre-releases are generated, the flex/bison generated files as well as the
40# various formats of manuals need to be included along with the rest of the
41# sources. Therefore we have --enable-generated-files-in-srcdir to do
42# just that.
43AC_MSG_CHECKING([for --enable-generated-files-in-srcdir])
44LIBAT_ENABLE(generated-files-in-srcdir, no, ,
45 [put copies of generated files in source dir intended for creating source
46 tarballs for users without texinfo bison or flex.],
47 permit yes|no)
48AC_MSG_RESULT($enable_generated_files_in_srcdir)
49AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
50
51
52# -------
53
54# Gets build, host, target, *_vendor, *_cpu, *_os, etc.
55#
56# You will slowly go insane if you do not grok the following fact: when
57# building this library, the top-level /target/ becomes the library's /host/.
58#
59# configure then causes --target to default to --host, exactly like any
60# other package using autoconf. Therefore, 'target' and 'host' will
61# always be the same. This makes sense both for native and cross compilers
62# just think about it for a little while. :-)
63#
64# Also, if this library is being configured as part of a cross compiler, the
65# top-level configure script will pass the "real" host as $with_cross_host.
66#
67# Do not delete or change the following two lines. For why, see
68# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
69AC_CANONICAL_SYSTEM
70target_alias=${target_alias-$host_alias}
71
72# Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the
73# following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
74# 1.9.0: minimum required version
75# no-define: PACKAGE and VERSION will not be #define'd in config.h (a bunch
76# of other PACKAGE_* variables will, however, and there's nothing
77# we can do about that; they come from AC_INIT).
c0758df9 78# no-dist: we don't want 'dist' and related rules.
48310492
RH
79# foreign: we don't follow the normal rules for GNU packages (no COPYING
80# file in the top srcdir, etc, etc), so stop complaining.
81# -Wall: turns on all automake warnings...
82# -Wno-portability: ...except this one, since GNU make is required.
83# -Wno-override: ... and this one, since we do want this in testsuite.
c0758df9 84AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
48310492
RH
85AM_ENABLE_MULTILIB(, ..)
86
e8e66971
MR
87GCC_WITH_TOOLEXECLIBDIR
88
48310492
RH
89# Calculate toolexeclibdir
90# Also toolexecdir, though it's only used in toolexeclibdir
91case ${enable_version_specific_runtime_libs} in
92 yes)
93 # Need the gcc compiler version to know where to install libraries
94 # and header files if --enable-version-specific-runtime-libs option
95 # is selected.
96 toolexecdir='$(libdir)/gcc/$(target_alias)'
97 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
98 ;;
99 no)
100 if test -n "$with_cross_host" &&
101 test x"$with_cross_host" != x"no"; then
102 # Install a library built with a cross compiler in tooldir, not libdir.
103 toolexecdir='$(exec_prefix)/$(target_alias)'
e8e66971
MR
104 case ${with_toolexeclibdir} in
105 no)
106 toolexeclibdir='$(toolexecdir)/lib'
107 ;;
108 *)
109 toolexeclibdir=${with_toolexeclibdir}
110 ;;
111 esac
48310492
RH
112 else
113 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
114 toolexeclibdir='$(libdir)'
115 fi
116 multi_os_directory=`$CC -print-multi-os-directory`
117 case $multi_os_directory in
118 .) ;; # Avoid trailing /.
119 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
120 esac
121 ;;
122esac
123AC_SUBST(toolexecdir)
124AC_SUBST(toolexeclibdir)
125
126# Check the compiler.
127# The same as in boehm-gc and libstdc++. Have to borrow it from there.
128# We must force CC to /not/ be precious variables; otherwise
129# the wrong, non-multilib-adjusted value will be used in multilibs.
130# As a side effect, we have to subst CFLAGS ourselves.
131
132m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
133m4_define([_AC_ARG_VAR_PRECIOUS],[])
134AC_PROG_CC
135AM_PROG_AS
136m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
137
138AC_SUBST(CFLAGS)
139
140# In order to override CFLAGS_FOR_TARGET, all of our special flags go
141# in XCFLAGS. But we need them in CFLAGS during configury. So put them
142# in both places for now and restore CFLAGS at the end of config.
143save_CFLAGS="$CFLAGS"
144
145# Find other programs we need.
146AC_CHECK_TOOL(AR, ar)
147AC_CHECK_TOOL(NM, nm)
148AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
48310492
RH
149AC_PROG_INSTALL
150
151# Configure libtool
152AM_PROG_LIBTOOL
dc3368d0 153ACX_LT_HOST_FLAGS
48310492
RH
154AC_SUBST(enable_shared)
155AC_SUBST(enable_static)
fa3cd3c3 156AM_MAINTAINER_MODE
48310492
RH
157
158# For libtool versioning info, format is CURRENT:REVISION:AGE
c29c36ad 159libtool_VERSION=3:0:2
48310492
RH
160AC_SUBST(libtool_VERSION)
161
dc3368d0
KT
162# Check for used threading-model
163AC_MSG_CHECKING([for thread model used by GCC])
164target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
165AC_MSG_RESULT([$target_thread_file])
166
9d0e85af
SE
167case "$target" in
168 *aarch64*)
169 ACX_PROG_CC_WARNING_OPTS([-march=armv8-a+lse],[enable_aarch64_lse])
170 ;;
171esac
172
48310492
RH
173# Get target configury.
174. ${srcdir}/configure.tgt
175if test -n "$UNSUPPORTED"; then
176 AC_MSG_ERROR([Configuration ${target} is unsupported.])
177fi
178
141abc6f
SE
179# Write out the ifunc resolver arg type.
180AC_DEFINE_UNQUOTED(IFUNC_RESOLVER_ARGS, $IFUNC_RESOLVER_ARGS,
181 [Define ifunc resolver function argument.])
182
48310492
RH
183# Disable fallbacks to __sync routines from libgcc. Otherwise we'll
184# make silly decisions about what the cpu can do.
185CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS"
186
187# Check header files.
188AC_STDC_HEADERS
189ACX_HEADER_STRING
190GCC_HEADER_STDINT(gstdint.h)
267bac10 191AC_CHECK_HEADERS([fenv.h])
48310492
RH
192
193# Check for common type sizes
194LIBAT_FORALL_MODES([LIBAT_HAVE_INT_MODE])
195
196# Check for compiler builtins of atomic operations.
197LIBAT_TEST_ATOMIC_INIT
198LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_LOADSTORE])
199LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_TAS])
200LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_EXCHANGE])
201LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_CAS])
202LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_ADD])
203LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_OP])
204
205AC_C_BIGENDIAN
206# I don't like the default behaviour of WORDS_BIGENDIAN undefined for LE.
207AH_BOTTOM(
208[#ifndef WORDS_BIGENDIAN
209#define WORDS_BIGENDIAN 0
210#endif])
211
212LIBAT_WORDSIZE
213
214# Check to see if -pthread or -lpthread is needed. Prefer the former.
215# In case the pthread.h system header is not found, this test will fail.
216case " $config_path " in
217 *" posix "*)
218 XPCFLAGS=""
219 CFLAGS="$CFLAGS -pthread"
220 AC_LINK_IFELSE(
221 [AC_LANG_PROGRAM(
222 [#include <pthread.h>
223 void *g(void *d) { return NULL; }],
224 [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
225 [XPCFLAGS=" -pthread"],
226 [CFLAGS="$save_CFLAGS $XCFLAGS" LIBS="-lpthread $LIBS"
227 AC_LINK_IFELSE(
228 [AC_LANG_PROGRAM(
229 [#include <pthread.h>
230 void *g(void *d) { return NULL; }],
231 [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
232 [],
233 [AC_MSG_ERROR([Pthreads are required to build libatomic])])])
e9885be5 234 CFLAGS="$save_CFLAGS $XPCFLAGS"
48310492
RH
235 ;;
236esac
237
238# See what sort of export controls are available.
239LIBAT_CHECK_ATTRIBUTE_VISIBILITY
240LIBAT_CHECK_ATTRIBUTE_DLLEXPORT
241LIBAT_CHECK_ATTRIBUTE_ALIAS
242if test x$try_ifunc = xyes; then
243 LIBAT_CHECK_IFUNC
244fi
245
246# Check linker support.
247LIBAT_ENABLE_SYMVERS
248
249# Cleanup and exit.
250CFLAGS="$save_CFLAGS"
251AC_CACHE_SAVE
252
45ba6bf2
DS
253AC_ARG_ENABLE([werror],
254 [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
48310492 255# Add -Wall -Werror if we are using GCC.
45ba6bf2
DS
256AS_IF([test "x$GCC" = "xyes"],
257 [XCFLAGS="$XCFLAGS -Wall"])
258AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"],
259 [XCFLAGS="$XCFLAGS -Werror"])
48310492 260
efc643e9
IT
261# Add CET specific flags if CET is enabled
262GCC_CET_FLAGS(CET_FLAGS)
263XCFLAGS="$XCFLAGS $CET_FLAGS"
264
48310492
RH
265XCFLAGS="$XCFLAGS $XPCFLAGS"
266
267AC_SUBST(config_path)
268AC_SUBST(XCFLAGS)
269AC_SUBST(XLDFLAGS)
270AC_SUBST(LIBS)
271AC_SUBST(SIZES)
272
47ddb895
DE
273# Conditionalize the makefile for this target machine.
274tmake_file_=
275for f in ${tmake_file}
276do
277 if test -f ${srcdir}/config/$f
278 then
279 tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
280 fi
281done
282tmake_file="${tmake_file_}"
283AC_SUBST(tmake_file)
284
285
48310492 286AM_CONDITIONAL(HAVE_IFUNC, test x$libat_cv_have_ifunc = xyes)
141abc6f
SE
287AM_CONDITIONAL(ARCH_AARCH64_LINUX,
288 [expr "$config_path" : ".* linux/aarch64 .*" > /dev/null])
48310492
RH
289AM_CONDITIONAL(ARCH_ARM_LINUX,
290 [expr "$config_path" : ".* linux/arm .*" > /dev/null])
291AM_CONDITIONAL(ARCH_I386,
292 [test "$ARCH" = x86 && test x$libat_cv_wordsize = x4])
293AM_CONDITIONAL(ARCH_X86_64,
294 [test "$ARCH" = x86 && test x$libat_cv_wordsize = x8])
295
3c36aa6b
JJ
296# Determine what GCC version number to use in filesystem paths.
297GCC_BASE_VER
298
48310492
RH
299if test ${multilib} = yes; then
300 multilib_arg="--enable-multilib"
301else
302 multilib_arg=
303fi
304
305AC_CONFIG_FILES(Makefile testsuite/Makefile)
5ff06d76 306AC_CONFIG_FILES(testsuite/libatomic-site-extra.exp)
48310492 307AC_OUTPUT