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