From 594464b6cf6d7401a37d81384a9f1f663eb5d933 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 13 Feb 1998 04:30:16 +0000 Subject: [PATCH] yacc cleanup --- ChangeLog | 5 +++++ THANKS | 1 + TODO | 3 +++ automake.in | 56 ++++++++++++++++++++++++++++++----------------------- 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8e5b816..78fdb687 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ Thu Feb 12 19:45:16 1998 Tom Tromey + Report from H.J. Lu. + * automake.in (output_yacc_build_rule): Don't write rule to create + `.h' file. + (handle_yacc_lex_cxx): Generate rule to build each .h file. + * automake.in (handle_options): Set readme-alpha and check-news for Gnits after main processing. Test alpha.test. From Jim Meyering. diff --git a/THANKS b/THANKS index a4e46eac..1520cf32 100644 --- a/THANKS +++ b/THANKS @@ -21,6 +21,7 @@ Garth Corral garthc@inktomi.com Glenn Amerine glenn@pie.mhsc.org Gord Matzigkeit gord@gnu.ai.mit.edu Greg A. Woods woods@most.weird.com +H.J. Lu hjl@lucon.org Harlan Stenn Harlan.Stenn@pfcs.com Henrik Frystyk Nielsen frystyk@w3.org Ian Lance Taylor ian@cygnus.com diff --git a/TODO b/TODO index d5be0ee6..7686e68e 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,6 @@ +* Every program foo has FOOFLAGS right now. + It should also have AM_FOOFLAGS, which can be set in Makefile.am. + * when cleaning, should recurse depth first * quoting bugs diff --git a/automake.in b/automake.in index d4088763..d3e3eb90 100755 --- a/automake.in +++ b/automake.in @@ -832,14 +832,26 @@ sub handle_yacc_lex_cxx if ($yacc_count) { + local ($file, $base, $hname, $cname); local (%seen_suffix) = (); - foreach (keys %yacc_sources) + foreach $file (keys %yacc_sources) { - /(\..*)$/; + $file =~ /(\..*)$/; &output_yacc_build_rule ($1, $yacc_count > 1) if (! defined $seen_suffix{$1}); $seen_suffix{$1} = 1; + + # Now generate rule to make the header file. This should + # only be generated if `yacc -d' specified. But right now + # there is no way to determine that. FIXME: the + # AM_FOOFLAGS idea would suffice here. + $file =~ /^(.*)\.(y|yy|y\+\+|yxx)$/; + $base = $1; + ($hname = $2) =~ tr/y/h/; + ($cname = $2) =~ tr/y/c/; + $output_rules .= "${base}.${hname}: ${base}.${cname}\n"; } + $output_rules .= "\n"; if (! defined $configure_vars{'YACC'}) { @@ -992,32 +1004,28 @@ sub output_yacc_build_rule { local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_; - local ($c_suffix, $suffix); - ($c_suffix = $yacc_suffix) =~ tr/y/c/; - push (@suffixes, $yacc_suffix, $c_suffix, '.h'); + local ($suffix); + ($suffix = $yacc_suffix) =~ tr/y/c/; + push (@suffixes, $yacc_suffix, $suffix); - # Generate rule for c/c++ and header file. Probably should only - # do header if `yacc -d' is run. But how can we determine that? - foreach $suffix ($c_suffix, '.h') - { - $output_rules .= "$yacc_suffix$suffix:\n\t"; + # Generate rule for c/c++. + $output_rules .= "$yacc_suffix$suffix:\n\t"; - if ($use_ylwrap) - { - $output_rules .= ('$(SHELL) $(YLWRAP)' - . ' "$(YACC)" $< y.tab.c $*' . $c_suffix - . ' y.tab.h $*.h -- $(YFLAGS)'); - } - else - { - $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $*' - . $c_suffix . "\n" - . "\tif test -f y.tab.h; then \\\n" - . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n" + if ($use_ylwrap) + { + $output_rules .= ('$(SHELL) $(YLWRAP)' + . ' "$(YACC)" $< y.tab.c $*' . $suffix + . ' y.tab.h $*.h -- $(YFLAGS)'); + } + else + { + $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $*' + . $suffix . "\n" + . "\tif test -f y.tab.h; then \\\n" + . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n" . "\telse :; fi"); - } - $output_rules .= "\n"; } + $output_rules .= "\n"; } sub output_lex_build_rule -- 2.43.5