test: check that subsecond mtime works with make.
[automake.git] / lib / am / header-vars.am
bloba9280d56ab8a0d64daaa781865e22733698fe4da
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994-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/>.
17 VPATH = @srcdir@
19 @SET_MAKE@
21 ## We used to define this.  However, we don't because vendor makes
22 ## (e.g., Solaris, Irix) won't correctly propagate variables that are
23 ## defined in Makefile.  This particular variable can't be correctly
24 ## defined by configure (at least, not the current configure), so we
25 ## simply avoid defining it to allow the user to use this feature with
26 ## a vendor make.
27 ## DESTDIR =
29 ## Shell code that determines whether we are running under GNU make.
31 ## Why the this needs to be so convoluted?
33 ## (1) We can't unconditionally use make functions or special variables
34 ##     starting with a dot, as those cause non-GNU implementations to
35 ##     crash hard.
37 ## (2) We can't use $(MAKE_VERSION) here, as it is also defined in some
38 ##     non-GNU make implementations (e.g., FreeBSD make).  But at least
39 ##     BSD make does *not* define the $(CURDIR) variable -- it uses
40 ##     $(.CURDIR) instead.
42 ## (3) We can't use $(MAKEFILE_LIST) here, as in some situations it
43 ##     might cause the shell to die with "Arg list too long" (see
44 ##     automake bug#18744).
46 ## (4) We can't use $(MAKE_HOST) unconditionally, as it is only
47 ##     defined in GNU make 4.0 or later.
49 am__is_gnu_make = { \
50   if test -z '$(MAKELEVEL)'; then \
51     false; \
52   elif test -n '$(MAKE_HOST)'; then \
53     true; \
54   elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
55     true; \
56   else \
57     false; \
58   fi; \
61 ## Shell code that determines whether the current make instance is
62 ## running with a given one-letter option (e.g., -k, -n) that takes
63 ## no argument.
64 am__make_running_with_option = \
65   case $${target_option-} in \
66       ?) ;; \
67       *) echo "am__make_running_with_option: internal error: invalid" \
68               "target option '$${target_option-}' specified" >&2; \
69          exit 1;; \
70   esac; \
71   has_opt=no; \
72   sane_makeflags=$$MAKEFLAGS; \
73   if $(am__is_gnu_make); then \
74 ## The format of $(MAKEFLAGS) is quite tricky with GNU make; the
75 ## variable $(MFLAGS) behaves much better in that regard.  So use it.
76     sane_makeflags=$$MFLAGS; \
77   else \
78 ## Non-GNU make: we must rely on $(MAKEFLAGS).  This is tricker and more
79 ## brittle, but is the best we can do.
80     case $$MAKEFLAGS in \
81 ## If we run "make TESTS='snooze nap'", FreeBSD make will export MAKEFLAGS
82 ## to " TESTS=foo\ nap", so that the simpler loop below (on word-split
83 ## $$MAKEFLAGS) would see a "make flag" equal to "nap", and would wrongly
84 ## misinterpret that as and indication that make is running in dry mode.
85 ## This has already happened in practice.  So we need this hack.
86       *\\[\ \   ]*) \
87 ## Extra indirection with ${bs} required by FreeBSD 8.x make.
88 ## Not sure why (so sorry for the cargo-cult programming here).
89         bs=\\; \
90         sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
91           | sed "s/$$bs$$bs[$$bs $$bs   ]*//g"`;; \
92     esac; \
93   fi; \
94   skip_next=no; \
95   strip_trailopt () \
96   { \
97     flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
98   }; \
99   for flg in $$sane_makeflags; do \
100     test $$skip_next = yes && { skip_next=no; continue; }; \
101     case $$flg in \
102       *=*|--*) continue;; \
104 ## GNU make 4.0 has changed the format of $MFLAGS, and removed the space
105 ## between an option and its argument (e.g., from "-I dir" to "-Idir").
106 ## So we need to handle both formats, at least for options valid in GNU
107 ## make.  OTOH, BSD make formats $(MAKEFLAGS) by separating all options,
108 ## and separating any option from its argument, so things are easier
109 ## there.
111 ## For GNU make and BSD make.
112         -*I) strip_trailopt 'I'; skip_next=yes;; \
113       -*I?*) strip_trailopt 'I';; \
114 ## For GNU make >= 4.0.
115         -*O) strip_trailopt 'O'; skip_next=yes;; \
116       -*O?*) strip_trailopt 'O';; \
117 ## For GNU make (possibly overkill, this one).
118         -*l) strip_trailopt 'l'; skip_next=yes;; \
119       -*l?*) strip_trailopt 'l';; \
120 ## For BSD make.
121       -[dEDm]) skip_next=yes;; \
122 ## For NetBSD make.
123       -[JT]) skip_next=yes;; \
124     esac; \
125     case $$flg in \
126       *$$target_option*) has_opt=yes; break;; \
127     esac; \
128   done; \
129   test $$has_opt = yes
131 ## Shell code that determines whether make is running in "dry mode"
132 ## ("make -n") or not.  Useful in rules that invoke make recursively,
133 ## and are thus executed also with "make -n" -- either because they
134 ## are declared as dependencies to '.MAKE' (NetBSD make), or because
135 ## their recipes contain the "$(MAKE)" string (GNU and Solaris make).
136 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
138 ## Shell code that determines whether make is running in "keep-going mode"
139 ## ("make -k") or not.  Useful in rules that must recursively descend into
140 ## subdirectories, and decide whether to stop at the first error or not.
141 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
143 ## Helper to handle `rm -f` failing with no arguments.
144 am__rm_f = rm -f $(am__rm_f_notfound)
145 am__rm_rf = rm -rf $(am__rm_f_notfound)
147 ## Some derived variables that have been found to be useful.
148 pkgdatadir = $(datadir)/@PACKAGE@
149 pkgincludedir = $(includedir)/@PACKAGE@
150 pkglibdir = $(libdir)/@PACKAGE@
151 pkglibexecdir = $(libexecdir)/@PACKAGE@
153 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
154 install_sh_DATA = $(install_sh) -c -m 644
155 install_sh_PROGRAM = $(install_sh) -c
156 install_sh_SCRIPT = $(install_sh) -c
157 INSTALL_HEADER = $(INSTALL_DATA)
158 transform = $(program_transform_name)
160 ## These are defined because otherwise make on NetBSD V1.1 will print
161 ## (eg): $(NORMAL_INSTALL) expands to empty string.
162 NORMAL_INSTALL = :
163 PRE_INSTALL = :
164 POST_INSTALL = :
165 NORMAL_UNINSTALL = :
166 PRE_UNINSTALL = :
167 POST_UNINSTALL = :
169 ## dejagnu.am uses these variables.  Some users might rely on them too.
170 ?BUILD?build_triplet = @build@
171 ?HOST?host_triplet = @host@
172 ?TARGET?target_triplet = @target@