[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch-1-7: lib/am/yacc.am: never redirect directly to $@
From: |
Jim Meyering |
Subject: |
branch-1-7: lib/am/yacc.am: never redirect directly to $@ |
Date: |
Thu, 17 Apr 2003 21:58:28 +0200 |
This patch is for the 1.7 branch, but I'll install it on
the trunk too, unless someone objects.
There are two important rules in writing Makefiles:
* never redirect directly to $@
* when you do update $@, do it atomically and only after any side-effect
commands have completed successfully
In the patch below, %OBJ% usually expands to address@hidden
2003-04-17 Jim Meyering <address@hidden>
* lib/am/yacc.am (?GENERIC?%EXT%%DERIVED-EXT% aka .y.c): Don't redirect
directly to address@hidden Instead, redirect to address@hidden and
rename upon success.
Also, move the commands that update $@ so they are last. Otherwise,
this rule could leave the user with an up to date target (.c file)
but with a missing or corrupted corresponding .h file.
Index: lib/am/yacc.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/yacc.am,v
retrieving revision 1.14
diff -u -p -r1.14 yacc.am
--- lib/am/yacc.am 8 Jun 2002 17:22:27 -0000 1.14
+++ lib/am/yacc.am 17 Apr 2003 19:51:05 -0000
@@ -1,5 +1,5 @@
## automake - create Makefile.in from Makefile.am
-## Copyright 1998, 1999, 2001 Free Software Foundation, Inc.
+## Copyright 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -22,9 +22,6 @@ if %?MORE-THAN-ONE%
$(SHELL) $(YLWRAP) `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
y.tab.c %OBJ% y.tab.h %BASE%.h y.output %BASE%.output -- %COMPILE%
else !%?MORE-THAN-ONE%
%COMPILE% `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
-## Edit out `#line' or `#' directives.
- sed '/^#/ s|y\.tab\.c|%OBJ%|' y.tab.c >%OBJ%
- rm -f y.tab.c
## Edit out Bison multiple inclusion guards. It may be BISON_Y_TAB_H,
## or Y_TAB_H depending upon the version, that's why the regexp is
## so loose.
@@ -43,4 +40,7 @@ else !%?MORE-THAN-ONE%
if test -f y.output; then \
mv y.output %BASE%.output; \
fi
+## Edit out `#line' or `#' directives.
+ sed '/^#/ s|y\.tab\.c|%OBJ%|' y.tab.c >%OBJ%t && mv %OBJ%t %OBJ%
+ rm -f y.tab.c
endif !%?MORE-THAN-ONE%
- branch-1-7: lib/am/yacc.am: never redirect directly to $@,
Jim Meyering <=