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