Add flexibility to localplt-*.data files, using an awk script rather than diff to...
[glibc.git] / configure.in
blob442f8eb503c517b135dd88ca1df96600837638cd
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.53)dnl              dnl Minimum Autoconf version required.
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 dnl This is here so we can set $subdirs directly based on configure fragments.
9 AC_CONFIG_SUBDIRS()
11 AC_CANONICAL_HOST
13 AC_PROG_CC
14 if test $host != $build; then
15   AC_CHECK_PROGS(BUILD_CC, gcc cc)
17 AC_SUBST(cross_compiling)
18 AC_PROG_CPP
19 # We need the C++ compiler only for testing.
20 AC_PROG_CXX
22 if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
23   AC_MSG_ERROR([you must configure in a separate build directory])
26 # This will get text that should go into config.make.
27 config_vars=
29 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
30 AC_ARG_WITH([gd],
31             AC_HELP_STRING([--with-gd=DIR],
32                            [find libgd include dir and library with prefix DIR]),
33             [dnl
34 case "$with_gd" in
35 yes|''|no) ;;
36 *) libgd_include="-I$withval/include"
37    libgd_ldflags="-L$withval/lib" ;;
38 esac
40 AC_ARG_WITH([gd-include],
41             AC_HELP_STRING([--with-gd-include=DIR],
42                            [find libgd include files in DIR]),
43             [dnl
44 case "$with_gd_include" in
45 ''|no) ;;
46 *) libgd_include="-I$withval" ;;
47 esac
49 AC_ARG_WITH([gd-lib],
50             AC_HELP_STRING([--with-gd-lib=DIR],
51                            [find libgd library files in DIR]),
52             [dnl
53 case "$with_gd_lib" in
54 ''|no) ;;
55 *) libgd_ldflags="-L$withval" ;;
56 esac
59 if test -n "$libgd_include"; then
60   config_vars="$config_vars
61 CFLAGS-memusagestat.c = $libgd_include"
63 if test -n "$libgd_ldflags"; then
64   config_vars="$config_vars
65 libgd-LDFLAGS = $libgd_ldflags"
68 dnl Arguments to specify presence of other packages/features.
69 AC_ARG_WITH([fp],
70             AC_HELP_STRING([--with-fp],
71                            [if using floating-point hardware @<:@default=yes@:>@]),
72             [with_fp=$withval],
73             [with_fp=yes])
74 AC_SUBST(with_fp)
75 AC_ARG_WITH([binutils],
76             AC_HELP_STRING([--with-binutils=PATH],
77                            [specify location of binutils (as and ld)]),
78             [path_binutils=$withval],
79             [path_binutils=''])
80 AC_ARG_WITH([selinux],
81             AC_HELP_STRING([--with-selinux],
82                            [if building with SELinux support]),
83             [with_selinux=$withval],
84             [with_selinux=auto])
86 AC_ARG_WITH([headers],
87             AC_HELP_STRING([--with-headers=PATH],
88                            [location of system headers to use
89                             (for example /usr/src/linux/include)
90                             @<:@default=compiler default@:>@]),
91             [sysheaders=$withval],
92             [sysheaders=''])
94 AC_SUBST(use_default_link)
95 AC_ARG_WITH([default-link],
96             AC_HELP_STRING([--with-default-link],
97                            [do not use explicit linker scripts]),
98             [use_default_link=$withval],
99             [use_default_link=default])
101 AC_ARG_ENABLE([sanity-checks],
102               AC_HELP_STRING([--disable-sanity-checks],
103                              [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
104               [enable_sanity=$enableval],
105               [enable_sanity=yes])
107 AC_SUBST(enable_check_abi)
108 AC_ARG_ENABLE([check-abi],
109               AC_HELP_STRING([--enable-check-abi],
110                              [do "make check-abi" in "make check" (no/warn/yes)
111                               @<:@default=no@:>@]),
112               [enable_check_abi=$enableval],
113               [enable_check_abi=no])
115 AC_ARG_ENABLE([shared],
116               AC_HELP_STRING([--enable-shared],
117                              [build shared library @<:@default=yes if GNU ld@:>@]),
118               [shared=$enableval],
119               [shared=yes])
120 AC_ARG_ENABLE([profile],
121               AC_HELP_STRING([--enable-profile],
122                              [build profiled library @<:@default=no@:>@]),
123               [profile=$enableval],
124               [profile=no])
125 AC_ARG_ENABLE([versioning],
126               AC_HELP_STRING([--disable-versioning],
127                              [do not include versioning information in the library objects @<:@default=yes if supported@:>@]),
128               [enable_versioning=$enableval],
129               [enable_versioning=yes])
131 AC_ARG_ENABLE([oldest-abi],
132               AC_HELP_STRING([--enable-oldest-abi=ABI],
133                              [configure the oldest ABI supported @<:@e.g. 2.2@:>@ @<:@default=glibc default@:>@]),
134               [oldest_abi=$enableval],
135               [oldest_abi=no])
136 if test "$oldest_abi" = yes || test "$oldest_abi" = no; then
137   oldest_abi=default
138 else
139   AC_DEFINE_UNQUOTED(GLIBC_OLDEST_ABI, "$oldest_abi")
141 AC_SUBST(oldest_abi)
143 AC_ARG_ENABLE([stackguard-randomization],
144               AC_HELP_STRING([--enable-stackguard-randomization],
145                              [initialize __stack_chk_guard canary with a random number at program start]),
146               [enable_stackguard_randomize=$enableval],
147               [enable_stackguard_randomize=no])
148 if test "$enable_stackguard_randomize" = yes; then
149   AC_DEFINE(ENABLE_STACKGUARD_RANDOMIZE)
152 dnl Generic infrastructure for drop-in additions to libc.
153 AC_ARG_ENABLE([add-ons],
154               AC_HELP_STRING([--enable-add-ons@<:@=DIRS...@:>@],
155                              [configure and build add-ons in DIR1,DIR2,...
156                               search for add-ons if no parameter given]),
157                              , [enable_add_ons=yes])
159 AC_ARG_ENABLE([hidden-plt],
160               AC_HELP_STRING([--disable-hidden-plt],
161                              [do not hide internal function calls to avoid PLT]),
162               [hidden=$enableval],
163               [hidden=yes])
164 if test "x$hidden" = xno; then
165   AC_DEFINE(NO_HIDDEN)
168 AC_ARG_ENABLE([bind-now],
169               AC_HELP_STRING([--enable-bind-now],
170                              [disable lazy relocations in DSOs]),
171               [bindnow=$enableval],
172               [bindnow=no])
173 AC_SUBST(bindnow)
175 dnl On some platforms we cannot use dynamic loading.  We must provide
176 dnl static NSS modules.
177 AC_ARG_ENABLE([static-nss],
178               AC_HELP_STRING([--enable-static-nss],
179                              [build static NSS modules @<:@default=no@:>@]),
180               [static_nss=$enableval],
181               [static_nss=no])
182 dnl Enable static NSS also if we build no shared objects.
183 if test x"$static_nss" = xyes || test x"$shared" = xno; then
184   static_nss=yes
185   AC_DEFINE(DO_STATIC_NSS)
188 AC_ARG_ENABLE([force-install],
189               AC_HELP_STRING([--disable-force-install],
190                              [don't force installation of files from this package, even if they are older than the installed files]),
191               [force_install=$enableval],
192               [force_install=yes])
193 AC_SUBST(force_install)
195 dnl On some platforms we allow dropping compatibility with all kernel
196 dnl versions.
197 AC_ARG_ENABLE([kernel],
198               AC_HELP_STRING([--enable-kernel=VERSION],
199                              [compile for compatibility with kernel not older than VERSION]),
200               [minimum_kernel=$enableval],
201               [])
202 dnl Prevent unreasonable values.
203 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
204   # Better nothing than this.
205   minimum_kernel=""
206 else
207   if test "$minimum_kernel" = current; then
208     minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
209   fi
212 dnl For the development we sometimes want gcc to issue even more warnings.
213 dnl This is not the default since many of the extra warnings are not
214 dnl appropriate.
215 AC_ARG_ENABLE([all-warnings],
216               AC_HELP_STRING([--enable-all-warnings],
217                              [enable all useful warnings gcc can issue]),
218               [all_warnings=$enableval],
219               [])
220 AC_SUBST(all_warnings)
222 AC_ARG_ENABLE([multi-arch],
223               AC_HELP_STRING([--enable-multi-arch],
224                              [enable single DSO with optimizations for multiple architectures]),
225               [multi_arch=$enableval],
226               [multi_arch=default])
228 AC_ARG_ENABLE([nss-crypt],
229               AC_HELP_STRING([--enable-nss-crypt],
230                              [enable libcrypt to use nss]),
231               [nss_crypt=$enableval],
232               [nss_crypt=no])
233 if test x$nss_crypt = xyes; then
234   nss_includes=-I$(nss-config --includedir 2>/dev/null)
235   if test $? -ne 0; then
236     AC_MSG_ERROR([cannot find include directory with nss-config])
237   fi
238   old_CFLAGS="$CFLAGS"
239   CFLAGS="$CFLAGS $nss_includes"
240   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
241 #include <hasht.h>
242 #include <nsslowhash.h>
243 void f (void) { NSSLOW_Init (); }])],
244              libc_cv_nss_crypt=yes,
245              AC_MSG_ERROR([
246 cannot find NSS headers with lowlevel hash function interfaces]))
247   old_LIBS="$LIBS"
248   LIBS="$LIBS -lfreebl3"
249   AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
250 #include <hasht.h>
251 #include <nsslowhash.h>],
252                                   [NSSLOW_Init();])],
253                  libc_cv_nss_crypt=yes,
254                  AC_MSG_ERROR([
255 cannot link program using lowlevel NSS hash functions]))
256   CFLAGS="$old_CFLAGS"
257   LIBS="$old_LIBS"
258 else
259   libc_cv_nss_crypt=no
261 AC_SUBST(libc_cv_nss_crypt)
263 # The way shlib-versions is used to generate soversions.mk uses a
264 # fairly simplistic model for name recognition that can't distinguish
265 # i486-pc-linux-gnu fully from i486-pc-gnu.  So we mutate a $host_os
266 # of `gnu*' here to be `gnu-gnu*' just so that shlib-versions can
267 # tell.  This doesn't get used much beyond that, so it's fairly safe.
268 case "$host_os" in
269 linux*)
270   ;;
271 gnu*)
272   host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
273   ;;
274 esac
276 # We keep the original values in `$config_*' and never modify them, so we
277 # can write them unchanged into config.make.  Everything else uses
278 # $machine, $vendor, and $os, and changes them whenever convenient.
279 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
281 # Don't allow vendor == "unknown"
282 test "$config_vendor" = unknown && config_vendor=
283 config_os="`echo $config_os | sed 's/^unknown-//'`"
285 # Some configurations imply other options.
286 elf=yes
288 # The configure fragment of an add-on port can modify these to supplement
289 # or override the table in the case statement below.  No fragment should
290 # ever change the config_* variables, however.
291 machine=$config_machine
292 vendor=$config_vendor
293 os=$config_os
294 base_os=''
296 # config.guess on some IBM machines says `rs6000' instead of `powerpc'.
297 # Unify this here.
298 if test "$machine" = rs6000; then
299   machine="powerpc"
302 # Braindead PowerPC box with absolutely no FPU.
303 case "$machine-$host_os" in
304   powerpc*-*soft)
305     with_fp=no
306     ;;
307 esac
309 submachine=
310 AC_ARG_WITH([cpu],
311             AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
312             [dnl
313   case "$withval" in
314   yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
315   no) ;;
316   *) submachine="$withval" ;;
317   esac
320 dnl Let sysdeps/*/preconfigure act here, like they can in add-ons.
321 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
323 # An add-on can set this when it wants to disable the sanity check below.
324 libc_config_ok=no
326 dnl Having this here, though empty, makes sure that if add-ons' fragments
327 dnl do AC_CONFIG_SUBDIRS([some-dir]), which just sets $subdirs, then
328 dnl our AC_OUTPUT will actually use it.
329 AC_CONFIG_SUBDIRS()
331 case "$enable_add_ons" in
332 ''|no) add_ons= ;;
333 yes|'*')
334  add_ons=`cd $srcdir && ls -d 2> /dev/null */configure */sysdeps |
335           sed 's@/[[^/]]*$@@' | sort | uniq`
336          add_ons_automatic=yes
337          ;;
338 *) add_ons=`echo "$enable_add_ons" | sed 's/,/ /g'`
339        add_ons_automatic=no ;;
340 esac
342 configured_add_ons=
343 add_ons_sfx=
344 add_ons_pfx=
345 if test x"$add_ons" != x; then
346   for f in $add_ons; do
347     # Some sanity checks
348     case "$f" in
349     crypt)
350       AC_MSG_ERROR([
351 *** It seems that you're using an old \`crypt' add-on.  crypt is now
352 *** part of glibc and using the old add-on will not work with this
353 *** release.  Start again with fresh sources and without the old
354 *** \`crypt' add-on.])
355     ;;
356     localedata)
357       AC_MSG_ERROR([
358 *** It seems that you're using an old \`localedata' add-on.  localedata
359 *** is now part of glibc and using the old add-on will not work with
360 *** this release.  Start again with fresh sources and without the old
361 *** \`localedata' add-on.])
362     ;;
363     esac
364   done
366   # Now source each add-on's configure fragment.
367   # The fragments can use $srcdir/$libc_add_on to find themselves,
368   # and test $add_ons_automatic to see if they were explicitly requested.
369   # A fragment can clear (or even change) $libc_add_on to affect
370   # whether it goes into the list to be actually used in the build.
371   use_add_ons=
372   for libc_add_on in $add_ons; do
373     # Test whether such a directory really exists.
374     # It can be absolute, or relative to $srcdir, or relative to the build dir.
375     case "$libc_add_on" in
376     /*)
377       libc_add_on_srcdir=$libc_add_on
378       ;;
379     *)
380       test -d "$srcdir/$libc_add_on" || {
381         if test -d "$libc_add_on"; then
382           libc_add_on="`pwd`/$libc_add_on"
383         else
384           AC_MSG_ERROR(add-on directory \"$libc_add_on\" does not exist)
385         fi
386       }
387       libc_add_on_srcdir=$srcdir/$libc_add_on
388       ;;
389     esac
391     libc_add_on_frag=$libc_add_on_srcdir/configure
392     libc_add_on_canonical=
393     libc_add_on_config_subdirs=
394     if test -r "$libc_add_on_frag"; then
395       AC_MSG_NOTICE(running configure fragment for add-on $libc_add_on)
396       libc_add_on_canonical=unknown
397       libc_add_on_subdirs=
398       . "$libc_add_on_frag"
399       test -z "$libc_add_on" || {
400         configured_add_ons="$configured_add_ons $libc_add_on"
401         if test "x$libc_add_on_canonical" = xunknown; then
402           AC_MSG_ERROR(fragment must set \$libc_add_on_canonical)
403         fi
404         for d in $libc_add_on_subdirs; do
405           case "$libc_add_on" in
406           /*) subdir_srcdir="$libc_add_on" ;;
407           *) subdir_srcdir="\$(..)$libc_add_on" ;;
408           esac
409           case "$d" in
410           .)
411             d="${libc_add_on_canonical:-$libc_add_on}"
412             ;;
413           /*)
414             subdir_srcdir="$d"
415             ;;
416           *)
417             subdir_srcdir="$subdir_srcdir/$d"
418             ;;
419           esac
420           d=`echo "$d" | sed 's@/*$@@;s@^.*/@@'`
421           add_on_subdirs="$add_on_subdirs $d"
422           test "$subdir_srcdir" = "\$(..)$d" || config_vars="$config_vars
423 $d-srcdir = $subdir_srcdir"
424         done
425         for d in $libc_add_on_config_subdirs; do
426           case "$d" in
427           /*) AC_MSG_ERROR(dnl
428 fragment uses absolute path in \$libc_add_on_config_subdirs) ;;
429           esac
430           if test ! -d "$libc_add_on_srcdir/$d"; then
431             AC_MSG_ERROR(fragment wants to configure missing directory $d)
432           fi
433           case "$libc_add_on" in
434           /*) AC_MSG_ERROR(dnl
435 relative path required for add-on using \$libc_add_on_config_subdirs) ;;
436           esac
437           subdirs="$subdirs $libc_add_on/$d"
438         done
439       }
440     fi
441     if test -n "$libc_add_on"; then
442       LIBC_PRECONFIGURE([$libc_add_on_srcdir], [add-on $libc_add_on for])
443       use_add_ons="$use_add_ons $libc_add_on"
444       add_ons_pfx="$add_ons_pfx $libc_add_on/"
445       test -z "$libc_add_on_canonical" ||
446       add_ons_sfx="$add_ons_sfx /$libc_add_on_canonical"
447     fi
448   done
449   # Use echo to strip excess whitespace.
450   add_ons="`echo $use_add_ons`"
452 AC_SUBST(add_ons)
453 AC_SUBST(add_on_subdirs)
457 ### I put this here to prevent those annoying emails from people who cannot
458 ### read and try to compile glibc on unsupported platforms.  --drepper
460 ### By using the undocumented --enable-hacker-mode option for configure
461 ### one can skip this test to make the configuration not fail for unsupported
462 ### platforms.
464 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
465   case "$machine-$host_os" in
466   *-linux* | *-gnu* | arm*-none*)
467     ;;
468   *)
469     echo "*** The GNU C library is currently not available for this platform."
470     echo "*** So far nobody cared to port it and if there is no volunteer it"
471     echo "*** might never happen.  So, if you have interest to see glibc on"
472     echo "*** this platform visit"
473     echo "***   http://www.gnu.org/software/libc/porting.html"
474     echo "*** and join the group of porters"
475     exit 1
476     ;;
477   esac
480 dnl We need to use [ and ] for other purposes for a while now.
481 changequote(,)dnl
482 # Expand the configuration machine name into a subdirectory by architecture
483 # type and particular chip.  If an add-on configure fragment already set
484 # base_machine, we don't change it.
485 test -n "$base_machine" || case "$machine" in
486 i[34567]86)     base_machine=i386 machine=i386/$machine ;;
487 powerpc)        base_machine=powerpc machine=powerpc/powerpc32 ;;
488 powerpc64)      base_machine=powerpc machine=powerpc/powerpc64 ;;
489 s390)           base_machine=s390 machine=s390/s390-32 ;;
490 s390x)          base_machine=s390 machine=s390/s390-64 ;;
491 sh3*)           base_machine=sh machine=sh/sh3 ;;
492 sh4*)           base_machine=sh machine=sh/sh4 ;;
493 sparc | sparcv[67])
494                 base_machine=sparc machine=sparc/sparc32 ;;
495 sparcv8 | supersparc | hypersparc)
496                 base_machine=sparc machine=sparc/sparc32/sparcv8 ;;
497 sparcv8plus | sparcv8plusa | sparcv9)
498                 base_machine=sparc machine=sparc/sparc32/sparcv9 ;;
499 sparcv8plusb | sparcv9b)
500                 base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9b ;;
501 sparcv9v)
502                 base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9v ;;
503 sparcv9v2)
504                 base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9v2 ;;
505 sparc64)
506                 base_machine=sparc machine=sparc/sparc64 ;;
507 sparc64b)
508                 base_machine=sparc machine=sparc/sparc64/sparcv9b ;;
509 sparc64v)
510                 base_machine=sparc machine=sparc/sparc64/sparcv9v ;;
511 sparc64v2)
512                 base_machine=sparc machine=sparc/sparc64/sparcv9v2 ;;
513 *)              base_machine=$machine ;;
514 esac
515 changequote([,])dnl
516 AC_SUBST(base_machine)
518 if test "$base_machine" = "i386"; then
519   AC_DEFINE(USE_REGPARMS)
522 # For the multi-arch option we need support in the assembler.
523 AC_CACHE_CHECK([for assembler gnu_indirect_function symbol type support],
524                libc_cv_asm_gnu_indirect_function, [dnl
525 cat > conftest.s <<EOF
526 .type foo,%gnu_indirect_function
528 if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD;
529 then
530   libc_cv_asm_gnu_indirect_function=yes
531 else
532   libc_cv_asm_gnu_indirect_function=no
534 rm -f conftest*])
536 AC_MSG_CHECKING(whether .text pseudo-op must be used)
537 AC_CACHE_VAL(libc_cv_dot_text, [dnl
538 cat > conftest.s <<EOF
539 .text
541 libc_cv_dot_text=
542 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
543   libc_cv_dot_text=.text
545 rm -f conftest*])
546 if test -z "$libc_cv_dot_text"; then
547   AC_MSG_RESULT(no)
548 else
549   AC_MSG_RESULT(yes)
552 AC_CACHE_CHECK(for assembler global-symbol directive,
553                libc_cv_asm_global_directive, [dnl
554 libc_cv_asm_global_directive=UNKNOWN
555 for ac_globl in .globl .global .EXPORT; do
556   cat > conftest.s <<EOF
557         ${libc_cv_dot_text}
558         ${ac_globl} foo
559 foo:
561   if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
562     libc_cv_asm_global_directive=${ac_globl}
563   fi
564   rm -f conftest*
565   test $libc_cv_asm_global_directive != UNKNOWN && break
566 done])
567 if test $libc_cv_asm_global_directive = UNKNOWN; then
568   AC_MSG_ERROR(cannot determine asm global directive)
569 else
570   AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${libc_cv_asm_global_directive})
573 AC_CACHE_CHECK(for assembler .type directive prefix,
574                libc_cv_asm_type_prefix, [dnl
575 libc_cv_asm_type_prefix=no
576 for ac_try_prefix in '@' '%' '#'; do
577   cat > conftest.s <<EOF
578         ${libc_cv_dot_text}
579         ${libc_cv_asm_global_directive} foo
580         .type foo, ${ac_try_prefix}object
581         .size foo, 1
582 foo:
583         .byte 1
585   if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
586     libc_cv_asm_type_prefix=${ac_try_prefix}
587   fi
588   rm -f conftest*
589   test "x$libc_cv_asm_type_prefix" != xno && break
590 done])
591 if test "x$libc_cv_asm_type_prefix" != xno; then
592   AC_DEFINE_UNQUOTED(ASM_TYPE_DIRECTIVE_PREFIX, ${libc_cv_asm_type_prefix})
595 if test x"$libc_cv_asm_gnu_indirect_function" != xyes -o x"$libc_cv_asm_type_prefix" = xno; then
596   if test x"$multi_arch" = xyes; then
597     AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
598   else
599     multi_arch=no
600   fi
602 if test x"$multi_arch" != xno; then
603   multi_arch_d=/multiarch
606 # Compute the list of sysdep directories for this configuration.
607 # This can take a while to compute.
608 sysdep_dir=$srcdir/sysdeps
609 AC_MSG_CHECKING(sysdep dirs)
610 dnl We need to use [ and ] for other purposes for a while now.
611 changequote(,)dnl
612 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
613 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
615 test "x$base_os" != x || case "$os" in
616 gnu*)
617   base_os=mach/hurd ;;
618 netbsd* | 386bsd* | freebsd* | bsdi*)
619   base_os=unix/bsd/bsd4.4 ;;
620 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
621   base_os=unix/bsd ;;
622 sysv* | isc* | esix* | sco* | minix* | irix4* | linux*)
623   base_os=unix/sysv ;;
624 irix6*)
625   base_os=unix/sysv/irix6/$os ;;
626 solaris[2-9]*)
627   base_os=unix/sysv/sysv4 ;;
628 none)
629   base_os=standalone ;;
630 esac
632 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
633 tail=$os
634 ostry=$os
635 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
636   ostry="$ostry /$o"
637   tail=$o
638 done
639 o=`echo $tail | sed 's/[0-9]*$//'`
640 if test $o != $tail; then
641   ostry="$ostry /$o"
643 # For linux-gnu, try linux-gnu, then linux.
644 o=`echo $tail | sed 's/-.*$//'`
645 if test $o != $tail; then
646   ostry="$ostry /$o"
649 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
650 base=
651 tail=$base_os
652 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
653   set $b
654   base="$base /$1"
655   tail="$2"
656 done
658 # For sparc/sparc32, try sparc/sparc32 and then sparc.
659 mach=
660 tail=$machine${submachine:+/$submachine}
661 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
662   set $m
663   # Prepend the machine's FPU directory unless --without-fp.
664   if test "$with_fp" = yes; then
665     mach="$mach /$1/fpu"
666   else
667     mach="$mach /$1/nofpu"
668   fi
669   mach="$mach /$1"
670   tail="$2"
671 done
673 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
674 changequote([,])dnl
676 # Find what sysdep directories exist.
677 sysnames_add_ons=
678 sysnames=
679 for b in $base ''; do
680   for m0 in $mach ''; do
681     for v in /$vendor ''; do
682       test "$v" = / && continue
683       for o in /$ostry ''; do
684         test "$o" = / && continue
685         for m in $multi_arch_d $mach ''; do
686           for d in $add_ons_pfx ''; do
687             for a in $add_ons_sfx ''; do
688               if test -n "$m0$m0sub$b$v$o$m$msub"; then
689                 try_srcdir="${srcdir}/"
690                 case "$d" in
691                 /*) try_srcdir= ;;
692                 esac
693                 try="${d}sysdeps$m0$m0sub$b$v$o$m$msub$a"
694                 test -n "$enable_debug_configure" &&
695                 echo "$0 [DEBUG]: try $try" >&2
696                 if test -d "$try_srcdir$try"; then
697                   sysnames="$sysnames $try"
698                   { test -n "$o" || test -n "$b"; } && os_used=t
699                   { test -n "$m" || test -n "$m0"; } && machine_used=t
700                   case x${m0:-$m} in
701                   x*/$submachine) submachine_used=t ;;
702                   esac
703                   if test -n "$d"; then
704                     case "$sysnames_add_ons" in
705                     *" $d "*) ;;
706                     *|'') sysnames_add_ons="$sysnames_add_ons $d" ;;
707                     esac
708                   fi
709                 fi
710               fi
711             done
712           done
713         done
714       done
715     done
716   done
717 done
719 # If the assembler supports gnu_indirect_function symbol type and the
720 # architecture supports multi-arch, we enable multi-arch by default.
721 case $sysnames_add_ons$sysnames in
722 *"$multi_arch_d"*)
723   ;;
725   test x"$multi_arch" = xdefault && multi_arch=no
726   ;;
727 esac
728 if test x"$multi_arch" != xno; then
729   AC_DEFINE(USE_MULTIARCH)
731 AC_SUBST(multi_arch)
733 if test -z "$os_used" && test "$os" != none; then
734   AC_MSG_ERROR(Operating system $os is not supported.)
736 if test -z "$machine_used" && test "$machine" != none; then
737   AC_MSG_ERROR(The $machine is not supported.)
739 if test -z "$submachine_used" && test -n "$submachine"; then
740   AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
742 AC_SUBST(submachine)
744 # We have now validated the configuration.
746 # Expand the list of system names into a full list of directories
747 # from each element's parent name and Implies file (if present).
748 set $sysnames
749 names=
750 while test $# -gt 0; do
751   name=$1
752   shift
754   case " $names " in *" $name "*)
755     # Already in the list.
756     continue
757   esac
759   # Report each name as we discover it, so there is no long pause in output.
760   echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
762   name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
764   case $name in
765     /*) xsrcdir= ;;
766     *)  xsrcdir=$srcdir/ ;;
767   esac
768   test -n "$enable_debug_configure" &&
769   echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
771   if test -f $xsrcdir$name/Implies; then
772     # Collect more names from the `Implies' file (removing comments).
773     implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/Implies`"
774     implied=
775     for x in $implied_candidate; do
776       found=no
777       if test -d $xsrcdir$name_base/$x; then
778         implied="$implied $name_base/$x";
779         found=yes
780       fi
781       for d in $add_ons_pfx ''; do
782         try="${d}sysdeps/$x"
783         case $d in
784          /*) try_srcdir= ;;
785          *) try_srcdir=$srcdir/ ;;
786         esac
787         test -n "$enable_debug_configure" &&
788          echo "[DEBUG]: $name implied $x try($d) {$try_srcdir}$try" >&2
789         if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
790         then
791           implied="$implied $try"
792           found=yes
793           case "$sysnames_add_ons" in
794           *" $d "*) ;;
795           *|'') sysnames_add_ons="$sysnames_add_ons $d" ;;
796           esac
797         fi
798       done
799       if test $found = no; then
800         AC_MSG_WARN($name/Implies specifies nonexistent $x)
801       fi
802     done
803   else
804     implied=
805   fi
807   # Add NAME to the list of names.
808   names="$names $name"
810   # Find the parent of NAME, using the empty string if it has none.
811 changequote(,)dnl
812   parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
813 changequote([,])dnl
815   # Add the names implied by NAME, and NAME's parent (if it has one), to
816   # the list of names to be processed (the argument list).  We prepend the
817   # implied names to the list and append the parent.  We want implied
818   # directories to come before further directories inferred from the
819   # configuration components; this ensures that for sysv4, unix/common
820   # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
821   # after sysv4).
822   sysnames="`echo $implied $* $parent`"
823   test -n "$sysnames" && set $sysnames
824 done
826 # Add the default directories.
827 default_sysnames="sysdeps/generic"
828 sysnames="$names $default_sysnames"
829 AC_SUBST(sysnames)
830 # The other names were emitted during the scan.
831 AC_MSG_RESULT($default_sysnames)
833 # Collect the list of add-ons that supply partial sysdeps trees.
834 sysdeps_add_ons=
835 for add_on in $add_ons; do
836   case "$add_on" in
837   /*) xsrcdir= ;;
838   *) xsrcdir="$srcdir/" ;;
839   esac
841   test -d "$xsrcdir$add_on/sysdeps" || {
842     case "$configured_add_ons " in
843     *" $add_on "*) ;;
844     *|'')
845       AC_MSG_ERROR(add-on $add_on has no configure fragment or sysdeps tree)
846       ;;
847     esac
848     continue
849   }
851   sysdeps_add_ons="$sysdeps_add_ons $add_on"
852   case "$sysnames_add_ons" in
853   *" $add_on/ "*) ;;
854   *|'')
855     AC_MSG_WARN(add-on $add_on contributed no sysdeps directories)
856     continue ;;
857   esac
859   found=no
860   for d in $sysnames; do
861     case "$d" in
862     $add_on/sysdeps/*) ;;
863     *) continue ;;
864     esac
865     (cd "$xsrcdir$d" && for f in *[[!~]]; do
866        case "$f" in
867        sys|bits)
868          for ff in $f/*.h; do
869            test -d "$ff" || { test -e "$ff" && exit 88; }
870          done
871          ;;
872        *)
873          test -d "$f" || { test -e "$f" && exit 88; }
874          ;;
875        esac
876      done)
877     if test $? -eq 88; then
878       found=yes
879       break
880     fi
881   done
882   if test $found = no; then
883     AC_MSG_WARN(add-on $add_on contributed no useful sysdeps directories)
884   fi
885 done
886 AC_SUBST(sysdeps_add_ons)
889 ### Locate tools.
891 AC_PROG_INSTALL
892 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
893   # The makefiles need to use a different form to find it in $srcdir.
894   INSTALL='\$(..)./scripts/install-sh -c'
896 AC_PROG_LN_S
898 LIBC_PROG_BINUTILS
899 AC_SUBST(MIG)dnl Needed by sysdeps/mach/configure.in
901 # Accept binutils 2.20 or newer.
902 AC_CHECK_PROG_VER(AS, $AS, --version,
903                   [GNU assembler.* \([0-9]*\.[0-9.]*\)],
904                   [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*], AS=: critic_missing="$critic_missing as")
905 AC_CHECK_PROG_VER(LD, $LD, --version,
906                   [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
907                   [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*], LD=: critic_missing="$critic_missing ld")
909 # These programs are version sensitive.
910 AC_CHECK_TOOL_PREFIX
911 AC_CHECK_PROG_VER(CC, ${ac_tool_prefix}gcc ${ac_tool_prefix}cc, -v,
912   [version \([egcygnustpi-]*[0-9.]*\)], [4.[3-9].* | 4.[1-9][0-9].* | [5-9].* ],
913   critic_missing="$critic_missing gcc")
914 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
915   [GNU Make[^0-9]*\([0-9][0-9.]*\)],
916   [3.79* | 3.[89]*], critic_missing="$critic_missing make")
918 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
919   [GNU gettext.* \([0-9]*\.[0-9.]*\)],
920   [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
921   MSGFMT=: aux_missing="$aux_missing msgfmt")
922 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
923   [GNU texinfo.* \([0-9][0-9.]*\)],
924   [4.*],
925   MAKEINFO=: aux_missing="$aux_missing makeinfo")
926 AC_CHECK_PROG_VER(SED, sed, --version,
927   [GNU sed version \([0-9]*\.[0-9.]*\)],
928   [3.0[2-9]*|3.[1-9]*|[4-9]*],
929   SED=: aux_missing="$aux_missing sed")
931 AC_CHECK_TOOL(READELF, readelf, false)
933 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
934 case "x$AUTOCONF" in
935 xno|x|x:) AUTOCONF=no ;;
937   AC_CACHE_CHECK(dnl
938 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
939   if (cd $srcdir; $AUTOCONF $ACFLAGS configure.in > /dev/null 2>&1); then
940     libc_cv_autoconf_works=yes
941   else
942     libc_cv_autoconf_works=no
943   fi])
944   test $libc_cv_autoconf_works = yes || AUTOCONF=no
945   ;;
946 esac
947 if test "x$AUTOCONF" = xno; then
948   aux_missing="$aux_missing autoconf"
951 test -n "$critic_missing" && AC_MSG_ERROR([
952 *** These critical programs are missing or too old:$critic_missing
953 *** Check the INSTALL file for required versions.])
955 test -n "$aux_missing" && AC_MSG_WARN([
956 *** These auxiliary programs are missing or incompatible versions:$aux_missing
957 *** some features will be disabled.
958 *** Check the INSTALL file for required versions.])
960 # if using special system headers, find out the compiler's sekrit
961 # header directory and add that to the list.  NOTE: Only does the right
962 # thing on a system that doesn't need fixincludes.  (Not presently a problem.)
963 if test -n "$sysheaders"; then
964   SYSINCLUDES=-nostdinc
965   for d in include include-fixed; do
966     i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
967     SYSINCLUDES="$SYSINCLUDES -isystem $i"
968   done
969   SYSINCLUDES="$SYSINCLUDES \
970 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
971   if test -n "$CXX"; then
972     CXX_SYSINCLUDES=
973     cxxversion=`$CXX -dumpversion 2>&AS_MESSAGE_LOG_FD` &&
974     cxxmachine=`$CXX -dumpmachine 2>&AS_MESSAGE_LOG_FD` &&
975     for d in include "$cxxmachine/include"; do
976       i=../../../../$d/c++/$cxxversion
977       cxxheaders=`$CXX -print-file-name="$i"` &&
978       test "x$cxxheaders" != x && test "x$i" != "x$cxxheaders" &&
979       CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders \
980 -isystem $cxxheaders/$cxxmachine -isystem $cxxheaders/backward"
981     done
982   fi
984 AC_SUBST(SYSINCLUDES)
985 AC_SUBST(CXX_SYSINCLUDES)
987 # Test if LD_LIBRARY_PATH contains the notation for the current directory
988 # since this would lead to problems installing/building glibc.
989 # LD_LIBRARY_PATH contains the current directory if one of the following
990 # is true:
991 # - one of the terminals (":" and ";") is the first or last sign
992 # - two terminals occur directly after each other
993 # - the path contains an element with a dot in it
994 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
995 changequote(,)dnl
996 case ${LD_LIBRARY_PATH} in
997   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
998     ld_library_path_setting="contains current directory"
999     ;;
1000   *)
1001     ld_library_path_setting="ok"
1002     ;;
1003 esac
1004 changequote([,])dnl
1005 AC_MSG_RESULT($ld_library_path_setting)
1006 if test "$ld_library_path_setting" != "ok"; then
1007 AC_MSG_ERROR([
1008 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1009 *** building glibc. Please change the environment variable
1010 *** and run configure again.])
1013 AC_CACHE_CHECK(whether GCC supports -static-libgcc, libc_cv_gcc_static_libgcc, [dnl
1014 if $CC -v -static-libgcc 2>&1 | grep -q 'unrecognized option.*static-libgcc'; then
1015   libc_cv_gcc_static_libgcc=
1016 else
1017   libc_cv_gcc_static_libgcc=-static-libgcc
1018 fi])
1019 AC_SUBST(libc_cv_gcc_static_libgcc)
1021 AC_PATH_PROG(BASH_SHELL, bash, no)
1022 if test "$BASH_SHELL" != no &&
1023    $BASH_SHELL -c 'test "$BASH_VERSINFO" \
1024              && test "$BASH_VERSINFO" -ge 2 >&/dev/null'; then
1025   libc_cv_have_bash2=yes
1026 else
1027   libc_cv_have_bash2=no
1029 AC_SUBST(libc_cv_have_bash2)
1031 dnl We need a ksh compatible shell for tzselect.
1032 if test "$BASH_SHELL" = no; then
1033   AC_PATH_PROG(KSH, ksh, no)
1034   if test "$KSH" = no; then
1035     libc_cv_have_ksh=no
1036   else
1037     libc_cv_have_ksh=yes
1038   fi
1039 else
1040   KSH="$BASH_SHELL"
1041   AC_SUBST(KSH)
1042   libc_cv_have_ksh=yes
1044 AC_SUBST(libc_cv_have_ksh)
1046 AC_PROG_AWK
1047 AC_PATH_PROG(PERL, perl, no)
1048 if test "$PERL" != no &&
1049    (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1050   PERL=no
1052 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1053              $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1054 AC_PATH_PROG(BISON, bison, no, $PATH:/usr/local/bin:/usr/bin:/bin)
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 $libc_cv_asm_global_directive 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, ${libc_cv_asm_type_prefix}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 .symver assembler directive, libc_cv_asm_symver_directive,
1134 [cat > conftest.s <<EOF
1135 ${libc_cv_dot_text}
1136 _sym:
1137 .symver _sym,sym@VERS
1139 if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1140   libc_cv_asm_symver_directive=yes
1141 else
1142   libc_cv_asm_symver_directive=no
1144 rm -f conftest*])
1145 AC_CACHE_CHECK(for ld --version-script, libc_cv_ld_version_script_option, [dnl
1146 if test $libc_cv_asm_symver_directive = yes; then
1147   cat > conftest.s <<EOF
1148 ${libc_cv_dot_text}
1149 _sym:
1150 .symver _sym,sym@VERS
1152   cat > conftest.map <<EOF
1153 VERS_1 {
1154         global: sym;
1157 VERS_2 {
1158         global: sym;
1159 } VERS_1;
1161   if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1162     if AC_TRY_COMMAND([${CC-cc} $CFLAGS $LDFLAGS -shared
1163                                 -o conftest.so conftest.o
1164                                 -nostartfiles -nostdlib
1165                                 -Wl,--version-script,conftest.map
1166                        1>&AS_MESSAGE_LOG_FD]);
1167     then
1168       libc_cv_ld_version_script_option=yes
1169     else
1170       libc_cv_ld_version_script_option=no
1171     fi
1172   else
1173     libc_cv_ld_version_script_option=no
1174   fi
1175 else
1176   libc_cv_ld_version_script_option=no
1178 rm -f conftest*])
1179 if test $shared != no &&
1180    test $libc_cv_asm_symver_directive = yes &&
1181    test $libc_cv_ld_version_script_option = yes &&
1182    test $enable_versioning = yes; then
1183   VERSIONING=yes
1184   AC_DEFINE(DO_VERSIONING)
1185 else
1186   VERSIONING=no
1188 AC_SUBST(VERSIONING)
1190 if test $shared != no && test $VERSIONING = no; then
1191   echo "\
1192 *** WARNING: You should not compile GNU libc without versioning. Not using
1193 *** versioning will introduce incompatibilities so that old binaries
1194 *** will not run anymore.
1195 *** For versioning you need recent binutils (binutils-2.8.1.0.23 or newer)."
1197 AC_CACHE_CHECK(for .previous assembler directive,
1198                libc_cv_asm_previous_directive, [dnl
1199 cat > conftest.s <<EOF
1200 .section foo_section
1201 .previous
1203 if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1204   libc_cv_asm_previous_directive=yes
1205 else
1206   libc_cv_asm_previous_directive=no
1208 rm -f conftest*])
1209 if test $libc_cv_asm_previous_directive = yes; then
1210   AC_DEFINE(HAVE_ASM_PREVIOUS_DIRECTIVE)
1211 else
1212   AC_CACHE_CHECK(for .popsection assembler directive,
1213                  libc_cv_asm_popsection_directive, [dnl
1214   cat > conftest.s <<EOF
1215 .pushsection foo_section
1216 .popsection
1218   if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1219     libc_cv_asm_popsection_directive=yes
1220   else
1221     libc_cv_asm_popsection_directive=no
1222   fi
1223   rm -f conftest*])
1224   if test $libc_cv_asm_popsection_directive = yes; then
1225     AC_DEFINE(HAVE_ASM_POPSECTION_DIRECTIVE)
1226   fi
1228 AC_CACHE_CHECK(for .protected and .hidden assembler directive,
1229                libc_cv_asm_protected_directive, [dnl
1230 cat > conftest.s <<EOF
1231 .protected foo
1232 foo:
1233 .hidden bar
1234 bar:
1236 if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1237   libc_cv_asm_protected_directive=yes
1238 else
1239   AC_MSG_ERROR(assembler support for symbol visibility is required)
1241 rm -f conftest*])
1243 if test $libc_cv_asm_protected_directive = yes; then
1244   AC_CACHE_CHECK(whether __attribute__((visibility())) is supported,
1245                  libc_cv_visibility_attribute,
1246                  [cat > conftest.c <<EOF
1247                   int foo __attribute__ ((visibility ("hidden"))) = 1;
1248                   int bar __attribute__ ((visibility ("protected"))) = 1;
1250                   libc_cv_visibility_attribute=no
1251                   if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1252                     if grep '\.hidden.*foo' conftest.s >/dev/null; then
1253                       if grep '\.protected.*bar' conftest.s >/dev/null; then
1254                         libc_cv_visibility_attribute=yes
1255                       fi
1256                     fi
1257                   fi
1258                   rm -f conftest.{c,s}
1259                  ])
1260   if test $libc_cv_visibility_attribute != yes; then
1261     AC_MSG_ERROR(compiler support for visibility attribute is required)
1262   fi
1265 if test $libc_cv_visibility_attribute = yes; then
1266   AC_CACHE_CHECK(for broken __attribute__((visibility())),
1267                  libc_cv_broken_visibility_attribute,
1268                  [cat > conftest.c <<EOF
1269                   int foo (int x);
1270                   int bar (int x) __asm__ ("foo") __attribute__ ((visibility ("hidden")));
1271                   int bar (int x) { return x; }
1273                   libc_cv_broken_visibility_attribute=yes
1274                   if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1275 changequote(,)dnl
1276                     if grep '\.hidden[  _]foo' conftest.s >/dev/null; then
1277 changequote([,])dnl
1278                       libc_cv_broken_visibility_attribute=no
1279                     fi
1280                   fi
1281                   rm -f conftest.c conftest.s
1282                  ])
1283   if test $libc_cv_broken_visibility_attribute = yes; then
1284     AC_MSG_ERROR(working compiler support for visibility attribute is required)
1285   fi
1288 AC_CACHE_CHECK(for broken __attribute__((alias())),
1289                libc_cv_broken_alias_attribute,
1290                [cat > conftest.c <<EOF
1291                extern int foo (int x) __asm ("xyzzy");
1292                int bar (int x) { return x; }
1293                extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1294                extern int dfoo;
1295                extern __typeof (dfoo) dfoo __asm ("abccb");
1296                int dfoo = 1;
1298                libc_cv_broken_alias_attribute=yes
1299                if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1300                  if grep 'xyzzy' conftest.s >/dev/null &&
1301                     grep 'abccb' conftest.s >/dev/null; then
1302                    libc_cv_broken_alias_attribute=no
1303                  fi
1304                fi
1305                rm -f conftest.c conftest.s
1306                ])
1307 if test $libc_cv_broken_alias_attribute = yes; then
1308   AC_MSG_ERROR(working alias attribute support required)
1311 if test $libc_cv_visibility_attribute = yes; then
1312   AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1313                  libc_cv_have_sdata_section,
1314                  [echo "int i;" > conftest.c
1315                   libc_cv_have_sdata_section=no
1316                   if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1317                      | grep '\.sdata' >/dev/null; then
1318                     libc_cv_have_sdata_section=yes
1319                   fi
1320                   rm -f conftest.c conftest.so
1321                  ])
1322   if test $libc_cv_have_sdata_section = yes; then
1323     AC_DEFINE(HAVE_SDATA_SECTION)
1324   fi
1327 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
1328                libc_cv_initfini_array, [dnl
1329 LIBC_TRY_LINK_STATIC([
1330 int foo (void) { return 1; }
1331 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
1333   [if $READELF -S conftest | fgrep INIT_ARRAY > /dev/null; then
1334     libc_cv_initfini_array=yes
1335   else
1336     libc_cv_initfini_array=no
1337   fi],
1338   [libc_cv_initfini_array=no])
1340 if test $libc_cv_initfini_array != yes; then
1341   AC_MSG_ERROR([Need linker with .init_array/.fini_array support.])
1344 AC_CACHE_CHECK(whether to use .ctors/.dtors header and trailer,
1345                libc_cv_ctors_header, [dnl
1346   libc_cv_ctors_header=yes
1347   LIBC_TRY_LINK_STATIC([
1348 __attribute__ ((constructor)) void ctor (void) { asm (""); }
1349 __attribute__ ((destructor))  void dtor (void) { asm (""); }
1351               [dnl
1352       AS_IF([$READELF -WS conftest$ac_exeext | $AWK '
1353         { gsub(/\@<:@ */, "@<:@") }
1354         $2 == ".ctors" || $2 == ".dtors" {
1355           size = strtonum("0x" $6)
1356           align = strtonum("0x" $NF)
1357           seen@<:@$2@:>@ = 1
1358           stub@<:@$2@:>@ = size == align * 2
1359         }
1360         END {
1361           ctors_ok = !seen@<:@".ctors"@:>@ || stub@<:@".ctors"@:>@
1362           dtors_ok = !seen@<:@".dtors"@:>@ || stub@<:@".dtors"@:>@
1363           exit ((ctors_ok && dtors_ok) ? 0 : 1)
1364         }
1365       '], [libc_cv_ctors_header=no])
1366     ], [dnl
1367       AC_MSG_ERROR([missing __attribute__ ((constructor)) support??])
1368     ])
1370 if test $libc_cv_ctors_header = no; then
1371   AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
1374 AC_CACHE_CHECK(for libunwind-support in compiler,
1375                libc_cv_cc_with_libunwind, [
1376   cat > conftest.c <<EOF
1377 int main (void) { return 0; }
1379   if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1380      conftest.c -v 2>&1 >/dev/null | grep -q " -lunwind "; then
1381     libc_cv_cc_with_libunwind=yes
1382   else
1383     libc_cv_cc_with_libunwind=no
1384   fi
1385   rm -f conftest*])
1386 AC_SUBST(libc_cv_cc_with_libunwind)
1387 if test $libc_cv_cc_with_libunwind = yes; then
1388   AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1391 AC_CACHE_CHECK(for -z nodelete option,
1392                libc_cv_z_nodelete, [dnl
1393 cat > conftest.c <<EOF
1394 int _start (void) { return 42; }
1396 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1397                    -fPIC -shared -o conftest.so conftest.c
1398                    -nostartfiles -nostdlib
1399                    -Wl,--enable-new-dtags,-z,nodelete 1>&AS_MESSAGE_LOG_FD])
1400 then
1401   libc_cv_z_nodelete=yes
1402 else
1403   AC_MSG_ERROR(linker with -z nodelete support required)
1405 rm -f conftest*])
1407 AC_CACHE_CHECK(for -z nodlopen option,
1408                libc_cv_z_nodlopen, [dnl
1409 cat > conftest.c <<EOF
1410 int _start (void) { return 42; }
1412 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1413                         -fPIC -shared -o conftest.so conftest.c
1414                         -nostartfiles -nostdlib
1415                         -Wl,--enable-new-dtags,-z,nodlopen 1>&AS_MESSAGE_LOG_FD])
1416 then
1417   libc_cv_z_nodlopen=yes
1418 else
1419   AC_MSG_ERROR(linker with -z nodlopen support required)
1421 rm -f conftest*])
1423 AC_CACHE_CHECK(for -z initfirst option,
1424                libc_cv_z_initfirst, [dnl
1425 cat > conftest.c <<EOF
1426 int _start (void) { return 42; }
1428 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1429                         -fPIC -shared -o conftest.so conftest.c
1430                         -nostartfiles -nostdlib
1431                         -Wl,--enable-new-dtags,-z,initfirst 1>&AS_MESSAGE_LOG_FD])
1432 then
1433   libc_cv_z_initfirst=yes
1434 else
1435   AC_MSG_ERROR(linker with -z initfirst support required)
1437 rm -f conftest*])
1439 # Add-on fragments can set these for other machines.
1440 libc_commonpagesize=${libc_commonpagesize:-no}
1441 libc_relro_required=${libc_relro_required:-no}
1442 case "$base_machine" in
1443   i[[34567]]86 | x86_64 | powerpc* | s390*)
1444     libc_commonpagesize=0x1000
1445     libc_relro_required=yes
1446     ;;
1447   sparc*)
1448     libc_commonpagesize=0x2000
1449     libc_relro_required=yes
1450     ;;
1451 esac
1453 if test $libc_commonpagesize != no; then
1454   AC_CACHE_CHECK(for -z relro option,
1455                  libc_cv_z_relro, [dnl
1456   libc_cv_z_relro=no
1457   AC_LANG_CONFTEST([AC_LANG_SOURCE([[
1458 int _start (void) { return 42; }
1459 extern void _exit (int);
1460 /* Since these pointers are const, they should go in rodata.
1461    Since they refer to functions that have to be resolved by
1462    dynamic linking, they should instead go in RELRO data.  */
1463 const void *const relro[] = { &_start, &_exit, 0 };
1464 /* GNU ld fails to produce RELRO data when it's very small and there is no
1465    normal writable data following it, or if only uninitialized (.bss) data
1466    follows it, or only very small writable data.  */
1467 int data[0x10000] = { 1, };
1468 ]])])
1469   cat > conftest.awk <<\EOF
1470 BEGIN {
1471   result = "no"
1472   commonpagesize = strtonum(commonpagesize)
1474 { print "LINE:", $0 > "/dev/stderr" }
1475 $1 == "GNU_RELRO" {
1476   vaddr = strtonum($3)
1477   memsz = strtonum($6)
1478   end = vaddr + memsz
1479   printf "vaddr %#x memsz %#x end %#x commonpagesize %#x\n", \
1480     vaddr, memsz, end, commonpagesize > "/dev/stderr"
1481   result = (end % commonpagesize == 0) ? "yes" : "broken"
1483 END { print result }
1485   AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1486                     -fPIC -shared -o conftest.so conftest.c
1487                     -nostartfiles -nostdlib
1488                     -Wl,-z,relro 1>&AS_MESSAGE_LOG_FD]) &&
1489   AC_TRY_COMMAND([$READELF -Wl conftest.so > conftest.ph]) &&
1490   AC_TRY_COMMAND([
1491       $AWK -v commonpagesize=$libc_commonpagesize -f conftest.awk
1492            conftest.ph > conftest.cps
1493     ]) &&
1494   libc_cv_z_relro=`cat conftest.cps 2>&AS_MESSAGE_LOG_FD`
1495   rm -f conftest*])
1496   if { test "x$libc_relro_required" = xyes &&
1497        test "x$libc_cv_z_relro" != xyes
1498      }
1499   then
1500     AC_MSG_ERROR(linker with -z relro support required)
1501   fi
1502 else
1503   AC_MSG_WARN([missing architecture parameter to check for working -z relro])
1506 AC_CACHE_CHECK(for -Bgroup option,
1507                libc_cv_Bgroup, [dnl
1508 cat > conftest.c <<EOF
1509 int _start (void) { return 42; }
1511 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1512                             -fPIC -shared -o conftest.so conftest.c
1513                             -Wl,-Bgroup -nostdlib 1>&AS_MESSAGE_LOG_FD])
1514 then
1515   libc_cv_Bgroup=yes
1516 else
1517   libc_cv_Bgroup=no
1519 rm -f conftest*])
1520 AC_SUBST(libc_cv_Bgroup)
1522 AC_CACHE_CHECK(for --as-needed option,
1523                libc_cv_as_needed, [dnl
1524 cat > conftest.c <<EOF
1525 int main (void) { return 0; }
1527 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1528                               -fPIC -shared -o conftest.so conftest.c
1529                               -lgcc_s -Wl,--as-needed
1530                               -nostdlib 1>&AS_MESSAGE_LOG_FD])
1531 then
1532   libc_cv_as_needed=yes
1533 else
1534   libc_cv_as_needed=no
1536 rm -f conftest*])
1537 AC_SUBST(libc_cv_as_needed)
1539 ASFLAGS_config=
1540 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1541                libc_cv_as_noexecstack, [dnl
1542 cat > conftest.c <<EOF
1543 void foo (void) { }
1545 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1546                    -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1547    && grep -q .note.GNU-stack conftest.s \
1548    && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1549                       -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1550 then
1551   libc_cv_as_noexecstack=yes
1552 else
1553   libc_cv_as_noexecstack=no
1555 rm -f conftest*])
1556 if test $libc_cv_as_noexecstack = yes; then
1557   ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1559 AC_SUBST(ASFLAGS_config)
1561 AC_CACHE_CHECK(for -z combreloc,
1562                libc_cv_z_combreloc, [dnl
1563 cat > conftest.c <<EOF
1564 extern int bar (int);
1565 extern int mumble;
1566 int foo (void) { return bar (mumble); }
1568 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1569                         -fPIC -shared -o conftest.so conftest.c
1570                         -nostdlib -nostartfiles
1571                         -Wl,-z,combreloc 1>&AS_MESSAGE_LOG_FD])
1572 then
1573 dnl The following test is a bit weak.  We must use a tool which can test
1574 dnl cross-platform since the gcc used can be a cross compiler.  Without
1575 dnl introducing new options this is not easily doable.  Instead use a tool
1576 dnl which always is cross-platform: readelf.  To detect whether -z combreloc
1577 dnl look for a section named .rel.dyn.
1578   if $READELF -S conftest.so | grep '\.rel\(a\|\)\.dyn' > /dev/null; then
1579     libc_cv_z_combreloc=yes
1580   else
1581     libc_cv_z_combreloc=no
1582   fi
1583 else
1584   libc_cv_z_combreloc=no
1586 rm -f conftest*])
1587 if test "$libc_cv_z_combreloc" = yes; then
1588   AC_DEFINE(HAVE_Z_COMBRELOC)
1590 AC_SUBST(libc_cv_z_combreloc)
1592 AC_CACHE_CHECK(for -z execstack,
1593                libc_cv_z_execstack, [dnl
1594 cat > conftest.c <<EOF
1595 int _start (void) { return 42; }
1597 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1598                             -fPIC -shared -o conftest.so conftest.c
1599                             -Wl,-z,execstack -nostdlib
1600                             1>&AS_MESSAGE_LOG_FD])
1601 then
1602   libc_cv_z_execstack=yes
1603 else
1604   libc_cv_z_execstack=no
1606 rm -f conftest*])
1607 AC_SUBST(libc_cv_z_execstack)
1609 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1610 cat > conftest.c <<EOF
1611 int foo;
1612 main () { return 0;}
1614 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fpie
1615                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1616 then
1617   libc_cv_fpie=yes
1618 else
1619   libc_cv_fpie=no
1621 rm -f conftest*])
1623 AC_SUBST(libc_cv_fpie)
1625 AC_CACHE_CHECK(for --hash-style option,
1626                libc_cv_hashstyle, [dnl
1627 cat > conftest.c <<EOF
1628 int _start (void) { return 42; }
1630 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1631                             -fPIC -shared -o conftest.so conftest.c
1632                             -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
1633 then
1634   libc_cv_hashstyle=yes
1635 else
1636   libc_cv_hashstyle=no
1638 rm -f conftest*])
1639 AC_SUBST(libc_cv_hashstyle)
1641 # The linker's default -shared behavior is good enough if it
1642 # does these things that our custom linker scripts ensure that
1643 # all allocated NOTE sections come first.
1644 if test "$use_default_link" = default; then
1645   AC_CACHE_CHECK([for sufficient default -shared layout],
1646                   libc_cv_use_default_link, [dnl
1647   libc_cv_use_default_link=no
1648   cat > conftest.s <<\EOF
1649           .section .note.a,"a",%note
1650           .balign 4
1651           .long 4,4,9
1652           .string "GNU"
1653           .string "foo"
1654           .section .note.b,"a",%note
1655           .balign 4
1656           .long 4,4,9
1657           .string "GNU"
1658           .string "bar"
1660   if AC_TRY_COMMAND([dnl
1661   ${CC-cc} $ASFLAGS -shared -o conftest.so conftest.s 1>&AS_MESSAGE_LOG_FD]) &&
1662        ac_try=`$READELF -S conftest.so | sed -n \
1663          ['${x;p;}
1664           s/^ *\[ *[1-9][0-9]*\]  *\([^ ][^ ]*\)  *\([^ ][^ ]*\) .*$/\2 \1/
1665           t a
1666           b
1667           : a
1668           H']`
1669   then
1670     libc_seen_a=no libc_seen_b=no
1671     set -- $ac_try
1672     while test $# -ge 2 -a "$1" = NOTE; do
1673       case "$2" in
1674       .note.a) libc_seen_a=yes ;;
1675       .note.b) libc_seen_b=yes ;;
1676       esac
1677       shift 2
1678     done
1679     case "$libc_seen_a$libc_seen_b" in
1680     yesyes)
1681       libc_cv_use_default_link=yes
1682       ;;
1683     *)
1684       echo >&AS_MESSAGE_LOG_FD "\
1685 $libc_seen_a$libc_seen_b from:
1686 $ac_try"
1687       ;;
1688     esac
1689   fi
1690   rm -f conftest*])
1691   use_default_link=$libc_cv_use_default_link
1694 AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
1695 if libc_cv_output_format=`
1696 ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
1697 then
1698   :
1699 else
1700   libc_cv_output_format=
1702 test -n "$libc_cv_output_format" || libc_cv_output_format=unknown])
1703 AC_SUBST(libc_cv_output_format)
1705 AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
1706 cat > conftest.c <<EOF
1707 int foo;
1709 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
1710                             conftest.c 1>&AS_MESSAGE_LOG_FD])
1711 then
1712   libc_cv_fno_toplevel_reorder=yes
1713 else
1714   libc_cv_fno_toplevel_reorder=no
1716 rm -f conftest*])
1717 if test $libc_cv_fno_toplevel_reorder = yes; then
1718   fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
1719 else
1720   fno_unit_at_a_time=-fno-unit-at-a-time
1722 AC_SUBST(fno_unit_at_a_time)
1724 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
1725 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
1726                    [libc_cv_ssp=yes],
1727                    [libc_cv_ssp=no])
1729 AC_SUBST(libc_cv_ssp)
1731 AC_CACHE_CHECK(for -fgnu89-inline, libc_cv_gnu89_inline, [dnl
1732 cat > conftest.c <<EOF
1733 int foo;
1734 #ifdef __GNUC_GNU_INLINE__
1735 main () { return 0;}
1736 #else
1737 #error
1738 #endif
1740 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -std=gnu99 -fgnu89-inline
1741                             -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD])
1742 then
1743   libc_cv_gnu89_inline=yes
1744 else
1745   libc_cv_gnu89_inline=no
1747 rm -f conftest*])
1748 if test $libc_cv_gnu89_inline = yes; then
1749   gnu89_inline=-fgnu89-inline
1750 else
1751   gnu89_inline=
1753 AC_SUBST(gnu89_inline)
1755 AC_CACHE_CHECK(whether cc puts quotes around section names,
1756                libc_cv_have_section_quotes,
1757                [cat > conftest.c <<EOF
1758                 static const int foo
1759                 __attribute__ ((section ("bar"))) = 1;
1761                 if ${CC-cc} -S conftest.c -o conftest.s; then
1762                   if grep '\.section.*"bar"' conftest.s >/dev/null; then
1763                     libc_cv_have_section_quotes=yes
1764                   else
1765                     libc_cv_have_section_quotes=no
1766                   fi
1767                 else
1768                   libc_cv_have_section_quotes=unknown
1769                 fi
1770                 rm -f conftest.{c,s}
1771                 ])
1772 if test $libc_cv_have_section_quotes = yes; then
1773   AC_DEFINE(HAVE_SECTION_QUOTES)
1776 AC_CACHE_CHECK(for assembler .weak directive, libc_cv_asm_weak_directive,
1777                [dnl
1778 cat > conftest.s <<EOF
1779 ${libc_cv_dot_text}
1780 ${libc_cv_asm_global_directive} foo
1781 foo:
1782 .weak foo
1783 .weak bar; bar = foo
1785 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1786   libc_cv_asm_weak_directive=yes
1787 else
1788   libc_cv_asm_weak_directive=no
1790 rm -f conftest*])
1792 if test $libc_cv_asm_weak_directive = no; then
1793   AC_CACHE_CHECK(for assembler .weakext directive,
1794                  libc_cv_asm_weakext_directive,
1795                  [dnl
1796 cat > conftest.s <<EOF
1797 ${libc_cv_dot_text}
1798 ${libc_cv_asm_global_directive} foo
1799 foo:
1800 .weakext bar foo
1801 .weakext baz
1802 ${libc_cv_asm_global_directive} baz
1803 baz:
1805   if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1806     libc_cv_asm_weakext_directive=yes
1807   else
1808     libc_cv_asm_weakext_directive=no
1809   fi
1810   rm -f conftest*])
1812 fi # no .weak
1814 if test $libc_cv_asm_weak_directive = yes; then
1815   AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE)
1816 elif test $libc_cv_asm_weakext_directive = yes; then
1817   AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
1820 AC_CACHE_CHECK(whether CFI directives are supported, libc_cv_asm_cfi_directives, [dnl
1821 case $machine in
1822   sparc/sparc64*) cfi_offset=2047;;
1823   *) cfi_offset=0;;
1824 esac
1825 cat > conftest.s <<EOF
1826         .text
1827         .type   func,%function
1828 func:
1829         .cfi_startproc
1830         .cfi_remember_state
1831         .cfi_rel_offset 1, $cfi_offset
1832         .cfi_endproc
1834 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1835   libc_cv_asm_cfi_directives=yes
1836 else
1837   libc_cv_asm_cfi_directives=no
1839 rm -f conftest*])
1840 if test $libc_cv_asm_cfi_directives = yes; then
1841   AC_DEFINE(HAVE_ASM_CFI_DIRECTIVES)
1844 AC_CACHE_CHECK(for ld --no-whole-archive, libc_cv_ld_no_whole_archive, [dnl
1845 cat > conftest.c <<\EOF
1846 _start () {}
1847 int __eh_pc;
1848 __throw () {}
1850 dnl No \ in command here because it ends up inside ''.
1851 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1852                             -nostdlib -nostartfiles -Wl,--no-whole-archive
1853                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
1854   libc_cv_ld_no_whole_archive=yes
1855 else
1856   libc_cv_ld_no_whole_archive=no
1858 rm -f conftest*])
1859 if test $libc_cv_ld_no_whole_archive = no; then
1860   AC_MSG_ERROR([support for --no-whole-archive is needed])
1863 AC_CACHE_CHECK(for gcc -fexceptions, libc_cv_gcc_exceptions, [dnl
1864 cat > conftest.c <<\EOF
1865 _start () {}
1866 int __eh_pc;
1867 __throw () {}
1869 dnl No \ in command here because it ends up inside ''.
1870 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1871                             -nostdlib -nostartfiles -fexceptions
1872                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
1873   libc_cv_gcc_exceptions=yes
1874 else
1875   libc_cv_gcc_exceptions=no
1877 rm -f conftest*])
1878 if test $libc_cv_gcc_exceptions = yes; then
1879   exceptions=-fexceptions
1881 AC_SUBST(exceptions)dnl
1883 if test "$host_cpu" = powerpc ; then
1884 # Check for a bug present in at least versions 2.8.x of GCC
1885 # and versions 1.0.x of EGCS.
1886 AC_CACHE_CHECK(whether clobbering cr0 causes problems,libc_cv_c_asmcr0_bug,[dnl
1887 AC_TRY_COMPILE([int tester(int x) { asm ("" : : : "cc"); return x & 123; }],,
1888                libc_cv_c_asmcr0_bug='no',
1889                libc_cv_c_asmcr0_bug='yes')])
1890 if test "$libc_cv_c_asmcr0_bug" != 'no'; then
1891   AC_DEFINE(BROKEN_PPC_ASM_CR0)
1895 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1896 cat > conftest.c <<\EOF
1897 void zero (void *x)
1899   __builtin_memset (x, 0, 1000);
1903 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "memset" > /dev/null]);
1904 then
1905   libc_cv_gcc_builtin_memset=no
1906 else
1907   libc_cv_gcc_builtin_memset=yes
1909 rm -f conftest* ])
1910 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1911   AC_DEFINE(HAVE_BUILTIN_MEMSET)
1914 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1915 cat > conftest.c <<\EOF
1916 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1917 char *foo (const char *a, const char *b)
1919   return __builtin_strstr (a, b);
1923 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "my_strstr" > /dev/null]);
1924 then
1925   libc_cv_gcc_builtin_redirection=yes
1926 else
1927   libc_cv_gcc_builtin_redirection=no
1929 rm -f conftest* ])
1930 if test "$libc_cv_gcc_builtin_redirection" = no; then
1931   AC_MSG_ERROR([support for the symbol redirection needed])
1934 dnl Check whether the compiler supports the __thread keyword.
1935 AC_CACHE_CHECK([for __thread], libc_cv_gcc___thread,
1936 [cat > conftest.c <<\EOF
1937 __thread int a = 42;
1939 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
1940   libc_cv_gcc___thread=yes
1941 else
1942   libc_cv_gcc___thread=no
1944 rm -f conftest*])
1945 if test "$libc_cv_gcc___thread" = no; then
1946   AC_MSG_ERROR([support for the __thread keyword is required])
1949 dnl Check whether the compiler supports the tls_model attribute.
1950 AC_CACHE_CHECK([for tls_model attribute], libc_cv_gcc_tls_model_attr, [dnl
1951 cat > conftest.c <<\EOF
1952 extern __thread int a __attribute__((tls_model ("initial-exec")));
1954 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -Werror conftest.c >&AS_MESSAGE_LOG_FD]); then
1955   libc_cv_gcc_tls_model_attr=yes
1956 else
1957   libc_cv_gcc_tls_model_attr=no
1959 rm -f conftest*])
1960 if test "$libc_cv_gcc_tls_model_attr" = no; then
1961   AC_MSG_ERROR([support for the tls_model attribute is required])
1964 dnl Determine how to disable generation of FMA instructions.
1965 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1966                libc_cv_cc_nofma, [dnl
1967 libc_cv_cc_nofma=
1968 for opt in -ffp-contract=off -mno-fused-madd; do
1969   LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1970 done])
1972 if test -n "$submachine"; then
1973   AC_CACHE_CHECK([for compiler option for CPU variant],
1974                  libc_cv_cc_submachine, [dnl
1975   libc_cv_cc_submachine=no
1976   for opt in "-march=$submachine" "-mcpu=$submachine"; do
1977     LIBC_TRY_CC_OPTION([$opt], [
1978       libc_cv_cc_submachine="$opt"
1979       break], [])
1980   done])
1981   if test "x$libc_cv_cc_submachine" = xno; then
1982     AC_MSG_ERROR([${CC-cc} does not support $submachine])
1983   fi
1985 AC_SUBST(libc_cv_cc_submachine)
1987 dnl Check whether we have the gd library available.
1988 AC_MSG_CHECKING(for libgd)
1989 if test "$with_gd" != "no"; then
1990   old_CFLAGS="$CFLAGS"
1991   CFLAGS="$CFLAGS $libgd_include"
1992   old_LDFLAGS="$LDFLAGS"
1993   LDFLAGS="$LDFLAGS $libgd_ldflags"
1994   old_LIBS="$LIBS"
1995   LIBS="$LIBS -lgd -lpng -lz -lm"
1996   AC_TRY_LINK([#include <gd.h>], [gdImagePng (0, 0)], LIBGD=yes, LIBGD=no)
1997   CFLAGS="$old_CFLAGS"
1998   LDFLAGS="$old_LDFLAGS"
1999   LIBS="$old_LIBS"
2000 else
2001   LIBGD=no
2003 AC_MSG_RESULT($LIBGD)
2004 AC_SUBST(LIBGD)
2006 # SELinux detection
2007 if test x$with_selinux = xno ; then
2008   have_selinux=no;
2009 else
2010   # See if we have the SELinux library
2011   AC_CHECK_LIB(selinux, is_selinux_enabled,
2012                have_selinux=yes, have_selinux=no)
2013   # See if we have the SELinux header with the NSCD permissions in it.
2014   if test x$have_selinux = xyes ; then
2015     AC_MSG_CHECKING([for NSCD Flask permissions in selinux/av_permissions.h])
2016     AC_TRY_COMPILE([#include <selinux/av_permissions.h>],
2017                     [#ifdef NSCD__SHMEMHOST
2018                      return 0;
2019                      #else
2020                      #error NSCD__SHMEMHOST not defined
2021                      #endif],
2022                     have_selinux=yes, have_selinux=no)
2023     AC_MSG_RESULT($have_selinux)
2024   fi
2026   if test x$with_selinux = xyes ; then
2027     if test x$have_selinux = xno ; then
2028       AC_MSG_ERROR([SELinux explicitly required, but sufficiently recent SELinux library not found])
2029     fi
2030   fi
2032 # Check if we're building with SELinux support.
2033 if test "x$have_selinux" = xyes; then
2034   AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
2036   # See if we have the libaudit library
2037   AC_CHECK_LIB(audit, audit_log_user_avc_message,
2038                have_libaudit=yes, have_libaudit=no)
2039   if test "x$have_libaudit" = xyes; then
2040     AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
2041   fi
2042   AC_SUBST(have_libaudit)
2044   # See if we have the libcap library
2045   AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
2046   if test "x$have_libcap" = xyes; then
2047     AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
2048   fi
2049   AC_SUBST(have_libcap)
2051 AC_SUBST(have_selinux)
2053 dnl check for the size of 'long double'.
2054 AC_CHECK_SIZEOF(long double, 0)
2055 sizeof_long_double=$ac_cv_sizeof_long_double
2056 AC_SUBST(sizeof_long_double)
2058 ### End of automated tests.
2059 ### Now run sysdeps configure fragments.
2061 # They also can set these variables.
2062 use_ldconfig=no
2063 ldd_rewrite_script=no
2064 libc_cv_sysconfdir=$sysconfdir
2065 libc_cv_gcc_unwind_find_fde=no
2066 libc_cv_idn=no
2068 # Iterate over all the sysdep directories we will use, running their
2069 # configure fragments.
2070 for dir in $sysnames; do
2071   case $dir in
2072     /*) dest=$dir ;;
2073     *)  dest=$srcdir/$dir ;;
2074   esac
2075   if test -r $dest/configure; then
2076     AC_MSG_RESULT(running configure fragment for $dir)
2077     . $dest/configure
2078   fi
2079 done
2081 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
2082   AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
2084 AC_SUBST(libc_cv_gcc_unwind_find_fde)
2086 # Test for old glibc 2.0.x headers so that they can be removed properly
2087 # Search only in includedir.
2088 AC_MSG_CHECKING(for old glibc 2.0.x headers)
2089 if eval test -f "${includedir}/elfclass.h" -a -f "${includedir}/fcntlbits.h"
2090 then
2091   old_glibc_headers=yes
2092 else
2093   old_glibc_headers=no
2095 AC_MSG_RESULT($old_glibc_headers)
2096 if test ${old_glibc_headers} = yes; then
2097   AC_MSG_WARN(*** During \"make install\" old headers from glibc 2.0.x will)
2098   AC_MSG_WARN(*** be removed.)
2100 AC_SUBST(old_glibc_headers)
2102 AC_SUBST(libc_cv_slibdir)
2103 AC_SUBST(libc_cv_localedir)
2104 AC_SUBST(libc_cv_sysconfdir)
2105 AC_SUBST(libc_cv_rootsbindir)
2106 AC_SUBST(libc_cv_forced_unwind)
2108 dnl sysdeps/CPU/configure.in checks set this via arch-specific asm tests
2109 AC_SUBST(libc_cv_cpp_asm_debuginfo)
2110 AC_SUBST(libc_cv_cc_sse4)
2111 AC_SUBST(libc_cv_cc_avx)
2112 AC_SUBST(libc_cv_cc_sse2avx)
2113 AC_SUBST(libc_cv_cc_novzeroupper)
2114 AC_SUBST(libc_cv_cc_fma4)
2115 AC_SUBST(libc_cv_cc_nofma)
2116 AC_SUBST(libc_cv_as_i686)
2117 AC_SUBST(libc_cv_sparc_as_vis3)
2119 AC_SUBST(use_ldconfig)
2120 AC_SUBST(ldd_rewrite_script)
2122 AC_SUBST(static)
2123 AC_SUBST(shared)
2125 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
2126 [libc_cv_pic_default=yes
2127 cat > conftest.c <<EOF
2128 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
2129 # error PIC is default.
2130 #endif
2132 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
2133   libc_cv_pic_default=no
2135 rm -f conftest.*])
2136 AC_SUBST(libc_cv_pic_default)
2138 AC_SUBST(profile)
2139 AC_SUBST(static_nss)
2141 AC_SUBST(DEFINES)
2143 dnl See sysdeps/mach/configure.in for this variable.
2144 AC_SUBST(mach_interface_list)
2146 if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
2147   config_makefile=
2148 else
2149   config_makefile=Makefile
2152 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
2153 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
2154 AC_SUBST(VERSION)
2155 AC_SUBST(RELEASE)
2157 AC_CONFIG_FILES([config.make ${config_makefile}])
2158 AC_CONFIG_COMMANDS([default],[[
2159 case $CONFIG_FILES in *config.make*)
2160 echo "$config_vars" >> config.make;;
2161 esac
2162 test -d bits || mkdir bits]],[[config_vars='$config_vars']])
2163 AC_OUTPUT