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