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