]> sourceware.org Git - glibc.git/blobdiff - Makerules
Add GLIBC_2.3.4.
[glibc.git] / Makerules
index 984a8ada1599f5dd814ca29b84fe807b164c1d15..7e955b657d9d47bcab7e80347e3a8e4bd5126239 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -1,20 +1,20 @@
-# Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
+# Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
 
 # The GNU C Library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Library General Public License for more details.
+# Lesser General Public License for more details.
 
-# You should have received a copy of the GNU Library General Public
-# License along with the GNU C Library; see the file COPYING.LIB.  If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
 
 #
 #      Common rules for making the GNU C library.  This file is included
@@ -57,13 +57,13 @@ include $(..)Makeconfig
 endif
 
 # `configure' writes a definition of `config-sysdirs' in `config.make'.
-sysdirs = $(strip $(full-config-sysdirs))
+sysdirs = $(strip $(full_config_sysdirs))
 
 +sysdir_pfx = $(common-objpfx)
 
 export sysdirs := $(sysdirs)
 
-+sysdep_dirs := $(full-config-sysdirs)
++sysdep_dirs := $(full_config_sysdirs)
 ifdef objdir
 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
 endif
@@ -94,28 +94,9 @@ vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
 # being included individually by a subdir makefile (hurd/Makefile needs this).
 in-Makerules := yes
 
--include $(+sysdir_pfx)sysd-Makefile
-ifndef avoid-generated
-ifneq ($(sysd-Makefile-sysdirs),$(config-sysdirs))
-sysd-Makefile-force = FORCE
-FORCE:
-endif
-$(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)config.make $(..)Makerules \
-                            $(sysd-Makefile-force)
-       -@rm -f $@T
-       (echo 'sysd-Makefile-sysdirs := $(config-sysdirs)';                   \
-        for file in $(config-sysdirs:=/Makefile); do                         \
-          if [ -f $(..)$$file ]; then                                        \
-            echo include "\$$(..)$$file";                                    \
-          else true; fi;                                                     \
-        done;                                                                \
-        echo 'sysd-Makefile-done=t') > $@T
-       mv -f $@T $@
-endif
-
-ifndef sysd-Makefile-done
-# Don't do deps until this exists, because it might change the sources list.
-no_deps=t
+sysdep-makefiles := $(wildcard $(full_config_sysdirs:=/Makefile))
+ifneq (,$(sysdep-makefiles))
+include $(sysdep-makefiles)
 endif
 
 
@@ -128,6 +109,31 @@ before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
                  $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
                               $(before-compile))
 
+# Even before that, we need abi-versions.h which is generated right here.
+ifeq ($(versioning),yes)
+ifndef avoid-generated
+before-compile := $(common-objpfx)abi-versions.h $(before-compile)
+$(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
+                               $(common-objpfx)Versions.all
+       LC_ALL=C $(AWK) -v oldest_abi=$(oldest-abi) -f $^ > $@T
+       mv -f $@T $@
+
+$(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
+       sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
+           $(common-objpfx)abi-versions.h > $@T
+       mv -f $@T $@
+endif # avoid-generated
+endif # $(versioning) = yes
+
+# Make sure the subdirectory for object files gets created.
+ifdef objpfx
+ifeq (,$(wildcard $(objpfx).))
+before-compile += $(objpfx).
+$(objpfx).:
+       $(make-target-directory)
+endif
+endif
+
 # Remove existing files from `before-compile'.  Things are added there when
 # they must exist for dependency generation to work right, but once they
 # exist there is no further need for every single file to depend on them,
@@ -139,6 +145,62 @@ before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
 ifdef before-compile
 $(before-compile):
 endif
+
+# We don't want $(common-objpfx) files to depend on miscellaneous stuff
+# in subdirs.
+ifdef subdir
+common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
+else
+common-before-compile = $(before-compile)
+endif
+
+ifndef subdir
+# If a makefile needs to do something conditional on something that
+# can only be figured out from headers, write a FOO.make.c input
+# file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
+# to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
+#
+# We only generate these in the top-level makefile, to avoid any weirdness
+# from subdir-specific makefile tweaks creeping in on an update.
+$(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
+       rm -f $@T $@.dT
+       (echo '# Generated from $*.make.c by Makerules.'; \
+        $(CC) $(CFLAGS) $(CPPFLAGS) -E $< \
+              -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
+        | sed -n '/@@@/{s/@@@[  ]*\(.*\)@@@/\1/;s/[     ]*$$//p;}'; \
+        echo 'common-generated += $(@F)'; \
+        sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
+        rm -f $@.dT) > $@T
+       mv -f $@T $@
+endif
+
+ifdef subdir
+sed-remove-dotdot := -e 's@  *\.\.\/\([^       \]*\)@ $$(..)\1@g' \
+                    -e 's@^\.\.\/\([^  \]*\)@$$(..)\1@g'
+else
+sed-remove-dotdot := -e 's@  *\([^     \/$$][^         \]*\)@ $$(..)\1@g' \
+                    -e 's@^\([^        \/$$][^         \]*\)@$$(..)\1@g'
+endif
+
+
+# Generating headers for assembly constants.
+# We need this defined early to get into before-compile before
+# it's used in sysd-rules, below.
+$(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
+                                          %.sym $(common-before-compile)
+       $(AWK) -f $< $(filter %.sym,$^) \
+       | $(CC) -S -o $(@:.h.d=.h)T3 $(CFLAGS) $(CPPFLAGS) -x c - \
+               -MD -MP -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)'
+       sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' \
+               $(@:.h.d=.h)T3 > $(@:.h.d=.h)T
+       rm -f $(@:.h.d=.h)T3
+       sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
+           $(@:.h=.h.d)T > $(@:.h=.h.d)T2
+       rm -f $(@:.h=.h.d)T
+       mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
+       mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
+vpath %.sym $(sysdirs)
+before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
 \f
 # Generate an ordered list of implicit rules which find the source files in
 # each sysdep directory.  The old method was to use vpath to search all the
@@ -146,15 +208,6 @@ endif
 # later directory would be chosen over a .c file in an earlier directory,
 # which does not preserve the desired sysdeps ordering behavior.
 
-# When making the list of .d files to include, we can't know which ones
-# have source in .s files, and thus do not in fact need a .d file.
-# So we must define rules to make .d files for .s files.
-define make-dummy-dep
-$(addprefix ln $(common-objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
-endef
-$(common-objpfx)dummy.d:
-       echo '# .s files cannot contain includes, so they need no deps.' > $@
-
 # It matters that this set of rules, for compiling from sources in
 # the current directory (the $srcdir/$subdir) come before the
 # generated sysdep rules in included from sysd-rules below.  When
@@ -165,21 +218,18 @@ $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
 endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
-$(objpfx)%.d: %.S $(before-compile); $(+make-deps)
 
 define o-iterator-doit
 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
 endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
-$(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep)
 
 define o-iterator-doit
 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
 endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
-$(objpfx)%.d: %.c $(before-compile); $(+make-deps)
 
 # Omit the objpfx rules when building in the source tree, because
 # objpfx is empty and so these rules just override the ones above.
@@ -191,21 +241,18 @@ $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
 endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
-$(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps)
 
 define o-iterator-doit
 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
 endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
-$(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep)
 
 define o-iterator-doit
 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
 endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
-$(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps)
 endif
 
 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
@@ -218,10 +265,6 @@ endef
 close-check-inhibit-asm = ;; esac ;
 endif
 
-# Don't include sysd-rules until sysd-Makefile is already there and has been
-# included.  It might define inhibit-sysdep-asm, which would affect the
-# contents of sysd-rules.
-ifdef sysd-Makefile-done
 -include $(+sysdir_pfx)sysd-rules
 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
 # The value of $(+sysdep_dirs) the sysd-rules was computed for
@@ -229,7 +272,6 @@ ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
 sysd-rules-force = FORCE
 FORCE:
 endif
-endif
 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
                          $(wildcard $(foreach dir,$(sysdirs),\
                                               $(dir)/Makefile))\
@@ -242,19 +284,25 @@ $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
             echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
                  \$$(compile-command.S)";                                    \
             echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
-                 \$$(compile-command.s)";                                    \
+                 \$$(compile-command.s)";                                    \
+            echo "\$$(objpfx)rtld-%$$o: $$dir/%.S \$$(before-compile); \
+                 \$$(compile-command.S)";                                    \
+            echo "\$$(objpfx)rtld-%$$o: $$dir/%.s \$$(before-compile); \
+                 \$$(compile-command.s)";                                    \
+            echo "\$$(objpfx)ptw-%$$o: $$dir/%.S \$$(before-compile); \
+                 \$$(compile-command.S)";                                    \
+            echo "\$$(objpfx)ptw-%$$o: $$dir/%.s \$$(before-compile); \
+                 \$$(compile-command.s)";                                    \
             $(close-check-inhibit-asm) \
             echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
                  \$$(compile-command.c)";                                    \
+            echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \
+                 \$$(compile-command.c)";                                    \
+            echo "\$$(objpfx)ptw-%$$o: $$dir/%.c \$$(before-compile); \
+                 \$$(compile-command.c)";                                    \
           done; \
-          $(open-check-inhibit-asm) \
-          echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
-               \$$(make-dummy-dep)";                          \
-          echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
-               \$$(+make-deps)";                                             \
-          $(close-check-inhibit-asm)   \
-          echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \
-               \$$(+make-deps)";                                             \
+          echo "\$$(objpfx)m_%.S: $$dir/s_%.S; \$$(+make-include-of-dep)";   \
+          echo "\$$(objpfx)m_%.c: $$dir/s_%.c; \$$(+make-include-of-dep)";   \
         done;                                                                \
         echo 'sysd-rules-done = t') > $@T
        mv -f $@T $@
@@ -264,54 +312,69 @@ ifndef sysd-rules-done
 no_deps=t
 endif
 
+# This is used by the m_%.[Sc] pattern rules in sysd-rules.
+define +make-include-of-dep
+echo '#include <$<>' > $@T
+mv -f $@T $@
+endef
+
 # Generate version maps, but wait until sysdep-subdirs is known
-ifdef sysd-dirs-done
+ifeq ($(sysd-sorted-done),t)
 ifeq ($(versioning),yes)
 -include $(common-objpfx)sysd-versions
 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
-common-generated += $(version-maps) sysd-versions
+common-generated += $(version-maps)
+postclean-generated += sysd-versions Versions.all abi-versions.h \
+                      Versions.def.v.i Versions.def.v Versions.v.i Versions.v
 
 ifndef avoid-generated
 ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
 sysd-versions-force = FORCE
 FORCE:
 endif
-$(common-objpfx)Versions.all: $(..)Versions.def \
-                             $(wildcard $(add-ons:%=$(..)%/Versions.def))
-       cat $^ > $@T
+# See %.v/%.v.i implicit rules in Makeconfig.
+$(common-objpfx)Versions.def.v.i: $(..)Versions.def \
+                                 $(wildcard $(add-ons:%=$(..)%/Versions.def))
+$(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
+                             $(common-objpfx)soversions.i \
+                             $(common-objpfx)Versions.def.v
+       { while read lib version setname; do \
+           test -z "$$setname" || echo "$$lib : $$setname"; \
+         done < $(word 2,$^); \
+         cat $(word 3,$^); \
+       } | LC_ALL=C $(AWK) -f $< > $@T
        mv -f $@T $@
-common-generated += $(common-objpfx)Versions.all
+# See %.v/%.v.i implicit rules in Makeconfig.
+$(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
+                             $(wildcard $(sysdirs:%=%/Versions)) \
+                             $(common-objpfx)abi-versions.h \
+                             $(sysd-versions-force)
 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
-                              $(..)scripts/versions.awk \
-                              $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
-                              $(wildcard $(sysdirs:%=%/Versions)) \
-                              $(sysd-versions-force)
-       { echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
-         $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
-                -v move_if_change='$(move-if-change)' \
-                -f $(filter-out $< $(sysd-versions-force),$^); \
-       } > $@T
+                              $(common-objpfx)Versions.v \
+                              $(..)scripts/versions.awk
+       ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
+         cat $(word 2,$^) \
+         | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
+                           -v move_if_change='$(move-if-change)' \
+                           -f $(word 3,$^); \
+       ) > $@T
        mv -f $@T $@
 endif # avoid-generated
 endif # $(versioning) = yes
-endif # sysd-dirs-done
+endif # sysd-sorted-done
 
-ifndef compile-command.S
-compile-command.S = $(compile.S) $(OUTPUT_OPTION)
-endif
-ifndef compile-command.s
-compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION)
-endif
-ifndef compile-command.c
-compile-command.c = $(compile.c) $(OUTPUT_OPTION)
-endif
+# Generate .dT files as we compile.
+compile-mkdep-flags = -MD -MP -MF $@.dt
+compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
+compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) $(compile-mkdep-flags)
+compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
 
 # GCC can grok options after the file name, and it looks nicer that way.
 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
-compile.S = \
-  $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
-COMPILE.S = \
-  $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
+compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
+                 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
+COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
+                 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
 
 # We need this for the output to go in the right place.  It will default to
@@ -319,16 +382,20 @@ COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
 # together.  You can't compile the C library with such a compiler.
 OUTPUT_OPTION = -o $@
 
-S-CPPFLAGS = $(asm-CPPFLAGS)
+# We need the $(CFLAGS) to be in there to have the right predefines during
+# the dependency run for C sources.  But having it for assembly sources can
+# get the wrong predefines.
+S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
+
 define +make-deps
 $(make-target-directory)
--@rm -f $@
-$(+mkdep) $< $(CFLAGS) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
-sed \
--e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
-$(sed-remove-objpfx) > $(@:.d=.T)
-mv -f $(@:.d=.T) $@
+$(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
+            $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
+'s,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
+$(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
+mv -f $(@:.d=.T) $@ $(generate-md5)
 endef
+
 ifneq (,$(objpfx))
 # Continuation lines here are dangerous because they introduce spaces!
 define sed-remove-objpfx
@@ -337,6 +404,30 @@ define sed-remove-objpfx
 endef
 endif
 \f
+# Modify the list of routines we build for different targets
+
+ifeq (yesyes,$(build-shared)$(elf))
+ifndef libc.so-version
+# Undefine this because it can't work when we libc.so is unversioned.
+static-only-routines =
+endif
+endif
+
+# Bounded pointer thunks are only built for *.ob
+elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
+
+elide-routines.oS += $(filter-out $(static-only-routines),\
+                                 $(routines) $(aux) $(sysdep_routines)) \
+                    $(elide-bp-thunks)
+elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
+
+# If we have versioned code we don't need the old versions in any of the
+# static libraries.
+elide-routines.o  += $(shared-only-routines) $(elide-bp-thunks)
+elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
+elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
+elide-routines.ob += $(shared-only-routines)
+\f
 # Shared library building.
 
 ifeq (yes,$(build-shared))
@@ -356,46 +447,135 @@ endif
 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
 # on other shared objects.
 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
+ifneq (,$(findstring aix,$(config-os)))
+       (echo '#!'; \
+        dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
+endif
        $(build-shlib)
 
-define build-shlib
-$(LINK.o) -shared -Wl,-O1 -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS)  \
-         -B$(csu-objpfx) $(load-map-file) \
+ifeq ($(elf),yes)
+define build-shlib-helper
+$(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
+         $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(config-LDFLAGS) \
+         $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
+         $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
          -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
          $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
-         -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
-         -Wl,--whole-archive \
-         $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
-         $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
+         -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
+endef
+else
+ifneq (,$(findstring aix,$(config-os)))
+define build-shlib-helper
+$(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
+         $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
+         $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
+         $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
+         -L$(subst :, -L,$(rpath-link))
+endef
+else
+endif
+endif
+
+ifeq (yes,$(elf))
+# binutils only position loadable notes into the first page for binaries,
+# not for shared objects
+$(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
+       $(LINK.o) -shared -Wl,-O1 \
+                 -nostdlib -nostartfiles \
+                 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
+                 -Wl,--verbose 2>&1 | \
+         sed > $@T \
+             -e '/^=========/,/^=========/!d;/^=========/d' \
+             -e 's/^.*\.hash[  ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+             -e 's/^.*\*(\.dynbss).*$$/& \
+                PROVIDE(__start___libc_freeres_ptrs = .); \
+                *(__libc_freeres_ptrs) \
+                PROVIDE(__stop___libc_freeres_ptrs = .);/'\
+             -e 's/^.*\*(\.jcr).*$$/&\n\
+                PROVIDE(__start___libc_subfreeres = .);\n\
+                __libc_subfreeres : { *(__libc_subfreeres) }\n\
+                PROVIDE(__stop___libc_subfreeres = .);\n\
+                PROVIDE(__start___libc_atexit = .);\n\
+                __libc_atexit : { *(__libc_atexit) }\n\
+                PROVIDE(__stop___libc_atexit = .);\n\
+                PROVIDE(__start___libc_thread_subfreeres = .);\n\
+                __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\n\
+                PROVIDE(__stop___libc_thread_subfreeres = .);/'
+       mv -f $@T $@
+common-generated += shlib.lds
+
+define build-shlib
+$(build-shlib-helper) -o $@ -T $(common-objpfx)shlib.lds \
+         $(csu-objpfx)abi-note.o $(build-shlib-objlist)
+endef
+else
+ifneq (,$(findstring aix,$(config-os)))
+define build-shlib
+$(build-shlib-helper) \
+       -o $@ \
+       $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
+       $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
+endef
+define build-shlib
+$(build-shlib-helper) \
+         $(build-shlib-objlist)
+endef
+endif
+endif
+
+ifneq (,$(findstring aix,$(config-os)))
+define build-module-helper
+$(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
+         $(sysdep-LDFLAGS) $(config-LDFLAGS) \
+         $(load-map-file) \
+         $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
+         -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
 endef
+else
+define build-module-helper
+$(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
+         $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
+         -B$(csu-objpfx) $(load-map-file) \
+         $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
+         -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
+endef
+endif
 
 # This macro is similar to build-shlib but it does not define a soname
 # and it does not depend on the destination name to start with `lib'.
+ifeq (yes,$(elf))
+# binutils only position loadable notes into the first page for binaries,
+# not for shared objects
 define build-module
-$(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS)  \
-         -B$(csu-objpfx) $(load-map-file) \
-         $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
-         -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
-         -Wl,--whole-archive \
+$(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
+         $(csu-objpfx)abi-note.o $(build-module-objlist)
+endef
+else
+ifneq (,$(findstring aix,$(config-os)))
+define build-module
+$(build-module-helper) \
+         -o $@ \
          $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
          $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
 endef
-
-ifndef libc.so-version
-# Undefine this because it can't work when we libc.so is unversioned.
-static-only-routines =
+else
+define build-module
+define build-module
+$(build-module-helper) \
+         -o $@ \
+         $(build-module-objlist)
+endef
+endif
 endif
 
-elide-routines.oS += $(filter-out $(static-only-routines),\
-                                 $(routines) $(aux) $(sysdep_routines))
-elide-routines.os += $(static-only-routines)
+build-module-helper-objlist = \
+       $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
+                  $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^))
+whole-archive := -Wl,--whole-archive
 
-# If we have versioned code we don't need the old versions in any of the
-# static libraries.
-elide-routines.o  += $(shared-only-routines)
-elide-routines.op += $(shared-only-routines)
-elide-routines.og += $(shared-only-routines)
-elide-routines.ob += $(shared-only-routines)
+build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
+build-shlib-objlist = $(build-module-helper-objlist) \
+                     $(LDLIBS-$(@F:lib%.so=%).so)
 
 # Don't try to use -lc when making libc.so itself.
 # Also omits crti.o and crtn.o, which we do not want
@@ -405,21 +585,21 @@ LDFLAGS-c.so = -nostdlib -nostartfiles
 LDLIBS-c.so += $(gnulib)
 # Give libc.so an entry point and make it directly runnable itself.
 LDFLAGS-c.so += -e __libc_main
-# Force the backward compatibility EH functions to be linked.
-LDFLAGS-c.so += -u __register_frame
 # Pre-link the objects of libc_pic.a so that we can locally resolve
 # COMMON symbols before we link against ld.so.  This is because ld.so
 # contains some of libc_pic.a already, which will prevent the COMMONs
 # from being allocated in libc.so, which introduces evil dependencies
 # between libc.so and ld.so, which can make it impossible to upgrade.
+ifeq ($(elf),yes)
 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
        $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
-       -Wl,-d -Wl,--whole-archive $^
+       $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
 # Use our own special initializer and finalizer files for libc.so.
 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
                         $(common-objpfx)libc_pic.os \
                         $(elfobjdir)/sofini.os \
-                        $(elfobjdir)/interp.os $(elfobjdir)/ld.so
+                        $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
+                        $(common-objpfx)shlib.lds
        $(build-shlib)
 ifeq ($(versioning),yes)
 $(common-objpfx)libc.so: $(common-objpfx)libc.map
@@ -431,19 +611,41 @@ $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
 common-generated += libc.so$(libc.so-version)
 endif
 endif
+else
+ifneq (,$(findstring aix,$(config-os)))
+$(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
+       @rm -f $@
+       (echo '#!'; \
+        dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
+       sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
+           /lib/syscalls.exp > $(common-objpfx)syscalls.exp
+       $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
+                 -bE:$(common-objpfx)syscalls.exp \
+                 -bI:$(common-objpfx)syscalls.exp \
+                 -L$(common-objpfx) -o $@ $^
+# AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
+       cp $@ $(common-objpfx)shr.o
+       $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
+endif
+endif
 \f
 # Figure out the source filenames in this directory.
 
-override sources       := $(addsuffix .c,$(filter-out $(elided-routines),\
-                                                      $(routines) $(aux) \
-                                                      $(sysdep_routines)))
+override sources := $(addsuffix .c,\
+                       $(filter-out $(elided-routines),\
+                           $(routines) $(aux) \
+                           $(sysdep_routines)))
 sysdep_routines := $(sysdep_routines)
 
 headers := $(headers) $(sysdep_headers)
 
 # This is the list of all object files, gotten by
 # replacing every ".c" in `sources' with a ".o".
-override objects       := $(addprefix $(objpfx),$(sources:.c=.o))
+# We also add bounded-pointer thunks, which are later
+# elided for all suffixes except for `.ob'.
+override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
+                     $(patsubst %,$(bppfx)%.o,\
+                       $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
 
 
 # The makefile may define $(extra-libs) with `libfoo libbar'
@@ -458,13 +660,28 @@ endif
 \f
 +depfiles := $(sources:.c=.d) \
             $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
-            $(addsuffix .d,$(tests) $(test-srcs))
+            $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
 +depfiles := $(addprefix $(objpfx),\
                         $(filter-out $(addsuffix .d,$(omit-deps)),\
                                      $(+depfiles)))
+all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
++depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
+            $(wildcard $(all-dt-files:.dt=.d))
+
+# This is a funny rule in that it removes its input file.
+%.d: %.dt
+       @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
+        mv -f $(@:.d=.T) $@ && \
+        rm -f $<
+
+# Avoid the .h.d files for any .sym files whose .h files don't exist yet.
+# They will be generated when they're needed, and trying too early won't work.
++gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
++depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
+                                               $(+gen-as-const)))
 
 ifdef +depfiles
 ifneq ($(no_deps),t)
@@ -509,7 +726,9 @@ lib-noranlib: libobjs
 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
                                                       $(elide-routines$o)),\
-                                           $(objects)))
+                                           $(objects))) \
+           $(addprefix $(objpfx),$(o-objects$o))
+
 others: $(addprefix $(objpfx),$(install-lib))
 
 ifndef objects
@@ -530,6 +749,7 @@ define o-iterator-doit
 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
 endef
 define do-stamp
+$(make-target-directory)
 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
 mv -f $@T $@
 endef
@@ -581,10 +801,10 @@ force-install:
 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
 # unless they also appear in $(non-lib.a).  $(install-data) are installed
 # as they are into $(datadir).  $(headers) are installed as they are in
-# $(includedir).  $(install-bin) and $(install-sbin) are installed from the
-# object directory into $(bindir) and $(sbindir), respectively.
-# $(install-others) are absolute path names of files to install; rules to
-# install them are defined elsewhere.
+# $(includedir).  $(install-bin), $(install-bin-script) and $(install-sbin)
+# are installed from the object directory into $(bindir), $(bindir) and
+# $(sbindir), respectively.  $(install-others) are absolute path names of
+# files to install; rules to install them are defined elsewhere.
 
 # The simple library name to install libc.a under.
 # This could be defined by a sysdep Makefile.
@@ -623,6 +843,12 @@ $(INSTALL_PROGRAM) $< $@.new
 mv -f $@.new $@
 endef
 
+define do-install-script
+$(make-target-directory)
+$(INSTALL_SCRIPT) $< $@.new
+mv -f $@.new $@
+endef
+
 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
 
@@ -634,8 +860,16 @@ versioned := $(strip $(foreach so,$(install-lib.so),\
 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
 
-install-lib-nosubdir: $(install-lib.so-versioned:%=$(inst_libdir)/%) \
-                     $(install-lib.so-unversioned:%=$(inst_slibdir)/%)
+# For versioned libraries, we install three files:
+#      $(inst_libdir)/libfoo.so        -- for linking, symlink or ld script
+#      $(inst_slibdir)/libfoo.so.NN    -- for loading by SONAME, symlink
+#      $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
+V := $(firstword $($(subdir)-version) $(version))
+install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
+                     $(foreach L,$(install-lib.so-versioned),\
+                               $(inst_libdir)/$L \
+                               $(inst_slibdir)/$(L:.so=)-$V.so \
+                               $(inst_slibdir)/$L$($L-version))
 
 # Install all the unversioned shared libraries.
 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
@@ -657,13 +891,16 @@ mv -f $@.new $@
 endef
 endif
 
-ifeq (no,$(cross-compiling))
 ifeq (yes,$(build-shared))
+ifeq (no,$(cross-compiling))
 symbolic-link-prog := $(common-objpfx)elf/sln
 symbolic-link-list := $(common-objpfx)elf/symlink.list
 define make-shlib-link
 echo $(<F) $@ >> $(symbolic-link-list)
 endef
+else # cross-compiling
+# We need a definition that can be used by elf/Makefile's install rules.
+symbolic-link-prog = $(LN_S)
 endif
 endif
 ifndef make-shlib-link
@@ -685,6 +922,20 @@ $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
        $(do-install-program)
 install: $(inst_slibdir)/libc.so$(libc.so-version)
 
+# This fragment of linker script gives the OUTPUT_FORMAT statement
+# for the configuration we are building.  We put this statement into
+# the linker scripts we install for -lc et al so that they will not be
+# used by a link for a different format on a multi-architecture system.
+$(common-objpfx)format.lds: $(..)scripts/output-format.sed \
+                           $(common-objpfx)config.make \
+                           $(common-objpfx)config.h $(..)Makerules
+       $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
+                 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
+       | sed -n -f $< > $@.new
+       rm -f $@.so
+       mv -f $@.new $@
+common-generated += format.lds
+
 ifndef subdir
 # What we install as libc.so for programs to link against is in fact a
 # link script.  It contains references for the various libraries we need.
@@ -693,13 +944,15 @@ ifndef subdir
 # We need to use absolute paths since otherwise local copies (if they exist)
 # of the files are taken by the linker.
 install: $(inst_libdir)/libc.so
-$(inst_libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \
+$(inst_libdir)/libc.so: $(common-objpfx)format.lds \
+                       $(common-objpfx)libc.so$(libc.so-version) \
                        $(inst_libdir)/$(patsubst %,$(libtype.oS),\
                                                  $(libprefix)$(libc-name)) \
                        $(+force)
        (echo '/* GNU ld script';\
         echo '   Use the shared library, but some functions are only in';\
         echo '   the static library, so try that secondarily.  */';\
+        cat $<; \
         echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
              '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
              ')' \
@@ -720,8 +973,10 @@ ifneq (,$(versioned))
 define o-iterator-doit
 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
 endef
-object-suffixes-left := $(versioned)
+object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
+ifneq (,$(object-suffixes-left))
 include $(o-iterator)
+endif
 
 # Make symlinks in the build directory, because the versioned names might
 # be referenced by a DT_NEEDED in another library.
@@ -787,6 +1042,11 @@ $(addprefix $(inst_bindir)/,$(install-bin)): \
     $(inst_bindir)/%: $(objpfx)% $(+force)
        $(do-install-program)
 endif
+ifdef install-bin-script
+$(addprefix $(inst_bindir)/,$(install-bin-script)): \
+    $(inst_bindir)/%: $(objpfx)% $(+force)
+       $(do-install-script)
+endif
 ifdef install-rootsbin
 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
    $(inst_rootsbindir)/%: $(objpfx)% $(+force)
@@ -822,9 +1082,11 @@ $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
        $(do-install)
 endif  # headers
 
-.PHONY: install-bin-nosubdir install-rootsbin-nosubdir install-sbin-nosubdir \
-       install-lib-nosubdir install-data-nosubdir install-headers-nosubdir
+.PHONY: install-bin-nosubdir install-bin-script-nosubdir \
+       install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
+       install-data-nosubdir install-headers-nosubdir
 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
+install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
 install-rootsbin-nosubdir: \
        $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
@@ -844,9 +1106,9 @@ install-%:: install-%-nosubdir ;
 .PHONY: install install-no-libc.a-nosubdir
 ifeq ($(build-programs),yes)
 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
-                           install-bin-nosubdir install-lib-nosubdir   \
-                           install-others-nosubdir install-rootsbin-nosubdir \
-                           install-sbin-nosubdir
+                           install-bin-nosubdir install-bin-script-nosubdir \
+                           install-lib-nosubdir install-others-nosubdir \
+                           install-rootsbin-nosubdir install-sbin-nosubdir
 else
 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
                            install-lib-nosubdir install-others-nosubdir
@@ -876,6 +1138,166 @@ ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
 # Support the GNU standard name for this target.
 .PHONY: check
 check: tests
+# Special target to run tests which cannot be run unconditionally.
+# Maintainers should use this target.
+.PHONY: xcheck
+xcheck: xtests
+
+all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
+ifneq (,$(all-nonlib))
+cpp-srcs-left = $(all-nonlib:=.c)
+lib := nonlib
+include $(patsubst %,$(..)cppflags-iterator.mk,$(all-nonlib))
+endif
+
+# The include magic above causes those files to use this variable for flags.
+CPPFLAGS-nonlib = -DNOT_IN_libc=1
+
+
+ifeq ($(versioning),yes)
+# Generate normalized lists of symbols, versions, and data sizes.
+# This is handy for checking against existing library binaries.
+
+%.symlist: $(..)scripts/abilist.awk %.dynsym
+       LC_ALL=C $(AWK) -f $^ > $@T
+       mv -f $@T $@
+
+%.dynsym: %.so
+       $(OBJDUMP) --dynamic-syms $< > $@T
+       mv -f $@T $@
+
+check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
+            $(..)abilist/%.abilist $(objpfx)%.symlist
+       $(check-abi)
+check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
+            $(..)abilist/%.abilist $(common-objpfx)%.symlist
+       $(check-abi)
+define check-abi
+       LC_ALL=C \
+       $(AWK) -f $< -v 'config=$(check-abi-config)' \
+              $(filter %.abilist,$^) \
+       | { diff -pu0 - $(filter %.symlist,$^) $(check-abi-warn) ; }
+endef
+ifeq ($(enable-check-abi),warn)
+check-abi-warn = || echo '*** WARNING: $*.so failed ABI check'
+endif
+
+ifeq ($(firstword $(sysd-sorted-done) f)$(firstword $(generating) f),tf)
+-include $(common-objpfx)tls.make
+config-tls := notls
+ifeq ($(use-tls),yes)
+config-tls := tls
+endif
+ifeq ($(use-thread),yes)
+config-tls := thread
+endif
+check-abi-config := \
+  $(config-machine)-$(config-vendor)-$(config-os)/$(config-tls)
+endif
+
+update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
+             $(objpfx)%.symlist
+       $(update-abi)
+update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
+             $(common-objpfx)%.symlist
+       $(update-abi)
+ifndef update-abi-config
+define update-abi
+       @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2
+endef
+else
+define update-abi
+LC_ALL=C $(AWK) -v config='$(update-abi-config)' -f $^ \
+        > $(..)abilist/$*.abilist.new
+@if cmp -s $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist 2> /dev/null; \
+ then rm -f $(..)abilist/$*.abilist.new; \
+      echo '+++ $(..)abilist/$*.abilist is unchanged'; \
+ else mv -f $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist; \
+      echo '*** Now check $*.abilist changes for correctness ***'; \
+ fi
+endef
+endif
+
+.PHONY: update-abi check-abi
+update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
+check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
+ifdef subdir
+subdir_check-abi: check-abi
+subdir_update-abi: update-abi
+else
+check-abi: subdir_check-abi
+update-abi: subdir_update-abi
+endif
+
+ifeq ($(subdir),elf)
+check-abi: check-abi-libc
+update-abi: update-abi-libc
+common-generated += libc.symlist
+endif
+
+ifeq ($(build-shared),yes)
+ifneq ($(enable-check-abi),no)
+ifdef subdir
+tests: check-abi
+endif
+endif
+endif
+
+endif
+
+# There's no good place to put this - here will do.
+ifeq ($(filter %posix, $(sysdirs)),)
+L_tmpnam  = 1
+TMP_MAX   = 0
+L_ctermid = 1
+L_cuserid = 1
+else
+L_tmpnam  = 20
+TMP_MAX   = 238328
+L_ctermid = 9
+L_cuserid = 9
+endif
+stdio_lim = $(common-objpfx)bits/stdio_lim.h
+
+$(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
+$(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
+                  $(common-objpfx)config.make
+       $(make-target-directory)
+       { echo '#include "$(..)posix/bits/posix1_lim.h"';               \
+         echo '#define _LIBC 1';                                       \
+         echo '#include "$(..)misc/sys/uio.h"'; } |                    \
+       $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)'   \
+             $(+includes) -xc - -o $(@:st=hT)
+       sed $(sed-remove-objpfx) $(sed-remove-dotdot)                   \
+           $(@:st=dT) > $(@:st=dt)
+       mv -f $(@:st=dt) $(@:st=d)
+       fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`;       \
+       filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`;    \
+       iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`;        \
+       fopen_max=$${fopen_max:-16};                                    \
+       filename_max=$${filename_max:-1024};                            \
+       if [ -z "$$iov_max" ]; then                                     \
+         define_iov_max="# undef IOV_MAX";                             \
+       else                                                            \
+         define_iov_max="# define IOV_MAX $$iov_max";                  \
+       fi;                                                             \
+       sed -e "s/@FOPEN_MAX@/$$fopen_max/"                             \
+           -e "s/@FILENAME_MAX@/$$filename_max/"                       \
+           -e "s/@L_tmpnam@/$(L_tmpnam)/"                              \
+           -e "s/@TMP_MAX@/$(TMP_MAX)/"                                \
+           -e "s/@L_ctermid@/$(L_ctermid)/"                            \
+           -e "s/@L_cuserid@/$(L_cuserid)/"                            \
+           -e "s/@define_IOV_MAX@/$$define_iov_max/"                   \
+           $< > $(@:st=h.new)
+       $(move-if-change) $(@:st=h.new) $(@:st=h)
+# Remove these last so that they can be examined if something went wrong.
+       rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
+       touch $@
+# Get dependencies.
+ifndef no_deps
+-include $(stdio_lim:h=d)
+endif
+common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
 \f
 .PHONY: TAGS
 TAGS: $(objpfx)distinfo $(..)MakeTAGS
@@ -898,20 +1320,29 @@ clean: common-clean
 mostlyclean: common-mostlyclean
 
 do-tests-clean:
-       -rm -f $(patsubst %,$(objpfx)%.out,$(tests) $(test-srcs))
+       -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
+                                                     $(test-srcs)) \
+                                    $(addsuffix -bp.out,$(tests) $(xtests) \
+                                                        $(test-srcs)))
 
 # Remove the object files.
 common-mostlyclean:
-       -rm -f $(addprefix $(objpfx),$(tests) $(test-srcs) $(others) \
-                                    $(sysdep-others) stubs \
-                                    $(addsuffix .o,$(tests) $(test-srcs) \
-                                                   $(others) \
+       -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
+                                    $(others) $(sysdep-others) stubs \
+                                    $(addsuffix .o,$(tests) $(xtests) \
+                                                   $(test-srcs) $(others) \
                                                    $(sysdep-others)) \
-                                    $(addsuffix .out,$(tests) $(test-srcs)))
+                                    $(addsuffix -bp,$(tests) $(xtests) \
+                                                    $(test-srcs)) \
+                                    $(addsuffix .out,$(tests) $(xtests) \
+                                                     $(test-srcs)) \
+                                    $(addsuffix -bp.out,$(tests) $(xtests) \
+                                                        $(test-srcs)))
        -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
                                     $(install-lib.so) \
                                     $(install-lib.so:%.so=%_pic.a))
        -rm -f core
+       -rm -f $(objpfx)rtld-*.os
        $(rmobjs)
 define rmobjs
 $(foreach o,$(object-suffixes-for-libc),
@@ -920,7 +1351,8 @@ endef
 
 # Also remove the dependencies and generated source files.
 common-clean: common-mostlyclean
-       -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
+       -rm -f $(addprefix $(objpfx),$(generated))
+       -rm -f $(objpfx)*.d $(objpfx)*.dt
        -rm -fr $(addprefix $(objpfx),$(generated-dirs))
        -rm -f $(addprefix $(common-objpfx),$(common-generated))
        -rm -f $(objpfx)distinfo
@@ -934,17 +1366,23 @@ ifdef objpfx
 .PHONY: stubs # The parent Makefile calls this target.
 stubs: $(objpfx)stubs
 endif
-s = $(sysdep_dir)/generic
 $(objpfx)stubs: $(+depfiles)
+ifneq (,$(strip $(+depfiles)))
 # Use /dev/null since `...` might expand to empty.
-       (s=`cd $s && /bin/pwd`; \
-        $(patsubst %/,cd % &&,$(objpfx)) \
-        sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
-         `sed -n -e '\@ $s/[^ ]*\.c@{; s@^.* $s/\([^ ]*\.c\).*$$@'"$$s"'/\1@; h; }' \
-               -e '/stub-tag\.h/{; g; p; }' \
-                 $(patsubst $(objpfx)%,%,$^) /dev/null` \
-            /dev/null) > $@T
+       c=`($(patsubst %/,cd % &&,$(objpfx)) \
+           sed -n -e 's@\$$(common-objpfx)@$(common-objpfx)@g' \
+                  -e 's@\$$(objpfx)@$(objpfx)@g' \
+                  -e '/stub-tag\.h/{; g; s/./&/p; }' \
+                  -e '/:/{x; s/^.*$$//; x; }' \
+                  -e 's/^.*://;s/\\$$//;s/^ *\([^ ][^ ]*\) .*$$/\1/' \
+                  -e '/^[^ ][^ ]*$$/{G;s/^.*\n\(..*\)/\1/;s/\n//;h; }' \
+                  $(patsubst $(objpfx)%,%,$^)) | sort | uniq`; \
+       sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
+           $$c /dev/null > $@T
        mv -f $@T $@
+else
+       > $@
+endif
 \f
 # Make the distribution tar file.
 
@@ -973,9 +1411,9 @@ rm -f $@.new
 echo > $@.new 'subdir := $(subdir)'
 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
              headers sysdep_headers distribute dont_distribute generated \
-             others tests test-srcs extra-libs $(extra-libs:%=%-routines) \
-             versioned \
-             $(addprefix install-,lib lib.so data bin sbin others),
+             others tests xtests test-srcs extra-libs versioned \
+             $(extra-libs:%=%-routines) \
+             $(addprefix install-,lib lib.so data bin bin-script sbin others),
 echo >> $@.new '$(subdir)-$(var) := $($(var))'
 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
 endef
@@ -993,3 +1431,7 @@ ifeq ($(with-cvs),yes)
 endif
 endif
 endif
+
+# Local Variables:
+# mode: makefile
+# End:
This page took 0.055955 seconds and 5 git commands to generate.