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