Merge branch 'sanity-sleep-fix-master'
[platform/upstream/automake.git] / lib / am / remake-hdr.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2005,
3 ## 2008, 2009, 2010 Free Software Foundation, Inc.
4
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2, or (at your option)
8 ## any later version.
9
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 ## Explicitly look in srcdir for benefit of non-GNU makes.
19
20
21 %CONFIG_H%: %STAMP%
22 ## Recover from removal of CONFIG_HEADER
23         @if test ! -f $@; then rm -f %STAMP%; else :; fi
24         @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) %STAMP%; else :; fi
25
26
27 %STAMP%: %CONFIG_H_DEPS% $(top_builddir)/config.status
28         @rm -f %STAMP%
29         cd $(top_builddir) && $(SHELL) ./config.status %CONFIG_H_PATH%
30
31
32 ## Only the first file of AC_CONFIG_HEADERS is assumed to be generated
33 ## by autoheader.
34 if %?FIRST%
35 %CONFIG_HIN%: %MAINTAINER-MODE% $(am__configure_deps) %FILES%
36 ## Cater to parallel BSD make.
37         ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
38 ## Whenever $(AUTOHEADER) has run, we must make sure that
39 ## ./config.status will rebuild config.h.  The dependency from %STAMP%
40 ## on %CONFIG_H_DEPS% (which contains config.hin) is not enough to
41 ## express this.
42 ##
43 ## There are some tricky cases where this rule will build a
44 ## config.hin which has the same timestamp as %STAMP%, in which case
45 ## ./config.status will not be rerun (meaning that users will use an
46 ## out-of-date config.h without knowing it).  One situation where this
47 ## can occur is the following:
48 ## 1. the user updates some configure dependency (let's say foo.m4)
49 ##    and runs `make'
50 ## 2. the rebuild rules detect that a foo.m4 has changed,
51 ##    run aclocal, autoconf, automake, and then run ./config.status.
52 ##    (Note that autoheader hasn't been called yet, so ./config.status
53 ##    outputs a config.h from an obsolete config.hin.)
54 ## 3. Once Makefile has been regenerated, make continues, and
55 ##    discovers that config.h is a dependency of the `all' rule.
56 ##    Because config.h depends on stamp-h1, stamp-h1 depends on
57 ##    config.hin, and config.hin depends on aclocal.m4, make runs
58 ##    autoheader to rebuild config.hin.
59 ## Now make ought to call ./config.status once again to rebuild
60 ## config.h from the new config.hin, but if you have a sufficiently
61 ## fast box, steps 2 and 3 will occur within the same second: the
62 ## config.h/stamp-h1 generated from the outdated config.hin will have
63 ## the same mtime as the new config.hin.  Hence make will think that
64 ## config.h is up to date.
65 ##
66 ## A solution is to erase %STAMP% here so that the %STAMP% rule
67 ## is always triggered after the this one.
68         rm -f %STAMP%
69 ## Autoheader has the bad habit of not changing the timestamp if
70 ## config.hin is unchanged, which breaks Make targets.  Since what
71 ## must not changed gratuitously is config.h, which is already handled
72 ## by config.status, there is no reason to make things complex for
73 ## config.hin.
74         touch $@
75 endif %?FIRST%