e6cab9c5bda601f711edcebd1fb1801b0181eeb7
[platform/upstream/glibc.git] / configure.ac
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)], [http://sourceware.org/bugzilla/], [glibc])
4 AC_CONFIG_SRCDIR([include/features.h])
5 AC_CONFIG_HEADERS([config.h])
6 AC_CONFIG_AUX_DIR([scripts])
7
8 ACX_PKGVERSION([GNU libc])
9 ACX_BUGURL([http://www.gnu.org/software/libc/bugs.html])
10 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"],
11                    [Package description])
12 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"],
13                    [Bug reporting address])
14
15 # Glibc should not depend on any header files
16 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
17   [m4_divert_text([DEFAULTS],
18     [ac_includes_default='/* none */'])])
19
20 # We require GCC, and by default use its preprocessor.  Override AC_PROG_CPP
21 # here to work around the Autoconf issue discussed in
22 # <http://sourceware.org/ml/libc-alpha/2013-01/msg00721.html>.
23 AC_DEFUN([AC_PROG_CPP],
24 [AC_REQUIRE([AC_PROG_CC])dnl
25 AC_ARG_VAR([CPP],      [C preprocessor])dnl
26 _AC_ARG_VAR_CPPFLAGS()dnl
27 # On Suns, sometimes $CPP names a directory.
28 if test -n "$CPP" && test -d "$CPP"; then
29   CPP=
30 fi
31 if test -z "$CPP"; then
32   CPP="$CC -E"
33 fi
34 AC_SUBST(CPP)dnl
35 ])# AC_PROG_CPP
36
37 # We require GCC.  Override _AC_PROG_CC_C89 here to work around the Autoconf
38 # issue discussed in
39 # <http://sourceware.org/ml/libc-alpha/2013-01/msg00757.html>.
40 AC_DEFUN([_AC_PROG_CC_C89], [[$1]])
41
42 dnl This is here so we can set $subdirs directly based on configure fragments.
43 AC_CONFIG_SUBDIRS()
44
45 AC_CANONICAL_HOST
46
47 AC_PROG_CC
48 if test $host != $build; then
49   AC_CHECK_PROGS(BUILD_CC, gcc cc)
50 fi
51 AC_SUBST(cross_compiling)
52 AC_PROG_CPP
53 AC_CHECK_TOOL(READELF, readelf, false)
54
55 # We need the C++ compiler only for testing.
56 AC_PROG_CXX
57 # It's useless to us if it can't link programs (e.g. missing -lstdc++).
58 AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
59 AC_LANG_PUSH([C++])
60 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
61                [libc_cv_cxx_link_ok=yes],
62                [libc_cv_cxx_link_ok=no])
63 AC_LANG_POP([C++])])
64 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
65
66 if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
67   AC_MSG_ERROR([you must configure in a separate build directory])
68 fi
69
70 # This will get text that should go into config.make.
71 config_vars=
72
73 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
74 AC_ARG_WITH([gd],
75             AC_HELP_STRING([--with-gd=DIR],
76                            [find libgd include dir and library with prefix DIR]),
77             [dnl
78 case "$with_gd" in
79 yes|''|no) ;;
80 *) libgd_include="-I$withval/include"
81    libgd_ldflags="-L$withval/lib" ;;
82 esac
83 ])
84 AC_ARG_WITH([gd-include],
85             AC_HELP_STRING([--with-gd-include=DIR],
86                            [find libgd include files in DIR]),
87             [dnl
88 case "$with_gd_include" in
89 ''|no) ;;
90 *) libgd_include="-I$withval" ;;
91 esac
92 ])
93 AC_ARG_WITH([gd-lib],
94             AC_HELP_STRING([--with-gd-lib=DIR],
95                            [find libgd library files in DIR]),
96             [dnl
97 case "$with_gd_lib" in
98 ''|no) ;;
99 *) libgd_ldflags="-L$withval" ;;
100 esac
101 ])
102
103 if test -n "$libgd_include"; then
104   config_vars="$config_vars
105 CFLAGS-memusagestat.c = $libgd_include"
106 fi
107 if test -n "$libgd_ldflags"; then
108   config_vars="$config_vars
109 libgd-LDFLAGS = $libgd_ldflags"
110 fi
111
112 dnl Arguments to specify presence of other packages/features.
113 AC_ARG_WITH([fp],
114             AC_HELP_STRING([--with-fp],
115                            [if using floating-point hardware @<:@default=yes@:>@]),
116             [with_fp=$withval],
117             [with_fp=yes])
118 AC_SUBST(with_fp)
119 AC_ARG_WITH([binutils],
120             AC_HELP_STRING([--with-binutils=PATH],
121                            [specify location of binutils (as and ld)]),
122             [path_binutils=$withval],
123             [path_binutils=''])
124 AC_ARG_WITH([selinux],
125             AC_HELP_STRING([--with-selinux],
126                            [if building with SELinux support]),
127             [with_selinux=$withval],
128             [with_selinux=auto])
129
130 AC_ARG_WITH([headers],
131             AC_HELP_STRING([--with-headers=PATH],
132                            [location of system headers to use
133                             (for example /usr/src/linux/include)
134                             @<:@default=compiler default@:>@]),
135             [sysheaders=$withval],
136             [sysheaders=''])
137 AC_SUBST(sysheaders)
138
139 AC_SUBST(use_default_link)
140 AC_ARG_WITH([default-link],
141             AC_HELP_STRING([--with-default-link],
142                            [do not use explicit linker scripts]),
143             [use_default_link=$withval],
144             [use_default_link=default])
145
146 AC_ARG_ENABLE([sanity-checks],
147               AC_HELP_STRING([--disable-sanity-checks],
148                              [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
149               [enable_sanity=$enableval],
150               [enable_sanity=yes])
151
152 AC_ARG_ENABLE([shared],
153               AC_HELP_STRING([--enable-shared],
154                              [build shared library @<:@default=yes if GNU ld@:>@]),
155               [shared=$enableval],
156               [shared=yes])
157 AC_ARG_ENABLE([profile],
158               AC_HELP_STRING([--enable-profile],
159                              [build profiled library @<:@default=no@:>@]),
160               [profile=$enableval],
161               [profile=no])
162 AC_ARG_ENABLE([timezone-tools],
163               AC_HELP_STRING([--disable-timezone-tools],
164                              [do not install timezone tools @<:@default=install@:>@]),
165               [enable_timezone_tools=$enableval],
166               [enable_timezone_tools=yes])
167 AC_SUBST(enable_timezone_tools)
168
169 AC_ARG_ENABLE([hardcoded-path-in-tests],
170               AC_HELP_STRING([--enable-hardcoded-path-in-tests],
171                              [hardcode newly built glibc path in tests @<:@default=no@:>@]),
172               [hardcoded_path_in_tests=$enableval],
173               [hardcoded_path_in_tests=no])
174 AC_SUBST(hardcoded_path_in_tests)
175
176 AC_ARG_ENABLE([stackguard-randomization],
177               AC_HELP_STRING([--enable-stackguard-randomization],
178                              [initialize __stack_chk_guard canary with a random number at program start]),
179               [enable_stackguard_randomize=$enableval],
180               [enable_stackguard_randomize=no])
181 if test "$enable_stackguard_randomize" = yes; then
182   AC_DEFINE(ENABLE_STACKGUARD_RANDOMIZE)
183 fi
184
185 AC_ARG_ENABLE([lock-elision],
186               AC_HELP_STRING([--enable-lock-elision[=yes/no]],
187                              [Enable lock elision for pthread mutexes by default]),
188               [enable_lock_elision=$enableval],
189               [enable_lock_elision=no])
190 AC_SUBST(enable_lock_elision)
191 if test "$enable_lock_elision" = yes ; then
192   AC_DEFINE(ENABLE_LOCK_ELISION)
193 fi
194
195 dnl Generic infrastructure for drop-in additions to libc.
196 AC_ARG_ENABLE([add-ons],
197               AC_HELP_STRING([--enable-add-ons@<:@=DIRS...@:>@],
198                              [configure and build add-ons in DIR1,DIR2,...
199                               search for add-ons if no parameter given]),
200                              , [enable_add_ons=yes])
201
202 AC_ARG_ENABLE([hidden-plt],
203               AC_HELP_STRING([--disable-hidden-plt],
204                              [do not hide internal function calls to avoid PLT]),
205               [hidden=$enableval],
206               [hidden=yes])
207 if test "x$hidden" = xno; then
208   AC_DEFINE(NO_HIDDEN)
209 fi
210
211 AC_ARG_ENABLE([bind-now],
212               AC_HELP_STRING([--enable-bind-now],
213                              [disable lazy relocations in DSOs]),
214               [bindnow=$enableval],
215               [bindnow=no])
216 AC_SUBST(bindnow)
217
218 dnl On some platforms we cannot use dynamic loading.  We must provide
219 dnl static NSS modules.
220 AC_ARG_ENABLE([static-nss],
221               AC_HELP_STRING([--enable-static-nss],
222                              [build static NSS modules @<:@default=no@:>@]),
223               [static_nss=$enableval],
224               [static_nss=no])
225 dnl Enable static NSS also if we build no shared objects.
226 if test x"$static_nss" = xyes || test x"$shared" = xno; then
227   static_nss=yes
228   AC_DEFINE(DO_STATIC_NSS)
229 fi
230
231 AC_ARG_ENABLE([force-install],
232               AC_HELP_STRING([--disable-force-install],
233                              [don't force installation of files from this package, even if they are older than the installed files]),
234               [force_install=$enableval],
235               [force_install=yes])
236 AC_SUBST(force_install)
237
238 AC_ARG_ENABLE([maintainer-mode],
239               AC_HELP_STRING([--enable-maintainer-mode],
240                              [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
241               [maintainer=$enableval],
242               [maintainer=no])
243
244 dnl On some platforms we allow dropping compatibility with all kernel
245 dnl versions.
246 AC_ARG_ENABLE([kernel],
247               AC_HELP_STRING([--enable-kernel=VERSION],
248                              [compile for compatibility with kernel not older than VERSION]),
249               [minimum_kernel=$enableval],
250               [])
251 dnl Prevent unreasonable values.
252 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
253   # Better nothing than this.
254   minimum_kernel=""
255 else
256   if test "$minimum_kernel" = current; then
257     minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
258   fi
259 fi
260
261 dnl For the development we sometimes want gcc to issue even more warnings.
262 dnl This is not the default since many of the extra warnings are not
263 dnl appropriate.
264 AC_ARG_ENABLE([all-warnings],
265               AC_HELP_STRING([--enable-all-warnings],
266                              [enable all useful warnings gcc can issue]),
267               [all_warnings=$enableval],
268               [])
269 AC_SUBST(all_warnings)
270
271 AC_ARG_ENABLE([werror],
272               AC_HELP_STRING([--disable-werror],
273                              [do not build with -Werror]),
274               [enable_werror=$enableval],
275               [enable_werror=yes])
276 AC_SUBST(enable_werror)
277
278 AC_ARG_ENABLE([multi-arch],
279               AC_HELP_STRING([--enable-multi-arch],
280                              [enable single DSO with optimizations for multiple architectures]),
281               [multi_arch=$enableval],
282               [multi_arch=default])
283
284 AC_ARG_ENABLE([nss-crypt],
285               AC_HELP_STRING([--enable-nss-crypt],
286                              [enable libcrypt to use nss]),
287               [nss_crypt=$enableval],
288               [nss_crypt=no])
289 if test x$nss_crypt = xyes; then
290   nss_includes=-I$(nss-config --includedir 2>/dev/null)
291   if test $? -ne 0; then
292     AC_MSG_ERROR([cannot find include directory with nss-config])
293   fi
294   old_CFLAGS="$CFLAGS"
295   CFLAGS="$CFLAGS $nss_includes"
296   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
297 #include <hasht.h>
298 #include <nsslowhash.h>
299 void f (void) { NSSLOW_Init (); }])],
300              libc_cv_nss_crypt=yes,
301              AC_MSG_ERROR([
302 cannot find NSS headers with lowlevel hash function interfaces]))
303   old_LIBS="$LIBS"
304   LIBS="$LIBS -lfreebl3"
305   AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
306 #include <hasht.h>
307 #include <nsslowhash.h>],
308                                   [NSSLOW_Init();])],
309                  libc_cv_nss_crypt=yes,
310                  AC_MSG_ERROR([
311 cannot link program using lowlevel NSS hash functions]))
312   CFLAGS="$old_CFLAGS"
313   LIBS="$old_LIBS"
314 else
315   libc_cv_nss_crypt=no
316 fi
317 AC_SUBST(libc_cv_nss_crypt)
318
319
320 AC_ARG_ENABLE([obsolete-rpc],
321               AC_HELP_STRING([--enable-obsolete-rpc],
322                              [build and install the obsolete RPC code for link-time usage]),
323               [link_obsolete_rpc=$enableval],
324               [link_obsolete_rpc=no])
325 AC_SUBST(link_obsolete_rpc)
326
327 if test "$link_obsolete_rpc" = yes; then
328   AC_DEFINE(LINK_OBSOLETE_RPC)
329 fi
330
331 AC_ARG_ENABLE([systemtap],
332               [AS_HELP_STRING([--enable-systemtap],
333                [enable systemtap static probe points @<:@default=no@:>@])],
334               [systemtap=$enableval],
335               [systemtap=no])
336 if test "x$systemtap" != xno; then
337   AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
338   old_CFLAGS="$CFLAGS"
339   CFLAGS="-std=gnu99 $CFLAGS"
340   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
341 void foo (int i, void *p)
342 {
343   asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
344        :: STAP_PROBE_ASM_OPERANDS (2, i, p));
345 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
346   CFLAGS="$old_CFLAGS"])
347   if test $libc_cv_sdt = yes; then
348     AC_DEFINE([USE_STAP_PROBE])
349   elif test "x$systemtap" != xauto; then
350     AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
351   fi
352 fi
353
354 AC_ARG_ENABLE([build-nscd],
355               [AS_HELP_STRING([--disable-build-nscd],
356                [disable building and installing the nscd daemon])],
357               [build_nscd=$enableval],
358               [build_nscd=default])
359 AC_SUBST(build_nscd)
360
361 # Note the use of $use_nscd is near the bottom of the file.
362 AC_ARG_ENABLE([nscd],
363               [AS_HELP_STRING([--disable-nscd],
364                [library functions will not contact the nscd daemon])],
365               [use_nscd=$enableval],
366               [use_nscd=yes])
367
368 AC_ARG_ENABLE([pt_chown],
369               [AS_HELP_STRING([--enable-pt_chown],
370                [Enable building and installing pt_chown])],
371               [build_pt_chown=$enableval],
372               [build_pt_chown=no])
373 AC_SUBST(build_pt_chown)
374 if test "$build_pt_chown" = yes; then
375   AC_DEFINE(HAVE_PT_CHOWN)
376 fi
377
378 # The abi-tags file uses a fairly simplistic model for name recognition that
379 # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu.  So we mutate a
380 # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
381 # This doesn't get used much beyond that, so it's fairly safe.
382 case "$host_os" in
383 linux*)
384   ;;
385 gnu*)
386   host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
387   ;;
388 esac
389
390 AC_ARG_ENABLE([mathvec],
391               [AS_HELP_STRING([--enable-mathvec],
392               [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
393               [build_mathvec=$enableval],
394               [build_mathvec=notset])
395
396 # We keep the original values in `$config_*' and never modify them, so we
397 # can write them unchanged into config.make.  Everything else uses
398 # $machine, $vendor, and $os, and changes them whenever convenient.
399 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
400
401 # Don't allow vendor == "unknown"
402 test "$config_vendor" = unknown && config_vendor=
403 config_os="`echo $config_os | sed 's/^unknown-//'`"
404
405 # Some configurations imply other options.
406 elf=yes
407
408 # The configure fragment of an add-on port can modify these to supplement
409 # or override the table in the case statement below.  No fragment should
410 # ever change the config_* variables, however.
411 machine=$config_machine
412 vendor=$config_vendor
413 os=$config_os
414 base_os=''
415
416 submachine=
417 AC_ARG_WITH([cpu],
418             AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
419             [dnl
420   case "$withval" in
421   yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
422   no) ;;
423   *) submachine="$withval" ;;
424   esac
425 ])
426
427 # An preconfigure script can set this when it wants to disable the sanity
428 # check below.
429 libc_config_ok=no
430
431 dnl Let sysdeps/*/preconfigure act here, like they can in add-ons.
432 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
433
434 dnl Having this here, though empty, makes sure that if add-ons' fragments
435 dnl do AC_CONFIG_SUBDIRS([some-dir]), which just sets $subdirs, then
436 dnl our AC_OUTPUT will actually use it.
437 AC_CONFIG_SUBDIRS()
438
439 case "$enable_add_ons" in
440 ''|no) add_ons= ;;
441 yes|'*')
442  add_ons=`cd $srcdir && ls -d 2> /dev/null */configure */sysdeps |
443           sed 's@/[[^/]]*$@@' | sort | uniq`
444          add_ons_automatic=yes
445          ;;
446 *) add_ons=`echo "$enable_add_ons" | sed 's/,/ /g'`
447        add_ons_automatic=no ;;
448 esac
449
450 configured_add_ons=
451 add_ons_sfx=
452 add_ons_pfx=
453 if test x"$add_ons" != x; then
454   for f in $add_ons; do
455     # Some sanity checks
456     case "$f" in
457     crypt)
458       AC_MSG_ERROR([
459 *** It seems that you're using an old \`crypt' add-on.  crypt is now
460 *** part of glibc and using the old add-on will not work with this
461 *** release.  Start again with fresh sources and without the old
462 *** \`crypt' add-on.])
463     ;;
464     localedata)
465       AC_MSG_ERROR([
466 *** It seems that you're using an old \`localedata' add-on.  localedata
467 *** is now part of glibc and using the old add-on will not work with
468 *** this release.  Start again with fresh sources and without the old
469 *** \`localedata' add-on.])
470     ;;
471     esac
472   done
473
474   # Now source each add-on's configure fragment.
475   # The fragments can use $srcdir/$libc_add_on to find themselves,
476   # and test $add_ons_automatic to see if they were explicitly requested.
477   # A fragment can clear (or even change) $libc_add_on to affect
478   # whether it goes into the list to be actually used in the build.
479   use_add_ons=
480   for libc_add_on in $add_ons; do
481     # Test whether such a directory really exists.
482     # It can be absolute, or relative to $srcdir, or relative to the build dir.
483     case "$libc_add_on" in
484     /*)
485       libc_add_on_srcdir=$libc_add_on
486       ;;
487     *)
488       test -d "$srcdir/$libc_add_on" || {
489         if test -d "$libc_add_on"; then
490           libc_add_on="`pwd`/$libc_add_on"
491         else
492           AC_MSG_ERROR(add-on directory \"$libc_add_on\" does not exist)
493         fi
494       }
495       libc_add_on_srcdir=$srcdir/$libc_add_on
496       ;;
497     esac
498
499     libc_add_on_frag=$libc_add_on_srcdir/configure
500     libc_add_on_canonical=
501     libc_add_on_config_subdirs=
502     if test -r "$libc_add_on_frag"; then
503       AC_MSG_NOTICE(running configure fragment for add-on $libc_add_on)
504       libc_add_on_canonical=unknown
505       libc_add_on_subdirs=
506       . "$libc_add_on_frag"
507       test -z "$libc_add_on" || {
508         configured_add_ons="$configured_add_ons $libc_add_on"
509         if test "x$libc_add_on_canonical" = xunknown; then
510           AC_MSG_ERROR(fragment must set \$libc_add_on_canonical)
511         fi
512         for d in $libc_add_on_subdirs; do
513           case "$libc_add_on" in
514           /*) subdir_srcdir="$libc_add_on" ;;
515           *) subdir_srcdir="\$(..)$libc_add_on" ;;
516           esac
517           case "$d" in
518           .)
519             d="${libc_add_on_canonical:-$libc_add_on}"
520             ;;
521           /*)
522             subdir_srcdir="$d"
523             ;;
524           *)
525             subdir_srcdir="$subdir_srcdir/$d"
526             ;;
527           esac
528           d=`echo "$d" | sed 's@/*$@@;s@^.*/@@'`
529           add_on_subdirs="$add_on_subdirs $d"
530           test "$subdir_srcdir" = "\$(..)$d" || config_vars="$config_vars
531 $d-srcdir = $subdir_srcdir"
532         done
533         for d in $libc_add_on_config_subdirs; do
534           case "$d" in
535           /*) AC_MSG_ERROR(dnl
536 fragment uses absolute path in \$libc_add_on_config_subdirs) ;;
537           esac
538           if test ! -d "$libc_add_on_srcdir/$d"; then
539             AC_MSG_ERROR(fragment wants to configure missing directory $d)
540           fi
541           case "$libc_add_on" in
542           /*) AC_MSG_ERROR(dnl
543 relative path required for add-on using \$libc_add_on_config_subdirs) ;;
544           esac
545           subdirs="$subdirs $libc_add_on/$d"
546         done
547       }
548     fi
549     if test -n "$libc_add_on"; then
550       LIBC_PRECONFIGURE([$libc_add_on_srcdir], [add-on $libc_add_on for])
551       use_add_ons="$use_add_ons $libc_add_on"
552       add_ons_pfx="$add_ons_pfx $libc_add_on/"
553       test -z "$libc_add_on_canonical" ||
554       add_ons_sfx="$add_ons_sfx /$libc_add_on_canonical"
555     fi
556   done
557   # Use echo to strip excess whitespace.
558   add_ons="`echo $use_add_ons`"
559 fi
560 AC_SUBST(add_ons)
561 AC_SUBST(add_on_subdirs)
562
563
564 ###
565 ### I put this here to prevent those annoying emails from people who cannot
566 ### read and try to compile glibc on unsupported platforms.  --drepper
567 ###
568 ### By using the undocumented --enable-hacker-mode option for configure
569 ### one can skip this test to make the configuration not fail for unsupported
570 ### platforms.
571 ###
572 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
573   case "$machine-$host_os" in
574   *-linux* | *-gnu*)
575     ;;
576   *)
577     echo "*** The GNU C library is currently not available for this platform."
578     echo "*** So far nobody cared to port it and if there is no volunteer it"
579     echo "*** might never happen.  So, if you have interest to see glibc on"
580     echo "*** this platform visit"
581     echo "***   http://www.gnu.org/software/libc/porting.html"
582     echo "*** and join the group of porters"
583     exit 1
584     ;;
585   esac
586 fi
587
588 # Set base_machine if not set by a preconfigure fragment.
589 test -n "$base_machine" || base_machine=$machine
590 AC_SUBST(base_machine)
591
592 # For the multi-arch option we need support in the assembler & linker.
593 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
594                libc_cv_ld_gnu_indirect_function, [dnl
595 cat > conftest.S <<EOF
596 .type foo,%gnu_indirect_function
597 foo:
598 .globl _start
599 _start:
600 .globl __start
601 __start:
602 .data
603 #ifdef _LP64
604 .quad foo
605 #else
606 .long foo
607 #endif
608 EOF
609 libc_cv_ld_gnu_indirect_function=no
610 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
611             -nostartfiles -nostdlib \
612             -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
613   # Do a link to see if the backend supports IFUNC relocs.
614   $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
615   LC_ALL=C $READELF -r conftest | grep 'no relocations' >/dev/null || {
616     libc_cv_ld_gnu_indirect_function=yes
617   }
618 fi
619 rm -f conftest*])
620
621 AC_MSG_CHECKING(whether .text pseudo-op must be used)
622 AC_CACHE_VAL(libc_cv_dot_text, [dnl
623 cat > conftest.s <<EOF
624 .text
625 EOF
626 libc_cv_dot_text=
627 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
628   libc_cv_dot_text=.text
629 fi
630 rm -f conftest*])
631 if test -z "$libc_cv_dot_text"; then
632   AC_MSG_RESULT(no)
633 else
634   AC_MSG_RESULT(yes)
635 fi
636
637 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
638   if test x"$multi_arch" = xyes; then
639     AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
640   else
641     multi_arch=no
642   fi
643 fi
644 multi_arch_d=
645 if test x"$multi_arch" != xno; then
646   multi_arch_d=/multiarch
647 fi
648
649 # Compute the list of sysdep directories for this configuration.
650 # This can take a while to compute.
651 sysdep_dir=$srcdir/sysdeps
652 AC_MSG_CHECKING(sysdep dirs)
653 dnl We need to use [ and ] for other purposes for a while now.
654 changequote(,)dnl
655 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
656 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
657
658 test "x$base_os" != x || case "$os" in
659 gnu*)
660   base_os=mach/hurd ;;
661 linux*)
662   base_os=unix/sysv ;;
663 esac
664
665 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
666 tail=$os
667 ostry=$os
668 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
669   ostry="$ostry /$o"
670   tail=$o
671 done
672 o=`echo $tail | sed 's/[0-9]*$//'`
673 if test $o != $tail; then
674   ostry="$ostry /$o"
675 fi
676 # For linux-gnu, try linux-gnu, then linux.
677 o=`echo $tail | sed 's/-.*$//'`
678 if test $o != $tail; then
679   ostry="$ostry /$o"
680 fi
681
682 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
683 base=
684 tail=$base_os
685 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
686   set $b
687   base="$base /$1"
688   tail="$2"
689 done
690
691 # For sparc/sparc32, try sparc/sparc32 and then sparc.
692 mach=
693 tail=$machine${submachine:+/$submachine}
694 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
695   set $m
696   # Prepend the machine's FPU directory unless --without-fp.
697   if test "$with_fp" = yes; then
698     maybe_fpu=/fpu
699   else
700     maybe_fpu=/nofpu
701   fi
702   # For each machine term, try it with and then without /multiarch.
703   for try_fpu in $maybe_fpu ''; do
704     for try_multi in $multi_arch_d ''; do
705       mach="$mach /$1$try_fpu$try_multi"
706     done
707   done
708   tail="$2"
709 done
710
711 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
712 changequote([,])dnl
713
714 # Find what sysdep directories exist.
715 sysnames_add_ons=
716 sysnames=
717 for b in $base ''; do
718   for m0 in $mach ''; do
719     for v in /$vendor ''; do
720       test "$v" = / && continue
721       for o in /$ostry ''; do
722         test "$o" = / && continue
723         for m in $mach ''; do
724           for d in $add_ons_pfx ''; do
725             for a in $add_ons_sfx ''; do
726               try_suffix="$m0$b$v$o$m"
727               if test -n "$try_suffix"; then
728                 try_srcdir="${srcdir}/"
729                 case "$d" in
730                 /*) try_srcdir= ;;
731                 esac
732                 try="${d}sysdeps$try_suffix$a"
733                 test -n "$enable_debug_configure" &&
734                 echo "$0 [DEBUG]: try $try" >&2
735                 if test -d "$try_srcdir$try"; then
736                   sysnames="$sysnames $try"
737                   { test -n "$o" || test -n "$b"; } && os_used=t
738                   { test -n "$m" || test -n "$m0"; } && machine_used=t
739                   case x${m0:-$m} in
740                   x*/$submachine) submachine_used=t ;;
741                   esac
742                   if test -n "$d"; then
743                     case "$sysnames_add_ons" in
744                     *" $d "*) ;;
745                     *|'') sysnames_add_ons="$sysnames_add_ons $d" ;;
746                     esac
747                   fi
748                 fi
749               fi
750             done
751           done
752         done
753       done
754     done
755   done
756 done
757
758 # If the assembler supports gnu_indirect_function symbol type and the
759 # architecture supports multi-arch, we enable multi-arch by default.
760 case $sysnames_add_ons$sysnames in
761 *"$multi_arch_d"*)
762   ;;
763 *)
764   test x"$multi_arch" = xdefault && multi_arch=no
765   ;;
766 esac
767 if test x"$multi_arch" != xno; then
768   AC_DEFINE(USE_MULTIARCH)
769 fi
770 AC_SUBST(multi_arch)
771
772 if test -z "$os_used" && test "$os" != none; then
773   AC_MSG_ERROR(Operating system $os is not supported.)
774 fi
775 if test -z "$machine_used" && test "$machine" != none; then
776   AC_MSG_ERROR(The $machine is not supported.)
777 fi
778 if test -z "$submachine_used" && test -n "$submachine"; then
779   AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
780 fi
781 AC_SUBST(submachine)
782
783 # We have now validated the configuration.
784
785 # Expand the list of system names into a full list of directories
786 # from each element's parent name and Implies file (if present).
787 set $sysnames
788 names=
789 while test $# -gt 0; do
790   name=$1
791   shift
792
793   case " $names " in *" $name "*)
794     # Already in the list.
795     continue
796   esac
797
798   # Report each name as we discover it, so there is no long pause in output.
799   echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
800
801   name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
802
803   case $name in
804     /*) xsrcdir= ;;
805     *)  xsrcdir=$srcdir/ ;;
806   esac
807   test -n "$enable_debug_configure" &&
808   echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
809
810   for implies_file in Implies Implies-before Implies-after; do
811     implies_type=`echo $implies_file | sed s/-/_/`
812     eval ${implies_type}=
813     if test -f $xsrcdir$name/$implies_file; then
814       # Collect more names from the `Implies' file (removing comments).
815       implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
816       for x in $implied_candidate; do
817         found=no
818         if test -d $xsrcdir$name_base/$x; then
819           eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
820           found=yes
821         fi
822         for d in $add_ons_pfx ''; do
823           try="${d}sysdeps/$x"
824           case $d in
825            /*) try_srcdir= ;;
826            *) try_srcdir=$srcdir/ ;;
827           esac
828           test -n "$enable_debug_configure" &&
829            echo "[DEBUG]: $name $implies_file $x try($d) {$try_srcdir}$try" >&2
830           if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
831           then
832             eval "${implies_type}=\"\$${implies_type} \$try\""
833             found=yes
834             case "$sysnames_add_ons" in
835             *" $d "*) ;;
836             *|'') sysnames_add_ons="$sysnames_add_ons $d" ;;
837             esac
838           fi
839         done
840         if test $found = no; then
841           AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
842         fi
843       done
844     fi
845   done
846
847   # Add NAME to the list of names.
848   names="$names $name"
849
850   # Find the parent of NAME, using the empty string if it has none.
851 changequote(,)dnl
852   parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
853 changequote([,])dnl
854
855   test -n "$enable_debug_configure" &&
856     echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
857 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
858
859   # Add the names implied by NAME, and NAME's parent (if it has one), to
860   # the list of names to be processed (the argument list).  We prepend the
861   # implied names to the list and append the parent.  We want implied
862   # directories to come before further directories inferred from the
863   # configuration components; this ensures that for sysv4, unix/common
864   # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
865   # after sysv4).
866   sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
867   test -n "$sysnames" && set $sysnames
868 done
869
870 # Add the default directories.
871 default_sysnames="sysdeps/generic"
872 sysnames="$names $default_sysnames"
873 AC_SUBST(sysnames)
874 # The other names were emitted during the scan.
875 AC_MSG_RESULT($default_sysnames)
876
877 # Collect the list of add-ons that supply partial sysdeps trees.
878 sysdeps_add_ons=
879 for add_on in $add_ons; do
880   case "$add_on" in
881   /*) xsrcdir= ;;
882   *) xsrcdir="$srcdir/" ;;
883   esac
884
885   test -d "$xsrcdir$add_on/sysdeps" || {
886     case "$configured_add_ons " in
887     *" $add_on "*) ;;
888     *|'')
889       AC_MSG_ERROR(add-on $add_on has no configure fragment or sysdeps tree)
890       ;;
891     esac
892     continue
893   }
894
895   sysdeps_add_ons="$sysdeps_add_ons $add_on"
896   case "$sysnames_add_ons" in
897   *" $add_on/ "*) ;;
898   *|'')
899     AC_MSG_WARN(add-on $add_on contributed no sysdeps directories)
900     continue ;;
901   esac
902
903   found=no
904   for d in $sysnames; do
905     case "$d" in
906     $add_on/sysdeps/*) ;;
907     *) continue ;;
908     esac
909     (cd "$xsrcdir$d" && for f in *[[!~]]; do
910        case "$f" in
911        sys|bits)
912          for ff in $f/*.h; do
913            test -d "$ff" || { test -e "$ff" && exit 88; }
914          done
915          ;;
916        *)
917          test -d "$f" || { test -e "$f" && exit 88; }
918          ;;
919        esac
920      done)
921     if test $? -eq 88; then
922       found=yes
923       break
924     fi
925   done
926   if test $found = no; then
927     AC_MSG_WARN(add-on $add_on contributed no useful sysdeps directories)
928   fi
929 done
930 AC_SUBST(sysdeps_add_ons)
931
932
933 ### Locate tools.
934
935 AC_PROG_INSTALL
936 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
937   # The makefiles need to use a different form to find it in $srcdir.
938   INSTALL='\$(..)./scripts/install-sh -c'
939 fi
940 AC_PROG_LN_S
941
942 LIBC_PROG_BINUTILS
943
944 # Accept binutils 2.22 or newer.
945 AC_CHECK_PROG_VER(AS, $AS, --version,
946                   [GNU assembler.* \([0-9]*\.[0-9.]*\)],
947                   [2.1[0-9][0-9]*|2.2[2-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
948                   AS=: critic_missing="$critic_missing as")
949 AC_CHECK_PROG_VER(LD, $LD, --version,
950                   [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
951                   [2.1[0-9][0-9]*|2.2[2-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
952                   LD=: critic_missing="$critic_missing ld")
953
954 # These programs are version sensitive.
955 AC_CHECK_TOOL_PREFIX
956 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
957   [GNU Make[^0-9]*\([0-9][0-9.]*\)],
958   [3.79* | 3.[89]* | [4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
959
960 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
961   [GNU gettext.* \([0-9]*\.[0-9.]*\)],
962   [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
963   MSGFMT=: aux_missing="$aux_missing msgfmt")
964 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
965   [GNU texinfo.* \([0-9][0-9.]*\)],
966   [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
967   MAKEINFO=: aux_missing="$aux_missing makeinfo")
968 AC_CHECK_PROG_VER(SED, sed, --version,
969   [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
970   [3.0[2-9]*|3.[1-9]*|[4-9]*],
971   SED=: aux_missing="$aux_missing sed")
972 AC_CHECK_PROG_VER(AWK, gawk, --version,
973   [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
974   [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
975
976 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
977 AC_TRY_COMPILE([], [
978 #if !defined __GNUC__ || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
979 #error insufficient compiler
980 #endif],
981                [libc_cv_compiler_ok=yes],
982                [libc_cv_compiler_ok=no])])
983 AS_IF([test $libc_cv_compiler_ok != yes],
984       [critic_missing="$critic_missing compiler"])
985
986 AC_CHECK_TOOL(NM, nm, false)
987
988 if test "x$maintainer" = "xyes"; then
989   AC_CHECK_PROGS(AUTOCONF, autoconf, no)
990   case "x$AUTOCONF" in
991   xno|x|x:) AUTOCONF=no ;;
992   *)
993     AC_CACHE_CHECK(dnl
994   whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
995     if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
996       libc_cv_autoconf_works=yes
997     else
998       libc_cv_autoconf_works=no
999     fi])
1000     test $libc_cv_autoconf_works = yes || AUTOCONF=no
1001     ;;
1002   esac
1003   if test "x$AUTOCONF" = xno; then
1004     aux_missing="$aux_missing autoconf"
1005   fi
1006 else
1007   AUTOCONF=no
1008 fi
1009
1010 test -n "$critic_missing" && AC_MSG_ERROR([
1011 *** These critical programs are missing or too old:$critic_missing
1012 *** Check the INSTALL file for required versions.])
1013
1014 test -n "$aux_missing" && AC_MSG_WARN([
1015 *** These auxiliary programs are missing or incompatible versions:$aux_missing
1016 *** some features will be disabled.
1017 *** Check the INSTALL file for required versions.])
1018
1019 # if using special system headers, find out the compiler's sekrit
1020 # header directory and add that to the list.  NOTE: Only does the right
1021 # thing on a system that doesn't need fixincludes.  (Not presently a problem.)
1022 if test -n "$sysheaders"; then
1023   SYSINCLUDES=-nostdinc
1024   for d in include include-fixed; do
1025     i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
1026     SYSINCLUDES="$SYSINCLUDES -isystem $i"
1027   done
1028   SYSINCLUDES="$SYSINCLUDES \
1029 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
1030   if test -n "$CXX"; then
1031     CXX_SYSINCLUDES=
1032     for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
1033     | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1034       test "x$cxxheaders" != x &&
1035       CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1036     done
1037   fi
1038 fi
1039 AC_SUBST(SYSINCLUDES)
1040 AC_SUBST(CXX_SYSINCLUDES)
1041
1042 # Test if LD_LIBRARY_PATH contains the notation for the current directory
1043 # since this would lead to problems installing/building glibc.
1044 # LD_LIBRARY_PATH contains the current directory if one of the following
1045 # is true:
1046 # - one of the terminals (":" and ";") is the first or last sign
1047 # - two terminals occur directly after each other
1048 # - the path contains an element with a dot in it
1049 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1050 changequote(,)dnl
1051 case ${LD_LIBRARY_PATH} in
1052   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1053     ld_library_path_setting="contains current directory"
1054     ;;
1055   *)
1056     ld_library_path_setting="ok"
1057     ;;
1058 esac
1059 changequote([,])dnl
1060 AC_MSG_RESULT($ld_library_path_setting)
1061 if test "$ld_library_path_setting" != "ok"; then
1062 AC_MSG_ERROR([
1063 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1064 *** building glibc. Please change the environment variable
1065 *** and run configure again.])
1066 fi
1067
1068 AC_PATH_PROG(BASH_SHELL, bash, no)
1069
1070 AC_PATH_PROG(PERL, perl, no)
1071 if test "$PERL" != no &&
1072    (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1073   PERL=no
1074 fi
1075 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1076              $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1077 AC_CHECK_PROG_VER(BISON, bison, --version,
1078                   [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
1079                   [2.7*|[3-9].*|[1-9][0-9]*],
1080                   BISON=no)
1081
1082 AC_CACHE_CHECK(whether we need to use -P to assemble .S files,
1083                libc_cv_need_minus_P, [dnl
1084 cat > conftest.S <<EOF
1085 #include "confdefs.h"
1086 /* Nothing whatsoever.  */
1087 EOF
1088 if AC_TRY_COMMAND(${CC-cc} $CPPFLAGS $ASFLAGS -c conftest.S 1>&AS_MESSAGE_LOG_FD); then
1089   libc_cv_need_minus_P=no
1090 else
1091   libc_cv_need_minus_P=yes
1092 fi
1093 rm -f conftest*])
1094 if test $libc_cv_need_minus_P = yes; then
1095   config_vars="$config_vars
1096 asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
1097 fi
1098
1099 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1100 cat > conftest.s <<EOF
1101 ${libc_cv_dot_text}
1102 foo:
1103 .set glibc_conftest_frobozz,foo
1104 .globl glibc_conftest_frobozz
1105 EOF
1106 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1107 # (but it doesn't work), so we must do a linking check to be sure.
1108 cat > conftest1.c <<\EOF
1109 extern int glibc_conftest_frobozz;
1110 void _start() { glibc_conftest_frobozz = 1; }
1111 EOF
1112 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1113             -nostartfiles -nostdlib \
1114             -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1115   libc_cv_asm_set_directive=yes
1116 else
1117   libc_cv_asm_set_directive=no
1118 fi
1119 rm -f conftest*])
1120 if test $libc_cv_asm_set_directive = yes; then
1121   AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1122 fi
1123
1124 AC_CACHE_CHECK(for assembler gnu_unique_object symbol type,
1125                libc_cv_asm_unique_object, [dnl
1126 cat > conftest.s <<EOF
1127 ${libc_cv_dot_text}
1128 _sym:
1129 .type _sym, %gnu_unique_object
1130 EOF
1131 if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1132   libc_cv_asm_unique_object=yes
1133 else
1134   libc_cv_asm_unique_object=no
1135 fi
1136 rm -f conftest*])
1137 if test $libc_cv_asm_unique_object = yes; then
1138   AC_DEFINE(HAVE_ASM_UNIQUE_OBJECT)
1139 fi
1140
1141 AC_CACHE_CHECK(for .protected and .hidden assembler directive,
1142                libc_cv_asm_protected_directive, [dnl
1143 cat > conftest.s <<EOF
1144 .protected foo
1145 foo:
1146 .hidden bar
1147 bar:
1148 EOF
1149 if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1150   libc_cv_asm_protected_directive=yes
1151 else
1152   AC_MSG_ERROR(assembler support for symbol visibility is required)
1153 fi
1154 rm -f conftest*])
1155
1156 if test $libc_cv_asm_protected_directive = yes; then
1157   AC_CACHE_CHECK(whether __attribute__((visibility())) is supported,
1158                  libc_cv_visibility_attribute,
1159                  [cat > conftest.c <<EOF
1160                   int foo __attribute__ ((visibility ("hidden"))) = 1;
1161                   int bar __attribute__ ((visibility ("protected"))) = 1;
1162 EOF
1163                   libc_cv_visibility_attribute=no
1164                   if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1165                     if grep '\.hidden.*foo' conftest.s >/dev/null; then
1166                       if grep '\.protected.*bar' conftest.s >/dev/null; then
1167                         libc_cv_visibility_attribute=yes
1168                       fi
1169                     fi
1170                   fi
1171                   rm -f conftest.{c,s}
1172                  ])
1173   if test $libc_cv_visibility_attribute != yes; then
1174     AC_MSG_ERROR(compiler support for visibility attribute is required)
1175   fi
1176 fi
1177
1178 if test $libc_cv_visibility_attribute = yes; then
1179   AC_CACHE_CHECK(linker support for protected data symbol,
1180                  libc_cv_protected_data,
1181                  [cat > conftest.c <<EOF
1182                   int bar __attribute__ ((visibility ("protected"))) = 1;
1183 EOF
1184                   libc_cv_protected_data=no
1185                   if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles -fPIC -shared conftest.c -o conftest.so); then
1186                     cat > conftest.c <<EOF
1187                     extern int bar;
1188                     int main (void) { return bar; }
1189 EOF
1190                     if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles conftest.c -o conftest conftest.so); then
1191                       libc_cv_protected_data=yes
1192                     fi
1193                   fi
1194                   rm -f conftest.*
1195                  ])
1196 else
1197   libc_cv_protected_data=no
1198 fi
1199 AC_SUBST(libc_cv_protected_data)
1200
1201 if test $libc_cv_visibility_attribute = yes; then
1202   AC_CACHE_CHECK(for broken __attribute__((visibility())),
1203                  libc_cv_broken_visibility_attribute,
1204                  [cat > conftest.c <<EOF
1205                   int foo (int x);
1206                   int bar (int x) __asm__ ("foo") __attribute__ ((visibility ("hidden")));
1207                   int bar (int x) { return x; }
1208 EOF
1209                   libc_cv_broken_visibility_attribute=yes
1210                   if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1211 changequote(,)dnl
1212                     if grep '\.hidden[  _]foo' conftest.s >/dev/null; then
1213 changequote([,])dnl
1214                       libc_cv_broken_visibility_attribute=no
1215                     fi
1216                   fi
1217                   rm -f conftest.c conftest.s
1218                  ])
1219   if test $libc_cv_broken_visibility_attribute = yes; then
1220     AC_MSG_ERROR(working compiler support for visibility attribute is required)
1221   fi
1222 fi
1223
1224 AC_CACHE_CHECK(for broken __attribute__((alias())),
1225                libc_cv_broken_alias_attribute,
1226                [cat > conftest.c <<EOF
1227                extern int foo (int x) __asm ("xyzzy");
1228                int bar (int x) { return x; }
1229                extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1230                extern int dfoo;
1231                extern __typeof (dfoo) dfoo __asm ("abccb");
1232                int dfoo = 1;
1233 EOF
1234                libc_cv_broken_alias_attribute=yes
1235                if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1236                  if grep 'xyzzy' conftest.s >/dev/null &&
1237                     grep 'abccb' conftest.s >/dev/null; then
1238                    libc_cv_broken_alias_attribute=no
1239                  fi
1240                fi
1241                rm -f conftest.c conftest.s
1242                ])
1243 if test $libc_cv_broken_alias_attribute = yes; then
1244   AC_MSG_ERROR(working alias attribute support required)
1245 fi
1246
1247 if test $libc_cv_visibility_attribute = yes; then
1248   AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1249                  libc_cv_have_sdata_section,
1250                  [echo "int i;" > conftest.c
1251                   libc_cv_have_sdata_section=no
1252                   if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1253                      | grep '\.sdata' >/dev/null; then
1254                     libc_cv_have_sdata_section=yes
1255                   fi
1256                   rm -f conftest.c conftest.so
1257                  ])
1258   if test $libc_cv_have_sdata_section = yes; then
1259     AC_DEFINE(HAVE_SDATA_SECTION)
1260   fi
1261 fi
1262
1263 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
1264                libc_cv_initfini_array, [dnl
1265 LIBC_TRY_LINK_STATIC([
1266 int foo (void) { return 1; }
1267 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
1268 ],
1269   [if $READELF -S conftest | fgrep INIT_ARRAY > /dev/null; then
1270     libc_cv_initfini_array=yes
1271   else
1272     libc_cv_initfini_array=no
1273   fi],
1274   [libc_cv_initfini_array=no])
1275 ])
1276 if test $libc_cv_initfini_array != yes; then
1277   AC_MSG_ERROR([Need linker with .init_array/.fini_array support.])
1278 fi
1279
1280 AC_CACHE_CHECK(whether to use .ctors/.dtors header and trailer,
1281                libc_cv_ctors_header, [dnl
1282   libc_cv_ctors_header=yes
1283   LIBC_TRY_LINK_STATIC([
1284 __attribute__ ((constructor)) void ctor (void) { asm (""); }
1285 __attribute__ ((destructor))  void dtor (void) { asm (""); }
1286 ],
1287               [dnl
1288       AS_IF([$READELF -WS conftest$ac_exeext | $AWK '
1289         { gsub(/\@<:@ */, "@<:@") }
1290         $2 == ".ctors" || $2 == ".dtors" {
1291           size = strtonum("0x" $6)
1292           align = strtonum("0x" $NF)
1293           seen@<:@$2@:>@ = 1
1294           stub@<:@$2@:>@ = size == align * 2
1295         }
1296         END {
1297           ctors_ok = !seen@<:@".ctors"@:>@ || stub@<:@".ctors"@:>@
1298           dtors_ok = !seen@<:@".dtors"@:>@ || stub@<:@".dtors"@:>@
1299           exit ((ctors_ok && dtors_ok) ? 0 : 1)
1300         }
1301       '], [libc_cv_ctors_header=no])
1302     ], [dnl
1303       AC_MSG_ERROR([missing __attribute__ ((constructor)) support??])
1304     ])
1305 ])
1306 if test $libc_cv_ctors_header = no; then
1307   AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
1308 fi
1309
1310 AC_CACHE_CHECK(for libunwind-support in compiler,
1311                libc_cv_cc_with_libunwind, [
1312   cat > conftest.c <<EOF
1313 int main (void) { return 0; }
1314 EOF
1315   if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1316      conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
1317     libc_cv_cc_with_libunwind=yes
1318   else
1319     libc_cv_cc_with_libunwind=no
1320   fi
1321   rm -f conftest*])
1322 AC_SUBST(libc_cv_cc_with_libunwind)
1323 if test $libc_cv_cc_with_libunwind = yes; then
1324   AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1325 fi
1326
1327 LIBC_LINKER_FEATURE([-z nodelete], [-Wl,--enable-new-dtags,-z,nodelete],
1328                     [libc_cv_z_nodelete=yes],
1329                     [AC_MSG_ERROR(linker with -z nodelete support required)])
1330
1331 LIBC_LINKER_FEATURE([-z nodlopen], [-Wl,--enable-new-dtags,-z,nodlopen],
1332                     [libc_cv_z_nodlopen=yes],
1333                     [AC_MSG_ERROR(linker with -z nodlopen support required)])
1334
1335 LIBC_LINKER_FEATURE([-z initfirst], [-Wl,--enable-new-dtags,-z,initfirst],
1336                     [libc_cv_z_initfirst=yes],
1337                     [AC_MSG_ERROR(linker with -z initfirst support required)])
1338
1339 ASFLAGS_config=
1340 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1341                libc_cv_as_noexecstack, [dnl
1342 cat > conftest.c <<EOF
1343 void foo (void) { }
1344 EOF
1345 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1346                    -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1347    && grep .note.GNU-stack conftest.s >/dev/null \
1348    && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1349                       -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1350 then
1351   libc_cv_as_noexecstack=yes
1352 else
1353   libc_cv_as_noexecstack=no
1354 fi
1355 rm -f conftest*])
1356 if test $libc_cv_as_noexecstack = yes; then
1357   ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1358 fi
1359 AC_SUBST(ASFLAGS_config)
1360
1361 AC_CACHE_CHECK(for -z combreloc,
1362                libc_cv_z_combreloc, [dnl
1363 cat > conftest.c <<EOF
1364 extern int bar (int);
1365 extern int mumble;
1366 int foo (void) { return bar (mumble); }
1367 EOF
1368 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1369                         -fPIC -shared -o conftest.so conftest.c
1370                         -nostdlib -nostartfiles
1371                         -Wl,-z,combreloc 1>&AS_MESSAGE_LOG_FD])
1372 then
1373 dnl The following test is a bit weak.  We must use a tool which can test
1374 dnl cross-platform since the gcc used can be a cross compiler.  Without
1375 dnl introducing new options this is not easily doable.  Instead use a tool
1376 dnl which always is cross-platform: readelf.  To detect whether -z combreloc
1377 dnl look for a section named .rel.dyn.
1378   if $READELF -S conftest.so | grep '\.rel\(a\|\)\.dyn' > /dev/null; then
1379     libc_cv_z_combreloc=yes
1380   else
1381     libc_cv_z_combreloc=no
1382   fi
1383 else
1384   libc_cv_z_combreloc=no
1385 fi
1386 rm -f conftest*])
1387 if test "$libc_cv_z_combreloc" = yes; then
1388   AC_DEFINE(HAVE_Z_COMBRELOC)
1389 fi
1390 AC_SUBST(libc_cv_z_combreloc)
1391
1392 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1393                     [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1394 AC_SUBST(libc_cv_z_execstack)
1395
1396 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1397 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1398 ])
1399
1400 AC_SUBST(libc_cv_fpie)
1401
1402 AC_CACHE_CHECK(for --hash-style option,
1403                libc_cv_hashstyle, [dnl
1404 cat > conftest.c <<EOF
1405 int _start (void) { return 42; }
1406 EOF
1407 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1408                             -fPIC -shared -o conftest.so conftest.c
1409                             -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
1410 then
1411   libc_cv_hashstyle=yes
1412 else
1413   libc_cv_hashstyle=no
1414 fi
1415 rm -f conftest*])
1416 AC_SUBST(libc_cv_hashstyle)
1417
1418 # The linker's default -shared behavior is good enough if it
1419 # does these things that our custom linker scripts ensure that
1420 # all allocated NOTE sections come first.
1421 if test "$use_default_link" = default; then
1422   AC_CACHE_CHECK([for sufficient default -shared layout],
1423                   libc_cv_use_default_link, [dnl
1424   libc_cv_use_default_link=no
1425   cat > conftest.s <<\EOF
1426           .section .note.a,"a",%note
1427           .balign 4
1428           .long 4,4,9
1429           .string "GNU"
1430           .string "foo"
1431           .section .note.b,"a",%note
1432           .balign 4
1433           .long 4,4,9
1434           .string "GNU"
1435           .string "bar"
1436 EOF
1437   if AC_TRY_COMMAND([dnl
1438   ${CC-cc} $ASFLAGS -shared -o conftest.so conftest.s 1>&AS_MESSAGE_LOG_FD]) &&
1439        ac_try=`$READELF -S conftest.so | sed -n \
1440          ['${x;p;}
1441           s/^ *\[ *[1-9][0-9]*\]  *\([^ ][^ ]*\)  *\([^ ][^ ]*\) .*$/\2 \1/
1442           t a
1443           b
1444           : a
1445           H']`
1446   then
1447     libc_seen_a=no libc_seen_b=no
1448     set -- $ac_try
1449     while test $# -ge 2 -a "$1" = NOTE; do
1450       case "$2" in
1451       .note.a) libc_seen_a=yes ;;
1452       .note.b) libc_seen_b=yes ;;
1453       esac
1454       shift 2
1455     done
1456     case "$libc_seen_a$libc_seen_b" in
1457     yesyes)
1458       libc_cv_use_default_link=yes
1459       ;;
1460     *)
1461       echo >&AS_MESSAGE_LOG_FD "\
1462 $libc_seen_a$libc_seen_b from:
1463 $ac_try"
1464       ;;
1465     esac
1466   fi
1467   rm -f conftest*])
1468   use_default_link=$libc_cv_use_default_link
1469 fi
1470
1471 AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
1472 if libc_cv_output_format=`
1473 ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
1474 then
1475   :
1476 else
1477   libc_cv_output_format=
1478 fi
1479 test -n "$libc_cv_output_format" || libc_cv_output_format=unknown])
1480 AC_SUBST(libc_cv_output_format)
1481
1482 AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
1483 cat > conftest.c <<EOF
1484 int foo;
1485 EOF
1486 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
1487                             conftest.c 1>&AS_MESSAGE_LOG_FD])
1488 then
1489   libc_cv_fno_toplevel_reorder=yes
1490 else
1491   libc_cv_fno_toplevel_reorder=no
1492 fi
1493 rm -f conftest*])
1494 if test $libc_cv_fno_toplevel_reorder = yes; then
1495   fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
1496 else
1497   fno_unit_at_a_time=-fno-unit-at-a-time
1498 fi
1499 AC_SUBST(fno_unit_at_a_time)
1500
1501 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
1502 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
1503                    [libc_cv_ssp=yes],
1504                    [libc_cv_ssp=no])
1505 ])
1506
1507 AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
1508 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
1509                    [libc_cv_ssp_strong=yes],
1510                    [libc_cv_ssp_strong=no])
1511 ])
1512
1513 stack_protector=
1514 if test "$libc_cv_ssp_strong" = "yes"; then
1515   stack_protector="-fstack-protector-strong"
1516 elif test "$libc_cv_ssp" = "yes"; then
1517   stack_protector="-fstack-protector"
1518 fi
1519 AC_SUBST(stack_protector)
1520
1521 AC_CACHE_CHECK(whether cc puts quotes around section names,
1522                libc_cv_have_section_quotes,
1523                [cat > conftest.c <<EOF
1524                 static const int foo
1525                 __attribute__ ((section ("bar"))) = 1;
1526 EOF
1527                 if ${CC-cc} -S conftest.c -o conftest.s; then
1528                   if grep '\.section.*"bar"' conftest.s >/dev/null; then
1529                     libc_cv_have_section_quotes=yes
1530                   else
1531                     libc_cv_have_section_quotes=no
1532                   fi
1533                 else
1534                   libc_cv_have_section_quotes=unknown
1535                 fi
1536                 rm -f conftest.{c,s}
1537                 ])
1538 if test $libc_cv_have_section_quotes = yes; then
1539   AC_DEFINE(HAVE_SECTION_QUOTES)
1540 fi
1541
1542 AC_CACHE_CHECK(for ld --no-whole-archive, libc_cv_ld_no_whole_archive, [dnl
1543 cat > conftest.c <<\EOF
1544 _start () {}
1545 int __eh_pc;
1546 __throw () {}
1547 EOF
1548 dnl No \ in command here because it ends up inside ''.
1549 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1550                             -nostdlib -nostartfiles -Wl,--no-whole-archive
1551                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
1552   libc_cv_ld_no_whole_archive=yes
1553 else
1554   libc_cv_ld_no_whole_archive=no
1555 fi
1556 rm -f conftest*])
1557 if test $libc_cv_ld_no_whole_archive = no; then
1558   AC_MSG_ERROR([support for --no-whole-archive is needed])
1559 fi
1560
1561 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1562 cat > conftest.c <<\EOF
1563 void zero (void *x)
1564 {
1565   __builtin_memset (x, 0, 1000);
1566 }
1567 EOF
1568 dnl
1569 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "memset" > /dev/null]);
1570 then
1571   libc_cv_gcc_builtin_memset=no
1572 else
1573   libc_cv_gcc_builtin_memset=yes
1574 fi
1575 rm -f conftest* ])
1576 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1577   AC_DEFINE(HAVE_BUILTIN_MEMSET)
1578 fi
1579
1580 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1581 cat > conftest.c <<\EOF
1582 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1583 char *foo (const char *a, const char *b)
1584 {
1585   return __builtin_strstr (a, b);
1586 }
1587 EOF
1588 dnl
1589 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "my_strstr" > /dev/null]);
1590 then
1591   libc_cv_gcc_builtin_redirection=yes
1592 else
1593   libc_cv_gcc_builtin_redirection=no
1594 fi
1595 rm -f conftest* ])
1596 if test "$libc_cv_gcc_builtin_redirection" = no; then
1597   AC_MSG_ERROR([support for the symbol redirection needed])
1598 fi
1599
1600 dnl Check whether the compiler supports the __thread keyword.
1601 AC_CACHE_CHECK([for __thread], libc_cv_gcc___thread,
1602 [cat > conftest.c <<\EOF
1603 __thread int a = 42;
1604 EOF
1605 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
1606   libc_cv_gcc___thread=yes
1607 else
1608   libc_cv_gcc___thread=no
1609 fi
1610 rm -f conftest*])
1611 if test "$libc_cv_gcc___thread" = no; then
1612   AC_MSG_ERROR([support for the __thread keyword is required])
1613 fi
1614
1615 dnl Check whether the compiler supports the tls_model attribute.
1616 AC_CACHE_CHECK([for tls_model attribute], libc_cv_gcc_tls_model_attr, [dnl
1617 cat > conftest.c <<\EOF
1618 extern __thread int a __attribute__((tls_model ("initial-exec")));
1619 EOF
1620 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -Werror conftest.c >&AS_MESSAGE_LOG_FD]); then
1621   libc_cv_gcc_tls_model_attr=yes
1622 else
1623   libc_cv_gcc_tls_model_attr=no
1624 fi
1625 rm -f conftest*])
1626 if test "$libc_cv_gcc_tls_model_attr" = no; then
1627   AC_MSG_ERROR([support for the tls_model attribute is required])
1628 fi
1629
1630 dnl Determine how to disable generation of FMA instructions.
1631 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1632                libc_cv_cc_nofma, [dnl
1633 libc_cv_cc_nofma=
1634 for opt in -ffp-contract=off -mno-fused-madd; do
1635   LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1636 done])
1637 AC_SUBST(libc_cv_cc_nofma)
1638
1639 if test -n "$submachine"; then
1640   AC_CACHE_CHECK([for compiler option for CPU variant],
1641                  libc_cv_cc_submachine, [dnl
1642   libc_cv_cc_submachine=no
1643   for opt in "-march=$submachine" "-mcpu=$submachine"; do
1644     LIBC_TRY_CC_OPTION([$opt], [
1645       libc_cv_cc_submachine="$opt"
1646       break], [])
1647   done])
1648   if test "x$libc_cv_cc_submachine" = xno; then
1649     AC_MSG_ERROR([${CC-cc} does not support $submachine])
1650   fi
1651 fi
1652 AC_SUBST(libc_cv_cc_submachine)
1653
1654 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1655 __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1656 cat > conftest.c <<EOF
1657 void
1658 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1659 foo (void) {}
1660 EOF
1661 libc_cv_cc_loop_to_function=no
1662 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
1663 then
1664   libc_cv_cc_loop_to_function=yes
1665 fi
1666 rm -f conftest*])
1667 if test $libc_cv_cc_loop_to_function = yes; then
1668   AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1669 fi
1670 AC_SUBST(libc_cv_cc_loop_to_function)
1671
1672 dnl Check whether we have the gd library available.
1673 AC_MSG_CHECKING(for libgd)
1674 if test "$with_gd" != "no"; then
1675   old_CFLAGS="$CFLAGS"
1676   CFLAGS="$CFLAGS $libgd_include"
1677   old_LDFLAGS="$LDFLAGS"
1678   LDFLAGS="$LDFLAGS $libgd_ldflags"
1679   old_LIBS="$LIBS"
1680   LIBS="$LIBS -lgd -lpng -lz -lm"
1681   AC_TRY_LINK([#include <gd.h>], [gdImagePng (0, 0)], LIBGD=yes, LIBGD=no)
1682   CFLAGS="$old_CFLAGS"
1683   LDFLAGS="$old_LDFLAGS"
1684   LIBS="$old_LIBS"
1685 else
1686   LIBGD=no
1687 fi
1688 AC_MSG_RESULT($LIBGD)
1689 AC_SUBST(LIBGD)
1690
1691 # SELinux detection
1692 if test x$with_selinux = xno ; then
1693   have_selinux=no;
1694 else
1695   # See if we have the SELinux library
1696   AC_CHECK_LIB(selinux, is_selinux_enabled,
1697                have_selinux=yes, have_selinux=no)
1698   if test x$with_selinux = xyes ; then
1699     if test x$have_selinux = xno ; then
1700       AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1701     fi
1702   fi
1703 fi
1704 # Check if we're building with SELinux support.
1705 if test "x$have_selinux" = xyes; then
1706   AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1707
1708   # See if we have the libaudit library
1709   AC_CHECK_LIB(audit, audit_log_user_avc_message,
1710                have_libaudit=yes, have_libaudit=no)
1711   if test "x$have_libaudit" = xyes; then
1712     AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1713   fi
1714   AC_SUBST(have_libaudit)
1715
1716   # See if we have the libcap library
1717   AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1718   if test "x$have_libcap" = xyes; then
1719     AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1720   fi
1721   AC_SUBST(have_libcap)
1722 fi
1723 AC_SUBST(have_selinux)
1724
1725 CPPUNDEFS=
1726 dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE.
1727 dnl Since we are building the implementations of the fortified functions here,
1728 dnl having the macro defined interacts very badly.
1729 AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source,
1730 [AC_TRY_COMPILE([], [
1731 #ifdef _FORTIFY_SOURCE
1732 # error bogon
1733 #endif],
1734                 [libc_cv_predef_fortify_source=no],
1735                 [libc_cv_predef_fortify_source=yes])])
1736 if test $libc_cv_predef_fortify_source = yes; then
1737   CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
1738 fi
1739 AC_SUBST(CPPUNDEFS)
1740
1741 dnl Check for silly hacked compilers inserting -fstack-protector.
1742 dnl This breaks badly for the early startup code we compile, since
1743 dnl the compiled code can refer to a magic machine-dependent location
1744 dnl for the canary value before we have sufficient setup for that to
1745 dnl work.  It's also questionable to build all of libc with this flag
1746 dnl even when you're doing that for most applications you build, since
1747 dnl libc's code is so heavily-used and performance-sensitive.  If we
1748 dnl ever really want to make that work, it should be enabled explicitly
1749 dnl in the libc build, not inherited from implicit compiler settings.
1750 AC_CACHE_CHECK([whether $CC implicitly enables -fstack-protector],
1751                libc_cv_predef_stack_protector, [
1752 AC_TRY_COMPILE([extern void foobar (char *);],
1753                [char large_array[2048]; foobar (large_array);], [
1754 libc_undefs=`$NM -u conftest.o |
1755   LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1756     2>&AS_MESSAGE_LOG_FD` || {
1757   AC_MSG_ERROR([confusing output from $NM -u])
1758 }
1759 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1760 # On some architectures, there are architecture-specific undefined
1761 # symbols (resolved by the linker), so filter out unknown symbols.
1762 # This will fail to produce the correct result if the compiler
1763 # defaults to -fstack-protector but this produces an undefined symbol
1764 # other than __stack_chk_fail.  However, compilers like that have not
1765 # been encountered in practice.
1766 libc_undefs=`echo "$libc_undefs" | egrep '^(foobar|__stack_chk_fail)$'`
1767 case "$libc_undefs" in
1768 foobar) libc_cv_predef_stack_protector=no ;;
1769 '__stack_chk_fail
1770 foobar') libc_cv_predef_stack_protector=yes ;;
1771 *) AC_MSG_ERROR([unexpected symbols in test: $libc_undefs]) ;;
1772 esac],
1773                [AC_MSG_ERROR([test compilation failed])])
1774 ])
1775 libc_extra_cflags=
1776 if test $libc_cv_predef_stack_protector = yes; then
1777   libc_extra_cflags="$libc_extra_cflags -fno-stack-protector"
1778 fi
1779 libc_extra_cppflags=
1780
1781 # Some linkers on some architectures support __ehdr_start but with
1782 # bugs.  Make sure usage of it does not create relocations in the
1783 # output (as the linker should resolve them all for us).
1784 AC_CACHE_CHECK([whether the linker provides working __ehdr_start],
1785                libc_cv_ehdr_start, [
1786 old_CFLAGS="$CFLAGS"
1787 old_LDFLAGS="$LDFLAGS"
1788 old_LIBS="$LIBS"
1789 CFLAGS="$CFLAGS -fPIC"
1790 LDFLAGS="$LDFLAGS -nostdlib -nostartfiles -shared"
1791 LIBS=
1792 AC_LINK_IFELSE([AC_LANG_SOURCE([
1793 typedef struct {
1794   char foo;
1795   long val;
1796 } Ehdr;
1797 extern const Ehdr __ehdr_start __attribute__ ((visibility ("hidden")));
1798 long ehdr (void) { return __ehdr_start.val; }
1799 ])],
1800                [if $READELF -r conftest | fgrep __ehdr_start >/dev/null; then
1801                   libc_cv_ehdr_start=broken
1802                 else
1803                   libc_cv_ehdr_start=yes
1804                 fi], [libc_cv_ehdr_start=no])
1805 CFLAGS="$old_CFLAGS"
1806 LDFLAGS="$old_LDFLAGS"
1807 LIBS="$old_LIBS"
1808 ])
1809 if test "$libc_cv_ehdr_start" = yes; then
1810   AC_DEFINE([HAVE_EHDR_START])
1811 elif test "$libc_cv_ehdr_start" = broken; then
1812   AC_MSG_WARN([linker is broken -- you should upgrade])
1813 fi
1814
1815 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1816                libc_cv_builtin_trap, [dnl
1817 libc_cv_builtin_trap=no
1818 AC_TRY_COMPILE([], [__builtin_trap ()], [
1819 libc_undefs=`$NM -u conftest.o |
1820   LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1821     2>&AS_MESSAGE_LOG_FD` || {
1822   AC_MSG_ERROR([confusing output from $NM -u])
1823 }
1824 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1825 if test -z "$libc_undefs"; then
1826   libc_cv_builtin_trap=yes
1827 fi])])
1828 if test $libc_cv_builtin_trap = yes; then
1829   AC_DEFINE([HAVE_BUILTIN_TRAP])
1830 fi
1831
1832 dnl C++ feature tests.
1833 AC_LANG_PUSH([C++])
1834
1835 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1836                libc_cv_cxx_thread_local, [
1837 old_CXXFLAGS="$CXXFLAGS"
1838 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1839 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1840 #include <thread>
1841
1842 // Compiler support.
1843 struct S
1844 {
1845   S ();
1846   ~S ();
1847 };
1848 thread_local S s;
1849 S * get () { return &s; }
1850
1851 // libstdc++ support.
1852 #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1853 #error __cxa_thread_atexit_impl not supported
1854 #endif
1855 ])],
1856                [libc_cv_cxx_thread_local=yes],
1857                [libc_cv_cxx_thread_local=no])
1858 CXXFLAGS="$old_CXXFLAGS"
1859 ])
1860 AC_SUBST(libc_cv_cxx_thread_local)
1861
1862 AC_LANG_POP([C++])
1863 dnl End of C++ feature tests.
1864
1865 ### End of automated tests.
1866 ### Now run sysdeps configure fragments.
1867
1868 # They also can set these variables.
1869 use_ldconfig=no
1870 ldd_rewrite_script=no
1871 libc_cv_sysconfdir=$sysconfdir
1872 libc_cv_localstatedir=$localstatedir
1873 libc_cv_gcc_unwind_find_fde=no
1874 libc_cv_idn=no
1875
1876 # Iterate over all the sysdep directories we will use, running their
1877 # configure fragments.
1878 for dir in $sysnames; do
1879   case $dir in
1880     /*) dest=$dir ;;
1881     *)  dest=$srcdir/$dir ;;
1882   esac
1883   if test -r $dest/configure; then
1884     AC_MSG_RESULT(running configure fragment for $dir)
1885     . $dest/configure
1886   fi
1887 done
1888
1889 if test x"$build_mathvec" = xnotset; then
1890   build_mathvec=no
1891 fi
1892 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1893
1894 AC_SUBST(libc_extra_cflags)
1895 AC_SUBST(libc_extra_cppflags)
1896
1897 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1898   AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1899 fi
1900 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1901
1902 # A sysdeps configure fragment can reset this if IFUNC is not actually
1903 # usable even though the assembler knows how to generate the symbol type.
1904 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1905   AC_DEFINE(HAVE_IFUNC)
1906 fi
1907
1908 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1909 # configure fragment can override the value to prevent this AC_DEFINE.
1910 AC_SUBST(use_nscd)
1911 if test "x$use_nscd" != xno; then
1912   AC_DEFINE([USE_NSCD])
1913 fi
1914 if test "x$build_nscd" = xdefault; then
1915   build_nscd=$use_nscd
1916 fi
1917
1918 # Test for old glibc 2.0.x headers so that they can be removed properly
1919 # Search only in includedir.
1920 AC_MSG_CHECKING(for old glibc 2.0.x headers)
1921 if eval test -f "${includedir}/elfclass.h" -a -f "${includedir}/fcntlbits.h"
1922 then
1923   old_glibc_headers=yes
1924 else
1925   old_glibc_headers=no
1926 fi
1927 AC_MSG_RESULT($old_glibc_headers)
1928 if test ${old_glibc_headers} = yes; then
1929   AC_MSG_WARN(*** During \"make install\" old headers from glibc 2.0.x will)
1930   AC_MSG_WARN(*** be removed.)
1931 fi
1932 AC_SUBST(old_glibc_headers)
1933
1934 AC_SUBST(libc_cv_slibdir)
1935 AC_SUBST(libc_cv_rtlddir)
1936 AC_SUBST(libc_cv_localedir)
1937 AC_SUBST(libc_cv_sysconfdir)
1938 AC_SUBST(libc_cv_localstatedir)
1939 AC_SUBST(libc_cv_rootsbindir)
1940 AC_SUBST(libc_cv_forced_unwind)
1941
1942 if test x$use_ldconfig = xyes; then
1943   AC_DEFINE(USE_LDCONFIG)
1944 fi
1945 AC_SUBST(use_ldconfig)
1946 AC_SUBST(ldd_rewrite_script)
1947
1948 AC_SUBST(static)
1949 AC_SUBST(shared)
1950
1951 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1952 [libc_cv_pic_default=yes
1953 cat > conftest.c <<EOF
1954 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
1955 # error PIC is default.
1956 #endif
1957 EOF
1958 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1959   libc_cv_pic_default=no
1960 fi
1961 rm -f conftest.*])
1962 AC_SUBST(libc_cv_pic_default)
1963
1964 AC_CACHE_CHECK([whether -fPIE is default], libc_cv_pie_default,
1965 [libc_cv_pie_default=yes
1966 cat > conftest.c <<EOF
1967 #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1968 # error PIE is default.
1969 #endif
1970 EOF
1971 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1972   libc_cv_pie_default=no
1973 fi
1974 rm -f conftest.*])
1975 AC_SUBST(libc_cv_pie_default)
1976
1977 AC_SUBST(profile)
1978 AC_SUBST(static_nss)
1979
1980 AC_SUBST(DEFINES)
1981
1982 dnl See sysdeps/mach/configure.ac for this variable.
1983 AC_SUBST(mach_interface_list)
1984
1985 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
1986 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
1987 AC_SUBST(VERSION)
1988 AC_SUBST(RELEASE)
1989
1990 AC_CONFIG_FILES([config.make Makefile])
1991 AC_CONFIG_COMMANDS([default],[[
1992 case $CONFIG_FILES in *config.make*)
1993 echo "$config_vars" >> config.make;;
1994 esac
1995 test -d bits || mkdir bits]],[[config_vars='$config_vars']])
1996 AC_OUTPUT