Makefile revision 1.59 1 1.41 christos # Make and install tzdb code and data.
2 1.1 mlelstv # This file is in the public domain, so clarified as of
3 1.1 mlelstv # 2009-05-17 by Arthur David Olson.
4 1.56 christos # Request POSIX conformance; this must be the first non-comment line.
5 1.56 christos .POSIX:
6 1.58 christos # On older platforms you may need to scrounge for POSIX conformance.
7 1.58 christos # For example, on Solaris 10 (2005) with Sun Studio 12 aka Sun C 5.9 (2007),
8 1.58 christos # use 'PATH=/usr/xpg4/bin:$PATH make CC=c99'.
9 1.56 christos
10 1.56 christos # To affect how this Makefile works, you can run a shell script like this:
11 1.56 christos #
12 1.56 christos # #!/bin/sh
13 1.58 christos # make CC='gcc -std=gnu23' "$@"
14 1.56 christos #
15 1.58 christos # This example script is appropriate for a circa 2024 GNU/Linux system
16 1.58 christos # where a non-default setting enables this package's optional use of C23.
17 1.56 christos #
18 1.56 christos # Alternatively, you can simply edit this Makefile to tailor the following
19 1.56 christos # macro definitions.
20 1.56 christos
21 1.56 christos ###############################################################################
22 1.56 christos # Start of macros that one plausibly might want to tailor.
23 1.1 mlelstv
24 1.10 christos # Package name for the code distribution.
25 1.10 christos PACKAGE= tzcode
26 1.10 christos
27 1.34 christos # Version number for the distribution, overridden in the 'tarballs' rule below.
28 1.35 christos VERSION= unknown
29 1.9 christos
30 1.9 christos # Email address for bug reports.
31 1.9 christos BUGEMAIL= tz@iana.org
32 1.6 christos
33 1.43 christos # DATAFORM selects the data format.
34 1.43 christos # Available formats represent essentially the same data, albeit
35 1.43 christos # possibly with minor discrepancies that users are not likely to notice.
36 1.43 christos # To get new features and the best data right away, use:
37 1.40 christos # DATAFORM= vanguard
38 1.40 christos # To wait a while before using new features, to give downstream users
39 1.40 christos # time to upgrade zic (the default), use:
40 1.40 christos # DATAFORM= main
41 1.40 christos # To wait even longer for new features, use:
42 1.40 christos # DATAFORM= rearguard
43 1.46 christos # Rearguard users might also want "ZFLAGS = -b fat"; see below.
44 1.40 christos DATAFORM= main
45 1.40 christos
46 1.41 christos # Change the line below for your timezone (after finding the one you want in
47 1.41 christos # one of the $(TDATA) source files, or adding it to a source file).
48 1.41 christos # Alternatively, if you discover you've got the wrong timezone, you can just
49 1.46 christos # 'zic -l -' to remove it, or 'zic -l rightzone' to change it.
50 1.1 mlelstv # Use the command
51 1.1 mlelstv # make zonenames
52 1.1 mlelstv # to get a list of the values you can use for LOCALTIME.
53 1.1 mlelstv
54 1.51 christos LOCALTIME= Factory
55 1.1 mlelstv
56 1.58 christos # The POSIXRULES macro controls interpretation of POSIX-like TZ
57 1.55 christos # settings like TZ='EET-2EEST' that lack DST transition rules.
58 1.46 christos # If POSIXRULES is '-', no template is installed; this is the default.
59 1.46 christos # Any other value for POSIXRULES is obsolete and should not be relied on, as:
60 1.44 christos # * It does not work correctly in popular implementations such as GNU/Linux.
61 1.49 christos # * It does not work even in tzcode, except for historical timestamps
62 1.49 christos # that precede the last explicit transition in the POSIXRULES file.
63 1.49 christos # Hence it typically does not work for current and future timestamps.
64 1.46 christos # If, despite the above, you want a template for handling these settings,
65 1.46 christos # you can change the line below (after finding the timezone you want in the
66 1.46 christos # one of the $(TDATA) source files, or adding it to a source file).
67 1.46 christos # Alternatively, if you discover you've got the wrong timezone, you can just
68 1.46 christos # 'zic -p -' to remove it, or 'zic -p rightzone' to change it.
69 1.46 christos # Use the command
70 1.46 christos # make zonenames
71 1.46 christos # to get a list of the values you can use for POSIXRULES.
72 1.1 mlelstv
73 1.46 christos POSIXRULES= -
74 1.1 mlelstv
75 1.1 mlelstv # Also see TZDEFRULESTRING below, which takes effect only
76 1.55 christos # if POSIXRULES is '-' or if the template file cannot be accessed.
77 1.1 mlelstv
78 1.1 mlelstv
79 1.39 christos # Installation locations.
80 1.39 christos #
81 1.39 christos # The defaults are suitable for Debian, except that if REDO is
82 1.39 christos # posix_right or right_posix then files that Debian puts under
83 1.39 christos # /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
84 1.39 christos # put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
85 1.39 christos # respectively. Problems with the Debian approach are discussed in
86 1.39 christos # the commentary for the right_posix rule (below).
87 1.39 christos
88 1.39 christos # Destination directory, which can be used for staging.
89 1.39 christos # 'make DESTDIR=/stage install' installs under /stage (e.g., to
90 1.39 christos # /stage/etc/localtime instead of to /etc/localtime). Files under
91 1.39 christos # /stage are not intended to work as-is, but can be copied by hand to
92 1.39 christos # the root directory later. If DESTDIR is empty, 'make install' does
93 1.39 christos # not stage, but installs directly into production locations.
94 1.39 christos DESTDIR =
95 1.39 christos
96 1.39 christos # Everything is installed into subdirectories of TOPDIR, and used there.
97 1.39 christos # TOPDIR should be empty (meaning the root directory),
98 1.39 christos # or a directory name that does not end in "/".
99 1.39 christos # TOPDIR should be empty or an absolute name unless you're just testing.
100 1.39 christos TOPDIR =
101 1.39 christos
102 1.41 christos # The default local timezone is taken from the file TZDEFAULT.
103 1.39 christos TZDEFAULT = $(TOPDIR)/etc/localtime
104 1.39 christos
105 1.39 christos # The subdirectory containing installed program and data files, and
106 1.39 christos # likewise for installed files that can be shared among architectures.
107 1.39 christos # These should be relative file names.
108 1.39 christos USRDIR = usr
109 1.39 christos USRSHAREDIR = $(USRDIR)/share
110 1.1 mlelstv
111 1.41 christos # "Compiled" timezone information is placed in the "TZDIR" directory
112 1.1 mlelstv # (and subdirectories).
113 1.38 christos # TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
114 1.15 christos TZDIR_BASENAME= zoneinfo
115 1.39 christos TZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
116 1.1 mlelstv
117 1.39 christos # The "tzselect" and (if you do "make INSTALL") "date" commands go in:
118 1.39 christos BINDIR = $(TOPDIR)/$(USRDIR)/bin
119 1.1 mlelstv
120 1.39 christos # The "zdump" command goes in:
121 1.39 christos ZDUMPDIR = $(BINDIR)
122 1.1 mlelstv
123 1.39 christos # The "zic" command goes in:
124 1.39 christos ZICDIR = $(TOPDIR)/$(USRDIR)/sbin
125 1.1 mlelstv
126 1.1 mlelstv # Manual pages go in subdirectories of. . .
127 1.39 christos MANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
128 1.1 mlelstv
129 1.39 christos # Library functions are put in an archive in LIBDIR.
130 1.39 christos LIBDIR = $(TOPDIR)/$(USRDIR)/lib
131 1.1 mlelstv
132 1.1 mlelstv
133 1.41 christos # Types to try, as an alternative to time_t.
134 1.41 christos TIME_T_ALTERNATIVES = $(TIME_T_ALTERNATIVES_HEAD) $(TIME_T_ALTERNATIVES_TAIL)
135 1.58 christos TIME_T_ALTERNATIVES_HEAD = int_least64_t.ck
136 1.58 christos TIME_T_ALTERNATIVES_TAIL = int_least32_t.ck uint_least32_t.ck \
137 1.58 christos uint_least64_t.ck
138 1.1 mlelstv
139 1.43 christos # What kind of TZif data files to generate. (TZif is the binary time
140 1.59 christos # zone data format that zic generates; see Internet RFC 9636.)
141 1.37 christos # If you want only POSIX time, with time values interpreted as
142 1.37 christos # seconds since the epoch (not counting leap seconds), use
143 1.1 mlelstv # REDO= posix_only
144 1.38 christos # below. If you want only "right" time, with values interpreted
145 1.37 christos # as seconds since the epoch (counting leap seconds), use
146 1.1 mlelstv # REDO= right_only
147 1.1 mlelstv # below. If you want both sets of data available, with leap seconds not
148 1.1 mlelstv # counted normally, use
149 1.1 mlelstv # REDO= posix_right
150 1.1 mlelstv # below. If you want both sets of data available, with leap seconds counted
151 1.1 mlelstv # normally, use
152 1.1 mlelstv # REDO= right_posix
153 1.32 christos # below. POSIX mandates that leap seconds not be counted; for compatibility
154 1.37 christos # with it, use "posix_only" or "posix_right". Use POSIX time on systems with
155 1.37 christos # leap smearing; this can work better than unsmeared "right" time with
156 1.37 christos # applications that are not leap second aware, and is closer to unsmeared
157 1.37 christos # "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
158 1.1 mlelstv
159 1.1 mlelstv REDO= posix_right
160 1.1 mlelstv
161 1.45 christos # Whether to put an "Expires" line in the leapseconds file.
162 1.45 christos # Use EXPIRES_LINE=1 to put the line in, 0 to omit it.
163 1.45 christos # The EXPIRES_LINE value matters only if REDO's value contains "right".
164 1.45 christos # If you change EXPIRES_LINE, remove the leapseconds file before running "make".
165 1.45 christos # zic's support for the Expires line was introduced in tzdb 2020a,
166 1.49 christos # and was modified in tzdb 2021b to generate version 4 TZif files.
167 1.49 christos # EXPIRES_LINE defaults to 0 for now so that the leapseconds file
168 1.49 christos # can be given to pre-2020a zic implementations and so that TZif files
169 1.49 christos # built by newer zic implementations can be read by pre-2021b libraries.
170 1.45 christos EXPIRES_LINE= 0
171 1.45 christos
172 1.41 christos # To install data in text form that has all the information of the TZif data,
173 1.38 christos # (optionally incorporating leap second information), use
174 1.38 christos # TZDATA_TEXT= tzdata.zi leapseconds
175 1.38 christos # To install text data without leap second information (e.g., because
176 1.38 christos # REDO='posix_only'), use
177 1.38 christos # TZDATA_TEXT= tzdata.zi
178 1.38 christos # To avoid installing text data, use
179 1.38 christos # TZDATA_TEXT=
180 1.38 christos
181 1.38 christos TZDATA_TEXT= leapseconds tzdata.zi
182 1.38 christos
183 1.38 christos # For backward-compatibility links for old zone names, use
184 1.39 christos # BACKWARD= backward
185 1.38 christos # To omit these links, use
186 1.38 christos # BACKWARD=
187 1.38 christos
188 1.39 christos BACKWARD= backward
189 1.38 christos
190 1.51 christos # If you want out-of-scope and often-wrong data from the file 'backzone',
191 1.51 christos # but only for entries listed in the backward-compatibility file zone.tab, use
192 1.32 christos # PACKRATDATA= backzone
193 1.51 christos # PACKRATLIST= zone.tab
194 1.51 christos # If you want all the 'backzone' data, use
195 1.51 christos # PACKRATDATA= backzone
196 1.51 christos # PACKRATLIST=
197 1.32 christos # To omit this data, use
198 1.32 christos # PACKRATDATA=
199 1.51 christos # PACKRATLIST=
200 1.32 christos
201 1.32 christos PACKRATDATA=
202 1.51 christos PACKRATLIST=
203 1.32 christos
204 1.38 christos # The name of a locale using the UTF-8 encoding, used during self-tests.
205 1.38 christos # The tests are skipped if the name does not appear to work on this system.
206 1.38 christos
207 1.38 christos UTF8_LOCALE= en_US.utf8
208 1.38 christos
209 1.1 mlelstv # Non-default libraries needed to link.
210 1.54 christos # On some hosts, this should have -lintl unless CFLAGS has -DHAVE_GETTEXT=0.
211 1.1 mlelstv LDLIBS=
212 1.1 mlelstv
213 1.56 christos # Add the following to an uncommented "CFLAGS=" line as needed
214 1.56 christos # to override defaults specified in the source code or by the system.
215 1.56 christos # "-DFOO" is equivalent to "-DFOO=1".
216 1.38 christos # -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
217 1.38 christos # formats that generate only the last two digits of year numbers
218 1.38 christos # -DEPOCH_LOCAL if the 'time' function returns local time not UT
219 1.38 christos # -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
220 1.38 christos # than what POSIX specifies, assuming local time is UT.
221 1.38 christos # For example, N is 252460800 on AmigaOS.
222 1.32 christos # -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
223 1.58 christos # on POSIX platforms predating POSIX.1-2024
224 1.38 christos # -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
225 1.54 christos # -DHAVE_DECL_TIMEGM=0 if <time.h> does not declare timegm
226 1.32 christos # -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
227 1.55 christos # -DHAVE__GENERIC=0 if _Generic does not work*
228 1.54 christos # -DHAVE_GETRANDOM if getrandom works (e.g., GNU/Linux),
229 1.54 christos # -DHAVE_GETRANDOM=0 to avoid using getrandom
230 1.54 christos # -DHAVE_GETTEXT if gettext works (e.g., GNU/Linux, FreeBSD, Solaris),
231 1.54 christos # where LDLIBS also needs to contain -lintl on some hosts;
232 1.54 christos # -DHAVE_GETTEXT=0 to avoid using gettext
233 1.38 christos # -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
234 1.58 christos # ctime_r and asctime_r incompatibly with POSIX.1-2017 and earlier
235 1.35 christos # (Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
236 1.55 christos # -DHAVE_INTTYPES_H=0 if <inttypes.h> does not work*+
237 1.16 christos # -DHAVE_LINK=0 if your system lacks a link function
238 1.23 christos # -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
239 1.23 christos # -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
240 1.23 christos # localtime_rz can make zdump significantly faster, but is nonstandard.
241 1.49 christos # -DHAVE_MALLOC_ERRNO=0 if malloc etc. do not set errno on failure.
242 1.32 christos # -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
243 1.32 christos # functions like 'link' or variables like 'tzname' required by POSIX
244 1.53 christos # -DHAVE_SETENV=0 if your system lacks the setenv function
245 1.55 christos # -DHAVE_SNPRINTF=0 if your system lacks the snprintf function+
246 1.54 christos # -DHAVE_STDCKDINT_H=0 if neither <stdckdint.h> nor substitutes like
247 1.54 christos # __builtin_add_overflow work*
248 1.55 christos # -DHAVE_STDINT_H=0 if <stdint.h> does not work*+
249 1.38 christos # -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
250 1.28 christos # -DHAVE_STRDUP=0 if your system lacks the strdup function
251 1.55 christos # -DHAVE_STRTOLL=0 if your system lacks the strtoll function+
252 1.1 mlelstv # -DHAVE_SYMLINK=0 if your system lacks the symlink function
253 1.54 christos # -DHAVE_SYS_STAT_H=0 if <sys/stat.h> does not work*
254 1.23 christos # -DHAVE_TZSET=0 if your system lacks a tzset function
255 1.54 christos # -DHAVE_UNISTD_H=0 if <unistd.h> does not work*
256 1.54 christos # -DHAVE_UTMPX_H=0 if <utmpx.h> does not work*
257 1.38 christos # -Dlocale_t=XXX if your system uses XXX instead of locale_t
258 1.59 christos # -DMKTIME_MIGHT_OVERFLOW if mktime might fail due to time_t overflow
259 1.56 christos # -DPORT_TO_C89 if tzcode should also run on mostly-C89 platforms+
260 1.56 christos # Typically it is better to use a later standard. For example,
261 1.56 christos # with GCC 4.9.4 (2016), prefer '-std=gnu11' to '-DPORT_TO_C89'.
262 1.56 christos # Even with -DPORT_TO_C89, the code needs at least one C99
263 1.56 christos # feature (integers at least 64 bits wide) and maybe more.
264 1.40 christos # -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
265 1.40 christos # with external linkage, e.g., applications cannot define 'localtime'.
266 1.59 christos # -Dssize_t=int on hosts like MS-Windows that lack ssize_t
267 1.58 christos # -DSUPPORT_C89=0 if the tzcode library should not support C89 callers
268 1.58 christos # Although -DSUPPORT_C89=0 might work around latent bugs in callers,
269 1.58 christos # it does not conform to POSIX.
270 1.58 christos # -DSUPPORT_POSIX2008 if the library should support older POSIX callers+
271 1.58 christos # However, this might cause problems in POSIX.1-2024-or-later callers.
272 1.40 christos # -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
273 1.40 christos # security implications and is not recommended for general use
274 1.38 christos # -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
275 1.23 christos # not needed by the main-program tz code, which is single-threaded.
276 1.23 christos # Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
277 1.14 christos # -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
278 1.38 christos # This is intended for internal use only; it mangles external names.
279 1.1 mlelstv # -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
280 1.22 christos # -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
281 1.1 mlelstv # the default is system-supplied, typically "/usr/lib/locale"
282 1.14 christos # -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
283 1.58 christos # DST transitions for proleptic format TZ strings lacking them,
284 1.55 christos # in the usual case where POSIXRULES is '-'. If not specified,
285 1.55 christos # TZDEFRULESTRING defaults to US rules for future DST transitions.
286 1.55 christos # This mishandles some past timestamps, as US DST rules have changed.
287 1.55 christos # It also mishandles settings like TZ='EET-2EEST' for eastern Europe,
288 1.55 christos # as Europe and US DST rules differ.
289 1.59 christos # -DTZNAME_MAXIMUM=N to limit time zone abbreviations to N bytes (default 254)
290 1.38 christos # -DUNINIT_TRAP if reading uninitialized storage can cause problems
291 1.23 christos # other than simply getting garbage data
292 1.23 christos # -DUSE_LTZ=0 to build zdump with the system time zone library
293 1.23 christos # Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
294 1.46 christos # -DZIC_BLOAT_DEFAULT=\"fat\" to default zic's -b option to "fat", and
295 1.46 christos # similarly for "slim". Fat TZif files work around incompatibilities
296 1.53 christos # and bugs in some TZif readers, notably older ones that
297 1.53 christos # ignore or otherwise mishandle 64-bit data in TZif files;
298 1.53 christos # however, fat TZif files may trigger bugs in newer TZif readers.
299 1.53 christos # Slim TZif files are more efficient, and are the default.
300 1.1 mlelstv # -DZIC_MAX_ABBR_LEN_WO_WARN=3
301 1.1 mlelstv # (or some other number) to set the maximum time zone abbreviation length
302 1.1 mlelstv # that zic will accept without a warning (the default is 6)
303 1.56 christos # -g to generate symbolic debugging info
304 1.56 christos # -Idir to include from directory 'dir'
305 1.56 christos # -O0 to disable optimization; other -O options to enable more optimization
306 1.56 christos # -Uname to remove any definition of the macro 'name'
307 1.30 christos # $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
308 1.53 christos #
309 1.53 christos # * Options marked "*" can be omitted if your compiler is C23 compatible.
310 1.55 christos # * Options marked "+" are obsolescent and are planned to be removed
311 1.58 christos # once the code assumes C99 or later (say in the year 2029)
312 1.58 christos # and POSIX.1-2024 or later (say in the year 2034).
313 1.53 christos #
314 1.38 christos # Select instrumentation via "make GCC_INSTRUMENT='whatever'".
315 1.38 christos GCC_INSTRUMENT = \
316 1.38 christos -fsanitize=undefined -fsanitize-address-use-after-scope \
317 1.38 christos -fsanitize-undefined-trap-on-error -fstack-protector
318 1.49 christos # Omit -fanalyzer from GCC_DEBUG_FLAGS, as it makes GCC too slow.
319 1.58 christos GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 \
320 1.38 christos $(GCC_INSTRUMENT) \
321 1.38 christos -Wall -Wextra \
322 1.38 christos -Walloc-size-larger-than=100000 -Warray-bounds=2 \
323 1.59 christos -Wbad-function-cast -Wbidi-chars=any,ucn -Wcast-align=strict -Wcast-qual \
324 1.59 christos -Wdate-time \
325 1.38 christos -Wdeclaration-after-statement -Wdouble-promotion \
326 1.58 christos -Wduplicated-branches -Wduplicated-cond -Wflex-array-member-not-at-end \
327 1.38 christos -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
328 1.54 christos -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op \
329 1.58 christos -Wmissing-declarations -Wmissing-prototypes \
330 1.58 christos -Wmissing-variable-declarations -Wnested-externs \
331 1.49 christos -Wnull-dereference \
332 1.38 christos -Wold-style-definition -Woverlength-strings -Wpointer-arith \
333 1.49 christos -Wshadow -Wshift-overflow=2 -Wstrict-overflow \
334 1.49 christos -Wstrict-prototypes -Wstringop-overflow=4 \
335 1.40 christos -Wstringop-truncation -Wsuggest-attribute=cold \
336 1.38 christos -Wsuggest-attribute=const -Wsuggest-attribute=format \
337 1.40 christos -Wsuggest-attribute=malloc \
338 1.38 christos -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
339 1.58 christos -Wtrampolines -Wundef -Wunused-macros -Wuse-after-free=3 \
340 1.38 christos -Wvariadic-macros -Wvla -Wwrite-strings \
341 1.59 christos -Wno-format-nonliteral -Wno-sign-compare -Wno-type-limits
342 1.1 mlelstv #
343 1.1 mlelstv # If your system has a "GMT offset" field in its "struct tm"s
344 1.1 mlelstv # (or if you decide to add such a field in your system's "time.h" file),
345 1.1 mlelstv # add the name to a define such as
346 1.1 mlelstv # -DTM_GMTOFF=tm_gmtoff
347 1.23 christos # to the end of the "CFLAGS=" line. If not defined, the code attempts to
348 1.23 christos # guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
349 1.23 christos # Similarly, if your system has a "zone abbreviation" field, define
350 1.1 mlelstv # -DTM_ZONE=tm_zone
351 1.57 christos # and define NO_TM_ZONE to suppress any guessing.
352 1.58 christos # Although POSIX.1-2024 requires these fields and they are widely available
353 1.58 christos # on GNU/Linux and BSD systems, some older systems lack them.
354 1.1 mlelstv #
355 1.38 christos # The next batch of options control support for external variables
356 1.38 christos # exported by tzcode. In practice these variables are less useful
357 1.38 christos # than TM_GMTOFF and TM_ZONE. However, most of them are standardized.
358 1.38 christos # #
359 1.38 christos # # To omit or support the external variable "tzname", add one of:
360 1.45 christos # # -DHAVE_TZNAME=0 # do not support "tzname"
361 1.45 christos # # -DHAVE_TZNAME=1 # support "tzname", which is defined by system library
362 1.45 christos # # -DHAVE_TZNAME=2 # support and define "tzname"
363 1.58 christos # # to the "CFLAGS=" line. Although "tzname" is required by POSIX.1-1988
364 1.58 christos # # and later, its contents are unspecified if you use a geographical TZ
365 1.58 christos # # and the variable is planned to be removed in a future POSIX edition.
366 1.38 christos # # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
367 1.38 christos # # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
368 1.38 christos # # crashes when combined with some platforms' standard libraries,
369 1.38 christos # # presumably due to memory allocation issues.
370 1.38 christos # #
371 1.38 christos # # To omit or support the external variables "timezone" and "daylight", add
372 1.45 christos # # -DUSG_COMPAT=0 # do not support
373 1.45 christos # # -DUSG_COMPAT=1 # support, and variables are defined by system library
374 1.45 christos # # -DUSG_COMPAT=2 # support and define variables
375 1.57 christos # # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by Unix
376 1.58 christos # # Systems Group code and are required by POSIX.1-2008 and later (with XSI),
377 1.58 christos # # although their contents are unspecified if you use a geographical TZ
378 1.58 christos # # and the variables are planned to be removed in a future edition of POSIX.
379 1.38 christos # # If not defined, the code attempts to guess USG_COMPAT from other macros.
380 1.38 christos # #
381 1.38 christos # # To support the external variable "altzone", add
382 1.45 christos # # -DALTZONE=0 # do not support
383 1.45 christos # # -DALTZONE=1 # support "altzone", which is defined by system library
384 1.45 christos # # -DALTZONE=2 # support and define "altzone"
385 1.38 christos # # to the end of the "CFLAGS=" line; although "altzone" appeared in
386 1.38 christos # # System V Release 3.1 it has not been standardized.
387 1.45 christos # # If not defined, the code attempts to guess ALTZONE from other macros.
388 1.38 christos #
389 1.1 mlelstv # If you want functions that were inspired by early versions of X3J11's work,
390 1.1 mlelstv # add
391 1.1 mlelstv # -DSTD_INSPIRED
392 1.54 christos # to the end of the "CFLAGS=" line. This arranges for the following
393 1.54 christos # functions to be added to the time conversion library.
394 1.1 mlelstv # "offtime" is like "gmtime" except that it accepts a second (long) argument
395 1.1 mlelstv # that gives an offset to add to the time_t when converting it.
396 1.56 christos # I.e., "offtime" is like calling "localtime_rz" with a fixed-offset zone.
397 1.56 christos # "timelocal" is nearly equivalent to "mktime".
398 1.1 mlelstv # "timeoff" is like "timegm" except that it accepts a second (long) argument
399 1.1 mlelstv # that gives an offset to use when converting to a time_t.
400 1.56 christos # I.e., "timeoff" is like calling "mktime_z" with a fixed-offset zone.
401 1.1 mlelstv # "posix2time" and "time2posix" are described in an included manual page.
402 1.1 mlelstv # X3J11's work does not describe any of these functions.
403 1.1 mlelstv # These functions may well disappear in future releases of the time
404 1.1 mlelstv # conversion package.
405 1.1 mlelstv #
406 1.23 christos # If you don't want functions that were inspired by NetBSD, add
407 1.23 christos # -DNETBSD_INSPIRED=0
408 1.23 christos # to the end of the "CFLAGS=" line. Otherwise, the functions
409 1.23 christos # "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
410 1.55 christos # time library, and if STD_INSPIRED is also defined to nonzero the functions
411 1.23 christos # "posix2time_z" and "time2posix_z" are added as well.
412 1.23 christos # The functions ending in "_z" (or "_rz") are like their unsuffixed
413 1.23 christos # (or suffixed-by-"_r") counterparts, except with an extra first
414 1.41 christos # argument of opaque type timezone_t that specifies the timezone.
415 1.23 christos # "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
416 1.23 christos #
417 1.1 mlelstv # If you want to allocate state structures in localtime, add
418 1.1 mlelstv # -DALL_STATE
419 1.1 mlelstv # to the end of the "CFLAGS=" line. Storage is obtained by calling malloc.
420 1.1 mlelstv #
421 1.1 mlelstv # NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
422 1.1 mlelstv # out by the National Institute of Standards and Technology
423 1.56 christos # which claims to test C and POSIX conformance. If you want to pass PCTS, add
424 1.1 mlelstv # -DPCTS
425 1.1 mlelstv # to the end of the "CFLAGS=" line.
426 1.1 mlelstv #
427 1.1 mlelstv # If you want strict compliance with XPG4 as of 1994-04-09, add
428 1.1 mlelstv # -DXPG4_1994_04_09
429 1.1 mlelstv # to the end of the "CFLAGS=" line. This causes "strftime" to always return
430 1.38 christos # 53 as a week number (rather than 52 or 53) for January days before
431 1.38 christos # January's first Monday when a "%V" format is used and January 1
432 1.1 mlelstv # falls on a Friday, Saturday, or Sunday.
433 1.56 christos #
434 1.56 christos # POSIX says CFLAGS defaults to "-O 1".
435 1.56 christos # Uncomment the following line and edit its contents as needed.
436 1.1 mlelstv
437 1.56 christos #CFLAGS= -O 1
438 1.1 mlelstv
439 1.9 christos
440 1.56 christos # The name of a POSIX-like library archiver, its flags, C compiler,
441 1.56 christos # linker flags, and 'make' utility. Ordinarily the defaults suffice.
442 1.58 christos # The commented-out values are the defaults specified by POSIX.1-2024.
443 1.56 christos #AR = ar
444 1.56 christos #ARFLAGS = -rv
445 1.56 christos #CC = c17
446 1.56 christos #LDFLAGS =
447 1.56 christos #MAKE = make
448 1.1 mlelstv
449 1.57 christos # Where to fetch leap-seconds.list from.
450 1.57 christos leaplist_URI = \
451 1.57 christos https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list
452 1.57 christos # The file is generated by the IERS Earth Orientation Centre, in Paris.
453 1.57 christos leaplist_TZ = Europe/Paris
454 1.57 christos
455 1.32 christos # The zic command and its arguments.
456 1.32 christos
457 1.1 mlelstv zic= ./zic
458 1.1 mlelstv ZIC= $(zic) $(ZFLAGS)
459 1.1 mlelstv
460 1.43 christos # To shrink the size of installed TZif files,
461 1.43 christos # append "-r @N" to omit data before N-seconds-after-the-Epoch.
462 1.53 christos # To grow the files and work around bugs in older applications,
463 1.53 christos # possibly at the expense of introducing bugs in newer ones,
464 1.53 christos # append "-b fat"; see ZIC_BLOAT_DEFAULT above.
465 1.44 christos # See the zic man page for more about -b and -r.
466 1.15 christos ZFLAGS=
467 1.15 christos
468 1.41 christos # How to use zic to install TZif files.
469 1.32 christos
470 1.58 christos ZIC_INSTALL= $(ZIC) -d '$(DESTDIR)$(TZDIR)'
471 1.32 christos
472 1.56 christos # The name of a POSIX-compliant 'awk' on your system.
473 1.50 christos # mawk 1.3.3 and Solaris 10 /usr/bin/awk do not work.
474 1.50 christos # Also, it is better (though not essential) if 'awk' supports UTF-8,
475 1.50 christos # and unfortunately mawk and busybox awk do not support UTF-8.
476 1.50 christos # Try AWK=gawk or AWK=nawk if your awk has the abovementioned problems.
477 1.9 christos AWK= awk
478 1.9 christos
479 1.56 christos # The full path name of a POSIX-compliant shell, preferably one that supports
480 1.16 christos # the Korn shell's 'select' statement as an extension.
481 1.16 christos # These days, Bash is the most popular.
482 1.16 christos # It should be OK to set this to /bin/sh, on platforms where /bin/sh
483 1.56 christos # lacks 'select' or doesn't completely conform to POSIX, but /bin/bash
484 1.16 christos # is typically nicer if it works.
485 1.9 christos KSHELL= /bin/bash
486 1.1 mlelstv
487 1.57 christos # Name of curl <https://curl.haxx.se/>, used for HTML validation
488 1.57 christos # and to fetch leap-seconds.list from upstream.
489 1.58 christos # Set CURL=: to disable use of the Internet.
490 1.42 christos CURL= curl
491 1.42 christos
492 1.44 christos # Name of GNU Privacy Guard <https://gnupg.org/>, used to sign distributions.
493 1.44 christos GPG= gpg
494 1.44 christos
495 1.23 christos # This expensive test requires USE_LTZ.
496 1.23 christos # To suppress it, define this macro to be empty.
497 1.23 christos CHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
498 1.23 christos
499 1.22 christos # SAFE_CHAR is a regular expression that matches a safe character.
500 1.22 christos # Some parts of this distribution are limited to safe characters;
501 1.22 christos # others can use any UTF-8 character.
502 1.22 christos # For now, the safe characters are a safe subset of ASCII.
503 1.9 christos # The caller must set the shell variable 'sharp' to the character '#',
504 1.9 christos # since Makefile macros cannot contain '#'.
505 1.9 christos # TAB_CHAR is a single tab character, in single quotes.
506 1.9 christos TAB_CHAR= ' '
507 1.22 christos SAFE_CHARSET1= $(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
508 1.22 christos SAFE_CHARSET2= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
509 1.22 christos SAFE_CHARSET3= 'abcdefghijklmnopqrstuvwxyz{|}~'
510 1.29 christos SAFE_CHARSET= $(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
511 1.29 christos SAFE_CHAR= '[]'$(SAFE_CHARSET)'-]'
512 1.29 christos
513 1.55 christos # These non-alphabetic, non-ASCII printable characters are Latin-1,
514 1.55 christos # and so are likely displayable even in editors like XEmacs 21
515 1.55 christos # that have limited display capabilities.
516 1.55 christos UNUSUAL_OK_LATIN_1 =
517 1.40 christos # Non-ASCII non-letters that OK_CHAR allows, as these characters are
518 1.41 christos # useful in commentary.
519 1.55 christos UNUSUAL_OK_CHARSET= $(UNUSUAL_OK_LATIN_1)
520 1.40 christos
521 1.51 christos # Put this in a bracket expression to match spaces.
522 1.51 christos s = [:space:]
523 1.51 christos
524 1.29 christos # OK_CHAR matches any character allowed in the distributed files.
525 1.40 christos # This is the same as SAFE_CHAR, except that UNUSUAL_OK_CHARSET and
526 1.40 christos # multibyte letters are also allowed so that commentary can contain a
527 1.40 christos # few safe symbols and people's names and can quote non-English sources.
528 1.40 christos # Other non-letters are limited to ASCII renderings for the
529 1.40 christos # convenience of maintainers using XEmacs 21.5.34, which by default
530 1.40 christos # mishandles Unicode characters U+0100 and greater.
531 1.40 christos OK_CHAR= '[][:alpha:]$(UNUSUAL_OK_CHARSET)'$(SAFE_CHARSET)'-]'
532 1.22 christos
533 1.22 christos # SAFE_LINE matches a line of safe characters.
534 1.29 christos # SAFE_SHARP_LINE is similar, except any OK character can follow '#';
535 1.22 christos # this is so that comments can contain non-ASCII characters.
536 1.29 christos # OK_LINE matches a line of OK characters.
537 1.22 christos SAFE_LINE= '^'$(SAFE_CHAR)'*$$'
538 1.29 christos SAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
539 1.29 christos OK_LINE= '^'$(OK_CHAR)'*$$'
540 1.9 christos
541 1.6 christos # Flags to give 'tar' when making a distribution.
542 1.6 christos # Try to use flags appropriate for GNU tar.
543 1.58 christos GNUTARFLAGS= --format=pax --pax-option=delete=atime,delete=ctime \
544 1.50 christos --numeric-owner --owner=0 --group=0 \
545 1.50 christos --mode=go+u,go-w --sort=name
546 1.58 christos SETUP_TAR= \
547 1.58 christos export LC_ALL=C && \
548 1.58 christos if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; then \
549 1.58 christos TAR='tar $(GNUTARFLAGS)'; \
550 1.58 christos else \
551 1.58 christos TAR=tar; \
552 1.58 christos fi
553 1.6 christos
554 1.6 christos # Flags to give 'gzip' when making a distribution.
555 1.38 christos GZIPFLAGS= -9n
556 1.6 christos
557 1.54 christos # When comparing .tzs files, use GNU diff's -F'^TZ=' option if supported.
558 1.54 christos # This makes it easier to see which Zone has been affected.
559 1.58 christos SETUP_DIFF_TZS = \
560 1.58 christos if diff -u -F'^TZ=' - - <>/dev/null >&0 2>&1; then \
561 1.58 christos DIFF_TZS='diff -u -F^TZ='; \
562 1.58 christos else \
563 1.58 christos DIFF_TZS='diff -u'; \
564 1.58 christos fi
565 1.54 christos
566 1.56 christos # ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
567 1.56 christos RANLIB= :
568 1.1 mlelstv
569 1.56 christos # POSIX prohibits defining or using SHELL. However, csh users on systems
570 1.56 christos # that use the user shell for Makefile commands may need to define SHELL.
571 1.56 christos #SHELL= /bin/sh
572 1.29 christos
573 1.56 christos # End of macros that one plausibly might want to tailor.
574 1.56 christos ###############################################################################
575 1.1 mlelstv
576 1.16 christos
577 1.28 christos TZCOBJS= zic.o
578 1.58 christos TZDOBJS= zdump.o localtime.o strftime.o
579 1.58 christos DATEOBJS= date.o localtime.o strftime.o
580 1.45 christos LIBSRCS= localtime.c asctime.c difftime.c strftime.c
581 1.45 christos LIBOBJS= localtime.o asctime.o difftime.o strftime.o
582 1.1 mlelstv HEADERS= tzfile.h private.h
583 1.28 christos NONLIBSRCS= zic.c zdump.c
584 1.45 christos NEWUCBSRCS= date.c
585 1.23 christos SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
586 1.35 christos tzselect.ksh workman.sh
587 1.1 mlelstv MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
588 1.1 mlelstv tzfile.5 tzselect.8 zic.8 zdump.8
589 1.16 christos MANTXTS= newctime.3.txt newstrftime.3.txt newtzset.3.txt \
590 1.16 christos time2posix.3.txt \
591 1.16 christos tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
592 1.16 christos date.1.txt
593 1.38 christos COMMON= calendars CONTRIBUTING LICENSE Makefile \
594 1.49 christos NEWS README SECURITY theory.html version
595 1.39 christos WEB_PAGES= tz-art.html tz-how-to.html tz-link.html
596 1.58 christos CHECK_WEB_PAGES=theory.ck tz-art.ck tz-how-to.ck tz-link.ck
597 1.23 christos DOCS= $(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
598 1.1 mlelstv PRIMARY_YDATA= africa antarctica asia australasia \
599 1.1 mlelstv europe northamerica southamerica
600 1.39 christos YDATA= $(PRIMARY_YDATA) etcetera
601 1.46 christos NDATA= factory
602 1.46 christos TDATA_TO_CHECK= $(YDATA) $(NDATA) backward
603 1.39 christos TDATA= $(YDATA) $(NDATA) $(BACKWARD)
604 1.56 christos ZONETABLES= zone.tab zone1970.tab zonenow.tab
605 1.38 christos TABDATA= iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
606 1.16 christos LEAP_DEPS= leapseconds.awk leap-seconds.list
607 1.51 christos TZDATA_ZI_DEPS= ziguard.awk zishrink.awk version $(TDATA) \
608 1.51 christos $(PACKRATDATA) $(PACKRATLIST)
609 1.51 christos DSTDATA_ZI_DEPS= ziguard.awk $(TDATA) $(PACKRATDATA) $(PACKRATLIST)
610 1.39 christos DATA= $(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
611 1.46 christos leapseconds $(ZONETABLES)
612 1.56 christos AWK_SCRIPTS= checklinks.awk checknow.awk checktab.awk leapseconds.awk \
613 1.40 christos ziguard.awk zishrink.awk
614 1.52 christos MISC= $(AWK_SCRIPTS)
615 1.34 christos TZS_YEAR= 2050
616 1.41 christos TZS_CUTOFF_FLAG= -c $(TZS_YEAR)
617 1.34 christos TZS= to$(TZS_YEAR).tzs
618 1.34 christos TZS_NEW= to$(TZS_YEAR)new.tzs
619 1.59 christos TZS_DEPS= $(YDATA) localtime.c private.h \
620 1.59 christos strftime.c tzfile.h zdump.c zic.c
621 1.51 christos TZDATA_DIST = $(COMMON) $(DATA) $(MISC)
622 1.41 christos # EIGHT_YARDS is just a yard short of the whole ENCHILADA.
623 1.51 christos EIGHT_YARDS = $(TZDATA_DIST) $(DOCS) $(SOURCES) tzdata.zi
624 1.41 christos ENCHILADA = $(EIGHT_YARDS) $(TZS)
625 1.34 christos
626 1.34 christos # Consult these files when deciding whether to rebuild the 'version' file.
627 1.34 christos # This list is not the same as the output of 'git ls-files', since
628 1.34 christos # .gitignore is not distributed.
629 1.34 christos VERSION_DEPS= \
630 1.49 christos calendars CONTRIBUTING LICENSE Makefile NEWS README SECURITY \
631 1.34 christos africa antarctica asctime.c asia australasia \
632 1.34 christos backward backzone \
633 1.56 christos checklinks.awk checknow.awk checktab.awk \
634 1.34 christos date.1 date.c difftime.c \
635 1.34 christos etcetera europe factory iso3166.tab \
636 1.34 christos leap-seconds.list leapseconds.awk localtime.c \
637 1.34 christos newctime.3 newstrftime.3 newtzset.3 northamerica \
638 1.46 christos private.h southamerica strftime.c theory.html \
639 1.39 christos time2posix.3 tz-art.html tz-how-to.html tz-link.html \
640 1.34 christos tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
641 1.46 christos workman.sh zdump.8 zdump.c zic.8 zic.c \
642 1.40 christos ziguard.awk zishrink.awk \
643 1.56 christos zone.tab zone1970.tab zonenow.tab
644 1.1 mlelstv
645 1.46 christos all: tzselect zic zdump libtz.a $(TABDATA) \
646 1.40 christos vanguard.zi main.zi rearguard.zi
647 1.1 mlelstv
648 1.29 christos ALL: all date $(ENCHILADA)
649 1.1 mlelstv
650 1.16 christos install: all $(DATA) $(REDO) $(MANS)
651 1.39 christos mkdir -p '$(DESTDIR)$(BINDIR)' \
652 1.39 christos '$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
653 1.39 christos '$(DESTDIR)$(LIBDIR)' \
654 1.39 christos '$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
655 1.39 christos '$(DESTDIR)$(MANDIR)/man8'
656 1.44 christos $(ZIC_INSTALL) -l $(LOCALTIME) \
657 1.58 christos -p $(POSIXRULES) \
658 1.39 christos -t '$(DESTDIR)$(TZDEFAULT)'
659 1.39 christos cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
660 1.39 christos cp tzselect '$(DESTDIR)$(BINDIR)/.'
661 1.39 christos cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
662 1.39 christos cp zic '$(DESTDIR)$(ZICDIR)/.'
663 1.39 christos cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
664 1.39 christos $(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
665 1.39 christos cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
666 1.39 christos cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
667 1.39 christos cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
668 1.1 mlelstv
669 1.1 mlelstv INSTALL: ALL install date.1
670 1.39 christos mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
671 1.39 christos cp date '$(DESTDIR)$(BINDIR)/.'
672 1.39 christos cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
673 1.1 mlelstv
674 1.48 christos # Calculate version number from git, if available.
675 1.48 christos # Otherwise, use $(VERSION) unless it is "unknown" and there is already
676 1.48 christos # a 'version' file, in which case reuse the existing 'version' contents
677 1.48 christos # and append "-dirty" if the contents do not already end in "-dirty".
678 1.34 christos version: $(VERSION_DEPS)
679 1.35 christos { (type git) >/dev/null 2>&1 && \
680 1.58 christos V=$$(git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
681 1.58 christos --abbrev=7 --dirty) || \
682 1.58 christos if test '$(VERSION)' = unknown && read -r V <$@; then \
683 1.58 christos V=$${V%-dirty}-dirty; \
684 1.48 christos else \
685 1.48 christos V='$(VERSION)'; \
686 1.48 christos fi; } && \
687 1.35 christos printf '%s\n' "$$V" >$@.out
688 1.35 christos mv $@.out $@
689 1.34 christos
690 1.51 christos # These files can be tailored by setting BACKWARD, PACKRATDATA, PACKRATLIST.
691 1.40 christos vanguard.zi main.zi rearguard.zi: $(DSTDATA_ZI_DEPS)
692 1.51 christos $(AWK) \
693 1.58 christos -v DATAFORM=$(@:.zi=) \
694 1.51 christos -v PACKRATDATA='$(PACKRATDATA)' \
695 1.51 christos -v PACKRATLIST='$(PACKRATLIST)' \
696 1.51 christos -f ziguard.awk \
697 1.40 christos $(TDATA) $(PACKRATDATA) >$@.out
698 1.40 christos mv $@.out $@
699 1.41 christos # This file has a version comment that attempts to capture any tailoring
700 1.51 christos # via BACKWARD, DATAFORM, PACKRATDATA, PACKRATLIST, and REDO.
701 1.41 christos tzdata.zi: $(DATAFORM).zi version zishrink.awk
702 1.58 christos read -r version <version && \
703 1.41 christos LC_ALL=C $(AWK) \
704 1.41 christos -v dataform='$(DATAFORM)' \
705 1.41 christos -v deps='$(DSTDATA_ZI_DEPS) zishrink.awk' \
706 1.41 christos -v redo='$(REDO)' \
707 1.41 christos -v version="$$version" \
708 1.41 christos -f zishrink.awk \
709 1.40 christos $(DATAFORM).zi >$@.out
710 1.38 christos mv $@.out $@
711 1.38 christos
712 1.56 christos tzdir.h:
713 1.56 christos printf '%s\n' >$@.out \
714 1.56 christos '#ifndef TZDEFAULT' \
715 1.56 christos '# define TZDEFAULT "$(TZDEFAULT)" /* default zone */' \
716 1.56 christos '#endif' \
717 1.56 christos '#ifndef TZDIR' \
718 1.56 christos '# define TZDIR "$(TZDIR)" /* TZif directory */' \
719 1.56 christos '#endif'
720 1.56 christos mv $@.out $@
721 1.56 christos
722 1.34 christos version.h: version
723 1.58 christos read -r VERSION <version && printf '%s\n' \
724 1.35 christos 'static char const PKGVERSION[]="($(PACKAGE)) ";' \
725 1.35 christos "static char const TZVERSION[]=\"$$VERSION\";" \
726 1.35 christos 'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
727 1.35 christos >$@.out
728 1.35 christos mv $@.out $@
729 1.6 christos
730 1.1 mlelstv zdump: $(TZDOBJS)
731 1.9 christos $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
732 1.1 mlelstv
733 1.32 christos zic: $(TZCOBJS)
734 1.9 christos $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
735 1.1 mlelstv
736 1.16 christos leapseconds: $(LEAP_DEPS)
737 1.45 christos $(AWK) -v EXPIRES_LINE=$(EXPIRES_LINE) \
738 1.45 christos -f leapseconds.awk leap-seconds.list >$@.out
739 1.35 christos mv $@.out $@
740 1.15 christos
741 1.57 christos # Awk script to extract a Git-style author from leap-seconds.list comments.
742 1.57 christos EXTRACT_AUTHOR = \
743 1.57 christos author_line { sub(/^.[[:space:]]*/, ""); \
744 1.57 christos sub(/:[[:space:]]*/, " <"); \
745 1.57 christos printf "%s>\n", $$0; \
746 1.57 christos success = 1; \
747 1.57 christos exit \
748 1.57 christos } \
749 1.57 christos /Questions or comments to:/ { author_line = 1 } \
750 1.57 christos END { exit !success }
751 1.57 christos
752 1.57 christos # Fetch leap-seconds.list from upstream.
753 1.57 christos fetch-leap-seconds.list:
754 1.57 christos $(CURL) -OR $(leaplist_URI)
755 1.57 christos
756 1.57 christos # Fetch leap-seconds.list from upstream and commit it to the local repository.
757 1.57 christos commit-leap-seconds.list: fetch-leap-seconds.list
758 1.57 christos author=$$($(AWK) '$(EXTRACT_AUTHOR)' leap-seconds.list) && \
759 1.57 christos date=$$(TZ=$(leaplist_TZ) stat -c%y leap-seconds.list) && \
760 1.57 christos git commit --author="$$author" --date="$$date" -m'make $@' \
761 1.57 christos leap-seconds.list
762 1.57 christos
763 1.58 christos # Arguments to pass to submakes.
764 1.32 christos # They can be overridden by later submake arguments.
765 1.32 christos INSTALLARGS = \
766 1.39 christos BACKWARD='$(BACKWARD)' \
767 1.39 christos DESTDIR='$(DESTDIR)' \
768 1.32 christos PACKRATDATA='$(PACKRATDATA)' \
769 1.51 christos PACKRATLIST='$(PACKRATLIST)' \
770 1.39 christos TZDEFAULT='$(TZDEFAULT)' \
771 1.39 christos TZDIR='$(TZDIR)' \
772 1.32 christos ZIC='$(ZIC)'
773 1.32 christos
774 1.46 christos INSTALL_DATA_DEPS = zic leapseconds tzdata.zi
775 1.41 christos
776 1.58 christos posix_only: $(INSTALL_DATA_DEPS)
777 1.38 christos $(ZIC_INSTALL) tzdata.zi
778 1.32 christos
779 1.41 christos right_only: $(INSTALL_DATA_DEPS)
780 1.58 christos $(ZIC_INSTALL) -L leapseconds tzdata.zi
781 1.1 mlelstv
782 1.1 mlelstv # In earlier versions of this makefile, the other two directories were
783 1.1 mlelstv # subdirectories of $(TZDIR). However, this led to configuration errors.
784 1.1 mlelstv # For example, with posix_right under the earlier scheme,
785 1.1 mlelstv # TZ='right/Australia/Adelaide' got you localtime with leap seconds,
786 1.1 mlelstv # but gmtime without leap seconds, which led to problems with applications
787 1.1 mlelstv # like sendmail that subtract gmtime from localtime.
788 1.1 mlelstv # Therefore, the other two directories are now siblings of $(TZDIR).
789 1.1 mlelstv # You must replace all of $(TZDIR) to switch from not using leap seconds
790 1.1 mlelstv # to using them, or vice versa.
791 1.32 christos right_posix: right_only
792 1.39 christos rm -fr '$(DESTDIR)$(TZDIR)-leaps'
793 1.39 christos ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
794 1.39 christos $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
795 1.39 christos $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
796 1.15 christos
797 1.32 christos posix_right: posix_only
798 1.39 christos rm -fr '$(DESTDIR)$(TZDIR)-posix'
799 1.39 christos ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
800 1.39 christos $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
801 1.39 christos $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
802 1.32 christos
803 1.1 mlelstv zones: $(REDO)
804 1.1 mlelstv
805 1.40 christos # dummy.zd is not a real file; it is mentioned here only so that the
806 1.40 christos # top-level 'make' does not have a syntax error.
807 1.40 christos ZDS = dummy.zd
808 1.40 christos # Rule used only by submakes invoked by the $(TZS_NEW) rule.
809 1.40 christos # It is separate so that GNU 'make -j' can run instances in parallel.
810 1.40 christos $(ZDS): zdump
811 1.58 christos ./zdump -i $(TZS_CUTOFF_FLAG) "$$PWD/$(@:.zd=)" >$@
812 1.40 christos
813 1.41 christos TZS_NEW_DEPS = tzdata.zi zdump zic
814 1.41 christos $(TZS_NEW): $(TZS_NEW_DEPS)
815 1.41 christos rm -fr tzs$(TZS_YEAR).dir
816 1.41 christos mkdir tzs$(TZS_YEAR).dir
817 1.41 christos $(zic) -d tzs$(TZS_YEAR).dir tzdata.zi
818 1.38 christos $(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
819 1.38 christos tzdata.zi | LC_ALL=C sort >$@.out
820 1.58 christos x=$$($(AWK) '/^Z/{print "tzs$(TZS_YEAR).dir/" $$2 ".zd"}' \
821 1.41 christos tzdata.zi \
822 1.58 christos | LC_ALL=C sort -t . -k 2,2) && \
823 1.41 christos set x $$x && \
824 1.40 christos shift && \
825 1.40 christos ZDS=$$* && \
826 1.58 christos $(MAKE) TZS_CUTOFF_FLAG="$(TZS_CUTOFF_FLAG)" \
827 1.41 christos ZDS="$$ZDS" $$ZDS && \
828 1.41 christos sed 's,^TZ=".*\.dir/,TZ=",' $$ZDS >>$@.out
829 1.41 christos rm -fr tzs$(TZS_YEAR).dir
830 1.40 christos mv $@.out $@
831 1.34 christos
832 1.58 christos # If $(TZS) exists but 'make tzs.ck' fails, a maintainer should inspect the
833 1.34 christos # failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
834 1.34 christos $(TZS):
835 1.41 christos touch $@
836 1.34 christos
837 1.34 christos force_tzs: $(TZS_NEW)
838 1.34 christos cp $(TZS_NEW) $(TZS)
839 1.34 christos
840 1.16 christos libtz.a: $(LIBOBJS)
841 1.37 christos rm -f $@
842 1.56 christos $(AR) $(ARFLAGS) $@ $(LIBOBJS)
843 1.16 christos $(RANLIB) $@
844 1.1 mlelstv
845 1.1 mlelstv date: $(DATEOBJS)
846 1.9 christos $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
847 1.1 mlelstv
848 1.34 christos tzselect: tzselect.ksh version
849 1.58 christos read -r VERSION <version && sed \
850 1.56 christos -e "s'#!/bin/bash'#!"'$(KSHELL)'\' \
851 1.56 christos -e s\''\(AWK\)=[^}]*'\''\1=\'\''$(AWK)\'\'\' \
852 1.56 christos -e s\''\(PKGVERSION\)=.*'\''\1=\'\''($(PACKAGE)) \'\'\' \
853 1.56 christos -e s\''\(REPORT_BUGS_TO\)=.*'\''\1=\'\''$(BUGEMAIL)\'\'\' \
854 1.56 christos -e s\''\(TZDIR\)=[^}]*'\''\1=\'\''$(TZDIR)\'\'\' \
855 1.56 christos -e s\''\(TZVERSION\)=.*'\''\1=\'"'$$VERSION\\''" \
856 1.56 christos <$@.ksh >$@.out
857 1.35 christos chmod +x $@.out
858 1.35 christos mv $@.out $@
859 1.1 mlelstv
860 1.59 christos check: check_mild back.ck now.ck
861 1.58 christos check_mild: check_web check_zishrink \
862 1.58 christos character-set.ck white-space.ck links.ck mainguard.ck \
863 1.59 christos name-lengths.ck slashed-abbrs.ck sorted.ck \
864 1.58 christos tables.ck ziguard.ck tzs.ck
865 1.9 christos
866 1.56 christos # True if UTF8_LOCALE does not work;
867 1.56 christos # otherwise, false but with LC_ALL set to $(UTF8_LOCALE).
868 1.56 christos UTF8_LOCALE_MISSING = \
869 1.56 christos { test ! '$(UTF8_LOCALE)' \
870 1.56 christos || ! printf 'A\304\200B\n' \
871 1.56 christos | LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 \
872 1.58 christos || { export LC_ALL='$(UTF8_LOCALE)'; false; }; }
873 1.56 christos
874 1.58 christos character-set.ck: $(ENCHILADA)
875 1.56 christos $(UTF8_LOCALE_MISSING) || { \
876 1.22 christos sharp='#' && \
877 1.35 christos ! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
878 1.35 christos $(MISC) $(SOURCES) $(WEB_PAGES) \
879 1.49 christos CONTRIBUTING LICENSE README SECURITY \
880 1.38 christos version tzdata.zi && \
881 1.41 christos ! grep -Env $(SAFE_LINE)'|^UNUSUAL_OK_'$(OK_CHAR)'*$$' \
882 1.40 christos Makefile && \
883 1.39 christos ! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
884 1.46 christos leapseconds zone.tab && \
885 1.38 christos ! grep -Env $(OK_LINE) $(ENCHILADA); \
886 1.38 christos }
887 1.41 christos touch $@
888 1.22 christos
889 1.58 christos white-space.ck: $(ENCHILADA)
890 1.56 christos $(UTF8_LOCALE_MISSING) || { \
891 1.58 christos enchilada='$(ENCHILADA)' && \
892 1.58 christos patfmt=' \t|[\f\r\v]' && pat=$$(printf "$$patfmt\\n") && \
893 1.56 christos ! grep -En "$$pat|[$s]\$$" \
894 1.58 christos $${enchilada%leap-seconds.list*} \
895 1.58 christos $${enchilada#*leap-seconds.list}; \
896 1.56 christos }
897 1.56 christos touch $@
898 1.23 christos
899 1.51 christos PRECEDES_FILE_NAME = ^(Zone|Link[$s]+[^$s]+)[$s]+
900 1.51 christos FILE_NAME_COMPONENT_TOO_LONG = $(PRECEDES_FILE_NAME)[^$s]*[^/$s]{15}
901 1.38 christos
902 1.58 christos name-lengths.ck: $(TDATA_TO_CHECK) backzone
903 1.58 christos :;! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
904 1.39 christos $(TDATA_TO_CHECK) backzone
905 1.41 christos touch $@
906 1.38 christos
907 1.58 christos mainguard.ck: main.zi
908 1.58 christos test '$(PACKRATLIST)' || \
909 1.58 christos cat $(TDATA) $(PACKRATDATA) | diff -u - main.zi
910 1.58 christos touch $@
911 1.58 christos
912 1.51 christos PRECEDES_STDOFF = ^(Zone[$s]+[^$s]+)?[$s]+
913 1.51 christos STDOFF = [-+]?[0-9:.]+
914 1.51 christos RULELESS_SAVE = (-|$(STDOFF)[sd]?)
915 1.51 christos RULELESS_SLASHED_ABBRS = \
916 1.51 christos $(PRECEDES_STDOFF)$(STDOFF)[$s]+$(RULELESS_SAVE)[$s]+[^$s]*/
917 1.51 christos
918 1.58 christos slashed-abbrs.ck: $(TDATA_TO_CHECK)
919 1.58 christos :;! grep -En '$(RULELESS_SLASHED_ABBRS)' $(TDATA_TO_CHECK)
920 1.51 christos touch $@
921 1.51 christos
922 1.23 christos CHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
923 1.23 christos
924 1.58 christos sorted.ck: backward backzone
925 1.54 christos $(AWK) '/^Link/ {printf "%.5d %s\n", g, $$3} !/./ {g++}' \
926 1.53 christos backward | LC_ALL=C sort -cu
927 1.58 christos $(AWK) '/^Zone.*\// {print $$2}' backzone | LC_ALL=C sort -cu
928 1.41 christos touch $@
929 1.23 christos
930 1.58 christos back.ck: checklinks.awk $(TDATA_TO_CHECK)
931 1.53 christos $(AWK) \
932 1.53 christos -v DATAFORM=$(DATAFORM) \
933 1.53 christos -v backcheck=backward \
934 1.53 christos -f checklinks.awk $(TDATA_TO_CHECK)
935 1.54 christos touch $@
936 1.54 christos
937 1.58 christos links.ck: checklinks.awk tzdata.zi
938 1.53 christos $(AWK) \
939 1.53 christos -v DATAFORM=$(DATAFORM) \
940 1.53 christos -f checklinks.awk tzdata.zi
941 1.41 christos touch $@
942 1.26 christos
943 1.56 christos # Check timestamps from now through 28 years from now, to make sure
944 1.56 christos # that zonenow.tab contains all sequences of planned timestamps,
945 1.56 christos # without any duplicate sequences. In theory this might require
946 1.58 christos # 2800+ years but that would take a long time to check.
947 1.58 christos CHECK_NOW_TIMESTAMP = $$(./date +%s)
948 1.56 christos CHECK_NOW_FUTURE_YEARS = 28
949 1.58 christos CHECK_NOW_FUTURE_SECS = $(CHECK_NOW_FUTURE_YEARS) * 366 * 24 * 60 * 60
950 1.58 christos now.ck: checknow.awk date tzdata.zi zdump zic zone1970.tab zonenow.tab
951 1.58 christos rm -fr $@d
952 1.58 christos mkdir $@d
953 1.58 christos ./zic -d $@d tzdata.zi
954 1.56 christos now=$(CHECK_NOW_TIMESTAMP) && \
955 1.58 christos future=$$(($(CHECK_NOW_FUTURE_SECS) + $$now)) && \
956 1.56 christos ./zdump -i -t $$now,$$future \
957 1.58 christos $$(find "$$PWD/$@d"/????*/ -type f) \
958 1.58 christos >$@d/zdump-now.tab && \
959 1.58 christos ./zdump -i -t 0,$$future \
960 1.58 christos $$(find "$$PWD/$@d" -name Etc -prune \
961 1.58 christos -o -type f ! -name '*.tab' -print) \
962 1.58 christos >$@d/zdump-1970.tab
963 1.56 christos $(AWK) \
964 1.58 christos -v zdump_table=$@d/zdump-now.tab \
965 1.56 christos -f checknow.awk zonenow.tab
966 1.58 christos $(AWK) \
967 1.58 christos 'BEGIN {print "-\t-\tUTC"} /^Zone/ {print "-\t-\t" $$2}' \
968 1.58 christos $(PRIMARY_YDATA) backward factory | \
969 1.58 christos $(AWK) \
970 1.58 christos -v zdump_table=$@d/zdump-1970.tab \
971 1.58 christos -f checknow.awk
972 1.58 christos rm -fr $@d
973 1.56 christos touch $@
974 1.56 christos
975 1.58 christos tables.ck: checktab.awk $(YDATA) backward zone.tab zone1970.tab
976 1.22 christos for tab in $(ZONETABLES); do \
977 1.49 christos test "$$tab" = zone.tab && links='$(BACKWARD)' || links=''; \
978 1.49 christos $(AWK) -f checktab.awk -v zone_table=$$tab $(YDATA) $$links \
979 1.22 christos || exit; \
980 1.22 christos done
981 1.41 christos touch $@
982 1.1 mlelstv
983 1.58 christos tzs.ck: $(TZS) $(TZS_NEW)
984 1.41 christos if test -s $(TZS); then \
985 1.58 christos $(SETUP_DIFF_TZS) && $$DIFF_TZS $(TZS) $(TZS_NEW); \
986 1.41 christos else \
987 1.41 christos cp $(TZS_NEW) $(TZS); \
988 1.41 christos fi
989 1.41 christos touch $@
990 1.34 christos
991 1.42 christos check_web: $(CHECK_WEB_PAGES)
992 1.58 christos .SUFFIXES: .ck .html
993 1.58 christos .html.ck:
994 1.58 christos { ! ($(CURL) --version) >/dev/null 2>&1 || \
995 1.58 christos $(CURL) -sS --url https://validator.w3.org/nu/ -F out=gnu \
996 1.58 christos -F file=@$<; } >$@.out && \
997 1.42 christos test ! -s $@.out || { cat $@.out; exit 1; }
998 1.42 christos mv $@.out $@
999 1.38 christos
1000 1.58 christos ziguard.ck: rearguard.zi vanguard.zi ziguard.awk
1001 1.51 christos $(AWK) -v DATAFORM=rearguard -f ziguard.awk vanguard.zi | \
1002 1.51 christos diff -u rearguard.zi -
1003 1.51 christos $(AWK) -v DATAFORM=vanguard -f ziguard.awk rearguard.zi | \
1004 1.51 christos diff -u vanguard.zi -
1005 1.51 christos touch $@
1006 1.51 christos
1007 1.40 christos # Check that zishrink.awk does not alter the data, and that ziguard.awk
1008 1.40 christos # preserves main-format data.
1009 1.58 christos check_zishrink: zishrink-posix.ck zishrink-right.ck
1010 1.58 christos zishrink-posix.ck zishrink-right.ck: \
1011 1.51 christos zic leapseconds $(PACKRATDATA) $(PACKRATLIST) \
1012 1.51 christos $(TDATA) $(DATAFORM).zi tzdata.zi
1013 1.58 christos rm -fr $@d t-$@d shrunk-$@d
1014 1.58 christos mkdir $@d t-$@d shrunk-$@d
1015 1.41 christos case $@ in \
1016 1.58 christos *right*) leap='-L leapseconds';; \
1017 1.41 christos *) leap=;; \
1018 1.41 christos esac && \
1019 1.58 christos $(ZIC) $$leap -d $@d $(DATAFORM).zi && \
1020 1.58 christos $(ZIC) $$leap -d shrunk-$@d tzdata.zi && \
1021 1.51 christos case $(DATAFORM),$(PACKRATLIST) in \
1022 1.51 christos main,) \
1023 1.58 christos $(ZIC) $$leap -d t-$@d $(TDATA) && \
1024 1.40 christos $(AWK) '/^Rule/' $(TDATA) | \
1025 1.58 christos $(ZIC) $$leap -d t-$@d - $(PACKRATDATA) && \
1026 1.58 christos diff -r $@d t-$@d;; \
1027 1.41 christos esac
1028 1.58 christos diff -r $@d shrunk-$@d
1029 1.58 christos rm -fr $@d t-$@d shrunk-$@d
1030 1.41 christos touch $@
1031 1.1 mlelstv
1032 1.14 christos clean_misc:
1033 1.58 christos rm -fr *.ckd *.dir
1034 1.58 christos rm -f *.ck *.core *.o *.out core core.* \
1035 1.56 christos date tzdir.h tzselect version.h zdump zic libtz.a
1036 1.14 christos clean: clean_misc
1037 1.58 christos rm -fr tzdb-*/
1038 1.43 christos rm -f *.zi $(TZS_NEW)
1039 1.1 mlelstv
1040 1.1 mlelstv maintainer-clean: clean
1041 1.1 mlelstv @echo 'This command is intended for maintainers to use; it'
1042 1.1 mlelstv @echo 'deletes files that may need special tools to rebuild.'
1043 1.34 christos rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
1044 1.1 mlelstv
1045 1.1 mlelstv names:
1046 1.1 mlelstv @echo $(ENCHILADA)
1047 1.1 mlelstv
1048 1.58 christos public: check public.ck $(CHECK_TIME_T_ALTERNATIVES) \
1049 1.16 christos tarballs signatures
1050 1.16 christos
1051 1.16 christos date.1.txt: date.1
1052 1.16 christos newctime.3.txt: newctime.3
1053 1.16 christos newstrftime.3.txt: newstrftime.3
1054 1.16 christos newtzset.3.txt: newtzset.3
1055 1.16 christos time2posix.3.txt: time2posix.3
1056 1.16 christos tzfile.5.txt: tzfile.5
1057 1.16 christos tzselect.8.txt: tzselect.8
1058 1.16 christos zdump.8.txt: zdump.8
1059 1.16 christos zic.8.txt: zic.8
1060 1.16 christos
1061 1.16 christos $(MANTXTS): workman.sh
1062 1.58 christos LC_ALL=C sh workman.sh $(@:.txt=) >$@.out
1063 1.35 christos mv $@.out $@
1064 1.9 christos
1065 1.48 christos # Set file timestamps deterministically if possible,
1066 1.48 christos # so that tarballs containing the timestamps are reproducible.
1067 1.48 christos #
1068 1.48 christos # '$(SET_TIMESTAMP_N) N DEST A B C ...' sets the timestamp of the
1069 1.48 christos # file DEST to the maximum of the timestamps of the files A B C ...,
1070 1.48 christos # plus N if GNU ls and touch are available.
1071 1.48 christos SET_TIMESTAMP_N = sh -c '\
1072 1.48 christos n=$$0 dest=$$1; shift; \
1073 1.56 christos <"$$dest" && \
1074 1.48 christos if test $$n != 0 && \
1075 1.58 christos lsout=$$(ls -nt --time-style="+%s" "$$@" 2>/dev/null); then \
1076 1.48 christos set x $$lsout && \
1077 1.58 christos timestamp=$$(($$7 + $$n)) && \
1078 1.56 christos echo "+ touch -md @$$timestamp $$dest" && \
1079 1.56 christos touch -md @$$timestamp "$$dest"; \
1080 1.56 christos else \
1081 1.58 christos newest=$$(ls -t "$$@" | sed 1q) && \
1082 1.56 christos echo "+ touch -mr $$newest $$dest" && \
1083 1.56 christos touch -mr "$$newest" "$$dest"; \
1084 1.56 christos fi'
1085 1.48 christos # If DEST depends on A B C ... in this Makefile, callers should use
1086 1.48 christos # $(SET_TIMESTAMP_DEP) DEST A B C ..., for the benefit of any
1087 1.48 christos # downstream 'make' that considers equal timestamps to be out of date.
1088 1.48 christos # POSIX allows this 'make' behavior, and HP-UX 'make' does it.
1089 1.48 christos # If all that matters is that the timestamp be reproducible
1090 1.48 christos # and plausible, use $(SET_TIMESTAMP).
1091 1.48 christos SET_TIMESTAMP = $(SET_TIMESTAMP_N) 0
1092 1.48 christos SET_TIMESTAMP_DEP = $(SET_TIMESTAMP_N) 1
1093 1.48 christos
1094 1.41 christos # Set the timestamps to those of the git repository, if available,
1095 1.6 christos # and if the files have not changed since then.
1096 1.48 christos # This uses GNU 'ls --time-style=+%s', which outputs the seconds count,
1097 1.48 christos # and GNU 'touch -d@N FILE', where N is the number of seconds since 1970.
1098 1.48 christos # If git or GNU is absent, don't bother to sync with git timestamps.
1099 1.16 christos # Also, set the timestamp of each prebuilt file like 'leapseconds'
1100 1.16 christos # to be the maximum of the files it depends on.
1101 1.41 christos set-timestamps.out: $(EIGHT_YARDS)
1102 1.16 christos rm -f $@
1103 1.35 christos if (type git) >/dev/null 2>&1 && \
1104 1.58 christos files=$$(git ls-files $(EIGHT_YARDS)) && \
1105 1.16 christos touch -md @1 test.out; then \
1106 1.16 christos rm -f test.out && \
1107 1.16 christos for file in $$files; do \
1108 1.59 christos if git diff --quiet HEAD $$file; then \
1109 1.58 christos time=$$(TZ=UTC0 git log -1 \
1110 1.56 christos --format='tformat:%cd' \
1111 1.56 christos --date='format:%Y-%m-%dT%H:%M:%SZ' \
1112 1.58 christos $$file) && \
1113 1.56 christos echo "+ touch -md $$time $$file" && \
1114 1.56 christos touch -md $$time $$file; \
1115 1.16 christos else \
1116 1.16 christos echo >&2 "$$file: warning: does not match repository"; \
1117 1.16 christos fi || exit; \
1118 1.16 christos done; \
1119 1.16 christos fi
1120 1.48 christos $(SET_TIMESTAMP_DEP) leapseconds $(LEAP_DEPS)
1121 1.58 christos for file in $(MANTXTS); do \
1122 1.58 christos $(SET_TIMESTAMP_DEP) $$file $${file%.txt} workman.sh || \
1123 1.16 christos exit; \
1124 1.6 christos done
1125 1.48 christos $(SET_TIMESTAMP_DEP) version $(VERSION_DEPS)
1126 1.48 christos $(SET_TIMESTAMP_DEP) tzdata.zi $(TZDATA_ZI_DEPS)
1127 1.41 christos touch $@
1128 1.41 christos set-tzs-timestamp.out: $(TZS)
1129 1.48 christos $(SET_TIMESTAMP_DEP) $(TZS) $(TZS_DEPS)
1130 1.16 christos touch $@
1131 1.6 christos
1132 1.1 mlelstv # The zics below ensure that each data file can stand on its own.
1133 1.1 mlelstv # We also do an all-files run to catch links to links.
1134 1.1 mlelstv
1135 1.58 christos public.ck: $(VERSION_DEPS)
1136 1.58 christos rm -fr $@d
1137 1.58 christos mkdir $@d
1138 1.58 christos ln $(VERSION_DEPS) $@d
1139 1.58 christos cd $@d \
1140 1.56 christos && $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' TZDIR='$(TZDIR)' ALL
1141 1.58 christos for i in $(TDATA_TO_CHECK) \
1142 1.58 christos tzdata.zi vanguard.zi main.zi rearguard.zi; \
1143 1.48 christos do \
1144 1.58 christos $@d/zic -v -d $@d/zoneinfo $@d/$$i || exit; \
1145 1.9 christos done
1146 1.58 christos $@d/zic -v -d $@d/zoneinfo-all $(TDATA_TO_CHECK)
1147 1.49 christos :
1148 1.49 christos : Also check 'backzone' syntax.
1149 1.58 christos rm $@d/main.zi
1150 1.58 christos cd $@d && $(MAKE) PACKRATDATA=backzone main.zi
1151 1.58 christos $@d/zic -d $@d/zoneinfo main.zi
1152 1.58 christos rm $@d/main.zi
1153 1.58 christos cd $@d && \
1154 1.51 christos $(MAKE) PACKRATDATA=backzone PACKRATLIST=zone.tab main.zi
1155 1.58 christos $@d/zic -d $@d/zoneinfo main.zi
1156 1.49 christos :
1157 1.58 christos rm -fr $@d
1158 1.41 christos touch $@
1159 1.9 christos
1160 1.14 christos # Check that the code works under various alternative
1161 1.14 christos # implementations of time_t.
1162 1.41 christos check_time_t_alternatives: $(TIME_T_ALTERNATIVES)
1163 1.41 christos $(TIME_T_ALTERNATIVES_TAIL): $(TIME_T_ALTERNATIVES_HEAD)
1164 1.41 christos $(TIME_T_ALTERNATIVES): $(VERSION_DEPS)
1165 1.58 christos rm -fr $@d
1166 1.58 christos mkdir $@d
1167 1.58 christos ln $(VERSION_DEPS) $@d
1168 1.41 christos case $@ in \
1169 1.58 christos *32_t*) range=-2147483648,2147483648;; \
1170 1.41 christos u*) range=0,4294967296;; \
1171 1.41 christos *) range=-4294967296,4294967296;; \
1172 1.41 christos esac && \
1173 1.58 christos wd=$$PWD && \
1174 1.58 christos zones=$$($(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab) && \
1175 1.41 christos if test $@ = $(TIME_T_ALTERNATIVES_HEAD); then \
1176 1.41 christos range_target=; \
1177 1.23 christos else \
1178 1.41 christos range_target=to$$range.tzs; \
1179 1.23 christos fi && \
1180 1.58 christos (cd $@d && \
1181 1.58 christos $(MAKE) TOPDIR="$$wd/$@d" \
1182 1.58 christos CFLAGS='$(CFLAGS) -Dtime_tz='"'$(@:.ck=)'" \
1183 1.23 christos REDO='$(REDO)' \
1184 1.58 christos D="$$wd/$@d" \
1185 1.41 christos TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
1186 1.41 christos install $$range_target) && \
1187 1.41 christos test $@ = $(TIME_T_ALTERNATIVES_HEAD) || { \
1188 1.58 christos (cd $(TIME_T_ALTERNATIVES_HEAD)d && \
1189 1.58 christos $(MAKE) TOPDIR="$$wd/$@d" \
1190 1.41 christos TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
1191 1.58 christos D="$$wd/$@d" \
1192 1.41 christos to$$range.tzs) && \
1193 1.58 christos $(SETUP_DIFF_TZS) && \
1194 1.58 christos $$DIFF_TZS $(TIME_T_ALTERNATIVES_HEAD)d/to$$range.tzs \
1195 1.58 christos $@d/to$$range.tzs && \
1196 1.41 christos if diff -q Makefile Makefile 2>/dev/null; then \
1197 1.41 christos quiet_option='-q'; \
1198 1.41 christos else \
1199 1.41 christos quiet_option=''; \
1200 1.41 christos fi && \
1201 1.58 christos diff $$quiet_option -r $(TIME_T_ALTERNATIVES_HEAD)d/etc \
1202 1.58 christos $@d/etc && \
1203 1.41 christos diff $$quiet_option -r \
1204 1.58 christos $(TIME_T_ALTERNATIVES_HEAD)d/usr/share \
1205 1.58 christos $@d/usr/share; \
1206 1.41 christos }
1207 1.41 christos touch $@
1208 1.34 christos
1209 1.40 christos TRADITIONAL_ASC = \
1210 1.40 christos tzcode$(VERSION).tar.gz.asc \
1211 1.40 christos tzdata$(VERSION).tar.gz.asc
1212 1.41 christos REARGUARD_ASC = \
1213 1.41 christos tzdata$(VERSION)-rearguard.tar.gz.asc
1214 1.41 christos ALL_ASC = $(TRADITIONAL_ASC) $(REARGUARD_ASC) \
1215 1.40 christos tzdb-$(VERSION).tar.lz.asc
1216 1.40 christos
1217 1.51 christos tarballs rearguard_tarballs tailored_tarballs traditional_tarballs \
1218 1.41 christos signatures rearguard_signatures traditional_signatures: \
1219 1.51 christos version set-timestamps.out rearguard.zi vanguard.zi
1220 1.58 christos read -r VERSION <version && \
1221 1.48 christos $(MAKE) AWK='$(AWK)' VERSION="$$VERSION" $@_version
1222 1.35 christos
1223 1.40 christos # These *_version rules are intended for use if VERSION is set by some
1224 1.40 christos # other means. Ordinarily these rules are used only by the above
1225 1.40 christos # non-_version rules, which set VERSION on the 'make' command line.
1226 1.41 christos tarballs_version: traditional_tarballs_version rearguard_tarballs_version \
1227 1.40 christos tzdb-$(VERSION).tar.lz
1228 1.41 christos rearguard_tarballs_version: \
1229 1.41 christos tzdata$(VERSION)-rearguard.tar.gz
1230 1.38 christos traditional_tarballs_version: \
1231 1.38 christos tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
1232 1.51 christos tailored_tarballs_version: \
1233 1.51 christos tzdata$(VERSION)-tailored.tar.gz
1234 1.40 christos signatures_version: $(ALL_ASC)
1235 1.41 christos rearguard_signatures_version: $(REARGUARD_ASC)
1236 1.40 christos traditional_signatures_version: $(TRADITIONAL_ASC)
1237 1.9 christos
1238 1.16 christos tzcode$(VERSION).tar.gz: set-timestamps.out
1239 1.58 christos $(SETUP_TAR) && \
1240 1.58 christos $$TAR -cf - \
1241 1.23 christos $(COMMON) $(DOCS) $(SOURCES) | \
1242 1.38 christos gzip $(GZIPFLAGS) >$@.out
1243 1.35 christos mv $@.out $@
1244 1.10 christos
1245 1.16 christos tzdata$(VERSION).tar.gz: set-timestamps.out
1246 1.58 christos $(SETUP_TAR) && \
1247 1.58 christos $$TAR -cf - $(TZDATA_DIST) | \
1248 1.38 christos gzip $(GZIPFLAGS) >$@.out
1249 1.35 christos mv $@.out $@
1250 1.9 christos
1251 1.51 christos # Create empty files with a reproducible timestamp.
1252 1.51 christos CREATE_EMPTY = TZ=UTC0 touch -mt 202010122253.00
1253 1.51 christos
1254 1.51 christos # The obsolescent *rearguard* targets and related macros are present
1255 1.51 christos # for backwards compatibility with tz releases 2018e through 2022a.
1256 1.51 christos # They should go away eventually. To build rearguard tarballs you
1257 1.51 christos # can instead use 'make DATAFORM=rearguard tailored_tarballs'.
1258 1.40 christos tzdata$(VERSION)-rearguard.tar.gz: rearguard.zi set-timestamps.out
1259 1.51 christos rm -fr $@.dir
1260 1.51 christos mkdir $@.dir
1261 1.51 christos ln $(TZDATA_DIST) $@.dir
1262 1.51 christos cd $@.dir && rm -f $(TDATA) $(PACKRATDATA) version
1263 1.40 christos for f in $(TDATA) $(PACKRATDATA); do \
1264 1.51 christos rearf=$@.dir/$$f; \
1265 1.40 christos $(AWK) -v DATAFORM=rearguard -f ziguard.awk $$f >$$rearf && \
1266 1.48 christos $(SET_TIMESTAMP_DEP) $$rearf ziguard.awk $$f || exit; \
1267 1.40 christos done
1268 1.51 christos sed '1s/$$/-rearguard/' <version >$@.dir/version
1269 1.47 christos : The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
1270 1.51 christos $(CREATE_EMPTY) $@.dir/pacificnew
1271 1.56 christos touch -mr version $@.dir/version
1272 1.58 christos $(SETUP_TAR) && \
1273 1.51 christos (cd $@.dir && \
1274 1.58 christos $$TAR -cf - \
1275 1.51 christos $(TZDATA_DIST) pacificnew | \
1276 1.40 christos gzip $(GZIPFLAGS)) >$@.out
1277 1.40 christos mv $@.out $@
1278 1.40 christos
1279 1.51 christos # Create a tailored tarball suitable for TZUpdater and compatible tools.
1280 1.51 christos # For example, 'make DATAFORM=vanguard tailored_tarballs' makes a tarball
1281 1.51 christos # useful for testing whether TZUpdater supports vanguard form.
1282 1.51 christos # The generated tarball is not byte-for-byte equivalent to a hand-tailored
1283 1.51 christos # traditional tarball, as data entries are put into 'etcetera' even if they
1284 1.51 christos # came from some other source file. However, the effect should be the same
1285 1.51 christos # for ordinary use, which reads all the source files.
1286 1.51 christos tzdata$(VERSION)-tailored.tar.gz: set-timestamps.out
1287 1.51 christos rm -fr $@.dir
1288 1.51 christos mkdir $@.dir
1289 1.51 christos : The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
1290 1.58 christos if test $(DATAFORM) = vanguard; then \
1291 1.58 christos pacificnew=; \
1292 1.58 christos else \
1293 1.58 christos pacificnew=pacificnew; \
1294 1.58 christos fi && \
1295 1.51 christos cd $@.dir && \
1296 1.51 christos $(CREATE_EMPTY) $(PRIMARY_YDATA) $(NDATA) backward \
1297 1.58 christos $$pacificnew
1298 1.51 christos (grep '^#' tzdata.zi && echo && cat $(DATAFORM).zi) \
1299 1.51 christos >$@.dir/etcetera
1300 1.56 christos touch -mr tzdata.zi $@.dir/etcetera
1301 1.51 christos sed -n \
1302 1.51 christos -e '/^# *version *\(.*\)/h' \
1303 1.51 christos -e '/^# *ddeps */H' \
1304 1.51 christos -e '$$!d' \
1305 1.51 christos -e 'g' \
1306 1.51 christos -e 's/^# *version *//' \
1307 1.51 christos -e 's/\n# *ddeps */-/' \
1308 1.51 christos -e 's/ /-/g' \
1309 1.51 christos -e 'p' \
1310 1.51 christos <tzdata.zi >$@.dir/version
1311 1.56 christos touch -mr version $@.dir/version
1312 1.51 christos links= && \
1313 1.51 christos for file in $(TZDATA_DIST); do \
1314 1.51 christos test -f $@.dir/$$file || links="$$links $$file"; \
1315 1.51 christos done && \
1316 1.51 christos ln $$links $@.dir
1317 1.58 christos $(SETUP_TAR) && \
1318 1.51 christos (cd $@.dir && \
1319 1.58 christos $$TAR -cf - * | gzip $(GZIPFLAGS)) >$@.out
1320 1.51 christos mv $@.out $@
1321 1.51 christos
1322 1.41 christos tzdb-$(VERSION).tar.lz: set-timestamps.out set-tzs-timestamp.out
1323 1.34 christos rm -fr tzdb-$(VERSION)
1324 1.34 christos mkdir tzdb-$(VERSION)
1325 1.34 christos ln $(ENCHILADA) tzdb-$(VERSION)
1326 1.48 christos $(SET_TIMESTAMP) tzdb-$(VERSION) tzdb-$(VERSION)/*
1327 1.58 christos $(SETUP_TAR) && \
1328 1.58 christos $$TAR -cf - tzdb-$(VERSION) | lzip -9 >$@.out
1329 1.35 christos mv $@.out $@
1330 1.9 christos
1331 1.9 christos tzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
1332 1.9 christos tzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
1333 1.40 christos tzdata$(VERSION)-rearguard.tar.gz.asc: tzdata$(VERSION)-rearguard.tar.gz
1334 1.34 christos tzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
1335 1.40 christos $(ALL_ASC):
1336 1.44 christos $(GPG) --armor --detach-sign $?
1337 1.34 christos
1338 1.41 christos TYPECHECK_CFLAGS = $(CFLAGS) -DTYPECHECK -D__time_t_defined -D_TIME_T
1339 1.58 christos typecheck: long-long.ck unsigned.ck
1340 1.58 christos long-long.ck unsigned.ck: $(VERSION_DEPS)
1341 1.58 christos rm -fr $@d
1342 1.58 christos mkdir $@d
1343 1.58 christos ln $(VERSION_DEPS) $@d
1344 1.58 christos cd $@d && \
1345 1.41 christos case $@ in \
1346 1.58 christos long-long.*) i="long long";; \
1347 1.58 christos unsigned.* ) i="unsigned" ;; \
1348 1.41 christos esac && \
1349 1.41 christos $(MAKE) \
1350 1.41 christos CFLAGS="$(TYPECHECK_CFLAGS) \"-Dtime_t=$$i\"" \
1351 1.58 christos TOPDIR="$$PWD" \
1352 1.41 christos install
1353 1.58 christos $@d/zdump -i -c 1970,1971 Europe/Rome
1354 1.41 christos touch $@
1355 1.1 mlelstv
1356 1.38 christos zonenames: tzdata.zi
1357 1.38 christos @$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
1358 1.1 mlelstv
1359 1.59 christos asctime.o: private.h
1360 1.1 mlelstv date.o: private.h
1361 1.1 mlelstv difftime.o: private.h
1362 1.59 christos localtime.o: private.h tzdir.h tzfile.h
1363 1.59 christos strftime.o: localtime.c private.h tzdir.h tzfile.h
1364 1.59 christos zdump.o: private.h version.h
1365 1.59 christos zic.o: private.h tzdir.h tzfile.h version.h
1366 1.1 mlelstv
1367 1.22 christos .PHONY: ALL INSTALL all
1368 1.54 christos .PHONY: check check_mild check_time_t_alternatives
1369 1.42 christos .PHONY: check_web check_zishrink
1370 1.57 christos .PHONY: clean clean_misc commit-leap-seconds.list dummy.zd
1371 1.57 christos .PHONY: fetch-leap-seconds.list force_tzs
1372 1.58 christos .PHONY: install maintainer-clean names
1373 1.51 christos .PHONY: posix_only posix_right public
1374 1.41 christos .PHONY: rearguard_signatures rearguard_signatures_version
1375 1.41 christos .PHONY: rearguard_tarballs rearguard_tarballs_version
1376 1.41 christos .PHONY: right_only right_posix signatures signatures_version
1377 1.40 christos .PHONY: tarballs tarballs_version
1378 1.40 christos .PHONY: traditional_signatures traditional_signatures_version
1379 1.40 christos .PHONY: traditional_tarballs traditional_tarballs_version
1380 1.51 christos .PHONY: tailored_tarballs tailored_tarballs_version
1381 1.40 christos .PHONY: typecheck
1382 1.22 christos .PHONY: zonenames zones
1383 1.40 christos .PHONY: $(ZDS)
1384