diff options
author | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2018-04-26 14:52:38 +0200 |
---|---|---|
committer | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2018-04-27 13:15:41 +0100 |
commit | ff8fc0b49b5eaf5ab3050e741935cf41dab1f3ca (patch) | |
tree | 762f906d94777be77357fd94ee225a9af1112453 | |
parent | 23692fe3ddd94c8a32d4a675787ba2685c6b9b1a (diff) |
Build: generate .d file at the same time as .o
Note: This patch is based on TF commit 710ea1d01a10 ("Build: generate
.d file at the same time as object is created").
Currently, .d files are generated before any objects are built.
IS_ANYTHING_TO_BUILD flag is needed to avoid such processing for
non-build targets.
Instead just create a .d file simultaneously when the corresponding
object is created. No need to have separate rules for .d files.
This commit will also fix a bug; -D$(IMAGE) is defined for $(OBJ), but
not for $(PREREQUISITES). So, .d files are generated with different
macro sets from those for .o files, then wrong .d files are generated.
For example, with the following code:
#if IMAGE_TFTF
#include <some_file.h>
#endif
<some_file.h> is included when building TFTF but the .d file does not
pick up that dependency.
With this commit, the compiler will generate .o and .d at the same
time, guaranteeing they are generated under the same circumstances.
Change-Id: I7d4aa4bbd65a828e2c1860a099231ca70d3a0886
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
-rw-r--r-- | Makefile | 62 |
1 files changed, 12 insertions, 50 deletions
@@ -315,95 +315,57 @@ checkpatch: locate-checkpatch -- ${CHECK_PATHS} | ${CHECKPATCH} - || true; \ done -define match_goals -$(strip $(foreach goal,$(1),$(filter $(goal),$(MAKECMDGOALS)))) -endef - -# List of rules that involve building things -BUILD_TARGETS := all tftf -ifeq (${FIRMWARE_UPDATE},1) - BUILD_TARGETS += ns_bl1u ns_bl2u -else +ifneq (${FIRMWARE_UPDATE},1) ns_bl1u ns_bl2u: @echo "ERROR: Can't build $@ because Firmware Update is not supported \ on this platform." @exit 1 endif -ifeq (${ARCH}-${PLAT},aarch64-fvp) - BUILD_TARGETS += cactus -else +ifneq (${ARCH}-${PLAT},aarch64-fvp) .PHONY: cactus cactus: @echo "ERROR: $@ is supported only on AArch64 FVP." @exit 1 endif -# Does the list of goals specified on the command line include a build target? -ifneq ($(call match_goals,${BUILD_TARGETS}),) -IS_ANYTHING_TO_BUILD := 1 -endif +MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ define MAKE_C $(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) -$(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ))) +$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) $(OBJ) : $(2) @echo " CC $$<" - $$(Q)$$(CC) $$(TFTF_CFLAGS) -DIMAGE_$(3) -c $$< -o $$@ - - -$(PREREQUISITES) : $(2) $(AUTOGEN_DIR)/tests_list.h - @echo " DEPS $$@" - @mkdir -p $(1) - $$(Q)$$(CC) $$(TFTF_CFLAGS) -M -MT $(OBJ) -MF $$@ $$< - -ifdef IS_ANYTHING_TO_BUILD --include $(PREREQUISITES) -endif + $$(Q)$$(CC) $$(TFTF_CFLAGS) -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@ +-include $(DEP) endef define MAKE_S $(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) -$(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ))) +$(eval DEP := $(patsubst %.o,%.d,$(OBJ))) $(OBJ) : $(2) @echo " AS $$<" - $$(Q)$$(AS) $$(ASFLAGS) -DIMAGE_$(3) -c $$< -o $$@ - -$(PREREQUISITES) : $(2) $(AUTOGEN_DIR)/tests_list.h - @echo " DEPS $$@" - @mkdir -p $(1) - $$(Q)$$(AS) $$(ASFLAGS) -M -MT $(OBJ) -MF $$@ $$< - -ifdef IS_ANYTHING_TO_BUILD --include $(PREREQUISITES) -endif + $$(Q)$$(AS) $$(ASFLAGS) -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@ +-include $(DEP) endef define MAKE_LD -$(eval PREREQUISITES := $(1).d) +$(eval DEP := $(1).d) $(1) : $(2) @echo " PP $$<" - $$(Q)$$(AS) $$(ASFLAGS) -P -E -o $$@ $$< - -$(PREREQUISITES) : $(2) - @echo " DEPS $$@" - @mkdir -p $$(dir $$@) - $$(Q)$$(AS) $$(ASFLAGS) -M -MT $(1) -MF $$@ $$< - -ifdef IS_ANYTHING_TO_BUILD --include $(PREREQUISITES) -endif + $$(Q)$$(AS) $$(ASFLAGS) -P -E $(MAKE_DEP) -o $$@ $$< +-include $(DEP) endef |