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