mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: barebox@lists.infradead.org
Subject: [PATCH 04/11] kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically
Date: Sun, 30 Dec 2018 22:59:21 +0900	[thread overview]
Message-ID: <1546178368-26182-5-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1546178368-26182-1-git-send-email-yamada.masahiro@socionext.com>

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 <yamada.masahiro@socionext.com>
---

 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

  parent reply	other threads:[~2018-12-30 14:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-30 13:59 [PATCH 00/11] Sync Kconfig to Linux 4.20 Masahiro Yamada
2018-12-30 13:59 ` [PATCH 01/11] kbuild: filter-out PHONY targets from "targets" Masahiro Yamada
2018-12-30 13:59 ` [PATCH 02/11] kbuild: add .DELETE_ON_ERROR special target Masahiro Yamada
2018-12-31  5:52   ` Sam Ravnborg
2018-12-30 13:59 ` [PATCH 03/11] kbuild: add .SECONDARY " Masahiro Yamada
2018-12-31  5:55   ` Sam Ravnborg
2018-12-30 13:59 ` Masahiro Yamada [this message]
2018-12-31  5:55   ` [PATCH 04/11] kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically Sam Ravnborg
2018-12-30 13:59 ` [PATCH 05/11] treewide: remove blank texts Masahiro Yamada
2018-12-30 13:59 ` [PATCH 06/11] .gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore Masahiro Yamada
2018-12-30 13:59 ` [PATCH 07/11] kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile Masahiro Yamada
2018-12-30 13:59 ` [PATCH 08/11] kbuild: rename HOSTLOADLIBES_* to HOSTLDLIBS_* Masahiro Yamada
2018-12-30 13:59 ` [PATCH 09/11] kbuild: generate lexer and parser during build instead of shipping Masahiro Yamada
2018-12-31  1:02   ` Masahiro Yamada
2018-12-30 13:59 ` [PATCH 10/11] kconfig: sync to Linux 4.20 Masahiro Yamada
2018-12-30 13:59 ` [PATCH 11/11] kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX Masahiro Yamada
2018-12-31  6:12 ` [PATCH 00/11] Sync Kconfig to Linux 4.20 Sam Ravnborg
2019-01-01  9:13   ` Masahiro Yamada
2019-01-03  9:18     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1546178368-26182-5-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox