[PATCH 09/10] kbuild: add *.asn1.[ch] to 'targets' automatically

From: Masahiro Yamada
Date: Fri Mar 23 2018 - 09:07:12 EST


Use $(call if_changed,...) instead of $(call cmd,...) in case the
build command is changed in the future. Add intermediate files to
'targets' automatically to include *.cmd files.

Signed-off-by: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
---

scripts/Makefile.build | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 8c3ca61..cc081af 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -432,8 +432,9 @@ quiet_cmd_asn1_compiler = ASN.1 $@

.PRECIOUS: $(objtree)/$(obj)/%.asn1.c $(objtree)/$(obj)/%.asn1.h

-$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
- $(call cmd,asn1_compiler)
+$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 \
+ $(objtree)/scripts/asn1_compiler FORCE
+ $(call if_changed,asn1_compiler)

# Build the compiled-in targets
# ---------------------------------------------------------------------------
@@ -544,10 +545,12 @@ targets := $(filter-out $(PHONY), $(targets))
intermediate_targets = $(foreach sfx, $(2), \
$(patsubst %$(strip $(1)),%$(sfx), \
$(filter %$(strip $(1)), $(targets))))
+# %.asn1.o <- %.asn1.[ch] <- %.asn1
# %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
# %.lex.o <- %.lex.c <- %.l
# %.tab.o <- %.tab.[ch] <- %.y
-targets += $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
+targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
+ $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
$(call intermediate_targets, .lex.o, .lex.c) \
$(call intermediate_targets, .tab.o, .tab.c .tab.h)

--
2.7.4