xref: /freebsd/contrib/tzdata/Makefile (revision 2723c7ff)
189abb9f8SPhilip Paeps# Make and install tzdb code and data.
2ba2b2efdSGlen Barber# This file is in the public domain, so clarified as of
3ba2b2efdSGlen Barber# 2009-05-17 by Arthur David Olson.
4eebb9c2cSPhilip Paeps# Request POSIX conformance; this must be the first non-comment line.
5eebb9c2cSPhilip Paeps.POSIX:
6eebb9c2cSPhilip Paeps# On older platforms you may need to scrounge for a POSIX-conforming 'make'.
7eebb9c2cSPhilip Paeps# For example, on Solaris 10 (2005), use /usr/sfw/bin/gmake or
8eebb9c2cSPhilip Paeps# /usr/xpg4/bin/make, not /usr/ccs/bin/make.
9eebb9c2cSPhilip Paeps
10eebb9c2cSPhilip Paeps# To affect how this Makefile works, you can run a shell script like this:
11eebb9c2cSPhilip Paeps#
12eebb9c2cSPhilip Paeps#	#!/bin/sh
13eebb9c2cSPhilip Paeps#	make CC='gcc -std=gnu11' "$@"
14eebb9c2cSPhilip Paeps#
15eebb9c2cSPhilip Paeps# This example script is appropriate for a pre-2017 GNU/Linux system
16eebb9c2cSPhilip Paeps# where a non-default setting is needed to support this package's use of C99.
17eebb9c2cSPhilip Paeps#
18eebb9c2cSPhilip Paeps# Alternatively, you can simply edit this Makefile to tailor the following
19eebb9c2cSPhilip Paeps# macro definitions.
20eebb9c2cSPhilip Paeps
21eebb9c2cSPhilip Paeps###############################################################################
22eebb9c2cSPhilip Paeps# Start of macros that one plausibly might want to tailor.
23ba2b2efdSGlen Barber
24ba2b2efdSGlen Barber# Package name for the code distribution.
25ba2b2efdSGlen BarberPACKAGE=	tzcode
26ba2b2efdSGlen Barber
27ba2b2efdSGlen Barber# Version number for the distribution, overridden in the 'tarballs' rule below.
28ba2b2efdSGlen BarberVERSION=	unknown
29ba2b2efdSGlen Barber
30ba2b2efdSGlen Barber# Email address for bug reports.
31ba2b2efdSGlen BarberBUGEMAIL=	tz@iana.org
32ba2b2efdSGlen Barber
33ad48359aSPhilip Paeps# DATAFORM selects the data format.
34ad48359aSPhilip Paeps# Available formats represent essentially the same data, albeit
35ad48359aSPhilip Paeps# possibly with minor discrepancies that users are not likely to notice.
36ad48359aSPhilip Paeps# To get new features and the best data right away, use:
3746bee4edSPhilip Paeps#	DATAFORM=	vanguard
3846bee4edSPhilip Paeps# To wait a while before using new features, to give downstream users
3946bee4edSPhilip Paeps# time to upgrade zic (the default), use:
4046bee4edSPhilip Paeps#	DATAFORM=	main
4146bee4edSPhilip Paeps# To wait even longer for new features, use:
4246bee4edSPhilip Paeps#	DATAFORM=	rearguard
4312a899b6SPhilip Paeps# Rearguard users might also want "ZFLAGS = -b fat"; see below.
4446bee4edSPhilip PaepsDATAFORM=		main
4546bee4edSPhilip Paeps
4689abb9f8SPhilip Paeps# Change the line below for your timezone (after finding the one you want in
4789abb9f8SPhilip Paeps# one of the $(TDATA) source files, or adding it to a source file).
48d81c2dd9SPhilip Paeps# Alternatively, if you discover you've got the wrong timezone, you can just
4912a899b6SPhilip Paeps# 'zic -l -' to remove it, or 'zic -l rightzone' to change it.
50ba2b2efdSGlen Barber# Use the command
51ba2b2efdSGlen Barber#	make zonenames
52ba2b2efdSGlen Barber# to get a list of the values you can use for LOCALTIME.
53ba2b2efdSGlen Barber
549f9fc6bbSPhilip PaepsLOCALTIME=	Factory
55ba2b2efdSGlen Barber
562723c7ffSPhilip Paeps# The POSIXRULES macro controls interpretation of POSIX-2017.1-like TZ
57259e2ad7SPhilip Paeps# settings like TZ='EET-2EEST' that lack DST transition rules.
5812a899b6SPhilip Paeps# If POSIXRULES is '-', no template is installed; this is the default.
5912a899b6SPhilip Paeps# Any other value for POSIXRULES is obsolete and should not be relied on, as:
602865ab3fSPhilip Paeps# * It does not work correctly in popular implementations such as GNU/Linux.
6194c2d487SPhilip Paeps# * It does not work even in tzcode, except for historical timestamps
6294c2d487SPhilip Paeps#   that precede the last explicit transition in the POSIXRULES file.
6394c2d487SPhilip Paeps#   Hence it typically does not work for current and future timestamps.
6412a899b6SPhilip Paeps# If, despite the above, you want a template for handling these settings,
6512a899b6SPhilip Paeps# you can change the line below (after finding the timezone you want in the
6612a899b6SPhilip Paeps# one of the $(TDATA) source files, or adding it to a source file).
6712a899b6SPhilip Paeps# Alternatively, if you discover you've got the wrong timezone, you can just
6812a899b6SPhilip Paeps# 'zic -p -' to remove it, or 'zic -p rightzone' to change it.
6912a899b6SPhilip Paeps# Use the command
7012a899b6SPhilip Paeps#	make zonenames
7112a899b6SPhilip Paeps# to get a list of the values you can use for POSIXRULES.
72ba2b2efdSGlen Barber
7312a899b6SPhilip PaepsPOSIXRULES=	-
74ba2b2efdSGlen Barber
75ba2b2efdSGlen Barber# Also see TZDEFRULESTRING below, which takes effect only
76259e2ad7SPhilip Paeps# if POSIXRULES is '-' or if the template file cannot be accessed.
77ba2b2efdSGlen Barber
78ba2b2efdSGlen Barber
79f2fcff28SPhilip Paeps# Installation locations.
80f2fcff28SPhilip Paeps#
81f2fcff28SPhilip Paeps# The defaults are suitable for Debian, except that if REDO is
82f2fcff28SPhilip Paeps# posix_right or right_posix then files that Debian puts under
83f2fcff28SPhilip Paeps# /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
84f2fcff28SPhilip Paeps# put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
85f2fcff28SPhilip Paeps# respectively.  Problems with the Debian approach are discussed in
86f2fcff28SPhilip Paeps# the commentary for the right_posix rule (below).
87f2fcff28SPhilip Paeps
88f2fcff28SPhilip Paeps# Destination directory, which can be used for staging.
89f2fcff28SPhilip Paeps# 'make DESTDIR=/stage install' installs under /stage (e.g., to
90f2fcff28SPhilip Paeps# /stage/etc/localtime instead of to /etc/localtime).  Files under
91f2fcff28SPhilip Paeps# /stage are not intended to work as-is, but can be copied by hand to
92f2fcff28SPhilip Paeps# the root directory later.  If DESTDIR is empty, 'make install' does
93f2fcff28SPhilip Paeps# not stage, but installs directly into production locations.
94f2fcff28SPhilip PaepsDESTDIR =
95f2fcff28SPhilip Paeps
96f2fcff28SPhilip Paeps# Everything is installed into subdirectories of TOPDIR, and used there.
97f2fcff28SPhilip Paeps# TOPDIR should be empty (meaning the root directory),
98f2fcff28SPhilip Paeps# or a directory name that does not end in "/".
99f2fcff28SPhilip Paeps# TOPDIR should be empty or an absolute name unless you're just testing.
100f2fcff28SPhilip PaepsTOPDIR =
101f2fcff28SPhilip Paeps
102f2fcff28SPhilip Paeps# The default local timezone is taken from the file TZDEFAULT.
103f2fcff28SPhilip PaepsTZDEFAULT = $(TOPDIR)/etc/localtime
104f2fcff28SPhilip Paeps
105f2fcff28SPhilip Paeps# The subdirectory containing installed program and data files, and
106f2fcff28SPhilip Paeps# likewise for installed files that can be shared among architectures.
107f2fcff28SPhilip Paeps# These should be relative file names.
108f2fcff28SPhilip PaepsUSRDIR = usr
109f2fcff28SPhilip PaepsUSRSHAREDIR = $(USRDIR)/share
110ba2b2efdSGlen Barber
111ba2b2efdSGlen Barber# "Compiled" timezone information is placed in the "TZDIR" directory
112ba2b2efdSGlen Barber# (and subdirectories).
1138d7edd17SPhilip Paeps# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
114ba2b2efdSGlen BarberTZDIR_BASENAME=	zoneinfo
115f2fcff28SPhilip PaepsTZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
116f2fcff28SPhilip Paeps
117f2fcff28SPhilip Paeps# The "tzselect" and (if you do "make INSTALL") "date" commands go in:
118f2fcff28SPhilip PaepsBINDIR = $(TOPDIR)/$(USRDIR)/bin
119f2fcff28SPhilip Paeps
120f2fcff28SPhilip Paeps# The "zdump" command goes in:
121f2fcff28SPhilip PaepsZDUMPDIR = $(BINDIR)
122f2fcff28SPhilip Paeps
123f2fcff28SPhilip Paeps# The "zic" command goes in:
124f2fcff28SPhilip PaepsZICDIR = $(TOPDIR)/$(USRDIR)/sbin
125f2fcff28SPhilip Paeps
126f2fcff28SPhilip Paeps# Manual pages go in subdirectories of. . .
127f2fcff28SPhilip PaepsMANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
128f2fcff28SPhilip Paeps
129f2fcff28SPhilip Paeps# Library functions are put in an archive in LIBDIR.
130f2fcff28SPhilip PaepsLIBDIR = $(TOPDIR)/$(USRDIR)/lib
131f2fcff28SPhilip Paeps
132ba2b2efdSGlen Barber
13389abb9f8SPhilip Paeps# Types to try, as an alternative to time_t.
13489abb9f8SPhilip PaepsTIME_T_ALTERNATIVES = $(TIME_T_ALTERNATIVES_HEAD) $(TIME_T_ALTERNATIVES_TAIL)
13594c2d487SPhilip PaepsTIME_T_ALTERNATIVES_HEAD = int_least64_t
13694c2d487SPhilip PaepsTIME_T_ALTERNATIVES_TAIL = int_least32_t uint_least32_t uint_least64_t
137ba2b2efdSGlen Barber
138ad48359aSPhilip Paeps# What kind of TZif data files to generate.  (TZif is the binary time
139ad48359aSPhilip Paeps# zone data format that zic generates; see Internet RFC 8536.)
140dc135c6eSBaptiste Daroussin# If you want only POSIX time, with time values interpreted as
141dc135c6eSBaptiste Daroussin# seconds since the epoch (not counting leap seconds), use
142ba2b2efdSGlen Barber#	REDO=		posix_only
1438d7edd17SPhilip Paeps# below.  If you want only "right" time, with values interpreted
144dc135c6eSBaptiste Daroussin# as seconds since the epoch (counting leap seconds), use
145ba2b2efdSGlen Barber#	REDO=		right_only
146ba2b2efdSGlen Barber# below.  If you want both sets of data available, with leap seconds not
147ba2b2efdSGlen Barber# counted normally, use
148ba2b2efdSGlen Barber#	REDO=		posix_right
149ba2b2efdSGlen Barber# below.  If you want both sets of data available, with leap seconds counted
150ba2b2efdSGlen Barber# normally, use
151ba2b2efdSGlen Barber#	REDO=		right_posix
152ba2b2efdSGlen Barber# below.  POSIX mandates that leap seconds not be counted; for compatibility
153dc135c6eSBaptiste Daroussin# with it, use "posix_only" or "posix_right".  Use POSIX time on systems with
154dc135c6eSBaptiste Daroussin# leap smearing; this can work better than unsmeared "right" time with
155dc135c6eSBaptiste Daroussin# applications that are not leap second aware, and is closer to unsmeared
156dc135c6eSBaptiste Daroussin# "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
157ba2b2efdSGlen Barber
158ba2b2efdSGlen BarberREDO=		posix_right
159ba2b2efdSGlen Barber
160dd5f96c4SPhilip Paeps# Whether to put an "Expires" line in the leapseconds file.
161dd5f96c4SPhilip Paeps# Use EXPIRES_LINE=1 to put the line in, 0 to omit it.
162dd5f96c4SPhilip Paeps# The EXPIRES_LINE value matters only if REDO's value contains "right".
163dd5f96c4SPhilip Paeps# If you change EXPIRES_LINE, remove the leapseconds file before running "make".
164dd5f96c4SPhilip Paeps# zic's support for the Expires line was introduced in tzdb 2020a,
16594c2d487SPhilip Paeps# and was modified in tzdb 2021b to generate version 4 TZif files.
16694c2d487SPhilip Paeps# EXPIRES_LINE defaults to 0 for now so that the leapseconds file
16794c2d487SPhilip Paeps# can be given to pre-2020a zic implementations and so that TZif files
16894c2d487SPhilip Paeps# built by newer zic implementations can be read by pre-2021b libraries.
169dd5f96c4SPhilip PaepsEXPIRES_LINE=	0
170dd5f96c4SPhilip Paeps
17189abb9f8SPhilip Paeps# To install data in text form that has all the information of the TZif data,
1728d7edd17SPhilip Paeps# (optionally incorporating leap second information), use
1738d7edd17SPhilip Paeps#	TZDATA_TEXT=	tzdata.zi leapseconds
1748d7edd17SPhilip Paeps# To install text data without leap second information (e.g., because
1758d7edd17SPhilip Paeps# REDO='posix_only'), use
1768d7edd17SPhilip Paeps#	TZDATA_TEXT=	tzdata.zi
1778d7edd17SPhilip Paeps# To avoid installing text data, use
1788d7edd17SPhilip Paeps#	TZDATA_TEXT=
1798d7edd17SPhilip Paeps
1808d7edd17SPhilip PaepsTZDATA_TEXT=	leapseconds tzdata.zi
1818d7edd17SPhilip Paeps
1828d7edd17SPhilip Paeps# For backward-compatibility links for old zone names, use
183f2fcff28SPhilip Paeps#	BACKWARD=	backward
1848d7edd17SPhilip Paeps# To omit these links, use
1858d7edd17SPhilip Paeps#	BACKWARD=
1868d7edd17SPhilip Paeps
187f2fcff28SPhilip PaepsBACKWARD=	backward
1888d7edd17SPhilip Paeps
1899f9fc6bbSPhilip Paeps# If you want out-of-scope and often-wrong data from the file 'backzone',
1909f9fc6bbSPhilip Paeps# but only for entries listed in the backward-compatibility file zone.tab, use
191ba2b2efdSGlen Barber#	PACKRATDATA=	backzone
1929f9fc6bbSPhilip Paeps#	PACKRATLIST=	zone.tab
1939f9fc6bbSPhilip Paeps# If you want all the 'backzone' data, use
1949f9fc6bbSPhilip Paeps#	PACKRATDATA=	backzone
1959f9fc6bbSPhilip Paeps#	PACKRATLIST=
196ba2b2efdSGlen Barber# To omit this data, use
197ba2b2efdSGlen Barber#	PACKRATDATA=
1989f9fc6bbSPhilip Paeps#	PACKRATLIST=
199ba2b2efdSGlen Barber
200ba2b2efdSGlen BarberPACKRATDATA=
2019f9fc6bbSPhilip PaepsPACKRATLIST=
202ba2b2efdSGlen Barber
2038d7edd17SPhilip Paeps# The name of a locale using the UTF-8 encoding, used during self-tests.
2048d7edd17SPhilip Paeps# The tests are skipped if the name does not appear to work on this system.
2058d7edd17SPhilip Paeps
2068d7edd17SPhilip PaepsUTF8_LOCALE=	en_US.utf8
2078d7edd17SPhilip Paeps
208ba2b2efdSGlen Barber# Non-default libraries needed to link.
209cf1ad535SPhilip Paeps# On some hosts, this should have -lintl unless CFLAGS has -DHAVE_GETTEXT=0.
210ba2b2efdSGlen BarberLDLIBS=
211ba2b2efdSGlen Barber
212eebb9c2cSPhilip Paeps# Add the following to an uncommented "CFLAGS=" line as needed
213eebb9c2cSPhilip Paeps# to override defaults specified in the source code or by the system.
214eebb9c2cSPhilip Paeps# "-DFOO" is equivalent to "-DFOO=1".
2158d7edd17SPhilip Paeps#  -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
2168d7edd17SPhilip Paeps#	formats that generate only the last two digits of year numbers
2178d7edd17SPhilip Paeps#  -DEPOCH_LOCAL if the 'time' function returns local time not UT
218ba2b2efdSGlen Barber#  -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
219ba2b2efdSGlen Barber#	than what POSIX specifies, assuming local time is UT.
220ba2b2efdSGlen Barber#	For example, N is 252460800 on AmigaOS.
2218d7edd17SPhilip Paeps#  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
2228d7edd17SPhilip Paeps#  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
223cf1ad535SPhilip Paeps#  -DHAVE_DECL_TIMEGM=0 if <time.h> does not declare timegm
2248d7edd17SPhilip Paeps#  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
225259e2ad7SPhilip Paeps#  -DHAVE__GENERIC=0 if _Generic does not work*
226cf1ad535SPhilip Paeps#  -DHAVE_GETRANDOM if getrandom works (e.g., GNU/Linux),
227cf1ad535SPhilip Paeps#	-DHAVE_GETRANDOM=0 to avoid using getrandom
228cf1ad535SPhilip Paeps#  -DHAVE_GETTEXT if gettext works (e.g., GNU/Linux, FreeBSD, Solaris),
229cf1ad535SPhilip Paeps#	where LDLIBS also needs to contain -lintl on some hosts;
230cf1ad535SPhilip Paeps#	-DHAVE_GETTEXT=0 to avoid using gettext
2318d7edd17SPhilip Paeps#  -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
2328d7edd17SPhilip Paeps#	ctime_r and asctime_r incompatibly with the POSIX standard
2338d7edd17SPhilip Paeps#	(Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
234259e2ad7SPhilip Paeps#  -DHAVE_INTTYPES_H=0 if <inttypes.h> does not work*+
2358d7edd17SPhilip Paeps#  -DHAVE_LINK=0 if your system lacks a link function
2368d7edd17SPhilip Paeps#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
2378d7edd17SPhilip Paeps#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
2388d7edd17SPhilip Paeps#	localtime_rz can make zdump significantly faster, but is nonstandard.
23994c2d487SPhilip Paeps#  -DHAVE_MALLOC_ERRNO=0 if malloc etc. do not set errno on failure.
2408d7edd17SPhilip Paeps#  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
2418d7edd17SPhilip Paeps#	functions like 'link' or variables like 'tzname' required by POSIX
2429142a2a3SPhilip Paeps#  -DHAVE_SETENV=0 if your system lacks the setenv function
243259e2ad7SPhilip Paeps#  -DHAVE_SNPRINTF=0 if your system lacks the snprintf function+
244cf1ad535SPhilip Paeps#  -DHAVE_STDCKDINT_H=0 if neither <stdckdint.h> nor substitutes like
245cf1ad535SPhilip Paeps#	__builtin_add_overflow work*
246259e2ad7SPhilip Paeps#  -DHAVE_STDINT_H=0 if <stdint.h> does not work*+
2478d7edd17SPhilip Paeps#  -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
2488d7edd17SPhilip Paeps#  -DHAVE_STRDUP=0 if your system lacks the strdup function
249259e2ad7SPhilip Paeps#  -DHAVE_STRTOLL=0 if your system lacks the strtoll function+
2508d7edd17SPhilip Paeps#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
251cf1ad535SPhilip Paeps#  -DHAVE_SYS_STAT_H=0 if <sys/stat.h> does not work*
2528d7edd17SPhilip Paeps#  -DHAVE_TZSET=0 if your system lacks a tzset function
253cf1ad535SPhilip Paeps#  -DHAVE_UNISTD_H=0 if <unistd.h> does not work*
254cf1ad535SPhilip Paeps#  -DHAVE_UTMPX_H=0 if <utmpx.h> does not work*
2558d7edd17SPhilip Paeps#  -Dlocale_t=XXX if your system uses XXX instead of locale_t
256eebb9c2cSPhilip Paeps#  -DPORT_TO_C89 if tzcode should also run on mostly-C89 platforms+
257eebb9c2cSPhilip Paeps#	Typically it is better to use a later standard.  For example,
258eebb9c2cSPhilip Paeps#	with GCC 4.9.4 (2016), prefer '-std=gnu11' to '-DPORT_TO_C89'.
259eebb9c2cSPhilip Paeps#	Even with -DPORT_TO_C89, the code needs at least one C99
260eebb9c2cSPhilip Paeps#	feature (integers at least 64 bits wide) and maybe more.
26146bee4edSPhilip Paeps#  -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
26246bee4edSPhilip Paeps#	with external linkage, e.g., applications cannot define 'localtime'.
2638d7edd17SPhilip Paeps#  -Dssize_t=long on hosts like MS-Windows that lack ssize_t
264259e2ad7SPhilip Paeps#  -DSUPPORT_C89 if the tzcode library should support C89 callers+
265eebb9c2cSPhilip Paeps#	However, this might trigger latent bugs in C99-or-later callers.
26646bee4edSPhilip Paeps#  -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
26746bee4edSPhilip Paeps#	security implications and is not recommended for general use
2688d7edd17SPhilip Paeps#  -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
269ba2b2efdSGlen Barber#	not needed by the main-program tz code, which is single-threaded.
270ba2b2efdSGlen Barber#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
271ba2b2efdSGlen Barber#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
2728d7edd17SPhilip Paeps#	This is intended for internal use only; it mangles external names.
273ba2b2efdSGlen Barber#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
274ba2b2efdSGlen Barber#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
275ba2b2efdSGlen Barber#	the default is system-supplied, typically "/usr/lib/locale"
276ba2b2efdSGlen Barber#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
2772723c7ffSPhilip Paeps#	DST transitions for POSIX.1-2017-style TZ strings lacking them,
278259e2ad7SPhilip Paeps#	in the usual case where POSIXRULES is '-'.  If not specified,
279259e2ad7SPhilip Paeps#	TZDEFRULESTRING defaults to US rules for future DST transitions.
280259e2ad7SPhilip Paeps#	This mishandles some past timestamps, as US DST rules have changed.
281259e2ad7SPhilip Paeps#	It also mishandles settings like TZ='EET-2EEST' for eastern Europe,
282259e2ad7SPhilip Paeps#	as Europe and US DST rules differ.
283259e2ad7SPhilip Paeps#  -DTZNAME_MAXIMUM=N to limit time zone abbreviations to N bytes (default 255)
2848d7edd17SPhilip Paeps#  -DUNINIT_TRAP if reading uninitialized storage can cause problems
285ba2b2efdSGlen Barber#	other than simply getting garbage data
286ba2b2efdSGlen Barber#  -DUSE_LTZ=0 to build zdump with the system time zone library
287ba2b2efdSGlen Barber#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
28812a899b6SPhilip Paeps#  -DZIC_BLOAT_DEFAULT=\"fat\" to default zic's -b option to "fat", and
28912a899b6SPhilip Paeps#	similarly for "slim".  Fat TZif files work around incompatibilities
2909142a2a3SPhilip Paeps#	and bugs in some TZif readers, notably older ones that
2919142a2a3SPhilip Paeps#	ignore or otherwise mishandle 64-bit data in TZif files;
2929142a2a3SPhilip Paeps#	however, fat TZif files may trigger bugs in newer TZif readers.
2939142a2a3SPhilip Paeps#	Slim TZif files are more efficient, and are the default.
294ba2b2efdSGlen Barber#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
295ba2b2efdSGlen Barber#	(or some other number) to set the maximum time zone abbreviation length
296ba2b2efdSGlen Barber#	that zic will accept without a warning (the default is 6)
297eebb9c2cSPhilip Paeps#  -g to generate symbolic debugging info
298eebb9c2cSPhilip Paeps#  -Idir to include from directory 'dir'
299eebb9c2cSPhilip Paeps#  -O0 to disable optimization; other -O options to enable more optimization
300eebb9c2cSPhilip Paeps#  -Uname to remove any definition of the macro 'name'
301ba2b2efdSGlen Barber#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
3029142a2a3SPhilip Paeps#
3039142a2a3SPhilip Paeps# * Options marked "*" can be omitted if your compiler is C23 compatible.
304259e2ad7SPhilip Paeps# * Options marked "+" are obsolescent and are planned to be removed
305eebb9c2cSPhilip Paeps#   once the code assumes C99 or later, say in the year 2029.
3069142a2a3SPhilip Paeps#
3078d7edd17SPhilip Paeps# Select instrumentation via "make GCC_INSTRUMENT='whatever'".
3088d7edd17SPhilip PaepsGCC_INSTRUMENT = \
3098d7edd17SPhilip Paeps  -fsanitize=undefined -fsanitize-address-use-after-scope \
3108d7edd17SPhilip Paeps  -fsanitize-undefined-trap-on-error -fstack-protector
31194c2d487SPhilip Paeps# Omit -fanalyzer from GCC_DEBUG_FLAGS, as it makes GCC too slow.
3128d7edd17SPhilip PaepsGCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \
3138d7edd17SPhilip Paeps  $(GCC_INSTRUMENT) \
314ba2b2efdSGlen Barber  -Wall -Wextra \
3158d7edd17SPhilip Paeps  -Walloc-size-larger-than=100000 -Warray-bounds=2 \
3169f9fc6bbSPhilip Paeps  -Wbad-function-cast -Wbidi-chars=any,ucn -Wcast-align=strict -Wdate-time \
3178d7edd17SPhilip Paeps  -Wdeclaration-after-statement -Wdouble-promotion \
31894c2d487SPhilip Paeps  -Wduplicated-branches -Wduplicated-cond \
3198d7edd17SPhilip Paeps  -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
320cf1ad535SPhilip Paeps  -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op \
3218d7edd17SPhilip Paeps  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
32294c2d487SPhilip Paeps  -Wnull-dereference \
323ba2b2efdSGlen Barber  -Wold-style-definition -Woverlength-strings -Wpointer-arith \
32494c2d487SPhilip Paeps  -Wshadow -Wshift-overflow=2 -Wstrict-overflow \
32594c2d487SPhilip Paeps  -Wstrict-prototypes -Wstringop-overflow=4 \
326d81c2dd9SPhilip Paeps  -Wstringop-truncation -Wsuggest-attribute=cold \
3278d7edd17SPhilip Paeps  -Wsuggest-attribute=const -Wsuggest-attribute=format \
328d81c2dd9SPhilip Paeps  -Wsuggest-attribute=malloc \
3298d7edd17SPhilip Paeps  -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
3309f9fc6bbSPhilip Paeps  -Wtrampolines -Wundef -Wuninitialized -Wunused-macros -Wuse-after-free=3 \
3318d7edd17SPhilip Paeps  -Wvariadic-macros -Wvla -Wwrite-strings \
332ba2b2efdSGlen Barber  -Wno-address -Wno-format-nonliteral -Wno-sign-compare \
333cf1ad535SPhilip Paeps  -Wno-type-limits
334ba2b2efdSGlen Barber#
335ba2b2efdSGlen Barber# If your system has a "GMT offset" field in its "struct tm"s
336ba2b2efdSGlen Barber# (or if you decide to add such a field in your system's "time.h" file),
337ba2b2efdSGlen Barber# add the name to a define such as
338ba2b2efdSGlen Barber#	-DTM_GMTOFF=tm_gmtoff
339ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
340ba2b2efdSGlen Barber# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
341ba2b2efdSGlen Barber# Similarly, if your system has a "zone abbreviation" field, define
342ba2b2efdSGlen Barber#	-DTM_ZONE=tm_zone
3432723c7ffSPhilip Paeps# and define NO_TM_ZONE to suppress any guessing.
3442723c7ffSPhilip Paeps# Although these two fields are not required by POSIX.1-2017,
3452723c7ffSPhilip Paeps# POSIX 202x/D4 requires them and they are widely available
3462723c7ffSPhilip Paeps# on GNU/Linux and BSD systems.
347ba2b2efdSGlen Barber#
3488d7edd17SPhilip Paeps# The next batch of options control support for external variables
3498d7edd17SPhilip Paeps# exported by tzcode.  In practice these variables are less useful
3508d7edd17SPhilip Paeps# than TM_GMTOFF and TM_ZONE.  However, most of them are standardized.
3518d7edd17SPhilip Paeps# #
3528d7edd17SPhilip Paeps# # To omit or support the external variable "tzname", add one of:
353dd5f96c4SPhilip Paeps# #	-DHAVE_TZNAME=0 # do not support "tzname"
354dd5f96c4SPhilip Paeps# #	-DHAVE_TZNAME=1 # support "tzname", which is defined by system library
355dd5f96c4SPhilip Paeps# #	-DHAVE_TZNAME=2 # support and define "tzname"
3562723c7ffSPhilip Paeps# # to the "CFLAGS=" line.  "tzname" is required by POSIX.1-1988 and later.
3578d7edd17SPhilip Paeps# # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
3588d7edd17SPhilip Paeps# # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
3598d7edd17SPhilip Paeps# # crashes when combined with some platforms' standard libraries,
3608d7edd17SPhilip Paeps# # presumably due to memory allocation issues.
3618d7edd17SPhilip Paeps# #
3628d7edd17SPhilip Paeps# # To omit or support the external variables "timezone" and "daylight", add
363dd5f96c4SPhilip Paeps# #	-DUSG_COMPAT=0 # do not support
364dd5f96c4SPhilip Paeps# #	-DUSG_COMPAT=1 # support, and variables are defined by system library
365dd5f96c4SPhilip Paeps# #	-DUSG_COMPAT=2 # support and define variables
3662723c7ffSPhilip Paeps# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by Unix
3672723c7ffSPhilip Paeps# # Systems Group code and are required by POSIX.1-2008 and later (with XSI).
3688d7edd17SPhilip Paeps# # If not defined, the code attempts to guess USG_COMPAT from other macros.
3698d7edd17SPhilip Paeps# #
3708d7edd17SPhilip Paeps# # To support the external variable "altzone", add
371dd5f96c4SPhilip Paeps# #	-DALTZONE=0 # do not support
372dd5f96c4SPhilip Paeps# #	-DALTZONE=1 # support "altzone", which is defined by system library
373dd5f96c4SPhilip Paeps# #	-DALTZONE=2 # support and define "altzone"
3748d7edd17SPhilip Paeps# # to the end of the "CFLAGS=" line; although "altzone" appeared in
3758d7edd17SPhilip Paeps# # System V Release 3.1 it has not been standardized.
376dd5f96c4SPhilip Paeps# # If not defined, the code attempts to guess ALTZONE from other macros.
3778d7edd17SPhilip Paeps#
378ba2b2efdSGlen Barber# If you want functions that were inspired by early versions of X3J11's work,
379ba2b2efdSGlen Barber# add
380ba2b2efdSGlen Barber#	-DSTD_INSPIRED
381cf1ad535SPhilip Paeps# to the end of the "CFLAGS=" line.  This arranges for the following
382cf1ad535SPhilip Paeps# functions to be added to the time conversion library.
383ba2b2efdSGlen Barber# "offtime" is like "gmtime" except that it accepts a second (long) argument
384ba2b2efdSGlen Barber# that gives an offset to add to the time_t when converting it.
385eebb9c2cSPhilip Paeps# I.e., "offtime" is like calling "localtime_rz" with a fixed-offset zone.
386eebb9c2cSPhilip Paeps# "timelocal" is nearly equivalent to "mktime".
387ba2b2efdSGlen Barber# "timeoff" is like "timegm" except that it accepts a second (long) argument
388ba2b2efdSGlen Barber# that gives an offset to use when converting to a time_t.
389eebb9c2cSPhilip Paeps# I.e., "timeoff" is like calling "mktime_z" with a fixed-offset zone.
390ba2b2efdSGlen Barber# "posix2time" and "time2posix" are described in an included manual page.
391ba2b2efdSGlen Barber# X3J11's work does not describe any of these functions.
392ba2b2efdSGlen Barber# These functions may well disappear in future releases of the time
393ba2b2efdSGlen Barber# conversion package.
394ba2b2efdSGlen Barber#
395ba2b2efdSGlen Barber# If you don't want functions that were inspired by NetBSD, add
396ba2b2efdSGlen Barber#	-DNETBSD_INSPIRED=0
397ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  Otherwise, the functions
398ba2b2efdSGlen Barber# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
399259e2ad7SPhilip Paeps# time library, and if STD_INSPIRED is also defined to nonzero the functions
400ba2b2efdSGlen Barber# "posix2time_z" and "time2posix_z" are added as well.
401ba2b2efdSGlen Barber# The functions ending in "_z" (or "_rz") are like their unsuffixed
402ba2b2efdSGlen Barber# (or suffixed-by-"_r") counterparts, except with an extra first
403ba2b2efdSGlen Barber# argument of opaque type timezone_t that specifies the timezone.
404ba2b2efdSGlen Barber# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
405ba2b2efdSGlen Barber#
406ba2b2efdSGlen Barber# If you want to allocate state structures in localtime, add
407ba2b2efdSGlen Barber#	-DALL_STATE
408ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
409ba2b2efdSGlen Barber#
410ba2b2efdSGlen Barber# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
411ba2b2efdSGlen Barber# out by the National Institute of Standards and Technology
412eebb9c2cSPhilip Paeps# which claims to test C and POSIX conformance.  If you want to pass PCTS, add
413ba2b2efdSGlen Barber#	-DPCTS
414ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.
415ba2b2efdSGlen Barber#
416ba2b2efdSGlen Barber# If you want strict compliance with XPG4 as of 1994-04-09, add
417ba2b2efdSGlen Barber#	-DXPG4_1994_04_09
418ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
4198d7edd17SPhilip Paeps# 53 as a week number (rather than 52 or 53) for January days before
4208d7edd17SPhilip Paeps# January's first Monday when a "%V" format is used and January 1
421ba2b2efdSGlen Barber# falls on a Friday, Saturday, or Sunday.
422eebb9c2cSPhilip Paeps#
423eebb9c2cSPhilip Paeps# POSIX says CFLAGS defaults to "-O 1".
424eebb9c2cSPhilip Paeps# Uncomment the following line and edit its contents as needed.
425ba2b2efdSGlen Barber
426eebb9c2cSPhilip Paeps#CFLAGS= -O 1
427ba2b2efdSGlen Barber
428ba2b2efdSGlen Barber
429eebb9c2cSPhilip Paeps# The name of a POSIX-like library archiver, its flags, C compiler,
430eebb9c2cSPhilip Paeps# linker flags, and 'make' utility.  Ordinarily the defaults suffice.
4312723c7ffSPhilip Paeps# The commented-out values are the defaults specified by POSIX.1-202x/D4.
432eebb9c2cSPhilip Paeps#AR = ar
433eebb9c2cSPhilip Paeps#ARFLAGS = -rv
434eebb9c2cSPhilip Paeps#CC = c17
435eebb9c2cSPhilip Paeps#LDFLAGS =
436eebb9c2cSPhilip Paeps#MAKE = make
437ba2b2efdSGlen Barber
438ba2b2efdSGlen Barber# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
439ba2b2efdSGlen Barber# submake command lines.  The default is no leap seconds.
440ba2b2efdSGlen Barber
441ba2b2efdSGlen BarberLEAPSECONDS=
442ba2b2efdSGlen Barber
4432723c7ffSPhilip Paeps# Where to fetch leap-seconds.list from.
4442723c7ffSPhilip Paepsleaplist_URI = \
4452723c7ffSPhilip Paeps  https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list
4462723c7ffSPhilip Paeps# The file is generated by the IERS Earth Orientation Centre, in Paris.
4472723c7ffSPhilip Paepsleaplist_TZ = Europe/Paris
4482723c7ffSPhilip Paeps
449ba2b2efdSGlen Barber# The zic command and its arguments.
450ba2b2efdSGlen Barber
451ba2b2efdSGlen Barberzic=		./zic
452ba2b2efdSGlen BarberZIC=		$(zic) $(ZFLAGS)
453ba2b2efdSGlen Barber
454ad48359aSPhilip Paeps# To shrink the size of installed TZif files,
455ad48359aSPhilip Paeps# append "-r @N" to omit data before N-seconds-after-the-Epoch.
4569142a2a3SPhilip Paeps# To grow the files and work around bugs in older applications,
4579142a2a3SPhilip Paeps# possibly at the expense of introducing bugs in newer ones,
4589142a2a3SPhilip Paeps# append "-b fat"; see ZIC_BLOAT_DEFAULT above.
4592865ab3fSPhilip Paeps# See the zic man page for more about -b and -r.
460ba2b2efdSGlen BarberZFLAGS=
461ba2b2efdSGlen Barber
46289abb9f8SPhilip Paeps# How to use zic to install TZif files.
463ba2b2efdSGlen Barber
464f2fcff28SPhilip PaepsZIC_INSTALL=	$(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS)
465ba2b2efdSGlen Barber
466eebb9c2cSPhilip Paeps# The name of a POSIX-compliant 'awk' on your system.
4678ea5af2bSPhilip Paeps# mawk 1.3.3 and Solaris 10 /usr/bin/awk do not work.
4688ea5af2bSPhilip Paeps# Also, it is better (though not essential) if 'awk' supports UTF-8,
4698ea5af2bSPhilip Paeps# and unfortunately mawk and busybox awk do not support UTF-8.
4708ea5af2bSPhilip Paeps# Try AWK=gawk or AWK=nawk if your awk has the abovementioned problems.
471ba2b2efdSGlen BarberAWK=		awk
472ba2b2efdSGlen Barber
473eebb9c2cSPhilip Paeps# The full path name of a POSIX-compliant shell, preferably one that supports
474ba2b2efdSGlen Barber# the Korn shell's 'select' statement as an extension.
475ba2b2efdSGlen Barber# These days, Bash is the most popular.
476ba2b2efdSGlen Barber# It should be OK to set this to /bin/sh, on platforms where /bin/sh
477eebb9c2cSPhilip Paeps# lacks 'select' or doesn't completely conform to POSIX, but /bin/bash
478ba2b2efdSGlen Barber# is typically nicer if it works.
479ba2b2efdSGlen BarberKSHELL=		/bin/bash
480ba2b2efdSGlen Barber
4812723c7ffSPhilip Paeps# Name of curl <https://curl.haxx.se/>, used for HTML validation
4822723c7ffSPhilip Paeps# and to fetch leap-seconds.list from upstream.
4832c5e84ccSPhilip PaepsCURL=		curl
4842c5e84ccSPhilip Paeps
4852865ab3fSPhilip Paeps# Name of GNU Privacy Guard <https://gnupg.org/>, used to sign distributions.
4862865ab3fSPhilip PaepsGPG=		gpg
4872865ab3fSPhilip Paeps
488ba2b2efdSGlen Barber# This expensive test requires USE_LTZ.
489ba2b2efdSGlen Barber# To suppress it, define this macro to be empty.
490ba2b2efdSGlen BarberCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
491ba2b2efdSGlen Barber
492ba2b2efdSGlen Barber# SAFE_CHAR is a regular expression that matches a safe character.
493ba2b2efdSGlen Barber# Some parts of this distribution are limited to safe characters;
494ba2b2efdSGlen Barber# others can use any UTF-8 character.
495ba2b2efdSGlen Barber# For now, the safe characters are a safe subset of ASCII.
496ba2b2efdSGlen Barber# The caller must set the shell variable 'sharp' to the character '#',
497ba2b2efdSGlen Barber# since Makefile macros cannot contain '#'.
498ba2b2efdSGlen Barber# TAB_CHAR is a single tab character, in single quotes.
499ba2b2efdSGlen BarberTAB_CHAR=	'	'
500ba2b2efdSGlen BarberSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
501ba2b2efdSGlen BarberSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
502ba2b2efdSGlen BarberSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
503ba2b2efdSGlen BarberSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
504ba2b2efdSGlen BarberSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
505ba2b2efdSGlen Barber
506259e2ad7SPhilip Paeps# These non-alphabetic, non-ASCII printable characters are Latin-1,
507259e2ad7SPhilip Paeps# and so are likely displayable even in editors like XEmacs 21
508259e2ad7SPhilip Paeps# that have limited display capabilities.
509259e2ad7SPhilip PaepsUNUSUAL_OK_LATIN_1 = ¡¢£¤¥¦§¨©«¬®¯°±²³´¶·¸¹»¼½¾¿×÷
51046bee4edSPhilip Paeps# Non-ASCII non-letters that OK_CHAR allows, as these characters are
51189abb9f8SPhilip Paeps# useful in commentary.
512259e2ad7SPhilip PaepsUNUSUAL_OK_CHARSET= $(UNUSUAL_OK_LATIN_1)
51346bee4edSPhilip Paeps
5149f9fc6bbSPhilip Paeps# Put this in a bracket expression to match spaces.
5159f9fc6bbSPhilip Paepss = [:space:]
5169f9fc6bbSPhilip Paeps
517ba2b2efdSGlen Barber# OK_CHAR matches any character allowed in the distributed files.
51846bee4edSPhilip Paeps# This is the same as SAFE_CHAR, except that UNUSUAL_OK_CHARSET and
51946bee4edSPhilip Paeps# multibyte letters are also allowed so that commentary can contain a
52046bee4edSPhilip Paeps# few safe symbols and people's names and can quote non-English sources.
52146bee4edSPhilip Paeps# Other non-letters are limited to ASCII renderings for the
52246bee4edSPhilip Paeps# convenience of maintainers using XEmacs 21.5.34, which by default
52346bee4edSPhilip Paeps# mishandles Unicode characters U+0100 and greater.
52446bee4edSPhilip PaepsOK_CHAR=	'[][:alpha:]$(UNUSUAL_OK_CHARSET)'$(SAFE_CHARSET)'-]'
525ba2b2efdSGlen Barber
526ba2b2efdSGlen Barber# SAFE_LINE matches a line of safe characters.
527ba2b2efdSGlen Barber# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
528ba2b2efdSGlen Barber# this is so that comments can contain non-ASCII characters.
529ba2b2efdSGlen Barber# OK_LINE matches a line of OK characters.
530ba2b2efdSGlen BarberSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
531ba2b2efdSGlen BarberSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
532ba2b2efdSGlen BarberOK_LINE=	'^'$(OK_CHAR)'*$$'
533ba2b2efdSGlen Barber
534ba2b2efdSGlen Barber# Flags to give 'tar' when making a distribution.
535ba2b2efdSGlen Barber# Try to use flags appropriate for GNU tar.
5368ea5af2bSPhilip PaepsGNUTARFLAGS= --format=pax --pax-option='delete=atime,delete=ctime' \
5378ea5af2bSPhilip Paeps  --numeric-owner --owner=0 --group=0 \
5388ea5af2bSPhilip Paeps  --mode=go+u,go-w --sort=name
539ba2b2efdSGlen BarberTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
540ba2b2efdSGlen Barber		 then echo $(GNUTARFLAGS); \
541ba2b2efdSGlen Barber		 else :; \
542ba2b2efdSGlen Barber		 fi`
543ba2b2efdSGlen Barber
544ba2b2efdSGlen Barber# Flags to give 'gzip' when making a distribution.
545ba2b2efdSGlen BarberGZIPFLAGS=	-9n
546ba2b2efdSGlen Barber
547cf1ad535SPhilip Paeps# When comparing .tzs files, use GNU diff's -F'^TZ=' option if supported.
548cf1ad535SPhilip Paeps# This makes it easier to see which Zone has been affected.
549cf1ad535SPhilip PaepsDIFF_TZS=	 diff -u$$(! diff -u -F'^TZ=' - - <>/dev/null >&0 2>&1 \
550cf1ad535SPhilip Paeps			   || echo ' -F^TZ=')
551cf1ad535SPhilip Paeps
552ba2b2efdSGlen Barber# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
553ba2b2efdSGlen BarberRANLIB=		:
554ba2b2efdSGlen Barber
555eebb9c2cSPhilip Paeps# POSIX prohibits defining or using SHELL.  However, csh users on systems
556eebb9c2cSPhilip Paeps# that use the user shell for Makefile commands may need to define SHELL.
557eebb9c2cSPhilip Paeps#SHELL=		/bin/sh
558eebb9c2cSPhilip Paeps
559eebb9c2cSPhilip Paeps# End of macros that one plausibly might want to tailor.
560eebb9c2cSPhilip Paeps###############################################################################
561eebb9c2cSPhilip Paeps
562eebb9c2cSPhilip Paeps
563ba2b2efdSGlen BarberTZCOBJS=	zic.o
5648d7edd17SPhilip PaepsTZDOBJS=	zdump.o localtime.o asctime.o strftime.o
565ba2b2efdSGlen BarberDATEOBJS=	date.o localtime.o strftime.o asctime.o
566dd5f96c4SPhilip PaepsLIBSRCS=	localtime.c asctime.c difftime.c strftime.c
567dd5f96c4SPhilip PaepsLIBOBJS=	localtime.o asctime.o difftime.o strftime.o
568ba2b2efdSGlen BarberHEADERS=	tzfile.h private.h
569ba2b2efdSGlen BarberNONLIBSRCS=	zic.c zdump.c
570dd5f96c4SPhilip PaepsNEWUCBSRCS=	date.c
571ba2b2efdSGlen BarberSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
572ba2b2efdSGlen Barber			tzselect.ksh workman.sh
573ba2b2efdSGlen BarberMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
574ba2b2efdSGlen Barber			tzfile.5 tzselect.8 zic.8 zdump.8
575ba2b2efdSGlen BarberMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
576ba2b2efdSGlen Barber			time2posix.3.txt \
577ba2b2efdSGlen Barber			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
578ba2b2efdSGlen Barber			date.1.txt
5798d7edd17SPhilip PaepsCOMMON=		calendars CONTRIBUTING LICENSE Makefile \
58093d120dbSPhilip Paeps			NEWS README SECURITY theory.html version
581f2fcff28SPhilip PaepsWEB_PAGES=	tz-art.html tz-how-to.html tz-link.html
582ad48359aSPhilip PaepsCHECK_WEB_PAGES=check_theory.html check_tz-art.html \
583ad48359aSPhilip Paeps			check_tz-how-to.html check_tz-link.html
584ba2b2efdSGlen BarberDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
585ba2b2efdSGlen BarberPRIMARY_YDATA=	africa antarctica asia australasia \
586ba2b2efdSGlen Barber		europe northamerica southamerica
587afb91be3SPhilip PaepsYDATA=		$(PRIMARY_YDATA) etcetera
58812a899b6SPhilip PaepsNDATA=		factory
58912a899b6SPhilip PaepsTDATA_TO_CHECK=	$(YDATA) $(NDATA) backward
590afb91be3SPhilip PaepsTDATA=		$(YDATA) $(NDATA) $(BACKWARD)
591eebb9c2cSPhilip PaepsZONETABLES=	zone.tab zone1970.tab zonenow.tab
5928d7edd17SPhilip PaepsTABDATA=	iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
593ba2b2efdSGlen BarberLEAP_DEPS=	leapseconds.awk leap-seconds.list
5949f9fc6bbSPhilip PaepsTZDATA_ZI_DEPS=	ziguard.awk zishrink.awk version $(TDATA) \
5959f9fc6bbSPhilip Paeps		  $(PACKRATDATA) $(PACKRATLIST)
5969f9fc6bbSPhilip PaepsDSTDATA_ZI_DEPS= ziguard.awk $(TDATA) $(PACKRATDATA) $(PACKRATLIST)
597afb91be3SPhilip PaepsDATA=		$(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
59812a899b6SPhilip Paeps			leapseconds $(ZONETABLES)
599eebb9c2cSPhilip PaepsAWK_SCRIPTS=	checklinks.awk checknow.awk checktab.awk leapseconds.awk \
60046bee4edSPhilip Paeps			ziguard.awk zishrink.awk
6015f33eb72SPhilip PaepsMISC=		$(AWK_SCRIPTS)
602ba2b2efdSGlen BarberTZS_YEAR=	2050
60389abb9f8SPhilip PaepsTZS_CUTOFF_FLAG=	-c $(TZS_YEAR)
604ba2b2efdSGlen BarberTZS=		to$(TZS_YEAR).tzs
605ba2b2efdSGlen BarberTZS_NEW=	to$(TZS_YEAR)new.tzs
60694c2d487SPhilip PaepsTZS_DEPS=	$(YDATA) asctime.c localtime.c \
607ba2b2efdSGlen Barber			private.h tzfile.h zdump.c zic.c
6089f9fc6bbSPhilip PaepsTZDATA_DIST = $(COMMON) $(DATA) $(MISC)
60989abb9f8SPhilip Paeps# EIGHT_YARDS is just a yard short of the whole ENCHILADA.
6109f9fc6bbSPhilip PaepsEIGHT_YARDS = $(TZDATA_DIST) $(DOCS) $(SOURCES) tzdata.zi
61189abb9f8SPhilip PaepsENCHILADA = $(EIGHT_YARDS) $(TZS)
612ba2b2efdSGlen Barber
613ba2b2efdSGlen Barber# Consult these files when deciding whether to rebuild the 'version' file.
614ba2b2efdSGlen Barber# This list is not the same as the output of 'git ls-files', since
615ba2b2efdSGlen Barber# .gitignore is not distributed.
616ba2b2efdSGlen BarberVERSION_DEPS= \
61793d120dbSPhilip Paeps		calendars CONTRIBUTING LICENSE Makefile NEWS README SECURITY \
618ba2b2efdSGlen Barber		africa antarctica asctime.c asia australasia \
619ba2b2efdSGlen Barber		backward backzone \
620eebb9c2cSPhilip Paeps		checklinks.awk checknow.awk checktab.awk \
621ba2b2efdSGlen Barber		date.1 date.c difftime.c \
622ba2b2efdSGlen Barber		etcetera europe factory iso3166.tab \
623ba2b2efdSGlen Barber		leap-seconds.list leapseconds.awk localtime.c \
624ba2b2efdSGlen Barber		newctime.3 newstrftime.3 newtzset.3 northamerica \
62512a899b6SPhilip Paeps		private.h southamerica strftime.c theory.html \
626f2fcff28SPhilip Paeps		time2posix.3 tz-art.html tz-how-to.html tz-link.html \
627ba2b2efdSGlen Barber		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
62812a899b6SPhilip Paeps		workman.sh zdump.8 zdump.c zic.8 zic.c \
629d81c2dd9SPhilip Paeps		ziguard.awk zishrink.awk \
630eebb9c2cSPhilip Paeps		zone.tab zone1970.tab zonenow.tab
631ba2b2efdSGlen Barber
63212a899b6SPhilip Paepsall:		tzselect zic zdump libtz.a $(TABDATA) \
63346bee4edSPhilip Paeps		  vanguard.zi main.zi rearguard.zi
634ba2b2efdSGlen Barber
635ba2b2efdSGlen BarberALL:		all date $(ENCHILADA)
636ba2b2efdSGlen Barber
637ba2b2efdSGlen Barberinstall:	all $(DATA) $(REDO) $(MANS)
638f2fcff28SPhilip Paeps		mkdir -p '$(DESTDIR)$(BINDIR)' \
639f2fcff28SPhilip Paeps			'$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
640f2fcff28SPhilip Paeps			'$(DESTDIR)$(LIBDIR)' \
641f2fcff28SPhilip Paeps			'$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
642f2fcff28SPhilip Paeps			'$(DESTDIR)$(MANDIR)/man8'
6432865ab3fSPhilip Paeps		$(ZIC_INSTALL) -l $(LOCALTIME) \
6442865ab3fSPhilip Paeps			`case '$(POSIXRULES)' in ?*) echo '-p';; esac \
6452865ab3fSPhilip Paeps			` $(POSIXRULES) \
646f2fcff28SPhilip Paeps			-t '$(DESTDIR)$(TZDEFAULT)'
647f2fcff28SPhilip Paeps		cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
648f2fcff28SPhilip Paeps		cp tzselect '$(DESTDIR)$(BINDIR)/.'
649f2fcff28SPhilip Paeps		cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
650f2fcff28SPhilip Paeps		cp zic '$(DESTDIR)$(ZICDIR)/.'
651f2fcff28SPhilip Paeps		cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
652f2fcff28SPhilip Paeps		$(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
653f2fcff28SPhilip Paeps		cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
654f2fcff28SPhilip Paeps		cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
655f2fcff28SPhilip Paeps		cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
656ba2b2efdSGlen Barber
657ba2b2efdSGlen BarberINSTALL:	ALL install date.1
658f2fcff28SPhilip Paeps		mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
659f2fcff28SPhilip Paeps		cp date '$(DESTDIR)$(BINDIR)/.'
660f2fcff28SPhilip Paeps		cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
661ba2b2efdSGlen Barber
662dc505d53SPhilip Paeps# Calculate version number from git, if available.
663dc505d53SPhilip Paeps# Otherwise, use $(VERSION) unless it is "unknown" and there is already
664dc505d53SPhilip Paeps# a 'version' file, in which case reuse the existing 'version' contents
665dc505d53SPhilip Paeps# and append "-dirty" if the contents do not already end in "-dirty".
666ba2b2efdSGlen Barberversion:	$(VERSION_DEPS)
667ba2b2efdSGlen Barber		{ (type git) >/dev/null 2>&1 && \
668ba2b2efdSGlen Barber		  V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
669ba2b2efdSGlen Barber				--abbrev=7 --dirty` || \
670dc505d53SPhilip Paeps		  if test '$(VERSION)' = unknown && V=`cat $@`; then \
671dc505d53SPhilip Paeps		    case $$V in *-dirty);; *) V=$$V-dirty;; esac; \
672dc505d53SPhilip Paeps		  else \
673dc505d53SPhilip Paeps		    V='$(VERSION)'; \
674dc505d53SPhilip Paeps		  fi; } && \
675ba2b2efdSGlen Barber		printf '%s\n' "$$V" >$@.out
676ba2b2efdSGlen Barber		mv $@.out $@
677ba2b2efdSGlen Barber
6789f9fc6bbSPhilip Paeps# These files can be tailored by setting BACKWARD, PACKRATDATA, PACKRATLIST.
67946bee4edSPhilip Paepsvanguard.zi main.zi rearguard.zi: $(DSTDATA_ZI_DEPS)
6809f9fc6bbSPhilip Paeps		$(AWK) \
6819f9fc6bbSPhilip Paeps		  -v DATAFORM=`expr $@ : '\(.*\).zi'` \
6829f9fc6bbSPhilip Paeps		  -v PACKRATDATA='$(PACKRATDATA)' \
6839f9fc6bbSPhilip Paeps		  -v PACKRATLIST='$(PACKRATLIST)' \
6849f9fc6bbSPhilip Paeps		  -f ziguard.awk \
685d81c2dd9SPhilip Paeps		  $(TDATA) $(PACKRATDATA) >$@.out
68646bee4edSPhilip Paeps		mv $@.out $@
68789abb9f8SPhilip Paeps# This file has a version comment that attempts to capture any tailoring
6889f9fc6bbSPhilip Paeps# via BACKWARD, DATAFORM, PACKRATDATA, PACKRATLIST, and REDO.
68989abb9f8SPhilip Paepstzdata.zi:	$(DATAFORM).zi version zishrink.awk
690f2fcff28SPhilip Paeps		version=`sed 1q version` && \
69189abb9f8SPhilip Paeps		  LC_ALL=C $(AWK) \
69289abb9f8SPhilip Paeps		    -v dataform='$(DATAFORM)' \
69389abb9f8SPhilip Paeps		    -v deps='$(DSTDATA_ZI_DEPS) zishrink.awk' \
69489abb9f8SPhilip Paeps		    -v redo='$(REDO)' \
69589abb9f8SPhilip Paeps		    -v version="$$version" \
69689abb9f8SPhilip Paeps		    -f zishrink.awk \
69746bee4edSPhilip Paeps		    $(DATAFORM).zi >$@.out
6988d7edd17SPhilip Paeps		mv $@.out $@
6998d7edd17SPhilip Paeps
700eebb9c2cSPhilip Paepstzdir.h:
701eebb9c2cSPhilip Paeps		printf '%s\n' >$@.out \
702eebb9c2cSPhilip Paeps		  '#ifndef TZDEFAULT' \
703eebb9c2cSPhilip Paeps		  '# define TZDEFAULT "$(TZDEFAULT)" /* default zone */' \
704eebb9c2cSPhilip Paeps		  '#endif' \
705eebb9c2cSPhilip Paeps		  '#ifndef TZDIR' \
706eebb9c2cSPhilip Paeps		  '# define TZDIR "$(TZDIR)" /* TZif directory */' \
707eebb9c2cSPhilip Paeps		  '#endif'
708eebb9c2cSPhilip Paeps		mv $@.out $@
709eebb9c2cSPhilip Paeps
710ba2b2efdSGlen Barberversion.h:	version
711ba2b2efdSGlen Barber		VERSION=`cat version` && printf '%s\n' \
712ba2b2efdSGlen Barber		  'static char const PKGVERSION[]="($(PACKAGE)) ";' \
713ba2b2efdSGlen Barber		  "static char const TZVERSION[]=\"$$VERSION\";" \
714ba2b2efdSGlen Barber		  'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
715ba2b2efdSGlen Barber		  >$@.out
716ba2b2efdSGlen Barber		mv $@.out $@
717ba2b2efdSGlen Barber
718ba2b2efdSGlen Barberzdump:		$(TZDOBJS)
719ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
720ba2b2efdSGlen Barber
721ba2b2efdSGlen Barberzic:		$(TZCOBJS)
722ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
723ba2b2efdSGlen Barber
724ba2b2efdSGlen Barberleapseconds:	$(LEAP_DEPS)
725dd5f96c4SPhilip Paeps		$(AWK) -v EXPIRES_LINE=$(EXPIRES_LINE) \
726dd5f96c4SPhilip Paeps		  -f leapseconds.awk leap-seconds.list >$@.out
727ba2b2efdSGlen Barber		mv $@.out $@
728ba2b2efdSGlen Barber
7292723c7ffSPhilip Paeps# Awk script to extract a Git-style author from leap-seconds.list comments.
7302723c7ffSPhilip PaepsEXTRACT_AUTHOR = \
7312723c7ffSPhilip Paeps  author_line { sub(/^.[[:space:]]*/, ""); \
7322723c7ffSPhilip Paeps      sub(/:[[:space:]]*/, " <"); \
7332723c7ffSPhilip Paeps      printf "%s>\n", $$0; \
7342723c7ffSPhilip Paeps      success = 1; \
7352723c7ffSPhilip Paeps      exit \
7362723c7ffSPhilip Paeps  } \
7372723c7ffSPhilip Paeps  /Questions or comments to:/ { author_line = 1 } \
7382723c7ffSPhilip Paeps  END { exit !success }
7392723c7ffSPhilip Paeps
7402723c7ffSPhilip Paeps# Fetch leap-seconds.list from upstream.
7412723c7ffSPhilip Paepsfetch-leap-seconds.list:
7422723c7ffSPhilip Paeps		$(CURL) -OR $(leaplist_URI)
7432723c7ffSPhilip Paeps
7442723c7ffSPhilip Paeps# Fetch leap-seconds.list from upstream and commit it to the local repository.
7452723c7ffSPhilip Paepscommit-leap-seconds.list: fetch-leap-seconds.list
7462723c7ffSPhilip Paeps		author=$$($(AWK) '$(EXTRACT_AUTHOR)' leap-seconds.list) && \
7472723c7ffSPhilip Paeps		date=$$(TZ=$(leaplist_TZ) stat -c%y leap-seconds.list) && \
7482723c7ffSPhilip Paeps		git commit --author="$$author" --date="$$date" -m'make $@' \
7492723c7ffSPhilip Paeps		  leap-seconds.list
7502723c7ffSPhilip Paeps
751ba2b2efdSGlen Barber# Arguments to pass to submakes of install_data.
752ba2b2efdSGlen Barber# They can be overridden by later submake arguments.
753ba2b2efdSGlen BarberINSTALLARGS = \
754f2fcff28SPhilip Paeps BACKWARD='$(BACKWARD)' \
755f2fcff28SPhilip Paeps DESTDIR='$(DESTDIR)' \
756ba2b2efdSGlen Barber LEAPSECONDS='$(LEAPSECONDS)' \
757ba2b2efdSGlen Barber PACKRATDATA='$(PACKRATDATA)' \
7589f9fc6bbSPhilip Paeps PACKRATLIST='$(PACKRATLIST)' \
759f2fcff28SPhilip Paeps TZDEFAULT='$(TZDEFAULT)' \
760f2fcff28SPhilip Paeps TZDIR='$(TZDIR)' \
761ba2b2efdSGlen Barber ZIC='$(ZIC)'
762ba2b2efdSGlen Barber
76312a899b6SPhilip PaepsINSTALL_DATA_DEPS = zic leapseconds tzdata.zi
76489abb9f8SPhilip Paeps
76589abb9f8SPhilip Paeps# 'make install_data' installs one set of TZif files.
76689abb9f8SPhilip Paepsinstall_data: $(INSTALL_DATA_DEPS)
7678d7edd17SPhilip Paeps		$(ZIC_INSTALL) tzdata.zi
768ba2b2efdSGlen Barber
76989abb9f8SPhilip Paepsposix_only: $(INSTALL_DATA_DEPS)
770ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
771ba2b2efdSGlen Barber
77289abb9f8SPhilip Paepsright_only: $(INSTALL_DATA_DEPS)
773ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
774ba2b2efdSGlen Barber			install_data
775ba2b2efdSGlen Barber
776ba2b2efdSGlen Barber# In earlier versions of this makefile, the other two directories were
777ba2b2efdSGlen Barber# subdirectories of $(TZDIR).  However, this led to configuration errors.
778ba2b2efdSGlen Barber# For example, with posix_right under the earlier scheme,
779ba2b2efdSGlen Barber# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
780ba2b2efdSGlen Barber# but gmtime without leap seconds, which led to problems with applications
781ba2b2efdSGlen Barber# like sendmail that subtract gmtime from localtime.
782ba2b2efdSGlen Barber# Therefore, the other two directories are now siblings of $(TZDIR).
783ba2b2efdSGlen Barber# You must replace all of $(TZDIR) to switch from not using leap seconds
784ba2b2efdSGlen Barber# to using them, or vice versa.
785ba2b2efdSGlen Barberright_posix:	right_only
786f2fcff28SPhilip Paeps		rm -fr '$(DESTDIR)$(TZDIR)-leaps'
787f2fcff28SPhilip Paeps		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
788f2fcff28SPhilip Paeps		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
789f2fcff28SPhilip Paeps		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
790ba2b2efdSGlen Barber
791ba2b2efdSGlen Barberposix_right:	posix_only
792f2fcff28SPhilip Paeps		rm -fr '$(DESTDIR)$(TZDIR)-posix'
793f2fcff28SPhilip Paeps		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
794f2fcff28SPhilip Paeps		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
795f2fcff28SPhilip Paeps		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
796ba2b2efdSGlen Barber
797ba2b2efdSGlen Barberzones:		$(REDO)
798ba2b2efdSGlen Barber
79946bee4edSPhilip Paeps# dummy.zd is not a real file; it is mentioned here only so that the
80046bee4edSPhilip Paeps# top-level 'make' does not have a syntax error.
80146bee4edSPhilip PaepsZDS = dummy.zd
80246bee4edSPhilip Paeps# Rule used only by submakes invoked by the $(TZS_NEW) rule.
80346bee4edSPhilip Paeps# It is separate so that GNU 'make -j' can run instances in parallel.
80446bee4edSPhilip Paeps$(ZDS): zdump
80589abb9f8SPhilip Paeps		./zdump -i $(TZS_CUTOFF_FLAG) '$(wd)/'$$(expr $@ : '\(.*\).zd') \
80689abb9f8SPhilip Paeps		  >$@
80746bee4edSPhilip Paeps
80889abb9f8SPhilip PaepsTZS_NEW_DEPS = tzdata.zi zdump zic
80989abb9f8SPhilip Paeps$(TZS_NEW): $(TZS_NEW_DEPS)
81089abb9f8SPhilip Paeps		rm -fr tzs$(TZS_YEAR).dir
81189abb9f8SPhilip Paeps		mkdir tzs$(TZS_YEAR).dir
81289abb9f8SPhilip Paeps		$(zic) -d tzs$(TZS_YEAR).dir tzdata.zi
8138d7edd17SPhilip Paeps		$(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
8148d7edd17SPhilip Paeps		   tzdata.zi | LC_ALL=C sort >$@.out
815ba2b2efdSGlen Barber		wd=`pwd` && \
81689abb9f8SPhilip Paeps		x=`$(AWK) '/^Z/{print "tzs$(TZS_YEAR).dir/" $$2 ".zd"}' \
81789abb9f8SPhilip Paeps				tzdata.zi \
81846bee4edSPhilip Paeps			| LC_ALL=C sort -t . -k 2,2` && \
81989abb9f8SPhilip Paeps		set x $$x && \
82046bee4edSPhilip Paeps		shift && \
82146bee4edSPhilip Paeps		ZDS=$$* && \
82289abb9f8SPhilip Paeps		$(MAKE) wd="$$wd" TZS_CUTOFF_FLAG="$(TZS_CUTOFF_FLAG)" \
82389abb9f8SPhilip Paeps		  ZDS="$$ZDS" $$ZDS && \
82489abb9f8SPhilip Paeps		sed 's,^TZ=".*\.dir/,TZ=",' $$ZDS >>$@.out
82589abb9f8SPhilip Paeps		rm -fr tzs$(TZS_YEAR).dir
82646bee4edSPhilip Paeps		mv $@.out $@
827ba2b2efdSGlen Barber
82889abb9f8SPhilip Paeps# If $(TZS) exists but 'make check_tzs' fails, a maintainer should inspect the
829ba2b2efdSGlen Barber# failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
830ba2b2efdSGlen Barber$(TZS):
83189abb9f8SPhilip Paeps		touch $@
832ba2b2efdSGlen Barber
833ba2b2efdSGlen Barberforce_tzs:	$(TZS_NEW)
834ba2b2efdSGlen Barber		cp $(TZS_NEW) $(TZS)
835ba2b2efdSGlen Barber
836ba2b2efdSGlen Barberlibtz.a:	$(LIBOBJS)
837e350c46aSBaptiste Daroussin		rm -f $@
838eebb9c2cSPhilip Paeps		$(AR) $(ARFLAGS) $@ $(LIBOBJS)
839ba2b2efdSGlen Barber		$(RANLIB) $@
840ba2b2efdSGlen Barber
841ba2b2efdSGlen Barberdate:		$(DATEOBJS)
842ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
843ba2b2efdSGlen Barber
844ba2b2efdSGlen Barbertzselect:	tzselect.ksh version
845ba2b2efdSGlen Barber		VERSION=`cat version` && sed \
846eebb9c2cSPhilip Paeps		  -e "s'#!/bin/bash'#!"'$(KSHELL)'\' \
847eebb9c2cSPhilip Paeps		  -e s\''\(AWK\)=[^}]*'\''\1=\'\''$(AWK)\'\'\' \
848eebb9c2cSPhilip Paeps		  -e s\''\(PKGVERSION\)=.*'\''\1=\'\''($(PACKAGE)) \'\'\' \
849eebb9c2cSPhilip Paeps		  -e s\''\(REPORT_BUGS_TO\)=.*'\''\1=\'\''$(BUGEMAIL)\'\'\' \
850eebb9c2cSPhilip Paeps		  -e s\''\(TZDIR\)=[^}]*'\''\1=\'\''$(TZDIR)\'\'\' \
851eebb9c2cSPhilip Paeps		  -e s\''\(TZVERSION\)=.*'\''\1=\'"'$$VERSION\\''" \
852ba2b2efdSGlen Barber		  <$@.ksh >$@.out
853ba2b2efdSGlen Barber		chmod +x $@.out
854ba2b2efdSGlen Barber		mv $@.out $@
855ba2b2efdSGlen Barber
856cf1ad535SPhilip Paepscheck: check_back check_mild
857cf1ad535SPhilip Paepscheck_mild:	check_character_set check_white_space check_links \
858eebb9c2cSPhilip Paeps		  check_name_lengths check_now \
859eebb9c2cSPhilip Paeps		  check_slashed_abbrs check_sorted \
8609f9fc6bbSPhilip Paeps		  check_tables check_web check_ziguard check_zishrink check_tzs
861ba2b2efdSGlen Barber
862eebb9c2cSPhilip Paeps# True if UTF8_LOCALE does not work;
863eebb9c2cSPhilip Paeps# otherwise, false but with LC_ALL set to $(UTF8_LOCALE).
864eebb9c2cSPhilip PaepsUTF8_LOCALE_MISSING = \
865eebb9c2cSPhilip Paeps  { test ! '$(UTF8_LOCALE)' \
866eebb9c2cSPhilip Paeps    || ! printf 'A\304\200B\n' \
867eebb9c2cSPhilip Paeps         | LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 \
868eebb9c2cSPhilip Paeps    || { LC_ALL='$(UTF8_LOCALE)'; export LC_ALL; false; }; }
869eebb9c2cSPhilip Paeps
870ba2b2efdSGlen Barbercheck_character_set: $(ENCHILADA)
871eebb9c2cSPhilip Paeps	$(UTF8_LOCALE_MISSING) || { \
872ba2b2efdSGlen Barber		sharp='#' && \
873ba2b2efdSGlen Barber		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
874ba2b2efdSGlen Barber			$(MISC) $(SOURCES) $(WEB_PAGES) \
87593d120dbSPhilip Paeps			CONTRIBUTING LICENSE README SECURITY \
8768d7edd17SPhilip Paeps			version tzdata.zi && \
87789abb9f8SPhilip Paeps		! grep -Env $(SAFE_LINE)'|^UNUSUAL_OK_'$(OK_CHAR)'*$$' \
87846bee4edSPhilip Paeps			Makefile && \
879afb91be3SPhilip Paeps		! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
88012a899b6SPhilip Paeps			leapseconds zone.tab && \
8818d7edd17SPhilip Paeps		! grep -Env $(OK_LINE) $(ENCHILADA); \
8828d7edd17SPhilip Paeps	}
88389abb9f8SPhilip Paeps	touch $@
884ba2b2efdSGlen Barber
885ba2b2efdSGlen Barbercheck_white_space: $(ENCHILADA)
886eebb9c2cSPhilip Paeps	$(UTF8_LOCALE_MISSING) || { \
887ba2b2efdSGlen Barber		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
888eebb9c2cSPhilip Paeps		! grep -En "$$pat|[$s]\$$" \
889eebb9c2cSPhilip Paeps			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list); \
890eebb9c2cSPhilip Paeps	}
89189abb9f8SPhilip Paeps	touch $@
892ba2b2efdSGlen Barber
8939f9fc6bbSPhilip PaepsPRECEDES_FILE_NAME = ^(Zone|Link[$s]+[^$s]+)[$s]+
8949f9fc6bbSPhilip PaepsFILE_NAME_COMPONENT_TOO_LONG = $(PRECEDES_FILE_NAME)[^$s]*[^/$s]{15}
8958d7edd17SPhilip Paeps
896afb91be3SPhilip Paepscheck_name_lengths: $(TDATA_TO_CHECK) backzone
897afb91be3SPhilip Paeps		! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
898afb91be3SPhilip Paeps			$(TDATA_TO_CHECK) backzone
89989abb9f8SPhilip Paeps		touch $@
9008d7edd17SPhilip Paeps
9019f9fc6bbSPhilip PaepsPRECEDES_STDOFF = ^(Zone[$s]+[^$s]+)?[$s]+
9029f9fc6bbSPhilip PaepsSTDOFF = [-+]?[0-9:.]+
9039f9fc6bbSPhilip PaepsRULELESS_SAVE = (-|$(STDOFF)[sd]?)
9049f9fc6bbSPhilip PaepsRULELESS_SLASHED_ABBRS = \
9059f9fc6bbSPhilip Paeps  $(PRECEDES_STDOFF)$(STDOFF)[$s]+$(RULELESS_SAVE)[$s]+[^$s]*/
9069f9fc6bbSPhilip Paeps
9079f9fc6bbSPhilip Paepscheck_slashed_abbrs: $(TDATA_TO_CHECK)
9089f9fc6bbSPhilip Paeps		! grep -En '$(RULELESS_SLASHED_ABBRS)' $(TDATA_TO_CHECK)
9099f9fc6bbSPhilip Paeps		touch $@
9109f9fc6bbSPhilip Paeps
911ba2b2efdSGlen BarberCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
912ba2b2efdSGlen Barber
913259e2ad7SPhilip Paepscheck_sorted: backward backzone
914cf1ad535SPhilip Paeps		$(AWK) '/^Link/ {printf "%.5d %s\n", g, $$3} !/./ {g++}' \
9159142a2a3SPhilip Paeps		  backward | LC_ALL=C sort -cu
916ba2b2efdSGlen Barber		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
91789abb9f8SPhilip Paeps		touch $@
918ba2b2efdSGlen Barber
919cf1ad535SPhilip Paepscheck_back:	checklinks.awk $(TDATA_TO_CHECK)
9209142a2a3SPhilip Paeps		$(AWK) \
9219142a2a3SPhilip Paeps		  -v DATAFORM=$(DATAFORM) \
9229142a2a3SPhilip Paeps		  -v backcheck=backward \
9239142a2a3SPhilip Paeps		  -f checklinks.awk $(TDATA_TO_CHECK)
924cf1ad535SPhilip Paeps		touch $@
925cf1ad535SPhilip Paeps
926cf1ad535SPhilip Paepscheck_links:	checklinks.awk tzdata.zi
9279142a2a3SPhilip Paeps		$(AWK) \
9289142a2a3SPhilip Paeps		  -v DATAFORM=$(DATAFORM) \
9299142a2a3SPhilip Paeps		  -f checklinks.awk tzdata.zi
93089abb9f8SPhilip Paeps		touch $@
931ba2b2efdSGlen Barber
932eebb9c2cSPhilip Paeps# Check timestamps from now through 28 years from now, to make sure
933eebb9c2cSPhilip Paeps# that zonenow.tab contains all sequences of planned timestamps,
934eebb9c2cSPhilip Paeps# without any duplicate sequences.  In theory this might require
935eebb9c2cSPhilip Paeps# 2800 years but that would take a long time to check.
936eebb9c2cSPhilip PaepsCHECK_NOW_TIMESTAMP = `./date +%s`
937eebb9c2cSPhilip PaepsCHECK_NOW_FUTURE_YEARS = 28
938eebb9c2cSPhilip PaepsCHECK_NOW_FUTURE_SECS = $(CHECK_NOW_FUTURE_YEARS) '*' 366 '*' 24 '*' 60 '*' 60
939eebb9c2cSPhilip Paepscheck_now:	checknow.awk date tzdata.zi zdump zic zone1970.tab zonenow.tab
940eebb9c2cSPhilip Paeps		rm -fr $@.dir
941eebb9c2cSPhilip Paeps		mkdir $@.dir
942eebb9c2cSPhilip Paeps		./zic -d $@.dir tzdata.zi
943eebb9c2cSPhilip Paeps		now=$(CHECK_NOW_TIMESTAMP) && \
944eebb9c2cSPhilip Paeps		  future=`expr $(CHECK_NOW_FUTURE_SECS) + $$now` && \
945eebb9c2cSPhilip Paeps		  ./zdump -i -t $$now,$$future \
946eebb9c2cSPhilip Paeps		     $$(find $$PWD/$@.dir/????*/ -type f) \
947eebb9c2cSPhilip Paeps		     >$@.dir/zdump.tab
948eebb9c2cSPhilip Paeps		$(AWK) \
949eebb9c2cSPhilip Paeps		  -v zdump_table=$@.dir/zdump.tab \
950eebb9c2cSPhilip Paeps		  -f checknow.awk zonenow.tab
951eebb9c2cSPhilip Paeps		rm -fr $@.dir
952eebb9c2cSPhilip Paeps		touch $@
953eebb9c2cSPhilip Paeps
954eebb9c2cSPhilip Paepscheck_tables:	checktab.awk $(YDATA) backward zone.tab zone1970.tab
955ba2b2efdSGlen Barber		for tab in $(ZONETABLES); do \
95694c2d487SPhilip Paeps		  test "$$tab" = zone.tab && links='$(BACKWARD)' || links=''; \
95794c2d487SPhilip Paeps		  $(AWK) -f checktab.awk -v zone_table=$$tab $(YDATA) $$links \
958ba2b2efdSGlen Barber		    || exit; \
959ba2b2efdSGlen Barber		done
96089abb9f8SPhilip Paeps		touch $@
961ba2b2efdSGlen Barber
962ba2b2efdSGlen Barbercheck_tzs:	$(TZS) $(TZS_NEW)
96389abb9f8SPhilip Paeps		if test -s $(TZS); then \
964cf1ad535SPhilip Paeps		  $(DIFF_TZS) $(TZS) $(TZS_NEW); \
96589abb9f8SPhilip Paeps		else \
96689abb9f8SPhilip Paeps		  cp $(TZS_NEW) $(TZS); \
96789abb9f8SPhilip Paeps		fi
96889abb9f8SPhilip Paeps		touch $@
969ba2b2efdSGlen Barber
9702c5e84ccSPhilip Paepscheck_web:	$(CHECK_WEB_PAGES)
971ad48359aSPhilip Paepscheck_theory.html: theory.html
9722c5e84ccSPhilip Paepscheck_tz-art.html: tz-art.html
97312a899b6SPhilip Paepscheck_tz-how-to.html: tz-how-to.html
9742c5e84ccSPhilip Paepscheck_tz-link.html: tz-link.html
97512a899b6SPhilip Paepscheck_theory.html check_tz-art.html check_tz-how-to.html check_tz-link.html:
9762c5e84ccSPhilip Paeps		$(CURL) -sS --url https://validator.w3.org/nu/ -F out=gnu \
9772c5e84ccSPhilip Paeps		    -F file=@$$(expr $@ : 'check_\(.*\)') -o $@.out && \
9782c5e84ccSPhilip Paeps		  test ! -s $@.out || { cat $@.out; exit 1; }
9792c5e84ccSPhilip Paeps		mv $@.out $@
9808d7edd17SPhilip Paeps
9819f9fc6bbSPhilip Paepscheck_ziguard: rearguard.zi vanguard.zi ziguard.awk
9829f9fc6bbSPhilip Paeps		$(AWK) -v DATAFORM=rearguard -f ziguard.awk vanguard.zi | \
9839f9fc6bbSPhilip Paeps		  diff -u rearguard.zi -
9849f9fc6bbSPhilip Paeps		$(AWK) -v DATAFORM=vanguard -f ziguard.awk rearguard.zi | \
9859f9fc6bbSPhilip Paeps		  diff -u vanguard.zi -
9869f9fc6bbSPhilip Paeps		touch $@
9879f9fc6bbSPhilip Paeps
98846bee4edSPhilip Paeps# Check that zishrink.awk does not alter the data, and that ziguard.awk
98946bee4edSPhilip Paeps# preserves main-format data.
99089abb9f8SPhilip Paepscheck_zishrink: check_zishrink_posix check_zishrink_right
99189abb9f8SPhilip Paepscheck_zishrink_posix check_zishrink_right: \
9929f9fc6bbSPhilip Paeps  zic leapseconds $(PACKRATDATA) $(PACKRATLIST) \
9939f9fc6bbSPhilip Paeps  $(TDATA) $(DATAFORM).zi tzdata.zi
99489abb9f8SPhilip Paeps		rm -fr $@.dir $@-t.dir $@-shrunk.dir
99589abb9f8SPhilip Paeps		mkdir $@.dir $@-t.dir $@-shrunk.dir
99689abb9f8SPhilip Paeps		case $@ in \
99789abb9f8SPhilip Paeps		  *_right) leap='-L leapseconds';; \
9988d7edd17SPhilip Paeps		  *) leap=;; \
9998d7edd17SPhilip Paeps		esac && \
100089abb9f8SPhilip Paeps		  $(ZIC) $$leap -d $@.dir $(DATAFORM).zi && \
100189abb9f8SPhilip Paeps		  $(ZIC) $$leap -d $@-shrunk.dir tzdata.zi && \
10029f9fc6bbSPhilip Paeps		  case $(DATAFORM),$(PACKRATLIST) in \
10039f9fc6bbSPhilip Paeps		    main,) \
100489abb9f8SPhilip Paeps		      $(ZIC) $$leap -d $@-t.dir $(TDATA) && \
10058d7edd17SPhilip Paeps		      $(AWK) '/^Rule/' $(TDATA) | \
100689abb9f8SPhilip Paeps			$(ZIC) $$leap -d $@-t.dir - $(PACKRATDATA) && \
100789abb9f8SPhilip Paeps		      diff -r $@.dir $@-t.dir;; \
100889abb9f8SPhilip Paeps		  esac
100989abb9f8SPhilip Paeps		diff -r $@.dir $@-shrunk.dir
101089abb9f8SPhilip Paeps		rm -fr $@.dir $@-t.dir $@-shrunk.dir
101189abb9f8SPhilip Paeps		touch $@
1012ba2b2efdSGlen Barber
1013ba2b2efdSGlen Barberclean_misc:
1014eebb9c2cSPhilip Paeps		rm -fr check_*.dir typecheck_*.dir
101589abb9f8SPhilip Paeps		rm -f *.o *.out $(TIME_T_ALTERNATIVES) \
101689abb9f8SPhilip Paeps		  check_* core typecheck_* \
1017eebb9c2cSPhilip Paeps		  date tzdir.h tzselect version.h zdump zic libtz.a
1018ba2b2efdSGlen Barberclean:		clean_misc
1019ad48359aSPhilip Paeps		rm -fr *.dir tzdb-*/
1020ad48359aSPhilip Paeps		rm -f *.zi $(TZS_NEW)
1021ba2b2efdSGlen Barber
1022ba2b2efdSGlen Barbermaintainer-clean: clean
1023ba2b2efdSGlen Barber		@echo 'This command is intended for maintainers to use; it'
1024ba2b2efdSGlen Barber		@echo 'deletes files that may need special tools to rebuild.'
1025ba2b2efdSGlen Barber		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
1026ba2b2efdSGlen Barber
1027ba2b2efdSGlen Barbernames:
1028ba2b2efdSGlen Barber		@echo $(ENCHILADA)
1029ba2b2efdSGlen Barber
1030ba2b2efdSGlen Barberpublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
1031ba2b2efdSGlen Barber		tarballs signatures
1032ba2b2efdSGlen Barber
1033ba2b2efdSGlen Barberdate.1.txt:	date.1
1034ba2b2efdSGlen Barbernewctime.3.txt:	newctime.3
1035ba2b2efdSGlen Barbernewstrftime.3.txt: newstrftime.3
1036ba2b2efdSGlen Barbernewtzset.3.txt:	newtzset.3
1037ba2b2efdSGlen Barbertime2posix.3.txt: time2posix.3
1038ba2b2efdSGlen Barbertzfile.5.txt:	tzfile.5
1039ba2b2efdSGlen Barbertzselect.8.txt:	tzselect.8
1040ba2b2efdSGlen Barberzdump.8.txt:	zdump.8
1041ba2b2efdSGlen Barberzic.8.txt:	zic.8
1042ba2b2efdSGlen Barber
1043ba2b2efdSGlen Barber$(MANTXTS):	workman.sh
1044ba2b2efdSGlen Barber		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out
1045ba2b2efdSGlen Barber		mv $@.out $@
1046ba2b2efdSGlen Barber
1047dc505d53SPhilip Paeps# Set file timestamps deterministically if possible,
1048dc505d53SPhilip Paeps# so that tarballs containing the timestamps are reproducible.
1049dc505d53SPhilip Paeps#
1050dc505d53SPhilip Paeps# '$(SET_TIMESTAMP_N) N DEST A B C ...' sets the timestamp of the
1051dc505d53SPhilip Paeps# file DEST to the maximum of the timestamps of the files A B C ...,
1052dc505d53SPhilip Paeps# plus N if GNU ls and touch are available.
1053dc505d53SPhilip PaepsSET_TIMESTAMP_N = sh -c '\
1054dc505d53SPhilip Paeps  n=$$0 dest=$$1; shift; \
1055eebb9c2cSPhilip Paeps  <"$$dest" && \
1056dc505d53SPhilip Paeps  if test $$n != 0 && \
1057eebb9c2cSPhilip Paeps     lsout=`ls -nt --time-style="+%s" "$$@" 2>/dev/null`; then \
1058dc505d53SPhilip Paeps    set x $$lsout && \
1059eebb9c2cSPhilip Paeps    timestamp=`expr $$7 + $$n` && \
1060eebb9c2cSPhilip Paeps    echo "+ touch -md @$$timestamp $$dest" && \
1061eebb9c2cSPhilip Paeps    touch -md @$$timestamp "$$dest"; \
1062eebb9c2cSPhilip Paeps  else \
1063eebb9c2cSPhilip Paeps    newest=`ls -t "$$@" | sed 1q` && \
1064eebb9c2cSPhilip Paeps    echo "+ touch -mr $$newest $$dest" && \
1065eebb9c2cSPhilip Paeps    touch -mr "$$newest" "$$dest"; \
1066eebb9c2cSPhilip Paeps  fi'
1067dc505d53SPhilip Paeps# If DEST depends on A B C ... in this Makefile, callers should use
1068dc505d53SPhilip Paeps# $(SET_TIMESTAMP_DEP) DEST A B C ..., for the benefit of any
1069dc505d53SPhilip Paeps# downstream 'make' that considers equal timestamps to be out of date.
1070dc505d53SPhilip Paeps# POSIX allows this 'make' behavior, and HP-UX 'make' does it.
1071dc505d53SPhilip Paeps# If all that matters is that the timestamp be reproducible
1072dc505d53SPhilip Paeps# and plausible, use $(SET_TIMESTAMP).
1073dc505d53SPhilip PaepsSET_TIMESTAMP = $(SET_TIMESTAMP_N) 0
1074dc505d53SPhilip PaepsSET_TIMESTAMP_DEP = $(SET_TIMESTAMP_N) 1
1075dc505d53SPhilip Paeps
1076ba2b2efdSGlen Barber# Set the timestamps to those of the git repository, if available,
1077ba2b2efdSGlen Barber# and if the files have not changed since then.
1078dc505d53SPhilip Paeps# This uses GNU 'ls --time-style=+%s', which outputs the seconds count,
1079dc505d53SPhilip Paeps# and GNU 'touch -d@N FILE', where N is the number of seconds since 1970.
1080dc505d53SPhilip Paeps# If git or GNU is absent, don't bother to sync with git timestamps.
1081ba2b2efdSGlen Barber# Also, set the timestamp of each prebuilt file like 'leapseconds'
1082ba2b2efdSGlen Barber# to be the maximum of the files it depends on.
108389abb9f8SPhilip Paepsset-timestamps.out: $(EIGHT_YARDS)
1084ba2b2efdSGlen Barber		rm -f $@
1085ba2b2efdSGlen Barber		if (type git) >/dev/null 2>&1 && \
108689abb9f8SPhilip Paeps		   files=`git ls-files $(EIGHT_YARDS)` && \
1087ba2b2efdSGlen Barber		   touch -md @1 test.out; then \
1088ba2b2efdSGlen Barber		  rm -f test.out && \
1089ba2b2efdSGlen Barber		  for file in $$files; do \
1090ba2b2efdSGlen Barber		    if git diff --quiet $$file; then \
1091eebb9c2cSPhilip Paeps		      time=`TZ=UTC0 git log -1 \
1092eebb9c2cSPhilip Paeps			--format='tformat:%cd' \
1093eebb9c2cSPhilip Paeps			--date='format:%Y-%m-%dT%H:%M:%SZ' \
1094eebb9c2cSPhilip Paeps			$$file` && \
1095eebb9c2cSPhilip Paeps		      echo "+ touch -md $$time $$file" && \
1096eebb9c2cSPhilip Paeps		      touch -md $$time $$file; \
1097ba2b2efdSGlen Barber		    else \
1098ba2b2efdSGlen Barber		      echo >&2 "$$file: warning: does not match repository"; \
1099ba2b2efdSGlen Barber		    fi || exit; \
1100ba2b2efdSGlen Barber		  done; \
1101ba2b2efdSGlen Barber		fi
1102dc505d53SPhilip Paeps		$(SET_TIMESTAMP_DEP) leapseconds $(LEAP_DEPS)
1103ba2b2efdSGlen Barber		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
1104dc505d53SPhilip Paeps		  $(SET_TIMESTAMP_DEP) $$file.txt $$file workman.sh || \
1105ba2b2efdSGlen Barber		    exit; \
1106ba2b2efdSGlen Barber		done
1107dc505d53SPhilip Paeps		$(SET_TIMESTAMP_DEP) version $(VERSION_DEPS)
1108dc505d53SPhilip Paeps		$(SET_TIMESTAMP_DEP) tzdata.zi $(TZDATA_ZI_DEPS)
1109ba2b2efdSGlen Barber		touch $@
111089abb9f8SPhilip Paepsset-tzs-timestamp.out: $(TZS)
1111dc505d53SPhilip Paeps		$(SET_TIMESTAMP_DEP) $(TZS) $(TZS_DEPS)
111289abb9f8SPhilip Paeps		touch $@
1113ba2b2efdSGlen Barber
1114ba2b2efdSGlen Barber# The zics below ensure that each data file can stand on its own.
1115ba2b2efdSGlen Barber# We also do an all-files run to catch links to links.
1116ba2b2efdSGlen Barber
111789abb9f8SPhilip Paepscheck_public: $(VERSION_DEPS)
1118ba2b2efdSGlen Barber		rm -fr public.dir
111989abb9f8SPhilip Paeps		mkdir public.dir
112089abb9f8SPhilip Paeps		ln $(VERSION_DEPS) public.dir
1121eebb9c2cSPhilip Paeps		cd public.dir \
1122eebb9c2cSPhilip Paeps		  && $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' TZDIR='$(TZDIR)' ALL
1123e35a01eeSPhilip Paeps		for i in $(TDATA_TO_CHECK) public.dir/tzdata.zi \
1124e35a01eeSPhilip Paeps		    public.dir/vanguard.zi public.dir/main.zi \
1125e35a01eeSPhilip Paeps		    public.dir/rearguard.zi; \
1126e35a01eeSPhilip Paeps		do \
112789abb9f8SPhilip Paeps		  public.dir/zic -v -d public.dir/zoneinfo $$i 2>&1 || exit; \
112889abb9f8SPhilip Paeps		done
112989abb9f8SPhilip Paeps		public.dir/zic -v -d public.dir/zoneinfo-all $(TDATA_TO_CHECK)
113094c2d487SPhilip Paeps		:
113194c2d487SPhilip Paeps		: Also check 'backzone' syntax.
113294c2d487SPhilip Paeps		rm public.dir/main.zi
113394c2d487SPhilip Paeps		cd public.dir && $(MAKE) PACKRATDATA=backzone main.zi
113494c2d487SPhilip Paeps		public.dir/zic -d public.dir/zoneinfo main.zi
11359f9fc6bbSPhilip Paeps		rm public.dir/main.zi
11369f9fc6bbSPhilip Paeps		cd public.dir && \
11379f9fc6bbSPhilip Paeps		  $(MAKE) PACKRATDATA=backzone PACKRATLIST=zone.tab main.zi
11389f9fc6bbSPhilip Paeps		public.dir/zic -d public.dir/zoneinfo main.zi
113994c2d487SPhilip Paeps		:
114089abb9f8SPhilip Paeps		rm -fr public.dir
114189abb9f8SPhilip Paeps		touch $@
1142ba2b2efdSGlen Barber
1143ba2b2efdSGlen Barber# Check that the code works under various alternative
1144ba2b2efdSGlen Barber# implementations of time_t.
114589abb9f8SPhilip Paepscheck_time_t_alternatives: $(TIME_T_ALTERNATIVES)
114689abb9f8SPhilip Paeps$(TIME_T_ALTERNATIVES_TAIL): $(TIME_T_ALTERNATIVES_HEAD)
114789abb9f8SPhilip Paeps$(TIME_T_ALTERNATIVES): $(VERSION_DEPS)
114889abb9f8SPhilip Paeps		rm -fr $@.dir
114989abb9f8SPhilip Paeps		mkdir $@.dir
115089abb9f8SPhilip Paeps		ln $(VERSION_DEPS) $@.dir
115189abb9f8SPhilip Paeps		case $@ in \
115294c2d487SPhilip Paeps		  int*32_t) range=-2147483648,2147483648;; \
115389abb9f8SPhilip Paeps		  u*) range=0,4294967296;; \
115489abb9f8SPhilip Paeps		  *) range=-4294967296,4294967296;; \
115589abb9f8SPhilip Paeps		esac && \
115689abb9f8SPhilip Paeps		wd=`pwd` && \
115789abb9f8SPhilip Paeps		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
115889abb9f8SPhilip Paeps		if test $@ = $(TIME_T_ALTERNATIVES_HEAD); then \
115989abb9f8SPhilip Paeps		  range_target=; \
116089abb9f8SPhilip Paeps		else \
116189abb9f8SPhilip Paeps		  range_target=to$$range.tzs; \
116289abb9f8SPhilip Paeps		fi && \
116389abb9f8SPhilip Paeps		(cd $@.dir && \
116489abb9f8SPhilip Paeps		  $(MAKE) TOPDIR="$$wd/$@.dir" \
116589abb9f8SPhilip Paeps		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$@'" \
116689abb9f8SPhilip Paeps		    REDO='$(REDO)' \
116789abb9f8SPhilip Paeps			D=$$wd/$@.dir \
116889abb9f8SPhilip Paeps		    TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
116989abb9f8SPhilip Paeps		    install $$range_target) && \
117089abb9f8SPhilip Paeps		test $@ = $(TIME_T_ALTERNATIVES_HEAD) || { \
117189abb9f8SPhilip Paeps		  (cd $(TIME_T_ALTERNATIVES_HEAD).dir && \
117289abb9f8SPhilip Paeps		    $(MAKE) TOPDIR="$$wd/$@.dir" \
117389abb9f8SPhilip Paeps		      TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
117489abb9f8SPhilip Paeps			D=$$wd/$@.dir \
117589abb9f8SPhilip Paeps		      to$$range.tzs) && \
1176cf1ad535SPhilip Paeps		  $(DIFF_TZS) $(TIME_T_ALTERNATIVES_HEAD).dir/to$$range.tzs \
117789abb9f8SPhilip Paeps			  $@.dir/to$$range.tzs && \
1178ba2b2efdSGlen Barber		  if diff -q Makefile Makefile 2>/dev/null; then \
1179ba2b2efdSGlen Barber		    quiet_option='-q'; \
1180ba2b2efdSGlen Barber		  else \
1181ba2b2efdSGlen Barber		    quiet_option=''; \
1182ba2b2efdSGlen Barber		  fi && \
118389abb9f8SPhilip Paeps		    diff $$quiet_option -r $(TIME_T_ALTERNATIVES_HEAD).dir/etc \
118489abb9f8SPhilip Paeps					   $@.dir/etc && \
1185ba2b2efdSGlen Barber		    diff $$quiet_option -r \
118689abb9f8SPhilip Paeps		      $(TIME_T_ALTERNATIVES_HEAD).dir/usr/share \
118789abb9f8SPhilip Paeps		      $@.dir/usr/share; \
118889abb9f8SPhilip Paeps		}
118989abb9f8SPhilip Paeps		touch $@
1190ba2b2efdSGlen Barber
1191d81c2dd9SPhilip PaepsTRADITIONAL_ASC = \
1192d81c2dd9SPhilip Paeps  tzcode$(VERSION).tar.gz.asc \
1193d81c2dd9SPhilip Paeps  tzdata$(VERSION).tar.gz.asc
119489abb9f8SPhilip PaepsREARGUARD_ASC = \
119589abb9f8SPhilip Paeps  tzdata$(VERSION)-rearguard.tar.gz.asc
119689abb9f8SPhilip PaepsALL_ASC = $(TRADITIONAL_ASC) $(REARGUARD_ASC) \
1197d81c2dd9SPhilip Paeps  tzdb-$(VERSION).tar.lz.asc
1198d81c2dd9SPhilip Paeps
11999f9fc6bbSPhilip Paepstarballs rearguard_tarballs tailored_tarballs traditional_tarballs \
120089abb9f8SPhilip Paepssignatures rearguard_signatures traditional_signatures: \
12019f9fc6bbSPhilip Paeps  version set-timestamps.out rearguard.zi vanguard.zi
1202ba2b2efdSGlen Barber		VERSION=`cat version` && \
1203dc505d53SPhilip Paeps		$(MAKE) AWK='$(AWK)' VERSION="$$VERSION" $@_version
1204ba2b2efdSGlen Barber
120546bee4edSPhilip Paeps# These *_version rules are intended for use if VERSION is set by some
120646bee4edSPhilip Paeps# other means.  Ordinarily these rules are used only by the above
120746bee4edSPhilip Paeps# non-_version rules, which set VERSION on the 'make' command line.
120889abb9f8SPhilip Paepstarballs_version: traditional_tarballs_version rearguard_tarballs_version \
1209d81c2dd9SPhilip Paeps  tzdb-$(VERSION).tar.lz
121089abb9f8SPhilip Paepsrearguard_tarballs_version: \
121189abb9f8SPhilip Paeps  tzdata$(VERSION)-rearguard.tar.gz
1212ba2b2efdSGlen Barbertraditional_tarballs_version: \
1213ba2b2efdSGlen Barber  tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
12149f9fc6bbSPhilip Paepstailored_tarballs_version: \
12159f9fc6bbSPhilip Paeps  tzdata$(VERSION)-tailored.tar.gz
1216d81c2dd9SPhilip Paepssignatures_version: $(ALL_ASC)
121789abb9f8SPhilip Paepsrearguard_signatures_version: $(REARGUARD_ASC)
1218d81c2dd9SPhilip Paepstraditional_signatures_version: $(TRADITIONAL_ASC)
1219ba2b2efdSGlen Barber
1220ba2b2efdSGlen Barbertzcode$(VERSION).tar.gz: set-timestamps.out
1221ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
1222ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - \
1223ba2b2efdSGlen Barber		    $(COMMON) $(DOCS) $(SOURCES) | \
1224ba2b2efdSGlen Barber		  gzip $(GZIPFLAGS) >$@.out
1225ba2b2efdSGlen Barber		mv $@.out $@
1226ba2b2efdSGlen Barber
1227ba2b2efdSGlen Barbertzdata$(VERSION).tar.gz: set-timestamps.out
1228ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
12299f9fc6bbSPhilip Paeps		tar $(TARFLAGS) -cf - $(TZDATA_DIST) | \
1230ba2b2efdSGlen Barber		  gzip $(GZIPFLAGS) >$@.out
1231ba2b2efdSGlen Barber		mv $@.out $@
1232ba2b2efdSGlen Barber
12339f9fc6bbSPhilip Paeps# Create empty files with a reproducible timestamp.
12349f9fc6bbSPhilip PaepsCREATE_EMPTY = TZ=UTC0 touch -mt 202010122253.00
12359f9fc6bbSPhilip Paeps
12369f9fc6bbSPhilip Paeps# The obsolescent *rearguard* targets and related macros are present
12379f9fc6bbSPhilip Paeps# for backwards compatibility with tz releases 2018e through 2022a.
12389f9fc6bbSPhilip Paeps# They should go away eventually.  To build rearguard tarballs you
12399f9fc6bbSPhilip Paeps# can instead use 'make DATAFORM=rearguard tailored_tarballs'.
1240d81c2dd9SPhilip Paepstzdata$(VERSION)-rearguard.tar.gz: rearguard.zi set-timestamps.out
12419f9fc6bbSPhilip Paeps		rm -fr $@.dir
12429f9fc6bbSPhilip Paeps		mkdir $@.dir
12439f9fc6bbSPhilip Paeps		ln $(TZDATA_DIST) $@.dir
12449f9fc6bbSPhilip Paeps		cd $@.dir && rm -f $(TDATA) $(PACKRATDATA) version
1245d81c2dd9SPhilip Paeps		for f in $(TDATA) $(PACKRATDATA); do \
12469f9fc6bbSPhilip Paeps		  rearf=$@.dir/$$f; \
1247d81c2dd9SPhilip Paeps		  $(AWK) -v DATAFORM=rearguard -f ziguard.awk $$f >$$rearf && \
1248dc505d53SPhilip Paeps		  $(SET_TIMESTAMP_DEP) $$rearf ziguard.awk $$f || exit; \
1249d81c2dd9SPhilip Paeps		done
12509f9fc6bbSPhilip Paeps		sed '1s/$$/-rearguard/' <version >$@.dir/version
1251e7e2d659SPhilip Paeps		: The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
12529f9fc6bbSPhilip Paeps		$(CREATE_EMPTY) $@.dir/pacificnew
1253eebb9c2cSPhilip Paeps		touch -mr version $@.dir/version
1254d81c2dd9SPhilip Paeps		LC_ALL=C && export LC_ALL && \
12559f9fc6bbSPhilip Paeps		  (cd $@.dir && \
1256e7e2d659SPhilip Paeps		   tar $(TARFLAGS) -cf - \
12579f9fc6bbSPhilip Paeps			$(TZDATA_DIST) pacificnew | \
1258d81c2dd9SPhilip Paeps		     gzip $(GZIPFLAGS)) >$@.out
1259d81c2dd9SPhilip Paeps		mv $@.out $@
1260d81c2dd9SPhilip Paeps
12619f9fc6bbSPhilip Paeps# Create a tailored tarball suitable for TZUpdater and compatible tools.
12629f9fc6bbSPhilip Paeps# For example, 'make DATAFORM=vanguard tailored_tarballs' makes a tarball
12639f9fc6bbSPhilip Paeps# useful for testing whether TZUpdater supports vanguard form.
12649f9fc6bbSPhilip Paeps# The generated tarball is not byte-for-byte equivalent to a hand-tailored
12659f9fc6bbSPhilip Paeps# traditional tarball, as data entries are put into 'etcetera' even if they
12669f9fc6bbSPhilip Paeps# came from some other source file.  However, the effect should be the same
12679f9fc6bbSPhilip Paeps# for ordinary use, which reads all the source files.
12689f9fc6bbSPhilip Paepstzdata$(VERSION)-tailored.tar.gz: set-timestamps.out
12699f9fc6bbSPhilip Paeps		rm -fr $@.dir
12709f9fc6bbSPhilip Paeps		mkdir $@.dir
12719f9fc6bbSPhilip Paeps		: The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
12729f9fc6bbSPhilip Paeps		cd $@.dir && \
12739f9fc6bbSPhilip Paeps		  $(CREATE_EMPTY) $(PRIMARY_YDATA) $(NDATA) backward \
12749f9fc6bbSPhilip Paeps		  `test $(DATAFORM) = vanguard || echo pacificnew`
12759f9fc6bbSPhilip Paeps		(grep '^#' tzdata.zi && echo && cat $(DATAFORM).zi) \
12769f9fc6bbSPhilip Paeps		  >$@.dir/etcetera
1277eebb9c2cSPhilip Paeps		touch -mr tzdata.zi $@.dir/etcetera
12789f9fc6bbSPhilip Paeps		sed -n \
12799f9fc6bbSPhilip Paeps		  -e '/^# *version  *\(.*\)/h' \
12809f9fc6bbSPhilip Paeps		  -e '/^# *ddeps  */H' \
12819f9fc6bbSPhilip Paeps		  -e '$$!d' \
12829f9fc6bbSPhilip Paeps		  -e 'g' \
12839f9fc6bbSPhilip Paeps		  -e 's/^# *version  *//' \
12849f9fc6bbSPhilip Paeps		  -e 's/\n# *ddeps  */-/' \
12859f9fc6bbSPhilip Paeps		  -e 's/ /-/g' \
12869f9fc6bbSPhilip Paeps		  -e 'p' \
12879f9fc6bbSPhilip Paeps		  <tzdata.zi >$@.dir/version
1288eebb9c2cSPhilip Paeps		touch -mr version $@.dir/version
12899f9fc6bbSPhilip Paeps		links= && \
12909f9fc6bbSPhilip Paeps		  for file in $(TZDATA_DIST); do \
12919f9fc6bbSPhilip Paeps		    test -f $@.dir/$$file || links="$$links $$file"; \
12929f9fc6bbSPhilip Paeps		  done && \
12939f9fc6bbSPhilip Paeps		  ln $$links $@.dir
12949f9fc6bbSPhilip Paeps		LC_ALL=C && export LC_ALL && \
12959f9fc6bbSPhilip Paeps		  (cd $@.dir && \
12969f9fc6bbSPhilip Paeps		   tar $(TARFLAGS) -cf - * | gzip $(GZIPFLAGS)) >$@.out
12979f9fc6bbSPhilip Paeps		mv $@.out $@
12989f9fc6bbSPhilip Paeps
129989abb9f8SPhilip Paepstzdb-$(VERSION).tar.lz: set-timestamps.out set-tzs-timestamp.out
1300ba2b2efdSGlen Barber		rm -fr tzdb-$(VERSION)
1301ba2b2efdSGlen Barber		mkdir tzdb-$(VERSION)
1302ba2b2efdSGlen Barber		ln $(ENCHILADA) tzdb-$(VERSION)
1303dc505d53SPhilip Paeps		$(SET_TIMESTAMP) tzdb-$(VERSION) tzdb-$(VERSION)/*
1304ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
1305ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out
1306ba2b2efdSGlen Barber		mv $@.out $@
1307ba2b2efdSGlen Barber
1308ba2b2efdSGlen Barbertzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
1309ba2b2efdSGlen Barbertzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
1310d81c2dd9SPhilip Paepstzdata$(VERSION)-rearguard.tar.gz.asc: tzdata$(VERSION)-rearguard.tar.gz
1311ba2b2efdSGlen Barbertzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
1312d81c2dd9SPhilip Paeps$(ALL_ASC):
13132865ab3fSPhilip Paeps		$(GPG) --armor --detach-sign $?
1314ba2b2efdSGlen Barber
131589abb9f8SPhilip PaepsTYPECHECK_CFLAGS = $(CFLAGS) -DTYPECHECK -D__time_t_defined -D_TIME_T
131689abb9f8SPhilip Paepstypecheck: typecheck_long_long typecheck_unsigned
131789abb9f8SPhilip Paepstypecheck_long_long typecheck_unsigned: $(VERSION_DEPS)
131889abb9f8SPhilip Paeps		rm -fr $@.dir
131989abb9f8SPhilip Paeps		mkdir $@.dir
132089abb9f8SPhilip Paeps		ln $(VERSION_DEPS) $@.dir
132189abb9f8SPhilip Paeps		cd $@.dir && \
132289abb9f8SPhilip Paeps		  case $@ in \
132389abb9f8SPhilip Paeps		    *_long_long) i="long long";; \
132489abb9f8SPhilip Paeps		    *_unsigned ) i="unsigned" ;; \
132589abb9f8SPhilip Paeps		  esac && \
132689abb9f8SPhilip Paeps		  typecheck_cflags='' && \
132789abb9f8SPhilip Paeps		  $(MAKE) \
132889abb9f8SPhilip Paeps		    CFLAGS="$(TYPECHECK_CFLAGS) \"-Dtime_t=$$i\"" \
132989abb9f8SPhilip Paeps		    TOPDIR="`pwd`" \
133089abb9f8SPhilip Paeps		    install
133189abb9f8SPhilip Paeps		$@.dir/zdump -i -c 1970,1971 Europe/Rome
133289abb9f8SPhilip Paeps		touch $@
1333ba2b2efdSGlen Barber
13348d7edd17SPhilip Paepszonenames:	tzdata.zi
13358d7edd17SPhilip Paeps		@$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
1336ba2b2efdSGlen Barber
1337ba2b2efdSGlen Barberasctime.o:	private.h tzfile.h
1338ba2b2efdSGlen Barberdate.o:		private.h
1339ba2b2efdSGlen Barberdifftime.o:	private.h
1340eebb9c2cSPhilip Paepslocaltime.o:	private.h tzfile.h tzdir.h
1341ba2b2efdSGlen Barberstrftime.o:	private.h tzfile.h
1342ba2b2efdSGlen Barberzdump.o:	version.h
1343eebb9c2cSPhilip Paepszic.o:		private.h tzfile.h tzdir.h version.h
1344ba2b2efdSGlen Barber
1345ba2b2efdSGlen Barber.PHONY: ALL INSTALL all
1346cf1ad535SPhilip Paeps.PHONY: check check_mild check_time_t_alternatives
13472c5e84ccSPhilip Paeps.PHONY: check_web check_zishrink
13482723c7ffSPhilip Paeps.PHONY: clean clean_misc commit-leap-seconds.list dummy.zd
13492723c7ffSPhilip Paeps.PHONY: fetch-leap-seconds.list force_tzs
1350ba2b2efdSGlen Barber.PHONY: install install_data maintainer-clean names
13519f9fc6bbSPhilip Paeps.PHONY: posix_only posix_right public
135289abb9f8SPhilip Paeps.PHONY: rearguard_signatures rearguard_signatures_version
135389abb9f8SPhilip Paeps.PHONY: rearguard_tarballs rearguard_tarballs_version
135489abb9f8SPhilip Paeps.PHONY: right_only right_posix signatures signatures_version
135546bee4edSPhilip Paeps.PHONY: tarballs tarballs_version
135646bee4edSPhilip Paeps.PHONY: traditional_signatures traditional_signatures_version
135746bee4edSPhilip Paeps.PHONY: traditional_tarballs traditional_tarballs_version
13589f9fc6bbSPhilip Paeps.PHONY: tailored_tarballs tailored_tarballs_version
135946bee4edSPhilip Paeps.PHONY: typecheck
1360ba2b2efdSGlen Barber.PHONY: zonenames zones
136146bee4edSPhilip Paeps.PHONY: $(ZDS)
1362