test: check that subsecond mtime works with make.
[automake.git] / lib / am / configure.am
blob310e47c90d6cfa8a118bcaffcca1866e1f0f60a5
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001-2024 Free Software Foundation, Inc.
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.
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.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
18 ## This dummy rule is called from subdirectories whenever one of the
19 ## top-level Makefile's dependencies must be updated.  It does depend
20 ## on %MAKEFILE% for the benefit of non-GNU make implementations (GNU
21 ## make will always make sure %MAKEFILE% is updated before considering
22 ## the am--refresh target anyway).
23 if %?TOPDIR_P%
24 .PHONY: am--refresh
25 am--refresh: %MAKEFILE%
26         @:
27 endif %?TOPDIR_P%
29 ## --------------------- ##
30 ## Building Makefile.*.  ##
31 ## --------------------- ##
33 ## This rule remakes the Makefile.in.
34 %MAKEFILE-IN%: %MAINTAINER-MODE% %MAKEFILE-AM% %MAKEFILE-IN-DEPS% $(am__configure_deps)
35 ## If configure.ac or one of configure's dependencies has changed, all
36 ## Makefile.in are to be updated; it is then more efficient to run
37 ## automake on all the Makefiles at once.  It also allow Automake to be
38 ## run for newly added directories.
39         @for dep in $?; do \
40           case '$(am__configure_deps)' in \
41             *$$dep*) \
42 ?TOPDIR_P?            echo ' cd $(srcdir) && $(AUTOMAKE) %AUTOMAKE-OPTIONS%'; \
43 ?TOPDIR_P?            $(am__cd) $(srcdir) && $(AUTOMAKE) %AUTOMAKE-OPTIONS% \
44 ?TOPDIR_P?              && exit 0; \
45 ?!TOPDIR_P?           ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
46 ## If on the other hand, subdir/Makefile.in has been removed, then toplevel
47 ## am--refresh will not be aware of any need to run.  We still invoke it
48 ## due to $? listing all prerequisites.  Fix up for it by running the rebuild
49 ## rule for this file only, below.
50 ?!TOPDIR_P?             && { if test -f $@; then exit 0; else break; fi; }; \
51               exit 1;; \
52           esac; \
53         done; \
54 ## Otherwise, rebuild only this file.
55         echo ' cd $(top_srcdir) && $(AUTOMAKE) %AUTOMAKE-OPTIONS% %MAKEFILE-AM-SOURCES%'; \
56         $(am__cd) $(top_srcdir) && \
57           $(AUTOMAKE) %AUTOMAKE-OPTIONS% %MAKEFILE-AM-SOURCES%
59 ## Ensure that GNU make doesn't remove Makefile if ./config.status (below)
60 ## is interrupted.  Otherwise, the user would need to know to rerun
61 ## ./config.status to recreate the lost Makefile.
62 .PRECIOUS: %MAKEFILE%
63 ## This rule remakes the Makefile.
64 %MAKEFILE%: %MAKEFILE-DEPS% $(top_builddir)/config.status
65 ## If Makefile is to be updated because of config.status, then run
66 ## config.status without argument in order to (i) rerun all the
67 ## AC_CONFIG_COMMANDS including those that are not visible to
68 ## Automake, and (ii) to save time by running config.status all with
69 ## all the files, instead of once per file (iii) generate Makefiles
70 ## in newly added directories.
71         @case '$?' in \
72 ## Don't prefix $(top_builddir), because GNU make will strip it out
73 ## when it's '.'.
74           *config.status*) \
75 ?TOPDIR_P?          echo ' $(SHELL) ./config.status'; \
76 ?TOPDIR_P?          $(SHELL) ./config.status;; \
77 ?!TOPDIR_P?         cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
78           *) \
79 ## FIXME: $(am__maybe_remake_depfiles) lets us re-run the rule to create the
80 ## .P files.  Ideally we wouldn't have to do this by hand.
81             echo ' cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__maybe_remake_depfiles)'; \
82             cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__maybe_remake_depfiles);; \
83         esac;
85 ## Avoid the "deleted header file" problem for the dependencies.
86 ##  Add the trailing "$(am__empty)" to trick Automake into not spuriously
87 ## complaining about "duplicated targets" in case the %MAKEFILE-IN-DEPS%
88 ## list expands to a single target that is also declared in some
89 ## user-defined rule.
90 ?HAVE-MAKEFILE-IN-DEPS?%MAKEFILE-IN-DEPS% $(am__empty):
92 DIST_COMMON += %MAKEFILE-AM%
95 ## --------------------------- ##
96 ## config.status & configure.  ##
97 ## --------------------------- ##
99 if %?TOPDIR_P%
100 ## Always require configure.ac and configure at top level, even if they
101 ## don't exist.  This is especially important for configure, since it
102 ## won't be created until autoconf is run -- which might be after
103 ## automake is run.
104 DIST_COMMON += $(top_srcdir)/configure $(am__configure_deps)
105 endif %?TOPDIR_P%
107 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
108 ?TOPDIR_P?      $(SHELL) ./config.status --recheck
109 ?!TOPDIR_P?     cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
111 $(top_srcdir)/configure: %MAINTAINER-MODE% $(am__configure_deps)
112 ?TOPDIR_P?      $(am__cd) $(srcdir) && $(AUTOCONF)
113 ?!TOPDIR_P?     cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
116 ## ------------ ##
117 ## aclocal.m4.  ##
118 ## ------------ ##
120 ## Whenever a configure dependency changes we need to rebuild
121 ## aclocal.m4 too.  Changing configure.ac, or any file included by
122 ## aclocal.m4 might require adding more files to aclocal.m4.  Hence
123 ## the $(am__configure_deps) dependency.
124 ## We still need $(ACLOCAL_AMFLAGS) for sake of backward-compatibility;
125 ## we should hopefully be able to get rid of it in a not-so-distant
126 ## future.
127 if %?REGEN-ACLOCAL-M4%
128 $(ACLOCAL_M4): %MAINTAINER-MODE% $(am__aclocal_m4_deps)
129 ?TOPDIR_P?      $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
130 ?!TOPDIR_P?     cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
132 ## Avoid the "deleted header file" problem for the dependencies.
133 $(am__aclocal_m4_deps):
134 endif %?REGEN-ACLOCAL-M4%
137 ## --------- ##
138 ## cleanup.  ##
139 ## --------- ##
141 ## We special-case config.status here.  If we do it as part of the
142 ## normal clean processing for this directory, then it might be
143 ## removed before some subdir is cleaned.  However, that subdir's
144 ## Makefile depends on config.status.
146 if %?TOPDIR_P%
147 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
148  configure.lineno config.status.lineno
149 distclean:
150         -rm -f $(am__CONFIG_DISTCLEAN_FILES)
152 ## Note: you might think we should remove Makefile.in, configure, or
153 ## aclocal.m4 here in a maintainer-clean rule.  However, the GNU
154 ## Coding Standards explicitly prohibit this.
156 maintainer-clean:
157         -rm -f $(am__CONFIG_DISTCLEAN_FILES)
158 ## autom4te.cache is created by Autoconf; the only valid target to
159 ## remove it is maintainer-clean, not distclean.
160 ## If you have an autom4te.cache that cause distcheck to fail, then
161 ## it is good news: you finally discovered that autoconf and/or
162 ## autoheader is needed to use your tarball, which is wrong.
163         -rm -rf $(top_srcdir)/autom4te.cache
166 endif %?TOPDIR_P%