make: Fix parallel builds
Parallel builds would fail while generating the dependency file of the
first source file that included tests_list.h due to it missing.
In-order builds only worked, because a rule that specified tests_list.c
as a prerequisite happened to get executed first.
This patch introduces tests_list.h as an order-only dependency of all
rules that generate dependency files. This is necessary because we can't
know which files actually depend on it until the dependency files have
been generated.
This forces the autogenerated files to be generated before any other
files are compiled, but does not cause unrelated files to recompile if
they are modified.
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
Change-Id: I21f0b98052a884a853935ea35a2898ff90245a49
diff --git a/Makefile b/Makefile
index 1269b6d..100e241 100644
--- a/Makefile
+++ b/Makefile
@@ -353,7 +353,7 @@
$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
-$(OBJ) : $(2)
+$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
@echo " CC $$<"
$$(Q)$$(CC) $$($(3)_CFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
@@ -366,7 +366,7 @@
$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
-$(OBJ) : $(2)
+$(OBJ) : $(2) | $(AUTOGEN_DIR)/tests_list.h
@echo " AS $$<"
$$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -DIMAGE_$(3) $(MAKE_DEP) -c $$< -o $$@
@@ -378,7 +378,7 @@
$(eval DEP := $(1).d)
-$(1) : $(2)
+$(1) : $(2) | $(AUTOGEN_DIR)/tests_list.h
@echo " PP $$<"
$$(Q)$$(AS) $$($(3)_ASFLAGS) ${$(3)_INCLUDES} ${$(3)_DEFINES} -P -E $(MAKE_DEP) -o $$@ $$<
diff --git a/fwu/ns_bl1u/ns_bl1u.mk b/fwu/ns_bl1u/ns_bl1u.mk
index 7a6b65b..cf2b4a8 100644
--- a/fwu/ns_bl1u/ns_bl1u.mk
+++ b/fwu/ns_bl1u/ns_bl1u.mk
@@ -68,5 +68,3 @@
else
$(eval $(call add_define,NS_BL1U_DEFINES,AARCH64))
endif
-
-ns_bl1u: ${AUTOGEN_DIR}/tests_list.h
diff --git a/fwu/ns_bl2u/ns_bl2u.mk b/fwu/ns_bl2u/ns_bl2u.mk
index 0351e55..dd9e663 100644
--- a/fwu/ns_bl2u/ns_bl2u.mk
+++ b/fwu/ns_bl2u/ns_bl2u.mk
@@ -64,5 +64,3 @@
else
$(eval $(call add_define,NS_BL2U_DEFINES,AARCH64))
endif
-
-ns_bl2u: ${AUTOGEN_DIR}/tests_list.h
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 4acc715..5620902 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -72,4 +72,4 @@
@echo "Built $@ successfully"
@echo
-cactus: $(CACTUS_DTB) $(AUTOGEN_DIR)/tests_list.h
+cactus: $(CACTUS_DTB)
diff --git a/spm/cactus_mm/cactus_mm.mk b/spm/cactus_mm/cactus_mm.mk
index cd799c1..449f2ce 100644
--- a/spm/cactus_mm/cactus_mm.mk
+++ b/spm/cactus_mm/cactus_mm.mk
@@ -55,5 +55,3 @@
$(eval $(call add_define,CACTUS_MM_DEFINES,LOG_LEVEL))
$(eval $(call add_define,CACTUS_MM_DEFINES,PLAT_${PLAT}))
$(eval $(call add_define,CACTUS_MM_DEFINES,AARCH64))
-
-cactus_mm: ${AUTOGEN_DIR}/tests_list.h
diff --git a/spm/ivy/ivy.mk b/spm/ivy/ivy.mk
index 5a6ccf0..2985b60 100644
--- a/spm/ivy/ivy.mk
+++ b/spm/ivy/ivy.mk
@@ -68,4 +68,4 @@
@echo "Built $@ successfully"
@echo
-ivy: $(IVY_DTB) $(AUTOGEN_DIR)/tests_list.h
+ivy: $(IVY_DTB)
diff --git a/spm/quark/quark.mk b/spm/quark/quark.mk
index 554d334..9bf81d1 100644
--- a/spm/quark/quark.mk
+++ b/spm/quark/quark.mk
@@ -61,4 +61,4 @@
@echo "Built $@ successfully"
@echo
-quark: $(QUARK_DTB) $(AUTOGEN_DIR)/tests_list.h
+quark: $(QUARK_DTB)