[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch (not checking in): yacc5.test fix take 2
From: |
Tom Tromey |
Subject: |
Patch (not checking in): yacc5.test fix take 2 |
Date: |
21 Jun 2001 00:35:37 -0600 |
This is the second revision of my yacc5.test fix. I took a more
ambitious approach. This time I changed how yacc and lex are handled.
Now they are handled more like ordinary languages. I removed some
special handling they had, but I also added at least one more yacc/lex
hack. I also changed how ylwrap is run, which is arguably bad (it
means people have to remember to update it).
Still, though there is some new ugliness, I think this is going in a
better direction. It still isn't what I really want, but it is
definitely getting closer.
If someone could read through this and comment I would appreciate it.
If the full test suite passes (I'm running it now) I will probably
check this in tomorrow.
I also have a list of new tests to write which might reveal bugs in
the below. I'll try to write those soon.
I really didn't want this bug to take as long as it did. It has taken
away time I wanted to use to fix the manual :-(
2001-06-21 Tom Tromey <address@hidden>
* lib/ylwrap: Changed usage.
* lib/am/yacc.am: Rewrote to use new substitutions.
* lib/am/lex.am: Likewise.
* automake.in (handle_languages): Skip files whose language
doesn't have a compiler.
Changed '$' to "\$" to aid Emacs fontification.
(struct): Added `rule_file'. Removed `derived_autodep'.
(yacc, yacxx, lex, lexxx): Set `rule_file', `flags', `compile',
and `compiler' attributes. Removed `linker', `derived_autodep',
and `ansi' attributes.
(saw_extension): Count number of times extension seen.
(count_files_for_language): New sub.
(saw_sources_p): Use it.
(handle_single_transform_list): Allow language rewrite function
to return a new source extension.
(yacc_sources, lex_sources): Removed.
(initialize_per_input): Don't initialize yacc_sources or
lex_sources.
(lang_yacc_rewrite): Rewrote.
(lang_yaccxx_rewrite): Likewise.
(lang_lex_rewrite): Likewise.
(lang_lexxx_rewrite): Likewise.
(output_yacc_build_rule): Removed.
(output_lex_build_rule): Removed.
(lang_yacc_finish): Removed build rule generation.
(lang_lex_finish): Likewise.
* tests/yacc5.test: Updated test.
Tom
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1141
diff -u -r1.1141 automake.in
--- automake.in 2001/06/18 01:08:34 1.1141
+++ automake.in 2001/06/21 06:10:13
@@ -38,44 +38,47 @@
use Automake::Struct;
struct (# Short name of the language (c, f77...).
- 'name' => '$',
+ 'name' => "\$",
# Nice name of the language (C, Fortran 77...).
- 'Name' => '$',
+ 'Name' => "\$",
# List of configure variables which must be defined.
'config_vars' => '@',
- 'ansi' => '$',
+ 'ansi' => "\$",
# `pure' is `1' or `'. A `pure' language is one where, if
# all the files in a directory are of that language, then we
# do not require the C compiler or any code to call it.
- 'pure' => '$',
+ 'pure' => "\$",
- 'autodep' => '$',
+ 'autodep' => "\$",
# Name of the compiling variable (COMPILE).
- 'compiler' => '$',
+ 'compiler' => "\$",
# Content of the compiling variable.
- 'compile' => '$',
+ 'compile' => "\$",
# Flag to require compilation without linking (-c).
- 'compile_flag' => '$',
- 'derived_autodep' => '$',
+ 'compile_flag' => "\$",
'extensions' => '@',
- 'flags' => '$',
+ 'flags' => "\$",
+ # The file to use when generating rules for this language.
+ # The default is 'depend2'.
+ 'rule_file' => "\$",
+
# Name of the linking variable (LINK).
- 'linker' => '$',
+ 'linker' => "\$",
# Content of the linking variable.
- 'link' => '$',
+ 'link' => "\$",
# Name of the linker variable (LD).
- 'lder' => '$',
+ 'lder' => "\$",
# Content of the linker variable ($(CC)).
- 'ld' => '$',
+ 'ld' => "\$",
# Flag to specify the output file (-o).
- 'output_flag' => '$',
- '_finish' => '$');
+ 'output_flag' => "\$",
+ '_finish' => "\$");
sub finish ($)
@@ -585,13 +588,6 @@
# in handle_options.
my $use_dependencies;
-# All yacc and lex source filenames for this directory. Use
-# filenames instead of raw count so that multiple instances are
-# counted correctly (eg one yacc file can appear in multiple
-# programs without harm).
-my %yacc_sources;
-my %lex_sources;
-
# This is a list of all targets to run during "make dist".
my @dist_targets;
@@ -744,9 +740,6 @@
$use_dependencies = $cmdline_use_dependencies;
- %yacc_sources = ();
- %lex_sources = ();
-
@dist_targets = ();
%de_ansi_files = ();
@@ -835,37 +828,43 @@
# Nothing to do.
'_finish' => sub { });
-# For now, yacc and lex can't be handled on a per-exe basis.
-
# Yacc (C & C++).
register_language ('name' => 'yacc',
'Name' => 'Yacc',
- 'ansi' => 1,
'config_vars' => ['YACC'],
- 'derived_autodep' => 'yes',
+ 'flags' => 'YFLAGS',
+ 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
+ 'compiler' => 'YACCCOMPILE',
'extensions' => ['y'],
+ 'rule_file' => 'yacc',
'_finish' => \&lang_yacc_finish);
register_language ('name' => 'yaccxx',
'Name' => 'Yacc (C++)',
'config_vars' => ['YACC'],
- 'linker' => 'CXXLINK',
- 'derived_autodep' => 'yes',
+ 'rule_file' => 'yacc',
+ 'flags' => 'YFLAGS',
+ 'compiler' => 'YACCCOMPILE',
+ 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
'_finish' => \&lang_yacc_finish);
# Lex (C & C++).
register_language ('name' => 'lex',
'Name' => 'Lex',
- 'ansi' => 1,
'config_vars' => ['LEX'],
- 'derived_autodep' => 'yes',
+ 'rule_file' => 'lex',
+ 'flags' => 'LFLAGS',
+ 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
+ 'compiler' => 'LEXCOMPILE',
'extensions' => ['l'],
'_finish' => \&lang_lex_finish);
register_language ('name' => 'lexxx',
'Name' => 'Lex (C++)',
'config_vars' => ['LEX'],
- 'linker' => 'CXXLINK',
- 'derived_autodep' => 'yes',
+ 'rule_file' => 'lex',
+ 'flags' => 'LFLAGS',
+ 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
+ 'compiler' => 'LEXCOMPILE',
'extensions' => ['l++', 'll', 'lxx', 'lpp'],
'_finish' => \&lang_lex_finish);
@@ -1519,11 +1518,13 @@
# Is the c linker needed?
my $needs_c = 0;
foreach my $ext (sort keys %extension_seen)
- {
+ {
next unless $extension_map{$ext};
my $lang = $languages{$extension_map{$ext}};
+ my $rule_file = $lang->rule_file || 'depend2';
+
# Get information on $LANG.
my $pfx = $lang->autodep;
my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
@@ -1536,12 +1537,14 @@
'FPFX' => $fpfx,
'LIBTOOL' => $seen_libtool,
'AMDEP' => $AMDEP,
- '-c' => $lang->compile_flag || '');
+ '-c' => $lang->compile_flag || '',
+ 'MORE-THAN-ONE'
+ => (count_files_for_language ($lang->name) >
1));
# Generate the appropriate rules for this extension.
- if ($use_dependencies && $lang->autodep ne 'no'
+ if (($use_dependencies && $lang->autodep ne 'no')
|| defined $lang->compile)
- {
+ {
# Some C compilers don't support -c -o. Use it only if really
# needed.
my $output_flag = $lang->output_flag || '';
@@ -1550,11 +1553,20 @@
&& $lang->flags eq 'CFLAGS'
&& defined $options{'subdir-objects'});
+ # FIXME: this is a temporary hack to compute a possible
+ # derived extension. This is not used by depend2.am.
+ (my $der_ext = $ext) =~ tr/yl/cc/;
+
+ # Another yacc/lex hack.
+ my $destfile = '$*.' . $der_ext;
+
$output_rules .=
- file_contents ('depend2',
+ file_contents ($rule_file,
%transform,
'GENERIC' => 1,
+ 'DERIVED-EXT' => $der_ext,
+
'BASE' => '$*',
'SOURCE' => '$<',
'OBJ' => '$@',
@@ -1564,14 +1576,14 @@
'COMPILE' => '$(' . $lang->compiler . ')',
'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
'-o' => $output_flag);
- }
+ }
# Now include code for each specially handled object with this
# language.
my %seen_files = ();
foreach my $file (@{$lang_specific_files{$lang->name}})
- {
- my ($derived, $source, $obj) = split (' ', $file);
+ {
+ my ($derived, $source, $obj, $myext) = split (' ', $file);
# We might see a given object twice, for instance if it is
# used under different conditions.
@@ -1581,6 +1593,9 @@
my $flags = $lang->flags || '';
my $val = "${derived}_${flags}";
+ &prog_error ("found $lang->name in handle_languages, but compiler
not defined")
+ unless defined $lang->compile;
+
(my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
@@ -1591,20 +1606,23 @@
# depend2.am into real targets for the particular objects we
# are building.
$output_rules .=
- file_contents ('depend2',
+ file_contents ($rule_file,
(%transform,
'GENERIC' => 0,
'BASE' => $obj,
'SOURCE' => $source,
- 'OBJ' => "$obj.o",
+ # Use $myext and not `.o' here, in case
+ # we are actually building a new source
+ # file -- e.g. via yacc.
+ 'OBJ' => "$obj$myext",
'OBJOBJ' => "$obj.obj",
'LTOBJ' => "$obj.lo",
'COMPILE' => $obj_compile,
'LTCOMPILE' => $obj_ltcompile,
'-o' => $output_flag));
- }
+ }
# The rest of the loop is done once per language.
next if defined $done{$lang};
@@ -1643,7 +1661,7 @@
# Call the finisher.
$lang->finish;
- }
+ }
# If the project is entirely C++ or entirely Fortran 77 (i.e., 1
# suffix rule was learned), don't bother with the C stuff. But if
@@ -1662,33 +1680,6 @@
}
}
-# Output a rule to build from a YACC source. The output from YACC is
-# compiled with C or C++, depending on the extension of the YACC file.
-sub output_yacc_build_rule
-{
- my ($yacc_suffix, $use_ylwrap) = @_;
-
- (my $c_suffix = $yacc_suffix) =~ tr/y/c/;
-
- # Generate rule for c/c++.
- $output_rules .= &file_contents ('yacc',
- ('YLWRAP' => $use_ylwrap,
- 'YACC_SUFFIX' => $yacc_suffix,
- 'C_SUFFIX' => $c_suffix));
-}
-
-sub output_lex_build_rule
-{
- my ($lex_suffix, $use_ylwrap) = @_;
-
- (my $c_suffix = $lex_suffix) =~ tr/l/c/;
-
- $output_rules .= &file_contents ('lex',
- ('YLWRAP' => $use_ylwrap,
- 'LEX_SUFFIX' => $lex_suffix,
- 'C_SUFFIX' => $c_suffix));
-}
-
# Check to make sure a source defined in LIBOBJS is not explicitly
# mentioned. This is a separate function (as opposed to being inlined
# in handle_source_transform) because it isn't always appropriate to
@@ -1747,9 +1738,12 @@
$nonansi_obj =~ s/\$U//g;
my %linkers_used = ();
- # Turn sources into objects.
- foreach (@files)
+ # Turn sources into objects. We use a while loop like this
+ # because we might add to @files in the loop.
+ while (scalar @files > 0)
{
+ $_ = shift @files;
+
# Configure substitutions in _SOURCES variables are errors.
if (/address@hidden@$/)
{
@@ -1757,8 +1751,9 @@
next;
}
- # If the source file is in a subdirectory then the `.o' is
- # put into the current directory.
+ # If the source file is in a subdirectory then the `.o' is put
+ # into the current directory, unless the subdir-objects option
+ # is in effect.
# Split file name into base and extension.
next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
@@ -1771,23 +1766,48 @@
my $renamed = 0;
my ($linker, $object);
+ # This records whether we've seen a derived source file (eg,
+ # yacc output).
+ my $derived_source = 0;
+
$extension = &derive_suffix ($extension);
my $lang;
if ($extension_map{$extension} &&
($lang = $languages{$extension_map{$extension}}))
{
- &saw_extension ($extension);
# Found the language, so see what it says.
+ &saw_extension ($extension);
+
+ # Note: computed subr call. The language rewrite function
+ # should return one of the $LANG_* constants. It could
+ # also return a list whose first value is such a constant
+ # and whose second value is a new source extension which
+ # should be applied. This means this particular language
+ # generates another source file which we must then process
+ # further.
my $subr = 'lang_' . $lang->name . '_rewrite';
- # Note: computed subr call.
- my $r = & $subr ($directory, $base, $extension);
+ my ($r, $source_extension)
+ = & $subr ($directory, $base, $extension);
# Skip this entry if we were asked not to process it.
next if $r == $LANG_IGNORE;
# Now extract linker and other info.
$linker = $lang->linker;
- my $this_obj_ext = $lang->ansi ? $obj : $nonansi_obj;
+ my $this_obj_ext;
+ if (defined $source_extension)
+ {
+ $this_obj_ext = '.' . $source_extension;
+ $derived_source = 1;
+ }
+ elsif ($lang->ansi)
+ {
+ $this_obj_ext = $obj;
+ }
+ else
+ {
+ $this_obj_ext = $nonansi_obj;
+ }
$object = $base . $this_obj_ext;
if (defined $lang->flags
@@ -1843,7 +1863,7 @@
{
my $obj_sans_ext = substr ($object, 0,
- length ($this_obj_ext));
- my $val = "$full $obj_sans_ext";
+ my $val = "$full $obj_sans_ext $this_obj_ext";
# If we renamed the object then we want to use the
# per-executable flag name. But if this is simply a
@@ -1858,6 +1878,11 @@
$val = "AM $val";
}
+ # Each item on this list is a string consisting of
+ # four space-separated values: the derived flag prefix
+ # (eg, for `foo_CFLAGS', it is `foo'), the name of the
+ # source file, the base name of the output file, and
+ # the extension for the object file.
push (@{$lang_specific_files{$lang->name}}, $val);
}
}
@@ -1873,13 +1898,13 @@
{
# No error message here. Used to have one, but it was
# very unpopular.
+ # FIXME: we could potentially do more processing here,
+ # perhaps treating the new extension as though it were a
+ # new source extension (as above). This would require
+ # more restructuring than is appropriate right now.
next;
}
- $linkers_used{$linker} = 1;
-
- push (@result, $object);
-
if (defined $object_map{$object})
{
if ($object_map{$object} ne $full)
@@ -1887,7 +1912,24 @@
&am_error ("object `$object' created by `$full' and
`$object_map{$object}'");
}
}
- else
+
+ if ($derived_source)
+ {
+ &prog_error ("$lang->name has automatic dependency tracking")
+ if $lang->autodep ne 'no';
+ # Make sure this new source file is handled next. That will
+ # make it appear to be at the right place in the list.
+ unshift (@files, $object);
+ # FIXME: nodist.
+ &push_dist_common ($object);
+ next;
+ }
+
+ $linkers_used{$linker} = 1;
+
+ push (@result, $object);
+
+ if (! defined $object_map{$object})
{
my @dep_list = ();
$object_map{$object} = $full;
@@ -1955,9 +1997,7 @@
# Transform .o or $o file into .P file (for automatic
# dependency code).
- if ($lang
- && ($lang->autodep ne 'no'
- || $lang->derived_autodep eq 'yes'))
+ if ($lang && $lang->autodep ne 'no')
{
my $depfile = $object;
$depfile =~ s/\.([^.]*)$/.P$1/;
@@ -4866,18 +4906,9 @@
{
my ($directory, $base, $ext) = @_;
- my $r = &lang_c_rewrite ($directory, $base, $ext);
- my $pfx = '';
- if ($r == $LANG_SUBDIR)
- {
- $pfx = $directory . '/';
- }
- $yacc_sources{$pfx . $base . '.' . $ext} = 1;
- $ext =~ tr/y/c/;
- &saw_extension ('c');
- # FIXME: nodist.
- &push_dist_common ($pfx . $base . '.' . $ext);
- return $r;
+ my $r = &lang_sub_obj;
+ (my $newext = $ext) =~ tr/y/c/;
+ return ($r, $newext);
}
# Rewrite a single yacc++ file.
@@ -4885,19 +4916,9 @@
{
my ($directory, $base, $ext) = @_;
- my $r = $LANG_PROCESS;
- my $pfx = '';
- if (defined $options{'subdir-objects'})
- {
- $pfx = $directory . '/';
- $r = $LANG_SUBDIR;
- }
- $yacc_sources{$pfx . $base . '.' . $ext} = 1;
- $ext =~ tr/y/c/;
- &saw_extension ($ext);
- # FIXME: nodist.
- &push_dist_common ($pfx . $base . '.' . $ext);
- return $r;
+ my $r = &lang_sub_obj;
+ (my $newext = $ext) =~ tr/y/c/;
+ return ($r, $newext);
}
# Rewrite a single lex file.
@@ -4905,18 +4926,9 @@
{
my ($directory, $base, $ext) = @_;
- my $r = &lang_c_rewrite ($directory, $base, $ext);
- my $pfx = '';
- if ($r == $LANG_SUBDIR)
- {
- $pfx = $directory . '/';
- }
- $lex_sources{$pfx . $base . '.' . $ext} = 1;
- $ext =~ tr/l/c/;
- &saw_extension ('c');
- # FIXME: nodist.
- &push_dist_common ($pfx . $base . '.' . $ext);
- return $r;
+ my $r = &lang_sub_obj;
+ (my $newext = $ext) =~ tr/l/c/;
+ return ($r, $newext);
}
# Rewrite a single lex++ file.
@@ -4924,19 +4936,9 @@
{
my ($directory, $base, $ext) = @_;
- my $r = $LANG_PROCESS;
- my $pfx = '';
- if (defined $options{'subdir-objects'})
- {
- $pfx = $directory . '/';
- $r = $LANG_SUBDIR;
- }
- $lex_sources{$pfx . $base . '.' . $ext} = 1;
- $ext =~ tr/l/c/;
- &saw_extension ($ext);
- # FIXME: nodist.
- &push_dist_common ($pfx . $base . '.' . $ext);
- return $r;
+ my $r = &lang_sub_obj;
+ (my $newext = $ext) =~ tr/l/c/;
+ return ($r, $newext);
}
# Rewrite a single assembly file.
@@ -5053,51 +5055,13 @@
return if defined $language_scratch{'yacc-done'};
$language_scratch{'yacc-done'} = 1;
- my %seen_suffix = ();
- my @yacc_files = sort keys %yacc_sources;
- my $yacc_count = scalar (@yacc_files);
- foreach my $file (@yacc_files)
- {
- $file =~ /(\..*)$/;
- &output_yacc_build_rule ($1, $yacc_count > 1)
- if ! defined $seen_suffix{$1};
- $seen_suffix{$1} = 1;
-
- $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
- my $base = $1;
- my $hname = 'h'; # Always use `.h' for header file.
- my $cname = $2;
- $cname =~ tr/y/c/;
-
- if ((&variable_defined ('AM_YFLAGS')
- && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
- || (&variable_defined ('YFLAGS')
- && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
- # Now generate rule to make the header file. This should only
- # be generated if `yacc -d' specified.
- $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
-
- # If the files are built in the build directory, then we want
- # to remove them with `make clean'. If they are in srcdir
- # they shouldn't be touched. However, we can't determine this
- # statically, and the GNU rules say that yacc/lex output files
- # should be removed by maintainer-clean. So that's what we
- # do.
- push (@maintainer_clean_files, "${base}.${hname}");
-
- &push_dist_common ("${base}.${hname}");
- }
- push (@maintainer_clean_files, "${base}.${cname}");
- }
- $output_rules .= "\n";
-
if (&variable_defined ('YACCFLAGS'))
{
&am_line_error ('YACCFLAGS',
"`YACCFLAGS' obsolete; use `YFLAGS' instead");
}
- if ($yacc_count > 1)
+ if (count_files_for_language ('yacc') > 1)
{
&yacc_lex_finish_helper;
}
@@ -5109,33 +5073,12 @@
return if defined $language_scratch{'lex-done'};
$language_scratch{'lex-done'} = 1;
- my %seen_suffix = ();
- my $lex_count = scalar (keys %lex_sources);
- foreach my $file (sort keys %lex_sources)
- {
- $file =~ /(\..*)$/;
- &output_lex_build_rule ($1, $lex_count > 1)
- if (! defined $seen_suffix{$1});
- $seen_suffix{$1} = 1;
-
- # If the files are built in the build directory, then we want
- # to remove them with `make clean'. If they are in srcdir
- # they shouldn't be touched. However, we can't determine this
- # statically, and the GNU rules say that yacc/lex output files
- # should be removed by maintainer-clean. So that's what we
- # do.
- $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
- my $cname;
- ($cname = $2) =~ tr/l/c/;
- push (@maintainer_clean_files, "${1}.${cname}");
- }
-
if (! $seen_decl_yytext)
{
&am_error ("lex source seen but `AC_DECL_YYTEXT' not in
`$configure_ac'");
}
- if ($lex_count > 1)
+ if (count_files_for_language ('lex') > 1)
{
&yacc_lex_finish_helper;
}
@@ -5165,7 +5108,48 @@
sub saw_extension
{
my ($ext) = @_;
- $extension_seen{$ext} = 1;
+ if (! defined $extension_seen{$ext})
+ {
+ $extension_seen{$ext} = 1;
+ }
+ else
+ {
+ ++$extension_seen{$ext};
+ }
+}
+
+# Return the number of files seen for a given language. Knows about
+# special cases we care about. FIXME: this is hideous. We need
+# something that involves real language objects. For instance yacc
+# and yaccxx could both derive from a common yacc class which would
+# know about the strange ylwrap requirement. (Or better yet we could
+# just not support legacy yacc!)
+sub count_files_for_language
+{
+ my ($name) = @_;
+
+ my @names;
+ if ($name eq 'yacc' || $name eq 'yaccxx')
+ {
+ @names = ('yacc', 'yaccxx');
+ }
+ elsif ($name eq 'lex' || $name eq 'lexxx')
+ {
+ @names = ('lex', 'lexxx');
+ }
+ else
+ {
+ @names = ($name);
+ }
+
+ my $r = 0;
+ foreach $name (@names)
+ {
+ my $lang = $languages{$name};
+ $r += scalar grep ($extension_seen{$_}, @{$lang->extensions});
+ }
+
+ return $r
}
# Called to ask whether source files have been seen . If HEADERS is 1,
@@ -5180,8 +5164,7 @@
}
else
{
- $headers = grep ($extension_seen{$_},
- @{$languages{'header'}->extensions});
+ $headers = count_files_for_language ('header');
}
return scalar keys %extension_seen > $headers;
@@ -5201,8 +5184,6 @@
unless defined $option{'ansi'};
$option{'autodep'} = 'no'
unless defined $option{'autodep'};
- $option{'derived_autodep'} = 'no'
- unless defined $option{'derived_autodep'};
$option{'linker'} = ''
unless defined $option{'linker'};
Index: lib/ylwrap
===================================================================
RCS file: /cvs/automake/automake/lib/ylwrap,v
retrieving revision 1.16
diff -u -r1.16 ylwrap
--- ylwrap 2001/05/15 03:33:20 1.16
+++ ylwrap 2001/06/21 06:10:14
@@ -18,38 +18,14 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Usage:
-# ylwrap PROGRAM [ARGS] INPUT [OUTPUT DESIRED]... -- [ARGS]...
-# * PROGRAM is program to run; options can follow but must start with `-'.
+# ylwrap INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
# * INPUT is the input file
# * OUTPUT is file PROG generates
# * DESIRED is file we actually want
+# * PROGRAM is program to run
# * ARGS are passed to PROG
# Any number of OUTPUT,DESIRED pairs may be used.
-# The program to run.
-prog="$1"
-shift
-# Make any relative path in $prog absolute.
-case "$prog" in
- /* | [A-Za-z]:*) ;;
- */*) prog="`pwd`/$prog" ;;
-esac
-
-# We also have to accept options here and append them to the program.
-# Why? Suppose YACC is set to `bison -y'. Clearly nobody uses
-# ylwrap, or this would have been discovered earlier!
-while :; do
- case "$1" in
- -*)
- prog="$prog $1"
- shift
- ;;
- *)
- break
- ;;
- esac
-done
-
# The input.
input="$1"
shift
@@ -80,6 +56,15 @@
pairlist="$pairlist $1"
shift
done
+
+# The program to run.
+prog="$1"
+shift
+# Make any relative path in $prog absolute.
+case "$prog" in
+ /* | [A-Za-z]:*) ;;
+ */*) prog="`pwd`/$prog" ;;
+esac
# FIXME: add hostname here for parallel makes that run commands on
# other machines. But that might take us over the 14-char limit.
Index: lib/am/lex.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/lex.am,v
retrieving revision 1.2
diff -u -r1.2 lex.am
--- lex.am 2001/05/08 10:58:49 1.2
+++ lex.am 2001/06/21 06:10:14
@@ -19,10 +19,10 @@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LEXLIB = @LEXLIB@
-## Generate rule for c/c++.
-%LEX_SUFFIX%%C_SUFFIX%:
-if %?YLWRAP%
- $(SHELL) $(YLWRAP) $(LEX) $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS)
$(LFLAGS)
-else !%?YLWRAP%
- $(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
-endif !%?YLWRAP%
+?GENERIC?.%EXT%.%DERIVED-EXT%:
+?!GENERIC?%OBJ%: %SOURCE%
+if %?MORE-THAN-ONE%
+ $(SHELL) $(YLWRAP) %SOURCE% $(LEX_OUTPUT_ROOT).c %OBJ% -- %COMPILE%
+else !%?MORE-THAN-ONE%
+ %COMPILE% %SOURCE% && mv $(LEX_OUTPUT_ROOT).c %OBJ%
+endif !%?MORE-THAN-ONE%
Index: lib/am/yacc.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/yacc.am,v
retrieving revision 1.4
diff -u -r1.4 yacc.am
--- yacc.am 2001/05/15 02:21:53 1.4
+++ yacc.am 2001/06/21 06:10:14
@@ -16,17 +16,26 @@
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
-## Generate rule for c/c++.
-%YACC_SUFFIX%%C_SUFFIX%:
-if %?YLWRAP%
- $(SHELL) $(YLWRAP) $(YACC) $< y.tab.c $*%C_SUFFIX% y.tab.h $*.h --
$(AM_YFLAGS) $(YFLAGS)
-else !%?YLWRAP%
- $(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*%C_SUFFIX%
+?GENERIC?.%EXT%.%DERIVED-EXT%:
+?!GENERIC?%OBJ%: %SOURCE%
+if %?MORE-THAN-ONE%
+ $(SHELL) $(YLWRAP) %SOURCE% y.tab.c %OBJ% y.tab.h %BASE%.h -- %COMPILE%
+else !%?MORE-THAN-ONE%
+ %COMPILE% %SOURCE% && mv y.tab.c %OBJ%
if test -f y.tab.h; then \
- if cmp -s y.tab.h $*.h; then \
+ if cmp -s y.tab.h %BASE%.h; then \
rm -f y.tab.h; \
else \
- mv y.tab.h $*.h; \
+ mv y.tab.h %BASE%.h; \
fi; \
fi
-endif !%?YLWRAP%
+endif !%?MORE-THAN-ONE%
+
+## Also generate a dependency for the .h file.
+## FIXME: does this sort of suffix rule really work?
+if %?GENERIC%
+.%EXT.h:
+ @:
+else !%?GENERIC%
+%BASE%.h: %SOURCE%
+endif !%?GENERIC%
Index: tests/yacc5.test
===================================================================
RCS file: /cvs/automake/automake/tests/yacc5.test,v
retrieving revision 1.2
diff -u -r1.2 yacc5.test
--- yacc5.test 2001/06/20 16:46:15 1.2
+++ yacc5.test 2001/06/21 06:10:14
@@ -43,7 +43,7 @@
$ACLOCAL || exit 1
$AUTOMAKE -a || exit 1
-grep '^sub/maude\.c:' Makefile.in
+grep '^sub/maude\.c:' Makefile.in || exit 1
## Try again with per-exe flags.
@@ -58,5 +58,13 @@
$ACLOCAL || exit 1
$AUTOMAKE -a || exit 1
-grep AM_YFLAGS Makefile.in && exit 1
+# Rule should use maude_YFLAGS.
+grep 'AM_YFLAGS.*maude' Makefile.in && exit 1
+
+# Silly regression.
+grep 'maudec' Makefile.in && exit 1
+
+# Make sure the .o file is required.
+grep '^am_maude_OBJECTS.*maude' Makefile.in || exit 1
+
exit 0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Patch (not checking in): yacc5.test fix take 2,
Tom Tromey <=