11 kx # Copyright (C) 1991-2023 Free Software Foundation, Inc.
11 kx # This file is part of the GNU C Library.
11 kx
11 kx # The GNU C Library is free software; you can redistribute it and/or
11 kx # modify it under the terms of the GNU Lesser General Public
11 kx # License as published by the Free Software Foundation; either
11 kx # version 2.1 of the License, or (at your option) any later version.
11 kx
11 kx # The GNU C Library is distributed in the hope that it will be useful,
11 kx # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 kx # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 kx # Lesser General Public License for more details.
11 kx
11 kx # You should have received a copy of the GNU Lesser General Public
11 kx # License along with the GNU C Library; if not, see
11 kx # <https://www.gnu.org/licenses/>.
11 kx
11 kx #
11 kx # Common rules for making the GNU C library. This file is included
11 kx # by the top-level Makefile and by all subdirectory makefiles
11 kx # (through Rules).
11 kx #
11 kx ifneq (,)
11 kx This makefile requires GNU Make.
11 kx endif
11 kx
11 kx REQUIRED_MAKE_VERSION = 3.74
11 kx REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
11 kx
11 kx ifneq ($(REQUIRED_MAKE_VERSION), \
11 kx $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION))))
11 kx Wrong GNU Make version. See above for the version needed.
11 kx endif
11 kx
11 kx
11 kx ifdef subdir
11 kx .. := ../
11 kx endif # subdir
11 kx
11 kx # If `sources' was defined by the parent makefile, undefine it so
11 kx # we will later get it from wildcard search in this directory.
11 kx ifneq "$(findstring env,$(origin sources))" ""
11 kx sources :=
11 kx endif
11 kx
11 kx oPATH := $(PATH)
11 kx PATH := this definition should take precedence over $(oPATH)
11 kx ifeq ($(PATH),$(oPATH))
11 kx You must not use the -e flag when building the GNU C library.
11 kx else
11 kx PATH := $(oPATH)
11 kx endif
11 kx
11 kx ifndef +included-Makeconfig
11 kx include $(..)Makeconfig
11 kx endif
11 kx
11 kx # This variable is used in ``include $(o-iterator)'' after defining
11 kx # $(o-iterator-doit) to produce some desired rule using $o for the object
11 kx # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
11 kx # is produced for each object suffix in use.
11 kx o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
11 kx
11 kx # Include any system-specific makefiles.
11 kx
11 kx # This is here so things in sysdep Makefiles can easily depend on foo.h as
11 kx # appropriate and not worry about where foo.h comes from, which may be
11 kx # system dependent and not known by that Makefile.
11 kx vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
11 kx $(+sysdep_dirs) $(..)))
11 kx
11 kx # The same is true for RPC source files.
11 kx vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
11 kx $(+sysdep_dirs) $(..)))
11 kx
11 kx # Some sysdep makefiles use this to distinguish being included here from
11 kx # being included individually by a subdir makefile (hurd/Makefile needs this).
11 kx in-Makerules := yes
11 kx
11 kx sysdep-makefiles := $(wildcard $(sysdirs:=/Makefile))
11 kx ifneq (,$(sysdep-makefiles))
11 kx include $(sysdep-makefiles)
11 kx endif
11 kx
11 kx
11 kx # Reorder before-compile so that mach things come first, and hurd things
11 kx # second, before all else. The mach and hurd subdirectories have many
11 kx # generated header files which the much of rest of the library depends on,
11 kx # so it is best to build them first (and mach before hurd, at that).
11 kx before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
11 kx $(before-compile)) \
11 kx $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
11 kx $(before-compile))
11 kx
11 kx # Even before that, we need abi-versions.h which is generated right here.
11 kx ifeq ($(build-shared),yes)
11 kx ifndef avoid-generated
11 kx before-compile := $(common-objpfx)abi-versions.h $(before-compile)
11 kx $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
11 kx $(common-objpfx)Versions.all
11 kx LC_ALL=C $(AWK) -f $^ > $@T
11 kx mv -f $@T $@
11 kx
11 kx $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
11 kx sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
11 kx $(common-objpfx)abi-versions.h > $@T
11 kx mv -f $@T $@
11 kx
11 kx # first-versions.h and ldbl-compat-choose.h provide macros used in
11 kx # various symbol versioning macro calls.
11 kx before-compile := $(common-objpfx)first-versions.h \
11 kx $(common-objpfx)ldbl-compat-choose.h $(before-compile)
11 kx $(common-objpfx)first-versions.h: $(common-objpfx)versions.stmp
11 kx $(common-objpfx)ldbl-compat-choose.h: $(common-objpfx)versions.stmp
11 kx endif # avoid-generated
11 kx endif # $(build-shared) = yes
11 kx
11 kx ifndef avoid-generated
11 kx ifneq (,$(CXX))
11 kx # If C++ headers <cstdlib> or <cmath> are used, GCC 6 will include
11 kx # /usr/include/stdlib.h or /usr/include/math.h from "#include_next"
11 kx # (instead of stdlib/stdlib.h or math/math.h in the glibc source
11 kx # directory), and this turns up as a make dependency. An implicit
11 kx # rule will kick in and make will try to install stdlib/stdlib.h or
11 kx # math/math.h as /usr/include/stdlib.h or /usr/include/math.h because
11 kx # the target is out of date. We make a copy of <cstdlib> and <cmath>
11 kx # in the glibc build directory so that stdlib/stdlib.h and math/math.h
11 kx # will be used instead of /usr/include/stdlib.h and /usr/include/math.h.
11 kx before-compile := $(common-objpfx)cstdlib $(common-objpfx)cmath \
11 kx $(before-compile)
11 kx $(common-objpfx)cstdlib: $(c++-cstdlib-header)
11 kx $(INSTALL_DATA) $< $@T
11 kx $(move-if-change) $@T $@
11 kx $(common-objpfx)cmath: $(c++-cmath-header)
11 kx $(INSTALL_DATA) $< $@T
11 kx $(move-if-change) $@T $@
11 kx ifneq (,$(c++-bits-std_abs-h))
11 kx # Also make a copy of <bits/std_abs.h> from GCC 7 to prevent it from
11 kx # including /usr/include/stdlib.h.
11 kx before-compile := $(common-objpfx)bits/std_abs.h $(before-compile)
11 kx $(common-objpfx)bits/std_abs.h: $(c++-bits-std_abs-h)
11 kx $(INSTALL_DATA) $< $@T
11 kx $(move-if-change) $@T $@
11 kx endif
11 kx endif
11 kx
11 kx before-compile := $(common-objpfx)libc-abis.h $(before-compile)
11 kx $(common-objpfx)libc-abis.h: $(common-objpfx)libc-abis.stamp; @:
11 kx $(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \
11 kx $(firstword $(wildcard $(sysdirs:=/libc-abis)) \
11 kx $(..)libc-abis) \
11 kx $(..)Makerules
11 kx $(SHELL) $< \
11 kx $(base-machine)-$(config-vendor)-$(config-os) \
11 kx < $(word 2,$^) > $(@:.stamp=.h)T
11 kx $(move-if-change) $(@:.stamp=.h)T $(@:.stamp=.h)
11 kx touch $@
11 kx common-generated += $(common-objpfx)libc-abis.h
11 kx endif # avoid-generated
11 kx
11 kx ifeq (yes,$(build-shared))
11 kx $(common-objpfx)runtime-linker.h: $(common-objpfx)runtime-linker.stamp; @:
11 kx $(common-objpfx)runtime-linker.stamp: $(common-objpfx)config.make
11 kx $(make-target-directory)
11 kx echo '#define RUNTIME_LINKER "$(rtlddir)/$(rtld-installed-name)"' \
11 kx > ${@:stamp=T}
11 kx $(move-if-change) ${@:stamp=T} ${@:stamp=h}
11 kx touch $@
11 kx endif
11 kx
11 kx # Make sure the subdirectory for object files gets created.
11 kx ifdef objpfx
11 kx ifeq (,$(wildcard $(objpfx).))
11 kx before-compile += $(objpfx).
11 kx $(objpfx).:
11 kx $(make-target-directory)
11 kx endif
11 kx endif
11 kx
11 kx # Remove existing files from `before-compile'. Things are added there when
11 kx # they must exist for dependency generation to work right, but once they
11 kx # exist there is no further need for every single file to depend on them,
11 kx # and those gratuitous dependencies result in many gratuitous
11 kx # recompilations.
11 kx before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
11 kx
11 kx # Don't let any before-compile file be an intermediate and get removed.
11 kx ifdef before-compile
11 kx $(before-compile):
11 kx endif
11 kx
11 kx # We don't want $(common-objpfx) files to depend on miscellaneous stuff
11 kx # in subdirs.
11 kx ifdef subdir
11 kx common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
11 kx else
11 kx common-before-compile = $(before-compile)
11 kx endif
11 kx
11 kx ifndef subdir
11 kx # If a makefile needs to do something conditional on something that
11 kx # can only be figured out from headers, write a FOO.make.c input
11 kx # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
11 kx # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
11 kx #
11 kx # We only generate these in the top-level makefile, to avoid any weirdness
11 kx # from subdir-specific makefile tweaks creeping in on an update.
11 kx $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
11 kx rm -f $@T $@.dT
11 kx (echo '# Generated from $*.make.c by Makerules.'; \
11 kx $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
11 kx -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
11 kx | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \
11 kx echo 'common-generated += $(@F)'; \
11 kx sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
11 kx rm -f $@.dT) > $@T
11 kx mv -f $@T $@
11 kx endif
11 kx
11 kx ifdef subdir
11 kx sed-remove-dotdot := -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' \
11 kx -e 's@^\.\.\/\([^ \]*\)@$$(..)\1@g'
11 kx else
11 kx sed-remove-dotdot := -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' \
11 kx -e 's@^\([^ \/$$][^ \]*\)@$$(..)\1@g'
11 kx endif
11 kx
11 kx ifdef gen-py-const-headers
11 kx # We'll use a static pattern rule to match .pysym files with their
11 kx # corresponding generated .py files.
11 kx # The generated .py files go in the submodule's dir in the glibc build dir.
11 kx py-const-files := $(patsubst %.pysym,%.py,$(gen-py-const-headers))
11 kx py-const-dir := $(objpfx)
11 kx py-const := $(addprefix $(py-const-dir),$(py-const-files))
11 kx py-const-script := $(..)scripts/gen-as-const.py
11 kx
11 kx # This is a hack we use to generate .py files with constants for
11 kx # Python code.
11 kx #
11 kx # $@.tmp is a temporary file we use to store the partial contents of
11 kx # the target file. We do this instead of just writing on $@ because,
11 kx # if the build process terminates prematurely, re-running Make
11 kx # wouldn't run this rule since Make would see that the target file
11 kx # already exists (despite it being incomplete).
11 kx #
11 kx # The output is redirected to a .py file; we'll import it in the main
11 kx # Python code to read the constants generated by gen-as-const.py.
11 kx $(py-const): $(py-const-dir)%.py: %.pysym $(py-const-script) \
11 kx $(common-before-compile)
11 kx $(make-target-directory)
11 kx $(PYTHON) $(py-const-script) --python \
11 kx --cc="$(CC) $(CFLAGS) $(CPPFLAGS)" $< \
11 kx > $@.tmp
11 kx mv -f $@.tmp $@
11 kx
11 kx generated += $(py-const)
11 kx endif # gen-py-const-headers
11 kx
11 kx ifdef gen-as-const-headers
11 kx # Generating headers for assembly constants.
11 kx # We need this defined early to get into before-compile before
11 kx # it's used in sysd-rules, below.
11 kx # Define GEN_AS_CONST_HEADERS to avoid circular dependency [BZ #22792].
11 kx # NB: <tcb-offsets.h> is generated from tcb-offsets.sym to define
11 kx # offsets and sizes of types in <tls.h> and maybe <pthread.h> which
11 kx # may include <tcb-offsets.h>. Target header files can check if
11 kx # GEN_AS_CONST_HEADERS is defined to avoid circular dependency which
11 kx # may lead to build hang on a many-core machine.
11 kx $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.py \
11 kx %.sym $(common-before-compile)
11 kx $(PYTHON) $< --cc="$(CC) $(CFLAGS) $(CPPFLAGS) -DGEN_AS_CONST_HEADERS \
11 kx -MD -MP -MF $(@:.h=.h.d)T \
11 kx -MT '$(@:.h=.h.d) $(@:.h.d=.h)'" \
11 kx $(filter %.sym,$^) > $(@:.h.d=.h)T
11 kx sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
11 kx $(@:.h=.h.d)T > $(@:.h=.h.d)T2
11 kx rm -f $(@:.h=.h.d)T
11 kx mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
11 kx mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
11 kx vpath %.sym $(sysdirs)
11 kx before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
11 kx
11 kx tests-internal += $(gen-as-const-headers:%.sym=test-as-const-%)
11 kx generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
11 kx $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.py $(..)Makerules \
11 kx %.sym $(common-objpfx)%.h
11 kx ($(AWK) '{ sub(/^/, "asconst_", $$2); print; }' $(filter %.h,$^); \
11 kx $(PYTHON) $< --test $(filter %.sym,$^)) > $@T
11 kx mv -f $@T $@
11 kx endif
11 kx
11 kx ifeq (yes,$(build-shared))
11 kx # Generate the header containing the names of all shared libraries.
11 kx # We use a stamp file to avoid unnecessary recompilations.
11 kx before-compile += $(common-objpfx)gnu/lib-names.h
11 kx ifeq ($(soversions.mk-done),t)
11 kx ifndef abi-variants
11 kx lib-names-h-abi = gnu/lib-names.h
11 kx lib-names-stmp-abi = gnu/lib-names.stmp
11 kx else
11 kx lib-names-h-abi = gnu/lib-names-$(default-abi).h
11 kx lib-names-stmp-abi = gnu/lib-names-$(default-abi).stmp
11 kx before-compile += $(common-objpfx)$(lib-names-h-abi)
11 kx common-generated += gnu/lib-names.h
11 kx install-others-nosubdir: $(inst_includedir)/$(lib-names-h-abi)
11 kx $(common-objpfx)gnu/lib-names.h:
11 kx $(make-target-directory)
11 kx { \
11 kx echo '/* This file is automatically generated.';\
11 kx echo ' It defines macros to allow user program to find the shared'; \
11 kx echo ' library files which come as part of GNU libc. */'; \
11 kx echo '#ifndef __GNU_LIB_NAMES_H'; \
11 kx echo '#define __GNU_LIB_NAMES_H 1'; \
11 kx echo ''; \
11 kx $(if $(abi-includes), \
11 kx $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
11 kx echo '';) \
11 kx $(foreach v,$(abi-variants),\
11 kx $(if $(abi-$(v)-condition),\
11 kx echo '#if $(abi-$(v)-condition)'; \
11 kx echo '# include <gnu/lib-names-$(v).h>'); \
11 kx $(if $(abi-$(v)-condition),echo '#endif';)) \
11 kx echo ''; \
11 kx echo '#endif /* gnu/lib-names.h */'; \
11 kx } > $@
11 kx endif
11 kx $(common-objpfx)$(lib-names-h-abi): $(common-objpfx)$(lib-names-stmp-abi); @:
11 kx $(common-objpfx)$(lib-names-stmp-abi): $(..)scripts/lib-names.awk \
11 kx $(common-objpfx)soversions.i
11 kx $(make-target-directory)
11 kx { \
11 kx $(if $(abi-variants), \
11 kx echo '/* This file is automatically generated. */';\
11 kx echo '#ifndef __GNU_LIB_NAMES_H'; \
11 kx echo '# error "Never use <$(lib-names-h-abi)> directly; include <gnu/lib-names.h> instead."'; \
11 kx echo '#endif';, \
11 kx echo '/* This file is automatically generated.';\
11 kx echo ' It defines macros to allow user program to find the shared'; \
11 kx echo ' library files which come as part of GNU libc. */'; \
11 kx echo '#ifndef __GNU_LIB_NAMES_H'; \
11 kx echo '#define __GNU_LIB_NAMES_H 1';) \
11 kx echo ''; \
11 kx ($(foreach s,$(all-sonames), echo $(s);)) \
11 kx | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort; \
11 kx $(if $(abi-variants),, \
11 kx echo ''; \
11 kx echo '#endif /* gnu/lib-names.h */';) \
11 kx } > ${@:stmp=T}
11 kx $(move-if-change) ${@:stmp=T} ${@:stmp=h}
11 kx touch $@
11 kx endif
11 kx common-generated += $(lib-names-h-abi) $(lib-names-stmp-abi)
11 kx endif
11 kx
11 kx ###############################################################################
11 kx # NOTE! Everything adding to before-compile needs to come before this point! #
11 kx ###############################################################################
11 kx
11 kx # Generate an ordered list of implicit rules which find the source files in
11 kx # each sysdep directory. The old method was to use vpath to search all the
11 kx # sysdep directories. However, that had the problem that a .S file in a
11 kx # later directory would be chosen over a .c file in an earlier directory,
11 kx # which does not preserve the desired sysdeps ordering behavior.
11 kx
11 kx # System-dependent makefiles can put in `inhibit-sysdep-asm' regexps
11 kx # matching sysdep directories whose assembly source files should be
11 kx # suppressed.
11 kx
11 kx -include $(common-objpfx)sysd-rules
11 kx ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
11 kx # The value of $(+sysdep_dirs) the sysd-rules was computed for
11 kx # differs from the one we are using now. So force a rebuild of sysd-rules.
11 kx sysd-rules-force = FORCE
11 kx FORCE:
11 kx endif
11 kx $(common-objpfx)sysd-rules: $(..)scripts/sysd-rules.awk \
11 kx $(common-objpfx)config.make $(..)Makerules \
11 kx $(sysdep-makefiles) $(sysdep-makeconfigs) \
11 kx $(sysd-rules-force)
11 kx -@rm -f $@T
11 kx LC_ALL=C $(AWK) -f $< > $@T \
11 kx -v all_object_suffixes='$(all-object-suffixes)' \
11 kx -v inhibit_sysdep_asm='$(inhibit-sysdep-asm)' \
11 kx -v sysd_rules_patterns='$(sysd-rules-patterns)' \
11 kx -v config_sysdirs='$(config-sysdirs)'
11 kx mv -f $@T $@
11 kx
11 kx ifndef sysd-rules-done
11 kx # Don't do deps until this exists, because it provides rules to make the deps.
11 kx no_deps=t
11 kx endif
11 kx
11 kx define o-iterator-doit
11 kx $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
11 kx endef
11 kx object-suffixes-left := $(all-object-suffixes)
11 kx include $(o-iterator)
11 kx
11 kx define o-iterator-doit
11 kx $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
11 kx endef
11 kx object-suffixes-left := $(all-object-suffixes)
11 kx include $(o-iterator)
11 kx
11 kx define o-iterator-doit
11 kx $(objpfx)%$o: %.cc $(before-compile); $$(compile-command.cc)
11 kx endef
11 kx object-suffixes-left := $(all-object-suffixes)
11 kx include $(o-iterator)
11 kx
11 kx # Omit the objpfx rules when building in the source tree, because
11 kx # objpfx is empty and so these rules just override the ones above.
11 kx ifdef objpfx
11 kx # Define first rules to find the source files in $(objpfx).
11 kx # Generated source files will end up there.
11 kx define o-iterator-doit
11 kx $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
11 kx endef
11 kx object-suffixes-left := $(all-object-suffixes)
11 kx include $(o-iterator)
11 kx
11 kx define o-iterator-doit
11 kx $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
11 kx endef
11 kx object-suffixes-left := $(all-object-suffixes)
11 kx include $(o-iterator)
11 kx
11 kx define o-iterator-doit
11 kx $(objpfx)%$o: $(objpfx)%.cc $(before-compile); $$(compile-command.cc)
11 kx endef
11 kx object-suffixes-left := $(all-object-suffixes)
11 kx include $(o-iterator)
11 kx endif
11 kx
11 kx # Generate .dT files as we compile.
11 kx compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
11 kx compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
11 kx compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
11 kx compile-command.cc = $(compile.cc) $(OUTPUT_OPTION) $(compile-mkdep-flags)
11 kx
11 kx # Like compile-mkdep-flags, but for use with $(BUILD_CC). We don't want to
11 kx # track system includes here, they may spuriously trigger an install rule,
11 kx # and would cause the check-local-headers test to fail.
11 kx native-compile-mkdep-flags = -MMD -MP -MF $@.dt -MT $@
11 kx
11 kx # GCC can grok options after the file name, and it looks nicer that way.
11 kx compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
11 kx compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
11 kx compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
11 kx $(ASFLAGS) $(ASFLAGS-$(suffix $@))
11 kx COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS)
11 kx COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
11 kx $(ASFLAGS) $(ASFLAGS-$(suffix $@))
11 kx
11 kx # We need this for the output to go in the right place. It will default to
11 kx # empty if make was configured to work with a cc that can't grok -c and -o
11 kx # together. You can't compile the C library with such a compiler.
11 kx OUTPUT_OPTION = -o $@
11 kx
11 kx # This is the end of the pipeline for compiling generated C code.
11 kx compile-stdin.c = $(COMPILE.c) -o $@ -x c - $(compile-mkdep-flags)
11 kx
11 kx # We need the $(CFLAGS) to be in there to have the right predefines during
11 kx # the dependency run for C sources. But having it for assembly sources can
11 kx # get the wrong predefines.
11 kx S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
11 kx
11 kx ifneq (,$(objpfx))
11 kx # Continuation lines here are dangerous because they introduce spaces!
11 kx define sed-remove-objpfx
11 kx -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
11 kx -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
11 kx endef
11 kx endif
11 kx
11 kx # Modify the list of routines we build for different targets
11 kx
11 kx ifeq (yes,$(build-shared))
11 kx ifndef libc.so-version
11 kx # Undefine this because it can't work when we libc.so is unversioned.
11 kx static-only-routines =
11 kx endif
11 kx endif
11 kx
11 kx elide-routines.oS += $(filter-out $(static-only-routines),\
11 kx $(routines) $(aux) $(sysdep_routines))
11 kx elide-routines.os += $(static-only-routines)
11 kx
11 kx # If we have versioned code we don't need the old versions in any of the
11 kx # static libraries.
11 kx elide-routines.o += $(shared-only-routines)
11 kx elide-routines.op += $(shared-only-routines)
11 kx
11 kx # Shared library building.
11 kx
11 kx ifeq (yes,$(build-shared))
11 kx
11 kx # Reference map file only when shared libraries are built and a map file name
11 kx # is given.
11 kx ifeq ($(build-shared),yes)
11 kx map-file = $(firstword $($(@F:.so=-map)) \
11 kx $(addprefix $(common-objpfx), \
11 kx $(filter $(@F:.so=.map),$(version-maps))))
11 kx load-map-file = $(map-file:%=-Wl,--version-script=%)
11 kx endif
11 kx
11 kx # Compiler arguments to use to link a shared object with libc and
11 kx # ld.so. This is intended to be as similar as possible to a default
11 kx # link with an installed libc.
11 kx link-libc-args = -Wl,--start-group \
11 kx $(libc-for-link) \
11 kx $(common-objpfx)libc_nonshared.a \
11 kx -Wl,--as-needed $(elf-objpfx)ld.so -Wl,--no-as-needed \
11 kx -Wl,--end-group
11 kx
11 kx # The corresponding shared libc to use. This may be modified for a
11 kx # particular target.
11 kx libc-for-link = $(common-objpfx)libc.so
11 kx
11 kx # The corresponding dependencies. As these are used in dependencies,
11 kx # not just commands, they cannot use target-specific variables so need
11 kx # to name both possible libc.so objects.
11 kx link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
11 kx $(common-objpfx)libc_nonshared.a $(elf-objpfx)ld.so
11 kx
11 kx # Pattern rule to build a shared object from an archive of PIC objects.
11 kx # This must come after the installation rules so Make doesn't try to
11 kx # build shared libraries in place from the installed *_pic.a files.
11 kx # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
11 kx # on other shared objects. The linking with libc and ld.so is intended
11 kx # to be as similar as possible to a default link with an installed libc.
11 kx lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(link-libc-deps)
11 kx $(build-shlib) $(link-libc-args)
11 kx $(call after-link,$@)
11 kx
11 kx define build-shlib-helper
11 kx $(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \
11 kx $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(rtld-LDFLAGS) \
11 kx $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(dt-relr-ldflag)) \
11 kx $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
11 kx $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
11 kx -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
11 kx $(LDFLAGS.so) $(LDFLAGS-lib.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
11 kx -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
11 kx endef
11 kx
11 kx ifeq (yes,$(use-default-link))
11 kx # If the linker is good enough, we can let it use its default linker script.
11 kx # In the long term the custom linker script will be removed.
11 kx shlib-lds =
11 kx shlib-lds-flags =
11 kx else
11 kx # binutils only position loadable notes into the first page for binaries,
11 kx # not for shared objects
11 kx # lld --verbose does not dump a linker script. Use -fuse-ld=bfd.
11 kx $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
11 kx $(LINK.o) -shared -Wl,-O1 \
11 kx -nostdlib -nostartfiles -fuse-ld=bfd \
11 kx $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
11 kx -Wl,--verbose 2>/dev/null | \
11 kx sed > $@T \
11 kx -e '/^=========/,/^=========/!d;/^=========/d' \
11 kx $(if $(filter yes,$(have-hash-style)), \
11 kx -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
11 kx -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
11 kx -e '/DATA_SEGMENT_ALIGN/{H;g}' \
11 kx , \
11 kx -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
11 kx ) \
11 kx -e 's/^.*\*(\.dynbss).*$$/& \
11 kx PROVIDE(__start___libc_freeres_ptrs = .); \
11 kx *(__libc_freeres_ptrs) \
11 kx PROVIDE(__stop___libc_freeres_ptrs = .);/'\
11 kx -e 's@^.*\*(\.jcr).*$$@& \
11 kx PROVIDE(__start___libc_subfreeres = .);\
11 kx __libc_subfreeres : { *(__libc_subfreeres) }\
11 kx PROVIDE(__stop___libc_subfreeres = .);\
11 kx PROVIDE(__start___libc_IO_vtables = .);\
11 kx __libc_IO_vtables : { *(__libc_IO_vtables) }\
11 kx PROVIDE(__stop___libc_IO_vtables = .);\
11 kx /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
11 kx test -s $@T
11 kx mv -f $@T $@
11 kx common-generated += shlib.lds
11 kx
11 kx shlib-lds = $(common-objpfx)shlib.lds
11 kx shlib-lds-flags = -T $(shlib-lds)
11 kx endif
11 kx
11 kx define build-shlib
11 kx $(build-shlib-helper) -o $@ $(shlib-lds-flags) \
11 kx $(csu-objpfx)abi-note.o $(build-shlib-objlist)
11 kx endef
11 kx
11 kx define build-module-helper
11 kx $(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
11 kx $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
11 kx $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(dt-relr-ldflag)) \
11 kx -B$(csu-objpfx) $(load-map-file) \
11 kx $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
11 kx $(link-test-modules-rpath-link) \
11 kx -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
11 kx endef
11 kx
11 kx # This macro is similar to build-shlib but it does not define a soname
11 kx # and it does not depend on the destination name to start with `lib'.
11 kx # binutils only position loadable notes into the first page for binaries,
11 kx # not for shared objects
11 kx define build-module
11 kx $(build-module-helper) -o $@ $(shlib-lds-flags) \
11 kx $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
11 kx $(call after-link,$@)
11 kx endef
11 kx define build-module-asneeded
11 kx $(build-module-helper) -o $@ $(shlib-lds-flags) \
11 kx $(csu-objpfx)abi-note.o \
11 kx -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
11 kx $(link-libc-args)
11 kx $(call after-link,$@)
11 kx endef
11 kx
11 kx # sofini.os must be placed last since it terminates .eh_frame section.
11 kx build-module-helper-objlist = \
11 kx $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
11 kx $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \
11 kx $(elf-objpfx)sofini.os \
11 kx $(link-libc-deps),$^))
11 kx
11 kx build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
11 kx build-shlib-objlist = $(build-module-helper-objlist) \
11 kx $(LDLIBS-$(@F:lib%.so=%).so) \
11 kx $(filter $(elf-objpfx)sofini.os,$^)
11 kx
11 kx # Don't try to use -lc when making libc.so itself.
11 kx # Also omits crti.o and crtn.o, which we do not want
11 kx # since we define our own `.init' section specially.
11 kx LDFLAGS-c.so = -nostdlib -nostartfiles
11 kx # But we still want to link libc.so against $(libc.so-gnulib).
11 kx LDLIBS-c.so += $(libc.so-gnulib)
11 kx # Give libc.so an entry point and make it directly runnable itself.
11 kx LDFLAGS-c.so += -e __libc_main
11 kx # Pre-link the objects of libc_pic.a for .gnu.glibc-stub.* processing.
11 kx $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
11 kx $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
11 kx $(LDFLAGS-c_pic.os) $(whole-archive) $^ -o $@
11 kx
11 kx ifeq (,$(strip $(shlib-lds-flags)))
11 kx # Generate a list of -R options to excise .gnu.glibc-stub.* sections.
11 kx $(common-objpfx)libc_pic.opts: $(common-objpfx)libc_pic.os
11 kx $(OBJDUMP) -h $< | \
11 kx $(AWK) '$$2 ~ /\.gnu\.glibc-stub\./ { print "-R", $$2 }' \
11 kx > $@T
11 kx mv -f $@T $@
11 kx # Apply those -R options.
11 kx $(common-objpfx)libc_pic.os.clean: $(common-objpfx)libc_pic.opts \
11 kx $(common-objpfx)libc_pic.os
11 kx $(OBJCOPY) @$^ $@
11 kx generated += libc_pic.opts libc_pic.os.clean
11 kx
11 kx libc_pic_clean := .clean
11 kx endif
11 kx
11 kx # Build a possibly-modified version of libc_pic.a for use in building
11 kx # linkobj/libc.so.
11 kx ifeq (,$(filter sunrpc,$(subdirs)))
11 kx $(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a
11 kx $(make-target-directory)
11 kx ln -f $< $@
11 kx else
11 kx $(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a \
11 kx $(common-objpfx)sunrpc/librpc_compat_pic.a
11 kx $(make-target-directory)
11 kx (cd $(common-objpfx)linkobj; \
11 kx $(AR) x ../libc_pic.a; \
11 kx rm $$($(AR) t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//'); \
11 kx $(AR) x ../sunrpc/librpc_compat_pic.a; \
11 kx $(AR) cr libc_pic.a *.os; \
11 kx rm *.os)
11 kx endif # $(subdirs) contains sunrpc
11 kx
11 kx # Clear link-libc-deps for the libc.so libraries so build-shlibs does not
11 kx # filter ld.so out of the list of linked objects.
11 kx $(common-objpfx)libc.so: link-libc-deps = # empty
11 kx $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty
11 kx
11 kx # Use our own special initializer and finalizer files for the libc.so
11 kx # libraries.
11 kx $(common-objpfx)libc.so: $(common-objpfx)libc_pic.os$(libc_pic_clean) \
11 kx $(elf-objpfx)sofini.os \
11 kx $(elf-objpfx)interp.os \
11 kx $(elf-objpfx)ld.so \
11 kx $(shlib-lds)
11 kx $(build-shlib)
11 kx $(call after-link,$@)
11 kx
11 kx $(common-objpfx)linkobj/libc.so: $(common-objpfx)linkobj/libc_pic.a \
11 kx $(elf-objpfx)sofini.os \
11 kx $(elf-objpfx)interp.os \
11 kx $(elf-objpfx)ld.so \
11 kx $(shlib-lds)
11 kx $(build-shlib)
11 kx $(call after-link,$@)
11 kx
11 kx ifeq ($(build-shared),yes)
11 kx $(common-objpfx)libc.so: $(common-objpfx)libc.map
11 kx endif
11 kx common-generated += libc.so libc_pic.os
11 kx ifdef libc.so-version
11 kx $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
11 kx $(make-link)
11 kx common-generated += libc.so$(libc.so-version)
11 kx endif
11 kx endif
11 kx
11 kx # Figure out the source filenames in this directory.
11 kx
11 kx override sources := $(addsuffix .c,\
11 kx $(filter-out $(elided-routines),\
11 kx $(routines) $(aux) \
11 kx $(sysdep_routines)))
11 kx sysdep_routines := $(sysdep_routines)
11 kx
11 kx headers := $(headers) $(sysdep_headers)
11 kx
11 kx # This is the list of all object files, gotten by
11 kx # replacing every ".c" in `sources' with a ".o".
11 kx override objects := $(addprefix $(objpfx),$(sources:.c=.o))
11 kx
11 kx
11 kx # The makefile may define $(extra-libs) with `libfoo libbar'
11 kx # to build libfoo.a et al from the modules listed in $(libfoo-routines).
11 kx ifdef extra-libs
11 kx # extra-lib.mk is included once for each extra lib to define rules
11 kx # to build it, and to add its objects to the various variables.
11 kx # During its evaluation, $(lib) is set to the name of the library.
11 kx extra-libs-left := $(extra-libs)
11 kx include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
11 kx endif
11 kx
11 kx
11 kx # The makefile may define $(modules-names) to build additional modules.
11 kx # These are built with $(build-module), except any in $(modules-names-nobuild).
11 kx # MODULE_NAME=extramodules, except any in $(modules-names-tests).
11 kx ifdef modules-names
11 kx cpp-srcs-left := $(filter-out $(modules-names-tests),$(modules-names))
11 kx ifneq (,$(cpp-srcs-left))
11 kx lib := extramodules
11 kx include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
11 kx endif
11 kx
11 kx ifdef modules-names-tests
11 kx cpp-srcs-left := $(filter $(modules-names-tests),$(modules-names))
11 kx ifneq (,$(cpp-srcs-left))
11 kx lib := testsuite
11 kx include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
11 kx endif
11 kx endif
11 kx
11 kx extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
11 kx $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
11 kx $(objpfx)%.os $(shlib-lds) $(link-libs-deps)
11 kx $(build-module)
11 kx endif
11 kx
11 kx +depfiles := $(sources:.c=.d) \
11 kx $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
11 kx $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
11 kx $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
11 kx $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
11 kx $(tests-container) $(tests-printers) \
11 kx $(test-srcs) $(tests-time64) $(xtests-time64))
11 kx ifeq ($(build-programs),yes)
11 kx +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
11 kx endif
11 kx +depfiles := $(addprefix $(objpfx),\
11 kx $(filter-out $(addsuffix .d,$(omit-deps)),\
11 kx $(+depfiles)))
11 kx all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
11 kx +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
11 kx $(wildcard $(all-dt-files:.dt=.d))
11 kx
11 kx # This is a funny rule in that it removes its input file.
11 kx %.d: %.dt
11 kx @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
11 kx mv -f $(@:.d=.T) $@ && \
11 kx rm -f $<
11 kx
11 kx # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
11 kx # They will be generated when they're needed, and trying too early won't work.
11 kx +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
11 kx +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
11 kx $(+gen-as-const)))
11 kx
11 kx ifdef +depfiles
11 kx ifneq ($(no_deps),t)
11 kx -include $(+depfiles)
11 kx endif
11 kx endif
11 kx
11 kx # Maximize efficiency by minimizing the number of rules.
11 kx .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
11 kx # Don't define any builtin rules.
11 kx MAKEFLAGS := $(MAKEFLAGS) -r
11 kx
11 kx # Generic rule for making directories.
11 kx %/:
11 kx # mkdir isn't smart enough to strip a trailing /.
11 kx # We always require a mkdir which supports the -p option to avoid error
11 kx # messages in case of races.
11 kx mkdir -p $(@:%/=%)
11 kx
11 kx # Make sure that object files are not removed
11 kx # when they are intermediates between sources and library members.
11 kx .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
11 kx
11 kx # Make sure that the parent library archive is never removed.
11 kx .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
11 kx
11 kx # Use the verbose option of ar and tar when not running silently.
11 kx ifeq ($(silent-make),no) # if not -s
11 kx verbose := v
11 kx else # -s
11 kx verbose :=
11 kx endif # not -s
11 kx
11 kx ARFLAGS := r$(verbose)
11 kx CREATE_ARFLAGS := cru$(verbose)
11 kx
11 kx # This makes all the object files in the parent library archive.
11 kx
11 kx .PHONY: lib lib-noranlib
11 kx lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
11 kx lib-noranlib: libobjs
11 kx
11 kx # For object-suffix $o, the list of objects with that suffix.
11 kx # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
11 kx o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
11 kx $(elide-routines$o)),\
11 kx $(objects))) \
11 kx $(addprefix $(objpfx),$(o-objects$o))
11 kx
11 kx others: $(addprefix $(objpfx),$(install-lib))
11 kx
11 kx ifndef objects
11 kx
11 kx # Create the stamp$o files to keep the parent makefile happy.
11 kx subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
11 kx $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
11 kx $(make-target-directory)
11 kx rm -f $@; > $@
11 kx else
11 kx
11 kx # Define explicit rules to update each $(objpfx)stamp.SUFFIX
11 kx # timestamp file; these rules (one explicit rule is generated for each
11 kx # object suffix) write a list of objects to update in the stamp file.
11 kx # The parent will then actually add them all to the archive in the
11 kx # archive rule, below.
11 kx define o-iterator-doit
11 kx $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
11 kx endef
11 kx define do-stamp
11 kx $(make-target-directory)
11 kx echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
11 kx mv -f $@T $@
11 kx endef
11 kx object-suffixes-left := $(object-suffixes-for-libc)
11 kx include $(o-iterator)
11 kx
11 kx endif
11 kx
11 kx # Now define explicit rules to build the library archives; these depend
11 kx # on the stamp files built above.
11 kx define o-iterator-doit
11 kx $(common-objpfx)$(patsubst %,$(libtype$o),c): \
11 kx $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
11 kx endef
11 kx define do-makelib
11 kx cd $(common-objdir) && \
11 kx $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
11 kx endef
11 kx subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
11 kx subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
11 kx ifndef subdir
11 kx $(subdirs-stamps): subdir_lib;
11 kx endif
11 kx object-suffixes-left = $(object-suffixes-for-libc)
11 kx include $(o-iterator)
11 kx
11 kx
11 kx # This makes all the object files.
11 kx .PHONY: objects objs libobjs extra-objs
11 kx objects objs: libobjs extra-objs
11 kx libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
11 kx extra-objs: $(addprefix $(objpfx),$(extra-objs))
11 kx
11 kx # Canned sequence for building an extra library archive.
11 kx define build-extra-lib
11 kx $(patsubst %/,cd % &&,$(objpfx)) \
11 kx $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
11 kx $(patsubst $(objpfx)%,%,$^)
11 kx endef
11 kx
11 kx # Installation.
11 kx
11 kx .PHONY: force-install
11 kx force-install:
11 kx
11 kx # $(install-lib) are installed from the object directory into $(libdir);
11 kx # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
11 kx # unless they also appear in $(non-lib.a). $(install-data) are installed as
11 kx # they are into $(datadir). $(headers) are installed as they are in
11 kx # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
11 kx # are installed from the object directory into $(bindir), $(bindir) and
11 kx # $(sbindir), respectively. $(install-others) and $(install-others-programs)
11 kx # are absolute path names of files to install; rules to install them are
11 kx # defined elsewhere.
11 kx
11 kx # The simple library name to install libc.a under.
11 kx # This could be defined by a sysdep Makefile.
11 kx ifndef libc-name
11 kx libc-name := c
11 kx endif
11 kx
11 kx define do-install
11 kx $(make-target-directory)
11 kx $(INSTALL_DATA) $< $@
11 kx endef
11 kx
11 kx # Make the target directory if it doesn't exist, using the `mkinstalldirs'
11 kx # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
11 kx define make-target-directory
11 kx $(addprefix $(..)./scripts/mkinstalldirs ,\
11 kx $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
11 kx endef
11 kx
11 kx # Any directory (parent or subdir) should install libc.a; this way
11 kx # "make install" in a subdir is guaranteed to install everything it changes.
11 kx installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
11 kx $(inst_libdir)/$(patsubst %,$(libtype$o),\
11 kx $(libprefix)$(libc-name)))
11 kx
11 kx .PHONY: check-install-supported
11 kx check-install-supported:
11 kx
11 kx # Check to see if the prefix or exec_prefix GNU standard variable
11 kx # has been overridden on the command line and, if so, fail with
11 kx # an error message since doing so is not supported (set DESTDIR
11 kx # instead).
11 kx ifeq ($(origin prefix),command line)
11 kx check-install-supported:
11 kx $(error Overriding prefix is not supported. Set DESTDIR instead.)
11 kx endif
11 kx
11 kx ifeq ($(origin exec_prefix),command line)
11 kx check-install-supported:
11 kx $(error Overriding exec_prefix is not supported. Set DESTDIR instead.)
11 kx endif
11 kx
11 kx install: check-install-supported
11 kx
11 kx install: $(installed-libcs)
11 kx $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
11 kx $(make-target-directory)
11 kx $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
11 kx
11 kx define do-install-program
11 kx $(make-target-directory)
11 kx $(INSTALL_PROGRAM) $< $@.new
11 kx mv -f $@.new $@
11 kx endef
11 kx
11 kx define do-install-script
11 kx $(make-target-directory)
11 kx $(INSTALL_SCRIPT) $< $@.new
11 kx mv -f $@.new $@
11 kx endef
11 kx
11 kx install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
11 kx install-lib := $(filter-out %.so %_pic.a,$(install-lib))
11 kx
11 kx ifeq (yes,$(build-shared))
11 kx # Find which .so's have a version number in their soname.
11 kx versioned := $(strip $(foreach so,$(install-lib.so),\
11 kx $(patsubst %,$(so),$($(so)-version))))
11 kx
11 kx install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
11 kx install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
11 kx
11 kx # For libraries whose soname have version numbers, we install two files:
11 kx # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
11 kx # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME
11 kx install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
11 kx $(foreach L,$(install-lib.so-versioned),\
11 kx $(inst_libdir)/$L \
11 kx $(inst_slibdir)/$L$($L-version))
11 kx
11 kx # Install all the unversioned shared libraries.
11 kx $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
11 kx $(objpfx)%.so $(+force)
11 kx $(do-install-program)
11 kx
11 kx ifneq ($(findstring -s,$(LN_S)),)
11 kx define make-link
11 kx rm -f $@.new
11 kx $(SHELL) $(..)scripts/rellns-sh $< $@.new
11 kx mv -f $@.new $@
11 kx endef
11 kx define make-link-multidir
11 kx $(patsubst %/,cd %,$(objpfx)); \
11 kx $(addprefix $(abspath $(..)scripts/mkinstalldirs) ,$(dir $(multidir))); \
11 kx $(LN_S) . $(multidir) 2> /dev/null; \
11 kx test -L $(multidir)
11 kx endef
11 kx else
11 kx # If we have no symbolic links don't bother with rellns-sh.
11 kx define make-link
11 kx rm -f $@.new
11 kx $(LN_S) $< $@.new
11 kx mv -f $@.new $@
11 kx endef
11 kx define make-link-multidir
11 kx $(make-target-directory)
11 kx ln -f $(objpfx)/$(@F) $@
11 kx endef
11 kx endif
11 kx
11 kx ifdef libc.so-version
11 kx $(inst_slibdir)/libc.so$(libc.so-version): $(common-objpfx)libc.so $(+force)
11 kx $(do-install-program)
11 kx
11 kx install: $(inst_slibdir)/libc.so$(libc.so-version)
11 kx
11 kx # This fragment of linker script gives the OUTPUT_FORMAT statement
11 kx # for the configuration we are building. We put this statement into
11 kx # the linker scripts we install for -lc et al so that they will not be
11 kx # used by a link for a different format on a multi-architecture system.
11 kx $(common-objpfx)format.lds: $(common-objpfx)config.make \
11 kx $(common-objpfx)config.h $(..)Makerules
11 kx $(LINK.o) -shared -nostdlib -nostartfiles \
11 kx -x assembler /dev/null -o $@.so
11 kx $(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@
11 kx rm -f $@.so
11 kx common-generated += format.lds
11 kx
11 kx ifndef subdir
11 kx # What we install as libc.so for programs to link against is in fact a
11 kx # link script. It contains references for the various libraries we need.
11 kx # The libc.so object is not complete since some functions are only defined
11 kx # in libc_nonshared.a.
11 kx # We need to use absolute paths since otherwise local copies (if they exist)
11 kx # of the files are taken by the linker.
11 kx install: $(inst_libdir)/libc.so
11 kx $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
11 kx $(common-objpfx)libc.so$(libc.so-version) \
11 kx $(inst_libdir)/$(patsubst %,$(libtype.oS),\
11 kx $(libprefix)$(libc-name)) \
11 kx $(+force)
11 kx (echo '/* GNU ld script';\
11 kx echo ' Use the shared library, but some functions are only in';\
11 kx echo ' the static library, so try that secondarily. */';\
11 kx cat $<; \
11 kx echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
11 kx '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
11 kx ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \
11 kx ) > $@.new
11 kx mv -f $@.new $@
11 kx
11 kx endif
11 kx
11 kx else
11 kx install: $(inst_slibdir)/libc.so
11 kx $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
11 kx $(do-install-program)
11 kx endif
11 kx
11 kx ifneq (,$(versioned))
11 kx # Produce three sets of rules as above for all the smaller versioned libraries.
11 kx
11 kx define o-iterator-doit
11 kx $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
11 kx endef
11 kx object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
11 kx ifneq (,$(object-suffixes-left))
11 kx include $(o-iterator)
11 kx endif
11 kx
11 kx # Make symlinks in the build directory, because the versioned names might
11 kx # be referenced by a DT_NEEDED in another library.
11 kx define o-iterator-doit
11 kx $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
11 kx endef
11 kx object-suffixes-left := $(versioned)
11 kx include $(o-iterator)
11 kx
11 kx generated += $(foreach o,$(versioned),$o$($o-version))
11 kx
11 kx define o-iterator-doit
11 kx $(inst_slibdir)/$o$($o-version): $(objpfx)$o $(+force);
11 kx $$(do-install-program)
11 kx endef
11 kx object-suffixes-left := $(versioned)
11 kx include $(o-iterator)
11 kx endif # ifneq (,$(versioned))
11 kx
11 kx define do-install-so
11 kx $(do-install-program)
11 kx $(patsubst %,$(LN_S) -f $(@F) \
11 kx $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
11 kx $(filter-out %.so,$@))
11 kx endef
11 kx
11 kx so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
11 kx $(foreach v,$(so-versions),\
11 kx $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
11 kx $(+force)
11 kx $(do-install-so)
11 kx $(foreach v,$(so-versions),\
11 kx $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
11 kx $(do-install-so)
11 kx endif
11 kx
11 kx ifdef install-bin
11 kx $(addprefix $(inst_bindir)/,$(install-bin)): \
11 kx $(inst_bindir)/%: $(objpfx)% $(+force)
11 kx $(do-install-program)
11 kx endif
11 kx ifdef install-bin-script
11 kx $(addprefix $(inst_bindir)/,$(install-bin-script)): \
11 kx $(inst_bindir)/%: $(objpfx)% $(+force)
11 kx $(do-install-script)
11 kx endif
11 kx ifdef install-rootsbin
11 kx $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
11 kx $(inst_rootsbindir)/%: $(objpfx)% $(+force)
11 kx $(do-install-program)
11 kx endif
11 kx ifdef install-sbin
11 kx $(addprefix $(inst_sbindir)/,$(install-sbin)): \
11 kx $(inst_sbindir)/%: $(objpfx)% $(+force)
11 kx $(do-install-program)
11 kx endif
11 kx ifdef install-lib
11 kx install-lib.a := $(filter lib%.a,$(install-lib))
11 kx install-lib.a := $(filter-out $(install-lib-ldscripts),$(install-lib.a))
11 kx install-lib-non.a := $(filter-out lib%.a,$(install-lib))
11 kx ifdef install-lib-non.a
11 kx $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
11 kx $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
11 kx $(do-install)
11 kx endif
11 kx ifdef install-lib.a
11 kx $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
11 kx $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
11 kx $(do-install)
11 kx endif
11 kx endif
11 kx ifdef install-data
11 kx $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
11 kx $(do-install)
11 kx endif
11 kx headers := $(strip $(headers))
11 kx ifdef headers
11 kx # This implicit rule installs headers from the source directory.
11 kx # It may be ignored in preference to rules from sysd-rules to find
11 kx # headers in the sysdeps tree.
11 kx $(inst_includedir)/%.h: $(objpfx)%.h $(+force)
11 kx $(do-install)
11 kx $(inst_includedir)/%.h: $(common-objpfx)%.h $(+force)
11 kx $(do-install)
11 kx $(inst_includedir)/%.h: %.h $(+force)
11 kx $(do-install)
11 kx $(inst_includedir)/%.h: $(..)include/%.h $(+force)
11 kx $(do-install)
11 kx headers-nonh := $(filter-out %.h,$(headers))
11 kx ifdef headers-nonh
11 kx $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
11 kx % $(+force)
11 kx $(do-install)
11 kx endif # headers-nonh
11 kx endif # headers
11 kx
11 kx .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
11 kx install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
11 kx install-data-nosubdir install-headers-nosubdir
11 kx install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
11 kx install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
11 kx install-rootsbin-nosubdir: \
11 kx $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
11 kx install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
11 kx install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
11 kx $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
11 kx $(addprefix $(libprefix),$(install-lib-non.a)))
11 kx install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
11 kx install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
11 kx install-others-nosubdir: $(install-others)
11 kx install-others-programs-nosubdir: $(install-others-programs)
11 kx
11 kx # We need all the `-nosubdir' targets so that `install' in the parent
11 kx # doesn't depend on several things which each iterate over the subdirs.
11 kx # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
11 kx # subroutine. Then in the parent `install-FOO' also causes subdir makes.
11 kx install-%:: install-%-nosubdir ;
11 kx
11 kx .PHONY: install install-no-libc.a-nosubdir
11 kx install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
11 kx install-lib-nosubdir install-others-nosubdir
11 kx ifeq ($(build-programs),yes)
11 kx install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
11 kx install-rootsbin-nosubdir install-sbin-nosubdir \
11 kx install-others-programs-nosubdir
11 kx endif
11 kx install: install-no-libc.a-nosubdir
11 kx
11 kx # Command to compile $< using the native libraries.
11 kx define native-compile
11 kx $(make-target-directory)
11 kx $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
11 kx $< $(OUTPUT_OPTION) $(BUILD_LDFLAGS)
11 kx endef
11 kx
11 kx # We always want to use configuration definitions.
11 kx ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -D_GNU_SOURCE \
11 kx -DIS_IN_build -include $(common-objpfx)config.h
11 kx
11 kx # Support the GNU standard name for this target.
11 kx .PHONY: check
11 kx check: tests
11 kx # Special target to run tests which cannot be run unconditionally.
11 kx # Maintainers should use this target.
11 kx .PHONY: xcheck
11 kx xcheck: xtests
11 kx
11 kx # Handle tests-time64 and xtests-time64 that should built with LFS
11 kx # and 64-bit time support.
11 kx include $(o-iterator)
11 kx define o-iterator-doit
11 kx $(foreach f,$(tests-time64) $(xtests-time64),\
11 kx $(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
11 kx endef
11 kx object-suffixes-left := $(all-object-suffixes)
11 kx include $(o-iterator)
11 kx
11 kx ifeq ($(have-time64-compat),yes)
11 kx tests += $(foreach t,$(tests-time64),$(t))
11 kx xtests += $(foreach t,$(xtests-time64),$(t))
11 kx endif
11 kx
11 kx # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
11 kx # that almost all internal declarations from config.h, libc-symbols.h, and
11 kx # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
11 kx all-testsuite := $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) \
11 kx $(tests-container))
11 kx ifneq (,$(all-testsuite))
11 kx cpp-srcs-left = $(all-testsuite)
11 kx lib := testsuite
11 kx include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
11 kx endif
11 kx
11 kx all-nonlib := $(strip $(others) $(others-extras))
11 kx ifneq (,$(all-nonlib))
11 kx cpp-srcs-left = $(all-nonlib)
11 kx lib := nonlib
11 kx include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
11 kx endif
11 kx
11 kx # All internal tests use testsuite-internal module since for 64 bit time
11 kx # support is set as default for MODULE_NAME=nonlib (which include some
11 kx # installed programs).
11 kx all-testsuite-internal := $(strip $(tests-internal) $(test-internal-extras))
11 kx ifneq (,$(all-testsuite-internal))
11 kx cpp-srcs-left = $(all-testsuite-internal)
11 kx lib := testsuite-internal
11 kx include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
11 kx endif
11 kx
11 kx ifeq ($(build-shared),yes)
11 kx # Generate normalized lists of symbols, versions, and data sizes.
11 kx # This is handy for checking against existing library binaries.
11 kx
11 kx %.symlist: $(..)scripts/abilist.awk %.dynsym
11 kx LC_ALL=C $(AWK) -f $^ > $@T
11 kx mv -f $@T $@
11 kx
11 kx %.dynsym: %.so
11 kx LC_ALL=C $(OBJDUMP) --dynamic-syms $< > $@T
11 kx mv -f $@T $@
11 kx
11 kx vpath %.abilist $(+sysdep_dirs)
11 kx
11 kx # The .PRECIOUS rule prevents the files built by an implicit rule whose
11 kx # target pattern is %.symlist from being considered "intermediate files"
11 kx # and automatically removed. We only want these files to be removed by
11 kx # 'make clean', which is handled by the 'generated' variable.
11 kx .PRECIOUS: %.symlist
11 kx generated += $(extra-libs:=.symlist)
11 kx
11 kx $(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
11 kx $(objpfx)%.symlist
11 kx $(check-abi); \
11 kx $(evaluate-test)
11 kx $(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
11 kx $(common-objpfx)%.symlist
11 kx $(check-abi); \
11 kx $(evaluate-test)
11 kx define check-abi
11 kx diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^) > $@
11 kx endef
11 kx
11 kx update-abi-%: $(objpfx)%.symlist %.abilist
11 kx $(update-abi)
11 kx update-abi-%: $(common-objpfx)%.symlist %.abilist
11 kx $(update-abi)
11 kx define update-abi
11 kx @if cmp -s $^ 2> /dev/null; \
11 kx then \
11 kx echo '+++ $(filter %.abilist,$^) is unchanged'; \
11 kx else cp -f $^; \
11 kx echo '*** Now check $(filter %.abilist,$^) changes for correctness ***'; \
11 kx fi
11 kx endef
11 kx
11 kx # Patch all .abilist files for one DSO. The find command locates abilist
11 kx # files for all architectures. The abilist files in /generic/ are
11 kx # filtered out because these are expected to remain empty.
11 kx define update-all-abi
11 kx $(SHELL) $(..)scripts/update-abilist.sh $^ \
11 kx $$(find $(..)sysdeps -name '$*.abilist' \! -path '*/generic/*')
11 kx endef
11 kx update-all-abi-%: %.abilist $(objpfx)%.symlist
11 kx $(update-all-abi)
11 kx update-all-abi-%: %.abilist $(common-objpfx)%.symlist
11 kx $(update-all-abi)
11 kx
11 kx .PHONY: update-abi update-all-abi check-abi
11 kx update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
11 kx update-all-abi: $(patsubst %.so,update-all-abi-%,$(install-lib.so-versioned))
11 kx check-abi-list = $(patsubst %.so,$(objpfx)check-abi-%.out, \
11 kx $(install-lib.so-versioned))
11 kx check-abi: $(check-abi-list)
11 kx ifdef subdir
11 kx subdir_check-abi: check-abi
11 kx subdir_update-abi: update-abi
11 kx subdir_update-all-abi: update-all-abi
11 kx else
11 kx check-abi: subdir_check-abi
11 kx if grep -q '^FAIL:' $(objpfx)*/check-abi*.test-result; then \
11 kx cat $(objpfx)*/check-abi*.out && exit 1; fi
11 kx update-abi: subdir_update-abi
11 kx update-all-abi: subdir_update-all-abi
11 kx endif
11 kx
11 kx ifeq ($(subdir),elf)
11 kx check-abi: $(objpfx)check-abi-libc.out
11 kx tests-special += $(objpfx)check-abi-libc.out
11 kx update-abi: update-abi-libc
11 kx update-all-abi: update-all-abi-libc
11 kx common-generated += libc.symlist
11 kx endif
11 kx
11 kx ifeq ($(build-shared),yes)
11 kx ifdef subdir
11 kx tests-special += $(check-abi-list)
11 kx endif
11 kx endif
11 kx
11 kx endif
11 kx
11 kx # These will have been set by sysdeps/posix/Makefile.
11 kx L_tmpnam ?= 1
11 kx TMP_MAX ?= 0
11 kx L_ctermid ?= 1
11 kx L_cuserid ?= 1
11 kx
11 kx stdio_lim = $(common-objpfx)bits/stdio_lim.h
11 kx
11 kx $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
11 kx $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
11 kx $(common-objpfx)config.make
11 kx $(make-target-directory)
11 kx { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
11 kx } | \
11 kx $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
11 kx $(CPPUNDEFS) $(+includes) -xc - -o $(@:st=hT)
11 kx sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
11 kx $(@:st=dT) > $(@:st=dt)
11 kx mv -f $(@:st=dt) $(@:st=d)
11 kx fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
11 kx filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
11 kx fopen_max=$${fopen_max:-16}; \
11 kx filename_max=$${filename_max:-1024}; \
11 kx sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
11 kx -e "s/@FILENAME_MAX@/$$filename_max/" \
11 kx -e "s/@L_tmpnam@/$(L_tmpnam)/" \
11 kx -e "s/@TMP_MAX@/$(TMP_MAX)/" \
11 kx -e "s/@L_ctermid@/$(L_ctermid)/" \
11 kx -e "s/@L_cuserid@/$(L_cuserid)/" \
11 kx $< > $(@:st=h.new)
11 kx $(move-if-change) $(@:st=h.new) $(@:st=h)
11 kx # Remove these last so that they can be examined if something went wrong.
11 kx rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
11 kx touch $@
11 kx # Get dependencies.
11 kx ifndef no_deps
11 kx -include $(stdio_lim:h=d)
11 kx endif
11 kx common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
11 kx
11 kx FORCE:
11 kx
11 kx .PHONY: echo-headers
11 kx echo-headers:
11 kx @echo $(headers)
11 kx
11 kx %.bz2: %; bzip2 -9vk $<
11 kx %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
11 kx %.xz: %; xz -9evk $<
11 kx
11 kx # Common cleaning targets.
11 kx
11 kx .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
11 kx clean: common-clean
11 kx mostlyclean: common-mostlyclean
11 kx
11 kx do-tests-clean:
11 kx -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) \
11 kx $(tests-internal) \
11 kx $(xtests) \
11 kx $(test-srcs)) \
11 kx $(addsuffix .test-result,$(tests) \
11 kx $(tests-internal) \
11 kx $(xtests) \
11 kx $(test-srcs)))
11 kx
11 kx # Remove the object files.
11 kx common-mostlyclean:
11 kx -rm -f $(addprefix $(objpfx),$(tests) $(tests-internal) $(xtests) \
11 kx $(test-srcs) \
11 kx $(others) $(sysdep-others) stubs \
11 kx $(addsuffix .o,$(tests) \
11 kx $(tests-internal) \
11 kx $(xtests) \
11 kx $(test-srcs) \
11 kx $(others) \
11 kx $(sysdep-others)) \
11 kx $(addsuffix .out,$(tests) \
11 kx $(tests-internal) \
11 kx $(xtests) \
11 kx $(test-srcs)) \
11 kx $(addsuffix .test-result,$(tests) \
11 kx $(tests-internal) \
11 kx $(xtests) \
11 kx $(test-srcs)))
11 kx -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
11 kx $(install-lib) $(install-lib.so) \
11 kx $(install-lib.so:%.so=%_pic.a))
11 kx -rm -f core
11 kx -rm -f $(objpfx)rtld-*.os
11 kx $(rmobjs)
11 kx define rmobjs
11 kx $(foreach o,$(object-suffixes-for-libc),
11 kx -rm -f $(objpfx)stamp$o $(o-objects))
11 kx endef
11 kx
11 kx # Also remove the dependencies and generated source files.
11 kx common-clean: common-mostlyclean
11 kx -rm -f $(addprefix $(objpfx),$(generated))
11 kx -rm -f $(objpfx)*.d $(objpfx)*.dt
11 kx -rm -fr $(addprefix $(objpfx),$(generated-dirs))
11 kx -rm -f $(addprefix $(common-objpfx),$(common-generated))
11 kx -rm -f $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
11 kx
11 kx # Produce a file `stubs' which contains `#define __stub_FUNCTION'
11 kx # for each function which is a stub.
11 kx
11 kx ifdef objpfx
11 kx .PHONY: stubs # The parent Makefile calls this target.
11 kx stubs: $(objpfx)stubs
11 kx endif
11 kx objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
11 kx $(addprefix $(objpfx),$(extra-objs))
11 kx $(objpfx)stubs: $(objs-for-stubs)
11 kx ifneq (,$(strip $(objs-for-stubs)))
11 kx (cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
11 kx $(AWK) '/\.gnu\.glibc-stub\./ { \
11 kx sub(/\.gnu\.glibc-stub\./, "", $$2); \
11 kx stubs[$$2] = 1; } \
11 kx END { for (s in stubs) print "#define __stub_" s }' > $@T
11 kx mv -f $@T $@
11 kx else
11 kx > $@
11 kx endif
11 kx
11 kx ifneq (,$(strip $(gpl2lgpl)))
11 kx ifneq (,$(wildcard $(..)gpl2lgpl.sed))
11 kx # Snarf from the master source and frob the copying notice.
11 kx $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
11 kx sed -f $^ > $@-tmp
11 kx # So I don't edit them by mistake.
11 kx chmod a-w $@-tmp
11 kx mv -f $@-tmp $@
11 kx endif
11 kx endif
11 kx
11 kx # Local Variables:
11 kx # mode: makefile
11 kx # End: