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 <pgeorgi@chromium.org>
Original-Commit-Id: d9ea2e082eca1045409ea1f403082c97dedc70d8
Original-Change-Id: I951edbc9f653321a9084543a65009c6e9154d819
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/259950
Original-Reviewed-by: Mike Frysinger <vapier@chromium.org>
Original-Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/9861
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Julius Werner 2015-03-12 23:17:16 -07:00 committed by Patrick Georgi
parent b16a6c4f5b
commit a32b6f0b7d
1 changed files with 1 additions and 1 deletions

View File

@ -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))))