Correctly determine libc.so 'OUTPUT_FORMAT' when cross-compiling.
[glibc.git] / configure.ac
blob973fe59e81e25002c8220abc2dea09252ef20a31
1 dnl Process this file with autoconf to produce a configure script.
2 dnl Note we do not use AC_PREREQ here!  See aclocal.m4 for what we use instead.
3 AC_INIT([GNU C Library], [(see version.h)], [https://sourceware.org/bugzilla/],
4   [glibc], [https://www.gnu.org/software/glibc/])
5 AC_CONFIG_SRCDIR([include/features.h])
6 AC_CONFIG_HEADERS([config.h])
7 AC_CONFIG_AUX_DIR([scripts])
9 ACX_PKGVERSION([GNU libc])
10 ACX_BUGURL([https://www.gnu.org/software/libc/bugs.html])
11 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"],
12                    [Package description])
13 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"],
14                    [Bug reporting address])
16 # Glibc should not depend on any header files
17 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
18   [m4_divert_text([DEFAULTS],
19     [ac_includes_default='/* none */'])])
21 # We require GCC, and by default use its preprocessor.  Override AC_PROG_CPP
22 # here to work around the Autoconf issue discussed in
23 # <https://sourceware.org/ml/libc-alpha/2013-01/msg00721.html>.
24 AC_DEFUN([AC_PROG_CPP],
25 [AC_REQUIRE([AC_PROG_CC])dnl
26 AC_ARG_VAR([CPP],      [C preprocessor])dnl
27 _AC_ARG_VAR_CPPFLAGS()dnl
28 # On Suns, sometimes $CPP names a directory.
29 if test -n "$CPP" && test -d "$CPP"; then
30   CPP=
32 if test -z "$CPP"; then
33   CPP="$CC -E"
35 AC_SUBST(CPP)dnl
36 ])# AC_PROG_CPP
38 # We require GCC.  Override _AC_PROG_CC_C89 here to work around the Autoconf
39 # issue discussed in
40 # <https://sourceware.org/ml/libc-alpha/2013-01/msg00757.html>.
41 AC_DEFUN([_AC_PROG_CC_C89], [[$1]])
43 dnl This is here so we can set $subdirs directly based on configure fragments.
44 AC_CONFIG_SUBDIRS()
46 AC_CANONICAL_HOST
48 AC_PROG_CC
49 if test $host != $build; then
50   AC_CHECK_PROGS(BUILD_CC, gcc cc)
52 AC_SUBST(cross_compiling)
53 AC_PROG_CPP
54 AC_CHECK_TOOL(READELF, readelf, false)
55 AC_CHECK_TOOL(OBJDUMP, objdump, false)
57 # We need the C++ compiler only for testing.
58 AC_PROG_CXX
59 # It's useless to us if it can't link programs (e.g. missing -lstdc++).
60 AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
61 AC_LANG_PUSH([C++])
62 # Default, dynamic case.
63 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
64                [libc_cv_cxx_link_ok=yes],
65                [libc_cv_cxx_link_ok=no])
66 # Static case.
67 old_LDFLAGS="$LDFLAGS"
68 LDFLAGS="$LDFLAGS -static"
69 AC_LINK_IFELSE([AC_LANG_SOURCE([
70 #include <iostream>
72 int
73 main()
75   std::cout << "Hello, world!";
76   return 0;
78 ])],
79                [],
80                [libc_cv_cxx_link_ok=no])
81 LDFLAGS="$old_LDFLAGS"
82 AC_LANG_POP([C++])])
83 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
85 if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
86   AC_MSG_ERROR([you must configure in a separate build directory])
89 # This will get text that should go into config.make.
90 config_vars=
92 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
93 AC_ARG_WITH([gd],
94             AS_HELP_STRING([--with-gd=DIR],
95                            [find libgd include dir and library with prefix DIR]),
96             [dnl
97 case "$with_gd" in
98 yes|''|no) ;;
99 *) libgd_include="-I$withval/include"
100    libgd_ldflags="-L$withval/lib" ;;
101 esac
103 AC_ARG_WITH([gd-include],
104             AS_HELP_STRING([--with-gd-include=DIR],
105                            [find libgd include files in DIR]),
106             [dnl
107 case "$with_gd_include" in
108 ''|no) ;;
109 *) libgd_include="-I$withval" ;;
110 esac
112 AC_ARG_WITH([gd-lib],
113             AS_HELP_STRING([--with-gd-lib=DIR],
114                            [find libgd library files in DIR]),
115             [dnl
116 case "$with_gd_lib" in
117 ''|no) ;;
118 *) libgd_ldflags="-L$withval" ;;
119 esac
122 if test -n "$libgd_include"; then
123   config_vars="$config_vars
124 CFLAGS-memusagestat.c = $libgd_include"
126 if test -n "$libgd_ldflags"; then
127   config_vars="$config_vars
128 libgd-LDFLAGS = $libgd_ldflags"
131 dnl Arguments to specify presence of other packages/features.
132 AC_ARG_WITH([binutils],
133             AS_HELP_STRING([--with-binutils=PATH],
134                            [specify location of binutils (as and ld)]),
135             [path_binutils=$withval],
136             [path_binutils=''])
137 AC_ARG_WITH([selinux],
138             AS_HELP_STRING([--with-selinux],
139                            [if building with SELinux support]),
140             [with_selinux=$withval],
141             [with_selinux=auto])
143 AC_ARG_WITH([headers],
144             AS_HELP_STRING([--with-headers=PATH],
145                            [location of system headers to use
146                             (for example /usr/src/linux/include)
147                             @<:@default=compiler default@:>@]),
148             [sysheaders=$withval],
149             [sysheaders=''])
150 AC_SUBST(sysheaders)
152 AC_SUBST(use_default_link)
153 AC_ARG_WITH([default-link],
154             AS_HELP_STRING([--with-default-link],
155                            [do not use explicit linker scripts]),
156             [use_default_link=$withval],
157             [use_default_link=no])
159 dnl Additional build flags injection.
160 AC_ARG_WITH([nonshared-cflags],
161             AS_HELP_STRING([--with-nonshared-cflags=CFLAGS],
162                            [build nonshared libraries with additional CFLAGS]),
163             [extra_nonshared_cflags=$withval],
164             [extra_nonshared_cflags=])
165 AC_SUBST(extra_nonshared_cflags)
166 AC_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=])
171 AC_SUBST(rtld_early_cflags)
173 AC_ARG_WITH([timeoutfactor],
174             AS_HELP_STRING([--with-timeoutfactor=NUM],
175                            [specify an integer to scale the timeout]),
176             [timeoutfactor=$withval],
177             [timeoutfactor=1])
178 AC_DEFINE_UNQUOTED(TIMEOUTFACTOR, $timeoutfactor)
180 AC_ARG_ENABLE([sanity-checks],
181               AS_HELP_STRING([--disable-sanity-checks],
182                              [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
183               [enable_sanity=$enableval],
184               [enable_sanity=yes])
186 AC_ARG_ENABLE([shared],
187               AS_HELP_STRING([--enable-shared],
188                              [build shared library @<:@default=yes if GNU ld@:>@]),
189               [shared=$enableval],
190               [shared=yes])
191 AC_ARG_ENABLE([profile],
192               AS_HELP_STRING([--enable-profile],
193                              [build profiled library @<:@default=no@:>@]),
194               [profile=$enableval],
195               [profile=no])
196 AC_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])
201 AC_ARG_ENABLE([timezone-tools],
202               AS_HELP_STRING([--disable-timezone-tools],
203                              [do not install timezone tools @<:@default=install@:>@]),
204               [enable_timezone_tools=$enableval],
205               [enable_timezone_tools=yes])
206 AC_SUBST(enable_timezone_tools)
208 AC_ARG_ENABLE([hardcoded-path-in-tests],
209               AS_HELP_STRING([--enable-hardcoded-path-in-tests],
210                              [hardcode newly built glibc path in tests @<:@default=no@:>@]),
211               [hardcoded_path_in_tests=$enableval],
212               [hardcoded_path_in_tests=no])
213 AC_SUBST(hardcoded_path_in_tests)
215 AC_ARG_ENABLE([hidden-plt],
216               AS_HELP_STRING([--disable-hidden-plt],
217                              [do not hide internal function calls to avoid PLT]),
218               [hidden=$enableval],
219               [hidden=yes])
220 if test "x$hidden" = xno; then
221   AC_DEFINE(NO_HIDDEN)
224 AC_ARG_ENABLE([bind-now],
225               AS_HELP_STRING([--enable-bind-now],
226                              [disable lazy relocations in DSOs]),
227               [bindnow=$enableval],
228               [bindnow=no])
229 AC_SUBST(bindnow)
230 if test "x$bindnow" = xyes; then
231   AC_DEFINE(BIND_NOW)
234 dnl Build glibc with -fstack-protector, -fstack-protector-all, or
235 dnl -fstack-protector-strong.
236 AC_ARG_ENABLE([stack-protector],
237               AS_HELP_STRING([--enable-stack-protector=@<:@yes|no|all|strong@:>@],
238                              [Use -fstack-protector[-all|-strong] to detect glibc buffer overflows]),
239               [enable_stack_protector=$enableval],
240               [enable_stack_protector=no])
241 case "$enable_stack_protector" in
242 all|yes|no|strong) ;;
243 *) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: \"$enable_stack_protector\"]);;
244 esac
246 dnl On some platforms we cannot use dynamic loading.  We must provide
247 dnl static NSS modules.
248 AC_ARG_ENABLE([static-nss],
249               AS_HELP_STRING([--enable-static-nss],
250                              [build static NSS modules @<:@default=no@:>@]),
251               [static_nss=$enableval],
252               [static_nss=no])
253 dnl Enable static NSS also if we build no shared objects.
254 if test x"$static_nss" = xyes || test x"$shared" = xno; then
255   static_nss=yes
256   AC_DEFINE(DO_STATIC_NSS)
259 AC_ARG_ENABLE([force-install],
260               AS_HELP_STRING([--disable-force-install],
261                              [don't force installation of files from this package, even if they are older than the installed files]),
262               [force_install=$enableval],
263               [force_install=yes])
264 AC_SUBST(force_install)
266 AC_ARG_ENABLE([maintainer-mode],
267               AS_HELP_STRING([--enable-maintainer-mode],
268                              [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
269               [maintainer=$enableval],
270               [maintainer=no])
272 dnl On some platforms we allow dropping compatibility with all kernel
273 dnl versions.
274 AC_ARG_ENABLE([kernel],
275               AS_HELP_STRING([--enable-kernel=VERSION],
276                              [compile for compatibility with kernel not older than VERSION]),
277               [minimum_kernel=$enableval],
278               [])
279 dnl Prevent unreasonable values.
280 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
281   # Better nothing than this.
282   minimum_kernel=""
283 else
284   if test "$minimum_kernel" = current; then
285     minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
286   fi
289 dnl For the development we sometimes want gcc to issue even more warnings.
290 dnl This is not the default since many of the extra warnings are not
291 dnl appropriate.
292 AC_ARG_ENABLE([all-warnings],
293               AS_HELP_STRING([--enable-all-warnings],
294                              [enable all useful warnings gcc can issue]),
295               [all_warnings=$enableval],
296               [])
297 AC_SUBST(all_warnings)
299 AC_ARG_ENABLE([werror],
300               AS_HELP_STRING([--disable-werror],
301                              [do not build with -Werror]),
302               [enable_werror=$enableval],
303               [enable_werror=yes])
304 AC_SUBST(enable_werror)
306 AC_ARG_ENABLE([multi-arch],
307               AS_HELP_STRING([--enable-multi-arch],
308                              [enable single DSO with optimizations for multiple architectures]),
309               [multi_arch=$enableval],
310               [multi_arch=default])
312 AC_ARG_ENABLE([experimental-malloc],
313               AS_HELP_STRING([--disable-experimental-malloc],
314                              [disable experimental malloc features]),
315               [experimental_malloc=$enableval],
316               [experimental_malloc=yes])
317 AC_SUBST(experimental_malloc)
319 AC_ARG_ENABLE([memory-tagging],
320               AS_HELP_STRING([--enable-memory-tagging],
321                              [enable memory tagging if supported by the architecture @<:@default=no@:>@]),
322               [memory_tagging=$enableval],
323               [memory_tagging=no])
324 if 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
332 AC_SUBST(memory_tagging)
334 AC_ARG_ENABLE([crypt],
335               AS_HELP_STRING([--disable-crypt],
336                              [do not build nor install the passphrase hashing library, libcrypt]),
337               [build_crypt=$enableval],
338               [build_crypt=yes])
339 AC_SUBST(build_crypt)
341 AC_ARG_ENABLE([nss-crypt],
342               AS_HELP_STRING([--enable-nss-crypt],
343                              [enable libcrypt to use nss]),
344               [nss_crypt=$enableval],
345               [nss_crypt=no])
346 if 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
350 if 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
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
359   old_CFLAGS="$CFLAGS"
360   CFLAGS="$CFLAGS $nss_includes $nspr_includes"
361   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
362 #include <hasht.h>
363 #include <nsslowhash.h>
364 void f (void) { NSSLOW_Init (); }])],
365              libc_cv_nss_crypt=yes,
366              AC_MSG_ERROR([
367 cannot find NSS headers with lowlevel hash function interfaces]))
368   old_LIBS="$LIBS"
369   old_LDFLAGS="$LDFLAGS"
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([
377 cannot link program using lowlevel NSS hash functions]))
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"
389   CFLAGS="$old_CFLAGS"
390   LIBS="$old_LIBS"
391 else
392   libc_cv_nss_crypt=no
393   libc_cv_static_nss_crypt=no
395 AC_SUBST(libc_cv_nss_crypt)
396 AC_SUBST(libc_cv_static_nss_crypt)
399 AC_ARG_ENABLE([systemtap],
400               [AS_HELP_STRING([--enable-systemtap],
401                [enable systemtap static probe points @<:@default=no@:>@])],
402               [systemtap=$enableval],
403               [systemtap=no])
404 if test "x$systemtap" != xno; then
405   AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
406   old_CFLAGS="$CFLAGS"
407   CFLAGS="-std=gnu11 $CFLAGS"
408   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
409 void foo (int i, void *p)
411   asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
412        :: STAP_PROBE_ASM_OPERANDS (2, i, p));
413 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
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
422 AC_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])
427 AC_SUBST(build_nscd)
429 # Note the use of $use_nscd is near the bottom of the file.
430 AC_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])
436 AC_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])
441 AC_SUBST(build_pt_chown)
442 if test "$build_pt_chown" = yes; then
443   AC_DEFINE(HAVE_PT_CHOWN)
446 AC_ARG_ENABLE([tunables],
447               [AS_HELP_STRING([--enable-tunables],
448                [Enable tunables support. Known values are 'yes', 'no' and 'valstring'])],
449               [have_tunables=$enableval],
450               [have_tunables=yes])
451 AC_SUBST(have_tunables)
452 if test "$have_tunables" = yes; then
453   AC_DEFINE(HAVE_TUNABLES)
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.
460 case "$host_os" in
461 linux*)
462   ;;
463 gnu*)
464   host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
465   ;;
466 esac
468 AC_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])
474 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
475 #ifndef __CET__
476 # error no CET compiler support
477 #endif]])],
478                [libc_cv_compiler_default_cet=yes],
479                [libc_cv_compiler_default_cet=no])
481 AC_ARG_ENABLE([cet],
482               AS_HELP_STRING([--enable-cet],
483                              [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
484               [enable_cet=$enableval],
485               [enable_cet=$libc_cv_compiler_default_cet])
487 AC_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])
493 AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
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.
498 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
500 # Don't allow vendor == "unknown"
501 test "$config_vendor" = unknown && config_vendor=
502 config_os="`echo $config_os | sed 's/^unknown-//'`"
504 # Some configurations imply other options.
505 elf=yes
507 # The configure fragment of a port can modify these to supplement
508 # or override the table in the case statement below.  No fragment should
509 # ever change the config_* variables, however.
510 machine=$config_machine
511 vendor=$config_vendor
512 os=$config_os
513 base_os=''
515 submachine=
516 AC_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
526 # An preconfigure script can set this when it wants to disable the sanity
527 # check below.
528 libc_config_ok=no
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.
533 with_fp_cond=1
535 dnl Let sysdeps/*/preconfigure act here.
536 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
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.
544 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
545   case "$machine-$host_os" in
546   *-linux* | *-gnu*)
547     ;;
548   *)
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!])
555     ;;
556   esac
559 # Set base_machine if not set by a preconfigure fragment.
560 test -n "$base_machine" || base_machine=$machine
561 AC_SUBST(base_machine)
563 # Determine whether to use fpu or nofpu sysdeps directories.
564 AC_CACHE_CHECK([for use of fpu sysdeps directories],
565                libc_cv_with_fp, [dnl
566 cat > conftest.c <<EOF
567 #if $with_fp_cond
568 int dummy;
569 #else
570 # error "no hardware floating point"
571 #endif
573 libc_cv_with_fp=no
574 if ${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
578 rm -f conftest*])
579 AC_SUBST(libc_cv_with_fp)
581 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
582 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
583                    [libc_cv_ssp=yes],
584                    [libc_cv_ssp=no])
587 AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
588 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
589                    [libc_cv_ssp_strong=yes],
590                    [libc_cv_ssp_strong=no])
593 AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
594 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
595                    [libc_cv_ssp_all=yes],
596                    [libc_cv_ssp_all=no])
599 stack_protector=
600 no_stack_protector=
601 if test "$libc_cv_ssp" = yes; then
602   no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
603   AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
606 if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
607   stack_protector="-fstack-protector"
608   AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
609 elif 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)
612 elif 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)
615 else
616   stack_protector="-fno-stack-protector"
617   AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
619 AC_SUBST(libc_cv_ssp)
620 AC_SUBST(stack_protector)
621 AC_SUBST(no_stack_protector)
623 if 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
627 else
628   no_ssp=
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
635 # For the multi-arch option we need support in the assembler & linker.
636 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
637                libc_cv_ld_gnu_indirect_function, [dnl
638 cat > conftest.S <<EOF
639 .type foo,%gnu_indirect_function
640 foo:
641 .globl _start
642 _start:
643 .globl __start
644 __start:
645 .data
646 #ifdef _LP64
647 .quad foo
648 #else
649 .long foo
650 #endif
652 libc_cv_ld_gnu_indirect_function=no
653 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
654             -nostartfiles -nostdlib $no_ssp \
655             -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
656   # Do a link to see if the backend supports IFUNC relocs.
657   $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
658   LC_ALL=C $READELF -Wr conftest | grep -q 'IRELATIVE\|R_SPARC_JMP_IREL' && {
659     libc_cv_ld_gnu_indirect_function=yes
660   }
662 rm -f conftest*])
664 # Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
665 AC_CACHE_CHECK([for gcc attribute ifunc support],
666                libc_cv_gcc_indirect_function, [dnl
667 cat > conftest.c <<EOF
668 extern int func (int);
669 int used_func (int a)
671   return a;
673 static void *resolver ()
675   return &used_func;
677 extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
679 libc_cv_gcc_indirect_function=no
680 if ${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
686 rm -f conftest*])
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.
690 AC_CACHE_CHECK([whether the linker supports textrels along with ifunc],
691                libc_cv_textrel_ifunc, [dnl
692 cat > conftest.S <<EOF
693 .type foo,%gnu_indirect_function
694 foo:
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
707 address:
708 #ifdef _LP64
709 .quad address
710 #else
711 .long address
712 #endif
714 libc_cv_textrel_ifunc=no
715 if 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
720 rm -f conftest*])
721 AC_SUBST(libc_cv_textrel_ifunc)
723 # Check if CC supports attribute retain as it is used in attribute_used_retain macro.
724 AC_CACHE_CHECK([for GNU attribute retain support],
725                libc_cv_gnu_retain, [dnl
726 cat > conftest.c <<EOF
727 static int var  __attribute__ ((used, retain, section ("__libc_atexit")));
729 libc_cv_gnu_retain=no
730 if ${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
734 rm -f conftest*])
735 if test $libc_cv_gnu_retain = yes; then
736   AC_DEFINE(HAVE_GNU_RETAIN)
738 LIBC_CONFIG_VAR([have-gnu-retain], [$libc_cv_gnu_retain])
740 # Check if gcc warns about alias for function with incompatible types.
741 AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
742                libc_cv_gcc_incompatible_alias, [dnl
743 cat > conftest.c <<EOF
744 int __redirect_foo (const void *s, int c);
746 __typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
747 __typeof (__redirect_foo) *foo_impl (void)
749   return 0;
752 extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
754 libc_cv_gcc_incompatible_alias=yes
755 if ${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
758 rm -f conftest*])
760 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
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
767 if 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.
771   if test x"$libc_cv_gcc_incompatible_alias" = xyes; then
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.
780 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
781   fi
783 multi_arch_d=
784 if test x"$multi_arch" != xno; then
785   multi_arch_d=/multiarch
788 # Compute the list of sysdep directories for this configuration.
789 # This can take a while to compute.
790 sysdep_dir=$srcdir/sysdeps
791 AC_MSG_CHECKING(sysdep dirs)
792 dnl We need to use [ and ] for other purposes for a while now.
793 changequote(,)dnl
794 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
795 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
797 test "x$base_os" != x || case "$os" in
798 gnu*)
799   base_os=mach/hurd ;;
800 linux*)
801   base_os=unix/sysv ;;
802 esac
804 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
805 tail=$os
806 ostry=$os
807 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
808   ostry="$ostry /$o"
809   tail=$o
810 done
811 o=`echo $tail | sed 's/[0-9]*$//'`
812 if test $o != $tail; then
813   ostry="$ostry /$o"
815 # For linux-gnu, try linux-gnu, then linux.
816 o=`echo $tail | sed 's/-.*$//'`
817 if test $o != $tail; then
818   ostry="$ostry /$o"
821 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
822 base=
823 tail=$base_os
824 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
825   set $b
826   base="$base /$1"
827   tail="$2"
828 done
830 # For sparc/sparc32, try sparc/sparc32 and then sparc.
831 mach=
832 tail=$machine${submachine:+/$submachine}
833 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
834   set $m
835   # Prepend the machine's FPU directory unless the architecture specific
836   # preconfigure disables it.
837   if test "$libc_cv_with_fp" = yes; then
838     maybe_fpu=/fpu
839   else
840     maybe_fpu=/nofpu
841   fi
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
848   tail="$2"
849 done
851 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
852 changequote([,])dnl
854 # Find what sysdep directories exist.
855 sysnames=
856 for 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
862         for m in $mach ''; do
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
878         done
879       done
880     done
881   done
882 done
884 # If the assembler supports gnu_indirect_function symbol type and the
885 # architecture supports multi-arch, we enable multi-arch by default.
886 case $sysnames in
887 *"$multi_arch_d"*)
888   ;;
890   test x"$multi_arch" = xdefault && multi_arch=no
891   ;;
892 esac
893 if test x"$multi_arch" != xno; then
894   AC_DEFINE(USE_MULTIARCH)
896 AC_SUBST(multi_arch)
898 if test -z "$os_used" && test "$os" != none; then
899   AC_MSG_ERROR(Operating system $os is not supported.)
901 if test -z "$machine_used" && test "$machine" != none; then
902   AC_MSG_ERROR(The $machine is not supported.)
904 if test -z "$submachine_used" && test -n "$submachine"; then
905   AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
907 AC_SUBST(submachine)
909 # We have now validated the configuration.
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).
913 set $sysnames
914 names=
915 while test $# -gt 0; do
916   name=$1
917   shift
919   case " $names " in *" $name "*)
920     # Already in the list.
921     continue
922   esac
924   # Report each name as we discover it, so there is no long pause in output.
925   echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
927   name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
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
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\""
946           found=yes
947         fi
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
957         if test $found = no; then
958           AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
959         fi
960       done
961     fi
962   done
964   # Add NAME to the list of names.
965   names="$names $name"
967   # Find the parent of NAME, using the empty string if it has none.
968 changequote(,)dnl
969   parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
970 changequote([,])dnl
972   test -n "$enable_debug_configure" &&
973     echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
974 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
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).
983   sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
984   test -n "$sysnames" && set $sysnames
985 done
987 # Add the default directories.
988 default_sysnames="sysdeps/generic"
989 sysnames="$names $default_sysnames"
990 AC_SUBST(sysnames)
991 # The other names were emitted during the scan.
992 AC_MSG_RESULT($default_sysnames)
995 ### Locate tools.
997 AC_PROG_INSTALL
998 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
999   # The makefiles need to use a different form to find it in $srcdir.
1000   INSTALL='\$(..)./scripts/install-sh -c'
1002 AC_PROG_LN_S
1004 LIBC_PROG_BINUTILS
1006 # Accept binutils 2.25 or newer.
1007 AC_CHECK_PROG_VER(AS, $AS, --version,
1008                   [GNU assembler.* \([0-9]*\.[0-9.]*\)],
1009                   [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
1010                   AS=: critic_missing="$critic_missing as")
1012 libc_cv_with_lld=no
1013 case $($LD --version) in
1014   "GNU gold"*)
1015   # Accept gold 1.14 or higher
1016     AC_CHECK_PROG_VER(LD, $LD, --version,
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")
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,
1031                     [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
1032                     [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
1033                     LD=: critic_missing="$critic_missing GNU ld")
1034     ;;
1035 esac
1036 LIBC_CONFIG_VAR([with-lld], [$libc_cv_with_lld])
1038 # These programs are version sensitive.
1039 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
1040   [GNU Make[^0-9]*\([0-9][0-9.]*\)],
1041   [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
1043 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
1044   [GNU gettext.* \([0-9]*\.[0-9.]*\)],
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")
1047 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
1048   [GNU texinfo.* \([0-9][0-9.]*\)],
1049   [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
1050   MAKEINFO=: aux_missing="$aux_missing makeinfo")
1051 AC_CHECK_PROG_VER(SED, sed, --version,
1052   [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
1053   [3.0[2-9]*|3.[1-9]*|[4-9]*],
1054   SED=: aux_missing="$aux_missing sed")
1055 AC_CHECK_PROG_VER(AWK, gawk, --version,
1056   [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
1057   [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
1058 AC_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")
1062 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
1063 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
1064 #if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
1065 #error insufficient compiler
1066 #endif]])],
1067                [libc_cv_compiler_ok=yes],
1068                [libc_cv_compiler_ok=no])])
1069 AS_IF([test $libc_cv_compiler_ok != yes],
1070       [critic_missing="$critic_missing compiler"])
1072 AC_CHECK_TOOL(NM, nm, false)
1074 if 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
1092 else
1093   AUTOCONF=no
1096 # Check for python3 if available, or else python.
1097 AC_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")
1101 PYTHON="$PYTHON_PROG -B"
1102 AC_SUBST(PYTHON)
1104 test -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.])
1108 test -n "$aux_missing" && AC_MSG_WARN([
1109 *** These auxiliary programs are missing or incompatible versions:$aux_missing
1110 *** some features or tests will be disabled.
1111 *** Check the INSTALL file for required versions.])
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.)
1116 if test -n "$sysheaders"; then
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 \
1123 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
1124   if test -n "$CXX"; then
1125     CXX_SYSINCLUDES=
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
1131   fi
1133 AC_SUBST(SYSINCLUDES)
1134 AC_SUBST(CXX_SYSINCLUDES)
1136 # Obtain some C++ header file paths.  This is used to make a local
1137 # copy of those headers in Makerules.
1138 if test -n "$CXX"; then
1139   find_cxx_header () {
1140     echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
1141          | sed -n "\,$1:,{s/:\$//;p}"
1142   }
1143   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
1144   CXX_CMATH_HEADER="$(find_cxx_header cmath)"
1145   CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
1147 AC_SUBST(CXX_CSTDLIB_HEADER)
1148 AC_SUBST(CXX_CMATH_HEADER)
1149 AC_SUBST(CXX_BITS_STD_ABS_H)
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
1158 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1159 changequote(,)dnl
1160 case ${LD_LIBRARY_PATH} in
1161   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1162     ld_library_path_setting="contains current directory"
1163     ;;
1164   *)
1165     ld_library_path_setting="ok"
1166     ;;
1167 esac
1168 changequote([,])dnl
1169 AC_MSG_RESULT($ld_library_path_setting)
1170 if test "$ld_library_path_setting" != "ok"; then
1171 AC_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.])
1177 AC_PATH_PROG(BASH_SHELL, bash, no)
1179 AC_PATH_PROG(PERL, perl, no)
1180 if test "$PERL" != no &&
1181    (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1182   PERL=no
1184 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1185              $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1187 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1188 cat > conftest.s <<EOF
1189 .text
1190 foo:
1191 .set glibc_conftest_frobozz,foo
1192 .globl glibc_conftest_frobozz
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.
1196 cat > conftest1.c <<\EOF
1197 extern int glibc_conftest_frobozz;
1198 void _start() { glibc_conftest_frobozz = 1; }
1200 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1201             -nostartfiles -nostdlib $no_ssp \
1202             -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1203   libc_cv_asm_set_directive=yes
1204 else
1205   libc_cv_asm_set_directive=no
1207 rm -f conftest*])
1208 if test $libc_cv_asm_set_directive = yes; then
1209   AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1212 AC_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;
1217                 libc_cv_protected_data=no
1218                 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
1219                   cat > conftest.c <<EOF
1220                   extern int bar;
1221                   int main (void) { return bar; }
1223                   if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
1224                     libc_cv_protected_data=yes
1225                   fi
1226                 fi
1227                 rm -f conftest.*
1228                ])
1229 AC_SUBST(libc_cv_protected_data)
1231 AC_CACHE_CHECK(linker support for INSERT in linker script,
1232                libc_cv_insert,
1233                [cat > conftest.c <<EOF
1234                 int __attribute__ ((section(".bar"))) bar = 0x12345678;
1235                 int test (void) { return bar; }
1237                 cat > conftest.t <<EOF
1238                 SECTIONS
1239                 {
1240                   .bar : { *(.bar) }
1241                 }
1242                 INSERT AFTER .rela.dyn;
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                ])
1250 AC_SUBST(libc_cv_insert)
1252 AC_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;
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                ])
1271 if test $libc_cv_broken_alias_attribute = yes; then
1272   AC_MSG_ERROR(working alias attribute support required)
1275 AC_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                ])
1285 if test $libc_cv_have_sdata_section = yes; then
1286   AC_DEFINE(HAVE_SDATA_SECTION)
1289 AC_CACHE_CHECK(for libunwind-support in compiler,
1290                libc_cv_cc_with_libunwind, [
1291   cat > conftest.c <<EOF
1292 int main (void) { return 0; }
1294   if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1295      conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
1296     libc_cv_cc_with_libunwind=yes
1297   else
1298     libc_cv_cc_with_libunwind=no
1299   fi
1300   rm -f conftest*])
1301 AC_SUBST(libc_cv_cc_with_libunwind)
1302 if test $libc_cv_cc_with_libunwind = yes; then
1303   AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1306 ASFLAGS_config=
1307 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1308                libc_cv_as_noexecstack, [dnl
1309 cat > conftest.c <<EOF
1310 void foo (void) { }
1312 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1313                    -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1314    && grep .note.GNU-stack conftest.s >/dev/null \
1315    && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1316                       -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1317 then
1318   libc_cv_as_noexecstack=yes
1319 else
1320   libc_cv_as_noexecstack=no
1322 rm -f conftest*])
1323 if test $libc_cv_as_noexecstack = yes; then
1324   ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1326 AC_SUBST(ASFLAGS_config)
1328 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1329                     [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1330 AC_SUBST(libc_cv_z_execstack)
1332 LIBC_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])
1334 LIBC_CONFIG_VAR([have-z-start-stop-gc], [$libc_cv_z_start_stop_gc])
1336 LIBC_LINKER_FEATURE([--depaudit], [-Wl,--depaudit,x],
1337                     [libc_cv_depaudit=yes], [libc_cv_depaudit=no])
1338 LIBC_CONFIG_VAR([have-depaudit], [$libc_cv_depaudit])
1340 LIBC_LINKER_FEATURE([-z pack-relative-relocs],
1341                     [-Wl,-z,pack-relative-relocs],
1342                     [libc_cv_dt_relr=yes], [libc_cv_dt_relr=no])
1343 LIBC_CONFIG_VAR([have-dt-relr], [$libc_cv_dt_relr])
1345 LIBC_LINKER_FEATURE([--no-dynamic-linker],
1346                     [-Wl,--no-dynamic-linker],
1347                     [libc_cv_no_dynamic_linker=yes],
1348                     [libc_cv_no_dynamic_linker=no])
1349 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
1351 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
1352 LIBC_TRY_CC_OPTION([-static-pie],
1353                    [libc_cv_static_pie=yes],
1354                    [libc_cv_static_pie=no])
1356 LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
1358 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1359 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1362 AC_SUBST(libc_cv_fpie)
1364 AC_CACHE_CHECK(for GLOB_DAT reloc,
1365                libc_cv_has_glob_dat, [dnl
1366 cat > conftest.c <<EOF
1367 extern int mumble;
1368 int foo (void) { return mumble; }
1370 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1371                         -fPIC -shared -o conftest.so conftest.c
1372                         -nostdlib -nostartfiles $no_ssp
1373                         1>&AS_MESSAGE_LOG_FD])
1374 then
1375 dnl 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
1381 else
1382   libc_cv_has_glob_dat=no
1384 rm -f conftest*])
1385 AC_SUBST(libc_cv_has_glob_dat)
1387 AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
1388 [dnl
1389 cat > conftest.c <<EOF
1390 __thread int i;
1391 void foo (void)
1393   i = 10;
1396 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=gnu2 -nostdlib -nostartfiles
1397                    conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD])
1398 then
1399   libc_cv_mtls_dialect_gnu2=yes
1400 else
1401   libc_cv_mtls_dialect_gnu2=no
1403 rm -f conftest*])
1404 AC_SUBST(libc_cv_mtls_dialect_gnu2)
1405 LIBC_CONFIG_VAR([have-mtls-dialect-gnu2], [$libc_cv_mtls_dialect_gnu2])
1407 AC_CACHE_CHECK(whether cc puts quotes around section names,
1408                libc_cv_have_section_quotes,
1409                [cat > conftest.c <<EOF
1410                 static const int foo
1411                 __attribute__ ((section ("bar"))) = 1;
1413                 if ${CC-cc} -S conftest.c -o conftest.s; then
1414                   if grep '\.section.*"bar"' conftest.s >/dev/null; then
1415                     libc_cv_have_section_quotes=yes
1416                   else
1417                     libc_cv_have_section_quotes=no
1418                   fi
1419                 else
1420                   libc_cv_have_section_quotes=unknown
1421                 fi
1422                 rm -f conftest.{c,s}
1423                 ])
1424 if test $libc_cv_have_section_quotes = yes; then
1425   AC_DEFINE(HAVE_SECTION_QUOTES)
1428 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1429 cat > conftest.c <<\EOF
1430 void zero (void *x)
1432   __builtin_memset (x, 0, 1000);
1436 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
1437 then
1438   libc_cv_gcc_builtin_memset=no
1439 else
1440   libc_cv_gcc_builtin_memset=yes
1442 rm -f conftest* ])
1443 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1444   AC_DEFINE(HAVE_BUILTIN_MEMSET)
1447 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1448 cat > conftest.c <<\EOF
1449 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1450 char *foo (const char *a, const char *b)
1452   return __builtin_strstr (a, b);
1456 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
1457 then
1458   libc_cv_gcc_builtin_redirection=yes
1459 else
1460   libc_cv_gcc_builtin_redirection=no
1462 rm -f conftest* ])
1463 if test "$libc_cv_gcc_builtin_redirection" = no; then
1464   AC_MSG_ERROR([support for the symbol redirection needed])
1467 dnl Determine how to disable generation of FMA instructions.
1468 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1469                libc_cv_cc_nofma, [dnl
1470 libc_cv_cc_nofma=
1471 for opt in -ffp-contract=off -mno-fused-madd; do
1472   LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1473 done])
1474 AC_SUBST(libc_cv_cc_nofma)
1476 if test -n "$submachine"; then
1477   AC_CACHE_CHECK([for compiler option for CPU variant],
1478                  libc_cv_cc_submachine, [dnl
1479   libc_cv_cc_submachine=no
1480   for opt in "-march=$submachine" "-mcpu=$submachine"; do
1481     LIBC_TRY_CC_OPTION([$opt], [
1482       libc_cv_cc_submachine="$opt"
1483       break], [])
1484   done])
1485   if test "x$libc_cv_cc_submachine" = xno; then
1486     AC_MSG_ERROR([${CC-cc} does not support $submachine])
1487   fi
1489 AC_SUBST(libc_cv_cc_submachine)
1491 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1492 __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1493 cat > conftest.c <<EOF
1494 void
1495 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1496 foo (void) {}
1498 libc_cv_cc_loop_to_function=no
1499 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
1500 then
1501   libc_cv_cc_loop_to_function=yes
1503 rm -f conftest*])
1504 if test $libc_cv_cc_loop_to_function = yes; then
1505   AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1507 AC_SUBST(libc_cv_cc_loop_to_function)
1509 dnl Check whether we have the gd library available.
1510 AC_MSG_CHECKING(for libgd)
1511 if test "$with_gd" != "no"; then
1512   old_CFLAGS="$CFLAGS"
1513   CFLAGS="$CFLAGS $libgd_include"
1514   old_LDFLAGS="$LDFLAGS"
1515   LDFLAGS="$LDFLAGS $libgd_ldflags"
1516   old_LIBS="$LIBS"
1517   LIBS="$LIBS -lgd -lpng -lz -lm"
1518   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gd.h>]], [[gdImagePng (0, 0)]])],
1519                  [LIBGD=yes], [LIBGD=no])
1520   CFLAGS="$old_CFLAGS"
1521   LDFLAGS="$old_LDFLAGS"
1522   LIBS="$old_LIBS"
1523 else
1524   LIBGD=no
1526 AC_MSG_RESULT($LIBGD)
1527 AC_SUBST(LIBGD)
1529 # SELinux detection
1530 if test x$with_selinux = xno ; then
1531   have_selinux=no;
1532 else
1533   # See if we have the SELinux library
1534   AC_CHECK_LIB(selinux, is_selinux_enabled,
1535                have_selinux=yes, have_selinux=no)
1536   if test x$with_selinux = xyes ; then
1537     if test x$have_selinux = xno ; then
1538       AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1539     fi
1540   fi
1542 # Check if we're building with SELinux support.
1543 if test "x$have_selinux" = xyes; then
1544   AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1546   # See if we have the libaudit library
1547   AC_CHECK_LIB(audit, audit_log_user_avc_message,
1548                have_libaudit=yes, have_libaudit=no)
1549   if test "x$have_libaudit" = xyes; then
1550     AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1551   fi
1552   AC_SUBST(have_libaudit)
1554   # See if we have the libcap library
1555   AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1556   if test "x$have_libcap" = xyes; then
1557     AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1558   fi
1559   AC_SUBST(have_libcap)
1561 AC_SUBST(have_selinux)
1563 CPPUNDEFS=
1564 dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE.
1565 dnl Since we are building the implementations of the fortified functions here,
1566 dnl having the macro defined interacts very badly.
1567 dnl _FORTIFY_SOURCE requires compiler optimization level 1 (gcc -O1)
1568 dnl and above (see "man FEATURE_TEST_MACROS").
1569 dnl So do NOT replace AC_COMPILE_IFELSE with AC_PREPROC_IFELSE.
1570 AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source,
1571 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1572 #ifdef _FORTIFY_SOURCE
1573 # error bogon
1574 #endif]])],
1575                 [libc_cv_predef_fortify_source=no],
1576                 [libc_cv_predef_fortify_source=yes])])
1577 if test $libc_cv_predef_fortify_source = yes; then
1578   CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
1580 AC_SUBST(CPPUNDEFS)
1582 dnl Starting with binutils 2.35, GAS can attach multiple symbol versions
1583 dnl to one symbol (PR 23840).
1584 AC_CACHE_CHECK(whether the assembler requires one version per symbol,
1585                libc_cv_symver_needs_alias, [dnl
1586   cat > conftest.s <<EOF
1587         .text
1588 testfunc:
1589         .globl testfunc
1590         .symver testfunc, testfunc1@VERSION1
1591         .symver testfunc, testfunc1@VERSION2
1593   libc_cv_symver_needs_alias=no
1594   if ${CC-cc} $ASFLAGS -c conftest.s 2>&AS_MESSAGE_LOG_FD; then
1595     libc_cv_symver_needs_alias=no
1596   else
1597     libc_cv_symver_needs_alias=yes
1598   fi
1599   rm conftest.*
1601 if test "$libc_cv_symver_needs_alias" = yes; then
1602   AC_DEFINE(SYMVER_NEEDS_ALIAS)
1605 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1606                libc_cv_builtin_trap, [dnl
1607 libc_cv_builtin_trap=no
1608 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[__builtin_trap ()]])],[
1609 libc_undefs=`$NM -u conftest.o |
1610   LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1611     2>&AS_MESSAGE_LOG_FD` || {
1612   AC_MSG_ERROR([confusing output from $NM -u])
1614 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1615 if test -z "$libc_undefs"; then
1616   libc_cv_builtin_trap=yes
1617 fi],[])])
1618 if test $libc_cv_builtin_trap = yes; then
1619   AC_DEFINE([HAVE_BUILTIN_TRAP])
1622 dnl C++ feature tests.
1623 AC_LANG_PUSH([C++])
1625 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1626                libc_cv_cxx_thread_local, [
1627 old_CXXFLAGS="$CXXFLAGS"
1628 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1629 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1630 #include <thread>
1632 // Compiler support.
1633 struct S
1635   S ();
1636   ~S ();
1638 thread_local S s;
1639 S * get () { return &s; }
1641 // libstdc++ support.
1642 #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1643 #error __cxa_thread_atexit_impl not supported
1644 #endif
1645 ])],
1646                [libc_cv_cxx_thread_local=yes],
1647                [libc_cv_cxx_thread_local=no])
1648 CXXFLAGS="$old_CXXFLAGS"
1650 AC_SUBST(libc_cv_cxx_thread_local)
1652 AC_LANG_POP([C++])
1653 dnl End of C++ feature tests.
1655 ### End of automated tests.
1656 ### Now run sysdeps configure fragments.
1658 # They also can set these variables.
1659 use_ldconfig=no
1660 ldd_rewrite_script=no
1661 libc_cv_sysconfdir=$sysconfdir
1662 libc_cv_localstatedir=$localstatedir
1663 libc_cv_gcc_unwind_find_fde=no
1664 libc_cv_idn=no
1665 pthread_in_libc=yes
1667 # Iterate over all the sysdep directories we will use, running their
1668 # configure fragments.
1669 for dir in $sysnames; do
1670   case $dir in
1671     /*) dest=$dir ;;
1672     *)  dest=$srcdir/$dir ;;
1673   esac
1674   if test -r $dest/configure; then
1675     AC_MSG_RESULT(running configure fragment for $dir)
1676     . $dest/configure
1677   fi
1678 done
1680 if test x"$build_mathvec" = xnotset; then
1681   build_mathvec=no
1683 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1685 AC_SUBST(libc_extra_cflags)
1686 AC_SUBST(libc_extra_cppflags)
1688 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1689   AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1691 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1693 # A sysdeps configure fragment can reset this if IFUNC is not actually
1694 # usable even though the assembler knows how to generate the symbol type.
1695 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1696   AC_DEFINE(HAVE_IFUNC)
1698 LIBC_CONFIG_VAR([have-ifunc], [$libc_cv_ld_gnu_indirect_function])
1700 if test x"$libc_cv_gcc_indirect_function" = xyes; then
1701   AC_DEFINE(HAVE_GCC_IFUNC)
1703 LIBC_CONFIG_VAR([have-gcc-ifunc], [$libc_cv_gcc_indirect_function])
1705 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1706 # configure fragment can override the value to prevent this AC_DEFINE.
1707 AC_SUBST(use_nscd)
1708 if test "x$use_nscd" != xno; then
1709   AC_DEFINE([USE_NSCD])
1711 if test "x$build_nscd" = xdefault; then
1712   build_nscd=$use_nscd
1715 AC_SUBST(libc_cv_slibdir)
1716 AC_SUBST(libc_cv_rtlddir)
1717 AC_SUBST(libc_cv_complocaledir)
1718 AC_SUBST(libc_cv_sysconfdir)
1719 AC_SUBST(libc_cv_localstatedir)
1720 AC_SUBST(libc_cv_rootsbindir)
1722 if test x$use_ldconfig = xyes; then
1723   AC_DEFINE(USE_LDCONFIG)
1725 AC_SUBST(use_ldconfig)
1726 AC_SUBST(ldd_rewrite_script)
1728 AC_SUBST(static)
1729 AC_SUBST(shared)
1731 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1732 [libc_cv_pic_default=yes
1733 cat > conftest.c <<EOF
1734 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
1735 # error PIC is default.
1736 #endif
1738 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1739   libc_cv_pic_default=no
1741 rm -f conftest.*])
1742 LIBC_CONFIG_VAR([build-pic-default], [$libc_cv_pic_default])
1744 AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
1745 [libc_cv_cc_pie_default=yes
1746 cat > conftest.c <<EOF
1747 #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1748 # error PIE is default.
1749 #endif
1751 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1752   libc_cv_cc_pie_default=no
1754 rm -f conftest.*])
1755 LIBC_CONFIG_VAR([cc-pie-default], [$libc_cv_cc_pie_default])
1757 AC_MSG_CHECKING(if we can build programs as PIE)
1758 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifdef PIE_UNSUPPORTED
1759 # error PIE is not supported
1760 #endif]])], [libc_cv_pie_supported=yes], [libc_cv_pie_supported=no])
1761 AC_MSG_RESULT($libc_cv_pie_supported)
1762 # Disable build-pie-default if target does not support it or glibc is
1763 # configured with --disable-default-pie.
1764 if test "x$default_pie" = xno; then
1765   build_pie_default=no
1766 else
1767   build_pie_default=$libc_cv_pie_supported
1769 LIBC_CONFIG_VAR([build-pie-default], [$build_pie_default])
1771 AC_MSG_CHECKING(if we can build static PIE programs)
1772 libc_cv_static_pie_supported=$libc_cv_pie_supported
1773 if test "x$libc_cv_pie_supported" != xno \
1774    -a "$libc_cv_no_dynamic_linker" = yes; then
1775   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE
1776 # error static PIE is not supported
1777 #endif]])], [libc_cv_static_pie_supported=yes],
1778             [libc_cv_static_pie_supported=no])
1780 AC_MSG_RESULT($libc_cv_static_pie_supported)
1782 # Enable static-pie only if it is available and glibc isn't configured
1783 # with --disable-default-pie.
1784 if test "x$default_pie" = xno; then
1785   libc_cv_static_pie=no
1786 else
1787   libc_cv_static_pie=$libc_cv_static_pie_supported
1789 if test "$libc_cv_static_pie" = "yes"; then
1790   AC_DEFINE(ENABLE_STATIC_PIE)
1792 LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
1794 # Set the `multidir' variable by grabbing the variable from the compiler.
1795 # We do it once and save the result in a generated makefile.
1796 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
1797 AC_SUBST(libc_cv_multidir)
1799 AC_SUBST(profile)
1800 AC_SUBST(static_nss)
1802 AC_SUBST(DEFINES)
1804 dnl See sysdeps/mach/configure.ac for this variable.
1805 AC_SUBST(mach_interface_list)
1807 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
1808 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
1809 AC_SUBST(VERSION)
1810 AC_SUBST(RELEASE)
1812 if test "$pthread_in_libc" = yes; then
1813   AC_DEFINE(PTHREAD_IN_LIBC)
1815 AC_SUBST(pthread_in_libc)
1817 AC_CONFIG_FILES([config.make Makefile])
1818 AC_CONFIG_COMMANDS([default],[[
1819 case $CONFIG_FILES in *config.make*)
1820 echo "$config_vars" >> config.make;;
1821 esac
1822 test -d bits || mkdir bits]],[[config_vars='$config_vars']])
1823 AC_OUTPUT