powerpc: drop R_PPC_REL16 check
[glibc.git] / configure.ac
blobd89aaf0cdf329f1fe6247dbbfad49693642c570f
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([hardcoded-path-in-tests],
155               AC_HELP_STRING([--enable-hardcoded-path-in-tests],
156                              [hardcode newly built glibc path in tests @<:@default=no@:>@]),
157               [hardcoded_path_in_tests=$enableval],
158               [hardcoded_path_in_tests=no])
159 AC_SUBST(hardcoded_path_in_tests)
161 AC_ARG_ENABLE([stackguard-randomization],
162               AC_HELP_STRING([--enable-stackguard-randomization],
163                              [initialize __stack_chk_guard canary with a random number at program start]),
164               [enable_stackguard_randomize=$enableval],
165               [enable_stackguard_randomize=no])
166 if test "$enable_stackguard_randomize" = yes; then
167   AC_DEFINE(ENABLE_STACKGUARD_RANDOMIZE)
170 AC_ARG_ENABLE([lock-elision],
171               AC_HELP_STRING([--enable-lock-elision[=yes/no]],
172                              [Enable lock elision for pthread mutexes by default]),
173               [enable_lock_elision=$enableval],
174               [enable_lock_elision=no])
175 AC_SUBST(enable_lock_elision)
176 if test "$enable_lock_elision" = yes ; then
177   AC_DEFINE(ENABLE_LOCK_ELISION)
180 dnl Generic infrastructure for drop-in additions to libc.
181 AC_ARG_ENABLE([add-ons],
182               AC_HELP_STRING([--enable-add-ons@<:@=DIRS...@:>@],
183                              [configure and build add-ons in DIR1,DIR2,...
184                               search for add-ons if no parameter given]),
185                              , [enable_add_ons=yes])
187 AC_ARG_ENABLE([hidden-plt],
188               AC_HELP_STRING([--disable-hidden-plt],
189                              [do not hide internal function calls to avoid PLT]),
190               [hidden=$enableval],
191               [hidden=yes])
192 if test "x$hidden" = xno; then
193   AC_DEFINE(NO_HIDDEN)
196 AC_ARG_ENABLE([bind-now],
197               AC_HELP_STRING([--enable-bind-now],
198                              [disable lazy relocations in DSOs]),
199               [bindnow=$enableval],
200               [bindnow=no])
201 AC_SUBST(bindnow)
203 dnl On some platforms we cannot use dynamic loading.  We must provide
204 dnl static NSS modules.
205 AC_ARG_ENABLE([static-nss],
206               AC_HELP_STRING([--enable-static-nss],
207                              [build static NSS modules @<:@default=no@:>@]),
208               [static_nss=$enableval],
209               [static_nss=no])
210 dnl Enable static NSS also if we build no shared objects.
211 if test x"$static_nss" = xyes || test x"$shared" = xno; then
212   static_nss=yes
213   AC_DEFINE(DO_STATIC_NSS)
216 AC_ARG_ENABLE([force-install],
217               AC_HELP_STRING([--disable-force-install],
218                              [don't force installation of files from this package, even if they are older than the installed files]),
219               [force_install=$enableval],
220               [force_install=yes])
221 AC_SUBST(force_install)
223 AC_ARG_ENABLE([maintainer-mode],
224               AC_HELP_STRING([--enable-maintainer-mode],
225                              [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
226               [maintainer=$enableval],
227               [maintainer=no])
229 dnl On some platforms we allow dropping compatibility with all kernel
230 dnl versions.
231 AC_ARG_ENABLE([kernel],
232               AC_HELP_STRING([--enable-kernel=VERSION],
233                              [compile for compatibility with kernel not older than VERSION]),
234               [minimum_kernel=$enableval],
235               [])
236 dnl Prevent unreasonable values.
237 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
238   # Better nothing than this.
239   minimum_kernel=""
240 else
241   if test "$minimum_kernel" = current; then
242     minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
243   fi
246 dnl For the development we sometimes want gcc to issue even more warnings.
247 dnl This is not the default since many of the extra warnings are not
248 dnl appropriate.
249 AC_ARG_ENABLE([all-warnings],
250               AC_HELP_STRING([--enable-all-warnings],
251                              [enable all useful warnings gcc can issue]),
252               [all_warnings=$enableval],
253               [])
254 AC_SUBST(all_warnings)
256 AC_ARG_ENABLE([werror],
257               AC_HELP_STRING([--disable-werror],
258                              [do not build with -Werror]),
259               [enable_werror=$enableval],
260               [enable_werror=yes])
261 AC_SUBST(enable_werror)
263 AC_ARG_ENABLE([multi-arch],
264               AC_HELP_STRING([--enable-multi-arch],
265                              [enable single DSO with optimizations for multiple architectures]),
266               [multi_arch=$enableval],
267               [multi_arch=default])
269 AC_ARG_ENABLE([nss-crypt],
270               AC_HELP_STRING([--enable-nss-crypt],
271                              [enable libcrypt to use nss]),
272               [nss_crypt=$enableval],
273               [nss_crypt=no])
274 if test x$nss_crypt = xyes; then
275   nss_includes=-I$(nss-config --includedir 2>/dev/null)
276   if test $? -ne 0; then
277     AC_MSG_ERROR([cannot find include directory with nss-config])
278   fi
279   old_CFLAGS="$CFLAGS"
280   CFLAGS="$CFLAGS $nss_includes"
281   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
282 #include <hasht.h>
283 #include <nsslowhash.h>
284 void f (void) { NSSLOW_Init (); }])],
285              libc_cv_nss_crypt=yes,
286              AC_MSG_ERROR([
287 cannot find NSS headers with lowlevel hash function interfaces]))
288   old_LIBS="$LIBS"
289   LIBS="$LIBS -lfreebl3"
290   AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
291 #include <hasht.h>
292 #include <nsslowhash.h>],
293                                   [NSSLOW_Init();])],
294                  libc_cv_nss_crypt=yes,
295                  AC_MSG_ERROR([
296 cannot link program using lowlevel NSS hash functions]))
297   CFLAGS="$old_CFLAGS"
298   LIBS="$old_LIBS"
299 else
300   libc_cv_nss_crypt=no
302 AC_SUBST(libc_cv_nss_crypt)
305 AC_ARG_ENABLE([obsolete-rpc],
306               AC_HELP_STRING([--enable-obsolete-rpc],
307                              [build and install the obsolete RPC code for link-time usage]),
308               [link_obsolete_rpc=$enableval],
309               [link_obsolete_rpc=no])
310 AC_SUBST(link_obsolete_rpc)
312 if test "$link_obsolete_rpc" = yes; then
313   AC_DEFINE(LINK_OBSOLETE_RPC)
316 AC_ARG_ENABLE([systemtap],
317               [AS_HELP_STRING([--enable-systemtap],
318                [enable systemtap static probe points @<:@default=no@:>@])],
319               [systemtap=$enableval],
320               [systemtap=no])
321 if test "x$systemtap" != xno; then
322   AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
323   old_CFLAGS="$CFLAGS"
324   CFLAGS="-std=gnu99 $CFLAGS"
325   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
326 void foo (int i, void *p)
328   asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
329        :: STAP_PROBE_ASM_OPERANDS (2, i, p));
330 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
331   CFLAGS="$old_CFLAGS"])
332   if test $libc_cv_sdt = yes; then
333     AC_DEFINE([USE_STAP_PROBE])
334   elif test "x$systemtap" != xauto; then
335     AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
336   fi
339 AC_ARG_ENABLE([build-nscd],
340               [AS_HELP_STRING([--disable-build-nscd],
341                [disable building and installing the nscd daemon])],
342               [build_nscd=$enableval],
343               [build_nscd=default])
344 AC_SUBST(build_nscd)
346 # Note the use of $use_nscd is near the bottom of the file.
347 AC_ARG_ENABLE([nscd],
348               [AS_HELP_STRING([--disable-nscd],
349                [library functions will not contact the nscd daemon])],
350               [use_nscd=$enableval],
351               [use_nscd=yes])
353 AC_ARG_ENABLE([pt_chown],
354               [AS_HELP_STRING([--enable-pt_chown],
355                [Enable building and installing pt_chown])],
356               [build_pt_chown=$enableval],
357               [build_pt_chown=no])
358 AC_SUBST(build_pt_chown)
359 if test "$build_pt_chown" = yes; then
360   AC_DEFINE(HAVE_PT_CHOWN)
363 # We keep the original values in `$config_*' and never modify them, so we
364 # can write them unchanged into config.make.  Everything else uses
365 # $machine, $vendor, and $os, and changes them whenever convenient.
366 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
368 # Don't allow vendor == "unknown"
369 test "$config_vendor" = unknown && config_vendor=
370 config_os="`echo $config_os | sed 's/^unknown-//'`"
372 # Some configurations imply other options.
373 elf=yes
375 # The configure fragment of an add-on port can modify these to supplement
376 # or override the table in the case statement below.  No fragment should
377 # ever change the config_* variables, however.
378 machine=$config_machine
379 vendor=$config_vendor
380 os=$config_os
381 base_os=''
383 submachine=
384 AC_ARG_WITH([cpu],
385             AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
386             [dnl
387   case "$withval" in
388   yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
389   no) ;;
390   *) submachine="$withval" ;;
391   esac
394 dnl Let sysdeps/*/preconfigure act here, like they can in add-ons.
395 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
397 # An add-on can set this when it wants to disable the sanity check below.
398 libc_config_ok=no
400 dnl Having this here, though empty, makes sure that if add-ons' fragments
401 dnl do AC_CONFIG_SUBDIRS([some-dir]), which just sets $subdirs, then
402 dnl our AC_OUTPUT will actually use it.
403 AC_CONFIG_SUBDIRS()
405 case "$enable_add_ons" in
406 ''|no) add_ons= ;;
407 yes|'*')
408  add_ons=`cd $srcdir && ls -d 2> /dev/null */configure */sysdeps |
409           sed 's@/[[^/]]*$@@' | sort | uniq`
410          add_ons_automatic=yes
411          ;;
412 *) add_ons=`echo "$enable_add_ons" | sed 's/,/ /g'`
413        add_ons_automatic=no ;;
414 esac
416 configured_add_ons=
417 add_ons_sfx=
418 add_ons_pfx=
419 if test x"$add_ons" != x; then
420   for f in $add_ons; do
421     # Some sanity checks
422     case "$f" in
423     crypt)
424       AC_MSG_ERROR([
425 *** It seems that you're using an old \`crypt' add-on.  crypt is now
426 *** part of glibc and using the old add-on will not work with this
427 *** release.  Start again with fresh sources and without the old
428 *** \`crypt' add-on.])
429     ;;
430     localedata)
431       AC_MSG_ERROR([
432 *** It seems that you're using an old \`localedata' add-on.  localedata
433 *** is now part of glibc and using the old add-on will not work with
434 *** this release.  Start again with fresh sources and without the old
435 *** \`localedata' add-on.])
436     ;;
437     esac
438   done
440   # Now source each add-on's configure fragment.
441   # The fragments can use $srcdir/$libc_add_on to find themselves,
442   # and test $add_ons_automatic to see if they were explicitly requested.
443   # A fragment can clear (or even change) $libc_add_on to affect
444   # whether it goes into the list to be actually used in the build.
445   use_add_ons=
446   for libc_add_on in $add_ons; do
447     # Test whether such a directory really exists.
448     # It can be absolute, or relative to $srcdir, or relative to the build dir.
449     case "$libc_add_on" in
450     /*)
451       libc_add_on_srcdir=$libc_add_on
452       ;;
453     *)
454       test -d "$srcdir/$libc_add_on" || {
455         if test -d "$libc_add_on"; then
456           libc_add_on="`pwd`/$libc_add_on"
457         else
458           AC_MSG_ERROR(add-on directory \"$libc_add_on\" does not exist)
459         fi
460       }
461       libc_add_on_srcdir=$srcdir/$libc_add_on
462       ;;
463     esac
465     libc_add_on_frag=$libc_add_on_srcdir/configure
466     libc_add_on_canonical=
467     libc_add_on_config_subdirs=
468     if test -r "$libc_add_on_frag"; then
469       AC_MSG_NOTICE(running configure fragment for add-on $libc_add_on)
470       libc_add_on_canonical=unknown
471       libc_add_on_subdirs=
472       . "$libc_add_on_frag"
473       test -z "$libc_add_on" || {
474         configured_add_ons="$configured_add_ons $libc_add_on"
475         if test "x$libc_add_on_canonical" = xunknown; then
476           AC_MSG_ERROR(fragment must set \$libc_add_on_canonical)
477         fi
478         for d in $libc_add_on_subdirs; do
479           case "$libc_add_on" in
480           /*) subdir_srcdir="$libc_add_on" ;;
481           *) subdir_srcdir="\$(..)$libc_add_on" ;;
482           esac
483           case "$d" in
484           .)
485             d="${libc_add_on_canonical:-$libc_add_on}"
486             ;;
487           /*)
488             subdir_srcdir="$d"
489             ;;
490           *)
491             subdir_srcdir="$subdir_srcdir/$d"
492             ;;
493           esac
494           d=`echo "$d" | sed 's@/*$@@;s@^.*/@@'`
495           add_on_subdirs="$add_on_subdirs $d"
496           test "$subdir_srcdir" = "\$(..)$d" || config_vars="$config_vars
497 $d-srcdir = $subdir_srcdir"
498         done
499         for d in $libc_add_on_config_subdirs; do
500           case "$d" in
501           /*) AC_MSG_ERROR(dnl
502 fragment uses absolute path in \$libc_add_on_config_subdirs) ;;
503           esac
504           if test ! -d "$libc_add_on_srcdir/$d"; then
505             AC_MSG_ERROR(fragment wants to configure missing directory $d)
506           fi
507           case "$libc_add_on" in
508           /*) AC_MSG_ERROR(dnl
509 relative path required for add-on using \$libc_add_on_config_subdirs) ;;
510           esac
511           subdirs="$subdirs $libc_add_on/$d"
512         done
513       }
514     fi
515     if test -n "$libc_add_on"; then
516       LIBC_PRECONFIGURE([$libc_add_on_srcdir], [add-on $libc_add_on for])
517       use_add_ons="$use_add_ons $libc_add_on"
518       add_ons_pfx="$add_ons_pfx $libc_add_on/"
519       test -z "$libc_add_on_canonical" ||
520       add_ons_sfx="$add_ons_sfx /$libc_add_on_canonical"
521     fi
522   done
523   # Use echo to strip excess whitespace.
524   add_ons="`echo $use_add_ons`"
526 AC_SUBST(add_ons)
527 AC_SUBST(add_on_subdirs)
531 ### I put this here to prevent those annoying emails from people who cannot
532 ### read and try to compile glibc on unsupported platforms.  --drepper
534 ### By using the undocumented --enable-hacker-mode option for configure
535 ### one can skip this test to make the configuration not fail for unsupported
536 ### platforms.
538 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
539   case "$machine-$host_os" in
540   *-linux* | *-gnu*)
541     ;;
542   *)
543     echo "*** The GNU C library is currently not available for this platform."
544     echo "*** So far nobody cared to port it and if there is no volunteer it"
545     echo "*** might never happen.  So, if you have interest to see glibc on"
546     echo "*** this platform visit"
547     echo "***   http://www.gnu.org/software/libc/porting.html"
548     echo "*** and join the group of porters"
549     exit 1
550     ;;
551   esac
554 # Set base_machine if not set by a preconfigure fragment.
555 test -n "$base_machine" || base_machine=$machine
556 AC_SUBST(base_machine)
558 # For the multi-arch option we need support in the assembler & linker.
559 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
560                libc_cv_ld_gnu_indirect_function, [dnl
561 cat > conftest.S <<EOF
562 .type foo,%gnu_indirect_function
563 foo:
564 .globl _start
565 _start:
566 .globl __start
567 __start:
568 .data
569 #ifdef _LP64
570 .quad foo
571 #else
572 .long foo
573 #endif
575 libc_cv_ld_gnu_indirect_function=no
576 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
577             -nostartfiles -nostdlib \
578             -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
579   # Do a link to see if the backend supports IFUNC relocs.
580   $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
581   LC_ALL=C $READELF -r conftest | grep 'no relocations' >/dev/null || {
582     libc_cv_ld_gnu_indirect_function=yes
583   }
585 rm -f conftest*])
587 AC_MSG_CHECKING(whether .text pseudo-op must be used)
588 AC_CACHE_VAL(libc_cv_dot_text, [dnl
589 cat > conftest.s <<EOF
590 .text
592 libc_cv_dot_text=
593 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
594   libc_cv_dot_text=.text
596 rm -f conftest*])
597 if test -z "$libc_cv_dot_text"; then
598   AC_MSG_RESULT(no)
599 else
600   AC_MSG_RESULT(yes)
603 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
604   if test x"$multi_arch" = xyes; then
605     AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
606   else
607     multi_arch=no
608   fi
610 multi_arch_d=
611 if test x"$multi_arch" != xno; then
612   multi_arch_d=/multiarch
615 # Compute the list of sysdep directories for this configuration.
616 # This can take a while to compute.
617 sysdep_dir=$srcdir/sysdeps
618 AC_MSG_CHECKING(sysdep dirs)
619 dnl We need to use [ and ] for other purposes for a while now.
620 changequote(,)dnl
621 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
622 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
624 test "x$base_os" != x || case "$os" in
625 gnu*)
626   base_os=mach/hurd ;;
627 linux*)
628   base_os=unix/sysv ;;
629 esac
631 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
632 tail=$os
633 ostry=$os
634 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
635   ostry="$ostry /$o"
636   tail=$o
637 done
638 o=`echo $tail | sed 's/[0-9]*$//'`
639 if test $o != $tail; then
640   ostry="$ostry /$o"
642 # For linux-gnu, try linux-gnu, then linux.
643 o=`echo $tail | sed 's/-.*$//'`
644 if test $o != $tail; then
645   ostry="$ostry /$o"
648 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
649 base=
650 tail=$base_os
651 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
652   set $b
653   base="$base /$1"
654   tail="$2"
655 done
657 # For sparc/sparc32, try sparc/sparc32 and then sparc.
658 mach=
659 tail=$machine${submachine:+/$submachine}
660 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
661   set $m
662   # Prepend the machine's FPU directory unless --without-fp.
663   if test "$with_fp" = yes; then
664     maybe_fpu=/fpu
665   else
666     maybe_fpu=/nofpu
667   fi
668   # For each machine term, try it with and then without /multiarch.
669   for try_fpu in $maybe_fpu ''; do
670     for try_multi in $multi_arch_d ''; do
671       mach="$mach /$1$try_fpu$try_multi"
672     done
673   done
674   tail="$2"
675 done
677 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
678 changequote([,])dnl
680 # Find what sysdep directories exist.
681 sysnames_add_ons=
682 sysnames=
683 for b in $base ''; do
684   for m0 in $mach ''; do
685     for v in /$vendor ''; do
686       test "$v" = / && continue
687       for o in /$ostry ''; do
688         test "$o" = / && continue
689         for m in $mach ''; do
690           for d in $add_ons_pfx ''; do
691             for a in $add_ons_sfx ''; do
692               try_suffix="$m0$b$v$o$m"
693               if test -n "$try_suffix"; then
694                 try_srcdir="${srcdir}/"
695                 case "$d" in
696                 /*) try_srcdir= ;;
697                 esac
698                 try="${d}sysdeps$try_suffix$a"
699                 test -n "$enable_debug_configure" &&
700                 echo "$0 [DEBUG]: try $try" >&2
701                 if test -d "$try_srcdir$try"; then
702                   sysnames="$sysnames $try"
703                   { test -n "$o" || test -n "$b"; } && os_used=t
704                   { test -n "$m" || test -n "$m0"; } && machine_used=t
705                   case x${m0:-$m} in
706                   x*/$submachine) submachine_used=t ;;
707                   esac
708                   if test -n "$d"; then
709                     case "$sysnames_add_ons" in
710                     *" $d "*) ;;
711                     *|'') sysnames_add_ons="$sysnames_add_ons $d" ;;
712                     esac
713                   fi
714                 fi
715               fi
716             done
717           done
718         done
719       done
720     done
721   done
722 done
724 # If the assembler supports gnu_indirect_function symbol type and the
725 # architecture supports multi-arch, we enable multi-arch by default.
726 case $sysnames_add_ons$sysnames in
727 *"$multi_arch_d"*)
728   ;;
730   test x"$multi_arch" = xdefault && multi_arch=no
731   ;;
732 esac
733 if test x"$multi_arch" != xno; then
734   AC_DEFINE(USE_MULTIARCH)
736 AC_SUBST(multi_arch)
738 if test -z "$os_used" && test "$os" != none; then
739   AC_MSG_ERROR(Operating system $os is not supported.)
741 if test -z "$machine_used" && test "$machine" != none; then
742   AC_MSG_ERROR(The $machine is not supported.)
744 if test -z "$submachine_used" && test -n "$submachine"; then
745   AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
747 AC_SUBST(submachine)
749 # We have now validated the configuration.
751 # Expand the list of system names into a full list of directories
752 # from each element's parent name and Implies file (if present).
753 set $sysnames
754 names=
755 while test $# -gt 0; do
756   name=$1
757   shift
759   case " $names " in *" $name "*)
760     # Already in the list.
761     continue
762   esac
764   # Report each name as we discover it, so there is no long pause in output.
765   echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
767   name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
769   case $name in
770     /*) xsrcdir= ;;
771     *)  xsrcdir=$srcdir/ ;;
772   esac
773   test -n "$enable_debug_configure" &&
774   echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
776   for implies_file in Implies Implies-before Implies-after; do
777     implies_type=`echo $implies_file | sed s/-/_/`
778     eval ${implies_type}=
779     if test -f $xsrcdir$name/$implies_file; then
780       # Collect more names from the `Implies' file (removing comments).
781       implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
782       for x in $implied_candidate; do
783         found=no
784         if test -d $xsrcdir$name_base/$x; then
785           eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
786           found=yes
787         fi
788         for d in $add_ons_pfx ''; do
789           try="${d}sysdeps/$x"
790           case $d in
791            /*) try_srcdir= ;;
792            *) try_srcdir=$srcdir/ ;;
793           esac
794           test -n "$enable_debug_configure" &&
795            echo "[DEBUG]: $name $implies_file $x try($d) {$try_srcdir}$try" >&2
796           if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
797           then
798             eval "${implies_type}=\"\$${implies_type} \$try\""
799             found=yes
800             case "$sysnames_add_ons" in
801             *" $d "*) ;;
802             *|'') sysnames_add_ons="$sysnames_add_ons $d" ;;
803             esac
804           fi
805         done
806         if test $found = no; then
807           AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
808         fi
809       done
810     fi
811   done
813   # Add NAME to the list of names.
814   names="$names $name"
816   # Find the parent of NAME, using the empty string if it has none.
817 changequote(,)dnl
818   parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
819 changequote([,])dnl
821   test -n "$enable_debug_configure" &&
822     echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
823 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
825   # Add the names implied by NAME, and NAME's parent (if it has one), to
826   # the list of names to be processed (the argument list).  We prepend the
827   # implied names to the list and append the parent.  We want implied
828   # directories to come before further directories inferred from the
829   # configuration components; this ensures that for sysv4, unix/common
830   # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
831   # after sysv4).
832   sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
833   test -n "$sysnames" && set $sysnames
834 done
836 # Add the default directories.
837 default_sysnames="sysdeps/generic"
838 sysnames="$names $default_sysnames"
839 AC_SUBST(sysnames)
840 # The other names were emitted during the scan.
841 AC_MSG_RESULT($default_sysnames)
843 # Collect the list of add-ons that supply partial sysdeps trees.
844 sysdeps_add_ons=
845 for add_on in $add_ons; do
846   case "$add_on" in
847   /*) xsrcdir= ;;
848   *) xsrcdir="$srcdir/" ;;
849   esac
851   test -d "$xsrcdir$add_on/sysdeps" || {
852     case "$configured_add_ons " in
853     *" $add_on "*) ;;
854     *|'')
855       AC_MSG_ERROR(add-on $add_on has no configure fragment or sysdeps tree)
856       ;;
857     esac
858     continue
859   }
861   sysdeps_add_ons="$sysdeps_add_ons $add_on"
862   case "$sysnames_add_ons" in
863   *" $add_on/ "*) ;;
864   *|'')
865     AC_MSG_WARN(add-on $add_on contributed no sysdeps directories)
866     continue ;;
867   esac
869   found=no
870   for d in $sysnames; do
871     case "$d" in
872     $add_on/sysdeps/*) ;;
873     *) continue ;;
874     esac
875     (cd "$xsrcdir$d" && for f in *[[!~]]; do
876        case "$f" in
877        sys|bits)
878          for ff in $f/*.h; do
879            test -d "$ff" || { test -e "$ff" && exit 88; }
880          done
881          ;;
882        *)
883          test -d "$f" || { test -e "$f" && exit 88; }
884          ;;
885        esac
886      done)
887     if test $? -eq 88; then
888       found=yes
889       break
890     fi
891   done
892   if test $found = no; then
893     AC_MSG_WARN(add-on $add_on contributed no useful sysdeps directories)
894   fi
895 done
896 AC_SUBST(sysdeps_add_ons)
899 ### Locate tools.
901 AC_PROG_INSTALL
902 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
903   # The makefiles need to use a different form to find it in $srcdir.
904   INSTALL='\$(..)./scripts/install-sh -c'
906 AC_PROG_LN_S
908 LIBC_PROG_BINUTILS
910 # Accept binutils 2.22 or newer.
911 AC_CHECK_PROG_VER(AS, $AS, --version,
912                   [GNU assembler.* \([0-9]*\.[0-9.]*\)],
913                   [2.1[0-9][0-9]*|2.2[2-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
914                   AS=: critic_missing="$critic_missing as")
915 AC_CHECK_PROG_VER(LD, $LD, --version,
916                   [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
917                   [2.1[0-9][0-9]*|2.2[2-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
918                   LD=: critic_missing="$critic_missing ld")
920 # These programs are version sensitive.
921 AC_CHECK_TOOL_PREFIX
922 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
923   [GNU Make[^0-9]*\([0-9][0-9.]*\)],
924   [3.79* | 3.[89]* | [4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
926 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
927   [GNU gettext.* \([0-9]*\.[0-9.]*\)],
928   [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
929   MSGFMT=: aux_missing="$aux_missing msgfmt")
930 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
931   [GNU texinfo.* \([0-9][0-9.]*\)],
932   [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
933   MAKEINFO=: aux_missing="$aux_missing makeinfo")
934 AC_CHECK_PROG_VER(SED, sed, --version,
935   [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
936   [3.0[2-9]*|3.[1-9]*|[4-9]*],
937   SED=: aux_missing="$aux_missing sed")
938 AC_CHECK_PROG_VER(AWK, gawk, --version,
939   [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
940   [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
942 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
943 AC_TRY_COMPILE([], [
944 #if !defined __GNUC__ || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
945 #error insufficient compiler
946 #endif],
947                [libc_cv_compiler_ok=yes],
948                [libc_cv_compiler_ok=no])])
949 AS_IF([test $libc_cv_compiler_ok != yes],
950       [critic_missing="$critic_missing compiler"])
952 AC_CHECK_TOOL(NM, nm, false)
954 if test "x$maintainer" = "xyes"; then
955   AC_CHECK_PROGS(AUTOCONF, autoconf, no)
956   case "x$AUTOCONF" in
957   xno|x|x:) AUTOCONF=no ;;
958   *)
959     AC_CACHE_CHECK(dnl
960   whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
961     if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
962       libc_cv_autoconf_works=yes
963     else
964       libc_cv_autoconf_works=no
965     fi])
966     test $libc_cv_autoconf_works = yes || AUTOCONF=no
967     ;;
968   esac
969   if test "x$AUTOCONF" = xno; then
970     aux_missing="$aux_missing autoconf"
971   fi
972 else
973   AUTOCONF=no
976 test -n "$critic_missing" && AC_MSG_ERROR([
977 *** These critical programs are missing or too old:$critic_missing
978 *** Check the INSTALL file for required versions.])
980 test -n "$aux_missing" && AC_MSG_WARN([
981 *** These auxiliary programs are missing or incompatible versions:$aux_missing
982 *** some features will be disabled.
983 *** Check the INSTALL file for required versions.])
985 # if using special system headers, find out the compiler's sekrit
986 # header directory and add that to the list.  NOTE: Only does the right
987 # thing on a system that doesn't need fixincludes.  (Not presently a problem.)
988 if test -n "$sysheaders"; then
989   SYSINCLUDES=-nostdinc
990   for d in include include-fixed; do
991     i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
992     SYSINCLUDES="$SYSINCLUDES -isystem $i"
993   done
994   SYSINCLUDES="$SYSINCLUDES \
995 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
996   if test -n "$CXX"; then
997     CXX_SYSINCLUDES=
998     for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
999     | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1000       test "x$cxxheaders" != x &&
1001       CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1002     done
1003   fi
1005 AC_SUBST(SYSINCLUDES)
1006 AC_SUBST(CXX_SYSINCLUDES)
1008 # Test if LD_LIBRARY_PATH contains the notation for the current directory
1009 # since this would lead to problems installing/building glibc.
1010 # LD_LIBRARY_PATH contains the current directory if one of the following
1011 # is true:
1012 # - one of the terminals (":" and ";") is the first or last sign
1013 # - two terminals occur directly after each other
1014 # - the path contains an element with a dot in it
1015 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1016 changequote(,)dnl
1017 case ${LD_LIBRARY_PATH} in
1018   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1019     ld_library_path_setting="contains current directory"
1020     ;;
1021   *)
1022     ld_library_path_setting="ok"
1023     ;;
1024 esac
1025 changequote([,])dnl
1026 AC_MSG_RESULT($ld_library_path_setting)
1027 if test "$ld_library_path_setting" != "ok"; then
1028 AC_MSG_ERROR([
1029 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1030 *** building glibc. Please change the environment variable
1031 *** and run configure again.])
1034 AC_CACHE_CHECK(whether GCC supports -static-libgcc, libc_cv_gcc_static_libgcc, [dnl
1035 if $CC -v -static-libgcc 2>&1 | grep 'unrecognized option.*static-libgcc' >/dev/null; then
1036   libc_cv_gcc_static_libgcc=
1037 else
1038   libc_cv_gcc_static_libgcc=-static-libgcc
1039 fi])
1040 AC_SUBST(libc_cv_gcc_static_libgcc)
1042 AC_PATH_PROG(BASH_SHELL, bash, no)
1044 AC_PATH_PROG(PERL, perl, no)
1045 if test "$PERL" != no &&
1046    (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1047   PERL=no
1049 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1050              $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1051 AC_CHECK_PROG_VER(BISON, bison, --version,
1052                   [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
1053                   [2.7*|[3-9].*|[1-9][0-9]*],
1054                   BISON=no)
1056 AC_CACHE_CHECK(for libc-friendly stddef.h, libc_cv_friendly_stddef, [dnl
1057 AC_TRY_COMPILE(dnl
1058 [#define __need_size_t
1059 #define __need_wchar_t
1060 #include <stddef.h>
1061 #define __need_NULL
1062 #include <stddef.h>], [size_t size; wchar_t wchar;
1063 #ifdef offsetof
1064 #error stddef.h ignored __need_*
1065 #endif
1066 if (&size == NULL || &wchar == NULL) abort ();],
1067                libc_cv_friendly_stddef=yes,
1068                libc_cv_friendly_stddef=no)])
1069 if test $libc_cv_friendly_stddef = yes; then
1070   config_vars="$config_vars
1071 override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
1074 AC_CACHE_CHECK(whether we need to use -P to assemble .S files,
1075                libc_cv_need_minus_P, [dnl
1076 cat > conftest.S <<EOF
1077 #include "confdefs.h"
1078 /* Nothing whatsoever.  */
1080 if AC_TRY_COMMAND(${CC-cc} $CPPFLAGS $ASFLAGS -c conftest.S 1>&AS_MESSAGE_LOG_FD); then
1081   libc_cv_need_minus_P=no
1082 else
1083   libc_cv_need_minus_P=yes
1085 rm -f conftest*])
1086 if test $libc_cv_need_minus_P = yes; then
1087   config_vars="$config_vars
1088 asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
1091 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1092 cat > conftest.s <<EOF
1093 ${libc_cv_dot_text}
1094 foo:
1095 .set glibc_conftest_frobozz,foo
1096 .globl glibc_conftest_frobozz
1098 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1099 # (but it doesn't work), so we must do a linking check to be sure.
1100 cat > conftest1.c <<\EOF
1101 extern int glibc_conftest_frobozz;
1102 void _start() { glibc_conftest_frobozz = 1; }
1104 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1105             -nostartfiles -nostdlib \
1106             -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1107   libc_cv_asm_set_directive=yes
1108 else
1109   libc_cv_asm_set_directive=no
1111 rm -f conftest*])
1112 if test $libc_cv_asm_set_directive = yes; then
1113   AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1116 AC_CACHE_CHECK(for assembler gnu_unique_object symbol type,
1117                libc_cv_asm_unique_object, [dnl
1118 cat > conftest.s <<EOF
1119 ${libc_cv_dot_text}
1120 _sym:
1121 .type _sym, %gnu_unique_object
1123 if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1124   libc_cv_asm_unique_object=yes
1125 else
1126   libc_cv_asm_unique_object=no
1128 rm -f conftest*])
1129 if test $libc_cv_asm_unique_object = yes; then
1130   AC_DEFINE(HAVE_ASM_UNIQUE_OBJECT)
1133 AC_CACHE_CHECK(for .previous assembler directive,
1134                libc_cv_asm_previous_directive, [dnl
1135 cat > conftest.s <<EOF
1136 .section foo_section
1137 .previous
1139 if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1140   libc_cv_asm_previous_directive=yes
1141 else
1142   libc_cv_asm_previous_directive=no
1144 rm -f conftest*])
1145 if test $libc_cv_asm_previous_directive = yes; then
1146   AC_DEFINE(HAVE_ASM_PREVIOUS_DIRECTIVE)
1147 else
1148   AC_CACHE_CHECK(for .popsection assembler directive,
1149                  libc_cv_asm_popsection_directive, [dnl
1150   cat > conftest.s <<EOF
1151 .pushsection foo_section
1152 .popsection
1154   if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1155     libc_cv_asm_popsection_directive=yes
1156   else
1157     libc_cv_asm_popsection_directive=no
1158   fi
1159   rm -f conftest*])
1160   if test $libc_cv_asm_popsection_directive = yes; then
1161     AC_DEFINE(HAVE_ASM_POPSECTION_DIRECTIVE)
1162   fi
1164 AC_CACHE_CHECK(for .protected and .hidden assembler directive,
1165                libc_cv_asm_protected_directive, [dnl
1166 cat > conftest.s <<EOF
1167 .protected foo
1168 foo:
1169 .hidden bar
1170 bar:
1172 if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1173   libc_cv_asm_protected_directive=yes
1174 else
1175   AC_MSG_ERROR(assembler support for symbol visibility is required)
1177 rm -f conftest*])
1179 if test $libc_cv_asm_protected_directive = yes; then
1180   AC_CACHE_CHECK(whether __attribute__((visibility())) is supported,
1181                  libc_cv_visibility_attribute,
1182                  [cat > conftest.c <<EOF
1183                   int foo __attribute__ ((visibility ("hidden"))) = 1;
1184                   int bar __attribute__ ((visibility ("protected"))) = 1;
1186                   libc_cv_visibility_attribute=no
1187                   if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1188                     if grep '\.hidden.*foo' conftest.s >/dev/null; then
1189                       if grep '\.protected.*bar' conftest.s >/dev/null; then
1190                         libc_cv_visibility_attribute=yes
1191                       fi
1192                     fi
1193                   fi
1194                   rm -f conftest.{c,s}
1195                  ])
1196   if test $libc_cv_visibility_attribute != yes; then
1197     AC_MSG_ERROR(compiler support for visibility attribute is required)
1198   fi
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; }
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
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;
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)
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
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;
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])
1276 if test $libc_cv_initfini_array != yes; then
1277   AC_MSG_ERROR([Need linker with .init_array/.fini_array support.])
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 (""); }
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     ])
1306 if test $libc_cv_ctors_header = no; then
1307   AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
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; }
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)
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)])
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)])
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)])
1339 AC_CACHE_CHECK(for -Bgroup option,
1340                libc_cv_Bgroup, [dnl
1341 cat > conftest.c <<EOF
1342 int _start (void) { return 42; }
1344 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1345                             -fPIC -shared -o conftest.so conftest.c
1346                             -Wl,-Bgroup -nostdlib 1>&AS_MESSAGE_LOG_FD])
1347 then
1348   libc_cv_Bgroup=yes
1349 else
1350   libc_cv_Bgroup=no
1352 rm -f conftest*])
1353 AC_SUBST(libc_cv_Bgroup)
1355 ASFLAGS_config=
1356 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1357                libc_cv_as_noexecstack, [dnl
1358 cat > conftest.c <<EOF
1359 void foo (void) { }
1361 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1362                    -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1363    && grep .note.GNU-stack conftest.s >/dev/null \
1364    && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1365                       -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1366 then
1367   libc_cv_as_noexecstack=yes
1368 else
1369   libc_cv_as_noexecstack=no
1371 rm -f conftest*])
1372 if test $libc_cv_as_noexecstack = yes; then
1373   ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1375 AC_SUBST(ASFLAGS_config)
1377 AC_CACHE_CHECK(for -z combreloc,
1378                libc_cv_z_combreloc, [dnl
1379 cat > conftest.c <<EOF
1380 extern int bar (int);
1381 extern int mumble;
1382 int foo (void) { return bar (mumble); }
1384 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1385                         -fPIC -shared -o conftest.so conftest.c
1386                         -nostdlib -nostartfiles
1387                         -Wl,-z,combreloc 1>&AS_MESSAGE_LOG_FD])
1388 then
1389 dnl The following test is a bit weak.  We must use a tool which can test
1390 dnl cross-platform since the gcc used can be a cross compiler.  Without
1391 dnl introducing new options this is not easily doable.  Instead use a tool
1392 dnl which always is cross-platform: readelf.  To detect whether -z combreloc
1393 dnl look for a section named .rel.dyn.
1394   if $READELF -S conftest.so | grep '\.rel\(a\|\)\.dyn' > /dev/null; then
1395     libc_cv_z_combreloc=yes
1396   else
1397     libc_cv_z_combreloc=no
1398   fi
1399 else
1400   libc_cv_z_combreloc=no
1402 rm -f conftest*])
1403 if test "$libc_cv_z_combreloc" = yes; then
1404   AC_DEFINE(HAVE_Z_COMBRELOC)
1406 AC_SUBST(libc_cv_z_combreloc)
1408 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1409                     [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1410 AC_SUBST(libc_cv_z_execstack)
1412 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1413 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1416 AC_SUBST(libc_cv_fpie)
1418 AC_CACHE_CHECK(for --hash-style option,
1419                libc_cv_hashstyle, [dnl
1420 cat > conftest.c <<EOF
1421 int _start (void) { return 42; }
1423 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1424                             -fPIC -shared -o conftest.so conftest.c
1425                             -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
1426 then
1427   libc_cv_hashstyle=yes
1428 else
1429   libc_cv_hashstyle=no
1431 rm -f conftest*])
1432 AC_SUBST(libc_cv_hashstyle)
1434 # The linker's default -shared behavior is good enough if it
1435 # does these things that our custom linker scripts ensure that
1436 # all allocated NOTE sections come first.
1437 if test "$use_default_link" = default; then
1438   AC_CACHE_CHECK([for sufficient default -shared layout],
1439                   libc_cv_use_default_link, [dnl
1440   libc_cv_use_default_link=no
1441   cat > conftest.s <<\EOF
1442           .section .note.a,"a",%note
1443           .balign 4
1444           .long 4,4,9
1445           .string "GNU"
1446           .string "foo"
1447           .section .note.b,"a",%note
1448           .balign 4
1449           .long 4,4,9
1450           .string "GNU"
1451           .string "bar"
1453   if AC_TRY_COMMAND([dnl
1454   ${CC-cc} $ASFLAGS -shared -o conftest.so conftest.s 1>&AS_MESSAGE_LOG_FD]) &&
1455        ac_try=`$READELF -S conftest.so | sed -n \
1456          ['${x;p;}
1457           s/^ *\[ *[1-9][0-9]*\]  *\([^ ][^ ]*\)  *\([^ ][^ ]*\) .*$/\2 \1/
1458           t a
1459           b
1460           : a
1461           H']`
1462   then
1463     libc_seen_a=no libc_seen_b=no
1464     set -- $ac_try
1465     while test $# -ge 2 -a "$1" = NOTE; do
1466       case "$2" in
1467       .note.a) libc_seen_a=yes ;;
1468       .note.b) libc_seen_b=yes ;;
1469       esac
1470       shift 2
1471     done
1472     case "$libc_seen_a$libc_seen_b" in
1473     yesyes)
1474       libc_cv_use_default_link=yes
1475       ;;
1476     *)
1477       echo >&AS_MESSAGE_LOG_FD "\
1478 $libc_seen_a$libc_seen_b from:
1479 $ac_try"
1480       ;;
1481     esac
1482   fi
1483   rm -f conftest*])
1484   use_default_link=$libc_cv_use_default_link
1487 AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
1488 if libc_cv_output_format=`
1489 ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
1490 then
1491   :
1492 else
1493   libc_cv_output_format=
1495 test -n "$libc_cv_output_format" || libc_cv_output_format=unknown])
1496 AC_SUBST(libc_cv_output_format)
1498 AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
1499 cat > conftest.c <<EOF
1500 int foo;
1502 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
1503                             conftest.c 1>&AS_MESSAGE_LOG_FD])
1504 then
1505   libc_cv_fno_toplevel_reorder=yes
1506 else
1507   libc_cv_fno_toplevel_reorder=no
1509 rm -f conftest*])
1510 if test $libc_cv_fno_toplevel_reorder = yes; then
1511   fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
1512 else
1513   fno_unit_at_a_time=-fno-unit-at-a-time
1515 AC_SUBST(fno_unit_at_a_time)
1517 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
1518 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
1519                    [libc_cv_ssp=yes],
1520                    [libc_cv_ssp=no])
1522 AC_SUBST(libc_cv_ssp)
1524 AC_CACHE_CHECK(for -fgnu89-inline, libc_cv_gnu89_inline, [dnl
1525 cat > conftest.c <<EOF
1526 int foo;
1527 #ifdef __GNUC_GNU_INLINE__
1528 main () { return 0;}
1529 #else
1530 #error
1531 #endif
1533 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -std=gnu99 -fgnu89-inline
1534                             -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD])
1535 then
1536   libc_cv_gnu89_inline=yes
1537 else
1538   libc_cv_gnu89_inline=no
1540 rm -f conftest*])
1541 if test $libc_cv_gnu89_inline = yes; then
1542   gnu89_inline=-fgnu89-inline
1543 else
1544   gnu89_inline=
1546 AC_SUBST(gnu89_inline)
1548 AC_CACHE_CHECK(whether cc puts quotes around section names,
1549                libc_cv_have_section_quotes,
1550                [cat > conftest.c <<EOF
1551                 static const int foo
1552                 __attribute__ ((section ("bar"))) = 1;
1554                 if ${CC-cc} -S conftest.c -o conftest.s; then
1555                   if grep '\.section.*"bar"' conftest.s >/dev/null; then
1556                     libc_cv_have_section_quotes=yes
1557                   else
1558                     libc_cv_have_section_quotes=no
1559                   fi
1560                 else
1561                   libc_cv_have_section_quotes=unknown
1562                 fi
1563                 rm -f conftest.{c,s}
1564                 ])
1565 if test $libc_cv_have_section_quotes = yes; then
1566   AC_DEFINE(HAVE_SECTION_QUOTES)
1569 AC_CACHE_CHECK(for assembler .weak directive, libc_cv_asm_weak_directive,
1570                [dnl
1571 cat > conftest.s <<EOF
1572 ${libc_cv_dot_text}
1573 .globl foo
1574 foo:
1575 .weak foo
1576 .weak bar; bar = foo
1578 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1579   libc_cv_asm_weak_directive=yes
1580 else
1581   libc_cv_asm_weak_directive=no
1583 rm -f conftest*])
1585 if test $libc_cv_asm_weak_directive = no; then
1586   AC_CACHE_CHECK(for assembler .weakext directive,
1587                  libc_cv_asm_weakext_directive,
1588                  [dnl
1589 cat > conftest.s <<EOF
1590 ${libc_cv_dot_text}
1591 .globl foo
1592 foo:
1593 .weakext bar foo
1594 .weakext baz
1595 .globl baz
1596 baz:
1598   if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1599     libc_cv_asm_weakext_directive=yes
1600   else
1601     libc_cv_asm_weakext_directive=no
1602   fi
1603   rm -f conftest*])
1605 fi # no .weak
1607 if test $libc_cv_asm_weak_directive = yes; then
1608   AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE)
1609 elif test $libc_cv_asm_weakext_directive = yes; then
1610   AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
1613 AC_CACHE_CHECK(for ld --no-whole-archive, libc_cv_ld_no_whole_archive, [dnl
1614 cat > conftest.c <<\EOF
1615 _start () {}
1616 int __eh_pc;
1617 __throw () {}
1619 dnl No \ in command here because it ends up inside ''.
1620 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1621                             -nostdlib -nostartfiles -Wl,--no-whole-archive
1622                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
1623   libc_cv_ld_no_whole_archive=yes
1624 else
1625   libc_cv_ld_no_whole_archive=no
1627 rm -f conftest*])
1628 if test $libc_cv_ld_no_whole_archive = no; then
1629   AC_MSG_ERROR([support for --no-whole-archive is needed])
1632 AC_CACHE_CHECK(for gcc -fexceptions, libc_cv_gcc_exceptions, [dnl
1633 cat > conftest.c <<\EOF
1634 _start () {}
1635 int __eh_pc;
1636 __throw () {}
1638 dnl No \ in command here because it ends up inside ''.
1639 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1640                             -nostdlib -nostartfiles -fexceptions
1641                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
1642   libc_cv_gcc_exceptions=yes
1643 else
1644   libc_cv_gcc_exceptions=no
1646 rm -f conftest*])
1647 if test $libc_cv_gcc_exceptions = yes; then
1648   exceptions=-fexceptions
1650 AC_SUBST(exceptions)dnl
1652 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1653 cat > conftest.c <<\EOF
1654 void zero (void *x)
1656   __builtin_memset (x, 0, 1000);
1660 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "memset" > /dev/null]);
1661 then
1662   libc_cv_gcc_builtin_memset=no
1663 else
1664   libc_cv_gcc_builtin_memset=yes
1666 rm -f conftest* ])
1667 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1668   AC_DEFINE(HAVE_BUILTIN_MEMSET)
1671 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1672 cat > conftest.c <<\EOF
1673 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1674 char *foo (const char *a, const char *b)
1676   return __builtin_strstr (a, b);
1680 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "my_strstr" > /dev/null]);
1681 then
1682   libc_cv_gcc_builtin_redirection=yes
1683 else
1684   libc_cv_gcc_builtin_redirection=no
1686 rm -f conftest* ])
1687 if test "$libc_cv_gcc_builtin_redirection" = no; then
1688   AC_MSG_ERROR([support for the symbol redirection needed])
1691 dnl Check whether the compiler supports the __thread keyword.
1692 AC_CACHE_CHECK([for __thread], libc_cv_gcc___thread,
1693 [cat > conftest.c <<\EOF
1694 __thread int a = 42;
1696 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
1697   libc_cv_gcc___thread=yes
1698 else
1699   libc_cv_gcc___thread=no
1701 rm -f conftest*])
1702 if test "$libc_cv_gcc___thread" = no; then
1703   AC_MSG_ERROR([support for the __thread keyword is required])
1706 dnl Check whether the compiler supports the tls_model attribute.
1707 AC_CACHE_CHECK([for tls_model attribute], libc_cv_gcc_tls_model_attr, [dnl
1708 cat > conftest.c <<\EOF
1709 extern __thread int a __attribute__((tls_model ("initial-exec")));
1711 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -Werror conftest.c >&AS_MESSAGE_LOG_FD]); then
1712   libc_cv_gcc_tls_model_attr=yes
1713 else
1714   libc_cv_gcc_tls_model_attr=no
1716 rm -f conftest*])
1717 if test "$libc_cv_gcc_tls_model_attr" = no; then
1718   AC_MSG_ERROR([support for the tls_model attribute is required])
1721 dnl Determine how to disable generation of FMA instructions.
1722 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1723                libc_cv_cc_nofma, [dnl
1724 libc_cv_cc_nofma=
1725 for opt in -ffp-contract=off -mno-fused-madd; do
1726   LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1727 done])
1728 AC_SUBST(libc_cv_cc_nofma)
1730 if test -n "$submachine"; then
1731   AC_CACHE_CHECK([for compiler option for CPU variant],
1732                  libc_cv_cc_submachine, [dnl
1733   libc_cv_cc_submachine=no
1734   for opt in "-march=$submachine" "-mcpu=$submachine"; do
1735     LIBC_TRY_CC_OPTION([$opt], [
1736       libc_cv_cc_submachine="$opt"
1737       break], [])
1738   done])
1739   if test "x$libc_cv_cc_submachine" = xno; then
1740     AC_MSG_ERROR([${CC-cc} does not support $submachine])
1741   fi
1743 AC_SUBST(libc_cv_cc_submachine)
1745 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1746 __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1747 cat > conftest.c <<EOF
1748 void
1749 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1750 foo (void) {}
1752 libc_cv_cc_loop_to_function=no
1753 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
1754 then
1755   libc_cv_cc_loop_to_function=yes
1757 rm -f conftest*])
1758 if test $libc_cv_cc_loop_to_function = yes; then
1759   AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1761 AC_SUBST(libc_cv_cc_loop_to_function)
1763 dnl Check whether we have the gd library available.
1764 AC_MSG_CHECKING(for libgd)
1765 if test "$with_gd" != "no"; then
1766   old_CFLAGS="$CFLAGS"
1767   CFLAGS="$CFLAGS $libgd_include"
1768   old_LDFLAGS="$LDFLAGS"
1769   LDFLAGS="$LDFLAGS $libgd_ldflags"
1770   old_LIBS="$LIBS"
1771   LIBS="$LIBS -lgd -lpng -lz -lm"
1772   AC_TRY_LINK([#include <gd.h>], [gdImagePng (0, 0)], LIBGD=yes, LIBGD=no)
1773   CFLAGS="$old_CFLAGS"
1774   LDFLAGS="$old_LDFLAGS"
1775   LIBS="$old_LIBS"
1776 else
1777   LIBGD=no
1779 AC_MSG_RESULT($LIBGD)
1780 AC_SUBST(LIBGD)
1782 # SELinux detection
1783 if test x$with_selinux = xno ; then
1784   have_selinux=no;
1785 else
1786   # See if we have the SELinux library
1787   AC_CHECK_LIB(selinux, is_selinux_enabled,
1788                have_selinux=yes, have_selinux=no)
1789   if test x$with_selinux = xyes ; then
1790     if test x$have_selinux = xno ; then
1791       AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1792     fi
1793   fi
1795 # Check if we're building with SELinux support.
1796 if test "x$have_selinux" = xyes; then
1797   AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1799   # See if we have the libaudit library
1800   AC_CHECK_LIB(audit, audit_log_user_avc_message,
1801                have_libaudit=yes, have_libaudit=no)
1802   if test "x$have_libaudit" = xyes; then
1803     AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1804   fi
1805   AC_SUBST(have_libaudit)
1807   # See if we have the libcap library
1808   AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1809   if test "x$have_libcap" = xyes; then
1810     AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1811   fi
1812   AC_SUBST(have_libcap)
1814 AC_SUBST(have_selinux)
1816 dnl check for the size of 'long double'.
1817 AC_CHECK_SIZEOF(long double, 0)
1818 sizeof_long_double=$ac_cv_sizeof_long_double
1819 AC_SUBST(sizeof_long_double)
1821 CPPUNDEFS=
1822 dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE.
1823 dnl Since we are building the implementations of the fortified functions here,
1824 dnl having the macro defined interacts very badly.
1825 AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source,
1826 [AC_TRY_COMPILE([], [
1827 #ifdef _FORTIFY_SOURCE
1828 # error bogon
1829 #endif],
1830                 [libc_cv_predef_fortify_source=no],
1831                 [libc_cv_predef_fortify_source=yes])])
1832 if test $libc_cv_predef_fortify_source = yes; then
1833   CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
1835 AC_SUBST(CPPUNDEFS)
1837 dnl Check for silly hacked compilers inserting -fstack-protector.
1838 dnl This breaks badly for the early startup code we compile, since
1839 dnl the compiled code can refer to a magic machine-dependent location
1840 dnl for the canary value before we have sufficient setup for that to
1841 dnl work.  It's also questionable to build all of libc with this flag
1842 dnl even when you're doing that for most applications you build, since
1843 dnl libc's code is so heavily-used and performance-sensitive.  If we
1844 dnl ever really want to make that work, it should be enabled explicitly
1845 dnl in the libc build, not inherited from implicit compiler settings.
1846 AC_CACHE_CHECK([whether $CC implicitly enables -fstack-protector],
1847                libc_cv_predef_stack_protector, [
1848 AC_TRY_COMPILE([extern void foobar (char *);],
1849                [char large_array[2048]; foobar (large_array);], [
1850 libc_undefs=`$NM -u conftest.o |
1851   LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1852     2>&AS_MESSAGE_LOG_FD` || {
1853   AC_MSG_ERROR([confusing output from $NM -u])
1855 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1856 # On some architectures, there are architecture-specific undefined
1857 # symbols (resolved by the linker), so filter out unknown symbols.
1858 # This will fail to produce the correct result if the compiler
1859 # defaults to -fstack-protector but this produces an undefined symbol
1860 # other than __stack_chk_fail.  However, compilers like that have not
1861 # been encountered in practice.
1862 libc_undefs=`echo "$libc_undefs" | egrep '^(foobar|__stack_chk_fail)$'`
1863 case "$libc_undefs" in
1864 foobar) libc_cv_predef_stack_protector=no ;;
1865 '__stack_chk_fail
1866 foobar') libc_cv_predef_stack_protector=yes ;;
1867 *) AC_MSG_ERROR([unexpected symbols in test: $libc_undefs]) ;;
1868 esac],
1869                [AC_MSG_ERROR([test compilation failed])])
1871 libc_extra_cflags=
1872 if test $libc_cv_predef_stack_protector = yes; then
1873   libc_extra_cflags="$libc_extra_cflags -fno-stack-protector"
1875 libc_extra_cppflags=
1877 # Some linkers on some architectures support __ehdr_start but with
1878 # bugs.  Make sure usage of it does not create relocations in the
1879 # output (as the linker should resolve them all for us).
1880 AC_CACHE_CHECK([whether the linker provides working __ehdr_start],
1881                libc_cv_ehdr_start, [
1882 old_CFLAGS="$CFLAGS"
1883 old_LDFLAGS="$LDFLAGS"
1884 old_LIBS="$LIBS"
1885 CFLAGS="$CFLAGS -fPIC"
1886 LDFLAGS="$LDFLAGS -nostdlib -nostartfiles -shared"
1887 LIBS=
1888 AC_LINK_IFELSE([AC_LANG_SOURCE([
1889 typedef struct {
1890   char foo;
1891   long val;
1892 } Ehdr;
1893 extern const Ehdr __ehdr_start __attribute__ ((visibility ("hidden")));
1894 long ehdr (void) { return __ehdr_start.val; }
1895 ])],
1896                [if $READELF -r conftest | fgrep __ehdr_start >/dev/null; then
1897                   libc_cv_ehdr_start=broken
1898                 else
1899                   libc_cv_ehdr_start=yes
1900                 fi], [libc_cv_ehdr_start=no])
1901 CFLAGS="$old_CFLAGS"
1902 LDFLAGS="$old_LDFLAGS"
1903 LIBS="$old_LIBS"
1905 if test "$libc_cv_ehdr_start" = yes; then
1906   AC_DEFINE([HAVE_EHDR_START])
1907 elif test "$libc_cv_ehdr_start" = broken; then
1908   AC_MSG_WARN([linker is broken -- you should upgrade])
1911 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1912                libc_cv_builtin_trap, [dnl
1913 libc_cv_builtin_trap=no
1914 AC_TRY_COMPILE([], [__builtin_trap ()], [
1915 libc_undefs=`$NM -u conftest.o |
1916   LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1917     2>&AS_MESSAGE_LOG_FD` || {
1918   AC_MSG_ERROR([confusing output from $NM -u])
1920 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1921 if test -z "$libc_undefs"; then
1922   libc_cv_builtin_trap=yes
1923 fi])])
1924 if test $libc_cv_builtin_trap = yes; then
1925   AC_DEFINE([HAVE_BUILTIN_TRAP])
1928 ### End of automated tests.
1929 ### Now run sysdeps configure fragments.
1931 # They also can set these variables.
1932 use_ldconfig=no
1933 ldd_rewrite_script=no
1934 libc_cv_sysconfdir=$sysconfdir
1935 libc_cv_localstatedir=$localstatedir
1936 libc_cv_gcc_unwind_find_fde=no
1937 libc_cv_idn=no
1939 # Iterate over all the sysdep directories we will use, running their
1940 # configure fragments.
1941 for dir in $sysnames; do
1942   case $dir in
1943     /*) dest=$dir ;;
1944     *)  dest=$srcdir/$dir ;;
1945   esac
1946   if test -r $dest/configure; then
1947     AC_MSG_RESULT(running configure fragment for $dir)
1948     . $dest/configure
1949   fi
1950 done
1952 AC_SUBST(libc_extra_cflags)
1953 AC_SUBST(libc_extra_cppflags)
1955 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1956   AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1958 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1960 # A sysdeps configure fragment can reset this if IFUNC is not actually
1961 # usable even though the assembler knows how to generate the symbol type.
1962 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1963   AC_DEFINE(HAVE_IFUNC)
1966 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1967 # configure fragment can override the value to prevent this AC_DEFINE.
1968 AC_SUBST(use_nscd)
1969 if test "x$use_nscd" != xno; then
1970   AC_DEFINE([USE_NSCD])
1972 if test "x$build_nscd" = xdefault; then
1973   build_nscd=$use_nscd
1976 # Test for old glibc 2.0.x headers so that they can be removed properly
1977 # Search only in includedir.
1978 AC_MSG_CHECKING(for old glibc 2.0.x headers)
1979 if eval test -f "${includedir}/elfclass.h" -a -f "${includedir}/fcntlbits.h"
1980 then
1981   old_glibc_headers=yes
1982 else
1983   old_glibc_headers=no
1985 AC_MSG_RESULT($old_glibc_headers)
1986 if test ${old_glibc_headers} = yes; then
1987   AC_MSG_WARN(*** During \"make install\" old headers from glibc 2.0.x will)
1988   AC_MSG_WARN(*** be removed.)
1990 AC_SUBST(old_glibc_headers)
1992 AC_SUBST(libc_cv_slibdir)
1993 AC_SUBST(libc_cv_rtlddir)
1994 AC_SUBST(libc_cv_localedir)
1995 AC_SUBST(libc_cv_sysconfdir)
1996 AC_SUBST(libc_cv_localstatedir)
1997 AC_SUBST(libc_cv_rootsbindir)
1998 AC_SUBST(libc_cv_forced_unwind)
2000 if test x$use_ldconfig = xyes; then
2001   AC_DEFINE(USE_LDCONFIG)
2003 AC_SUBST(use_ldconfig)
2004 AC_SUBST(ldd_rewrite_script)
2006 AC_SUBST(static)
2007 AC_SUBST(shared)
2009 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
2010 [libc_cv_pic_default=yes
2011 cat > conftest.c <<EOF
2012 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
2013 # error PIC is default.
2014 #endif
2016 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
2017   libc_cv_pic_default=no
2019 rm -f conftest.*])
2020 AC_SUBST(libc_cv_pic_default)
2022 AC_SUBST(profile)
2023 AC_SUBST(static_nss)
2025 AC_SUBST(DEFINES)
2027 dnl See sysdeps/mach/configure.ac for this variable.
2028 AC_SUBST(mach_interface_list)
2030 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
2031 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
2032 AC_SUBST(VERSION)
2033 AC_SUBST(RELEASE)
2035 AC_CONFIG_FILES([config.make Makefile])
2036 AC_CONFIG_COMMANDS([default],[[
2037 case $CONFIG_FILES in *config.make*)
2038 echo "$config_vars" >> config.make;;
2039 esac
2040 test -d bits || mkdir bits]],[[config_vars='$config_vars']])
2041 AC_OUTPUT