From a32b6f0b7d3f35f58d2cfefd8d28c46a80a78ef7 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Thu, 12 Mar 2015 23:17:16 -0700 Subject: Makefile: Avoid duplicate class suffixes in $(call src-to-obj) The build system uses the $(src-to-obj) function in multiple places to figure out the corresponding output object file for a certan source file, most importantly when generating the rule to build it. Usually this is pretty simple, but some odd cases are a little tricky... such as the auto-generated intermediary C files containing an array definition generated from an ASL file. These files have already been compiled per stage, so they contain the stage as a suffix and reside in the build directory (e.g. build/.../dsdt.ramstage.c). The previous $(src-to-obj) implementation just blindly appends the stage again and turns this into build/.../dsdt.ramstage.ramstage.o. This isn't very useful, so to avoid confusion this patch makes it strip additional stage suffixes for those intermediary files. This also fixes a bug with the ASL postprocessor, which didn't take this double suffix into account: it added build/.../dsdt.ramstage.o to ramstage-objs which should've been build/.../dsdt.ramstage.ramstage.o. This only worked by accident because make compiled the file with its implicit %.o: %.c rule instead. BRANCH=none BUG=chromium:466469 TEST=emerge-falco coreboot with the new make 4.1. Also build Falco and Veyron_Jerry with make -r -R to make sure there are no other accidental uses of implicit rules in our build system. Change-Id: I4aeaa60add1ef4215cb6c0b222c3886395c7a045 Signed-off-by: Patrick Georgi Original-Commit-Id: d9ea2e082eca1045409ea1f403082c97dedc70d8 Original-Change-Id: I951edbc9f653321a9084543a65009c6e9154d819 Original-Signed-off-by: Julius Werner Original-Reviewed-on: https://chromium-review.googlesource.com/259950 Original-Reviewed-by: Mike Frysinger Original-Reviewed-by: Patrick Georgi Reviewed-on: http://review.coreboot.org/9861 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3c576082be..e5255f80ac 100644 --- a/Makefile +++ b/Makefile @@ -209,7 +209,7 @@ $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs)))) # Only .c and .S get converted to .o, other files (like .ld) keep their name. # $1 stage name # $2 file path (list) -src-to-obj=$(foreach file,$(2),$(basename $(patsubst src/%,$(obj)/%,$(file))).$(1)$(patsubst %.c,%.o,$(patsubst %.S,%.o,$(suffix $(file))))) +src-to-obj=$(foreach file,$(2),$(subst .$(1),,$(basename $(patsubst src/%,$(obj)/%,$(file)))).$(1)$(patsubst %.c,%.o,$(patsubst %.S,%.o,$(suffix $(file))))) $(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs)))) -- cgit v1.2.3