]> git.ipfire.org Git - thirdparty/glibc.git/blame - configure.ac
posix/glob.c: update from gnulib
[thirdparty/glibc.git] / configure.ac
CommitLineData
f4017d20 1dnl Process this file with autoconf to produce a configure script.
f7934be8 2dnl Note we do not use AC_PREREQ here! See aclocal.m4 for what we use instead.
02d35f06
PE
3AC_INIT([GNU C Library], [(see version.h)], [https://sourceware.org/bugzilla/],
4 [glibc], [https://www.gnu.org/software/glibc/])
5d77b1da 5AC_CONFIG_SRCDIR([include/features.h])
6b7f6183
RM
6AC_CONFIG_HEADERS([config.h])
7AC_CONFIG_AUX_DIR([scripts])
28f540f4 8
8b748aed 9ACX_PKGVERSION([GNU libc])
5a82c748 10ACX_BUGURL([https://www.gnu.org/software/libc/bugs.html])
8b748aed
JM
11AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"],
12 [Package description])
13AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"],
14 [Bug reporting address])
15
918b5606
L
16# Glibc should not depend on any header files
17AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
18 [m4_divert_text([DEFAULTS],
19 [ac_includes_default='/* none */'])])
20
bb931195
TS
21# We require GCC, and by default use its preprocessor. Override AC_PROG_CPP
22# here to work around the Autoconf issue discussed in
a306c790 23# <https://sourceware.org/ml/libc-alpha/2013-01/msg00721.html>.
bb931195
TS
24AC_DEFUN([AC_PROG_CPP],
25[AC_REQUIRE([AC_PROG_CC])dnl
26AC_ARG_VAR([CPP], [C preprocessor])dnl
27_AC_ARG_VAR_CPPFLAGS()dnl
28# On Suns, sometimes $CPP names a directory.
29if test -n "$CPP" && test -d "$CPP"; then
30 CPP=
31fi
32if test -z "$CPP"; then
33 CPP="$CC -E"
34fi
35AC_SUBST(CPP)dnl
36])# AC_PROG_CPP
37
b5a5da23
TS
38# We require GCC. Override _AC_PROG_CC_C89 here to work around the Autoconf
39# issue discussed in
a306c790 40# <https://sourceware.org/ml/libc-alpha/2013-01/msg00757.html>.
b5a5da23
TS
41AC_DEFUN([_AC_PROG_CC_C89], [[$1]])
42
7967983f
RM
43dnl This is here so we can set $subdirs directly based on configure fragments.
44AC_CONFIG_SUBDIRS()
45
c16a054d
AS
46AC_CANONICAL_HOST
47
c0bac8b0
UD
48AC_PROG_CC
49if test $host != $build; then
50 AC_CHECK_PROGS(BUILD_CC, gcc cc)
51fi
52AC_SUBST(cross_compiling)
53AC_PROG_CPP
e4693aa7
RM
54AC_CHECK_TOOL(READELF, readelf, false)
55
c0bac8b0
UD
56# We need the C++ compiler only for testing.
57AC_PROG_CXX
e4693aa7
RM
58# It's useless to us if it can't link programs (e.g. missing -lstdc++).
59AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
60AC_LANG_PUSH([C++])
d337ceb7 61# Default, dynamic case.
e4693aa7
RM
62AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
63 [libc_cv_cxx_link_ok=yes],
64 [libc_cv_cxx_link_ok=no])
d337ceb7
FW
65# Static case.
66old_LDFLAGS="$LDFLAGS"
67LDFLAGS="$LDFLAGS -static"
68AC_LINK_IFELSE([AC_LANG_SOURCE([
69#include <iostream>
70
71int
72main()
73{
74 std::cout << "Hello, world!";
75 return 0;
76}
77])],
78 [],
79 [libc_cv_cxx_link_ok=no])
80LDFLAGS="$old_LDFLAGS"
e4693aa7
RM
81AC_LANG_POP([C++])])
82AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
c0bac8b0 83
db340c90 84if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
c72637d4
RM
85 AC_MSG_ERROR([you must configure in a separate build directory])
86fi
87
28f540f4
RM
88# This will get text that should go into config.make.
89config_vars=
90
c8f3e6db 91# Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
6b7f6183 92AC_ARG_WITH([gd],
83103074 93 AS_HELP_STRING([--with-gd=DIR],
77e8bddf 94 [find libgd include dir and library with prefix DIR]),
c8f3e6db
UD
95 [dnl
96case "$with_gd" in
f5f7239f
UD
97yes|''|no) ;;
98*) libgd_include="-I$withval/include"
c8f3e6db
UD
99 libgd_ldflags="-L$withval/lib" ;;
100esac
101])
6b7f6183 102AC_ARG_WITH([gd-include],
83103074 103 AS_HELP_STRING([--with-gd-include=DIR],
77e8bddf
AS
104 [find libgd include files in DIR]),
105 [dnl
f5f7239f
UD
106case "$with_gd_include" in
107''|no) ;;
108*) libgd_include="-I$withval" ;;
109esac
110])
6b7f6183 111AC_ARG_WITH([gd-lib],
83103074 112 AS_HELP_STRING([--with-gd-lib=DIR],
77e8bddf
AS
113 [find libgd library files in DIR]),
114 [dnl
f5f7239f
UD
115case "$with_gd_lib" in
116''|no) ;;
117*) libgd_ldflags="-L$withval" ;;
118esac
119])
120
121if test -n "$libgd_include"; then
122 config_vars="$config_vars
cf90163d 123CFLAGS-memusagestat.c = $libgd_include"
f5f7239f
UD
124fi
125if test -n "$libgd_ldflags"; then
126 config_vars="$config_vars
127libgd-LDFLAGS = $libgd_ldflags"
128fi
28f540f4 129
ff3d7ed3 130dnl Arguments to specify presence of other packages/features.
6b7f6183 131AC_ARG_WITH([binutils],
83103074 132 AS_HELP_STRING([--with-binutils=PATH],
77e8bddf 133 [specify location of binutils (as and ld)]),
6b7f6183
RM
134 [path_binutils=$withval],
135 [path_binutils=''])
2fff3d93 136AC_ARG_WITH([selinux],
83103074 137 AS_HELP_STRING([--with-selinux],
77e8bddf 138 [if building with SELinux support]),
2fff3d93
UD
139 [with_selinux=$withval],
140 [with_selinux=auto])
28f540f4 141
6b7f6183 142AC_ARG_WITH([headers],
83103074 143 AS_HELP_STRING([--with-headers=PATH],
77e8bddf 144 [location of system headers to use
6b7f6183
RM
145 (for example /usr/src/linux/include)
146 @<:@default=compiler default@:>@]),
147 [sysheaders=$withval],
148 [sysheaders=''])
c91c505f 149AC_SUBST(sysheaders)
dbe7a0f5 150
f781ef40
RM
151AC_SUBST(use_default_link)
152AC_ARG_WITH([default-link],
83103074 153 AS_HELP_STRING([--with-default-link],
fd5e21c7 154 [do not use explicit linker scripts]),
f781ef40 155 [use_default_link=$withval],
198abcbb 156 [use_default_link=no])
f781ef40 157
6413fcde
FW
158dnl Additional build flags injection.
159AC_ARG_WITH([nonshared-cflags],
83103074 160 AS_HELP_STRING([--with-nonshared-cflags=CFLAGS],
6413fcde
FW
161 [build nonshared libraries with additional CFLAGS]),
162 [extra_nonshared_cflags=$withval],
163 [extra_nonshared_cflags=])
164AC_SUBST(extra_nonshared_cflags)
9ba202c7
FW
165AC_ARG_WITH([rtld-early-cflags],
166 AS_HELP_STRING([--with-rtld-early-cflags=CFLAGS],
167 [build early initialization with additional CFLAGS]),
168 [rtld_early_cflags=$withval],
169 [rtld_early_cflags=])
170AC_SUBST(rtld_early_cflags)
6413fcde 171
bada2e31
L
172AC_ARG_WITH([timeoutfactor],
173 AS_HELP_STRING([--with-timeoutfactor=NUM],
174 [specify an integer to scale the timeout]),
175 [timeoutfactor=$withval],
176 [timeoutfactor=1])
177AC_DEFINE_UNQUOTED(TIMEOUTFACTOR, $timeoutfactor)
178
6b7f6183 179AC_ARG_ENABLE([sanity-checks],
83103074 180 AS_HELP_STRING([--disable-sanity-checks],
77e8bddf 181 [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
6b7f6183
RM
182 [enable_sanity=$enableval],
183 [enable_sanity=yes])
a18f587d 184
6b7f6183 185AC_ARG_ENABLE([shared],
83103074 186 AS_HELP_STRING([--enable-shared],
a0da5fe1 187 [build shared library @<:@default=yes if GNU ld@:>@]),
6b7f6183 188 [shared=$enableval],
a0da5fe1 189 [shared=yes])
6b7f6183 190AC_ARG_ENABLE([profile],
83103074 191 AS_HELP_STRING([--enable-profile],
77e8bddf 192 [build profiled library @<:@default=no@:>@]),
6b7f6183 193 [profile=$enableval],
11bf311e 194 [profile=no])
23645707
SP
195AC_ARG_ENABLE([default-pie],
196 AS_HELP_STRING([--disable-default-pie],
197 [Do not build glibc programs and the testsuite as PIE @<:@default=no@:>@]),
198 [default_pie=$enableval],
199 [default_pie=yes])
1cba4036 200AC_ARG_ENABLE([timezone-tools],
83103074 201 AS_HELP_STRING([--disable-timezone-tools],
44f826e3 202 [do not install timezone tools @<:@default=install@:>@]),
1cba4036
MF
203 [enable_timezone_tools=$enableval],
204 [enable_timezone_tools=yes])
205AC_SUBST(enable_timezone_tools)
6b7f6183 206
740b3dbe 207AC_ARG_ENABLE([hardcoded-path-in-tests],
83103074 208 AS_HELP_STRING([--enable-hardcoded-path-in-tests],
740b3dbe
L
209 [hardcode newly built glibc path in tests @<:@default=no@:>@]),
210 [hardcoded_path_in_tests=$enableval],
211 [hardcoded_path_in_tests=no])
212AC_SUBST(hardcoded_path_in_tests)
213
6b7f6183 214AC_ARG_ENABLE([hidden-plt],
83103074 215 AS_HELP_STRING([--disable-hidden-plt],
77e8bddf 216 [do not hide internal function calls to avoid PLT]),
6b7f6183
RM
217 [hidden=$enableval],
218 [hidden=yes])
749a9a4f
RM
219if test "x$hidden" = xno; then
220 AC_DEFINE(NO_HIDDEN)
221fi
222
4df8c11d 223AC_ARG_ENABLE([bind-now],
83103074 224 AS_HELP_STRING([--enable-bind-now],
4df8c11d
UD
225 [disable lazy relocations in DSOs]),
226 [bindnow=$enableval],
227 [bindnow=no])
228AC_SUBST(bindnow)
6901def6
L
229if test "x$bindnow" = xyes; then
230 AC_DEFINE(BIND_NOW)
231fi
4df8c11d 232
03baef1c
NA
233dnl Build glibc with -fstack-protector, -fstack-protector-all, or
234dnl -fstack-protector-strong.
235AC_ARG_ENABLE([stack-protector],
83103074 236 AS_HELP_STRING([--enable-stack-protector=@<:@yes|no|all|strong@:>@],
03baef1c
NA
237 [Use -fstack-protector[-all|-strong] to detect glibc buffer overflows]),
238 [enable_stack_protector=$enableval],
239 [enable_stack_protector=no])
240case "$enable_stack_protector" in
241all|yes|no|strong) ;;
242*) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: \"$enable_stack_protector\"]);;
243esac
244
5107cf1d
UD
245dnl On some platforms we cannot use dynamic loading. We must provide
246dnl static NSS modules.
6b7f6183 247AC_ARG_ENABLE([static-nss],
83103074 248 AS_HELP_STRING([--enable-static-nss],
77e8bddf 249 [build static NSS modules @<:@default=no@:>@]),
6b7f6183
RM
250 [static_nss=$enableval],
251 [static_nss=no])
834cef7c
UD
252dnl Enable static NSS also if we build no shared objects.
253if test x"$static_nss" = xyes || test x"$shared" = xno; then
3172f58f 254 static_nss=yes
5107cf1d
UD
255 AC_DEFINE(DO_STATIC_NSS)
256fi
257
6b7f6183 258AC_ARG_ENABLE([force-install],
83103074 259 AS_HELP_STRING([--disable-force-install],
77e8bddf 260 [don't force installation of files from this package, even if they are older than the installed files]),
6b7f6183
RM
261 [force_install=$enableval],
262 [force_install=yes])
73237de3
UD
263AC_SUBST(force_install)
264
8894bad3 265AC_ARG_ENABLE([maintainer-mode],
83103074 266 AS_HELP_STRING([--enable-maintainer-mode],
8894bad3
AM
267 [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
268 [maintainer=$enableval],
269 [maintainer=no])
270
958f238f
UD
271dnl On some platforms we allow dropping compatibility with all kernel
272dnl versions.
6b7f6183 273AC_ARG_ENABLE([kernel],
83103074 274 AS_HELP_STRING([--enable-kernel=VERSION],
77e8bddf 275 [compile for compatibility with kernel not older than VERSION]),
6b7f6183
RM
276 [minimum_kernel=$enableval],
277 [])
86cfe82d
UD
278dnl Prevent unreasonable values.
279if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
280 # Better nothing than this.
281 minimum_kernel=""
269e369f
UD
282else
283 if test "$minimum_kernel" = current; then
284 minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
285 fi
86cfe82d 286fi
958f238f 287
6cc7d725
UD
288dnl For the development we sometimes want gcc to issue even more warnings.
289dnl This is not the default since many of the extra warnings are not
290dnl appropriate.
6b7f6183 291AC_ARG_ENABLE([all-warnings],
83103074 292 AS_HELP_STRING([--enable-all-warnings],
77e8bddf 293 [enable all useful warnings gcc can issue]),
6b7f6183
RM
294 [all_warnings=$enableval],
295 [])
6cc7d725
UD
296AC_SUBST(all_warnings)
297
a4ecc9eb 298AC_ARG_ENABLE([werror],
83103074 299 AS_HELP_STRING([--disable-werror],
a4ecc9eb
JM
300 [do not build with -Werror]),
301 [enable_werror=$enableval],
302 [enable_werror=yes])
303AC_SUBST(enable_werror)
304
425ce2ed 305AC_ARG_ENABLE([multi-arch],
83103074 306 AS_HELP_STRING([--enable-multi-arch],
425ce2ed
UD
307 [enable single DSO with optimizations for multiple architectures]),
308 [multi_arch=$enableval],
6f89d2f3 309 [multi_arch=default])
425ce2ed 310
d5c3fafc 311AC_ARG_ENABLE([experimental-malloc],
83103074 312 AS_HELP_STRING([--disable-experimental-malloc],
d5c3fafc
DD
313 [disable experimental malloc features]),
314 [experimental_malloc=$enableval],
315 [experimental_malloc=yes])
316AC_SUBST(experimental_malloc)
317
33784089 318AC_ARG_ENABLE([memory-tagging],
83103074 319 AS_HELP_STRING([--enable-memory-tagging],
33784089
RE
320 [enable memory tagging if supported by the architecture @<:@default=no@:>@]),
321 [memory_tagging=$enableval],
322 [memory_tagging=no])
323if test "$memory_tagging" = yes; then
324 # Only enable this on architectures that support it.
325 case $host_cpu in
326 aarch64)
327 AC_DEFINE(USE_MTAG)
328 ;;
329 esac
330fi
331AC_SUBST(memory_tagging)
332
e69d994a 333AC_ARG_ENABLE([crypt],
83103074 334 AS_HELP_STRING([--disable-crypt],
e69d994a
ZW
335 [do not build nor install the passphrase hashing library, libcrypt]),
336 [build_crypt=$enableval],
337 [build_crypt=yes])
338AC_SUBST(build_crypt)
339
ff886b82 340AC_ARG_ENABLE([nss-crypt],
83103074 341 AS_HELP_STRING([--enable-nss-crypt],
ff886b82
UD
342 [enable libcrypt to use nss]),
343 [nss_crypt=$enableval],
344 [nss_crypt=no])
e69d994a
ZW
345if test x$build_libcrypt = xno && test x$nss_crypt = xyes; then
346 AC_MSG_WARN([--enable-nss-crypt has no effect when libcrypt is disabled])
347 nss_crypt=no
348fi
ff886b82
UD
349if test x$nss_crypt = xyes; then
350 nss_includes=-I$(nss-config --includedir 2>/dev/null)
351 if test $? -ne 0; then
352 AC_MSG_ERROR([cannot find include directory with nss-config])
353 fi
57b4af19
GT
354 nspr_includes=-I$(nspr-config --includedir 2>/dev/null)
355 if test $? -ne 0; then
356 AC_MSG_ERROR([cannot find include directory with nspr-config])
357 fi
ff886b82 358 old_CFLAGS="$CFLAGS"
57b4af19 359 CFLAGS="$CFLAGS $nss_includes $nspr_includes"
b68e08db 360 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
ff886b82
UD
361#include <hasht.h>
362#include <nsslowhash.h>
b68e08db 363void f (void) { NSSLOW_Init (); }])],
ff886b82
UD
364 libc_cv_nss_crypt=yes,
365 AC_MSG_ERROR([
366cannot find NSS headers with lowlevel hash function interfaces]))
367 old_LIBS="$LIBS"
84aa7516 368 old_LDFLAGS="$LDFLAGS"
ff886b82
UD
369 LIBS="$LIBS -lfreebl3"
370 AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
371#include <hasht.h>
372#include <nsslowhash.h>],
373 [NSSLOW_Init();])],
374 libc_cv_nss_crypt=yes,
375 AC_MSG_ERROR([
376cannot link program using lowlevel NSS hash functions]))
84aa7516
CD
377 # Check to see if there is a static NSS cryptographic library.
378 # If there isn't then we can't link anything with libcrypt.a,
379 # and that might mean disabling some static tests.
380 LDFLAGS="$LDFLAGS -static"
381 AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
382#include <hasht.h>
383#include <nsslowhash.h>],
384 [NSSLOW_Init();])],
385 libc_cv_static_nss_crypt=yes,
386 libc_cv_static_nss_crypt=no)
387 LDFLAGS="$old_LDFLAGS"
ff886b82
UD
388 CFLAGS="$old_CFLAGS"
389 LIBS="$old_LIBS"
390else
391 libc_cv_nss_crypt=no
84aa7516 392 libc_cv_static_nss_crypt=no
ff886b82
UD
393fi
394AC_SUBST(libc_cv_nss_crypt)
84aa7516 395AC_SUBST(libc_cv_static_nss_crypt)
ff886b82 396
3a097cc7 397
3a097cc7
RM
398AC_ARG_ENABLE([systemtap],
399 [AS_HELP_STRING([--enable-systemtap],
400 [enable systemtap static probe points @<:@default=no@:>@])],
401 [systemtap=$enableval],
402 [systemtap=no])
403if test "x$systemtap" != xno; then
404 AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
405 old_CFLAGS="$CFLAGS"
783dd2d3 406 CFLAGS="-std=gnu11 $CFLAGS"
0e3933b9 407 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
3a097cc7
RM
408void foo (int i, void *p)
409{
410 asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
411 :: STAP_PROBE_ASM_OPERANDS (2, i, p));
0e3933b9 412}]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
3a097cc7
RM
413 CFLAGS="$old_CFLAGS"])
414 if test $libc_cv_sdt = yes; then
415 AC_DEFINE([USE_STAP_PROBE])
416 elif test "x$systemtap" != xauto; then
417 AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
418 fi
419fi
420
c53d909c
RM
421AC_ARG_ENABLE([build-nscd],
422 [AS_HELP_STRING([--disable-build-nscd],
423 [disable building and installing the nscd daemon])],
424 [build_nscd=$enableval],
425 [build_nscd=default])
426AC_SUBST(build_nscd)
427
3cc3ef96
RM
428# Note the use of $use_nscd is near the bottom of the file.
429AC_ARG_ENABLE([nscd],
430 [AS_HELP_STRING([--disable-nscd],
431 [library functions will not contact the nscd daemon])],
432 [use_nscd=$enableval],
433 [use_nscd=yes])
434
e4608715
CD
435AC_ARG_ENABLE([pt_chown],
436 [AS_HELP_STRING([--enable-pt_chown],
437 [Enable building and installing pt_chown])],
438 [build_pt_chown=$enableval],
439 [build_pt_chown=no])
440AC_SUBST(build_pt_chown)
8c12f01d 441if test "$build_pt_chown" = yes; then
e4608715
CD
442 AC_DEFINE(HAVE_PT_CHOWN)
443fi
444
67e58f39
SP
445AC_ARG_ENABLE([tunables],
446 [AS_HELP_STRING([--enable-tunables],
6765d5d3 447 [Enable tunables support. Known values are 'yes', 'no' and 'valstring'])],
67e58f39 448 [have_tunables=$enableval],
2c0b90ab 449 [have_tunables=yes])
67e58f39
SP
450AC_SUBST(have_tunables)
451if test "$have_tunables" = yes; then
452 AC_DEFINE(HAVE_TUNABLES)
453fi
454
ebf27d12
ST
455# The abi-tags file uses a fairly simplistic model for name recognition that
456# can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
457# $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
458# This doesn't get used much beyond that, so it's fairly safe.
459case "$host_os" in
460linux*)
461 ;;
462gnu*)
463 host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
464 ;;
465esac
466
5695d46f
AS
467AC_ARG_ENABLE([mathvec],
468 [AS_HELP_STRING([--enable-mathvec],
469 [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
470 [build_mathvec=$enableval],
471 [build_mathvec=notset])
472
b190bccc 473AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
9fb81390
FW
474#ifndef __CET__
475# error no CET compiler support
b190bccc 476#endif]])],
9fb81390
FW
477 [libc_cv_compiler_default_cet=yes],
478 [libc_cv_compiler_default_cet=no])
479
f753fa7d 480AC_ARG_ENABLE([cet],
83103074 481 AS_HELP_STRING([--enable-cet],
f753fa7d
L
482 [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
483 [enable_cet=$enableval],
9fb81390 484 [enable_cet=$libc_cv_compiler_default_cet])
f753fa7d 485
ebae2f5a
MC
486AC_ARG_ENABLE([scv],
487 AC_HELP_STRING([--disable-scv],
488 [syscalls will not use scv instruction, even if the kernel supports it, powerpc only]),
489 [use_scv=$enableval],
490 [use_scv=yes])
491
492AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
493
28f540f4
RM
494# We keep the original values in `$config_*' and never modify them, so we
495# can write them unchanged into config.make. Everything else uses
496# $machine, $vendor, and $os, and changes them whenever convenient.
497config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
498
2f64b655
UD
499# Don't allow vendor == "unknown"
500test "$config_vendor" = unknown && config_vendor=
501config_os="`echo $config_os | sed 's/^unknown-//'`"
502
a2fe9c76 503# Some configurations imply other options.
0269750c 504elf=yes
a2fe9c76 505
644d3857 506# The configure fragment of a port can modify these to supplement
8f73811b
RM
507# or override the table in the case statement below. No fragment should
508# ever change the config_* variables, however.
28f540f4
RM
509machine=$config_machine
510vendor=$config_vendor
511os=$config_os
b22d21b3 512base_os=''
28f540f4 513
2ceaa76a
RM
514submachine=
515AC_ARG_WITH([cpu],
516 AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
517 [dnl
518 case "$withval" in
519 yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
520 no) ;;
521 *) submachine="$withval" ;;
522 esac
523])
524
05439291
RM
525# An preconfigure script can set this when it wants to disable the sanity
526# check below.
527libc_config_ok=no
528
8df5d347
JM
529# A preconfigure script for a system that may or may not use fpu
530# sysdeps directories sets this to a preprocessor conditional for
531# whether to use such directories.
532with_fp_cond=1
533
644d3857 534dnl Let sysdeps/*/preconfigure act here.
10a803e0
RM
535LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
536
8f73811b 537
bdc8eb03
UD
538###
539### By using the undocumented --enable-hacker-mode option for configure
540### one can skip this test to make the configuration not fail for unsupported
541### platforms.
542###
8f73811b 543if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
bdc8eb03 544 case "$machine-$host_os" in
2ce4f015 545 *-linux* | *-gnu*)
bdc8eb03
UD
546 ;;
547 *)
4e58b648
MF
548 AC_MSG_ERROR([
549*** The GNU C library is currently unavailable for this platform.
550*** If you are interested in seeing glibc on this platform visit
551*** the "How to submit a new port" in the wiki:
552*** https://sourceware.org/glibc/wiki/#Development
553*** and join the community!])
bdc8eb03
UD
554 ;;
555 esac
556fi
557
3e239be6
JM
558# Set base_machine if not set by a preconfigure fragment.
559test -n "$base_machine" || base_machine=$machine
f0523145 560AC_SUBST(base_machine)
28f540f4 561
8df5d347
JM
562# Determine whether to use fpu or nofpu sysdeps directories.
563AC_CACHE_CHECK([for use of fpu sysdeps directories],
564 libc_cv_with_fp, [dnl
565cat > conftest.c <<EOF
566#if $with_fp_cond
567int dummy;
568#else
569# error "no hardware floating point"
570#endif
571EOF
572libc_cv_with_fp=no
573if ${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c -o conftest.s \
574 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
575 libc_cv_with_fp=yes
576fi
577rm -f conftest*])
578AC_SUBST(libc_cv_with_fp)
579
03baef1c
NA
580AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
581LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
582 [libc_cv_ssp=yes],
583 [libc_cv_ssp=no])
584])
585
586AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
587LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
588 [libc_cv_ssp_strong=yes],
589 [libc_cv_ssp_strong=no])
590])
591
592AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
593LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
594 [libc_cv_ssp_all=yes],
595 [libc_cv_ssp_all=no])
596])
597
598stack_protector=
599no_stack_protector=
600if test "$libc_cv_ssp" = yes; then
601 no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
de659123 602 AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
03baef1c
NA
603fi
604
605if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
606 stack_protector="-fstack-protector"
607 AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
608elif test "$enable_stack_protector" = all && test "$libc_cv_ssp_all" = yes; then
609 stack_protector="-fstack-protector-all"
610 AC_DEFINE(STACK_PROTECTOR_LEVEL, 2)
611elif test "$enable_stack_protector" = strong && test "$libc_cv_ssp_strong" = yes; then
612 stack_protector="-fstack-protector-strong"
613 AC_DEFINE(STACK_PROTECTOR_LEVEL, 3)
66a704c4
NA
614else
615 stack_protector="-fno-stack-protector"
616 AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
03baef1c
NA
617fi
618AC_SUBST(libc_cv_ssp)
619AC_SUBST(stack_protector)
620AC_SUBST(no_stack_protector)
621
66a704c4
NA
622if test -n "$stack_protector"; then
623 dnl Don't run configure tests with stack-protection on, to avoid problems with
624 dnl bootstrapping.
625 no_ssp=-fno-stack-protector
626else
627 no_ssp=
628
629 if test "$enable_stack_protector" != no; then
630 AC_MSG_ERROR([--enable-stack-protector=$enable_stack_protector specified, but specified level of stack protection is not supported by the compiler.])
631 fi
632fi
633
0cae3f4b
MF
634# For the multi-arch option we need support in the assembler & linker.
635AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
636 libc_cv_ld_gnu_indirect_function, [dnl
786b0b67 637cat > conftest.S <<EOF
84b9230c 638.type foo,%gnu_indirect_function
0cae3f4b
MF
639foo:
640.globl _start
641_start:
642.globl __start
643__start:
644.data
786b0b67
AS
645#ifdef _LP64
646.quad foo
647#else
0cae3f4b 648.long foo
786b0b67 649#endif
84b9230c 650EOF
0cae3f4b
MF
651libc_cv_ld_gnu_indirect_function=no
652if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
66a704c4 653 -nostartfiles -nostdlib $no_ssp \
786b0b67 654 -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
0cae3f4b
MF
655 # Do a link to see if the backend supports IFUNC relocs.
656 $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
87a698a2 657 LC_ALL=C $READELF -Wr conftest | grep -q 'IRELATIVE\|R_SPARC_JMP_IREL' && {
0cae3f4b
MF
658 libc_cv_ld_gnu_indirect_function=yes
659 }
84b9230c
MF
660fi
661rm -f conftest*])
662
022dfdce
SL
663# Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
664AC_CACHE_CHECK([for gcc attribute ifunc support],
665 libc_cv_gcc_indirect_function, [dnl
666cat > conftest.c <<EOF
667extern int func (int);
668int used_func (int a)
669{
670 return a;
671}
672static void *resolver ()
673{
674 return &used_func;
675}
676extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
677EOF
678libc_cv_gcc_indirect_function=no
679if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
680 2>&AS_MESSAGE_LOG_FD ; then
681 if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
682 libc_cv_gcc_indirect_function=yes
683 fi
684fi
685rm -f conftest*])
686
b5c45e83
AZ
687# Check if linker supports textrel relocation with ifunc (used on elf/tests).
688# Note that it relies on libc_cv_ld_gnu_indirect_function test above.
689AC_CACHE_CHECK([whether the linker supports textrels along with ifunc],
690 libc_cv_textrel_ifunc, [dnl
691cat > conftest.S <<EOF
692.type foo,%gnu_indirect_function
693foo:
694.globl _start
695_start:
696.globl __start
697__start:
698.data
699#ifdef _LP64
700.quad foo
701#else
702.long foo
703#endif
704.text
705.globl address
706address:
707#ifdef _LP64
708.quad address
709#else
710.long address
711#endif
712EOF
713libc_cv_textrel_ifunc=no
714if test $libc_cv_ld_gnu_indirect_function = yes; then
715 if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp -pie -o conftest conftest.S); then
716 libc_cv_textrel_ifunc=yes
717 fi
718fi
719rm -f conftest*])
720AC_SUBST(libc_cv_textrel_ifunc)
721
cd6ae7ea
FS
722# Check if CC supports attribute retain as it is used in attribute_used_retain macro.
723AC_CACHE_CHECK([for GNU attribute retain support],
724 libc_cv_gnu_retain, [dnl
725cat > conftest.c <<EOF
726static int var __attribute__ ((used, retain, section ("__libc_atexit")));
727EOF
728libc_cv_gnu_retain=no
729if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&AS_MESSAGE_LOG_FD \
730 2>&AS_MESSAGE_LOG_FD ; then
731 libc_cv_gnu_retain=yes
732fi
733rm -f conftest*])
734if test $libc_cv_gnu_retain = yes; then
735 AC_DEFINE(HAVE_GNU_RETAIN)
736fi
737LIBC_CONFIG_VAR([have-gnu-retain], [$libc_cv_gnu_retain])
738
8f6f5362
AZ
739# Check if gcc warns about alias for function with incompatible types.
740AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
741 libc_cv_gcc_incompatible_alias, [dnl
742cat > conftest.c <<EOF
743int __redirect_foo (const void *s, int c);
744
745__typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
746__typeof (__redirect_foo) *foo_impl (void)
747{
748 return 0;
749}
750
751extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
752EOF
753libc_cv_gcc_incompatible_alias=yes
754if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
755 libc_cv_gcc_incompatible_alias=no
756fi
757rm -f conftest*])
758
0cae3f4b 759if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
84b9230c
MF
760 if test x"$multi_arch" = xyes; then
761 AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
762 else
763 multi_arch=no
764 fi
765fi
8f6f5362
AZ
766if test x"$libc_cv_gcc_indirect_function" != xyes; then
767 # GCC 8+ emits a warning for alias with incompatible types and it might
768 # fail to build ifunc resolvers aliases to either weak or internal
769 # symbols. Disables multiarch build in this case.
cb7b1c90 770 if test x"$libc_cv_gcc_incompatible_alias" = xyes; then
8f6f5362
AZ
771 AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
772 if test x"$multi_arch" = xyes; then
773 AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
774 fi
775 AC_MSG_WARN([Multi-arch is disabled.])
776 multi_arch=no
777 elif test x"$multi_arch" = xyes; then
778 AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
022dfdce 779Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
8f6f5362 780 fi
022dfdce 781fi
6270516e 782multi_arch_d=
84b9230c
MF
783if test x"$multi_arch" != xno; then
784 multi_arch_d=/multiarch
785fi
786
f0523145 787# Compute the list of sysdep directories for this configuration.
f332db02 788# This can take a while to compute.
f0523145 789sysdep_dir=$srcdir/sysdeps
f332db02 790AC_MSG_CHECKING(sysdep dirs)
f0523145
RM
791dnl We need to use [ and ] for other purposes for a while now.
792changequote(,)dnl
28f540f4
RM
793# Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
794os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
795
b22d21b3 796test "x$base_os" != x || case "$os" in
28f540f4
RM
797gnu*)
798 base_os=mach/hurd ;;
2ce4f015 799linux*)
28f540f4 800 base_os=unix/sysv ;;
28f540f4
RM
801esac
802
803# For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
804tail=$os
805ostry=$os
806while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
807 ostry="$ostry /$o"
808 tail=$o
75914335 809done
28f540f4
RM
810o=`echo $tail | sed 's/[0-9]*$//'`
811if test $o != $tail; then
812 ostry="$ostry /$o"
813fi
ec4b0518
UD
814# For linux-gnu, try linux-gnu, then linux.
815o=`echo $tail | sed 's/-.*$//'`
816if test $o != $tail; then
817 ostry="$ostry /$o"
818fi
28f540f4
RM
819
820# For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
821base=
822tail=$base_os
823while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
824 set $b
825 base="$base /$1"
826 tail="$2"
827done
828
ae6b8730 829# For sparc/sparc32, try sparc/sparc32 and then sparc.
28f540f4 830mach=
2ceaa76a 831tail=$machine${submachine:+/$submachine}
28f540f4
RM
832while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
833 set $m
a63189c0
AZ
834 # Prepend the machine's FPU directory unless the architecture specific
835 # preconfigure disables it.
8df5d347 836 if test "$libc_cv_with_fp" = yes; then
6270516e 837 maybe_fpu=/fpu
f4b07664 838 else
6270516e 839 maybe_fpu=/nofpu
82d00cab 840 fi
6270516e
RM
841 # For each machine term, try it with and then without /multiarch.
842 for try_fpu in $maybe_fpu ''; do
843 for try_multi in $multi_arch_d ''; do
844 mach="$mach /$1$try_fpu$try_multi"
845 done
846 done
28f540f4
RM
847 tail="$2"
848done
849
850dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
851changequote([,])dnl
852
853# Find what sysdep directories exist.
854sysnames=
4b69abad
RM
855for b in $base ''; do
856 for m0 in $mach ''; do
857 for v in /$vendor ''; do
858 test "$v" = / && continue
859 for o in /$ostry ''; do
860 test "$o" = / && continue
6270516e 861 for m in $mach ''; do
644d3857
JM
862 try_suffix="$m0$b$v$o$m"
863 if test -n "$try_suffix"; then
864 try_srcdir="${srcdir}/"
865 try="sysdeps$try_suffix"
866 test -n "$enable_debug_configure" &&
867 echo "$0 [DEBUG]: try $try" >&2
868 if test -d "$try_srcdir$try"; then
869 sysnames="$sysnames $try"
870 { test -n "$o" || test -n "$b"; } && os_used=t
871 { test -n "$m" || test -n "$m0"; } && machine_used=t
872 case x${m0:-$m} in
873 x*/$submachine) submachine_used=t ;;
874 esac
875 fi
876 fi
28f540f4
RM
877 done
878 done
879 done
880 done
4b69abad 881done
28f540f4 882
6f89d2f3
L
883# If the assembler supports gnu_indirect_function symbol type and the
884# architecture supports multi-arch, we enable multi-arch by default.
644d3857 885case $sysnames in
84b9230c
MF
886*"$multi_arch_d"*)
887 ;;
888*)
77e8bddf 889 test x"$multi_arch" = xdefault && multi_arch=no
84b9230c
MF
890 ;;
891esac
892if test x"$multi_arch" != xno; then
6f89d2f3
L
893 AC_DEFINE(USE_MULTIARCH)
894fi
895AC_SUBST(multi_arch)
896
28f540f4
RM
897if test -z "$os_used" && test "$os" != none; then
898 AC_MSG_ERROR(Operating system $os is not supported.)
899fi
900if test -z "$machine_used" && test "$machine" != none; then
901 AC_MSG_ERROR(The $machine is not supported.)
902fi
2ceaa76a
RM
903if test -z "$submachine_used" && test -n "$submachine"; then
904 AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
905fi
906AC_SUBST(submachine)
28f540f4
RM
907
908# We have now validated the configuration.
909
28f540f4
RM
910# Expand the list of system names into a full list of directories
911# from each element's parent name and Implies file (if present).
912set $sysnames
e50ec9f9 913names=
28f540f4
RM
914while test $# -gt 0; do
915 name=$1
916 shift
917
e50ec9f9 918 case " $names " in *" $name "*)
f332db02
RM
919 # Already in the list.
920 continue
e50ec9f9 921 esac
f332db02
RM
922
923 # Report each name as we discover it, so there is no long pause in output.
0b4ee387 924 echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
f332db02 925
57ba7bb4
UD
926 name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
927
928 case $name in
929 /*) xsrcdir= ;;
930 *) xsrcdir=$srcdir/ ;;
931 esac
932 test -n "$enable_debug_configure" &&
933 echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
934
ba75122d
RM
935 for implies_file in Implies Implies-before Implies-after; do
936 implies_type=`echo $implies_file | sed s/-/_/`
937 eval ${implies_type}=
938 if test -f $xsrcdir$name/$implies_file; then
939 # Collect more names from the `Implies' file (removing comments).
940 implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
941 for x in $implied_candidate; do
942 found=no
943 if test -d $xsrcdir$name_base/$x; then
944 eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
636ccfc8 945 found=yes
ba75122d 946 fi
644d3857
JM
947 try="sysdeps/$x"
948 try_srcdir=$srcdir/
949 test -n "$enable_debug_configure" &&
950 echo "[DEBUG]: $name $implies_file $x try() {$try_srcdir}$try" >&2
951 if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
952 then
953 eval "${implies_type}=\"\$${implies_type} \$try\""
954 found=yes
955 fi
ba75122d
RM
956 if test $found = no; then
957 AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
636ccfc8
UD
958 fi
959 done
ba75122d
RM
960 fi
961 done
28f540f4
RM
962
963 # Add NAME to the list of names.
964 names="$names $name"
965
966 # Find the parent of NAME, using the empty string if it has none.
967changequote(,)dnl
57ba7bb4 968 parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
28f540f4
RM
969changequote([,])dnl
970
ba75122d
RM
971 test -n "$enable_debug_configure" &&
972 echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
57633811 973Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
ba75122d 974
28f540f4
RM
975 # Add the names implied by NAME, and NAME's parent (if it has one), to
976 # the list of names to be processed (the argument list). We prepend the
977 # implied names to the list and append the parent. We want implied
978 # directories to come before further directories inferred from the
979 # configuration components; this ensures that for sysv4, unix/common
980 # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
981 # after sysv4).
ba75122d 982 sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
28f540f4
RM
983 test -n "$sysnames" && set $sysnames
984done
985
986# Add the default directories.
83ef87ba 987default_sysnames="sysdeps/generic"
ecdc196c 988sysnames="$names $default_sysnames"
f332db02
RM
989AC_SUBST(sysnames)
990# The other names were emitted during the scan.
ecdc196c 991AC_MSG_RESULT($default_sysnames)
28f540f4 992
f332db02
RM
993
994### Locate tools.
28f540f4 995
28f540f4 996AC_PROG_INSTALL
2b80a372 997if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
28f540f4 998 # The makefiles need to use a different form to find it in $srcdir.
2b80a372 999 INSTALL='\$(..)./scripts/install-sh -c'
28f540f4 1000fi
0e3426bb 1001AC_PROG_LN_S
ae828bc6 1002
4baa087a 1003LIBC_PROG_BINUTILS
4baa087a 1004
b4396163 1005# Accept binutils 2.25 or newer.
4baa087a
RM
1006AC_CHECK_PROG_VER(AS, $AS, --version,
1007 [GNU assembler.* \([0-9]*\.[0-9.]*\)],
b4396163 1008 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
bd805071 1009 AS=: critic_missing="$critic_missing as")
f300dc73 1010
224edada
FS
1011libc_cv_with_lld=no
1012case $($LD --version) in
1013 "GNU gold"*)
f300dc73 1014 # Accept gold 1.14 or higher
224edada 1015 AC_CHECK_PROG_VER(LD, $LD, --version,
f300dc73
L
1016 [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
1017 [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
1018 LD=: critic_missing="$critic_missing GNU gold")
224edada
FS
1019 ;;
1020 "LLD"*)
1021 # Accept LLD 13.0.0 or higher
1022 AC_CHECK_PROG_VER(LD, $LD, --version,
1023 [LLD.* \([0-9][0-9]*\.[0-9.]*\)],
1024 [1[3-9].*|[2-9][0-9].*],
1025 LD=: critic_missing="$critic_missing LLD")
1026 libc_cv_with_lld=yes
1027 ;;
1028 *)
1029 AC_CHECK_PROG_VER(LD, $LD, --version,
f300dc73 1030 [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
073e8fa7 1031 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
f300dc73 1032 LD=: critic_missing="$critic_missing GNU ld")
224edada
FS
1033 ;;
1034esac
1035LIBC_CONFIG_VAR([with-lld], [$libc_cv_with_lld])
4baa087a 1036
63bda0c1 1037# These programs are version sensitive.
22e65f8f 1038AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
8fc1e2ca 1039 [GNU Make[^0-9]*\([0-9][0-9.]*\)],
f2873d2d 1040 [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
63bda0c1 1041
22e65f8f 1042AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
bdd421cc 1043 [GNU gettext.* \([0-9]*\.[0-9.]*\)],
aefdff34
RM
1044 [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
1045 MSGFMT=: aux_missing="$aux_missing msgfmt")
63bda0c1 1046AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
8b7fb588 1047 [GNU texinfo.* \([0-9][0-9.]*\)],
3a12c70f 1048 [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
aefdff34 1049 MAKEINFO=: aux_missing="$aux_missing makeinfo")
d6a97a28 1050AC_CHECK_PROG_VER(SED, sed, --version,
07e51550 1051 [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
aefdff34
RM
1052 [3.0[2-9]*|3.[1-9]*|[4-9]*],
1053 SED=: aux_missing="$aux_missing sed")
0786794f
AM
1054AC_CHECK_PROG_VER(AWK, gawk, --version,
1055 [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
12086fb4 1056 [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
1faaf703
JB
1057AC_CHECK_PROG_VER(BISON, bison, --version,
1058 [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
1059 [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
63bda0c1 1060
461a7b1e 1061AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
b190bccc 1062AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
4dcbbc3b 1063#if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
461a7b1e 1064#error insufficient compiler
b190bccc 1065#endif]])],
461a7b1e
RM
1066 [libc_cv_compiler_ok=yes],
1067 [libc_cv_compiler_ok=no])])
1068AS_IF([test $libc_cv_compiler_ok != yes],
1069 [critic_missing="$critic_missing compiler"])
1070
30b99d79 1071AC_CHECK_TOOL(NM, nm, false)
d30cf5bb 1072
8894bad3
AM
1073if test "x$maintainer" = "xyes"; then
1074 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
1075 case "x$AUTOCONF" in
1076 xno|x|x:) AUTOCONF=no ;;
1077 *)
1078 AC_CACHE_CHECK(dnl
1079 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
1080 if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
1081 libc_cv_autoconf_works=yes
1082 else
1083 libc_cv_autoconf_works=no
1084 fi])
1085 test $libc_cv_autoconf_works = yes || AUTOCONF=no
1086 ;;
1087 esac
1088 if test "x$AUTOCONF" = xno; then
1089 aux_missing="$aux_missing autoconf"
1090 fi
9e8ac24b
AM
1091else
1092 AUTOCONF=no
14519931 1093fi
1400de2e 1094
8ce8299f 1095# Check for python3 if available, or else python.
c6982f7e
JM
1096AC_CHECK_PROG_VER(PYTHON_PROG, python3 python, --version,
1097 [Python \([0-9][0-9.]*\)],
1098 [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*],
1099 critic_missing="$critic_missing python")
1100PYTHON="$PYTHON_PROG -B"
1101AC_SUBST(PYTHON)
8ce8299f 1102
32a448ed
RM
1103test -n "$critic_missing" && AC_MSG_ERROR([
1104*** These critical programs are missing or too old:$critic_missing
1105*** Check the INSTALL file for required versions.])
1106
4bca4c17 1107test -n "$aux_missing" && AC_MSG_WARN([
9c6fffc0 1108*** These auxiliary programs are missing or incompatible versions:$aux_missing
8ce8299f 1109*** some features or tests will be disabled.
63bda0c1 1110*** Check the INSTALL file for required versions.])
28f540f4 1111
dbe7a0f5
UD
1112# if using special system headers, find out the compiler's sekrit
1113# header directory and add that to the list. NOTE: Only does the right
1114# thing on a system that doesn't need fixincludes. (Not presently a problem.)
1115if test -n "$sysheaders"; then
67fbfa5c
RM
1116 SYSINCLUDES=-nostdinc
1117 for d in include include-fixed; do
1118 i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
1119 SYSINCLUDES="$SYSINCLUDES -isystem $i"
1120 done
1121 SYSINCLUDES="$SYSINCLUDES \
3d6ce23a 1122-isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
ef226fec 1123 if test -n "$CXX"; then
7872cfb0 1124 CXX_SYSINCLUDES=
67060746
AC
1125 for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
1126 | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1127 test "x$cxxheaders" != x &&
1128 CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1129 done
ef226fec 1130 fi
dbe7a0f5
UD
1131fi
1132AC_SUBST(SYSINCLUDES)
ef226fec 1133AC_SUBST(CXX_SYSINCLUDES)
dbe7a0f5 1134
fc3e1337
FW
1135# Obtain some C++ header file paths. This is used to make a local
1136# copy of those headers in Makerules.
1137if test -n "$CXX"; then
1138 find_cxx_header () {
c2528fef
FW
1139 echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
1140 | sed -n "\,$1:,{s/:\$//;p}"
fc3e1337
FW
1141 }
1142 CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
1143 CXX_CMATH_HEADER="$(find_cxx_header cmath)"
a65ea28d 1144 CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
fc3e1337
FW
1145fi
1146AC_SUBST(CXX_CSTDLIB_HEADER)
1147AC_SUBST(CXX_CMATH_HEADER)
a65ea28d 1148AC_SUBST(CXX_BITS_STD_ABS_H)
fc3e1337 1149
3911660e
UD
1150# Test if LD_LIBRARY_PATH contains the notation for the current directory
1151# since this would lead to problems installing/building glibc.
1152# LD_LIBRARY_PATH contains the current directory if one of the following
1153# is true:
1154# - one of the terminals (":" and ";") is the first or last sign
1155# - two terminals occur directly after each other
1156# - the path contains an element with a dot in it
1157AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1158changequote(,)dnl
1159case ${LD_LIBRARY_PATH} in
1160 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
b3a86ae1 1161 ld_library_path_setting="contains current directory"
3911660e
UD
1162 ;;
1163 *)
1164 ld_library_path_setting="ok"
1165 ;;
1166esac
1167changequote([,])dnl
1168AC_MSG_RESULT($ld_library_path_setting)
1169if test "$ld_library_path_setting" != "ok"; then
63bda0c1
UD
1170AC_MSG_ERROR([
1171*** LD_LIBRARY_PATH shouldn't contain the current directory when
1172*** building glibc. Please change the environment variable
1173*** and run configure again.])
3911660e 1174fi
8e31cf7e 1175
26f56c1c 1176AC_PATH_PROG(BASH_SHELL, bash, no)
84384f5b 1177
c0016081 1178AC_PATH_PROG(PERL, perl, no)
2fd5d029
RM
1179if test "$PERL" != no &&
1180 (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1181 PERL=no
ecb06196 1182fi
2f512715
AS
1183AC_PATH_PROG(INSTALL_INFO, install-info, no,
1184 $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
2de00372 1185
b8dc6a10 1186AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
9a70fcab 1187cat > conftest.s <<EOF
8c0c01db 1188.text
ae1025be 1189foo:
df2a0c93 1190.set glibc_conftest_frobozz,foo
7b8e0d49 1191.globl glibc_conftest_frobozz
e215c478 1192EOF
df2a0c93
RM
1193# The alpha-dec-osf1 assembler gives only a warning for `.set'
1194# (but it doesn't work), so we must do a linking check to be sure.
1195cat > conftest1.c <<\EOF
1196extern int glibc_conftest_frobozz;
640f0119 1197void _start() { glibc_conftest_frobozz = 1; }
df2a0c93
RM
1198EOF
1199if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
66a704c4 1200 -nostartfiles -nostdlib $no_ssp \
0b4ee387 1201 -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
e215c478
RM
1202 libc_cv_asm_set_directive=yes
1203else
1204 libc_cv_asm_set_directive=no
1205fi
65b3cbcb 1206rm -f conftest*])
e215c478
RM
1207if test $libc_cv_asm_set_directive = yes; then
1208 AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1209fi
1210
2a723ff6
JM
1211AC_CACHE_CHECK(linker support for protected data symbol,
1212 libc_cv_protected_data,
1213 [cat > conftest.c <<EOF
1214 int bar __attribute__ ((visibility ("protected"))) = 1;
83569fb8 1215EOF
2a723ff6 1216 libc_cv_protected_data=no
66a704c4 1217 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
2a723ff6
JM
1218 cat > conftest.c <<EOF
1219 extern int bar;
1220 int main (void) { return bar; }
83569fb8 1221EOF
66a704c4 1222 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
2a723ff6 1223 libc_cv_protected_data=yes
83569fb8 1224 fi
2a723ff6
JM
1225 fi
1226 rm -f conftest.*
1227 ])
83569fb8
L
1228AC_SUBST(libc_cv_protected_data)
1229
19f1a11e
L
1230AC_CACHE_CHECK(linker support for INSERT in linker script,
1231 libc_cv_insert,
1232 [cat > conftest.c <<EOF
5f07d47e 1233 int __attribute__ ((section(".bar"))) bar = 0x12345678;
19f1a11e
L
1234 int test (void) { return bar; }
1235EOF
1236 cat > conftest.t <<EOF
1237 SECTIONS
1238 {
1239 .bar : { *(.bar) }
1240 }
1241 INSERT AFTER .rela.dyn;
1242EOF
1243 libc_cv_insert=no
1244 if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
1245 libc_cv_insert=yes
1246 fi
1247 rm -f conftest.*
1248 ])
1249AC_SUBST(libc_cv_insert)
1250
a0da5fe1
UD
1251AC_CACHE_CHECK(for broken __attribute__((alias())),
1252 libc_cv_broken_alias_attribute,
1253 [cat > conftest.c <<EOF
1254 extern int foo (int x) __asm ("xyzzy");
1255 int bar (int x) { return x; }
1256 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1257 extern int dfoo;
1258 extern __typeof (dfoo) dfoo __asm ("abccb");
1259 int dfoo = 1;
37ba7d66 1260EOF
a0da5fe1
UD
1261 libc_cv_broken_alias_attribute=yes
1262 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1263 if grep 'xyzzy' conftest.s >/dev/null &&
1264 grep 'abccb' conftest.s >/dev/null; then
1265 libc_cv_broken_alias_attribute=no
1266 fi
1267 fi
1268 rm -f conftest.c conftest.s
1269 ])
1270if test $libc_cv_broken_alias_attribute = yes; then
1271 AC_MSG_ERROR(working alias attribute support required)
1272fi
1273
2a723ff6
JM
1274AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1275 libc_cv_have_sdata_section,
1276 [echo "int i;" > conftest.c
1277 libc_cv_have_sdata_section=no
1278 if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1279 | grep '\.sdata' >/dev/null; then
1280 libc_cv_have_sdata_section=yes
1281 fi
1282 rm -f conftest.c conftest.so
1283 ])
1284if test $libc_cv_have_sdata_section = yes; then
1285 AC_DEFINE(HAVE_SDATA_SECTION)
a0da5fe1 1286fi
0d01dace 1287
a0da5fe1
UD
1288AC_CACHE_CHECK(for libunwind-support in compiler,
1289 libc_cv_cc_with_libunwind, [
1290 cat > conftest.c <<EOF
cbdb12de
UD
1291int main (void) { return 0; }
1292EOF
a0da5fe1 1293 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
8175a253 1294 conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
a0da5fe1
UD
1295 libc_cv_cc_with_libunwind=yes
1296 else
1297 libc_cv_cc_with_libunwind=no
c776b3d7 1298 fi
a0da5fe1
UD
1299 rm -f conftest*])
1300AC_SUBST(libc_cv_cc_with_libunwind)
1301if test $libc_cv_cc_with_libunwind = yes; then
1302 AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1303fi
c776b3d7 1304
a0da5fe1
UD
1305ASFLAGS_config=
1306AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1307 libc_cv_as_noexecstack, [dnl
1308cat > conftest.c <<EOF
35915ec8
UD
1309void foo (void) { }
1310EOF
a0da5fe1
UD
1311if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1312 -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
8175a253 1313 && grep .note.GNU-stack conftest.s >/dev/null \
a0da5fe1
UD
1314 && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1315 -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1316then
1317 libc_cv_as_noexecstack=yes
1318else
1319 libc_cv_as_noexecstack=no
1320fi
1321rm -f conftest*])
1322if test $libc_cv_as_noexecstack = yes; then
1323 ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1324fi
1325AC_SUBST(ASFLAGS_config)
2abf9ff1 1326
6bfea974
L
1327LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1328 [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
a0da5fe1 1329AC_SUBST(libc_cv_z_execstack)
c9c60884 1330
cd6ae7ea
FS
1331LIBC_LINKER_FEATURE([-z start-stop-gc], [-Wl,-z,start-stop-gc],
1332 [libc_cv_z_start_stop_gc=yes], [libc_cv_z_start_stop_gc=no])
1333LIBC_CONFIG_VAR([have-z-start-stop-gc], [$libc_cv_z_start_stop_gc])
1334
9926f6e2
FS
1335LIBC_LINKER_FEATURE([--depaudit], [-Wl,--depaudit,x],
1336 [libc_cv_depaudit=yes], [libc_cv_depaudit=no])
1337LIBC_CONFIG_VAR([have-depaudit], [$libc_cv_depaudit])
1338
e895cff5
FS
1339LIBC_LINKER_FEATURE([-z pack-relative-relocs],
1340 [-Wl,-z,pack-relative-relocs],
1341 [libc_cv_dt_relr=yes], [libc_cv_dt_relr=no])
1342LIBC_CONFIG_VAR([have-dt-relr], [$libc_cv_dt_relr])
1343
9d7a3741
L
1344LIBC_LINKER_FEATURE([--no-dynamic-linker],
1345 [-Wl,--no-dynamic-linker],
1346 [libc_cv_no_dynamic_linker=yes],
1347 [libc_cv_no_dynamic_linker=no])
1348LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
1349
1350AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
1351LIBC_TRY_CC_OPTION([-static-pie],
1352 [libc_cv_static_pie=yes],
1353 [libc_cv_static_pie=no])
1354])
1355LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
1356
a0da5fe1 1357AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
4da0431d
JM
1358LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1359])
c9c60884 1360
a0da5fe1 1361AC_SUBST(libc_cv_fpie)
871b9158 1362
a0da5fe1
UD
1363AC_CACHE_CHECK(for --hash-style option,
1364 libc_cv_hashstyle, [dnl
1365cat > conftest.c <<EOF
871b9158
UD
1366int _start (void) { return 42; }
1367EOF
66a704c4 1368if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
a0da5fe1
UD
1369 -fPIC -shared -o conftest.so conftest.c
1370 -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
1371then
1372 libc_cv_hashstyle=yes
1373else
1374 libc_cv_hashstyle=no
1375fi
1376rm -f conftest*])
1377AC_SUBST(libc_cv_hashstyle)
1378
89569c8b
L
1379AC_CACHE_CHECK(for GLOB_DAT reloc,
1380 libc_cv_has_glob_dat, [dnl
1381cat > conftest.c <<EOF
1382extern int mumble;
1383int foo (void) { return mumble; }
1384EOF
1385if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1386 -fPIC -shared -o conftest.so conftest.c
66a704c4 1387 -nostdlib -nostartfiles $no_ssp
89569c8b
L
1388 1>&AS_MESSAGE_LOG_FD])
1389then
1390dnl look for GLOB_DAT relocation.
1391 if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
1392 libc_cv_has_glob_dat=yes
1393 else
1394 libc_cv_has_glob_dat=no
1395 fi
1396else
1397 libc_cv_has_glob_dat=no
1398fi
1399rm -f conftest*])
1400AC_SUBST(libc_cv_has_glob_dat)
1401
22dca1ea 1402AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
49803108
AJ
1403cat > conftest.c <<EOF
1404int foo;
1405EOF
22dca1ea 1406if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
49803108
AJ
1407 conftest.c 1>&AS_MESSAGE_LOG_FD])
1408then
18e2ac6d 1409 libc_cv_fno_toplevel_reorder=yes
49803108 1410else
18e2ac6d 1411 libc_cv_fno_toplevel_reorder=no
49803108
AJ
1412fi
1413rm -f conftest*])
18e2ac6d 1414if test $libc_cv_fno_toplevel_reorder = yes; then
22dca1ea 1415 fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
18e2ac6d 1416else
49803108
AJ
1417 fno_unit_at_a_time=-fno-unit-at-a-time
1418fi
1419AC_SUBST(fno_unit_at_a_time)
fd26970f 1420
61655555
L
1421AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
1422[dnl
1423cat > conftest.c <<EOF
1424__thread int i;
1425void foo (void)
1426{
1427 i = 10;
1428}
1429EOF
04e8169f
AZ
1430if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=gnu2 -nostdlib -nostartfiles
1431 conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD])
61655555
L
1432then
1433 libc_cv_mtls_dialect_gnu2=yes
1434else
1435 libc_cv_mtls_dialect_gnu2=no
1436fi
1437rm -f conftest*])
1438AC_SUBST(libc_cv_mtls_dialect_gnu2)
1439LIBC_CONFIG_VAR([have-mtls-dialect-gnu2], [$libc_cv_mtls_dialect_gnu2])
1440
a0da5fe1
UD
1441AC_CACHE_CHECK(whether cc puts quotes around section names,
1442 libc_cv_have_section_quotes,
1443 [cat > conftest.c <<EOF
1444 static const int foo
1445 __attribute__ ((section ("bar"))) = 1;
e26dd47f 1446EOF
a0da5fe1
UD
1447 if ${CC-cc} -S conftest.c -o conftest.s; then
1448 if grep '\.section.*"bar"' conftest.s >/dev/null; then
1449 libc_cv_have_section_quotes=yes
e26dd47f 1450 else
a0da5fe1 1451 libc_cv_have_section_quotes=no
e26dd47f 1452 fi
a0da5fe1
UD
1453 else
1454 libc_cv_have_section_quotes=unknown
1455 fi
1456 rm -f conftest.{c,s}
1457 ])
1458if test $libc_cv_have_section_quotes = yes; then
1459 AC_DEFINE(HAVE_SECTION_QUOTES)
9a97d1f7
UD
1460fi
1461
d555194c
UD
1462AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1463cat > conftest.c <<\EOF
1464void zero (void *x)
1465{
a52d1562 1466 __builtin_memset (x, 0, 1000);
d555194c
UD
1467}
1468EOF
1469dnl
e37fc4aa 1470if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
d555194c
UD
1471then
1472 libc_cv_gcc_builtin_memset=no
1473else
1474 libc_cv_gcc_builtin_memset=yes
1475fi
1476rm -f conftest* ])
1477if test "$libc_cv_gcc_builtin_memset" = yes ; then
1478 AC_DEFINE(HAVE_BUILTIN_MEMSET)
1479fi
1480
85dd1003
UD
1481AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1482cat > conftest.c <<\EOF
1483extern char *strstr (const char *, const char *) __asm ("my_strstr");
1484char *foo (const char *a, const char *b)
1485{
1486 return __builtin_strstr (a, b);
1487}
1488EOF
1489dnl
e37fc4aa 1490if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
85dd1003
UD
1491then
1492 libc_cv_gcc_builtin_redirection=yes
1493else
1494 libc_cv_gcc_builtin_redirection=no
1495fi
1496rm -f conftest* ])
3ce1f295
UD
1497if test "$libc_cv_gcc_builtin_redirection" = no; then
1498 AC_MSG_ERROR([support for the symbol redirection needed])
85dd1003
UD
1499fi
1500
7998fa78
AS
1501dnl Determine how to disable generation of FMA instructions.
1502AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1503 libc_cv_cc_nofma, [dnl
1504libc_cv_cc_nofma=
1505for opt in -ffp-contract=off -mno-fused-madd; do
1506 LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1507done])
bef0b507 1508AC_SUBST(libc_cv_cc_nofma)
7998fa78 1509
2cf9ad57
RM
1510if test -n "$submachine"; then
1511 AC_CACHE_CHECK([for compiler option for CPU variant],
f7d82dc9 1512 libc_cv_cc_submachine, [dnl
2cf9ad57
RM
1513 libc_cv_cc_submachine=no
1514 for opt in "-march=$submachine" "-mcpu=$submachine"; do
40b601fb 1515 LIBC_TRY_CC_OPTION([$opt], [
2cf9ad57 1516 libc_cv_cc_submachine="$opt"
40b601fb 1517 break], [])
2cf9ad57
RM
1518 done])
1519 if test "x$libc_cv_cc_submachine" = xno; then
1520 AC_MSG_ERROR([${CC-cc} does not support $submachine])
1521 fi
1522fi
1523AC_SUBST(libc_cv_cc_submachine)
1524
85c2e611
AZ
1525AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1526__attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1527cat > conftest.c <<EOF
1528void
1529__attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1530foo (void) {}
1531EOF
1532libc_cv_cc_loop_to_function=no
1533if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
1534then
1535 libc_cv_cc_loop_to_function=yes
1536fi
1537rm -f conftest*])
1538if test $libc_cv_cc_loop_to_function = yes; then
1539 AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1540fi
1541AC_SUBST(libc_cv_cc_loop_to_function)
1542
c8f3e6db
UD
1543dnl Check whether we have the gd library available.
1544AC_MSG_CHECKING(for libgd)
6dab8688
UD
1545if test "$with_gd" != "no"; then
1546 old_CFLAGS="$CFLAGS"
1547 CFLAGS="$CFLAGS $libgd_include"
1548 old_LDFLAGS="$LDFLAGS"
1549 LDFLAGS="$LDFLAGS $libgd_ldflags"
1550 old_LIBS="$LIBS"
1551 LIBS="$LIBS -lgd -lpng -lz -lm"
e9e7f245
NT
1552 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gd.h>]], [[gdImagePng (0, 0)]])],
1553 [LIBGD=yes], [LIBGD=no])
6dab8688
UD
1554 CFLAGS="$old_CFLAGS"
1555 LDFLAGS="$old_LDFLAGS"
1556 LIBS="$old_LIBS"
1557else
1558 LIBGD=no
1559fi
c8f3e6db
UD
1560AC_MSG_RESULT($LIBGD)
1561AC_SUBST(LIBGD)
3d558f4e 1562
2fff3d93
UD
1563# SELinux detection
1564if test x$with_selinux = xno ; then
1565 have_selinux=no;
1566else
1567 # See if we have the SELinux library
1568 AC_CHECK_LIB(selinux, is_selinux_enabled,
1569 have_selinux=yes, have_selinux=no)
49155d51 1570 if test x$with_selinux = xyes ; then
2fff3d93 1571 if test x$have_selinux = xno ; then
0699f766 1572 AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
2fff3d93
UD
1573 fi
1574 fi
1575fi
1576# Check if we're building with SELinux support.
1577if test "x$have_selinux" = xyes; then
943db9eb 1578 AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
ec23b9be
UD
1579
1580 # See if we have the libaudit library
943db9eb 1581 AC_CHECK_LIB(audit, audit_log_user_avc_message,
77e8bddf 1582 have_libaudit=yes, have_libaudit=no)
ec23b9be 1583 if test "x$have_libaudit" = xyes; then
943db9eb 1584 AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
ec23b9be
UD
1585 fi
1586 AC_SUBST(have_libaudit)
1f063dca
UD
1587
1588 # See if we have the libcap library
1589 AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1590 if test "x$have_libcap" = xyes; then
1591 AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1592 fi
1593 AC_SUBST(have_libcap)
2fff3d93
UD
1594fi
1595AC_SUBST(have_selinux)
1596
61653dfb
RM
1597CPPUNDEFS=
1598dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE.
1599dnl Since we are building the implementations of the fortified functions here,
1600dnl having the macro defined interacts very badly.
b190bccc
NT
1601dnl _FORTIFY_SOURCE requires compiler optimization level 1 (gcc -O1)
1602dnl and above (see "man FEATURE_TEST_MACROS").
1603dnl So do NOT replace AC_COMPILE_IFELSE with AC_PREPROC_IFELSE.
61653dfb 1604AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source,
b190bccc 1605[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
61653dfb
RM
1606#ifdef _FORTIFY_SOURCE
1607# error bogon
b190bccc 1608#endif]])],
61653dfb
RM
1609 [libc_cv_predef_fortify_source=no],
1610 [libc_cv_predef_fortify_source=yes])])
1611if test $libc_cv_predef_fortify_source = yes; then
1612 CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
1613fi
1614AC_SUBST(CPPUNDEFS)
1615
0923f74a
FW
1616dnl Starting with binutils 2.35, GAS can attach multiple symbol versions
1617dnl to one symbol (PR 23840).
1618AC_CACHE_CHECK(whether the assembler requires one version per symbol,
1619 libc_cv_symver_needs_alias, [dnl
1620 cat > conftest.s <<EOF
1621 .text
1622testfunc:
1623 .globl testfunc
1624 .symver testfunc, testfunc1@VERSION1
1625 .symver testfunc, testfunc1@VERSION2
1626EOF
1627 libc_cv_symver_needs_alias=no
1628 if ${CC-cc} $ASFLAGS -c conftest.s 2>&AS_MESSAGE_LOG_FD; then
1629 libc_cv_symver_needs_alias=no
1630 else
1631 libc_cv_symver_needs_alias=yes
1632 fi
1633 rm conftest.*
1634])
1635if test "$libc_cv_symver_needs_alias" = yes; then
1636 AC_DEFINE(SYMVER_NEEDS_ALIAS)
1637fi
1638
9fe7e787
RM
1639AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1640 libc_cv_builtin_trap, [dnl
1641libc_cv_builtin_trap=no
b190bccc 1642AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[__builtin_trap ()]])],[
9fe7e787
RM
1643libc_undefs=`$NM -u conftest.o |
1644 LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1645 2>&AS_MESSAGE_LOG_FD` || {
1646 AC_MSG_ERROR([confusing output from $NM -u])
1647}
1648echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1649if test -z "$libc_undefs"; then
1650 libc_cv_builtin_trap=yes
b190bccc 1651fi],[])])
9fe7e787
RM
1652if test $libc_cv_builtin_trap = yes; then
1653 AC_DEFINE([HAVE_BUILTIN_TRAP])
44c4e5d5
RM
1654fi
1655
99e1dc0a
FW
1656dnl C++ feature tests.
1657AC_LANG_PUSH([C++])
1658
1659AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1660 libc_cv_cxx_thread_local, [
1661old_CXXFLAGS="$CXXFLAGS"
1662CXXFLAGS="$CXXFLAGS -std=gnu++11"
1663AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1664#include <thread>
1665
1666// Compiler support.
1667struct S
1668{
1669 S ();
1670 ~S ();
1671};
1672thread_local S s;
1673S * get () { return &s; }
1674
1675// libstdc++ support.
1676#ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1677#error __cxa_thread_atexit_impl not supported
1678#endif
1679])],
1680 [libc_cv_cxx_thread_local=yes],
1681 [libc_cv_cxx_thread_local=no])
1682CXXFLAGS="$old_CXXFLAGS"
1683])
1684AC_SUBST(libc_cv_cxx_thread_local)
1685
1686AC_LANG_POP([C++])
1687dnl End of C++ feature tests.
1688
c224a18a
RM
1689### End of automated tests.
1690### Now run sysdeps configure fragments.
1691
cb343854 1692# They also can set these variables.
591e1ffb 1693use_ldconfig=no
cb343854 1694ldd_rewrite_script=no
77259608 1695libc_cv_sysconfdir=$sysconfdir
4248b1b1 1696libc_cv_localstatedir=$localstatedir
74bd2300 1697libc_cv_gcc_unwind_find_fde=no
e2fd3cbe 1698libc_cv_idn=no
ad201afe 1699pthread_in_libc=yes
cb343854 1700
28f540f4 1701# Iterate over all the sysdep directories we will use, running their
09055553 1702# configure fragments.
28f540f4 1703for dir in $sysnames; do
57ba7bb4
UD
1704 case $dir in
1705 /*) dest=$dir ;;
1706 *) dest=$srcdir/$dir ;;
1707 esac
1708 if test -r $dest/configure; then
d1149385 1709 AC_MSG_RESULT(running configure fragment for $dir)
57ba7bb4 1710 . $dest/configure
28f540f4 1711 fi
28f540f4
RM
1712done
1713
5695d46f
AS
1714if test x"$build_mathvec" = xnotset; then
1715 build_mathvec=no
1716fi
1717LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1718
7ffa9423
AZ
1719AC_SUBST(libc_extra_cflags)
1720AC_SUBST(libc_extra_cppflags)
1721
74bd2300
UD
1722if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1723 AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1724fi
1725AC_SUBST(libc_cv_gcc_unwind_find_fde)
1726
6e6249d0
RM
1727# A sysdeps configure fragment can reset this if IFUNC is not actually
1728# usable even though the assembler knows how to generate the symbol type.
1729if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1730 AC_DEFINE(HAVE_IFUNC)
1731fi
92ad88fe 1732LIBC_CONFIG_VAR([have-ifunc], [$libc_cv_ld_gnu_indirect_function])
6e6249d0 1733
022dfdce
SL
1734if test x"$libc_cv_gcc_indirect_function" = xyes; then
1735 AC_DEFINE(HAVE_GCC_IFUNC)
1736fi
16b59780 1737LIBC_CONFIG_VAR([have-gcc-ifunc], [$libc_cv_gcc_indirect_function])
022dfdce 1738
3cc3ef96
RM
1739# This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1740# configure fragment can override the value to prevent this AC_DEFINE.
1741AC_SUBST(use_nscd)
1742if test "x$use_nscd" != xno; then
1743 AC_DEFINE([USE_NSCD])
1744fi
c53d909c
RM
1745if test "x$build_nscd" = xdefault; then
1746 build_nscd=$use_nscd
1747fi
3cc3ef96 1748
84384f5b 1749AC_SUBST(libc_cv_slibdir)
aaa8cb4b 1750AC_SUBST(libc_cv_rtlddir)
90fe682d 1751AC_SUBST(libc_cv_complocaledir)
77259608 1752AC_SUBST(libc_cv_sysconfdir)
4248b1b1 1753AC_SUBST(libc_cv_localstatedir)
1ef32c3d
UD
1754AC_SUBST(libc_cv_rootsbindir)
1755
f57f8055
RM
1756if test x$use_ldconfig = xyes; then
1757 AC_DEFINE(USE_LDCONFIG)
1758fi
591e1ffb 1759AC_SUBST(use_ldconfig)
cb343854 1760AC_SUBST(ldd_rewrite_script)
84384f5b 1761
650425ce 1762AC_SUBST(static)
ff3d7ed3 1763AC_SUBST(shared)
a334319f 1764
ff886b82
UD
1765AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1766[libc_cv_pic_default=yes
cc3fa755 1767cat > conftest.c <<EOF
9756dfe1 1768#if defined __PIC__ || defined __pic__ || defined PIC || defined pic
cc3fa755
UD
1769# error PIC is default.
1770#endif
1771EOF
0b4ee387 1772if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
ff886b82 1773 libc_cv_pic_default=no
cc3fa755
UD
1774fi
1775rm -f conftest.*])
23645707 1776LIBC_CONFIG_VAR([build-pic-default], [$libc_cv_pic_default])
cc3fa755 1777
00c714df
L
1778AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
1779[libc_cv_cc_pie_default=yes
cc08749b
L
1780cat > conftest.c <<EOF
1781#if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1782# error PIE is default.
1783#endif
1784EOF
1785if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
00c714df 1786 libc_cv_cc_pie_default=no
cc08749b
L
1787fi
1788rm -f conftest.*])
23645707
SP
1789LIBC_CONFIG_VAR([cc-pie-default], [$libc_cv_cc_pie_default])
1790
1791AC_MSG_CHECKING(if we can build programs as PIE)
ded3aeb2 1792AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifdef PIE_UNSUPPORTED
23645707 1793# error PIE is not supported
ded3aeb2
L
1794#endif]])], [libc_cv_pie_supported=yes], [libc_cv_pie_supported=no])
1795AC_MSG_RESULT($libc_cv_pie_supported)
1796# Disable build-pie-default if target does not support it or glibc is
1797# configured with --disable-default-pie.
1798if test "x$default_pie" = xno; then
1799 build_pie_default=no
1800else
1801 build_pie_default=$libc_cv_pie_supported
23645707 1802fi
ded3aeb2 1803LIBC_CONFIG_VAR([build-pie-default], [$build_pie_default])
23645707
SP
1804
1805AC_MSG_CHECKING(if we can build static PIE programs)
ded3aeb2
L
1806libc_cv_static_pie_supported=$libc_cv_pie_supported
1807if test "x$libc_cv_pie_supported" != xno \
23645707 1808 -a "$libc_cv_no_dynamic_linker" = yes; then
23645707
SP
1809 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE
1810# error static PIE is not supported
ded3aeb2
L
1811#endif]])], [libc_cv_static_pie_supported=yes],
1812 [libc_cv_static_pie_supported=no])
1813fi
1814AC_MSG_RESULT($libc_cv_static_pie_supported)
1815
1816# Enable static-pie only if it is available and glibc isn't configured
1817# with --disable-default-pie.
1818if test "x$default_pie" = xno; then
1819 libc_cv_static_pie=no
1820else
1821 libc_cv_static_pie=$libc_cv_static_pie_supported
1822fi
1823if test "$libc_cv_static_pie" = "yes"; then
1824 AC_DEFINE(ENABLE_STATIC_PIE)
23645707 1825fi
23645707 1826LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
cc08749b 1827
abcb584d
L
1828# Set the `multidir' variable by grabbing the variable from the compiler.
1829# We do it once and save the result in a generated makefile.
1830libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
1831AC_SUBST(libc_cv_multidir)
1832
ff3d7ed3 1833AC_SUBST(profile)
5107cf1d 1834AC_SUBST(static_nss)
ff3d7ed3 1835
edf5b2d7
UD
1836AC_SUBST(DEFINES)
1837
cb8a6dbd 1838dnl See sysdeps/mach/configure.ac for this variable.
61c83c3f
RM
1839AC_SUBST(mach_interface_list)
1840
ee74a442
UD
1841VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
1842RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
df4ef2ab 1843AC_SUBST(VERSION)
ee74a442 1844AC_SUBST(RELEASE)
df4ef2ab 1845
ad201afe
FW
1846if test "$pthread_in_libc" = yes; then
1847 AC_DEFINE(PTHREAD_IN_LIBC)
1848fi
1849AC_SUBST(pthread_in_libc)
1850
728e272a 1851AC_CONFIG_FILES([config.make Makefile])
c118d634 1852AC_CONFIG_COMMANDS([default],[[
737547be
UD
1853case $CONFIG_FILES in *config.make*)
1854echo "$config_vars" >> config.make;;
1855esac
c118d634
RM
1856test -d bits || mkdir bits]],[[config_vars='$config_vars']])
1857AC_OUTPUT