Skip to content

Commit 7373f4f

Browse files
committed
kbuild: add implicit rules for parser generation
Cc: David Gibson <[email protected]> Cc: Michal Marek <[email protected]> Signed-off-by: Arnaud Lacombe <[email protected]>
1 parent e0318d8 commit 7373f4f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

scripts/Makefile.lib

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,44 @@ ld_flags = $(LDFLAGS) $(ldflags-y)
160160
modname-multi = $(sort $(foreach m,$(multi-used),\
161161
$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
162162

163+
ifdef REGENERATE_PARSERS
164+
165+
# GPERF
166+
# ---------------------------------------------------------------------------
167+
quiet_cmd_gperf = GPERF $@
168+
cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $<
169+
170+
$(src)/%.hash.c_shipped: $(src)/%.gperf
171+
$(call cmd,gperf)
172+
173+
# LEX
174+
# ---------------------------------------------------------------------------
175+
LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
176+
177+
quiet_cmd_flex = LEX $@
178+
cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $<
179+
180+
$(src)/%.lex.c_shipped: $(src)/%.l
181+
$(call cmd,flex)
182+
183+
# YACC
184+
# ---------------------------------------------------------------------------
185+
YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
186+
187+
quiet_cmd_bison = YACC $@
188+
cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $<
189+
190+
$(src)/%.tab.c_shipped: $(src)/%.y
191+
$(call cmd,bison)
192+
193+
quiet_cmd_bison_h = YACC $@
194+
cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $<
195+
196+
$(src)/%.tab.h_shipped: $(src)/%.y
197+
$(call cmd,bison_h)
198+
199+
endif
200+
163201
# Shipped files
164202
# ===========================================================================
165203

0 commit comments

Comments
 (0)