summaryrefslogtreecommitdiff
path: root/lib/ylwrap
diff options
context:
space:
mode:
authorAlexandre Duret-Lutz <adl@gnu.org>2003-11-18 20:06:44 +0000
committerAlexandre Duret-Lutz <adl@gnu.org>2003-11-18 20:06:44 +0000
commit28c655bd03f2098c66fd6bafd4d0d1cb8c171f3e (patch)
treecbb9a60a1b855bd66320a5d72ce5abaa370404e5 /lib/ylwrap
parent9b5e57d52c8465ea7df1af852cedeaeb0f43f748 (diff)
downloadautomake-28c655bd03f2098c66fd6bafd4d0d1cb8c171f3e.tar.gz
* lib/ylwrap: Do not overwrite headers if they haven't changed.
Fix the include guard substitution. * tests/yacc6.test: Augment to run ylwrap, and make sure it does not needlessly update headers. * tests/yacc8.test: Make sure headers are not needlessly updated with ylwrap is not used. Move `test -f foo.o' into the Makefile as `test -f foo.$(OBJEXT)' for portability.
Diffstat (limited to 'lib/ylwrap')
-rwxr-xr-xlib/ylwrap28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/ylwrap b/lib/ylwrap
index f5d0c30f6..f86e21730 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -1,7 +1,7 @@
#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations.
-scriptversion=2003-11-09.00
+scriptversion=2003-11-18.20
# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003
# Free Software Foundation, Inc.
@@ -149,6 +149,16 @@ if test $status -eq 0; then
*) target="../$2";;
esac
+ # We do not want to overwrite a header file if it hasn't
+ # changed. This avoid useless recompilations. However the
+ # parser itself (the first file) should always be updated,
+ # because it is the destination of the .y.c rule in the
+ # Makefile. Divert the output of all other files to a temporary
+ # file so we can compare them to existing versions.
+ if test $first = no; then
+ realtarget="$target"
+ target="tmp-`echo $target | sed s/.*[\\/]//g`"
+ fi
# Edit out `#line' or `#' directives.
#
# We don't want the resulting debug information to point at
@@ -165,8 +175,20 @@ if test $status -eq 0; then
TARGET=`echo "$2" | sed \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
- sed "/^#/{s,$input_rx,,;s,$from,$2,;s,$FROM,$TO,;}" "$from" >"$target" ||
- status=$?
+
+ sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
+ -e "s,$FROM,$TARGET," "$from" >"$target" || status=$?
+
+ # Check whether header files must be updated.
+ if test $first = no; then
+ if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
+ echo "$2" is unchanged
+ rm -f "$target"
+ else
+ echo updating "$2"
+ mv -f "$target" "$realtarget"
+ fi
+ fi
else
# A missing file is only an error for the first file. This
# is a blatant hack to let us support using "yacc -d". If -d