diff mbox

[RFC,7/9] kbuild: merge parser generation rules

Message ID 1304561004-2684-8-git-send-email-lacombar@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arnaud Lacombe May 5, 2011, 2:03 a.m. UTC
---
 scripts/Makefile.lib      |   31 ++++++++++++++++++++++++++++++-
 scripts/genksyms/Makefile |   20 --------------------
 scripts/kconfig/Makefile  |   25 -------------------------
 3 files changed, 30 insertions(+), 46 deletions(-)

Comments

Michal Marek May 5, 2011, 1:32 p.m. UTC | #1
Hi Arnaud,

nice cleanup, I only have a few random comments to this and other patches.

On Wed, May 04, 2011 at 10:03:22PM -0400, Arnaud Lacombe wrote:
>  # Shipped files
>  # ===========================================================================
>  
>  quiet_cmd_shipped = SHIPPED $@
>  cmd_shipped = cat $< > $@
>  
> -$(obj)/%:: $(src)/%_shipped
> +$(obj)/%.tab.c: $(src)/%.tab.c_shipped
> +	$(call cmd,shipped)
> +
> +$(obj)/lex.%.c: $(src)/lex.%.c_shipped
> +	$(call cmd,shipped)
> +
> +$(obj)/%.hash.c: $(src)/%.hash.c_shipped
>  	$(call cmd,shipped)

Please don't change this rule, there are other uses of _shipped files in the
tree than just bison/lex/gperf generated files.
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnaud Lacombe May 5, 2011, 2:50 p.m. UTC | #2
Hi,

On Thu, May 5, 2011 at 9:32 AM, Michal Marek <mmarek@suse.cz> wrote:
> Hi Arnaud,
>
> nice cleanup, I only have a few random comments to this and other patches.
>
> On Wed, May 04, 2011 at 10:03:22PM -0400, Arnaud Lacombe wrote:
>>  # Shipped files
>>  # ===========================================================================
>>
>>  quiet_cmd_shipped = SHIPPED $@
>>  cmd_shipped = cat $< > $@
>>
>> -$(obj)/%:: $(src)/%_shipped
>> +$(obj)/%.tab.c: $(src)/%.tab.c_shipped
>> +     $(call cmd,shipped)
>> +
>> +$(obj)/lex.%.c: $(src)/lex.%.c_shipped
>> +     $(call cmd,shipped)
>> +
>> +$(obj)/%.hash.c: $(src)/%.hash.c_shipped
>>       $(call cmd,shipped)
>
> Please don't change this rule, there are other uses of _shipped files in the
> tree than just bison/lex/gperf generated files.
>
I could not make the other implicit target work without changing this one. Ie:

$(src)/%.tab.c_shipped: $(src)/%.y
       $(call cmd,bison)

was not working with the _shipped rules left intact, but hardcoding
stem value, eg.:

$(src)/zconf.tab.c_shipped: $(src)/zconf.y
       $(call cmd,bison)

was working, at least to link the different implicit target, but
that's breaking other part. I'll try to re-investigate tonight.

 - Arnaud
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 1c702ca..74a73de 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -160,13 +160,42 @@  ld_flags       = $(LDFLAGS) $(ldflags-y)
 modname-multi = $(sort $(foreach m,$(multi-used),\
 		$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
 
+ifdef REGENERATE_PARSERS
+# GPERF
+# ---------------------------------------------------------------------------
+quiet_cmd_gperf = GPERF $@
+      cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $<
+$(src)/%.hash.c_shipped: $(src)/%.gperf
+	$(call cmd,gperf)
+
+# LEX
+# ---------------------------------------------------------------------------
+quiet_cmd_flex = LEX     $@
+      cmd_flex = flex -L -P$(notdir $*) -o$@ $<
+$(src)/lex.%.c_shipped: $(src)/%.l
+	$(call cmd,flex)
+
+# YACC
+# ---------------------------------------------------------------------------
+quiet_cmd_bison = YACC    $@
+      cmd_bison = bison -o$@ -l -b $* -p $(notdir $*) $<
+$(src)/%.tab.c_shipped: $(src)/%.y
+	$(call cmd,bison)
+endif
+
 # Shipped files
 # ===========================================================================
 
 quiet_cmd_shipped = SHIPPED $@
 cmd_shipped = cat $< > $@
 
-$(obj)/%:: $(src)/%_shipped
+$(obj)/%.tab.c: $(src)/%.tab.c_shipped
+	$(call cmd,shipped)
+
+$(obj)/lex.%.c: $(src)/lex.%.c_shipped
+	$(call cmd,shipped)
+
+$(obj)/%.hash.c: $(src)/%.hash.c_shipped
 	$(call cmd,shipped)
 
 # Commands useful for building a boot image
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index de6675d..e3295a8 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -14,23 +14,3 @@  clean-files	:= genksyms.tab.c lex.genksyms.c genksyms.hash.c
 
 $(obj)/genksyms.tab.o: $(obj)/lex.genksyms.c $(obj)/genksyms.hash.c
 
-ifdef GENKSYMS_GENPARSER
-
-$(obj)/genksyms.tab.c: $(src)/genksyms.y
-$(obj)/lex.genksyms.c: $(src)/genksyms.l
-$(obj)/genksyms.hash.c: $(src)/genksyms.gperf
-
-%.tab.c: %.y
-	bison -l -b $* -p $(notdir $*) $<
-	cp $@ $@_shipped
-
-lex.%.c: %.l
-	flex -L -P$(notdir $*) -o$@ $<
-	cp $@ $@_shipped
-
-%.hash.c: %.gperf
-	gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $<
-	cp $@ $@_shipped
-
-endif
-
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 368ae30..c9ec4d6 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -327,28 +327,3 @@  $(obj)/lkc_defs.h: $(src)/lkc_proto.h
 $(obj)/gconf.glade.h: $(obj)/gconf.glade
 	intltool-extract --type=gettext/glade $(obj)/gconf.glade
 
-###
-# The following requires flex/bison/gperf
-# By default we use the _shipped versions, uncomment the following line if
-# you are modifying the flex/bison src.
-# LKC_GENPARSER := 1
-
-ifdef LKC_GENPARSER
-
-$(obj)/zconf.tab.c: $(src)/zconf.y
-$(obj)/lex.zconf.c: $(src)/zconf.l
-$(obj)/zconf.hash.c: $(src)/zconf.gperf
-
-%.tab.c: %.y
-	bison -l -b $* -p $(notdir $*) $<
-	cp $@ $@_shipped
-
-lex.%.c: %.l
-	flex -L -P$(notdir $*) -o$@ $<
-	cp $@ $@_shipped
-
-%.hash.c: %.gperf
-	gperf < $< > $@
-	cp $@ $@_shipped
-
-endif