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