summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.lib
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-12-30 22:59:26 +0900
committerSascha Hauer <s.hauer@pengutronix.de>2019-01-03 10:17:16 +0100
commit273dbe5f87de8d6129a68ad40e87922fb6e783b6 (patch)
tree41f19d7c159df88aa1dee4bff084f3e57dfc18db /scripts/Makefile.lib
parentc17116dc3818b45cbc3997de72d05e64aab04cbe (diff)
downloadbarebox-273dbe5f87de8d6129a68ad40e87922fb6e783b6.tar.gz
barebox-273dbe5f87de8d6129a68ad40e87922fb6e783b6.tar.xz
kbuild: generate lexer and parser during build instead of shipping
Recent kernel versions run flex and bison to generate lexers and parsers from real source files such as *.l and *.y . This provides better maintainability than version-controlling pre-generated C files with a "_shipped" suffix. This commit imports flex and bison rules from Linux, and deletes pre-generated parsers and lexers. Refer to the following commits in Linux: - 033dba2ec06c ("kbuild: prepare to remove C files pre-generated by flex and bison") - 29c833061c1d ("kconfig: generate lexer and parser during build instead of shipping") - e039139be8c2 ("scripts/dtc: generate lexer and parser during build instead of shipping") Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/Makefile.lib')
-rw-r--r--scripts/Makefile.lib26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3b4277e5ab..b0f6d68906 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -177,6 +177,32 @@ $(foreach m, $(notdir $1), \
$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
endef
+# LEX
+# ---------------------------------------------------------------------------
+LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
+
+quiet_cmd_flex = LEX $@
+ cmd_flex = $(LEX) -o$@ -L -P $(LEX_PREFIX) $<
+
+$(obj)/%.lex.c: $(src)/%.l FORCE
+ $(call if_changed,flex)
+
+# YACC
+# ---------------------------------------------------------------------------
+YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
+
+quiet_cmd_bison = YACC $@
+ cmd_bison = $(YACC) -o$@ -t -l -p $(YACC_PREFIX) $<
+
+$(obj)/%.tab.c: $(src)/%.y FORCE
+ $(call if_changed,bison)
+
+quiet_cmd_bison_h = YACC $@
+ cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $<
+
+$(obj)/%.tab.h: $(src)/%.y FORCE
+ $(call if_changed,bison_h)
+
# Shipped files
# ===========================================================================