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