-# Copyright (C) 1991-2015 Free Software Foundation, Inc.
+# Copyright (C) 1991-2024 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
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
-# <http://www.gnu.org/licenses/>.
+# <https://www.gnu.org/licenses/>.
#
# Common rules for making the GNU C library. This file is included
sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
$(common-objpfx)abi-versions.h > $@T
mv -f $@T $@
+
+# first-versions.h and ldbl-compat-choose.h provide macros used in
+# various symbol versioning macro calls.
+before-compile := $(common-objpfx)first-versions.h \
+ $(common-objpfx)ldbl-compat-choose.h $(before-compile)
+$(common-objpfx)first-versions.h: $(common-objpfx)versions.stmp
+$(common-objpfx)ldbl-compat-choose.h: $(common-objpfx)versions.stmp
endif # avoid-generated
endif # $(build-shared) = yes
ifndef avoid-generated
+ifneq (,$(CXX))
+# If C++ headers <cstdlib> or <cmath> are used, GCC 6 will include
+# /usr/include/stdlib.h or /usr/include/math.h from "#include_next"
+# (instead of stdlib/stdlib.h or math/math.h in the glibc source
+# directory), and this turns up as a make dependency. An implicit
+# rule will kick in and make will try to install stdlib/stdlib.h or
+# math/math.h as /usr/include/stdlib.h or /usr/include/math.h because
+# the target is out of date. We make a copy of <cstdlib> and <cmath>
+# in the glibc build directory so that stdlib/stdlib.h and math/math.h
+# will be used instead of /usr/include/stdlib.h and /usr/include/math.h.
+before-compile := $(common-objpfx)cstdlib $(common-objpfx)cmath \
+ $(before-compile)
+$(common-objpfx)cstdlib: $(c++-cstdlib-header)
+ $(INSTALL_DATA) $< $@T
+ $(move-if-change) $@T $@
+$(common-objpfx)cmath: $(c++-cmath-header)
+ $(INSTALL_DATA) $< $@T
+ $(move-if-change) $@T $@
+ifneq (,$(c++-bits-std_abs-h))
+# Also make a copy of <bits/std_abs.h> from GCC 7 to prevent it from
+# including /usr/include/stdlib.h.
+before-compile := $(common-objpfx)bits/std_abs.h $(before-compile)
+$(common-objpfx)bits/std_abs.h: $(c++-bits-std_abs-h)
+ $(INSTALL_DATA) $< $@T
+ $(move-if-change) $@T $@
+endif
+endif
+
before-compile := $(common-objpfx)libc-abis.h $(before-compile)
$(common-objpfx)libc-abis.h: $(common-objpfx)libc-abis.stamp; @:
$(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \
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
+# file that uses cpp constructs 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
-e 's@^\([^ \/$$][^ \]*\)@$$(..)\1@g'
endif
+ifdef gen-py-const-headers
+# We'll use a static pattern rule to match .pysym files with their
+# corresponding generated .py files.
+# The generated .py files go in the submodule's dir in the glibc build dir.
+py-const-files := $(patsubst %.pysym,%.py,$(gen-py-const-headers))
+py-const-dir := $(objpfx)
+py-const := $(addprefix $(py-const-dir),$(py-const-files))
+py-const-script := $(..)scripts/gen-as-const.py
+
+# This is a hack we use to generate .py files with constants for
+# Python code.
+#
+# $@.tmp is a temporary file we use to store the partial contents of
+# the target file. We do this instead of just writing on $@ because,
+# if the build process terminates prematurely, re-running Make
+# wouldn't run this rule since Make would see that the target file
+# already exists (despite it being incomplete).
+#
+# The output is redirected to a .py file; we'll import it in the main
+# Python code to read the constants generated by gen-as-const.py.
+$(py-const): $(py-const-dir)%.py: %.pysym $(py-const-script) \
+ $(common-before-compile)
+ $(make-target-directory)
+ $(PYTHON) $(py-const-script) --python \
+ --cc="$(CC) $(CFLAGS) $(CPPFLAGS)" $< \
+ > $@.tmp
+ mv -f $@.tmp $@
+
+generated += $(py-const)
+endif # gen-py-const-headers
ifdef gen-as-const-headers
# 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 \
+# Define GEN_AS_CONST_HEADERS to avoid circular dependency [BZ #22792].
+# NB: <tcb-offsets.h> is generated from tcb-offsets.sym to define
+# offsets and sizes of types in <tls.h> and maybe <pthread.h> which
+# may include <tcb-offsets.h>. Target header files can check if
+# GEN_AS_CONST_HEADERS is defined to avoid circular dependency which
+# may lead to build hang on a many-core machine.
+$(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.py \
%.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
+ $(PYTHON) $< --cc="$(CC) $(CFLAGS) $(CPPFLAGS) -DGEN_AS_CONST_HEADERS \
+ -MD -MP -MF $(@:.h=.h.d)T \
+ -MT '$(@:.h=.h.d) $(@:.h.d=.h)'" \
+ $(filter %.sym,$^) > $(@:.h.d=.h)T
sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
$(@:.h=.h.d)T > $(@:.h=.h.d)T2
rm -f $(@:.h=.h.d)T
vpath %.sym $(sysdirs)
before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
-tests += $(gen-as-const-headers:%.sym=test-as-const-%)
+tests-internal += $(gen-as-const-headers:%.sym=test-as-const-%)
generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
-$(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \
+$(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.py $(..)Makerules \
%.sym $(common-objpfx)%.h
($(AWK) '{ sub(/^/, "asconst_", $$2); print; }' $(filter %.h,$^); \
- $(AWK) -v test=1 -f $< $(filter %.sym,$^); \
- echo '#include "$(..)test-skeleton.c"') > $@T
+ $(PYTHON) $< --test $(filter %.sym,$^)) > $@T
mv -f $@T $@
endif
\f
endef
object-suffixes-left := $(all-object-suffixes)
include $(o-iterator)
-endif
-# Generate version maps, but wait until sysdep-subdirs is known
-ifeq ($(sysd-sorted-done),t)
-ifeq ($(build-shared),yes)
--include $(common-objpfx)sysd-versions
-$(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
-common-generated += $(version-maps)
-postclean-generated += sysd-versions Versions.all abi-versions.h \
- Versions.def Versions.v.i Versions.v
-
-ifndef avoid-generated
-ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
-sysd-versions-force = FORCE
-FORCE:
+define o-iterator-doit
+$(objpfx)%$o: $(objpfx)%.cc $(before-compile); $$(compile-command.cc)
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
endif
-$(common-objpfx)Versions.def: $(..)scripts/versionlist.awk \
- $(common-objpfx)Versions.v
- LC_ALL=C $(AWK) -f $^ > $@T
- mv -f $@T $@
-
-$(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
- $(common-objpfx)soversions.i \
- $(common-objpfx)Versions.def
- { while read which lib version setname; do \
- test x"$$which" = xDEFAULT || continue; \
- test -z "$$setname" || echo "$$lib : $$setname"; \
- done < $(word 2,$^); \
- cat $(word 3,$^); \
- } | LC_ALL=C $(AWK) -f $< > $@T
- mv -f $@T $@
-# See %.v/%.v.i implicit rules in Makeconfig.
-$(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
- $(wildcard $(sysdirs:%=%/Versions)) \
- $(sysd-versions-force)
-$(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
- $(common-objpfx)Versions.v \
- $(..)scripts/versions.awk
- ( echo 'sysd-versions-subdirs = $(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 # $(build-shared) = yes
-endif # sysd-sorted-done
-
# Generate .dT files as we compile.
compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
- $(ASFLAGS) $(ASFLAGS-$(suffix $@))
+ $(ASFLAGS) $(ASFLAGS-$(suffix $@)) $(sysdep-ASFLAGS) \
+ $(ASFLAGS-$(<F)) $(ASFLAGS-$(@F))
COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS)
COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
- $(ASFLAGS) $(ASFLAGS-$(suffix $@))
+ $(ASFLAGS) $(ASFLAGS-$(suffix $@)) $(sysdep-ASFLAGS) \
+ $(ASFLAGS-$(<F)) $(ASFLAGS-$(@F))
# We need this for the output to go in the right place. It will default to
# empty if make was configured to work with a cc that can't grok -c and -o
# get the wrong predefines.
S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
-define +make-deps
-$(make-target-directory)
-$(+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
# static libraries.
elide-routines.o += $(shared-only-routines)
elide-routines.op += $(shared-only-routines)
-elide-routines.og += $(shared-only-routines)
\f
# Shared library building.
link-libc-args = -Wl,--start-group \
$(libc-for-link) \
$(common-objpfx)libc_nonshared.a \
- $(as-needed) $(elf-objpfx)ld.so $(no-as-needed) \
+ -Wl,--as-needed $(elf-objpfx)ld.so -Wl,--no-as-needed \
-Wl,--end-group
# The corresponding shared libc to use. This may be modified for a
$(call after-link,$@)
define build-shlib-helper
-$(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
+$(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \
$(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(rtld-LDFLAGS) \
+ $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(dt-relr-ldflag)) \
$(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) \
+ $(LDFLAGS.so) $(LDFLAGS-lib.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
-L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
endef
-ifeq (yes,$(use-default-link))
-# If the linker is good enough, we can let it use its default linker script.
-shlib-lds =
-shlib-lds-flags =
-else
-# 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) $(rtld-LDFLAGS) $(LDFLAGS.so) \
- -Wl,--verbose 2>&1 | \
- sed > $@T \
- -e '/^=========/,/^=========/!d;/^=========/d' \
- $(if $(filter yes,$(have-hash-style)), \
- -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
- -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
- -e '/DATA_SEGMENT_ALIGN/{H;g}' \
- , \
- -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).*$$@& \
- PROVIDE(__start___libc_subfreeres = .);\
- __libc_subfreeres : { *(__libc_subfreeres) }\
- PROVIDE(__stop___libc_subfreeres = .);\
- PROVIDE(__start___libc_atexit = .);\
- __libc_atexit : { *(__libc_atexit) }\
- PROVIDE(__stop___libc_atexit = .);\
- PROVIDE(__start___libc_thread_subfreeres = .);\
- __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
- PROVIDE(__stop___libc_thread_subfreeres = .);\
- /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
- test -s $@T
- mv -f $@T $@
-common-generated += shlib.lds
-
-shlib-lds = $(common-objpfx)shlib.lds
-shlib-lds-flags = -T $(shlib-lds)
-endif
-
define build-shlib
-$(build-shlib-helper) -o $@ $(shlib-lds-flags) \
+$(build-shlib-helper) -o $@ \
$(csu-objpfx)abi-note.o $(build-shlib-objlist)
endef
define build-module-helper
-$(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
+$(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
$(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
+ $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(dt-relr-ldflag)) \
-B$(csu-objpfx) $(load-map-file) \
$(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
+ $(link-test-modules-rpath-link) \
-L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
endef
# binutils only position loadable notes into the first page for binaries,
# not for shared objects
define build-module
-$(build-module-helper) -o $@ $(shlib-lds-flags) \
+$(build-module-helper) -o $@ \
$(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
$(call after-link,$@)
endef
define build-module-asneeded
-$(build-module-helper) -o $@ $(shlib-lds-flags) \
+$(build-module-helper) -o $@ \
$(csu-objpfx)abi-note.o \
-Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
$(link-libc-args)
$(call after-link,$@)
endef
+# sofini.os must be placed last since it terminates .eh_frame section.
build-module-helper-objlist = \
$(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
$(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \
+ $(elf-objpfx)sofini.os \
$(link-libc-deps),$^))
build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
build-shlib-objlist = $(build-module-helper-objlist) \
- $(LDLIBS-$(@F:lib%.so=%).so)
+ $(LDLIBS-$(@F:lib%.so=%).so) \
+ $(filter $(elf-objpfx)sofini.os,$^)
# Don't try to use -lc when making libc.so itself.
# Also omits crti.o and crtn.o, which we do not want
LDLIBS-c.so += $(libc.so-gnulib)
# Give libc.so an entry point and make it directly runnable itself.
LDFLAGS-c.so += -e __libc_main
-# If lazy relocation is disabled add the -z now flag.
-ifeq ($(bind-now),yes)
-LDFLAGS-c.so += -Wl,-z,now
-endif
-# 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.
+# Pre-link the objects of libc_pic.a for .gnu.glibc-stub.* processing.
$(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
$(LINK.o) -nostdlib -nostartfiles -r -o $@ \
- $(LDFLAGS-c_pic.os) -Wl,-d $(whole-archive) $^ -o $@
+ $(LDFLAGS-c_pic.os) $(whole-archive) $^ -o $@
-ifeq (,$(strip $(shlib-lds-flags)))
# Generate a list of -R options to excise .gnu.glibc-stub.* sections.
$(common-objpfx)libc_pic.opts: $(common-objpfx)libc_pic.os
$(OBJDUMP) -h $< | \
generated += libc_pic.opts libc_pic.os.clean
libc_pic_clean := .clean
-endif
# Build a possibly-modified version of libc_pic.a for use in building
# linkobj/libc.so.
# Use our own special initializer and finalizer files for the libc.so
# libraries.
-$(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
- $(common-objpfx)libc_pic.os$(libc_pic_clean) \
+$(common-objpfx)libc.so: $(common-objpfx)libc_pic.os$(libc_pic_clean) \
$(elf-objpfx)sofini.os \
$(elf-objpfx)interp.os \
- $(elf-objpfx)ld.so \
- $(shlib-lds)
+ $(elf-objpfx)ld.so
$(build-shlib)
$(call after-link,$@)
-$(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \
- $(common-objpfx)linkobj/libc_pic.a \
+$(common-objpfx)linkobj/libc.so: $(common-objpfx)linkobj/libc_pic.a \
$(elf-objpfx)sofini.os \
$(elf-objpfx)interp.os \
- $(elf-objpfx)ld.so \
- $(shlib-lds)
+ $(elf-objpfx)ld.so
$(build-shlib)
$(call after-link,$@)
# The makefile may define $(modules-names) to build additional modules.
# These are built with $(build-module), except any in $(modules-names-nobuild).
+# MODULE_NAME=extramodules, except any in $(modules-names-tests).
ifdef modules-names
-# extra-lib.mk is included once for each extra lib to define rules
-# to build it, and to add its objects to the various variables.
-# During its evaluation, $(lib) is set to the name of the library.
-extra-modules-left := $(modules-names)
-include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
+cpp-srcs-left := $(filter-out $(modules-names-tests),$(modules-names))
+ifneq (,$(cpp-srcs-left))
+lib := extramodules
+include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
+endif
+
+ifdef modules-names-tests
+cpp-srcs-left := $(filter $(modules-names-tests),$(modules-names))
+ifneq (,$(cpp-srcs-left))
+lib := testsuite
+include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
+endif
+endif
extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
$(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
- $(objpfx)%.os $(shlib-lds) $(link-libs-deps)
+ $(objpfx)%.os $(link-libs-deps)
$(build-module)
endif
\f
$(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
$(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
$(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
- $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
+ $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+ $(tests-container) $(tests-printers) \
+ $(test-srcs) $(tests-time64) $(xtests-time64))
ifeq ($(build-programs),yes)
+depfiles += $(addsuffix .d,$(others) $(sysdep-others))
endif
# Maximize efficiency by minimizing the number of rules.
.SUFFIXES: # Clear the suffix list. We don't use suffix rules.
# Don't define any builtin rules.
-MAKEFLAGS := $(MAKEFLAGS)r
+MAKEFLAGS := $(MAKEFLAGS) -r
# Generic rule for making directories.
%/:
.PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
\f
# Use the verbose option of ar and tar when not running silently.
-ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
+ifeq ($(silent-make),no) # if not -s
verbose := v
else # -s
verbose :=
install-lib := $(filter-out %.so %_pic.a,$(install-lib))
ifeq (yes,$(build-shared))
-# Find which .so's have versions.
+# Find which .so's have a version number in their soname.
versioned := $(strip $(foreach so,$(install-lib.so),\
$(patsubst %,$(so),$($(so)-version))))
install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
-# For versioned libraries, we install three files:
+# For libraries whose soname have version numbers, we install two 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
-lib-version := $(firstword $($(subdir)-version) $(version))
+# $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME
install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
$(foreach L,$(install-lib.so-versioned),\
$(inst_libdir)/$L \
- $(inst_slibdir)/$(L:.so=)-$(lib-version).so \
$(inst_slibdir)/$L$($L-version))
# Install all the unversioned shared libraries.
$(SHELL) $(..)scripts/rellns-sh $< $@.new
mv -f $@.new $@
endef
+define make-link-multidir
+$(patsubst %/,cd %,$(objpfx)); \
+ $(addprefix $(abspath $(..)scripts/mkinstalldirs) ,$(dir $(multidir))); \
+ $(LN_S) . $(multidir) 2> /dev/null; \
+ test -L $(multidir)
+endef
else
# If we have no symbolic links don't bother with rellns-sh.
define make-link
$(LN_S) $< $@.new
mv -f $@.new $@
endef
-endif
-
-ifeq (yes,$(build-shared))
-ifeq (no,$(cross-compiling))
-symbolic-link-prog := $(elf-objpfx)sln
-symbolic-link-list := $(elf-objpfx)symlink.list
-define make-shlib-link
-echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(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
-define make-shlib-link
-rm -f $@
-$(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
+define make-link-multidir
+$(make-target-directory)
+ln -f $(objpfx)/$(@F) $@
endef
endif
ifdef libc.so-version
-# For a library specified to be version N, install three files:
-# libc.so -> libc.so.N (e.g. libc.so.6)
-# libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
-
-$(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
- $(+force)
- $(make-shlib-link)
-$(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
+$(inst_slibdir)/libc.so$(libc.so-version): $(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)format.lds: $(common-objpfx)config.make \
$(common-objpfx)config.h $(..)Makerules
-ifneq (unknown,$(output-format))
- echo > $@.new 'OUTPUT_FORMAT($(output-format))'
-else
- $(LINK.o) -shared $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
- -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
- | sed -n -f $< > $@.new
- test -s $@.new
+ $(LINK.o) -shared -nostdlib -nostartfiles \
+ -x assembler /dev/null -o $@.so
+ $(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@
rm -f $@.so
-endif
- mv -f $@.new $@
common-generated += format.lds
ifndef subdir
generated += $(foreach o,$(versioned),$o$($o-version))
-ifeq (,$($(subdir)-version))
-define o-iterator-doit
-$(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
- $(+force);
- $$(make-shlib-link)
-endef
-object-suffixes-left := $(versioned)
-include $(o-iterator)
-
define o-iterator-doit
-$(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
+$(inst_slibdir)/$o$($o-version): $(objpfx)$o $(+force);
$$(do-install-program)
endef
object-suffixes-left := $(versioned)
include $(o-iterator)
-else
-define o-iterator-doit
-$(inst_slibdir)/$o$($o-version): \
- $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
- $$(make-shlib-link)
-endef
-object-suffixes-left := $(versioned)
-include $(o-iterator)
-
-define o-iterator-doit
-$(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
- $$(do-install-program)
-endef
-object-suffixes-left := $(versioned)
-include $(o-iterator)
-endif
-endif
+endif # ifneq (,$(versioned))
define do-install-so
$(do-install-program)
-$(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
+$(patsubst %,$(LN_S) -f $(@F) \
+ $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
$(filter-out %.so,$@))
endef
endif
ifdef install-lib
install-lib.a := $(filter lib%.a,$(install-lib))
+install-lib.a := $(filter-out $(install-lib-ldscripts),$(install-lib.a))
install-lib-non.a := $(filter-out lib%.a,$(install-lib))
ifdef install-lib-non.a
$(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
$(do-install)
$(inst_includedir)/%.h: %.h $(+force)
$(do-install)
-$(inst_includedir)/%.h: $(..)include/%.h $(+force)
- $(do-install)
headers-nonh := $(filter-out %.h,$(headers))
ifdef headers-nonh
$(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
.PHONY: xcheck
xcheck: xtests
-all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64) $(xtests-time64),\
+ $(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+ifeq ($(have-time64-compat),yes)
+tests += $(foreach t,$(tests-time64),$(t))
+xtests += $(foreach t,$(xtests-time64),$(t))
+endif
+
+# The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
+# that almost all internal declarations from config.h, libc-symbols.h, and
+# include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
+all-testsuite := $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) \
+ $(tests-container))
+ifneq (,$(all-testsuite))
+cpp-srcs-left = $(all-testsuite)
+lib := testsuite
+include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
+endif
+
+all-nonlib := $(strip $(others) $(others-extras))
ifneq (,$(all-nonlib))
cpp-srcs-left = $(all-nonlib)
lib := nonlib
-include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
+include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
endif
+# All internal tests use testsuite-internal module since for 64 bit time
+# support is set as default for MODULE_NAME=nonlib (which include some
+# installed programs).
+all-testsuite-internal := $(strip $(tests-internal) $(test-internal-extras))
+ifneq (,$(all-testsuite-internal))
+cpp-srcs-left = $(all-testsuite-internal)
+lib := testsuite-internal
+include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
+endif
ifeq ($(build-shared),yes)
# Generate normalized lists of symbols, versions, and data sizes.
LC_ALL=C $(OBJDUMP) --dynamic-syms $< > $@T
mv -f $@T $@
-# A sysdeps/.../Makefile can set abilist-pattern to something like
-# %-foo.abilist to look for libc-foo.abilist instead of libc.abilist.
-# This makes sense if multiple ABIs can be most cleanly supported by a
-# configuration without using separate sysdeps directories for each.
-ifdef abilist-pattern
-vpath $(abilist-pattern) $(+sysdep_dirs)
-endif
-
vpath %.abilist $(+sysdep_dirs)
# The .PRECIOUS rule prevents the files built by an implicit rule whose
.PRECIOUS: %.symlist
generated += $(extra-libs:=.symlist)
-ifdef abilist-pattern
-$(objpfx)check-abi-%.out: $(common-objpfx)config.make $(abilist-pattern) \
- $(objpfx)%.symlist
- $(check-abi-pattern); \
- $(evaluate-test)
-$(objpfx)check-abi-%.out: $(common-objpfx)config.make $(abilist-pattern) \
- $(common-objpfx)%.symlist
- $(check-abi-pattern); \
- $(evaluate-test)
-endif
$(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
$(objpfx)%.symlist
$(check-abi); \
$(common-objpfx)%.symlist
$(check-abi); \
$(evaluate-test)
-define check-abi-pattern
- diff -p -U 0 $(filter $(abilist-pattern),$^) $(filter %.symlist,$^) \
- > $@
-endef
define check-abi
diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^) > $@
endef
-ifdef abilist-pattern
-update-abi-%: $(objpfx)%.symlist $(abilist-pattern)
- $(update-abi-pattern)
-update-abi-%: $(common-objpfx)%.symlist $(abilist-pattern)
- $(update-abi-pattern)
-endif
update-abi-%: $(objpfx)%.symlist %.abilist
$(update-abi)
update-abi-%: $(common-objpfx)%.symlist %.abilist
$(update-abi)
-define update-abi-pattern
-@if cmp -s $^ 2> /dev/null; \
- then \
- echo '+++ $(filter $(abilist-pattern),$^) is unchanged'; \
- else cp -f $^; \
- echo '*** Now check $(filter $(abilist-pattern),$^) changes for correctness ***'; \
- fi
-endef
define update-abi
@if cmp -s $^ 2> /dev/null; \
then \
fi
endef
-.PHONY: update-abi check-abi
+# Patch all .abilist files for one DSO. The find command locates abilist
+# files for all architectures. The abilist files in /generic/ are
+# filtered out because these are expected to remain empty.
+define update-all-abi
+$(SHELL) $(..)scripts/update-abilist.sh $^ \
+ $$(find $(..)sysdeps -name '$*.abilist' \! -path '*/generic/*')
+endef
+update-all-abi-%: %.abilist $(objpfx)%.symlist
+ $(update-all-abi)
+update-all-abi-%: %.abilist $(common-objpfx)%.symlist
+ $(update-all-abi)
+
+.PHONY: update-abi update-all-abi check-abi
update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
+update-all-abi: $(patsubst %.so,update-all-abi-%,$(install-lib.so-versioned))
check-abi-list = $(patsubst %.so,$(objpfx)check-abi-%.out, \
$(install-lib.so-versioned))
check-abi: $(check-abi-list)
ifdef subdir
subdir_check-abi: check-abi
subdir_update-abi: update-abi
+subdir_update-all-abi: update-all-abi
else
check-abi: subdir_check-abi
if grep -q '^FAIL:' $(objpfx)*/check-abi*.test-result; then \
cat $(objpfx)*/check-abi*.out && exit 1; fi
update-abi: subdir_update-abi
+update-all-abi: subdir_update-all-abi
endif
ifeq ($(subdir),elf)
check-abi: $(objpfx)check-abi-libc.out
tests-special += $(objpfx)check-abi-libc.out
update-abi: update-abi-libc
+update-all-abi: update-all-abi-libc
common-generated += libc.symlist
endif
endif
\f
-# These will have been set by sysdeps/posix/Makefile.
-L_tmpnam ?= 1
-TMP_MAX ?= 0
-L_ctermid ?= 1
-L_cuserid ?= 1
-
-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)' \
- $(CPPUNDEFS) $(+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
FORCE:
.PHONY: echo-headers
clean: common-clean
mostlyclean: common-mostlyclean
+# Remove test artifacts from a given directory
do-tests-clean:
- -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
- $(test-srcs)) \
- $(addsuffix .test-result,$(tests) \
- $(xtests) \
- $(test-srcs)))
+ -find $(objpfx) -name '*.out' -delete
+ -find $(objpfx) -name '*.test-result' -delete
# Remove the object files.
-common-mostlyclean:
- -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
+common-mostlyclean: do-tests-clean
+ -rm -f $(addprefix $(objpfx),$(tests) $(tests-internal) $(xtests) \
+ $(test-srcs) \
$(others) $(sysdep-others) stubs \
- $(addsuffix .o,$(tests) $(xtests) \
- $(test-srcs) $(others) \
- $(sysdep-others)) \
- $(addsuffix .out,$(tests) $(xtests) \
- $(test-srcs)) \
- $(addsuffix .test-result,$(tests) \
- $(xtests) \
- $(test-srcs)))
+ $(addsuffix .o,$(tests) \
+ $(tests-internal) \
+ $(xtests) \
+ $(test-srcs) \
+ $(others) \
+ $(sysdep-others)))
-rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
$(install-lib) $(install-lib.so) \
$(install-lib.so:%.so=%_pic.a))