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