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.
+2003-11-18 Paolo Bonzini <bonzini@gnu.org>
+ Alexandre Duret-Lutz <adl@gnu.org>
+
+ * 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.
+
2003-11-17 Alexandre Duret-Lutz <adl@gnu.org>
* automake.in (generate_makefile): Define SUBDIRS if it is
install it once for all in your source tree (and in your code
management system).
+ - Fix ylwrap so that it does not overwrite header files that haven't
+ changed, as the inline rule already does.
+
* Miscellaneous
- The Automake manual is now distributed under the terms of the GNU FDL.
#! /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.
*) 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
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
#! /bin/sh
-# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
# Test to make sure ylwrap put in right location.
# Report from Tim Van Holder.
+# Also make sure depcomp does not needlessly update headers.
+# Report from Paolo Bonzini.
+required='gcc bison'
. ./defs || exit 1
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_AUX_DIR([aux])
AC_PROG_CC
AC_PROG_YACC
-AC_OUTPUT(Makefile sub/Makefile)
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
END
cat > Makefile.am << 'END'
SUBDIRS = sub
+
+test-time-unchanged:
+ test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = z
+test-time-changed:
+ test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = sub/main.$(OBJEXT)
END
-mkdir sub
+mkdir aux sub
cat > sub/Makefile.am << 'END'
-bin_PROGRAMS = foo
-foo_SOURCES = foo.y bar.y
+bin_PROGRAMS = foo bar
+AM_YFLAGS = -d
+foo_SOURCES = foo.y main.c
+foo_CPPFLAGS = -DFOO
+bar_SOURCES = bar.y main.c
+END
+
+cat > sub/foo.y << 'END'
+%{
+int yylex () {return 0;}
+void yyerror (char *s) {}
+%}
+%token TOKEN
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
END
-: > sub/foo.y
-: > sub/bar.y
+cp sub/foo.y sub/bar.y
+
+cat >sub/main.c <<'EOF'
+#ifdef FOO
+# include "foo.h"
+#else
+# include "bar.h"
+#endif
+
+int
+main()
+{
+ return 0;
+}
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+test -f aux/ylwrap
+test ! -f ylwrap
+test ! -f sub/ylwrap
+$FGREP '(top_srcdir)/aux/ylwrap' sub/Makefile.in
+./configure
+$MAKE
+grep '#.*line.*foo.y' sub/foo.c
+grep '#.*line.*bar.y' sub/bar.c
-$ACLOCAL || exit 1
-$AUTOMAKE -a || exit 1
-test -f ylwrap || exit 1
-$FGREP '(srcdir)/ylwrap' sub/Makefile.in && exit 1
-exit 0
+$sleep
+: > z
+$sleep
+touch sub/bar.y
+$MAKE
+$MAKE test-time-unchanged
+$sleep
+$PERL -pi -e s/TOKEN/TEKON/g sub/bar.y
+$MAKE
+$MAKE test-time-changed
bin_PROGRAMS = foo/foo
foo_foo_SOURCES = foo/parse.y
AM_YFLAGS = -d
+
+obj: foo/parse.$(OBJEXT)
+
+test1: obj
+ test -f foo/parse.c
+ test -f foo/parse.$(OBJEXT)
+
+test2: obj
+ test -f foo/parse.c
+ test -f foo/parse.$(OBJEXT)
END
mkdir foo
cd sub
../configure
-$MAKE foo/parse.o
-test -f foo/parse.c
-test -f foo/parse.o
+$MAKE test1
# Aside of the rest of this test, let's see if we can recover from
# parse.h removal
$MAKE foo/parse.h
test -f foo/parse.h
+# Make sure foo/parse.h is not updated, unless when needed.
+$sleep
+: > z
+$sleep
+touch ../foo/parse.y
+$MAKE obj
+test `ls -1t foo/parse.h z | sed 1q` = z
+$sleep
+$PERL -pi -e 's/%%/%token TOKEN\n%%/g' ../foo/parse.y
+$MAKE obj
+test `ls -1t foo/parse.h z | sed 1q` = foo/parse.h
+
# Now, adds another parser to test ylwrap.
cd ..
cd sub
# Regenerate Makefile (automatic in GNU Make, but not in other Makes)
./config.status
-$MAKE foo/parse2.o
-test -f foo/parse2.c
-test -f foo/parse2.o
-
-exit 0
+$MAKE test2