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