diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-08-20 20:54:39 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-08-20 20:54:39 +0200 |
commit | 29af7775cfef6ed3b466b92e44387574122ed61b (patch) | |
tree | c968738daba6d87d69dc4e8b4cb1445a7b6420cb /Makerules | |
parent | 4893e0ed57daaff901442bacc10ae09cd3e1850f (diff) | |
parent | f76453c31593957fec1a99b986bfa5506618b79c (diff) |
Merge branch 'baseline' into refs/top-bases/tschwinge/Roger_Whittaker
Diffstat (limited to 'Makerules')
-rw-r--r-- | Makerules | 209 |
1 files changed, 165 insertions, 44 deletions
@@ -1,4 +1,4 @@ -# Copyright (C) 1991-2014 Free Software Foundation, Inc. +# Copyright (C) 1991-2015 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 @@ -98,7 +98,7 @@ 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 + LC_ALL=C $(AWK) -f $^ > $@T mv -f $@T $@ $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h @@ -123,6 +123,16 @@ $(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \ common-generated += $(common-objpfx)libc-abis.h endif # avoid-generated +ifeq (yes,$(build-shared)) +$(common-objpfx)runtime-linker.h: $(common-objpfx)runtime-linker.stamp; @: +$(common-objpfx)runtime-linker.stamp: $(common-objpfx)config.make + $(make-target-directory) + echo '#define RUNTIME_LINKER "$(rtlddir)/$(rtld-installed-name)"' \ + > ${@:stamp=T} + $(move-if-change) ${@:stamp=T} ${@:stamp=h} + touch $@ +endif + # Make sure the subdirectory for object files gets created. ifdef objpfx ifeq (,$(wildcard $(objpfx).)) @@ -211,6 +221,73 @@ $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \ mv -f $@T $@ endif +ifeq (yes,$(build-shared)) +# Generate the header containing the names of all shared libraries. +# We use a stamp file to avoid unnecessary recompilations. +before-compile += $(common-objpfx)gnu/lib-names.h +ifeq ($(soversions.mk-done),t) +ifndef abi-variants +lib-names-h-abi = gnu/lib-names.h +lib-names-stmp-abi = gnu/lib-names.stmp +else +lib-names-h-abi = gnu/lib-names-$(default-abi).h +lib-names-stmp-abi = gnu/lib-names-$(default-abi).stmp +before-compile += $(common-objpfx)$(lib-names-h-abi) +common-generated += gnu/lib-names.h +install-others-nosubdir: $(inst_includedir)/$(lib-names-h-abi) +$(common-objpfx)gnu/lib-names.h: + $(make-target-directory) + { \ + echo '/* This file is automatically generated.';\ + echo ' It defines macros to allow user program to find the shared'; \ + echo ' library files which come as part of GNU libc. */'; \ + echo '#ifndef __GNU_LIB_NAMES_H'; \ + echo '#define __GNU_LIB_NAMES_H 1'; \ + echo ''; \ + $(if $(abi-includes), \ + $(foreach h,$(abi-includes), echo '#include <$(h)>';) \ + echo '';) \ + $(foreach v,$(abi-variants),\ + $(if $(abi-$(v)-condition),\ + echo '#if $(abi-$(v)-condition)'; \ + echo '# include <gnu/lib-names-$(v).h>'); \ + $(if $(abi-$(v)-condition),echo '#endif';)) \ + echo ''; \ + echo '#endif /* gnu/lib-names.h */'; \ + } > $@ +endif +$(common-objpfx)$(lib-names-h-abi): $(common-objpfx)$(lib-names-stmp-abi); @: +$(common-objpfx)$(lib-names-stmp-abi): $(..)scripts/lib-names.awk \ + $(common-objpfx)soversions.i + $(make-target-directory) + { \ + $(if $(abi-variants), \ + echo '/* This file is automatically generated. */';\ + echo '#ifndef __GNU_LIB_NAMES_H'; \ + echo '# error "Never use <$(lib-names-h-abi)> directly; include <gnu/lib-names.h> instead."'; \ + echo '#endif';, \ + echo '/* This file is automatically generated.';\ + echo ' It defines macros to allow user program to find the shared'; \ + echo ' library files which come as part of GNU libc. */'; \ + echo '#ifndef __GNU_LIB_NAMES_H'; \ + echo '#define __GNU_LIB_NAMES_H 1';) \ + echo ''; \ + ($(foreach s,$(all-sonames), echo $(s);)) \ + | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort; \ + $(if $(abi-variants),, \ + echo ''; \ + echo '#endif /* gnu/lib-names.h */';) \ + } > ${@:stmp=T} + $(move-if-change) ${@:stmp=T} ${@:stmp=h} + touch $@ +endif +common-generated += $(lib-names-h-abi) $(lib-names-stmp-abi) +endif + +############################################################################### +# NOTE! Everything adding to before-compile needs to come before this point! # +############################################################################### + # 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 # sysdep directories. However, that had the problem that a .S file in a @@ -288,19 +365,22 @@ ifeq ($(build-shared),yes) $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)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 + Versions.def Versions.v.i Versions.v ifndef avoid-generated ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs)) sysd-versions-force = FORCE FORCE: endif -# See %.v/%.v.i implicit rules in Makeconfig. -$(common-objpfx)Versions.def.v.i: $(..)Versions.def \ - $(wildcard $(add-ons:%=$(..)%/Versions.def)) + +$(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.v + $(common-objpfx)Versions.def { while read which lib version setname; do \ test x"$$which" = xDEFAULT || continue; \ test -z "$$setname" || echo "$$lib : $$setname"; \ @@ -311,7 +391,6 @@ $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \ # See %.v/%.v.i implicit rules in Makeconfig. $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \ $(wildcard $(sysdirs:%=%/Versions)) \ - $(common-objpfx)abi-versions.h \ $(sysd-versions-force) $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \ $(common-objpfx)Versions.v \ @@ -415,7 +494,7 @@ endif link-libc-args = -Wl,--start-group \ $(libc-for-link) \ $(common-objpfx)libc_nonshared.a \ - $(as-needed) $(elfobjdir)/ld.so $(no-as-needed) \ + $(as-needed) $(elf-objpfx)ld.so $(no-as-needed) \ -Wl,--end-group # The corresponding shared libc to use. This may be modified for a @@ -426,7 +505,7 @@ libc-for-link = $(common-objpfx)libc.so # not just commands, they cannot use target-specific variables so need # to name both possible libc.so objects. link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \ - $(common-objpfx)libc_nonshared.a $(elfobjdir)/ld.so + $(common-objpfx)libc_nonshared.a $(elf-objpfx)ld.so # Pattern rule to build a shared object from an archive of PIC objects. # This must come after the installation rules so Make doesn't try to @@ -434,8 +513,9 @@ link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \ # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies # on other shared objects. The linking with libc and ld.so is intended # to be as similar as possible to a default link with an installed libc. -lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) $(link-libc-deps) +lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(link-libc-deps) $(build-shlib) $(link-libc-args) + $(call after-link,$@) define build-shlib-helper $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \ @@ -559,12 +639,14 @@ endef define build-module $(build-module-helper) -o $@ $(shlib-lds-flags) \ $(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) \ $(csu-objpfx)abi-note.o \ -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \ $(link-libc-args) +$(call after-link,$@) endef build-module-helper-objlist = \ @@ -638,21 +720,23 @@ $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty # Use our own special initializer and finalizer files for the libc.so # libraries. -$(common-objpfx)libc.so: $(elfobjdir)/soinit.os \ +$(common-objpfx)libc.so: $(elf-objpfx)soinit.os \ $(common-objpfx)libc_pic.os$(libc_pic_clean) \ - $(elfobjdir)/sofini.os \ - $(elfobjdir)/interp.os \ - $(elfobjdir)/ld.so \ + $(elf-objpfx)sofini.os \ + $(elf-objpfx)interp.os \ + $(elf-objpfx)ld.so \ $(shlib-lds) $(build-shlib) + $(call after-link,$@) -$(common-objpfx)linkobj/libc.so: $(elfobjdir)/soinit.os \ +$(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \ $(common-objpfx)linkobj/libc_pic.a \ - $(elfobjdir)/sofini.os \ - $(elfobjdir)/interp.os \ - $(elfobjdir)/ld.so \ + $(elf-objpfx)sofini.os \ + $(elf-objpfx)interp.os \ + $(elf-objpfx)ld.so \ $(shlib-lds) $(build-shlib) + $(call after-link,$@) ifeq ($(build-shared),yes) $(common-objpfx)libc.so: $(common-objpfx)libc.map @@ -880,6 +964,26 @@ endef installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\ $(inst_libdir)/$(patsubst %,$(libtype$o),\ $(libprefix)$(libc-name))) + +.PHONY: check-install-supported +check-install-supported: + +# Check to see if the prefix or exec_prefix GNU standard variable +# has been overridden on the command line and, if so, fail with +# an error message since doing so is not supported (set DESTDIR +# instead). +ifeq ($(origin prefix),command line) +check-install-supported: + $(error Overriding prefix is not supported. Set DESTDIR instead.) +endif + +ifeq ($(origin exec_prefix),command line) +check-install-supported: + $(error Overriding exec_prefix is not supported. Set DESTDIR instead.) +endif + +install: check-install-supported + install: $(installed-libcs) $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force) $(make-target-directory) @@ -941,8 +1045,8 @@ endif ifeq (yes,$(build-shared)) ifeq (no,$(cross-compiling)) -symbolic-link-prog := $(common-objpfx)elf/sln -symbolic-link-list := $(common-objpfx)elf/symlink.list +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 @@ -1079,7 +1183,8 @@ endif 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 @@ -1205,14 +1310,11 @@ xcheck: xtests all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others)) ifneq (,$(all-nonlib)) -cpp-srcs-left = $(all-nonlib:=.c) $(all-nonlib:=.cc) +cpp-srcs-left = $(all-nonlib) lib := nonlib include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) endif -# The include magic above causes those files to use this variable for flags. -CPPFLAGS-nonlib = -DNOT_IN_libc=1 - ifeq ($(build-shared),yes) # Generate normalized lists of symbols, versions, and data sizes. @@ -1244,21 +1346,29 @@ vpath %.abilist $(+sysdep_dirs) generated += $(extra-libs:=.symlist) ifdef abilist-pattern -check-abi-%: $(common-objpfx)config.make $(abilist-pattern) $(objpfx)%.symlist - $(check-abi-pattern) -check-abi-%: $(common-objpfx)config.make $(abilist-pattern) \ - $(common-objpfx)%.symlist - $(check-abi-pattern) -endif -check-abi-%: $(common-objpfx)config.make %.abilist $(objpfx)%.symlist - $(check-abi) -check-abi-%: $(common-objpfx)config.make %.abilist $(common-objpfx)%.symlist - $(check-abi) +$(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); \ + $(evaluate-test) +$(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \ + $(common-objpfx)%.symlist + $(check-abi); \ + $(evaluate-test) define check-abi-pattern - diff -p -U 0 $(filter $(abilist-pattern),$^) $(filter %.symlist,$^) + diff -p -U 0 $(filter $(abilist-pattern),$^) $(filter %.symlist,$^) \ + > $@ endef define check-abi - diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^) + diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^) > $@ endef ifdef abilist-pattern @@ -1290,29 +1400,34 @@ endef .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)) +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 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 endif ifeq ($(subdir),elf) -check-abi: check-abi-libc +check-abi: $(objpfx)check-abi-libc.out +tests-special += $(objpfx)check-abi-libc.out update-abi: update-abi-libc common-generated += libc.symlist endif ifeq ($(build-shared),yes) ifdef subdir -tests: check-abi +tests-special += $(check-abi-list) endif endif endif - + # These will have been set by sysdeps/posix/Makefile. L_tmpnam ?= 1 TMP_MAX ?= 0 @@ -1379,7 +1494,10 @@ mostlyclean: common-mostlyclean do-tests-clean: -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \ - $(test-srcs))) + $(test-srcs)) \ + $(addsuffix .test-result,$(tests) \ + $(xtests) \ + $(test-srcs))) # Remove the object files. common-mostlyclean: @@ -1389,7 +1507,10 @@ common-mostlyclean: $(test-srcs) $(others) \ $(sysdep-others)) \ $(addsuffix .out,$(tests) $(xtests) \ - $(test-srcs))) + $(test-srcs)) \ + $(addsuffix .test-result,$(tests) \ + $(xtests) \ + $(test-srcs))) -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \ $(install-lib) $(install-lib.so) \ $(install-lib.so:%.so=%_pic.a)) |