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