]>
Commit | Line | Data |
---|---|---|
48310492 | 1 | # Process this file with autoreconf to produce a configure script. |
a5544970 | 2 | # Copyright (C) 2012-2019 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 |
25 | AC_INIT([GNU Atomic Library], 1.0,,[libatomic]) |
26 | AC_CONFIG_HEADER(auto-config.h) | |
27 | ||
28 | # ------- | |
29 | # Options | |
30 | # ------- | |
31 | ||
32 | AC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) | |
33 | LIBAT_ENABLE(version-specific-runtime-libs, no, , | |
34 | [Specify that runtime libraries should be installed in a compiler-specific directory], | |
35 | permit yes|no) | |
36 | AC_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. | |
43 | AC_MSG_CHECKING([for --enable-generated-files-in-srcdir]) | |
44 | LIBAT_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) | |
48 | AC_MSG_RESULT($enable_generated_files_in_srcdir) | |
49 | AM_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 | |
69 | AC_CANONICAL_SYSTEM | |
70 | target_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 | 84 | AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override]) |
48310492 RH |
85 | AM_ENABLE_MULTILIB(, ..) |
86 | ||
87 | # Calculate toolexeclibdir | |
88 | # Also toolexecdir, though it's only used in toolexeclibdir | |
89 | case ${enable_version_specific_runtime_libs} in | |
90 | yes) | |
91 | # Need the gcc compiler version to know where to install libraries | |
92 | # and header files if --enable-version-specific-runtime-libs option | |
93 | # is selected. | |
94 | toolexecdir='$(libdir)/gcc/$(target_alias)' | |
95 | toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' | |
96 | ;; | |
97 | no) | |
98 | if test -n "$with_cross_host" && | |
99 | test x"$with_cross_host" != x"no"; then | |
100 | # Install a library built with a cross compiler in tooldir, not libdir. | |
101 | toolexecdir='$(exec_prefix)/$(target_alias)' | |
102 | toolexeclibdir='$(toolexecdir)/lib' | |
103 | else | |
104 | toolexecdir='$(libdir)/gcc-lib/$(target_alias)' | |
105 | toolexeclibdir='$(libdir)' | |
106 | fi | |
107 | multi_os_directory=`$CC -print-multi-os-directory` | |
108 | case $multi_os_directory in | |
109 | .) ;; # Avoid trailing /. | |
110 | *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; | |
111 | esac | |
112 | ;; | |
113 | esac | |
114 | AC_SUBST(toolexecdir) | |
115 | AC_SUBST(toolexeclibdir) | |
116 | ||
117 | # Check the compiler. | |
118 | # The same as in boehm-gc and libstdc++. Have to borrow it from there. | |
119 | # We must force CC to /not/ be precious variables; otherwise | |
120 | # the wrong, non-multilib-adjusted value will be used in multilibs. | |
121 | # As a side effect, we have to subst CFLAGS ourselves. | |
122 | ||
123 | m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) | |
124 | m4_define([_AC_ARG_VAR_PRECIOUS],[]) | |
125 | AC_PROG_CC | |
126 | AM_PROG_AS | |
127 | m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) | |
128 | ||
129 | AC_SUBST(CFLAGS) | |
130 | ||
131 | # In order to override CFLAGS_FOR_TARGET, all of our special flags go | |
132 | # in XCFLAGS. But we need them in CFLAGS during configury. So put them | |
133 | # in both places for now and restore CFLAGS at the end of config. | |
134 | save_CFLAGS="$CFLAGS" | |
135 | ||
136 | # Find other programs we need. | |
137 | AC_CHECK_TOOL(AR, ar) | |
138 | AC_CHECK_TOOL(NM, nm) | |
139 | AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error) | |
140 | AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error) | |
141 | AC_PROG_INSTALL | |
142 | ||
143 | # Configure libtool | |
144 | AM_PROG_LIBTOOL | |
dc3368d0 | 145 | ACX_LT_HOST_FLAGS |
48310492 RH |
146 | AC_SUBST(enable_shared) |
147 | AC_SUBST(enable_static) | |
fa3cd3c3 | 148 | AM_MAINTAINER_MODE |
48310492 RH |
149 | |
150 | # For libtool versioning info, format is CURRENT:REVISION:AGE | |
c29c36ad | 151 | libtool_VERSION=3:0:2 |
48310492 RH |
152 | AC_SUBST(libtool_VERSION) |
153 | ||
dc3368d0 KT |
154 | # Check for used threading-model |
155 | AC_MSG_CHECKING([for thread model used by GCC]) | |
156 | target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` | |
157 | AC_MSG_RESULT([$target_thread_file]) | |
158 | ||
9d0e85af SE |
159 | case "$target" in |
160 | *aarch64*) | |
161 | ACX_PROG_CC_WARNING_OPTS([-march=armv8-a+lse],[enable_aarch64_lse]) | |
162 | ;; | |
163 | esac | |
164 | ||
48310492 RH |
165 | # Get target configury. |
166 | . ${srcdir}/configure.tgt | |
167 | if test -n "$UNSUPPORTED"; then | |
168 | AC_MSG_ERROR([Configuration ${target} is unsupported.]) | |
169 | fi | |
170 | ||
141abc6f SE |
171 | # Write out the ifunc resolver arg type. |
172 | AC_DEFINE_UNQUOTED(IFUNC_RESOLVER_ARGS, $IFUNC_RESOLVER_ARGS, | |
173 | [Define ifunc resolver function argument.]) | |
174 | ||
48310492 RH |
175 | # Disable fallbacks to __sync routines from libgcc. Otherwise we'll |
176 | # make silly decisions about what the cpu can do. | |
177 | CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS" | |
178 | ||
179 | # Check header files. | |
180 | AC_STDC_HEADERS | |
181 | ACX_HEADER_STRING | |
182 | GCC_HEADER_STDINT(gstdint.h) | |
267bac10 | 183 | AC_CHECK_HEADERS([fenv.h]) |
48310492 RH |
184 | |
185 | # Check for common type sizes | |
186 | LIBAT_FORALL_MODES([LIBAT_HAVE_INT_MODE]) | |
187 | ||
188 | # Check for compiler builtins of atomic operations. | |
189 | LIBAT_TEST_ATOMIC_INIT | |
190 | LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_LOADSTORE]) | |
191 | LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_TAS]) | |
192 | LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_EXCHANGE]) | |
193 | LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_CAS]) | |
194 | LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_ADD]) | |
195 | LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_OP]) | |
196 | ||
197 | AC_C_BIGENDIAN | |
198 | # I don't like the default behaviour of WORDS_BIGENDIAN undefined for LE. | |
199 | AH_BOTTOM( | |
200 | [#ifndef WORDS_BIGENDIAN | |
201 | #define WORDS_BIGENDIAN 0 | |
202 | #endif]) | |
203 | ||
204 | LIBAT_WORDSIZE | |
205 | ||
206 | # Check to see if -pthread or -lpthread is needed. Prefer the former. | |
207 | # In case the pthread.h system header is not found, this test will fail. | |
208 | case " $config_path " in | |
209 | *" posix "*) | |
210 | XPCFLAGS="" | |
211 | CFLAGS="$CFLAGS -pthread" | |
212 | AC_LINK_IFELSE( | |
213 | [AC_LANG_PROGRAM( | |
214 | [#include <pthread.h> | |
215 | void *g(void *d) { return NULL; }], | |
216 | [pthread_t t; pthread_create(&t,NULL,g,NULL);])], | |
217 | [XPCFLAGS=" -pthread"], | |
218 | [CFLAGS="$save_CFLAGS $XCFLAGS" LIBS="-lpthread $LIBS" | |
219 | AC_LINK_IFELSE( | |
220 | [AC_LANG_PROGRAM( | |
221 | [#include <pthread.h> | |
222 | void *g(void *d) { return NULL; }], | |
223 | [pthread_t t; pthread_create(&t,NULL,g,NULL);])], | |
224 | [], | |
225 | [AC_MSG_ERROR([Pthreads are required to build libatomic])])]) | |
e9885be5 | 226 | CFLAGS="$save_CFLAGS $XPCFLAGS" |
48310492 RH |
227 | ;; |
228 | esac | |
229 | ||
230 | # See what sort of export controls are available. | |
231 | LIBAT_CHECK_ATTRIBUTE_VISIBILITY | |
232 | LIBAT_CHECK_ATTRIBUTE_DLLEXPORT | |
233 | LIBAT_CHECK_ATTRIBUTE_ALIAS | |
234 | if test x$try_ifunc = xyes; then | |
235 | LIBAT_CHECK_IFUNC | |
236 | fi | |
237 | ||
238 | # Check linker support. | |
239 | LIBAT_ENABLE_SYMVERS | |
240 | ||
241 | # Cleanup and exit. | |
242 | CFLAGS="$save_CFLAGS" | |
243 | AC_CACHE_SAVE | |
244 | ||
245 | # Add -Wall -Werror if we are using GCC. | |
246 | if test "x$GCC" = "xyes"; then | |
247 | XCFLAGS="$XCFLAGS -Wall -Werror" | |
248 | fi | |
249 | ||
efc643e9 IT |
250 | # Add CET specific flags if CET is enabled |
251 | GCC_CET_FLAGS(CET_FLAGS) | |
252 | XCFLAGS="$XCFLAGS $CET_FLAGS" | |
253 | ||
48310492 RH |
254 | XCFLAGS="$XCFLAGS $XPCFLAGS" |
255 | ||
256 | AC_SUBST(config_path) | |
257 | AC_SUBST(XCFLAGS) | |
258 | AC_SUBST(XLDFLAGS) | |
259 | AC_SUBST(LIBS) | |
260 | AC_SUBST(SIZES) | |
261 | ||
262 | AM_CONDITIONAL(HAVE_IFUNC, test x$libat_cv_have_ifunc = xyes) | |
141abc6f SE |
263 | AM_CONDITIONAL(ARCH_AARCH64_LINUX, |
264 | [expr "$config_path" : ".* linux/aarch64 .*" > /dev/null]) | |
48310492 RH |
265 | AM_CONDITIONAL(ARCH_ARM_LINUX, |
266 | [expr "$config_path" : ".* linux/arm .*" > /dev/null]) | |
267 | AM_CONDITIONAL(ARCH_I386, | |
268 | [test "$ARCH" = x86 && test x$libat_cv_wordsize = x4]) | |
269 | AM_CONDITIONAL(ARCH_X86_64, | |
270 | [test "$ARCH" = x86 && test x$libat_cv_wordsize = x8]) | |
271 | ||
3c36aa6b JJ |
272 | # Determine what GCC version number to use in filesystem paths. |
273 | GCC_BASE_VER | |
274 | ||
48310492 RH |
275 | if test ${multilib} = yes; then |
276 | multilib_arg="--enable-multilib" | |
277 | else | |
278 | multilib_arg= | |
279 | fi | |
280 | ||
281 | AC_CONFIG_FILES(Makefile testsuite/Makefile) | |
282 | AC_OUTPUT |