Follow-up Comment #3, bug #27609 (project make):

Re: what can be done about it.

Enough silly venting. How about the question of what can be done about it? I
have an idea. How about a check to see whether the .c file to be clobbered is
actually a yacc-generated file?

If the file already exists, only do the move if, say, the first three lines
of the the file are different from the first three lines of y.tab.c.

Otherwise emit a diagnostic.

If you have GNU bash, or some other shell which supports process
substitution, the logic can be expressed as:

  # Do the rename if $target does not exist, or if it
  # matches source in the first three lines.
  
  if ![ -e "$target" ] || !diff <(head -3 "$source") <(head -3 "$target");
then
    mv -- "$source" "$target"
  else
    echo "refusing update $target by replacing it with $source"
    echo "target seems to have contents unrelated to $source"
  fi

Of course, it has to be done according to whatever portability guidelines
apply to the ruleset.

The downside would be that the rule refuses to do the move when it should:
there is a false difference in the first three lines on every incremental
rebuild. This might happen if the yacc implementation does something different
in the first three lines (like adding a date stamp). Or (probably very
unlikely) if edits in the actual yacc spec are reflected in an actual change
in the first three lines.

The output of Bison does have a date stamp in the first three lines, but it's
not generated; it's part of the boiler plate. For example:

#ifndef lint
static char const
yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06
bde Exp $";

This stamp won't change unless someone checks in the generated parser under
version control which not only does RCS keyword expansion, but recognizes and
expands the custom FreeBSD keyword.

Suppose your CVS does that. So you'd be doing a ``cvs up'', and then a
``make'', and ... oops! The parser.c got refreshed, so did parser.y, and now
GNU make refuses to rename y.tab.c to parser.c, because CVS modified the
$FreeBSD: ... $ text.

You would have to "rm parser.c" and run make again.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?27609>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to