From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gdbdf-0007gR-HG for barebox@lists.infradead.org; Sun, 30 Dec 2018 14:00:25 +0000 From: Masahiro Yamada Date: Sun, 30 Dec 2018 22:59:21 +0900 Message-Id: <1546178368-26182-5-git-send-email-yamada.masahiro@socionext.com> In-Reply-To: <1546178368-26182-1-git-send-email-yamada.masahiro@socionext.com> References: <1546178368-26182-1-git-send-email-yamada.masahiro@socionext.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 04/11] kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically To: barebox@lists.infradead.org Linux commit b23d1a241f4eb44ae55785c9b65274717c8e2c1e (adjust commit log for barebox) This will be needed for Barebox to switch to the compile-time generattion of lexers and parsers. Files generated by if_changed* must be added to 'targets' to include *.cmd files. Otherwise, they would be regenerated every time. The build system automatically adds objects to 'targets' where appropriate, such as obj-y, extra-y, etc. but does nothing for intermediate files. So, each Makefile needs to add them by itself. There are some common cases where objects are generated by chained rules. Lexers and parsers are compiled like follows: %.lex.o <- %.lex.c <- %.l %.tab.o <- %.tab.c <- %.y They are common patterns, so it is reasonable to take care of them in the core Makefile instead of requiring each Makefile to do so. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 883435b..3c686e4 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -379,6 +379,17 @@ $(call multi_depend, $(multi-used-m), .o, -objs -y) targets += $(multi-used-y) $(multi-used-m) targets := $(filter-out $(PHONY), $(targets)) +# Add intermediate targets: +# When building objects with specific suffix patterns, add intermediate +# targets that the final targets are derived from. +intermediate_targets = $(foreach sfx, $(2), \ + $(patsubst %$(strip $(1)),%$(sfx), \ + $(filter %$(strip $(1)), $(targets)))) +# %.lex.o <- %.lex.c <- %.l +# %.tab.o <- %.tab.[ch] <- %.y +targets += $(call intermediate_targets, .lex.o, .lex.c) \ + $(call intermediate_targets, .tab.o, .tab.c .tab.h) + # Descending # --------------------------------------------------------------------------- -- 2.7.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox