* configure.in: Relax -z relro requirement a bit.
[platform/upstream/glibc.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION([$CVSid$])
3 AC_PREREQ(2.53)dnl              dnl Minimum Autoconf version required.
4 AC_INIT([GNU C Library], [(see version.h)], [glibc])
5 AC_CONFIG_SRCDIR([include/features.h])
6 AC_CONFIG_HEADERS([config.h])
7 AC_CONFIG_AUX_DIR([scripts])
8
9 if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
10   AC_MSG_ERROR([you must configure in a separate build directory])
11 fi
12
13 # This will get text that should go into config.make.
14 config_vars=
15
16 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
17 AC_ARG_WITH([gd],
18             AC_HELP_STRING([--with-gd=DIR],
19                            [find libgd include dir and library with prefix DIR]),
20             [dnl
21 case "$with_gd" in
22 yes|''|no) ;;
23 *) libgd_include="-I$withval/include"
24    libgd_ldflags="-L$withval/lib" ;;
25 esac
26 ])
27 AC_ARG_WITH([gd-include],
28             AC_HELP_STRING([--with-gd-include=DIR],
29                            [find libgd include files in DIR]),
30             [dnl
31 case "$with_gd_include" in
32 ''|no) ;;
33 *) libgd_include="-I$withval" ;;
34 esac
35 ])
36 AC_ARG_WITH([gd-lib],
37             AC_HELP_STRING([--with-gd-lib=DIR],
38                            [find libgd library files in DIR]),
39             [dnl
40 case "$with_gd_lib" in
41 ''|no) ;;
42 *) libgd_ldflags="-L$withval" ;;
43 esac
44 ])
45
46 if test -n "$libgd_include"; then
47   config_vars="$config_vars
48 CFLAGS-memusagestat.c = $libgd_include"
49 fi
50 if test -n "$libgd_ldflags"; then
51   config_vars="$config_vars
52 libgd-LDFLAGS = $libgd_ldflags"
53 fi
54
55 dnl Arguments to specify presence of other packages/features.
56 AC_ARG_WITH([fp],
57             AC_HELP_STRING([--with-fp],
58                            [if using floating-point hardware @<:@default=yes@:>@]),
59             [with_fp=$withval],
60             [with_fp=yes])
61 AC_SUBST(with_fp)
62 AC_ARG_WITH([binutils],
63             AC_HELP_STRING([--with-binutils=PATH],
64                            [specify location of binutils (as and ld)]),
65             [path_binutils=$withval],
66             [path_binutils=''])
67 AC_ARG_WITH([elf],
68             AC_HELP_STRING([--with-elf],
69                            [if using the ELF object format]),
70             [elf=$withval],
71             [elf=no])
72 AC_ARG_WITH([selinux],
73             AC_HELP_STRING([--with-selinux],
74                            [if building with SELinux support]),
75             [with_selinux=$withval],
76             [with_selinux=auto])
77 AC_ARG_WITH([xcoff],
78             AC_HELP_STRING([--with-xcoff],
79                            [if using the XCOFF object format]),
80             [xcoff=$withval],
81             [xcoff=no])
82 AC_ARG_WITH([cvs],
83             AC_HELP_STRING([--without-cvs],
84                            [if CVS should not be used]),
85             [with_cvs=$withval],
86             [with_cvs=yes])
87 if test "$with_cvs" = yes; then
88   if test -d $srcdir/CVS && grep :pserver: $srcdir/CVS/Root > /dev/null
89   then
90     with_cvs=no
91   fi
92 fi
93 AC_SUBST(with_cvs)
94
95 AC_ARG_WITH([headers],
96             AC_HELP_STRING([--with-headers=PATH],
97                            [location of system headers to use
98                             (for example /usr/src/linux/include)
99                             @<:@default=compiler default@:>@]),
100             [sysheaders=$withval],
101             [sysheaders=''])
102
103 AC_ARG_ENABLE([sanity-checks],
104               AC_HELP_STRING([--disable-sanity-checks],
105                              [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
106               [enable_sanity=$enableval],
107               [enable_sanity=yes])
108
109 AC_SUBST(enable_check_abi)
110 AC_ARG_ENABLE([check-abi],
111               AC_HELP_STRING([--enable-check-abi],
112                              [do "make check-abi" in "make check" (no/warn/yes)
113                               @<:@default=no@:>@]),
114               [enable_check_abi=$enableval],
115               [enable_check_abi=no])
116
117 dnl Arguments to enable or disable building the static, shared, profiled,
118 dnl and -fomit-frame-pointer libraries.
119 dnl I've disabled this for now since we cannot build glibc without static
120 dnl libraries built in the moment.
121 dnl AC_ARG_ENABLE([static],
122 dnl               AC_HELP_STRING([--enable-static],
123 dnl                              [build static library @<:@default=yes@:>@]),
124 dnl               [static=$enableval],
125 dnl               [static=yes])
126 static=yes
127 AC_ARG_ENABLE([shared],
128               AC_HELP_STRING([--enable-shared],
129                              [build shared library @<:@default=yes if GNU ld & ELF@:>@]),
130               [shared=$enableval],
131               [shared=default])
132 AC_ARG_ENABLE([profile],
133               AC_HELP_STRING([--enable-profile],
134                              [build profiled library @<:@default=no@:>@]),
135               [profile=$enableval],
136               [profile=no])
137 AC_ARG_ENABLE([omitfp],
138               AC_HELP_STRING([--enable-omitfp],
139                              [build undebuggable optimized library @<:@default=no@:>@]),
140               [omitfp=$enableval],
141               [omitfp=no])
142 AC_ARG_ENABLE([bounded],
143               AC_HELP_STRING([--enable-bounded],
144                              [build with runtime bounds checking @<:@default=no@:>@]),
145               [bounded=$enableval],
146               [bounded=no])
147 AC_ARG_ENABLE([versioning],
148               AC_HELP_STRING([--disable-versioning],
149                              [do not include versioning information in the library objects @<:@default=yes if supported@:>@]),
150               [enable_versioning=$enableval],
151               [enable_versioning=yes])
152
153 AC_ARG_ENABLE([oldest-abi],
154               AC_HELP_STRING([--enable-oldest-abi=ABI],
155                              [configure the oldest ABI supported @<:@e.g. 2.2@:>@ @<:@default=glibc default@:>@]),
156               [oldest_abi=$enableval],
157               [oldest_abi=no])
158 if test "$oldest_abi" = yes || test "$oldest_abi" = no; then
159   oldest_abi=default
160 else
161   AC_DEFINE_UNQUOTED(GLIBC_OLDEST_ABI, "$oldest_abi")
162 fi
163 AC_SUBST(oldest_abi)
164
165 AC_ARG_ENABLE([stackguard-randomization],
166               AC_HELP_STRING([--enable-stackguard-randomization],
167                              [initialize __stack_chk_guard canary with a random number at program start]),
168               [enable_stackguard_randomize=$enableval],
169               [enable_stackguard_randomize=no])
170 if test "$enable_stackguard_randomize" = yes; then
171   AC_DEFINE(ENABLE_STACKGUARD_RANDOMIZE)
172 fi
173
174 dnl Generic infrastructure for drop-in additions to libc.
175 AC_ARG_ENABLE([add-ons],
176               AC_HELP_STRING([--enable-add-ons@<:@=DIRS...@:>@],
177                              [configure and build add-ons in DIR1,DIR2,...
178                               search for add-ons if no parameter given]),
179                              , [enable_add_ons=yes])
180
181 dnl Let the user avoid using TLS.  Don't know why but...
182 AC_ARG_WITH([tls],
183             AC_HELP_STRING([--with-tls],
184                            [enable support for TLS]),
185             [usetls=$withval],
186             [usetls=yes])
187
188 AC_ARG_WITH([__thread],
189             AC_HELP_STRING([--without-__thread],
190                            [do not use TLS features even when supporting them]),
191             [use__thread=$withval],
192             [use__thread=yes])
193
194 AC_ARG_ENABLE([hidden-plt],
195               AC_HELP_STRING([--disable-hidden-plt],
196                              [do not hide internal function calls to avoid PLT]),
197               [hidden=$enableval],
198               [hidden=yes])
199 if test "x$hidden" = xno; then
200   AC_DEFINE(NO_HIDDEN)
201 fi
202
203 AC_ARG_ENABLE([bind-now],
204               AC_HELP_STRING([--enable-bind-now],
205                              [disable lazy relocations in DSOs]),
206               [bindnow=$enableval],
207               [bindnow=no])
208 AC_SUBST(bindnow)
209
210 dnl On some platforms we cannot use dynamic loading.  We must provide
211 dnl static NSS modules.
212 AC_ARG_ENABLE([static-nss],
213               AC_HELP_STRING([--enable-static-nss],
214                              [build static NSS modules @<:@default=no@:>@]),
215               [static_nss=$enableval],
216               [static_nss=no])
217 dnl Enable static NSS also if we build no shared objects.
218 if test x"$static_nss" = xyes || test x"$shared" = xno; then
219   static_nss=yes
220   AC_DEFINE(DO_STATIC_NSS)
221 fi
222
223 AC_ARG_ENABLE([force-install],
224               AC_HELP_STRING([--disable-force-install],
225                              [don't force installation of files from this package, even if they are older than the installed files]),
226               [force_install=$enableval],
227               [force_install=yes])
228 AC_SUBST(force_install)
229
230 dnl On some platforms we allow dropping compatibility with all kernel
231 dnl versions.
232 AC_ARG_ENABLE([kernel],
233               AC_HELP_STRING([--enable-kernel=VERSION],
234                              [compile for compatibility with kernel not older than VERSION]),
235               [minimum_kernel=$enableval],
236               [])
237 dnl Prevent unreasonable values.
238 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
239   # Better nothing than this.
240   minimum_kernel=""
241 else
242   if test "$minimum_kernel" = current; then
243     minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
244   fi
245 fi
246
247 dnl For the development we sometimes want gcc to issue even more warnings.
248 dnl This is not the default since many of the extra warnings are not
249 dnl appropriate.
250 AC_ARG_ENABLE([all-warnings],
251               AC_HELP_STRING([--enable-all-warnings],
252                              [enable all useful warnings gcc can issue]),
253               [all_warnings=$enableval],
254               [])
255 AC_SUBST(all_warnings)
256
257 AC_CANONICAL_HOST
258
259 # The way shlib-versions is used to generate soversions.mk uses a
260 # fairly simplistic model for name recognition that can't distinguish
261 # i486-pc-linux-gnu fully from i486-pc-gnu.  So we mutate a $host_os
262 # of `gnu*' here to be `gnu-gnu*' just so that shlib-versions can
263 # tell.  This doesn't get used much beyond that, so it's fairly safe.
264 case "$host_os" in
265 linux*)
266   ;;
267 gnu*)
268   host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
269   ;;
270 esac
271
272 # We keep the original values in `$config_*' and never modify them, so we
273 # can write them unchanged into config.make.  Everything else uses
274 # $machine, $vendor, and $os, and changes them whenever convenient.
275 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
276
277 # Don't allow vendor == "unknown"
278 test "$config_vendor" = unknown && config_vendor=
279 config_os="`echo $config_os | sed 's/^unknown-//'`"
280
281 # Some configurations imply other options.
282 case "$host_os" in
283 # i586-linuxaout is mangled into i586-pc-linux-gnuaout
284 linux*ecoff* | linux*aout* | gnu*aout* | gnu*ecoff*)
285   ;;
286 gnu* | linux* | freebsd* | netbsd* | sysv4* | solaris2* | irix6*)
287   # These systems (almost) always use the ELF format.
288   elf=yes
289   ;;
290 aix*)
291   # These systems are always xcoff
292   xcoff=yes
293   elf=no
294   ;;
295 esac
296
297 # The configure fragment of an add-on port can modify these to supplement
298 # or override the table in the case statement below.  No fragment should
299 # ever change the config_* variables, however.
300 machine=$config_machine
301 vendor=$config_vendor
302 os=$config_os
303
304 # config.guess on some IBM machines says `rs6000' instead of `powerpc'.
305 # Unify this here.
306 if test "$machine" = rs6000; then
307   machine="powerpc"
308 fi
309
310 # Braindead PowerPC box with absolutely no FPU.
311 case "$machine-$host_os" in
312   powerpc*-*soft)
313     with_fp=no
314     ;;
315 esac
316
317 submachine=
318 AC_ARG_WITH([cpu],
319             AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
320             [dnl
321   case "$withval" in
322   yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
323   no) ;;
324   *) submachine="$withval" ;;
325   esac
326 ])
327
328
329 # An add-on can set this when it wants to disable the sanity check below.
330 libc_config_ok=no
331
332 dnl Having this here, though empty, makes sure that if add-ons' fragments
333 dnl do AC_CONFIG_SUBDIRS([some-dir]), which just sets $subdirs, then
334 dnl our AC_OUTPUT will actually use it.
335 AC_CONFIG_SUBDIRS()
336
337 case "$enable_add_ons" in
338 ''|no) add_ons= ;;
339 yes|'*')
340  add_ons=`cd $srcdir && ls -d 2> /dev/null */configure */sysdeps |
341           sed 's@/[[^/]]*$@@' | sort | uniq`
342          add_ons_automatic=yes
343          ;;
344 *) add_ons=`echo "$enable_add_ons" | sed 's/,/ /g'`
345        add_ons_automatic=no ;;
346 esac
347
348 configured_add_ons=
349 add_ons_sfx=
350 add_ons_pfx=
351 if test x"$add_ons" != x; then
352   for f in $add_ons; do
353     # Some sanity checks
354     case "$f" in
355     crypt)
356       AC_MSG_ERROR([
357 *** It seems that you're using an old \`crypt' add-on.  crypt is now
358 *** part of glibc and using the old add-on will not work with this
359 *** release.  Start again with fresh sources and without the old
360 *** \`crypt' add-on.])
361     ;;
362     localedata)
363       AC_MSG_ERROR([
364 *** It seems that you're using an old \`localedata' add-on.  localedata
365 *** is now part of glibc and using the old add-on will not work with
366 *** this release.  Start again with fresh sources and without the old
367 *** \`localedata' add-on.])
368     ;;
369     esac
370   done
371
372   # Now source each add-on's configure fragment.
373   # The fragments can use $srcdir/$libc_add_on to find themselves,
374   # and test $add_ons_automatic to see if they were explicitly requested.
375   # A fragment can clear (or even change) $libc_add_on to affect
376   # whether it goes into the list to be actually used in the build.
377   use_add_ons=
378   for libc_add_on in $add_ons; do
379     # Test whether such a directory really exists.
380     # It can be absolute, or relative to $srcdir, or relative to the build dir.
381     case "$libc_add_on" in
382     /*)
383       libc_add_on_srcdir=$libc_add_on
384       ;;
385     *)
386       test -d "$srcdir/$libc_add_on" || {
387         if test -d "$libc_add_on"; then
388           libc_add_on="`pwd`/$libc_add_on"
389         else
390           AC_MSG_ERROR(add-on directory \"$libc_add_on\" does not exist)
391         fi
392       }
393       libc_add_on_srcdir=$srcdir/$libc_add_on
394       ;;
395     esac
396
397     libc_add_on_frag=$libc_add_on_srcdir/configure
398     libc_add_on_canonical=
399     if test -r "$libc_add_on_frag"; then
400       AC_MSG_NOTICE(running configure fragment for add-on $libc_add_on)
401       libc_add_on_canonical=unknown
402       libc_add_on_subdirs=
403       . "$libc_add_on_frag"
404       test -z "$libc_add_on" || {
405         configured_add_ons="$configured_add_ons $libc_add_on"
406         if test "x$libc_add_on_canonical" = xunknown; then
407           AC_MSG_ERROR(fragment must set \$libc_add_on_canonical)
408         fi
409         for d in $libc_add_on_subdirs; do
410           case "$libc_add_on" in
411           /*) subdir_srcdir="$libc_add_on" ;;
412           *) subdir_srcdir="\$(..)$libc_add_on" ;;
413           esac
414           case "$d" in
415           .)
416             d="${libc_add_on_canonical:-$libc_add_on}"
417             ;;
418           /*)
419             subdir_srcdir="$d"
420             ;;
421           *)
422             subdir_srcdir="$subdir_srcdir/$d"
423             ;;
424           esac
425           d=`echo "$d" | sed 's@/*$@@;s@^.*/@@'`
426           add_on_subdirs="$add_on_subdirs $d"
427           test "$subdir_srcdir" = "\$(..)$d" || config_vars="$config_vars
428 $d-srcdir = $subdir_srcdir"
429         done
430       }
431     fi
432     if test -n "$libc_add_on"; then
433       if frags=`ls -d $libc_add_on_srcdir/sysdeps/*/preconfigure 2> /dev/null`
434       then
435         AC_MSG_CHECKING(add-on $libc_add_on for preconfigure fragments)
436         for frag in $frags; do
437           name=`echo "$frag" | sed 's@/[[^/]]*$@@;s@^.*/@@'`
438           echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
439           . "$frag"
440         done
441         AC_MSG_RESULT()
442       fi
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`"
451 fi
452 AC_SUBST(add_ons)
453 AC_SUBST(add_on_subdirs)
454
455
456 ###
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
459 ###
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.
463 ###
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* | powerpc-aix4.3.*)
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
478 fi
479
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 a29k | am29000) base_machine=a29k machine=a29k ;;
487 alpha*)         base_machine=alpha machine=alpha/$machine ;;
488 c3[012])        base_machine=cx0 machine=cx0/c30 ;;
489 c4[04])         base_machine=cx0 machine=cx0/c40 ;;
490 i[34567]86)     base_machine=i386 machine=i386/$machine ;;
491 ia64)           base_machine=ia64 machine=ia64 ;;
492 m88???)         base_machine=m88k machine=m88k/$machine ;;
493 m88k)           base_machine=m88k machine=m88k/m88100 ;;
494 powerpc)        base_machine=powerpc machine=powerpc/powerpc32 ;;
495 powerpc64)      base_machine=powerpc machine=powerpc/powerpc64 ;;
496 s390)           base_machine=s390 machine=s390/s390-32 ;;
497 s390x)          base_machine=s390 machine=s390/s390-64 ;;
498 sh3*)           base_machine=sh machine=sh/sh3 ;;
499 sh4*)           base_machine=sh machine=sh/sh4 ;;
500 sparc | sparcv[67])
501                 base_machine=sparc machine=sparc/sparc32 ;;
502 sparcv8 | supersparc | hypersparc)
503                 base_machine=sparc machine=sparc/sparc32/sparcv8 ;;
504 sparcv8plus | sparcv8plusa | sparcv9)
505                 base_machine=sparc machine=sparc/sparc32/sparcv9 ;;
506 sparcv8plusb | sparcv9b)
507                 base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9b ;;
508 sparcv9v)
509                 base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9v ;;
510 sparc64)
511                 base_machine=sparc machine=sparc/sparc64 ;;
512 sparc64b)
513                 base_machine=sparc machine=sparc/sparc64/sparcv9b ;;
514 sparc64v)
515                 base_machine=sparc machine=sparc/sparc64/sparcv9v ;;
516 *)              base_machine=$machine ;;
517 esac
518 changequote([,])dnl
519 AC_SUBST(base_machine)
520
521 if test "$base_machine" = "i386"; then
522   AC_DEFINE(USE_REGPARMS)
523 fi
524
525 # Compute the list of sysdep directories for this configuration.
526 # This can take a while to compute.
527 sysdep_dir=$srcdir/sysdeps
528 AC_MSG_CHECKING(sysdep dirs)
529 dnl We need to use [ and ] for other purposes for a while now.
530 changequote(,)dnl
531 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
532 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
533
534 case "$os" in
535 gnu*)
536   base_os=mach/hurd ;;
537 netbsd* | 386bsd* | freebsd* | bsdi*)
538   base_os=unix/bsd/bsd4.4 ;;
539 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
540   base_os=unix/bsd ;;
541 sysv* | isc* | esix* | sco* | minix* | irix4* | linux*)
542   base_os=unix/sysv ;;
543 irix6*)
544   base_os=unix/sysv/irix6/$os ;;
545 solaris[2-9]*)
546   base_os=unix/sysv/sysv4 ;;
547 hpux*)
548   base_os=unix/sysv/hpux/$os ;;
549 aix4.3*)
550   base_os=unix/sysv/aix/aix4.3 ;;
551 none)
552   base_os=standalone ;;
553 *)
554   base_os='' ;;
555 esac
556
557 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
558 tail=$os
559 ostry=$os
560 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
561   ostry="$ostry /$o"
562   tail=$o
563 done
564 o=`echo $tail | sed 's/[0-9]*$//'`
565 if test $o != $tail; then
566   ostry="$ostry /$o"
567 fi
568 # For linux-gnu, try linux-gnu, then linux.
569 o=`echo $tail | sed 's/-.*$//'`
570 if test $o != $tail; then
571   ostry="$ostry /$o"
572 fi
573
574 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
575 base=
576 tail=$base_os
577 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
578   set $b
579   base="$base /$1"
580   tail="$2"
581 done
582
583 # For sparc/sparc32, try sparc/sparc32 and then sparc.
584 mach=
585 tail=$machine${submachine:+/$submachine}
586 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
587   set $m
588   # Prepend the machine's FPU directory unless --without-fp.
589   if test "$with_fp" = yes; then
590     mach="$mach /$1/fpu"
591   else
592     mach="$mach /$1/nofpu"
593   fi
594   mach="$mach /$1"
595   tail="$2"
596 done
597
598 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
599 changequote([,])dnl
600
601 # Find what sysdep directories exist.
602 sysnames_add_ons=
603 sysnames=
604 for b in $base ''; do
605   for m0 in $mach ''; do
606     for v in /$vendor ''; do
607       test "$v" = / && continue
608       for o in /$ostry ''; do
609         test "$o" = / && continue
610         for m in $mach ''; do
611           for d in $add_ons_pfx ''; do
612             for a in $add_ons_sfx ''; do
613               if test -n "$m0$m0sub$b$v$o$m$msub"; then
614                 try_srcdir="${srcdir}/"
615                 case "$d" in
616                 /*) try_srcdir= ;;
617                 esac
618                 try="${d}sysdeps$m0$m0sub$b$v$o$m$msub$a"
619                 test -n "$enable_debug_configure" &&
620                 echo "$0 [DEBUG]: try $try" >&2
621                 if test -d "$try_srcdir$try"; then
622                   sysnames="$sysnames $try"
623                   { test -n "$o" || test -n "$b"; } && os_used=t
624                   { test -n "$m" || test -n "$m0"; } && machine_used=t
625                   case x${m0:-$m} in
626                   x*/$submachine) submachine_used=t ;;
627                   esac
628                   if test -n "$d"; then
629                     case "$sysnames_add_ons" in
630                     *" $d "*) ;;
631                     *|'') sysnames_add_ons="$sysnames_add_ons $d" ;;
632                     esac
633                   fi
634                 fi
635               fi
636             done
637           done
638         done
639       done
640     done
641   done
642 done
643
644 if test -z "$os_used" && test "$os" != none; then
645   AC_MSG_ERROR(Operating system $os is not supported.)
646 fi
647 if test -z "$machine_used" && test "$machine" != none; then
648   AC_MSG_ERROR(The $machine is not supported.)
649 fi
650 if test -z "$submachine_used" && test -n "$submachine"; then
651   AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
652 fi
653 AC_SUBST(submachine)
654
655 # We have now validated the configuration.
656
657
658 # If using ELF, look for an `elf' subdirectory of each machine directory.
659 # We prepend these rather than inserting them whereever the machine appears
660 # because things specified by the machine's ELF ABI should override
661 # OS-specific things, and should always be the same for any OS on the
662 # machine (otherwise what's the point of an ABI?).
663 if test "$elf" = yes; then
664   elf_dirs=
665   for d in $add_ons_pfx ''; do
666     for m in $mach; do
667       if test -d $srcdir/${d}sysdeps$m/elf; then
668         elf_dirs="$elf_dirs ${d}sysdeps$m/elf"
669       fi
670     done
671   done
672   sysnames="`echo $elf_dirs | sed -e 's,//,/,g'` $sysnames"
673 fi
674
675
676 # Expand the list of system names into a full list of directories
677 # from each element's parent name and Implies file (if present).
678 set $sysnames
679 names=
680 while test $# -gt 0; do
681   name=$1
682   shift
683
684   case " $names " in *" $name "*)
685     # Already in the list.
686     continue
687   esac
688
689   # Report each name as we discover it, so there is no long pause in output.
690   echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
691
692   name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
693
694   case $name in
695     /*) xsrcdir= ;;
696     *)  xsrcdir=$srcdir/ ;;
697   esac
698   test -n "$enable_debug_configure" &&
699   echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
700
701   if test -f $xsrcdir$name/Implies; then
702     # Collect more names from the `Implies' file (removing comments).
703     implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/Implies`"
704     implied=
705     for x in $implied_candidate; do
706       found=no
707       if test -d $xsrcdir$name_base/$x; then
708         implied="$implied $name_base/$x";
709         found=yes
710       fi
711       for d in $add_ons_pfx ''; do
712         try="${d}sysdeps/$x"
713         case $d in
714          /*) try_srcdir= ;;
715          *) try_srcdir=$srcdir/ ;;
716         esac
717         test -n "$enable_debug_configure" &&
718          echo "[DEBUG]: $name implied $x try($d) {$try_srcdir}$try" >&2
719         if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
720         then
721           implied="$implied $try"
722           found=yes
723           case "$sysnames_add_ons" in
724           *" $d "*) ;;
725           *|'') sysnames_add_ons="$sysnames_add_ons $d" ;;
726           esac
727         fi
728       done
729       if test $found = no; then
730         AC_MSG_WARN($name/Implies specifies nonexistent $x)
731       fi
732     done
733   else
734     implied=
735   fi
736
737   # Add NAME to the list of names.
738   names="$names $name"
739
740   # Find the parent of NAME, using the empty string if it has none.
741 changequote(,)dnl
742   parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
743 changequote([,])dnl
744
745   # Add the names implied by NAME, and NAME's parent (if it has one), to
746   # the list of names to be processed (the argument list).  We prepend the
747   # implied names to the list and append the parent.  We want implied
748   # directories to come before further directories inferred from the
749   # configuration components; this ensures that for sysv4, unix/common
750   # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
751   # after sysv4).
752   sysnames="`echo $implied $* $parent`"
753   test -n "$sysnames" && set $sysnames
754 done
755
756 # Add the default directories.
757 default_sysnames=sysdeps/generic
758 if test "$elf" = yes; then
759   default_sysnames="sysdeps/generic/elf $default_sysnames"
760 fi
761 sysnames="$names $default_sysnames"
762 AC_SUBST(sysnames)
763 # The other names were emitted during the scan.
764 AC_MSG_RESULT($default_sysnames)
765
766 # Collect the list of add-ons that supply partial sysdeps trees.
767 sysdeps_add_ons=
768 for add_on in $add_ons; do
769   case "$add_on" in
770   /*) xsrcdir= ;;
771   *) xsrcdir="$srcdir/" ;;
772   esac
773
774   test -d "$xsrcdir$add_on/sysdeps" || {
775     case "$configured_add_ons " in
776     *" $add_on "*) ;;
777     *|'')
778       AC_MSG_ERROR(add-on $add_on has no configure fragment or sysdeps tree)
779       ;;
780     esac
781     continue
782   }
783
784   sysdeps_add_ons="$sysdeps_add_ons $add_on"
785   case "$sysnames_add_ons" in
786   *" $add_on/ "*) ;;
787   *|'')
788     AC_MSG_WARN(add-on $add_on contributed no sysdeps directories)
789     continue ;;
790   esac
791
792   found=no
793   for d in $sysnames; do
794     case "$d" in
795     $add_on/sysdeps/*) ;;
796     *) continue ;;
797     esac
798     (cd "$xsrcdir$d" && for f in *[[!~]]; do
799        case "$f" in
800        sys|bits)
801          for ff in $f/*.h; do
802            test -d "$ff" || { test -e "$ff" && exit 88; }
803          done
804          ;;
805        *)
806          test -d "$f" || { test -e "$f" && exit 88; }
807          ;;
808        esac
809      done)
810     if test $? -eq 88; then
811       found=yes
812       break
813     fi
814   done
815   if test $found = no; then
816     AC_MSG_WARN(add-on $add_on contributed no useful sysdeps directories)
817   fi
818 done
819 AC_SUBST(sysdeps_add_ons)
820
821
822 ### Locate tools.
823
824 AC_PROG_INSTALL
825 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
826   # The makefiles need to use a different form to find it in $srcdir.
827   INSTALL='\$(..)./scripts/install-sh -c'
828 fi
829 AC_PROG_LN_S
830
831 AC_PROG_CC
832 if test $host != $build; then
833   AC_CHECK_PROGS(BUILD_CC, gcc cc)
834 fi
835 AC_SUBST(cross_compiling)
836 AC_PROG_CPP
837 # We need the C++ compiler only for testing.
838 AC_PROG_CXX
839 LIBC_PROG_BINUTILS
840 AC_SUBST(MIG)dnl Needed by sysdeps/mach/configure.in
841
842 # Accept binutils 2.13 or newer.
843 AC_CHECK_PROG_VER(AS, $AS, --version,
844                   [GNU assembler.* \([0-9]*\.[0-9.]*\)],
845                   [2.1[3-9]*], AS=: critic_missing="$critic_missing as")
846 AC_CHECK_PROG_VER(LD, $LD, --version,
847                   [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
848                   [2.1[3-9]*], LD=: critic_missing="$critic_missing ld")
849
850 # We need the physical current working directory.  We cannot use the
851 # "pwd -P" shell builtin since that's not portable.  Instead we try to
852 # find a pwd binary.  Note that assigning to the PWD environment
853 # variable might have some interesting side effects, so we don't do
854 # that.
855 AC_PATH_PROG(PWD_P, pwd, no)
856 if test "$PWD_P" = no; then
857   AC_MSG_ERROR(*** A pwd binary could not be found.)
858 fi
859
860 # These programs are version sensitive.
861 AC_CHECK_TOOL_PREFIX
862 AC_CHECK_PROG_VER(CC, ${ac_tool_prefix}gcc ${ac_tool_prefix}cc, -v,
863   [version \([egcygnustpi-]*[0-9.]*\)], [3.4* | 4.[0-9]* ],
864   critic_missing="$critic_missing gcc")
865 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
866   [GNU Make[^0-9]*\([0-9][0-9.]*\)],
867   [3.79* | 3.[89]*], critic_missing="$critic_missing make")
868
869 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
870   [GNU gettext.* \([0-9]*\.[0-9.]*\)],
871   [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
872   MSGFMT=: aux_missing="$aux_missing msgfmt")
873 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
874   [GNU texinfo.* \([0-9][0-9.]*\)],
875   [4.*],
876   MAKEINFO=: aux_missing="$aux_missing makeinfo")
877 AC_CHECK_PROG_VER(SED, sed, --version,
878   [GNU sed version \([0-9]*\.[0-9.]*\)],
879   [3.0[2-9]*|3.[1-9]*|[4-9]*],
880   SED=: aux_missing="$aux_missing sed")
881
882 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
883 case "x$AUTOCONF" in
884 xno|x|x:) AUTOCONF=no ;;
885 *)
886   AC_CACHE_CHECK(dnl
887 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
888   if (cd $srcdir; $AUTOCONF $ACFLAGS configure.in > /dev/null 2>&1); then
889     libc_cv_autoconf_works=yes
890   else
891     libc_cv_autoconf_works=no
892   fi])
893   test $libc_cv_autoconf_works = yes || AUTOCONF=no
894   ;;
895 esac
896 if test "x$with_cvs" = xyes && test "x$AUTOCONF" = xno; then
897   # If --without-cvs they probably won't change configure.in, so no complaints.
898   aux_missing="$aux_missing autoconf"
899 fi
900
901 test -n "$critic_missing" && AC_MSG_ERROR([
902 *** These critical programs are missing or too old:$critic_missing
903 *** Check the INSTALL file for required versions.])
904
905 test -n "$aux_missing" && AC_MSG_WARN([
906 *** These auxiliary programs are missing or incompatible versions:$aux_missing
907 *** some features will be disabled.
908 *** Check the INSTALL file for required versions.])
909
910 # if using special system headers, find out the compiler's sekrit
911 # header directory and add that to the list.  NOTE: Only does the right
912 # thing on a system that doesn't need fixincludes.  (Not presently a problem.)
913 if test -n "$sysheaders"; then
914   ccheaders=`$CC -print-file-name=include`
915   SYSINCLUDES="-nostdinc -isystem $ccheaders \
916 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
917   if test -n "$CXX"; then
918     cxxversion=`$CXX -dumpversion 2>&AS_MESSAGE_LOG_FD` &&
919     cxxmachine=`$CXX -dumpmachine 2>&AS_MESSAGE_LOG_FD` &&
920     cxxheaders=`$CXX -print-file-name=../../../../include/c++/`"$cxxversion" &&
921     CXX_SYSINCLUDES="-isystem $cxxheaders \
922 -isystem $cxxheaders/$cxxmachine -isystem $cxxheaders/backward"
923   fi
924 fi
925 AC_SUBST(SYSINCLUDES)
926 AC_SUBST(CXX_SYSINCLUDES)
927
928 # check if ranlib is necessary
929 AC_CACHE_CHECK(whether ranlib is necessary, libc_cv_ranlib_necessary, [dnl
930 cat > conftest.c <<EOF
931 int a;
932 char b;
933 void c(void) {}
934 EOF
935 $CC $CFLAGS $CPPFLAGS -c conftest.c
936 $AR cr conftest.a conftest.o
937 cp conftest.a conftest2.a
938 $RANLIB conftest.a
939 if cmp -s conftest.a conftest2.a; then
940   libc_cv_ranlib_necessary=no
941 else
942   libc_cv_ranlib_necessary=yes
943 fi
944 rm -rf conftest*])
945 if test "$libc_cv_ranlib_necessary" = no; then
946  RANLIB=:
947 fi
948
949 # Test if LD_LIBRARY_PATH contains the notation for the current directory
950 # since this would lead to problems installing/building glibc.
951 # LD_LIBRARY_PATH contains the current directory if one of the following
952 # is true:
953 # - one of the terminals (":" and ";") is the first or last sign
954 # - two terminals occur directly after each other
955 # - the path contains an element with a dot in it
956 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
957 changequote(,)dnl
958 case ${LD_LIBRARY_PATH} in
959   [:\;]* | *[:\;] | *[:\;][:\;]* |  *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
960     ld_library_path_setting="contains current directory"
961     ;;
962   *)
963     ld_library_path_setting="ok"
964     ;;
965 esac
966 changequote([,])dnl
967 AC_MSG_RESULT($ld_library_path_setting)
968 if test "$ld_library_path_setting" != "ok"; then
969 AC_MSG_ERROR([
970 *** LD_LIBRARY_PATH shouldn't contain the current directory when
971 *** building glibc. Please change the environment variable
972 *** and run configure again.])
973 fi
974
975 AC_CACHE_CHECK(whether GCC supports -static-libgcc, libc_cv_gcc_static_libgcc, [dnl
976 if $CC -v -static-libgcc 2>&1 | grep -q 'unrecognized option.*static-libgcc'; then
977   libc_cv_gcc_static_libgcc=
978 else
979   libc_cv_gcc_static_libgcc=-static-libgcc
980 fi])
981 AC_SUBST(libc_cv_gcc_static_libgcc)
982
983 AC_PATH_PROG(BASH, bash, no)
984 if test "$BASH" != no &&
985    $BASH -c 'test "$BASH_VERSINFO" \
986              && test "$BASH_VERSINFO" -ge 2 >&/dev/null'; then
987   libc_cv_have_bash2=yes
988 else
989   libc_cv_have_bash2=no
990 fi
991 AC_SUBST(libc_cv_have_bash2)
992
993 dnl We need a ksh compatible shell for tzselect.
994 if test "$BASH" = no; then
995   AC_PATH_PROG(KSH, ksh, no)
996   if test "$KSH" = no; then
997     libc_cv_have_ksh=no
998   else
999     libc_cv_have_ksh=yes
1000   fi
1001 else
1002   KSH="$BASH"
1003   AC_SUBST(KSH)
1004   libc_cv_have_ksh=yes
1005 fi
1006 AC_SUBST(libc_cv_have_ksh)
1007
1008 AC_PROG_AWK
1009 AC_PATH_PROG(PERL, perl, no)
1010 if test "$PERL" != no &&
1011    (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1012   PERL=no
1013 fi
1014 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1015              $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1016 AC_PATH_PROG(BISON, bison, no, $PATH:/usr/local/bin:/usr/bin:/bin)
1017
1018 AC_CACHE_CHECK(for signed size_t type, libc_cv_signed_size_t, [dnl
1019 echo '#include <stddef.h>
1020 FOOBAR __SIZE_TYPE__ FOOBAR' > conftest.c
1021 if eval "$ac_cpp conftest.c 2>/dev/null" \
1022 | grep '^FOOBAR.*unsigned.*FOOBAR$' >/dev/null; then
1023   libc_cv_signed_size_t=no
1024 else
1025   libc_cv_signed_size_t=yes
1026 fi
1027 rm -f conftest*])
1028 if test $libc_cv_signed_size_t = yes; then
1029   dnl Do this by hand instead of AC_DEFINE so can add #undef to avoid warnings.
1030   cat >> confdefs.h <<\EOF
1031 #undef __SIZE_TYPE__
1032 #define __SIZE_TYPE__ unsigned
1033 EOF
1034 fi
1035
1036 AC_CACHE_CHECK(for libc-friendly stddef.h, libc_cv_friendly_stddef, [dnl
1037 AC_TRY_COMPILE(dnl
1038 [#define __need_size_t
1039 #define __need_wchar_t
1040 #include <stddef.h>
1041 #define __need_NULL
1042 #include <stddef.h>], [size_t size; wchar_t wchar;
1043 #ifdef offsetof
1044 #error stddef.h ignored __need_*
1045 #endif
1046 if (&size == NULL || &wchar == NULL) abort ();],
1047                libc_cv_friendly_stddef=yes,
1048                libc_cv_friendly_stddef=no)])
1049 if test $libc_cv_friendly_stddef = yes; then
1050   config_vars="$config_vars
1051 override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
1052 fi
1053
1054 AC_CACHE_CHECK(whether we need to use -P to assemble .S files,
1055                libc_cv_need_minus_P, [dnl
1056 cat > conftest.S <<EOF
1057 #include "confdefs.h"
1058 /* Nothing whatsoever.  */
1059 EOF
1060 if AC_TRY_COMMAND(${CC-cc} $CPPFLAGS $ASFLAGS -c conftest.S 1>&AS_MESSAGE_LOG_FD); then
1061   libc_cv_need_minus_P=no
1062 else
1063   libc_cv_need_minus_P=yes
1064 fi
1065 rm -f conftest*])
1066 if test $libc_cv_need_minus_P = yes; then
1067   config_vars="$config_vars
1068 asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
1069 fi
1070
1071 AC_MSG_CHECKING(whether .text pseudo-op must be used)
1072 AC_CACHE_VAL(libc_cv_dot_text, [dnl
1073 cat > conftest.s <<EOF
1074 .text
1075 EOF
1076 libc_cv_dot_text=
1077 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1078   libc_cv_dot_text=.text
1079 fi
1080 rm -f conftest*])
1081 if test -z "$libc_cv_dot_text"; then
1082   AC_MSG_RESULT(no)
1083 else
1084   AC_MSG_RESULT(yes)
1085 fi
1086
1087 AC_CACHE_CHECK(for assembler global-symbol directive,
1088                libc_cv_asm_global_directive, [dnl
1089 libc_cv_asm_global_directive=UNKNOWN
1090 for ac_globl in .globl .global .EXPORT; do
1091   cat > conftest.s <<EOF
1092         ${libc_cv_dot_text}
1093         ${ac_globl} foo
1094 foo:
1095 EOF
1096   if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1097     libc_cv_asm_global_directive=${ac_globl}
1098   fi
1099   rm -f conftest*
1100   test $libc_cv_asm_global_directive != UNKNOWN && break
1101 done])
1102 if test $libc_cv_asm_global_directive = UNKNOWN; then
1103   AC_MSG_ERROR(cannot determine asm global directive)
1104 else
1105   AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${libc_cv_asm_global_directive})
1106 fi
1107
1108 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1109 cat > conftest.s <<EOF
1110 ${libc_cv_dot_text}
1111 foo:
1112 .set glibc_conftest_frobozz,foo
1113 $libc_cv_asm_global_directive glibc_conftest_frobozz
1114 EOF
1115 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1116 # (but it doesn't work), so we must do a linking check to be sure.
1117 cat > conftest1.c <<\EOF
1118 extern int glibc_conftest_frobozz;
1119 void _start() { glibc_conftest_frobozz = 1; }
1120 EOF
1121 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1122             -nostartfiles -nostdlib \
1123             -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1124   libc_cv_asm_set_directive=yes
1125 else
1126   libc_cv_asm_set_directive=no
1127 fi
1128 rm -f conftest*])
1129 if test $libc_cv_asm_set_directive = yes; then
1130   AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1131 fi
1132
1133 AC_CACHE_CHECK(for assembler .type directive prefix,
1134                libc_cv_asm_type_prefix, [dnl
1135 libc_cv_asm_type_prefix=no
1136 for ac_try_prefix in '@' '%' '#'; do
1137   cat > conftest.s <<EOF
1138         ${libc_cv_dot_text}
1139         ${libc_cv_asm_global_directive} foo
1140         .type foo, ${ac_try_prefix}object
1141         .size foo, 1
1142 foo:
1143         .byte 1
1144 EOF
1145   if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1146     libc_cv_asm_type_prefix=${ac_try_prefix}
1147   fi
1148   rm -f conftest*
1149   test "x$libc_cv_asm_type_prefix" != xno && break
1150 done])
1151 if test "x$libc_cv_asm_type_prefix" != xno; then
1152   AC_DEFINE_UNQUOTED(ASM_TYPE_DIRECTIVE_PREFIX, ${libc_cv_asm_type_prefix})
1153 fi
1154
1155 AC_CACHE_CHECK(for .symver assembler directive, libc_cv_asm_symver_directive,
1156 [cat > conftest.s <<EOF
1157 ${libc_cv_dot_text}
1158 _sym:
1159 .symver _sym,sym@VERS
1160 EOF
1161 if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1162   libc_cv_asm_symver_directive=yes
1163 else
1164   libc_cv_asm_symver_directive=no
1165 fi
1166 rm -f conftest*])
1167 AC_CACHE_CHECK(for ld --version-script, libc_cv_ld_version_script_option, [dnl
1168 if test $libc_cv_asm_symver_directive = yes; then
1169   cat > conftest.s <<EOF
1170 ${libc_cv_dot_text}
1171 _sym:
1172 .symver _sym,sym@VERS
1173 EOF
1174   cat > conftest.map <<EOF
1175 VERS_1 {
1176         global: sym;
1177 };
1178
1179 VERS_2 {
1180         global: sym;
1181 } VERS_1;
1182 EOF
1183   if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1184     if AC_TRY_COMMAND([${CC-cc} $CFLAGS $LDFLAGS -shared
1185                                 -o conftest.so conftest.o
1186                                 -nostartfiles -nostdlib
1187                                 -Wl,--version-script,conftest.map
1188                        1>&AS_MESSAGE_LOG_FD]);
1189     then
1190       libc_cv_ld_version_script_option=yes
1191     else
1192       libc_cv_ld_version_script_option=no
1193     fi
1194   else
1195     libc_cv_ld_version_script_option=no
1196   fi
1197 else
1198   libc_cv_ld_version_script_option=no
1199 fi
1200 rm -f conftest*])
1201 if test $shared != no &&
1202    test $libc_cv_asm_symver_directive = yes &&
1203    test $libc_cv_ld_version_script_option = yes &&
1204    test $enable_versioning = yes; then
1205   VERSIONING=yes
1206   AC_DEFINE(DO_VERSIONING)
1207 else
1208   VERSIONING=no
1209 fi
1210 AC_SUBST(VERSIONING)
1211
1212 if test $elf = yes && test $shared != no && test $VERSIONING = no; then
1213   echo "\
1214 *** WARNING: You should not compile GNU libc without versioning. Not using
1215 *** versioning will introduce incompatibilities so that old binaries
1216 *** will not run anymore.
1217 *** For versioning you need recent binutils (binutils-2.8.1.0.23 or newer)."
1218 fi
1219 if test $elf = yes; then
1220   AC_CACHE_CHECK(for .previous assembler directive,
1221                  libc_cv_asm_previous_directive, [dnl
1222   cat > conftest.s <<EOF
1223 .section foo_section
1224 .previous
1225 EOF
1226   if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1227     libc_cv_asm_previous_directive=yes
1228   else
1229     libc_cv_asm_previous_directive=no
1230   fi
1231   rm -f conftest*])
1232   if test $libc_cv_asm_previous_directive = yes; then
1233     AC_DEFINE(HAVE_ASM_PREVIOUS_DIRECTIVE)
1234   else
1235     AC_CACHE_CHECK(for .popsection assembler directive,
1236                    libc_cv_asm_popsection_directive, [dnl
1237     cat > conftest.s <<EOF
1238 .pushsection foo_section
1239 .popsection
1240 EOF
1241     if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1242       libc_cv_asm_popsection_directive=yes
1243     else
1244       libc_cv_asm_popsection_directive=no
1245     fi
1246     rm -f conftest*])
1247     if test $libc_cv_asm_popsection_directive = yes; then
1248       AC_DEFINE(HAVE_ASM_POPSECTION_DIRECTIVE)
1249     fi
1250   fi
1251   AC_CACHE_CHECK(for .protected and .hidden assembler directive,
1252                  libc_cv_asm_protected_directive, [dnl
1253   cat > conftest.s <<EOF
1254 .protected foo
1255 foo:
1256 .hidden bar
1257 bar:
1258 EOF
1259   if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
1260     libc_cv_asm_protected_directive=yes
1261   else
1262     AC_MSG_ERROR(assembler support for symbol visibility is required)
1263   fi
1264   rm -f conftest*])
1265
1266   if test $libc_cv_asm_protected_directive = yes; then
1267     AC_CACHE_CHECK(whether __attribute__((visibility())) is supported,
1268                  libc_cv_visibility_attribute,
1269                  [cat > conftest.c <<EOF
1270                   int foo __attribute__ ((visibility ("hidden"))) = 1;
1271                   int bar __attribute__ ((visibility ("protected"))) = 1;
1272 EOF
1273                   libc_cv_visibility_attribute=no
1274                   if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1275                     if grep '\.hidden.*foo' conftest.s >/dev/null; then
1276                       if grep '\.protected.*bar' conftest.s >/dev/null; then
1277                         libc_cv_visibility_attribute=yes
1278                       fi
1279                     fi
1280                   fi
1281                   rm -f conftest.[cs]
1282                  ])
1283     if test $libc_cv_visibility_attribute != yes; then
1284       AC_MSG_ERROR(compiler support for visibility attribute is required)
1285     fi
1286   fi
1287
1288   if test $libc_cv_visibility_attribute = yes; then
1289     AC_CACHE_CHECK(for broken __attribute__((visibility())),
1290                  libc_cv_broken_visibility_attribute,
1291                  [cat > conftest.c <<EOF
1292                   int foo (int x);
1293                   int bar (int x) __asm__ ("foo") __attribute__ ((visibility ("hidden")));
1294                   int bar (int x) { return x; }
1295 EOF
1296                   libc_cv_broken_visibility_attribute=yes
1297                   if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s1>&AS_MESSAGE_LOG_FD); then
1298 changequote(,)dnl
1299                     if grep '\.hidden[  _]foo' conftest.s >/dev/null; then
1300 changequote([,])dnl
1301                       libc_cv_broken_visibility_attribute=no
1302                     fi
1303                   fi
1304                   rm -f conftest.c conftest.s
1305                  ])
1306     if test $libc_cv_broken_visibility_attribute = yes; then
1307       AC_MSG_ERROR(working compiler support for visibility attribute is required)
1308     fi
1309   fi
1310
1311   AC_CACHE_CHECK(for broken __attribute__((alias())),
1312                  libc_cv_broken_alias_attribute,
1313                  [cat > conftest.c <<EOF
1314                   extern int foo (int x) __asm ("xyzzy");
1315                   int bar (int x) { return x; }
1316                   extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1317                   extern int dfoo;
1318                   extern __typeof (dfoo) dfoo __asm ("abccb");
1319                   int dfoo = 1;
1320 EOF
1321                   libc_cv_broken_alias_attribute=yes
1322                   if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1323                     if grep 'xyzzy' conftest.s >/dev/null &&
1324                        grep 'abccb' conftest.s >/dev/null; then
1325                       libc_cv_broken_alias_attribute=no
1326                     fi
1327                   fi
1328                   rm -f conftest.c conftest.s
1329                  ])
1330   if test $libc_cv_broken_alias_attribute = yes; then
1331     AC_MSG_ERROR(working alias attribute support required)
1332   fi
1333
1334   if test $libc_cv_visibility_attribute = yes; then
1335     AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1336                  libc_cv_have_sdata_section,
1337                  [echo "int i;" > conftest.c
1338                   libc_cv_have_sdata_section=no
1339                   if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1340                      | grep '\.sdata' >/dev/null; then
1341                     libc_cv_have_sdata_section=yes
1342                   fi
1343                   rm -f conftest.c conftest.so
1344                  ])
1345     if test $libc_cv_have_sdata_section = yes; then
1346       AC_DEFINE(HAVE_SDATA_SECTION)
1347     fi
1348   fi
1349
1350   AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
1351                  libc_cv_initfini_array, [dnl
1352   cat > conftest.c <<EOF
1353 int _start (void) { return 0; }
1354 int __start (void) { return 0; }
1355 int foo (void) { return 1; }
1356 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
1357 EOF
1358   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -o conftest conftest.c
1359                      -static -nostartfiles -nostdlib 1>&AS_MESSAGE_LOG_FD])
1360   then
1361     if readelf -S conftest | fgrep INIT_ARRAY > /dev/null; then
1362       libc_cv_initfini_array=yes
1363     else
1364       libc_cv_initfini_array=no
1365     fi
1366   else
1367     libc_cv_initfini_array=no
1368   fi
1369   rm -f conftest*])
1370   if test $libc_cv_initfini_array != yes; then
1371     AC_MSG_ERROR([Need linker with .init_array/.fini_array support.])
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 -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)
1389   fi
1390
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; }
1395 EOF
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)
1404   fi
1405   rm -f conftest*])
1406
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; }
1411 EOF
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)
1420   fi
1421   rm -f conftest*])
1422
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; }
1427 EOF
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)
1436   fi
1437   rm -f conftest*])
1438
1439   AC_CACHE_CHECK(for -z relro option,
1440                  libc_cv_z_relro, [dnl
1441   libc_cv_z_relro=no
1442   if AC_TRY_COMMAND([${CC-cc} -v --help 2>&1|grep "z relro" 1>&AS_MESSAGE_LOG_FD])
1443   then
1444     if AC_TRY_COMMAND([${CC-cc} -Wl,--verbose 2>&1|grep DATA_SEGMENT_RELRO_END 1>&AS_MESSAGE_LOG_FD])
1445     then
1446       libc_cv_z_relro=yes
1447     else
1448       case "$base_machine" in
1449         i[34567]86 | x86_64 | powerpc* | s390* | sparc* | alpha*) ;;
1450         *) libc_cv_z_relro="not required" ;;
1451       esac
1452     fi
1453   fi])
1454   if test "$libc_cv_z_relro" = no; then
1455     AC_MSG_ERROR(linker with -z relro support required)
1456   fi
1457
1458   AC_CACHE_CHECK(for -Bgroup option,
1459                  libc_cv_Bgroup, [dnl
1460   cat > conftest.c <<EOF
1461 int _start (void) { return 42; }
1462 EOF
1463   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1464                               -fPIC -shared -o conftest.so conftest.c
1465                               -Wl,-Bgroup -nostdlib 1>&AS_MESSAGE_LOG_FD])
1466   then
1467     libc_cv_Bgroup=yes
1468   else
1469     libc_cv_Bgroup=no
1470   fi
1471   rm -f conftest*])
1472   AC_SUBST(libc_cv_Bgroup)
1473
1474   AC_CACHE_CHECK(for libgcc_s suffix,
1475                  libc_cv_libgcc_s_suffix, [dnl
1476   cat > conftest.c <<EOF
1477 int main (void) { return 0; }
1478 EOF
1479 changequote(,)dnl
1480   libc_cv_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1481                            -fPIC -shared -shared-libgcc -o conftest.so \
1482                            conftest.c -v 2>&1 >/dev/null \
1483                            | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
1484 changequote([,])dnl
1485   rm -f conftest*])
1486   AC_SUBST(libc_cv_libgcc_s_suffix)
1487
1488   AC_CACHE_CHECK(for --as-needed option,
1489                  libc_cv_as_needed, [dnl
1490   cat > conftest.c <<EOF
1491 int main (void) { return 0; }
1492 EOF
1493   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1494                               -fPIC -shared -o conftest.so conftest.c
1495                               -lgcc_s$libc_cv_libgcc_s_suffix -Wl,--as-needed
1496                               -nostdlib 1>&AS_MESSAGE_LOG_FD])
1497   then
1498     libc_cv_as_needed=yes
1499   else
1500     libc_cv_as_needed=no
1501   fi
1502   rm -f conftest*])
1503   AC_SUBST(libc_cv_as_needed)
1504
1505   ASFLAGS_config=
1506   AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1507                  libc_cv_as_noexecstack, [dnl
1508   cat > conftest.c <<EOF
1509 void foo (void) { }
1510 EOF
1511   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1512                      -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1513      && grep -q .note.GNU-stack conftest.s \
1514      && AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wa,--noexecstack
1515                        -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1516   then
1517     libc_cv_as_noexecstack=yes
1518   else
1519     libc_cv_as_noexecstack=no
1520   fi
1521   rm -f conftest*])
1522   if test $libc_cv_as_noexecstack = yes; then
1523     ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1524   fi
1525   AC_SUBST(ASFLAGS_config)
1526
1527   AC_CACHE_CHECK(for -z combreloc,
1528                  libc_cv_z_combreloc, [dnl
1529   cat > conftest.c <<EOF
1530 extern int bar (int);
1531 extern int mumble;
1532 int foo (void) { return bar (mumble); }
1533 EOF
1534   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1535                         -fPIC -shared -o conftest.so conftest.c
1536                         -nostdlib -nostartfiles
1537                         -Wl,-z,combreloc 1>&AS_MESSAGE_LOG_FD])
1538   then
1539 dnl The following test is a bit weak.  We must use a tool which can test
1540 dnl cross-platform since the gcc used can be a cross compiler.  Without
1541 dnl introducing new options this is not easily doable.  Instead use a tool
1542 dnl which always is cross-platform: readelf.  To detect whether -z combreloc
1543 dnl look for a section named .rel.dyn.
1544     if readelf -S conftest.so | grep '\.rel\(a\|\)\.dyn' > /dev/null; then
1545       libc_cv_z_combreloc=yes
1546     else
1547       libc_cv_z_combreloc=no
1548     fi
1549   else
1550     libc_cv_z_combreloc=no
1551   fi
1552   rm -f conftest*])
1553   if test "$libc_cv_z_combreloc" = yes; then
1554     AC_DEFINE(HAVE_Z_COMBRELOC)
1555   fi
1556   AC_SUBST(libc_cv_z_combreloc)
1557
1558   AC_CACHE_CHECK(for -z execstack,
1559                  libc_cv_z_execstack, [dnl
1560   cat > conftest.c <<EOF
1561 int _start (void) { return 42; }
1562 EOF
1563   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1564                               -fPIC -shared -o conftest.so conftest.c
1565                               -Wl,-z,execstack -nostdlib
1566                               1>&AS_MESSAGE_LOG_FD])
1567   then
1568     libc_cv_z_execstack=yes
1569   else
1570     libc_cv_z_execstack=no
1571   fi
1572   rm -f conftest*])
1573   AC_SUBST(libc_cv_z_execstack)
1574
1575   AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1576   cat > conftest.c <<EOF
1577 int foo;
1578 main () { return 0;}
1579 EOF
1580   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fpie
1581                               -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1582   then
1583     libc_cv_fpie=yes
1584   else
1585     libc_cv_fpie=no
1586   fi
1587   rm -f conftest*])
1588
1589   AC_SUBST(libc_cv_fpie)
1590
1591   AC_CACHE_CHECK(for --hash-style option,
1592                  libc_cv_hashstyle, [dnl
1593   cat > conftest.c <<EOF
1594 int _start (void) { return 42; }
1595 EOF
1596   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1597                               -fPIC -shared -o conftest.so conftest.c
1598                               -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
1599   then
1600     libc_cv_hashstyle=yes
1601   else
1602     libc_cv_hashstyle=no
1603   fi
1604   rm -f conftest*])
1605   AC_SUBST(libc_cv_hashstyle)
1606 fi
1607
1608 AC_CACHE_CHECK(for -fno-toplevel-reorder, libc_cv_fno_toplevel_reorder, [dnl
1609 cat > conftest.c <<EOF
1610 int foo;
1611 EOF
1612 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder
1613                             conftest.c 1>&AS_MESSAGE_LOG_FD])
1614 then
1615   libc_cv_fno_toplevel_reorder=yes
1616 else
1617   libc_cv_fno_toplevel_reorder=no
1618 fi
1619 rm -f conftest*])
1620 if test $libc_cv_fno_toplevel_reorder = yes; then
1621   fno_unit_at_a_time=-fno-toplevel-reorder
1622 else
1623   fno_unit_at_a_time=-fno-unit-at-a-time
1624 fi
1625 AC_SUBST(fno_unit_at_a_time)
1626
1627 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
1628 cat > conftest.c <<EOF
1629 int foo;
1630 main () { return 0;}
1631 EOF
1632 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fstack-protector
1633                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1634 then
1635   libc_cv_ssp=yes
1636 else
1637   libc_cv_ssp=no
1638 fi
1639 rm -f conftest*])
1640 AC_SUBST(libc_cv_ssp)
1641
1642 if test $elf != yes; then
1643   AC_CACHE_CHECK(for .init and .fini sections, libc_cv_have_initfini,
1644                  [AC_TRY_COMPILE(, [asm (".section .init");
1645                                     asm (".section .fini");
1646                                     asm ("${libc_cv_dot_text}");],
1647                                  libc_cv_have_initfini=yes,
1648                                  libc_cv_have_initfini=no)])
1649   AC_SUBST(libc_cv_have_initfini)dnl
1650   if test $libc_cv_have_initfini = yes; then
1651     AC_DEFINE(HAVE_INITFINI)
1652   fi
1653 fi
1654
1655 if test $elf = yes; then
1656   AC_CACHE_CHECK(whether cc puts quotes around section names,
1657                  libc_cv_have_section_quotes,
1658                  [cat > conftest.c <<EOF
1659                   static const int foo
1660                   __attribute__ ((section ("bar"))) = 1;
1661 EOF
1662                   if ${CC-cc} -S conftest.c -o conftest.s; then
1663                     if grep '\.section.*"bar"' conftest.s >/dev/null; then
1664                       libc_cv_have_section_quotes=yes
1665                     else
1666                       libc_cv_have_section_quotes=no
1667                     fi
1668                   else
1669                     libc_cv_have_section_quotes=unknown
1670                   fi
1671                   rm -f conftest.[cs]
1672                  ])
1673   if test $libc_cv_have_section_quotes = yes; then
1674     AC_DEFINE(HAVE_SECTION_QUOTES)
1675   fi
1676 fi
1677
1678 dnl AC_CHECK_ASM_UNDERSCORE([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
1679 AC_DEFUN(AC_CHECK_ASM_UNDERSCORE,
1680 [cat > conftest.$ac_ext <<EOF
1681 dnl This sometimes fails to find confdefs.h, for some reason.
1682 dnl [#]line $LINENO "[$]0"
1683 [#]line $LINENO "configure"
1684 #include "confdefs.h"
1685 void underscore_test(void) {
1686 return; }
1687 EOF
1688 if AC_TRY_EVAL(ac_compile); then
1689   if grep _underscore_test conftest* >/dev/null; then
1690     ifelse([$1], , :, [rm -f conftest*
1691     $1])
1692   else
1693     ifelse([$2], , , [rm -f conftest*
1694     $2])
1695   fi
1696 else
1697   echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
1698   cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
1699   ifelse([$2], , , [rm -f conftest*
1700   $2])
1701 fi
1702 rm -f conftest*])
1703
1704 if test $elf = yes; then
1705   libc_cv_asm_underscores=no
1706 else
1707   if test $ac_cv_prog_cc_works = yes; then
1708     AC_CACHE_CHECK(for _ prefix on C symbol names, libc_cv_asm_underscores,
1709                    [AC_TRY_LINK([asm ("_glibc_foobar:");], [glibc_foobar ();],
1710                                 libc_cv_asm_underscores=yes,
1711                                 libc_cv_asm_underscores=no)])
1712   else
1713     AC_CACHE_CHECK(for _ prefix on C symbol names, libc_cv_asm_underscores,
1714                    [AC_CHECK_ASM_UNDERSCORE(libc_cv_asm_underscores=yes,
1715                                             libc_cv_asm_underscores=no)])
1716   fi
1717 fi
1718 if test $libc_cv_asm_underscores = no; then
1719   AC_DEFINE(NO_UNDERSCORES)
1720 fi
1721
1722 if test $elf = yes; then
1723   libc_cv_weak_symbols=yes
1724 fi
1725
1726 AC_CACHE_CHECK(for assembler .weak directive, libc_cv_asm_weak_directive,
1727                [dnl
1728 cat > conftest.s <<EOF
1729 ${libc_cv_dot_text}
1730 ${libc_cv_asm_global_directive} foo
1731 foo:
1732 .weak foo
1733 .weak bar; bar = foo
1734 EOF
1735 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1736   libc_cv_asm_weak_directive=yes
1737 else
1738   libc_cv_asm_weak_directive=no
1739 fi
1740 rm -f conftest*])
1741
1742 if test $libc_cv_asm_weak_directive = no; then
1743   AC_CACHE_CHECK(for assembler .weakext directive,
1744                  libc_cv_asm_weakext_directive,
1745                  [dnl
1746 cat > conftest.s <<EOF
1747 ${libc_cv_dot_text}
1748 ${libc_cv_asm_global_directive} foo
1749 foo:
1750 .weakext bar foo
1751 .weakext baz
1752 ${libc_cv_asm_global_directive} baz
1753 baz:
1754 EOF
1755   if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1756     libc_cv_asm_weakext_directive=yes
1757   else
1758     libc_cv_asm_weakext_directive=no
1759   fi
1760   rm -f conftest*])
1761
1762 fi # no .weak
1763
1764 if test $libc_cv_asm_weak_directive = yes; then
1765   AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE)
1766 elif test $libc_cv_asm_weakext_directive = yes; then
1767   AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
1768 fi
1769
1770 AC_CACHE_CHECK(whether CFI directives are supported, libc_cv_asm_cfi_directives, [dnl
1771 case $machine in
1772   sparc/sparc64*) cfi_offset=2047;;
1773   *) cfi_offset=0;;
1774 esac
1775 cat > conftest.s <<EOF
1776         .text
1777         .type   func,%function
1778 func:
1779         .cfi_startproc
1780         .cfi_remember_state
1781         .cfi_rel_offset 1, $cfi_offset
1782         .cfi_endproc
1783 EOF
1784 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
1785   libc_cv_asm_cfi_directives=yes
1786 else
1787   libc_cv_asm_cfi_directives=no
1788 fi
1789 rm -f conftest*])
1790 if test $libc_cv_asm_cfi_directives = yes; then
1791   AC_DEFINE(HAVE_ASM_CFI_DIRECTIVES)
1792 fi
1793
1794 AC_CACHE_CHECK(for ld --no-whole-archive, libc_cv_ld_no_whole_archive, [dnl
1795 cat > conftest.c <<\EOF
1796 _start () {}
1797 int __eh_pc;
1798 __throw () {}
1799 EOF
1800 dnl No \ in command here because it ends up inside ''.
1801 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1802                             -nostdlib -nostartfiles -Wl,--no-whole-archive
1803                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
1804   libc_cv_ld_no_whole_archive=yes
1805 else
1806   libc_cv_ld_no_whole_archive=no
1807 fi
1808 rm -f conftest*])
1809 if test $libc_cv_ld_no_whole_archive = yes; then
1810   no_whole_archive=-Wl,--no-whole-archive
1811 fi
1812 AC_SUBST(no_whole_archive)dnl
1813
1814 AC_CACHE_CHECK(for gcc -fexceptions, libc_cv_gcc_exceptions, [dnl
1815 cat > conftest.c <<\EOF
1816 _start () {}
1817 int __eh_pc;
1818 __throw () {}
1819 EOF
1820 dnl No \ in command here because it ends up inside ''.
1821 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1822                             -nostdlib -nostartfiles -fexceptions
1823                             -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then
1824   libc_cv_gcc_exceptions=yes
1825 else
1826   libc_cv_gcc_exceptions=no
1827 fi
1828 rm -f conftest*])
1829 if test $libc_cv_gcc_exceptions = yes; then
1830   exceptions=-fexceptions
1831 fi
1832 AC_SUBST(exceptions)dnl
1833
1834 if test "$host_cpu" = powerpc ; then
1835 # Check for a bug present in at least versions 2.8.x of GCC
1836 # and versions 1.0.x of EGCS.
1837 AC_CACHE_CHECK(whether clobbering cr0 causes problems,libc_cv_c_asmcr0_bug,[dnl
1838 AC_TRY_COMPILE([int tester(int x) { asm ("" : : : "cc"); return x & 123; }],,
1839                libc_cv_c_asmcr0_bug='no',
1840                libc_cv_c_asmcr0_bug='yes')])
1841 if test "$libc_cv_c_asmcr0_bug" != 'no'; then
1842   AC_DEFINE(BROKEN_PPC_ASM_CR0)
1843 fi
1844 fi
1845
1846 dnl Check whether compiler understands __builtin_expect.
1847 AC_CACHE_CHECK(for __builtin_expect, libc_cv_gcc_builtin_expect,
1848 [cat > conftest.c <<EOF
1849 #line $LINENO "configure"
1850 int foo (int a)
1851 {
1852   a = __builtin_expect (a, 10);
1853   return a == 10 ? 0 : 1;
1854 }
1855 EOF
1856 dnl No \ in command here because it ends up inside ''.
1857 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles
1858                             -o conftest conftest.c -lgcc >&AS_MESSAGE_LOG_FD]); then
1859   libc_cv_gcc_builtin_expect=yes
1860 else
1861   libc_cv_gcc_builtin_expect=no
1862 fi
1863 rm -f conftest*])
1864 if test "$libc_cv_gcc_builtin_expect" = yes; then
1865   AC_DEFINE(HAVE_BUILTIN_EXPECT)
1866 fi
1867
1868 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1869 cat > conftest.c <<\EOF
1870 void zero (void *x)
1871 {
1872   __builtin_memset (x, 0, 1000);
1873 }
1874 EOF
1875 dnl
1876 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "memset" > /dev/null]);
1877 then
1878   libc_cv_gcc_builtin_memset=no
1879 else
1880   libc_cv_gcc_builtin_memset=yes
1881 fi
1882 rm -f conftest* ])
1883 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1884   AC_DEFINE(HAVE_BUILTIN_MEMSET)
1885 fi
1886
1887 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1888 cat > conftest.c <<\EOF
1889 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1890 char *foo (const char *a, const char *b)
1891 {
1892   return __builtin_strstr (a, b);
1893 }
1894 EOF
1895 dnl
1896 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "my_strstr" > /dev/null]);
1897 then
1898   libc_cv_gcc_builtin_redirection=yes
1899 else
1900   libc_cv_gcc_builtin_redirection=no
1901 fi
1902 rm -f conftest* ])
1903 if test "$libc_cv_gcc_builtin_redirection" = yes ; then
1904   AC_DEFINE(HAVE_BUILTIN_REDIRECTION)
1905 fi
1906
1907 dnl Check whether the compiler supports the __thread keyword.
1908 if test "x$use__thread" != xno; then
1909   AC_CACHE_CHECK([for __thread], libc_cv_gcc___thread,
1910   [cat > conftest.c <<\EOF
1911 __thread int a = 42;
1912 EOF
1913   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
1914     libc_cv_gcc___thread=yes
1915   else
1916     libc_cv_gcc___thread=no
1917   fi
1918   rm -f conftest*])
1919   if test "$libc_cv_gcc___thread" = yes; then
1920     AC_DEFINE(HAVE___THREAD)
1921   fi
1922 else
1923   libc_cv_gcc___thread=no
1924 fi
1925
1926 if test "$libc_cv_gcc___thread" = yes; then
1927   dnl Check whether the compiler supports the tls_model attribute.
1928   AC_CACHE_CHECK([for tls_model attribute], libc_cv_gcc_tls_model_attr, [dnl
1929   cat > conftest.c <<\EOF
1930 extern __thread int a __attribute__((tls_model ("initial-exec")));
1931 EOF
1932   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -Werror conftest.c >&AS_MESSAGE_LOG_FD]); then
1933     libc_cv_gcc_tls_model_attr=yes
1934   else
1935     libc_cv_gcc_tls_model_attr=no
1936   fi
1937   rm -f conftest*])
1938   if test "$libc_cv_gcc_tls_model_attr" = yes; then
1939     AC_DEFINE(HAVE_TLS_MODEL_ATTRIBUTE)
1940   fi
1941 fi
1942
1943 dnl Check whether we have the gd library available.
1944 AC_MSG_CHECKING(for libgd)
1945 if test "$with_gd" != "no"; then
1946   old_CFLAGS="$CFLAGS"
1947   CFLAGS="$CFLAGS $libgd_include"
1948   old_LDFLAGS="$LDFLAGS"
1949   LDFLAGS="$LDFLAGS $libgd_ldflags"
1950   old_LIBS="$LIBS"
1951   LIBS="$LIBS -lgd -lpng -lz -lm"
1952   AC_TRY_LINK([#include <gd.h>], [gdImagePng (0, 0)], LIBGD=yes, LIBGD=no)
1953   CFLAGS="$old_CFLAGS"
1954   LDFLAGS="$old_LDFLAGS"
1955   LIBS="$old_LIBS"
1956 else
1957   LIBGD=no
1958 fi
1959 AC_MSG_RESULT($LIBGD)
1960 AC_SUBST(LIBGD)
1961
1962 # SELinux detection
1963 if test x$with_selinux = xno ; then
1964   have_selinux=no;
1965 else
1966   # See if we have the SELinux library
1967   AC_CHECK_LIB(selinux, is_selinux_enabled,
1968                have_selinux=yes, have_selinux=no)
1969   # See if we have the SELinux header with the NSCD permissions in it.
1970   if test x$have_selinux = xyes ; then
1971     AC_MSG_CHECKING([for NSCD Flask permissions in selinux/av_permissions.h])
1972     AC_TRY_COMPILE([#include <selinux/av_permissions.h>],
1973                     [#ifdef NSCD__SHMEMHOST
1974                      return 0;
1975                      #else
1976                      #error NSCD__SHMEMHOST not defined
1977                      #endif],
1978                     have_selinux=yes, have_selinux=no)
1979     AC_MSG_RESULT($have_selinux)
1980   fi
1981
1982   if test x$with_selinux = xyes ; then
1983     if test x$have_selinux = xno ; then
1984       AC_MSG_ERROR([SELinux explicitly required, but sufficiently recent SELinux library not found])
1985     fi
1986   fi
1987 fi
1988 # Check if we're building with SELinux support.
1989 if test "x$have_selinux" = xyes; then
1990   AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1991
1992   # See if we have the libaudit library
1993   AC_CHECK_LIB(audit, audit_log_user_avc_message,
1994                have_libaudit=yes, have_libaudit=no)
1995   if test "x$have_libaudit" = xyes; then
1996     AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1997   fi
1998   AC_SUBST(have_libaudit)
1999
2000   # See if we have the libcap library
2001   AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
2002   if test "x$have_libcap" = xyes; then
2003     AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
2004   fi
2005   AC_SUBST(have_libcap)
2006 fi
2007 AC_SUBST(have_selinux)
2008
2009 dnl check for the size of 'long double'.
2010 AC_CHECK_SIZEOF(long double, 0)
2011 sizeof_long_double=$ac_cv_sizeof_long_double
2012 AC_SUBST(sizeof_long_double)
2013
2014 ### End of automated tests.
2015 ### Now run sysdeps configure fragments.
2016
2017 # They also can set these variables.
2018 use_ldconfig=no
2019 ldd_rewrite_script=no
2020 libc_cv_sysconfdir=$sysconfdir
2021 libc_cv_gcc_unwind_find_fde=no
2022 libc_cv_idn=no
2023
2024 # Iterate over all the sysdep directories we will use, running their
2025 # configure fragments, and looking for a uname implementation.
2026 uname=
2027 for dir in $sysnames; do
2028   case $dir in
2029     /*) dest=$dir ;;
2030     *)  dest=$srcdir/$dir ;;
2031   esac
2032   if test -r $dest/configure; then
2033     AC_MSG_RESULT(running configure fragment for $dir)
2034     . $dest/configure
2035   fi
2036 [
2037   if test -z "$uname"; then
2038     if test -r $dest/uname.c ||
2039        test -r $dest/uname.S ||
2040        { test -r $dest/syscalls.list &&
2041          grep '^uname[  ]' $dest/syscalls.list >/dev/null; }; then
2042       uname=$dir
2043     fi
2044   fi
2045 ]dnl
2046 done
2047
2048 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
2049   AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
2050 fi
2051 AC_SUBST(libc_cv_gcc_unwind_find_fde)
2052
2053 # If we will use the generic uname implementation, we must figure out what
2054 # it will say by examining the system, and write the results in config-name.h.
2055 if test "$uname" = "sysdeps/generic"; then
2056
2057 changequote(,)dnl
2058   uname_sysname=`echo $config_os | sed 's/[0-9.]*$//'`
2059 changequote([,])dnl
2060   if test $uname_sysname != $config_os; then
2061     config_release=`echo $config_os | sed s/$uname_sysname//`
2062   fi
2063 dnl
2064 AC_DEFUN(LIBC_KERNEL_ID, [dnl
2065     if test -r /vmunix; then
2066       kernel_id=`strings /vmunix | grep UNIX`
2067     elif test -r /dynix; then
2068       kernel_id=`strings /dynix | grep DYNIX`
2069     else
2070       kernel_id=
2071     fi
2072 ])dnl
2073
2074   AC_CACHE_CHECK(OS release for uname, libc_cv_uname_release, [dnl
2075 LIBC_KERNEL_ID
2076 changequote(,)dnl
2077   kernel_release=`echo "$kernel_id" | sed 's/^[^0-9.]*\([0-9.]*\).*$/\1/'`
2078 changequote([,])dnl
2079   if test x`echo "$config_release" | sed "s/^$kernel_release//"` \
2080          != x$config_release; then
2081     # The configuration release is a substring of the kernel release.
2082     libc_cv_uname_release=$kernel_release
2083   elif test x$config_release != x; then
2084     libc_cv_uname_release=$config_release
2085   elif test x$kernel_release != x; then
2086     libc_cv_uname_release=$kernel_release
2087   else
2088     libc_cv_uname_release=unknown
2089   fi])
2090   uname_release="$libc_cv_uname_release"
2091
2092   AC_CACHE_CHECK(OS version for uname, libc_cv_uname_version, [dnl
2093 LIBC_KERNEL_ID
2094 changequote(,)dnl
2095   kernel_version=`echo "$kernel_id" | sed 's/^[^#]*#\([0-9]*\).*$/\1/'`
2096 changequote([,])dnl
2097   if test -n "$kernel_version"; then
2098     libc_cv_uname_version="$kernel_version"
2099   else
2100     libc_cv_uname_version=unknown
2101   fi])
2102   uname_version="$libc_cv_uname_version"
2103
2104 AC_SUBST(uname_sysname) AC_SUBST(uname_release) AC_SUBST(uname_version)dnl
2105   config_uname=config-name.h:config-name.in
2106 else
2107   # For non-generic uname, we don't need to create config-name.h at all.
2108   config_uname=
2109 fi
2110
2111 dnl This is tested by existing code and it's simpler to avoid changing it.
2112 AC_DEFINE(USE_IN_LIBIO)
2113
2114 # Test for old glibc 2.0.x headers so that they can be removed properly
2115 # Search only in includedir.
2116 AC_MSG_CHECKING(for old glibc 2.0.x headers)
2117 if eval test -f "${includedir}/elfclass.h" -a -f "${includedir}/fcntlbits.h"
2118 then
2119   old_glibc_headers=yes
2120 else
2121   old_glibc_headers=no
2122 fi
2123 AC_MSG_RESULT($old_glibc_headers)
2124 if test ${old_glibc_headers} = yes; then
2125   AC_MSG_WARN(*** During \"make install\" old headers from glibc 2.0.x will)
2126   AC_MSG_WARN(*** be removed.)
2127 fi
2128 AC_SUBST(old_glibc_headers)
2129
2130 AC_SUBST(libc_cv_slibdir)
2131 AC_SUBST(libc_cv_localedir)
2132 AC_SUBST(libc_cv_sysconfdir)
2133 AC_SUBST(libc_cv_rootsbindir)
2134 AC_SUBST(libc_cv_forced_unwind)
2135
2136 AC_SUBST(use_ldconfig)
2137 AC_SUBST(ldd_rewrite_script)
2138
2139 AC_SUBST(elf) AC_SUBST(xcoff)
2140 if test $elf = yes; then
2141   AC_DEFINE(HAVE_ELF)
2142 fi
2143 if test $xcoff = yes; then
2144   AC_DEFINE(HAVE_XCOFF)
2145 fi
2146
2147 AC_SUBST(static)
2148 AC_SUBST(shared)
2149 if test $shared = default; then
2150   shared=$elf
2151 fi
2152
2153 AC_CACHE_CHECK([whether -fPIC is default], pic_default,
2154 [pic_default=yes
2155 cat > conftest.c <<EOF
2156 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
2157 # error PIC is default.
2158 #endif
2159 EOF
2160 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
2161   pic_default=no
2162 fi
2163 rm -f conftest.*])
2164 AC_SUBST(pic_default)
2165
2166 AC_SUBST(profile)
2167 AC_SUBST(omitfp)
2168 AC_SUBST(bounded)
2169 AC_SUBST(static_nss)
2170 AC_SUBST(nopic_initfini)
2171
2172 AC_SUBST(DEFINES)
2173
2174 dnl See sysdeps/mach/configure.in for this variable.
2175 AC_SUBST(mach_interface_list)
2176
2177 if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
2178   config_makefile=
2179 else
2180   config_makefile=Makefile
2181 fi
2182
2183 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
2184 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
2185 AC_SUBST(VERSION)
2186 AC_SUBST(RELEASE)
2187
2188 AC_CONFIG_FILES([config.make ${config_makefile} ${config_uname}])
2189 AC_CONFIG_COMMANDS([default],[[
2190 case $CONFIG_FILES in *config.make*)
2191 echo "$config_vars" >> config.make;;
2192 esac
2193 test -d bits || mkdir bits]],[[config_vars='$config_vars']])
2194 AC_OUTPUT