[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: fixing AC_CONFIG_HEADERS rules (PR/355)
From: |
Alexandre Duret-Lutz |
Subject: |
Re: RFC: fixing AC_CONFIG_HEADERS rules (PR/355) |
Date: |
Mon, 27 Oct 2003 22:17:03 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) |
>>> "adl" == Alexandre Duret-Lutz <address@hidden> writes:
[...]
adl> - ensure that all AC_CONFIG_HEADERS *inputs* are up to
adl> date before running a complete config.status.
adl> The last point is the one that worries me. Without it
adl> you can get the following scenario:
adl> 1. the user updates some configure dependency (let's say foo.m4)
adl> and run `make'
adl> 2. our new rebuild rules detect that a foo.m4 has changed,
adl> run aclocal, autoconf, automake, and then run ./config.status.
adl> (Note that autoheader hasn't been called yet, so ./config.status
adl> outputs a config.h from an obsolete config.h.in.)
adl> 3. Once Makefile has been regenerated, make continues, and
adl> discover that config.h is a dependency of the `all' rule.
adl> Because config.h depends on stamp-h1, stamp-h1 depends on
adl> config.hin, and config.h.in depends on aclocal.m4, make runs
adl> autoheader to rebuild config.h.in.
adl> Now make ought to call ./config.status once again
adl> to rebuild config.h from the new config.h.in, but if you have a
adl> sufficiently fast box, steps 2 and 3 will occur within the
adl> same second: the config.h generated from the outdated
adl> config.h.in will have the same mtime as the new config.h.in.
adl> Hence make will think that config.h is up to date.
adl> I thought of two solution for this:
adl> a. sleep before running autoheader
adl> b. ensure that config.h.in is up to date before running
adl> ./config.status at step 2.
I've found another solution, which is simple enough: it suffices
to erase the stamp file when autoheader runs.
I'm installing the following.
2003-10-27 Alexandre Duret-Lutz <address@hidden>
* lib/am/remake-hdr.am ($(srcdir)/%CONFIG_HIN%): Erase %STAMP%.
* tests/Makefile.am (TESTS): Add autohdr3.test
* tests/autohdr3.test: New file.
Index: lib/am/remake-hdr.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/remake-hdr.am,v
retrieving revision 1.41
diff -u -r1.41 remake-hdr.am
--- lib/am/remake-hdr.am 27 Oct 2003 07:52:00 -0000 1.41
+++ lib/am/remake-hdr.am 27 Oct 2003 21:12:29 -0000
@@ -38,7 +38,38 @@
if %?FIRST_CONFIG_HIN%
$(srcdir)/%CONFIG_HIN%: %MAINTAINER-MODE% $(am__configure_deps) %FILES%
cd $(top_srcdir) && $(AUTOHEADER)
-## Autoheader has the bad habit of not changing the time stamp if
+## Whenever $(AUTOHEADER) has run, we must make sure that
+## ./config.status will rebuild config.h. The dependency from %STAMP%
+## on %CONFIG_H_DEPS% (which contains config.hin) is not enough to
+## express his.
+##
+## There are some tricky cases where this rule will build a
+## config.hin which has the same timestamp as %STAMP%, in which case
+## ./config.status will not be rerun (meaning that users will use in
+## out-of-date config.h without knowing it). One situation where this
+## can occurs is the following:
+## 1. the user updates some configure dependency (let's say foo.m4)
+## and run `make'
+## 2. the rebuild rules detect that a foo.m4 has changed,
+## run aclocal, autoconf, automake, and then run ./config.status.
+## (Note that autoheader hasn't been called yet, so ./config.status
+## outputs a config.h from an obsolete config.hin.)
+## 3. Once Makefile has been regenerated, make continues, and
+## discover that config.h is a dependency of the `all' rule.
+## Because config.h depends on stamp-h1, stamp-h1 depends on
+## config.hin, and config.hin depends on aclocal.m4, make runs
+## autoheader to rebuild config.hin.
+## Now make ought to call ./config.status once again to rebuild
+## config.h from the new config.hin, but if you have a sufficiently
+## fast box, steps 2 and 3 will occur within the same second: the
+## config.h/stamp-h1 generated from the outdated config.hin will have
+## the same mtime as the new config.hin. Hence make will think that
+## config.h is up to date.
+##
+## A solution is to erase %STAMP% here so that the %STAMP% rule
+## is always triggered after the this one.
+ rm -f %STAMP%
+## Autoheader has the bad habit of not changing the timestamp if
## config.hin is unchanged, which breaks Make targets. Since what
## must not changed gratuitously is config.h, which is already handled
## by config.status, there is no reason to make things complex for
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.521
diff -u -r1.521 Makefile.am
--- tests/Makefile.am 26 Oct 2003 21:20:10 -0000 1.521
+++ tests/Makefile.am 27 Oct 2003 21:12:29 -0000
@@ -46,6 +46,7 @@
asm.test \
autohdr.test \
autohdr2.test \
+autohdr3.test \
autohdr4.test \
auxdir.test \
auxdir2.test \
Index: tests/autohdr3.test
===================================================================
RCS file: tests/autohdr3.test
diff -N tests/autohdr3.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/autohdr3.test 27 Oct 2003 21:12:29 -0000
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check rebuild rules for autoheader.
+
+required=GNUmake
+. ./defs
+
+set -e
+
+cat >>configure.in <<EOF
+m4_include([foo.m4])
+AC_CONFIG_HEADERS([config.h:config.hin])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+: > foo.m4
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+./configure
+$MAKE
+
+$sleep
+echo 'AC_DEFINE([GREPME], 1, [Doc for GREPME])' > foo.m4
+
+$MAKE
+grep GREPME config.hin
+grep GREPME config.h
+
+$MAKE distcheck
--
Alexandre Duret-Lutz