xref: /freebsd/contrib/tzdata/Makefile (revision 259e2ad76d1da961cc34c2903cb5f72f28503eb8)
189abb9f8SPhilip Paeps# Make and install tzdb code and data.
289abb9f8SPhilip Paeps
3ba2b2efdSGlen Barber# This file is in the public domain, so clarified as of
4ba2b2efdSGlen Barber# 2009-05-17 by Arthur David Olson.
5ba2b2efdSGlen Barber
6ba2b2efdSGlen Barber# Package name for the code distribution.
7ba2b2efdSGlen BarberPACKAGE=	tzcode
8ba2b2efdSGlen Barber
9ba2b2efdSGlen Barber# Version number for the distribution, overridden in the 'tarballs' rule below.
10ba2b2efdSGlen BarberVERSION=	unknown
11ba2b2efdSGlen Barber
12ba2b2efdSGlen Barber# Email address for bug reports.
13ba2b2efdSGlen BarberBUGEMAIL=	tz@iana.org
14ba2b2efdSGlen Barber
15ad48359aSPhilip Paeps# DATAFORM selects the data format.
16ad48359aSPhilip Paeps# Available formats represent essentially the same data, albeit
17ad48359aSPhilip Paeps# possibly with minor discrepancies that users are not likely to notice.
18ad48359aSPhilip Paeps# To get new features and the best data right away, use:
1946bee4edSPhilip Paeps#	DATAFORM=	vanguard
2046bee4edSPhilip Paeps# To wait a while before using new features, to give downstream users
2146bee4edSPhilip Paeps# time to upgrade zic (the default), use:
2246bee4edSPhilip Paeps#	DATAFORM=	main
2346bee4edSPhilip Paeps# To wait even longer for new features, use:
2446bee4edSPhilip Paeps#	DATAFORM=	rearguard
2512a899b6SPhilip Paeps# Rearguard users might also want "ZFLAGS = -b fat"; see below.
2646bee4edSPhilip PaepsDATAFORM=		main
2746bee4edSPhilip Paeps
2889abb9f8SPhilip Paeps# Change the line below for your timezone (after finding the one you want in
2989abb9f8SPhilip Paeps# one of the $(TDATA) source files, or adding it to a source file).
30d81c2dd9SPhilip Paeps# Alternatively, if you discover you've got the wrong timezone, you can just
3112a899b6SPhilip Paeps# 'zic -l -' to remove it, or 'zic -l rightzone' to change it.
32ba2b2efdSGlen Barber# Use the command
33ba2b2efdSGlen Barber#	make zonenames
34ba2b2efdSGlen Barber# to get a list of the values you can use for LOCALTIME.
35ba2b2efdSGlen Barber
369f9fc6bbSPhilip PaepsLOCALTIME=	Factory
37ba2b2efdSGlen Barber
38*259e2ad7SPhilip Paeps# The POSIXRULES macro controls interpretation of POSIX-like TZ
39*259e2ad7SPhilip Paeps# settings like TZ='EET-2EEST' that lack DST transition rules.
4012a899b6SPhilip Paeps# If POSIXRULES is '-', no template is installed; this is the default.
4112a899b6SPhilip Paeps# Any other value for POSIXRULES is obsolete and should not be relied on, as:
422865ab3fSPhilip Paeps# * It does not work correctly in popular implementations such as GNU/Linux.
4394c2d487SPhilip Paeps# * It does not work even in tzcode, except for historical timestamps
4494c2d487SPhilip Paeps#   that precede the last explicit transition in the POSIXRULES file.
4594c2d487SPhilip Paeps#   Hence it typically does not work for current and future timestamps.
4612a899b6SPhilip Paeps# If, despite the above, you want a template for handling these settings,
4712a899b6SPhilip Paeps# you can change the line below (after finding the timezone you want in the
4812a899b6SPhilip Paeps# one of the $(TDATA) source files, or adding it to a source file).
4912a899b6SPhilip Paeps# Alternatively, if you discover you've got the wrong timezone, you can just
5012a899b6SPhilip Paeps# 'zic -p -' to remove it, or 'zic -p rightzone' to change it.
5112a899b6SPhilip Paeps# Use the command
5212a899b6SPhilip Paeps#	make zonenames
5312a899b6SPhilip Paeps# to get a list of the values you can use for POSIXRULES.
54ba2b2efdSGlen Barber
5512a899b6SPhilip PaepsPOSIXRULES=	-
56ba2b2efdSGlen Barber
57ba2b2efdSGlen Barber# Also see TZDEFRULESTRING below, which takes effect only
58*259e2ad7SPhilip Paeps# if POSIXRULES is '-' or if the template file cannot be accessed.
59ba2b2efdSGlen Barber
60ba2b2efdSGlen Barber
61f2fcff28SPhilip Paeps# Installation locations.
62f2fcff28SPhilip Paeps#
63f2fcff28SPhilip Paeps# The defaults are suitable for Debian, except that if REDO is
64f2fcff28SPhilip Paeps# posix_right or right_posix then files that Debian puts under
65f2fcff28SPhilip Paeps# /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
66f2fcff28SPhilip Paeps# put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
67f2fcff28SPhilip Paeps# respectively.  Problems with the Debian approach are discussed in
68f2fcff28SPhilip Paeps# the commentary for the right_posix rule (below).
69f2fcff28SPhilip Paeps
70f2fcff28SPhilip Paeps# Destination directory, which can be used for staging.
71f2fcff28SPhilip Paeps# 'make DESTDIR=/stage install' installs under /stage (e.g., to
72f2fcff28SPhilip Paeps# /stage/etc/localtime instead of to /etc/localtime).  Files under
73f2fcff28SPhilip Paeps# /stage are not intended to work as-is, but can be copied by hand to
74f2fcff28SPhilip Paeps# the root directory later.  If DESTDIR is empty, 'make install' does
75f2fcff28SPhilip Paeps# not stage, but installs directly into production locations.
76f2fcff28SPhilip PaepsDESTDIR =
77f2fcff28SPhilip Paeps
78f2fcff28SPhilip Paeps# Everything is installed into subdirectories of TOPDIR, and used there.
79f2fcff28SPhilip Paeps# TOPDIR should be empty (meaning the root directory),
80f2fcff28SPhilip Paeps# or a directory name that does not end in "/".
81f2fcff28SPhilip Paeps# TOPDIR should be empty or an absolute name unless you're just testing.
82f2fcff28SPhilip PaepsTOPDIR =
83f2fcff28SPhilip Paeps
84f2fcff28SPhilip Paeps# The default local timezone is taken from the file TZDEFAULT.
85f2fcff28SPhilip PaepsTZDEFAULT = $(TOPDIR)/etc/localtime
86f2fcff28SPhilip Paeps
87f2fcff28SPhilip Paeps# The subdirectory containing installed program and data files, and
88f2fcff28SPhilip Paeps# likewise for installed files that can be shared among architectures.
89f2fcff28SPhilip Paeps# These should be relative file names.
90f2fcff28SPhilip PaepsUSRDIR = usr
91f2fcff28SPhilip PaepsUSRSHAREDIR = $(USRDIR)/share
92ba2b2efdSGlen Barber
93ba2b2efdSGlen Barber# "Compiled" timezone information is placed in the "TZDIR" directory
94ba2b2efdSGlen Barber# (and subdirectories).
958d7edd17SPhilip Paeps# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
96ba2b2efdSGlen BarberTZDIR_BASENAME=	zoneinfo
97f2fcff28SPhilip PaepsTZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
98f2fcff28SPhilip Paeps
99f2fcff28SPhilip Paeps# The "tzselect" and (if you do "make INSTALL") "date" commands go in:
100f2fcff28SPhilip PaepsBINDIR = $(TOPDIR)/$(USRDIR)/bin
101f2fcff28SPhilip Paeps
102f2fcff28SPhilip Paeps# The "zdump" command goes in:
103f2fcff28SPhilip PaepsZDUMPDIR = $(BINDIR)
104f2fcff28SPhilip Paeps
105f2fcff28SPhilip Paeps# The "zic" command goes in:
106f2fcff28SPhilip PaepsZICDIR = $(TOPDIR)/$(USRDIR)/sbin
107f2fcff28SPhilip Paeps
108f2fcff28SPhilip Paeps# Manual pages go in subdirectories of. . .
109f2fcff28SPhilip PaepsMANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
110f2fcff28SPhilip Paeps
111f2fcff28SPhilip Paeps# Library functions are put in an archive in LIBDIR.
112f2fcff28SPhilip PaepsLIBDIR = $(TOPDIR)/$(USRDIR)/lib
113f2fcff28SPhilip Paeps
114ba2b2efdSGlen Barber
11589abb9f8SPhilip Paeps# Types to try, as an alternative to time_t.
11689abb9f8SPhilip PaepsTIME_T_ALTERNATIVES = $(TIME_T_ALTERNATIVES_HEAD) $(TIME_T_ALTERNATIVES_TAIL)
11794c2d487SPhilip PaepsTIME_T_ALTERNATIVES_HEAD = int_least64_t
11894c2d487SPhilip PaepsTIME_T_ALTERNATIVES_TAIL = int_least32_t uint_least32_t uint_least64_t
119ba2b2efdSGlen Barber
120ad48359aSPhilip Paeps# What kind of TZif data files to generate.  (TZif is the binary time
121ad48359aSPhilip Paeps# zone data format that zic generates; see Internet RFC 8536.)
122dc135c6eSBaptiste Daroussin# If you want only POSIX time, with time values interpreted as
123dc135c6eSBaptiste Daroussin# seconds since the epoch (not counting leap seconds), use
124ba2b2efdSGlen Barber#	REDO=		posix_only
1258d7edd17SPhilip Paeps# below.  If you want only "right" time, with values interpreted
126dc135c6eSBaptiste Daroussin# as seconds since the epoch (counting leap seconds), use
127ba2b2efdSGlen Barber#	REDO=		right_only
128ba2b2efdSGlen Barber# below.  If you want both sets of data available, with leap seconds not
129ba2b2efdSGlen Barber# counted normally, use
130ba2b2efdSGlen Barber#	REDO=		posix_right
131ba2b2efdSGlen Barber# below.  If you want both sets of data available, with leap seconds counted
132ba2b2efdSGlen Barber# normally, use
133ba2b2efdSGlen Barber#	REDO=		right_posix
134ba2b2efdSGlen Barber# below.  POSIX mandates that leap seconds not be counted; for compatibility
135dc135c6eSBaptiste Daroussin# with it, use "posix_only" or "posix_right".  Use POSIX time on systems with
136dc135c6eSBaptiste Daroussin# leap smearing; this can work better than unsmeared "right" time with
137dc135c6eSBaptiste Daroussin# applications that are not leap second aware, and is closer to unsmeared
138dc135c6eSBaptiste Daroussin# "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
139ba2b2efdSGlen Barber
140ba2b2efdSGlen BarberREDO=		posix_right
141ba2b2efdSGlen Barber
142dd5f96c4SPhilip Paeps# Whether to put an "Expires" line in the leapseconds file.
143dd5f96c4SPhilip Paeps# Use EXPIRES_LINE=1 to put the line in, 0 to omit it.
144dd5f96c4SPhilip Paeps# The EXPIRES_LINE value matters only if REDO's value contains "right".
145dd5f96c4SPhilip Paeps# If you change EXPIRES_LINE, remove the leapseconds file before running "make".
146dd5f96c4SPhilip Paeps# zic's support for the Expires line was introduced in tzdb 2020a,
14794c2d487SPhilip Paeps# and was modified in tzdb 2021b to generate version 4 TZif files.
14894c2d487SPhilip Paeps# EXPIRES_LINE defaults to 0 for now so that the leapseconds file
14994c2d487SPhilip Paeps# can be given to pre-2020a zic implementations and so that TZif files
15094c2d487SPhilip Paeps# built by newer zic implementations can be read by pre-2021b libraries.
151dd5f96c4SPhilip PaepsEXPIRES_LINE=	0
152dd5f96c4SPhilip Paeps
15389abb9f8SPhilip Paeps# To install data in text form that has all the information of the TZif data,
1548d7edd17SPhilip Paeps# (optionally incorporating leap second information), use
1558d7edd17SPhilip Paeps#	TZDATA_TEXT=	tzdata.zi leapseconds
1568d7edd17SPhilip Paeps# To install text data without leap second information (e.g., because
1578d7edd17SPhilip Paeps# REDO='posix_only'), use
1588d7edd17SPhilip Paeps#	TZDATA_TEXT=	tzdata.zi
1598d7edd17SPhilip Paeps# To avoid installing text data, use
1608d7edd17SPhilip Paeps#	TZDATA_TEXT=
1618d7edd17SPhilip Paeps
1628d7edd17SPhilip PaepsTZDATA_TEXT=	leapseconds tzdata.zi
1638d7edd17SPhilip Paeps
1648d7edd17SPhilip Paeps# For backward-compatibility links for old zone names, use
165f2fcff28SPhilip Paeps#	BACKWARD=	backward
1668d7edd17SPhilip Paeps# To omit these links, use
1678d7edd17SPhilip Paeps#	BACKWARD=
1688d7edd17SPhilip Paeps
169f2fcff28SPhilip PaepsBACKWARD=	backward
1708d7edd17SPhilip Paeps
1719f9fc6bbSPhilip Paeps# If you want out-of-scope and often-wrong data from the file 'backzone',
1729f9fc6bbSPhilip Paeps# but only for entries listed in the backward-compatibility file zone.tab, use
173ba2b2efdSGlen Barber#	PACKRATDATA=	backzone
1749f9fc6bbSPhilip Paeps#	PACKRATLIST=	zone.tab
1759f9fc6bbSPhilip Paeps# If you want all the 'backzone' data, use
1769f9fc6bbSPhilip Paeps#	PACKRATDATA=	backzone
1779f9fc6bbSPhilip Paeps#	PACKRATLIST=
178ba2b2efdSGlen Barber# To omit this data, use
179ba2b2efdSGlen Barber#	PACKRATDATA=
1809f9fc6bbSPhilip Paeps#	PACKRATLIST=
181ba2b2efdSGlen Barber
182ba2b2efdSGlen BarberPACKRATDATA=
1839f9fc6bbSPhilip PaepsPACKRATLIST=
184ba2b2efdSGlen Barber
1858d7edd17SPhilip Paeps# The name of a locale using the UTF-8 encoding, used during self-tests.
1868d7edd17SPhilip Paeps# The tests are skipped if the name does not appear to work on this system.
1878d7edd17SPhilip Paeps
1888d7edd17SPhilip PaepsUTF8_LOCALE=	en_US.utf8
1898d7edd17SPhilip Paeps
190ba2b2efdSGlen Barber# Non-default libraries needed to link.
191cf1ad535SPhilip Paeps# On some hosts, this should have -lintl unless CFLAGS has -DHAVE_GETTEXT=0.
192ba2b2efdSGlen BarberLDLIBS=
193ba2b2efdSGlen Barber
1948d7edd17SPhilip Paeps# Add the following to the end of the "CFLAGS=" line as needed to override
1958d7edd17SPhilip Paeps# defaults specified in the source code.  "-DFOO" is equivalent to "-DFOO=1".
1968d7edd17SPhilip Paeps#  -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
1978d7edd17SPhilip Paeps#	formats that generate only the last two digits of year numbers
1988d7edd17SPhilip Paeps#  -DEPOCH_LOCAL if the 'time' function returns local time not UT
199ba2b2efdSGlen Barber#  -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
200ba2b2efdSGlen Barber#	than what POSIX specifies, assuming local time is UT.
201ba2b2efdSGlen Barber#	For example, N is 252460800 on AmigaOS.
2028d7edd17SPhilip Paeps#  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
2038d7edd17SPhilip Paeps#  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
204cf1ad535SPhilip Paeps#  -DHAVE_DECL_TIMEGM=0 if <time.h> does not declare timegm
2058d7edd17SPhilip Paeps#  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
206*259e2ad7SPhilip Paeps#  -DHAVE__GENERIC=0 if _Generic does not work*
207cf1ad535SPhilip Paeps#  -DHAVE_GETRANDOM if getrandom works (e.g., GNU/Linux),
208cf1ad535SPhilip Paeps#	-DHAVE_GETRANDOM=0 to avoid using getrandom
209cf1ad535SPhilip Paeps#  -DHAVE_GETTEXT if gettext works (e.g., GNU/Linux, FreeBSD, Solaris),
210cf1ad535SPhilip Paeps#	where LDLIBS also needs to contain -lintl on some hosts;
211cf1ad535SPhilip Paeps#	-DHAVE_GETTEXT=0 to avoid using gettext
2128d7edd17SPhilip Paeps#  -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
2138d7edd17SPhilip Paeps#	ctime_r and asctime_r incompatibly with the POSIX standard
2148d7edd17SPhilip Paeps#	(Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
215*259e2ad7SPhilip Paeps#  -DHAVE_INTTYPES_H=0 if <inttypes.h> does not work*+
2168d7edd17SPhilip Paeps#  -DHAVE_LINK=0 if your system lacks a link function
2178d7edd17SPhilip Paeps#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
2188d7edd17SPhilip Paeps#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
2198d7edd17SPhilip Paeps#	localtime_rz can make zdump significantly faster, but is nonstandard.
22094c2d487SPhilip Paeps#  -DHAVE_MALLOC_ERRNO=0 if malloc etc. do not set errno on failure.
2218d7edd17SPhilip Paeps#  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
2228d7edd17SPhilip Paeps#	functions like 'link' or variables like 'tzname' required by POSIX
2239142a2a3SPhilip Paeps#  -DHAVE_SETENV=0 if your system lacks the setenv function
224*259e2ad7SPhilip Paeps#  -DHAVE_SNPRINTF=0 if your system lacks the snprintf function+
225cf1ad535SPhilip Paeps#  -DHAVE_STDCKDINT_H=0 if neither <stdckdint.h> nor substitutes like
226cf1ad535SPhilip Paeps#	__builtin_add_overflow work*
227*259e2ad7SPhilip Paeps#  -DHAVE_STDINT_H=0 if <stdint.h> does not work*+
2288d7edd17SPhilip Paeps#  -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
2298d7edd17SPhilip Paeps#  -DHAVE_STRDUP=0 if your system lacks the strdup function
230*259e2ad7SPhilip Paeps#  -DHAVE_STRTOLL=0 if your system lacks the strtoll function+
2318d7edd17SPhilip Paeps#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
232cf1ad535SPhilip Paeps#  -DHAVE_SYS_STAT_H=0 if <sys/stat.h> does not work*
2338d7edd17SPhilip Paeps#  -DHAVE_TZSET=0 if your system lacks a tzset function
234cf1ad535SPhilip Paeps#  -DHAVE_UNISTD_H=0 if <unistd.h> does not work*
235cf1ad535SPhilip Paeps#  -DHAVE_UTMPX_H=0 if <utmpx.h> does not work*
2368d7edd17SPhilip Paeps#  -Dlocale_t=XXX if your system uses XXX instead of locale_t
237*259e2ad7SPhilip Paeps#  -DPORT_TO_C89 if tzcode should also run on C89 platforms+
23846bee4edSPhilip Paeps#  -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
23946bee4edSPhilip Paeps#	with external linkage, e.g., applications cannot define 'localtime'.
2408d7edd17SPhilip Paeps#  -Dssize_t=long on hosts like MS-Windows that lack ssize_t
241*259e2ad7SPhilip Paeps#  -DSUPPORT_C89 if the tzcode library should support C89 callers+
24246bee4edSPhilip Paeps#  -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
24346bee4edSPhilip Paeps#	security implications and is not recommended for general use
2448d7edd17SPhilip Paeps#  -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
245ba2b2efdSGlen Barber#	not needed by the main-program tz code, which is single-threaded.
246ba2b2efdSGlen Barber#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
247ba2b2efdSGlen Barber#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
2488d7edd17SPhilip Paeps#	This is intended for internal use only; it mangles external names.
249ba2b2efdSGlen Barber#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
250ba2b2efdSGlen Barber#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
251ba2b2efdSGlen Barber#	the default is system-supplied, typically "/usr/lib/locale"
252ba2b2efdSGlen Barber#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
253*259e2ad7SPhilip Paeps#	DST transitions for POSIX-style TZ strings lacking them,
254*259e2ad7SPhilip Paeps#	in the usual case where POSIXRULES is '-'.  If not specified,
255*259e2ad7SPhilip Paeps#	TZDEFRULESTRING defaults to US rules for future DST transitions.
256*259e2ad7SPhilip Paeps#	This mishandles some past timestamps, as US DST rules have changed.
257*259e2ad7SPhilip Paeps#	It also mishandles settings like TZ='EET-2EEST' for eastern Europe,
258*259e2ad7SPhilip Paeps#	as Europe and US DST rules differ.
259*259e2ad7SPhilip Paeps#  -DTZNAME_MAXIMUM=N to limit time zone abbreviations to N bytes (default 255)
2608d7edd17SPhilip Paeps#  -DUNINIT_TRAP if reading uninitialized storage can cause problems
261ba2b2efdSGlen Barber#	other than simply getting garbage data
262ba2b2efdSGlen Barber#  -DUSE_LTZ=0 to build zdump with the system time zone library
263ba2b2efdSGlen Barber#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
26412a899b6SPhilip Paeps#  -DZIC_BLOAT_DEFAULT=\"fat\" to default zic's -b option to "fat", and
26512a899b6SPhilip Paeps#	similarly for "slim".  Fat TZif files work around incompatibilities
2669142a2a3SPhilip Paeps#	and bugs in some TZif readers, notably older ones that
2679142a2a3SPhilip Paeps#	ignore or otherwise mishandle 64-bit data in TZif files;
2689142a2a3SPhilip Paeps#	however, fat TZif files may trigger bugs in newer TZif readers.
2699142a2a3SPhilip Paeps#	Slim TZif files are more efficient, and are the default.
270ba2b2efdSGlen Barber#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
271ba2b2efdSGlen Barber#	(or some other number) to set the maximum time zone abbreviation length
272ba2b2efdSGlen Barber#	that zic will accept without a warning (the default is 6)
273ba2b2efdSGlen Barber#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
2749142a2a3SPhilip Paeps#
2759142a2a3SPhilip Paeps# * Options marked "*" can be omitted if your compiler is C23 compatible.
276*259e2ad7SPhilip Paeps# * Options marked "+" are obsolescent and are planned to be removed
277*259e2ad7SPhilip Paeps#   once the code assumes C99 or later.
2789142a2a3SPhilip Paeps#
2798d7edd17SPhilip Paeps# Select instrumentation via "make GCC_INSTRUMENT='whatever'".
2808d7edd17SPhilip PaepsGCC_INSTRUMENT = \
2818d7edd17SPhilip Paeps  -fsanitize=undefined -fsanitize-address-use-after-scope \
2828d7edd17SPhilip Paeps  -fsanitize-undefined-trap-on-error -fstack-protector
28394c2d487SPhilip Paeps# Omit -fanalyzer from GCC_DEBUG_FLAGS, as it makes GCC too slow.
2848d7edd17SPhilip PaepsGCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \
2858d7edd17SPhilip Paeps  $(GCC_INSTRUMENT) \
286ba2b2efdSGlen Barber  -Wall -Wextra \
2878d7edd17SPhilip Paeps  -Walloc-size-larger-than=100000 -Warray-bounds=2 \
2889f9fc6bbSPhilip Paeps  -Wbad-function-cast -Wbidi-chars=any,ucn -Wcast-align=strict -Wdate-time \
2898d7edd17SPhilip Paeps  -Wdeclaration-after-statement -Wdouble-promotion \
29094c2d487SPhilip Paeps  -Wduplicated-branches -Wduplicated-cond \
2918d7edd17SPhilip Paeps  -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
292cf1ad535SPhilip Paeps  -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op \
2938d7edd17SPhilip Paeps  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
29494c2d487SPhilip Paeps  -Wnull-dereference \
295ba2b2efdSGlen Barber  -Wold-style-definition -Woverlength-strings -Wpointer-arith \
29694c2d487SPhilip Paeps  -Wshadow -Wshift-overflow=2 -Wstrict-overflow \
29794c2d487SPhilip Paeps  -Wstrict-prototypes -Wstringop-overflow=4 \
298d81c2dd9SPhilip Paeps  -Wstringop-truncation -Wsuggest-attribute=cold \
2998d7edd17SPhilip Paeps  -Wsuggest-attribute=const -Wsuggest-attribute=format \
300d81c2dd9SPhilip Paeps  -Wsuggest-attribute=malloc \
3018d7edd17SPhilip Paeps  -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
3029f9fc6bbSPhilip Paeps  -Wtrampolines -Wundef -Wuninitialized -Wunused-macros -Wuse-after-free=3 \
3038d7edd17SPhilip Paeps  -Wvariadic-macros -Wvla -Wwrite-strings \
304ba2b2efdSGlen Barber  -Wno-address -Wno-format-nonliteral -Wno-sign-compare \
305cf1ad535SPhilip Paeps  -Wno-type-limits
306ba2b2efdSGlen Barber#
307ba2b2efdSGlen Barber# If your system has a "GMT offset" field in its "struct tm"s
308ba2b2efdSGlen Barber# (or if you decide to add such a field in your system's "time.h" file),
309ba2b2efdSGlen Barber# add the name to a define such as
310ba2b2efdSGlen Barber#	-DTM_GMTOFF=tm_gmtoff
311ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
312ba2b2efdSGlen Barber# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
313ba2b2efdSGlen Barber# Similarly, if your system has a "zone abbreviation" field, define
314ba2b2efdSGlen Barber#	-DTM_ZONE=tm_zone
3155f33eb72SPhilip Paeps# and define NO_TM_ZONE to suppress any guessing.  Although these two fields
3165f33eb72SPhilip Paeps# not required by POSIX, a future version of POSIX is planned to require them
3175f33eb72SPhilip Paeps# and they are widely available on GNU/Linux and BSD systems.
318ba2b2efdSGlen Barber#
3198d7edd17SPhilip Paeps# The next batch of options control support for external variables
3208d7edd17SPhilip Paeps# exported by tzcode.  In practice these variables are less useful
3218d7edd17SPhilip Paeps# than TM_GMTOFF and TM_ZONE.  However, most of them are standardized.
3228d7edd17SPhilip Paeps# #
3238d7edd17SPhilip Paeps# # To omit or support the external variable "tzname", add one of:
324dd5f96c4SPhilip Paeps# #	-DHAVE_TZNAME=0 # do not support "tzname"
325dd5f96c4SPhilip Paeps# #	-DHAVE_TZNAME=1 # support "tzname", which is defined by system library
326dd5f96c4SPhilip Paeps# #	-DHAVE_TZNAME=2 # support and define "tzname"
3278d7edd17SPhilip Paeps# # to the "CFLAGS=" line.  "tzname" is required by POSIX 1988 and later.
3288d7edd17SPhilip Paeps# # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
3298d7edd17SPhilip Paeps# # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
3308d7edd17SPhilip Paeps# # crashes when combined with some platforms' standard libraries,
3318d7edd17SPhilip Paeps# # presumably due to memory allocation issues.
3328d7edd17SPhilip Paeps# #
3338d7edd17SPhilip Paeps# # To omit or support the external variables "timezone" and "daylight", add
334dd5f96c4SPhilip Paeps# #	-DUSG_COMPAT=0 # do not support
335dd5f96c4SPhilip Paeps# #	-DUSG_COMPAT=1 # support, and variables are defined by system library
336dd5f96c4SPhilip Paeps# #	-DUSG_COMPAT=2 # support and define variables
3378d7edd17SPhilip Paeps# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by
3388d7edd17SPhilip Paeps# # Unix Systems Group code and are required by POSIX 2008 (with XSI) and later.
3398d7edd17SPhilip Paeps# # If not defined, the code attempts to guess USG_COMPAT from other macros.
3408d7edd17SPhilip Paeps# #
3418d7edd17SPhilip Paeps# # To support the external variable "altzone", add
342dd5f96c4SPhilip Paeps# #	-DALTZONE=0 # do not support
343dd5f96c4SPhilip Paeps# #	-DALTZONE=1 # support "altzone", which is defined by system library
344dd5f96c4SPhilip Paeps# #	-DALTZONE=2 # support and define "altzone"
3458d7edd17SPhilip Paeps# # to the end of the "CFLAGS=" line; although "altzone" appeared in
3468d7edd17SPhilip Paeps# # System V Release 3.1 it has not been standardized.
347dd5f96c4SPhilip Paeps# # If not defined, the code attempts to guess ALTZONE from other macros.
3488d7edd17SPhilip Paeps#
349ba2b2efdSGlen Barber# If you want functions that were inspired by early versions of X3J11's work,
350ba2b2efdSGlen Barber# add
351ba2b2efdSGlen Barber#	-DSTD_INSPIRED
352cf1ad535SPhilip Paeps# to the end of the "CFLAGS=" line.  This arranges for the following
353cf1ad535SPhilip Paeps# functions to be added to the time conversion library.
354ba2b2efdSGlen Barber# "offtime" is like "gmtime" except that it accepts a second (long) argument
355ba2b2efdSGlen Barber# that gives an offset to add to the time_t when converting it.
356ba2b2efdSGlen Barber# "timelocal" is equivalent to "mktime".
357ba2b2efdSGlen Barber# "timeoff" is like "timegm" except that it accepts a second (long) argument
358ba2b2efdSGlen Barber# that gives an offset to use when converting to a time_t.
359ba2b2efdSGlen Barber# "posix2time" and "time2posix" are described in an included manual page.
360ba2b2efdSGlen Barber# X3J11's work does not describe any of these functions.
361ba2b2efdSGlen Barber# These functions may well disappear in future releases of the time
362ba2b2efdSGlen Barber# conversion package.
363ba2b2efdSGlen Barber#
364ba2b2efdSGlen Barber# If you don't want functions that were inspired by NetBSD, add
365ba2b2efdSGlen Barber#	-DNETBSD_INSPIRED=0
366ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  Otherwise, the functions
367ba2b2efdSGlen Barber# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
368*259e2ad7SPhilip Paeps# time library, and if STD_INSPIRED is also defined to nonzero the functions
369ba2b2efdSGlen Barber# "posix2time_z" and "time2posix_z" are added as well.
370ba2b2efdSGlen Barber# The functions ending in "_z" (or "_rz") are like their unsuffixed
371ba2b2efdSGlen Barber# (or suffixed-by-"_r") counterparts, except with an extra first
372ba2b2efdSGlen Barber# argument of opaque type timezone_t that specifies the timezone.
373ba2b2efdSGlen Barber# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
374ba2b2efdSGlen Barber#
375ba2b2efdSGlen Barber# If you want to allocate state structures in localtime, add
376ba2b2efdSGlen Barber#	-DALL_STATE
377ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
378ba2b2efdSGlen Barber#
379ba2b2efdSGlen Barber# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
380ba2b2efdSGlen Barber# out by the National Institute of Standards and Technology
381ba2b2efdSGlen Barber# which claims to test C and Posix conformance.  If you want to pass PCTS, add
382ba2b2efdSGlen Barber#	-DPCTS
383ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.
384ba2b2efdSGlen Barber#
385ba2b2efdSGlen Barber# If you want strict compliance with XPG4 as of 1994-04-09, add
386ba2b2efdSGlen Barber#	-DXPG4_1994_04_09
387ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
3888d7edd17SPhilip Paeps# 53 as a week number (rather than 52 or 53) for January days before
3898d7edd17SPhilip Paeps# January's first Monday when a "%V" format is used and January 1
390ba2b2efdSGlen Barber# falls on a Friday, Saturday, or Sunday.
391ba2b2efdSGlen Barber
392ba2b2efdSGlen BarberCFLAGS=
393ba2b2efdSGlen Barber
394ba2b2efdSGlen Barber# Linker flags.  Default to $(LFLAGS) for backwards compatibility
395ba2b2efdSGlen Barber# to release 2012h and earlier.
396ba2b2efdSGlen Barber
397ba2b2efdSGlen BarberLDFLAGS=	$(LFLAGS)
398ba2b2efdSGlen Barber
399ba2b2efdSGlen Barber# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
400ba2b2efdSGlen Barber# submake command lines.  The default is no leap seconds.
401ba2b2efdSGlen Barber
402ba2b2efdSGlen BarberLEAPSECONDS=
403ba2b2efdSGlen Barber
404ba2b2efdSGlen Barber# The zic command and its arguments.
405ba2b2efdSGlen Barber
406ba2b2efdSGlen Barberzic=		./zic
407ba2b2efdSGlen BarberZIC=		$(zic) $(ZFLAGS)
408ba2b2efdSGlen Barber
409ad48359aSPhilip Paeps# To shrink the size of installed TZif files,
410ad48359aSPhilip Paeps# append "-r @N" to omit data before N-seconds-after-the-Epoch.
4119142a2a3SPhilip Paeps# To grow the files and work around bugs in older applications,
4129142a2a3SPhilip Paeps# possibly at the expense of introducing bugs in newer ones,
4139142a2a3SPhilip Paeps# append "-b fat"; see ZIC_BLOAT_DEFAULT above.
4142865ab3fSPhilip Paeps# See the zic man page for more about -b and -r.
415ba2b2efdSGlen BarberZFLAGS=
416ba2b2efdSGlen Barber
41789abb9f8SPhilip Paeps# How to use zic to install TZif files.
418ba2b2efdSGlen Barber
419f2fcff28SPhilip PaepsZIC_INSTALL=	$(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS)
420ba2b2efdSGlen Barber
421ba2b2efdSGlen Barber# The name of a Posix-compliant 'awk' on your system.
4228ea5af2bSPhilip Paeps# mawk 1.3.3 and Solaris 10 /usr/bin/awk do not work.
4238ea5af2bSPhilip Paeps# Also, it is better (though not essential) if 'awk' supports UTF-8,
4248ea5af2bSPhilip Paeps# and unfortunately mawk and busybox awk do not support UTF-8.
4258ea5af2bSPhilip Paeps# Try AWK=gawk or AWK=nawk if your awk has the abovementioned problems.
426ba2b2efdSGlen BarberAWK=		awk
427ba2b2efdSGlen Barber
428ba2b2efdSGlen Barber# The full path name of a Posix-compliant shell, preferably one that supports
429ba2b2efdSGlen Barber# the Korn shell's 'select' statement as an extension.
430ba2b2efdSGlen Barber# These days, Bash is the most popular.
431ba2b2efdSGlen Barber# It should be OK to set this to /bin/sh, on platforms where /bin/sh
432ba2b2efdSGlen Barber# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
433ba2b2efdSGlen Barber# is typically nicer if it works.
434ba2b2efdSGlen BarberKSHELL=		/bin/bash
435ba2b2efdSGlen Barber
4362c5e84ccSPhilip Paeps# Name of curl <https://curl.haxx.se/>, used for HTML validation.
4372c5e84ccSPhilip PaepsCURL=		curl
4382c5e84ccSPhilip Paeps
4392865ab3fSPhilip Paeps# Name of GNU Privacy Guard <https://gnupg.org/>, used to sign distributions.
4402865ab3fSPhilip PaepsGPG=		gpg
4412865ab3fSPhilip Paeps
442ba2b2efdSGlen Barber# This expensive test requires USE_LTZ.
443ba2b2efdSGlen Barber# To suppress it, define this macro to be empty.
444ba2b2efdSGlen BarberCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
445ba2b2efdSGlen Barber
446ba2b2efdSGlen Barber# SAFE_CHAR is a regular expression that matches a safe character.
447ba2b2efdSGlen Barber# Some parts of this distribution are limited to safe characters;
448ba2b2efdSGlen Barber# others can use any UTF-8 character.
449ba2b2efdSGlen Barber# For now, the safe characters are a safe subset of ASCII.
450ba2b2efdSGlen Barber# The caller must set the shell variable 'sharp' to the character '#',
451ba2b2efdSGlen Barber# since Makefile macros cannot contain '#'.
452ba2b2efdSGlen Barber# TAB_CHAR is a single tab character, in single quotes.
453ba2b2efdSGlen BarberTAB_CHAR=	'	'
454ba2b2efdSGlen BarberSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
455ba2b2efdSGlen BarberSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
456ba2b2efdSGlen BarberSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
457ba2b2efdSGlen BarberSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
458ba2b2efdSGlen BarberSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
459ba2b2efdSGlen Barber
460*259e2ad7SPhilip Paeps# These non-alphabetic, non-ASCII printable characters are Latin-1,
461*259e2ad7SPhilip Paeps# and so are likely displayable even in editors like XEmacs 21
462*259e2ad7SPhilip Paeps# that have limited display capabilities.
463*259e2ad7SPhilip PaepsUNUSUAL_OK_LATIN_1 = ¡¢£¤¥¦§¨©«¬®¯°±²³´¶·¸¹»¼½¾¿×÷
46446bee4edSPhilip Paeps# Non-ASCII non-letters that OK_CHAR allows, as these characters are
46589abb9f8SPhilip Paeps# useful in commentary.
466*259e2ad7SPhilip PaepsUNUSUAL_OK_CHARSET= $(UNUSUAL_OK_LATIN_1)
46746bee4edSPhilip Paeps
4689f9fc6bbSPhilip Paeps# Put this in a bracket expression to match spaces.
4699f9fc6bbSPhilip Paepss = [:space:]
4709f9fc6bbSPhilip Paeps
471ba2b2efdSGlen Barber# OK_CHAR matches any character allowed in the distributed files.
47246bee4edSPhilip Paeps# This is the same as SAFE_CHAR, except that UNUSUAL_OK_CHARSET and
47346bee4edSPhilip Paeps# multibyte letters are also allowed so that commentary can contain a
47446bee4edSPhilip Paeps# few safe symbols and people's names and can quote non-English sources.
47546bee4edSPhilip Paeps# Other non-letters are limited to ASCII renderings for the
47646bee4edSPhilip Paeps# convenience of maintainers using XEmacs 21.5.34, which by default
47746bee4edSPhilip Paeps# mishandles Unicode characters U+0100 and greater.
47846bee4edSPhilip PaepsOK_CHAR=	'[][:alpha:]$(UNUSUAL_OK_CHARSET)'$(SAFE_CHARSET)'-]'
479ba2b2efdSGlen Barber
480ba2b2efdSGlen Barber# SAFE_LINE matches a line of safe characters.
481ba2b2efdSGlen Barber# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
482ba2b2efdSGlen Barber# this is so that comments can contain non-ASCII characters.
483ba2b2efdSGlen Barber# OK_LINE matches a line of OK characters.
484ba2b2efdSGlen BarberSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
485ba2b2efdSGlen BarberSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
486ba2b2efdSGlen BarberOK_LINE=	'^'$(OK_CHAR)'*$$'
487ba2b2efdSGlen Barber
488ba2b2efdSGlen Barber# Flags to give 'tar' when making a distribution.
489ba2b2efdSGlen Barber# Try to use flags appropriate for GNU tar.
4908ea5af2bSPhilip PaepsGNUTARFLAGS= --format=pax --pax-option='delete=atime,delete=ctime' \
4918ea5af2bSPhilip Paeps  --numeric-owner --owner=0 --group=0 \
4928ea5af2bSPhilip Paeps  --mode=go+u,go-w --sort=name
493ba2b2efdSGlen BarberTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
494ba2b2efdSGlen Barber		 then echo $(GNUTARFLAGS); \
495ba2b2efdSGlen Barber		 else :; \
496ba2b2efdSGlen Barber		 fi`
497ba2b2efdSGlen Barber
498ba2b2efdSGlen Barber# Flags to give 'gzip' when making a distribution.
499ba2b2efdSGlen BarberGZIPFLAGS=	-9n
500ba2b2efdSGlen Barber
501cf1ad535SPhilip Paeps# When comparing .tzs files, use GNU diff's -F'^TZ=' option if supported.
502cf1ad535SPhilip Paeps# This makes it easier to see which Zone has been affected.
503cf1ad535SPhilip PaepsDIFF_TZS=	 diff -u$$(! diff -u -F'^TZ=' - - <>/dev/null >&0 2>&1 \
504cf1ad535SPhilip Paeps			   || echo ' -F^TZ=')
505cf1ad535SPhilip Paeps
506ba2b2efdSGlen Barber###############################################################################
507ba2b2efdSGlen Barber
508ba2b2efdSGlen Barber#MAKE=		make
509ba2b2efdSGlen Barber
510ba2b2efdSGlen Barbercc=		cc
511f2fcff28SPhilip PaepsCC=		$(cc) -DTZDIR='"$(TZDIR)"'
512ba2b2efdSGlen Barber
513ba2b2efdSGlen BarberAR=		ar
514ba2b2efdSGlen Barber
515ba2b2efdSGlen Barber# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
516ba2b2efdSGlen BarberRANLIB=		:
517ba2b2efdSGlen Barber
518ba2b2efdSGlen BarberTZCOBJS=	zic.o
5198d7edd17SPhilip PaepsTZDOBJS=	zdump.o localtime.o asctime.o strftime.o
520ba2b2efdSGlen BarberDATEOBJS=	date.o localtime.o strftime.o asctime.o
521dd5f96c4SPhilip PaepsLIBSRCS=	localtime.c asctime.c difftime.c strftime.c
522dd5f96c4SPhilip PaepsLIBOBJS=	localtime.o asctime.o difftime.o strftime.o
523ba2b2efdSGlen BarberHEADERS=	tzfile.h private.h
524ba2b2efdSGlen BarberNONLIBSRCS=	zic.c zdump.c
525dd5f96c4SPhilip PaepsNEWUCBSRCS=	date.c
526ba2b2efdSGlen BarberSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
527ba2b2efdSGlen Barber			tzselect.ksh workman.sh
528ba2b2efdSGlen BarberMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
529ba2b2efdSGlen Barber			tzfile.5 tzselect.8 zic.8 zdump.8
530ba2b2efdSGlen BarberMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
531ba2b2efdSGlen Barber			time2posix.3.txt \
532ba2b2efdSGlen Barber			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
533ba2b2efdSGlen Barber			date.1.txt
5348d7edd17SPhilip PaepsCOMMON=		calendars CONTRIBUTING LICENSE Makefile \
53593d120dbSPhilip Paeps			NEWS README SECURITY theory.html version
536f2fcff28SPhilip PaepsWEB_PAGES=	tz-art.html tz-how-to.html tz-link.html
537ad48359aSPhilip PaepsCHECK_WEB_PAGES=check_theory.html check_tz-art.html \
538ad48359aSPhilip Paeps			check_tz-how-to.html check_tz-link.html
539ba2b2efdSGlen BarberDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
540ba2b2efdSGlen BarberPRIMARY_YDATA=	africa antarctica asia australasia \
541ba2b2efdSGlen Barber		europe northamerica southamerica
542afb91be3SPhilip PaepsYDATA=		$(PRIMARY_YDATA) etcetera
54312a899b6SPhilip PaepsNDATA=		factory
54412a899b6SPhilip PaepsTDATA_TO_CHECK=	$(YDATA) $(NDATA) backward
545afb91be3SPhilip PaepsTDATA=		$(YDATA) $(NDATA) $(BACKWARD)
546ba2b2efdSGlen BarberZONETABLES=	zone1970.tab zone.tab
5478d7edd17SPhilip PaepsTABDATA=	iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
548ba2b2efdSGlen BarberLEAP_DEPS=	leapseconds.awk leap-seconds.list
5499f9fc6bbSPhilip PaepsTZDATA_ZI_DEPS=	ziguard.awk zishrink.awk version $(TDATA) \
5509f9fc6bbSPhilip Paeps		  $(PACKRATDATA) $(PACKRATLIST)
5519f9fc6bbSPhilip PaepsDSTDATA_ZI_DEPS= ziguard.awk $(TDATA) $(PACKRATDATA) $(PACKRATLIST)
552afb91be3SPhilip PaepsDATA=		$(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
55312a899b6SPhilip Paeps			leapseconds $(ZONETABLES)
55446bee4edSPhilip PaepsAWK_SCRIPTS=	checklinks.awk checktab.awk leapseconds.awk \
55546bee4edSPhilip Paeps			ziguard.awk zishrink.awk
5565f33eb72SPhilip PaepsMISC=		$(AWK_SCRIPTS)
557ba2b2efdSGlen BarberTZS_YEAR=	2050
55889abb9f8SPhilip PaepsTZS_CUTOFF_FLAG=	-c $(TZS_YEAR)
559ba2b2efdSGlen BarberTZS=		to$(TZS_YEAR).tzs
560ba2b2efdSGlen BarberTZS_NEW=	to$(TZS_YEAR)new.tzs
56194c2d487SPhilip PaepsTZS_DEPS=	$(YDATA) asctime.c localtime.c \
562ba2b2efdSGlen Barber			private.h tzfile.h zdump.c zic.c
5639f9fc6bbSPhilip PaepsTZDATA_DIST = $(COMMON) $(DATA) $(MISC)
56489abb9f8SPhilip Paeps# EIGHT_YARDS is just a yard short of the whole ENCHILADA.
5659f9fc6bbSPhilip PaepsEIGHT_YARDS = $(TZDATA_DIST) $(DOCS) $(SOURCES) tzdata.zi
56689abb9f8SPhilip PaepsENCHILADA = $(EIGHT_YARDS) $(TZS)
567ba2b2efdSGlen Barber
568ba2b2efdSGlen Barber# Consult these files when deciding whether to rebuild the 'version' file.
569ba2b2efdSGlen Barber# This list is not the same as the output of 'git ls-files', since
570ba2b2efdSGlen Barber# .gitignore is not distributed.
571ba2b2efdSGlen BarberVERSION_DEPS= \
57293d120dbSPhilip Paeps		calendars CONTRIBUTING LICENSE Makefile NEWS README SECURITY \
573ba2b2efdSGlen Barber		africa antarctica asctime.c asia australasia \
574ba2b2efdSGlen Barber		backward backzone \
575ba2b2efdSGlen Barber		checklinks.awk checktab.awk \
576ba2b2efdSGlen Barber		date.1 date.c difftime.c \
577ba2b2efdSGlen Barber		etcetera europe factory iso3166.tab \
578ba2b2efdSGlen Barber		leap-seconds.list leapseconds.awk localtime.c \
579ba2b2efdSGlen Barber		newctime.3 newstrftime.3 newtzset.3 northamerica \
58012a899b6SPhilip Paeps		private.h southamerica strftime.c theory.html \
581f2fcff28SPhilip Paeps		time2posix.3 tz-art.html tz-how-to.html tz-link.html \
582ba2b2efdSGlen Barber		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
58312a899b6SPhilip Paeps		workman.sh zdump.8 zdump.c zic.8 zic.c \
584d81c2dd9SPhilip Paeps		ziguard.awk zishrink.awk \
5855f33eb72SPhilip Paeps		zone.tab zone1970.tab
586ba2b2efdSGlen Barber
587ba2b2efdSGlen Barber# And for the benefit of csh users on systems that assume the user
588ba2b2efdSGlen Barber# shell should be used to handle commands in Makefiles. . .
589ba2b2efdSGlen Barber
590ba2b2efdSGlen BarberSHELL=		/bin/sh
591ba2b2efdSGlen Barber
59212a899b6SPhilip Paepsall:		tzselect zic zdump libtz.a $(TABDATA) \
59346bee4edSPhilip Paeps		  vanguard.zi main.zi rearguard.zi
594ba2b2efdSGlen Barber
595ba2b2efdSGlen BarberALL:		all date $(ENCHILADA)
596ba2b2efdSGlen Barber
597ba2b2efdSGlen Barberinstall:	all $(DATA) $(REDO) $(MANS)
598f2fcff28SPhilip Paeps		mkdir -p '$(DESTDIR)$(BINDIR)' \
599f2fcff28SPhilip Paeps			'$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
600f2fcff28SPhilip Paeps			'$(DESTDIR)$(LIBDIR)' \
601f2fcff28SPhilip Paeps			'$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
602f2fcff28SPhilip Paeps			'$(DESTDIR)$(MANDIR)/man8'
6032865ab3fSPhilip Paeps		$(ZIC_INSTALL) -l $(LOCALTIME) \
6042865ab3fSPhilip Paeps			`case '$(POSIXRULES)' in ?*) echo '-p';; esac \
6052865ab3fSPhilip Paeps			` $(POSIXRULES) \
606f2fcff28SPhilip Paeps			-t '$(DESTDIR)$(TZDEFAULT)'
607f2fcff28SPhilip Paeps		cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
608f2fcff28SPhilip Paeps		cp tzselect '$(DESTDIR)$(BINDIR)/.'
609f2fcff28SPhilip Paeps		cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
610f2fcff28SPhilip Paeps		cp zic '$(DESTDIR)$(ZICDIR)/.'
611f2fcff28SPhilip Paeps		cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
612f2fcff28SPhilip Paeps		$(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
613f2fcff28SPhilip Paeps		cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
614f2fcff28SPhilip Paeps		cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
615f2fcff28SPhilip Paeps		cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
616ba2b2efdSGlen Barber
617ba2b2efdSGlen BarberINSTALL:	ALL install date.1
618f2fcff28SPhilip Paeps		mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
619f2fcff28SPhilip Paeps		cp date '$(DESTDIR)$(BINDIR)/.'
620f2fcff28SPhilip Paeps		cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
621ba2b2efdSGlen Barber
622dc505d53SPhilip Paeps# Calculate version number from git, if available.
623dc505d53SPhilip Paeps# Otherwise, use $(VERSION) unless it is "unknown" and there is already
624dc505d53SPhilip Paeps# a 'version' file, in which case reuse the existing 'version' contents
625dc505d53SPhilip Paeps# and append "-dirty" if the contents do not already end in "-dirty".
626ba2b2efdSGlen Barberversion:	$(VERSION_DEPS)
627ba2b2efdSGlen Barber		{ (type git) >/dev/null 2>&1 && \
628ba2b2efdSGlen Barber		  V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
629ba2b2efdSGlen Barber				--abbrev=7 --dirty` || \
630dc505d53SPhilip Paeps		  if test '$(VERSION)' = unknown && V=`cat $@`; then \
631dc505d53SPhilip Paeps		    case $$V in *-dirty);; *) V=$$V-dirty;; esac; \
632dc505d53SPhilip Paeps		  else \
633dc505d53SPhilip Paeps		    V='$(VERSION)'; \
634dc505d53SPhilip Paeps		  fi; } && \
635ba2b2efdSGlen Barber		printf '%s\n' "$$V" >$@.out
636ba2b2efdSGlen Barber		mv $@.out $@
637ba2b2efdSGlen Barber
6389f9fc6bbSPhilip Paeps# These files can be tailored by setting BACKWARD, PACKRATDATA, PACKRATLIST.
63946bee4edSPhilip Paepsvanguard.zi main.zi rearguard.zi: $(DSTDATA_ZI_DEPS)
6409f9fc6bbSPhilip Paeps		$(AWK) \
6419f9fc6bbSPhilip Paeps		  -v DATAFORM=`expr $@ : '\(.*\).zi'` \
6429f9fc6bbSPhilip Paeps		  -v PACKRATDATA='$(PACKRATDATA)' \
6439f9fc6bbSPhilip Paeps		  -v PACKRATLIST='$(PACKRATLIST)' \
6449f9fc6bbSPhilip Paeps		  -f ziguard.awk \
645d81c2dd9SPhilip Paeps		  $(TDATA) $(PACKRATDATA) >$@.out
64646bee4edSPhilip Paeps		mv $@.out $@
64789abb9f8SPhilip Paeps# This file has a version comment that attempts to capture any tailoring
6489f9fc6bbSPhilip Paeps# via BACKWARD, DATAFORM, PACKRATDATA, PACKRATLIST, and REDO.
64989abb9f8SPhilip Paepstzdata.zi:	$(DATAFORM).zi version zishrink.awk
650f2fcff28SPhilip Paeps		version=`sed 1q version` && \
65189abb9f8SPhilip Paeps		  LC_ALL=C $(AWK) \
65289abb9f8SPhilip Paeps		    -v dataform='$(DATAFORM)' \
65389abb9f8SPhilip Paeps		    -v deps='$(DSTDATA_ZI_DEPS) zishrink.awk' \
65489abb9f8SPhilip Paeps		    -v redo='$(REDO)' \
65589abb9f8SPhilip Paeps		    -v version="$$version" \
65689abb9f8SPhilip Paeps		    -f zishrink.awk \
65746bee4edSPhilip Paeps		    $(DATAFORM).zi >$@.out
6588d7edd17SPhilip Paeps		mv $@.out $@
6598d7edd17SPhilip Paeps
660ba2b2efdSGlen Barberversion.h:	version
661ba2b2efdSGlen Barber		VERSION=`cat version` && printf '%s\n' \
662ba2b2efdSGlen Barber		  'static char const PKGVERSION[]="($(PACKAGE)) ";' \
663ba2b2efdSGlen Barber		  "static char const TZVERSION[]=\"$$VERSION\";" \
664ba2b2efdSGlen Barber		  'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
665ba2b2efdSGlen Barber		  >$@.out
666ba2b2efdSGlen Barber		mv $@.out $@
667ba2b2efdSGlen Barber
668ba2b2efdSGlen Barberzdump:		$(TZDOBJS)
669ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
670ba2b2efdSGlen Barber
671ba2b2efdSGlen Barberzic:		$(TZCOBJS)
672ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
673ba2b2efdSGlen Barber
674ba2b2efdSGlen Barberleapseconds:	$(LEAP_DEPS)
675dd5f96c4SPhilip Paeps		$(AWK) -v EXPIRES_LINE=$(EXPIRES_LINE) \
676dd5f96c4SPhilip Paeps		  -f leapseconds.awk leap-seconds.list >$@.out
677ba2b2efdSGlen Barber		mv $@.out $@
678ba2b2efdSGlen Barber
679ba2b2efdSGlen Barber# Arguments to pass to submakes of install_data.
680ba2b2efdSGlen Barber# They can be overridden by later submake arguments.
681ba2b2efdSGlen BarberINSTALLARGS = \
682f2fcff28SPhilip Paeps BACKWARD='$(BACKWARD)' \
683f2fcff28SPhilip Paeps DESTDIR='$(DESTDIR)' \
684ba2b2efdSGlen Barber LEAPSECONDS='$(LEAPSECONDS)' \
685ba2b2efdSGlen Barber PACKRATDATA='$(PACKRATDATA)' \
6869f9fc6bbSPhilip Paeps PACKRATLIST='$(PACKRATLIST)' \
687f2fcff28SPhilip Paeps TZDEFAULT='$(TZDEFAULT)' \
688f2fcff28SPhilip Paeps TZDIR='$(TZDIR)' \
689ba2b2efdSGlen Barber ZIC='$(ZIC)'
690ba2b2efdSGlen Barber
69112a899b6SPhilip PaepsINSTALL_DATA_DEPS = zic leapseconds tzdata.zi
69289abb9f8SPhilip Paeps
69389abb9f8SPhilip Paeps# 'make install_data' installs one set of TZif files.
69489abb9f8SPhilip Paepsinstall_data: $(INSTALL_DATA_DEPS)
6958d7edd17SPhilip Paeps		$(ZIC_INSTALL) tzdata.zi
696ba2b2efdSGlen Barber
69789abb9f8SPhilip Paepsposix_only: $(INSTALL_DATA_DEPS)
698ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
699ba2b2efdSGlen Barber
70089abb9f8SPhilip Paepsright_only: $(INSTALL_DATA_DEPS)
701ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
702ba2b2efdSGlen Barber			install_data
703ba2b2efdSGlen Barber
704ba2b2efdSGlen Barber# In earlier versions of this makefile, the other two directories were
705ba2b2efdSGlen Barber# subdirectories of $(TZDIR).  However, this led to configuration errors.
706ba2b2efdSGlen Barber# For example, with posix_right under the earlier scheme,
707ba2b2efdSGlen Barber# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
708ba2b2efdSGlen Barber# but gmtime without leap seconds, which led to problems with applications
709ba2b2efdSGlen Barber# like sendmail that subtract gmtime from localtime.
710ba2b2efdSGlen Barber# Therefore, the other two directories are now siblings of $(TZDIR).
711ba2b2efdSGlen Barber# You must replace all of $(TZDIR) to switch from not using leap seconds
712ba2b2efdSGlen Barber# to using them, or vice versa.
713ba2b2efdSGlen Barberright_posix:	right_only
714f2fcff28SPhilip Paeps		rm -fr '$(DESTDIR)$(TZDIR)-leaps'
715f2fcff28SPhilip Paeps		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
716f2fcff28SPhilip Paeps		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
717f2fcff28SPhilip Paeps		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
718ba2b2efdSGlen Barber
719ba2b2efdSGlen Barberposix_right:	posix_only
720f2fcff28SPhilip Paeps		rm -fr '$(DESTDIR)$(TZDIR)-posix'
721f2fcff28SPhilip Paeps		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
722f2fcff28SPhilip Paeps		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
723f2fcff28SPhilip Paeps		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
724ba2b2efdSGlen Barber
725ba2b2efdSGlen Barberzones:		$(REDO)
726ba2b2efdSGlen Barber
72746bee4edSPhilip Paeps# dummy.zd is not a real file; it is mentioned here only so that the
72846bee4edSPhilip Paeps# top-level 'make' does not have a syntax error.
72946bee4edSPhilip PaepsZDS = dummy.zd
73046bee4edSPhilip Paeps# Rule used only by submakes invoked by the $(TZS_NEW) rule.
73146bee4edSPhilip Paeps# It is separate so that GNU 'make -j' can run instances in parallel.
73246bee4edSPhilip Paeps$(ZDS): zdump
73389abb9f8SPhilip Paeps		./zdump -i $(TZS_CUTOFF_FLAG) '$(wd)/'$$(expr $@ : '\(.*\).zd') \
73489abb9f8SPhilip Paeps		  >$@
73546bee4edSPhilip Paeps
73689abb9f8SPhilip PaepsTZS_NEW_DEPS = tzdata.zi zdump zic
73789abb9f8SPhilip Paeps$(TZS_NEW): $(TZS_NEW_DEPS)
73889abb9f8SPhilip Paeps		rm -fr tzs$(TZS_YEAR).dir
73989abb9f8SPhilip Paeps		mkdir tzs$(TZS_YEAR).dir
74089abb9f8SPhilip Paeps		$(zic) -d tzs$(TZS_YEAR).dir tzdata.zi
7418d7edd17SPhilip Paeps		$(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
7428d7edd17SPhilip Paeps		   tzdata.zi | LC_ALL=C sort >$@.out
743ba2b2efdSGlen Barber		wd=`pwd` && \
74489abb9f8SPhilip Paeps		x=`$(AWK) '/^Z/{print "tzs$(TZS_YEAR).dir/" $$2 ".zd"}' \
74589abb9f8SPhilip Paeps				tzdata.zi \
74646bee4edSPhilip Paeps			| LC_ALL=C sort -t . -k 2,2` && \
74789abb9f8SPhilip Paeps		set x $$x && \
74846bee4edSPhilip Paeps		shift && \
74946bee4edSPhilip Paeps		ZDS=$$* && \
75089abb9f8SPhilip Paeps		$(MAKE) wd="$$wd" TZS_CUTOFF_FLAG="$(TZS_CUTOFF_FLAG)" \
75189abb9f8SPhilip Paeps		  ZDS="$$ZDS" $$ZDS && \
75289abb9f8SPhilip Paeps		sed 's,^TZ=".*\.dir/,TZ=",' $$ZDS >>$@.out
75389abb9f8SPhilip Paeps		rm -fr tzs$(TZS_YEAR).dir
75446bee4edSPhilip Paeps		mv $@.out $@
755ba2b2efdSGlen Barber
75689abb9f8SPhilip Paeps# If $(TZS) exists but 'make check_tzs' fails, a maintainer should inspect the
757ba2b2efdSGlen Barber# failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
758ba2b2efdSGlen Barber$(TZS):
75989abb9f8SPhilip Paeps		touch $@
760ba2b2efdSGlen Barber
761ba2b2efdSGlen Barberforce_tzs:	$(TZS_NEW)
762ba2b2efdSGlen Barber		cp $(TZS_NEW) $(TZS)
763ba2b2efdSGlen Barber
764ba2b2efdSGlen Barberlibtz.a:	$(LIBOBJS)
765e350c46aSBaptiste Daroussin		rm -f $@
766e350c46aSBaptiste Daroussin		$(AR) -rc $@ $(LIBOBJS)
767ba2b2efdSGlen Barber		$(RANLIB) $@
768ba2b2efdSGlen Barber
769ba2b2efdSGlen Barberdate:		$(DATEOBJS)
770ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
771ba2b2efdSGlen Barber
772ba2b2efdSGlen Barbertzselect:	tzselect.ksh version
773ba2b2efdSGlen Barber		VERSION=`cat version` && sed \
774ba2b2efdSGlen Barber			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
7758ea5af2bSPhilip Paeps			-e 's|AWK=[^}]*|AWK='\''$(AWK)'\''|g' \
776ba2b2efdSGlen Barber			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
777ba2b2efdSGlen Barber			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
778ba2b2efdSGlen Barber			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
779ba2b2efdSGlen Barber			-e 's|\(TZVERSION\)=.*|\1='"$$VERSION"'|' \
780ba2b2efdSGlen Barber			<$@.ksh >$@.out
781ba2b2efdSGlen Barber		chmod +x $@.out
782ba2b2efdSGlen Barber		mv $@.out $@
783ba2b2efdSGlen Barber
784cf1ad535SPhilip Paepscheck: check_back check_mild
785cf1ad535SPhilip Paepscheck_mild:	check_character_set check_white_space check_links \
7869f9fc6bbSPhilip Paeps		  check_name_lengths check_slashed_abbrs check_sorted \
7879f9fc6bbSPhilip Paeps		  check_tables check_web check_ziguard check_zishrink check_tzs
788ba2b2efdSGlen Barber
789ba2b2efdSGlen Barbercheck_character_set: $(ENCHILADA)
7908d7edd17SPhilip Paeps	test ! '$(UTF8_LOCALE)' || \
7918d7edd17SPhilip Paeps	! printf 'A\304\200B\n' | \
7928d7edd17SPhilip Paeps	  LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 || { \
7938d7edd17SPhilip Paeps		LC_ALL='$(UTF8_LOCALE)' && export LC_ALL && \
794ba2b2efdSGlen Barber		sharp='#' && \
795ba2b2efdSGlen Barber		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
796ba2b2efdSGlen Barber			$(MISC) $(SOURCES) $(WEB_PAGES) \
79793d120dbSPhilip Paeps			CONTRIBUTING LICENSE README SECURITY \
7988d7edd17SPhilip Paeps			version tzdata.zi && \
79989abb9f8SPhilip Paeps		! grep -Env $(SAFE_LINE)'|^UNUSUAL_OK_'$(OK_CHAR)'*$$' \
80046bee4edSPhilip Paeps			Makefile && \
801afb91be3SPhilip Paeps		! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
80212a899b6SPhilip Paeps			leapseconds zone.tab && \
8038d7edd17SPhilip Paeps		! grep -Env $(OK_LINE) $(ENCHILADA); \
8048d7edd17SPhilip Paeps	}
80589abb9f8SPhilip Paeps	touch $@
806ba2b2efdSGlen Barber
807ba2b2efdSGlen Barbercheck_white_space: $(ENCHILADA)
808ba2b2efdSGlen Barber		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
80989abb9f8SPhilip Paeps		! grep -En "$$pat" \
81089abb9f8SPhilip Paeps			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
8119f9fc6bbSPhilip Paeps		! grep -n '[$s]$$' \
812afb91be3SPhilip Paeps			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
81389abb9f8SPhilip Paeps		touch $@
814ba2b2efdSGlen Barber
8159f9fc6bbSPhilip PaepsPRECEDES_FILE_NAME = ^(Zone|Link[$s]+[^$s]+)[$s]+
8169f9fc6bbSPhilip PaepsFILE_NAME_COMPONENT_TOO_LONG = $(PRECEDES_FILE_NAME)[^$s]*[^/$s]{15}
8178d7edd17SPhilip Paeps
818afb91be3SPhilip Paepscheck_name_lengths: $(TDATA_TO_CHECK) backzone
819afb91be3SPhilip Paeps		! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
820afb91be3SPhilip Paeps			$(TDATA_TO_CHECK) backzone
82189abb9f8SPhilip Paeps		touch $@
8228d7edd17SPhilip Paeps
8239f9fc6bbSPhilip PaepsPRECEDES_STDOFF = ^(Zone[$s]+[^$s]+)?[$s]+
8249f9fc6bbSPhilip PaepsSTDOFF = [-+]?[0-9:.]+
8259f9fc6bbSPhilip PaepsRULELESS_SAVE = (-|$(STDOFF)[sd]?)
8269f9fc6bbSPhilip PaepsRULELESS_SLASHED_ABBRS = \
8279f9fc6bbSPhilip Paeps  $(PRECEDES_STDOFF)$(STDOFF)[$s]+$(RULELESS_SAVE)[$s]+[^$s]*/
8289f9fc6bbSPhilip Paeps
8299f9fc6bbSPhilip Paepscheck_slashed_abbrs: $(TDATA_TO_CHECK)
8309f9fc6bbSPhilip Paeps		! grep -En '$(RULELESS_SLASHED_ABBRS)' $(TDATA_TO_CHECK)
8319f9fc6bbSPhilip Paeps		touch $@
8329f9fc6bbSPhilip Paeps
833ba2b2efdSGlen BarberCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
834ba2b2efdSGlen Barber
835*259e2ad7SPhilip Paepscheck_sorted: backward backzone
836cf1ad535SPhilip Paeps		$(AWK) '/^Link/ {printf "%.5d %s\n", g, $$3} !/./ {g++}' \
8379142a2a3SPhilip Paeps		  backward | LC_ALL=C sort -cu
838ba2b2efdSGlen Barber		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
83989abb9f8SPhilip Paeps		touch $@
840ba2b2efdSGlen Barber
841cf1ad535SPhilip Paepscheck_back:	checklinks.awk $(TDATA_TO_CHECK)
8429142a2a3SPhilip Paeps		$(AWK) \
8439142a2a3SPhilip Paeps		  -v DATAFORM=$(DATAFORM) \
8449142a2a3SPhilip Paeps		  -v backcheck=backward \
8459142a2a3SPhilip Paeps		  -f checklinks.awk $(TDATA_TO_CHECK)
846cf1ad535SPhilip Paeps		touch $@
847cf1ad535SPhilip Paeps
848cf1ad535SPhilip Paepscheck_links:	checklinks.awk tzdata.zi
8499142a2a3SPhilip Paeps		$(AWK) \
8509142a2a3SPhilip Paeps		  -v DATAFORM=$(DATAFORM) \
8519142a2a3SPhilip Paeps		  -f checklinks.awk tzdata.zi
85289abb9f8SPhilip Paeps		touch $@
853ba2b2efdSGlen Barber
85494c2d487SPhilip Paepscheck_tables:	checktab.awk $(YDATA) backward $(ZONETABLES)
855ba2b2efdSGlen Barber		for tab in $(ZONETABLES); do \
85694c2d487SPhilip Paeps		  test "$$tab" = zone.tab && links='$(BACKWARD)' || links=''; \
85794c2d487SPhilip Paeps		  $(AWK) -f checktab.awk -v zone_table=$$tab $(YDATA) $$links \
858ba2b2efdSGlen Barber		    || exit; \
859ba2b2efdSGlen Barber		done
86089abb9f8SPhilip Paeps		touch $@
861ba2b2efdSGlen Barber
862ba2b2efdSGlen Barbercheck_tzs:	$(TZS) $(TZS_NEW)
86389abb9f8SPhilip Paeps		if test -s $(TZS); then \
864cf1ad535SPhilip Paeps		  $(DIFF_TZS) $(TZS) $(TZS_NEW); \
86589abb9f8SPhilip Paeps		else \
86689abb9f8SPhilip Paeps		  cp $(TZS_NEW) $(TZS); \
86789abb9f8SPhilip Paeps		fi
86889abb9f8SPhilip Paeps		touch $@
869ba2b2efdSGlen Barber
8702c5e84ccSPhilip Paepscheck_web:	$(CHECK_WEB_PAGES)
871ad48359aSPhilip Paepscheck_theory.html: theory.html
8722c5e84ccSPhilip Paepscheck_tz-art.html: tz-art.html
87312a899b6SPhilip Paepscheck_tz-how-to.html: tz-how-to.html
8742c5e84ccSPhilip Paepscheck_tz-link.html: tz-link.html
87512a899b6SPhilip Paepscheck_theory.html check_tz-art.html check_tz-how-to.html check_tz-link.html:
8762c5e84ccSPhilip Paeps		$(CURL) -sS --url https://validator.w3.org/nu/ -F out=gnu \
8772c5e84ccSPhilip Paeps		    -F file=@$$(expr $@ : 'check_\(.*\)') -o $@.out && \
8782c5e84ccSPhilip Paeps		  test ! -s $@.out || { cat $@.out; exit 1; }
8792c5e84ccSPhilip Paeps		mv $@.out $@
8808d7edd17SPhilip Paeps
8819f9fc6bbSPhilip Paepscheck_ziguard: rearguard.zi vanguard.zi ziguard.awk
8829f9fc6bbSPhilip Paeps		$(AWK) -v DATAFORM=rearguard -f ziguard.awk vanguard.zi | \
8839f9fc6bbSPhilip Paeps		  diff -u rearguard.zi -
8849f9fc6bbSPhilip Paeps		$(AWK) -v DATAFORM=vanguard -f ziguard.awk rearguard.zi | \
8859f9fc6bbSPhilip Paeps		  diff -u vanguard.zi -
8869f9fc6bbSPhilip Paeps		touch $@
8879f9fc6bbSPhilip Paeps
88846bee4edSPhilip Paeps# Check that zishrink.awk does not alter the data, and that ziguard.awk
88946bee4edSPhilip Paeps# preserves main-format data.
89089abb9f8SPhilip Paepscheck_zishrink: check_zishrink_posix check_zishrink_right
89189abb9f8SPhilip Paepscheck_zishrink_posix check_zishrink_right: \
8929f9fc6bbSPhilip Paeps  zic leapseconds $(PACKRATDATA) $(PACKRATLIST) \
8939f9fc6bbSPhilip Paeps  $(TDATA) $(DATAFORM).zi tzdata.zi
89489abb9f8SPhilip Paeps		rm -fr $@.dir $@-t.dir $@-shrunk.dir
89589abb9f8SPhilip Paeps		mkdir $@.dir $@-t.dir $@-shrunk.dir
89689abb9f8SPhilip Paeps		case $@ in \
89789abb9f8SPhilip Paeps		  *_right) leap='-L leapseconds';; \
8988d7edd17SPhilip Paeps		  *) leap=;; \
8998d7edd17SPhilip Paeps		esac && \
90089abb9f8SPhilip Paeps		  $(ZIC) $$leap -d $@.dir $(DATAFORM).zi && \
90189abb9f8SPhilip Paeps		  $(ZIC) $$leap -d $@-shrunk.dir tzdata.zi && \
9029f9fc6bbSPhilip Paeps		  case $(DATAFORM),$(PACKRATLIST) in \
9039f9fc6bbSPhilip Paeps		    main,) \
90489abb9f8SPhilip Paeps		      $(ZIC) $$leap -d $@-t.dir $(TDATA) && \
9058d7edd17SPhilip Paeps		      $(AWK) '/^Rule/' $(TDATA) | \
90689abb9f8SPhilip Paeps			$(ZIC) $$leap -d $@-t.dir - $(PACKRATDATA) && \
90789abb9f8SPhilip Paeps		      diff -r $@.dir $@-t.dir;; \
90889abb9f8SPhilip Paeps		  esac
90989abb9f8SPhilip Paeps		diff -r $@.dir $@-shrunk.dir
91089abb9f8SPhilip Paeps		rm -fr $@.dir $@-t.dir $@-shrunk.dir
91189abb9f8SPhilip Paeps		touch $@
912ba2b2efdSGlen Barber
913ba2b2efdSGlen Barberclean_misc:
914ad48359aSPhilip Paeps		rm -fr check_*.dir
91589abb9f8SPhilip Paeps		rm -f *.o *.out $(TIME_T_ALTERNATIVES) \
91689abb9f8SPhilip Paeps		  check_* core typecheck_* \
91712a899b6SPhilip Paeps		  date tzselect version.h zdump zic libtz.a
918ba2b2efdSGlen Barberclean:		clean_misc
919ad48359aSPhilip Paeps		rm -fr *.dir tzdb-*/
920ad48359aSPhilip Paeps		rm -f *.zi $(TZS_NEW)
921ba2b2efdSGlen Barber
922ba2b2efdSGlen Barbermaintainer-clean: clean
923ba2b2efdSGlen Barber		@echo 'This command is intended for maintainers to use; it'
924ba2b2efdSGlen Barber		@echo 'deletes files that may need special tools to rebuild.'
925ba2b2efdSGlen Barber		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
926ba2b2efdSGlen Barber
927ba2b2efdSGlen Barbernames:
928ba2b2efdSGlen Barber		@echo $(ENCHILADA)
929ba2b2efdSGlen Barber
930ba2b2efdSGlen Barberpublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
931ba2b2efdSGlen Barber		tarballs signatures
932ba2b2efdSGlen Barber
933ba2b2efdSGlen Barberdate.1.txt:	date.1
934ba2b2efdSGlen Barbernewctime.3.txt:	newctime.3
935ba2b2efdSGlen Barbernewstrftime.3.txt: newstrftime.3
936ba2b2efdSGlen Barbernewtzset.3.txt:	newtzset.3
937ba2b2efdSGlen Barbertime2posix.3.txt: time2posix.3
938ba2b2efdSGlen Barbertzfile.5.txt:	tzfile.5
939ba2b2efdSGlen Barbertzselect.8.txt:	tzselect.8
940ba2b2efdSGlen Barberzdump.8.txt:	zdump.8
941ba2b2efdSGlen Barberzic.8.txt:	zic.8
942ba2b2efdSGlen Barber
943ba2b2efdSGlen Barber$(MANTXTS):	workman.sh
944ba2b2efdSGlen Barber		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out
945ba2b2efdSGlen Barber		mv $@.out $@
946ba2b2efdSGlen Barber
947dc505d53SPhilip Paeps# Set file timestamps deterministically if possible,
948dc505d53SPhilip Paeps# so that tarballs containing the timestamps are reproducible.
949dc505d53SPhilip Paeps#
950dc505d53SPhilip Paeps# '$(SET_TIMESTAMP_N) N DEST A B C ...' sets the timestamp of the
951dc505d53SPhilip Paeps# file DEST to the maximum of the timestamps of the files A B C ...,
952dc505d53SPhilip Paeps# plus N if GNU ls and touch are available.
953dc505d53SPhilip PaepsSET_TIMESTAMP_N = sh -c '\
954dc505d53SPhilip Paeps  n=$$0 dest=$$1; shift; \
955dc505d53SPhilip Paeps  touch -cmr `ls -t "$$@" | sed 1q` "$$dest" && \
956dc505d53SPhilip Paeps  if test $$n != 0 && \
957dc505d53SPhilip Paeps     lsout=`ls -n --time-style="+%s" "$$dest" 2>/dev/null`; then \
958dc505d53SPhilip Paeps    set x $$lsout && \
959dc505d53SPhilip Paeps    touch -cmd @`expr $$7 + $$n` "$$dest"; \
960dc505d53SPhilip Paeps  else :; fi'
961dc505d53SPhilip Paeps# If DEST depends on A B C ... in this Makefile, callers should use
962dc505d53SPhilip Paeps# $(SET_TIMESTAMP_DEP) DEST A B C ..., for the benefit of any
963dc505d53SPhilip Paeps# downstream 'make' that considers equal timestamps to be out of date.
964dc505d53SPhilip Paeps# POSIX allows this 'make' behavior, and HP-UX 'make' does it.
965dc505d53SPhilip Paeps# If all that matters is that the timestamp be reproducible
966dc505d53SPhilip Paeps# and plausible, use $(SET_TIMESTAMP).
967dc505d53SPhilip PaepsSET_TIMESTAMP = $(SET_TIMESTAMP_N) 0
968dc505d53SPhilip PaepsSET_TIMESTAMP_DEP = $(SET_TIMESTAMP_N) 1
969dc505d53SPhilip Paeps
970ba2b2efdSGlen Barber# Set the timestamps to those of the git repository, if available,
971ba2b2efdSGlen Barber# and if the files have not changed since then.
972dc505d53SPhilip Paeps# This uses GNU 'ls --time-style=+%s', which outputs the seconds count,
973dc505d53SPhilip Paeps# and GNU 'touch -d@N FILE', where N is the number of seconds since 1970.
974dc505d53SPhilip Paeps# If git or GNU is absent, don't bother to sync with git timestamps.
975ba2b2efdSGlen Barber# Also, set the timestamp of each prebuilt file like 'leapseconds'
976ba2b2efdSGlen Barber# to be the maximum of the files it depends on.
97789abb9f8SPhilip Paepsset-timestamps.out: $(EIGHT_YARDS)
978ba2b2efdSGlen Barber		rm -f $@
979ba2b2efdSGlen Barber		if (type git) >/dev/null 2>&1 && \
98089abb9f8SPhilip Paeps		   files=`git ls-files $(EIGHT_YARDS)` && \
981ba2b2efdSGlen Barber		   touch -md @1 test.out; then \
982ba2b2efdSGlen Barber		  rm -f test.out && \
983ba2b2efdSGlen Barber		  for file in $$files; do \
984ba2b2efdSGlen Barber		    if git diff --quiet $$file; then \
985ba2b2efdSGlen Barber		      time=`git log -1 --format='tformat:%ct' $$file` && \
986ba2b2efdSGlen Barber		      touch -cmd @$$time $$file; \
987ba2b2efdSGlen Barber		    else \
988ba2b2efdSGlen Barber		      echo >&2 "$$file: warning: does not match repository"; \
989ba2b2efdSGlen Barber		    fi || exit; \
990ba2b2efdSGlen Barber		  done; \
991ba2b2efdSGlen Barber		fi
992dc505d53SPhilip Paeps		$(SET_TIMESTAMP_DEP) leapseconds $(LEAP_DEPS)
993ba2b2efdSGlen Barber		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
994dc505d53SPhilip Paeps		  $(SET_TIMESTAMP_DEP) $$file.txt $$file workman.sh || \
995ba2b2efdSGlen Barber		    exit; \
996ba2b2efdSGlen Barber		done
997dc505d53SPhilip Paeps		$(SET_TIMESTAMP_DEP) version $(VERSION_DEPS)
998dc505d53SPhilip Paeps		$(SET_TIMESTAMP_DEP) tzdata.zi $(TZDATA_ZI_DEPS)
999ba2b2efdSGlen Barber		touch $@
100089abb9f8SPhilip Paepsset-tzs-timestamp.out: $(TZS)
1001dc505d53SPhilip Paeps		$(SET_TIMESTAMP_DEP) $(TZS) $(TZS_DEPS)
100289abb9f8SPhilip Paeps		touch $@
1003ba2b2efdSGlen Barber
1004ba2b2efdSGlen Barber# The zics below ensure that each data file can stand on its own.
1005ba2b2efdSGlen Barber# We also do an all-files run to catch links to links.
1006ba2b2efdSGlen Barber
100789abb9f8SPhilip Paepscheck_public: $(VERSION_DEPS)
1008ba2b2efdSGlen Barber		rm -fr public.dir
100989abb9f8SPhilip Paeps		mkdir public.dir
101089abb9f8SPhilip Paeps		ln $(VERSION_DEPS) public.dir
101189abb9f8SPhilip Paeps		cd public.dir && $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' ALL
1012e35a01eeSPhilip Paeps		for i in $(TDATA_TO_CHECK) public.dir/tzdata.zi \
1013e35a01eeSPhilip Paeps		    public.dir/vanguard.zi public.dir/main.zi \
1014e35a01eeSPhilip Paeps		    public.dir/rearguard.zi; \
1015e35a01eeSPhilip Paeps		do \
101689abb9f8SPhilip Paeps		  public.dir/zic -v -d public.dir/zoneinfo $$i 2>&1 || exit; \
101789abb9f8SPhilip Paeps		done
101889abb9f8SPhilip Paeps		public.dir/zic -v -d public.dir/zoneinfo-all $(TDATA_TO_CHECK)
101994c2d487SPhilip Paeps		:
102094c2d487SPhilip Paeps		: Also check 'backzone' syntax.
102194c2d487SPhilip Paeps		rm public.dir/main.zi
102294c2d487SPhilip Paeps		cd public.dir && $(MAKE) PACKRATDATA=backzone main.zi
102394c2d487SPhilip Paeps		public.dir/zic -d public.dir/zoneinfo main.zi
10249f9fc6bbSPhilip Paeps		rm public.dir/main.zi
10259f9fc6bbSPhilip Paeps		cd public.dir && \
10269f9fc6bbSPhilip Paeps		  $(MAKE) PACKRATDATA=backzone PACKRATLIST=zone.tab main.zi
10279f9fc6bbSPhilip Paeps		public.dir/zic -d public.dir/zoneinfo main.zi
102894c2d487SPhilip Paeps		:
102989abb9f8SPhilip Paeps		rm -fr public.dir
103089abb9f8SPhilip Paeps		touch $@
1031ba2b2efdSGlen Barber
1032ba2b2efdSGlen Barber# Check that the code works under various alternative
1033ba2b2efdSGlen Barber# implementations of time_t.
103489abb9f8SPhilip Paepscheck_time_t_alternatives: $(TIME_T_ALTERNATIVES)
103589abb9f8SPhilip Paeps$(TIME_T_ALTERNATIVES_TAIL): $(TIME_T_ALTERNATIVES_HEAD)
103689abb9f8SPhilip Paeps$(TIME_T_ALTERNATIVES): $(VERSION_DEPS)
103789abb9f8SPhilip Paeps		rm -fr $@.dir
103889abb9f8SPhilip Paeps		mkdir $@.dir
103989abb9f8SPhilip Paeps		ln $(VERSION_DEPS) $@.dir
104089abb9f8SPhilip Paeps		case $@ in \
104194c2d487SPhilip Paeps		  int*32_t) range=-2147483648,2147483648;; \
104289abb9f8SPhilip Paeps		  u*) range=0,4294967296;; \
104389abb9f8SPhilip Paeps		  *) range=-4294967296,4294967296;; \
104489abb9f8SPhilip Paeps		esac && \
104589abb9f8SPhilip Paeps		wd=`pwd` && \
104689abb9f8SPhilip Paeps		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
104789abb9f8SPhilip Paeps		if test $@ = $(TIME_T_ALTERNATIVES_HEAD); then \
104889abb9f8SPhilip Paeps		  range_target=; \
104989abb9f8SPhilip Paeps		else \
105089abb9f8SPhilip Paeps		  range_target=to$$range.tzs; \
105189abb9f8SPhilip Paeps		fi && \
105289abb9f8SPhilip Paeps		(cd $@.dir && \
105389abb9f8SPhilip Paeps		  $(MAKE) TOPDIR="$$wd/$@.dir" \
105489abb9f8SPhilip Paeps		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$@'" \
105589abb9f8SPhilip Paeps		    REDO='$(REDO)' \
105689abb9f8SPhilip Paeps			D=$$wd/$@.dir \
105789abb9f8SPhilip Paeps		    TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
105889abb9f8SPhilip Paeps		    install $$range_target) && \
105989abb9f8SPhilip Paeps		test $@ = $(TIME_T_ALTERNATIVES_HEAD) || { \
106089abb9f8SPhilip Paeps		  (cd $(TIME_T_ALTERNATIVES_HEAD).dir && \
106189abb9f8SPhilip Paeps		    $(MAKE) TOPDIR="$$wd/$@.dir" \
106289abb9f8SPhilip Paeps		      TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
106389abb9f8SPhilip Paeps			D=$$wd/$@.dir \
106489abb9f8SPhilip Paeps		      to$$range.tzs) && \
1065cf1ad535SPhilip Paeps		  $(DIFF_TZS) $(TIME_T_ALTERNATIVES_HEAD).dir/to$$range.tzs \
106689abb9f8SPhilip Paeps			  $@.dir/to$$range.tzs && \
1067ba2b2efdSGlen Barber		  if diff -q Makefile Makefile 2>/dev/null; then \
1068ba2b2efdSGlen Barber		    quiet_option='-q'; \
1069ba2b2efdSGlen Barber		  else \
1070ba2b2efdSGlen Barber		    quiet_option=''; \
1071ba2b2efdSGlen Barber		  fi && \
107289abb9f8SPhilip Paeps		    diff $$quiet_option -r $(TIME_T_ALTERNATIVES_HEAD).dir/etc \
107389abb9f8SPhilip Paeps					   $@.dir/etc && \
1074ba2b2efdSGlen Barber		    diff $$quiet_option -r \
107589abb9f8SPhilip Paeps		      $(TIME_T_ALTERNATIVES_HEAD).dir/usr/share \
107689abb9f8SPhilip Paeps		      $@.dir/usr/share; \
107789abb9f8SPhilip Paeps		}
107889abb9f8SPhilip Paeps		touch $@
1079ba2b2efdSGlen Barber
1080d81c2dd9SPhilip PaepsTRADITIONAL_ASC = \
1081d81c2dd9SPhilip Paeps  tzcode$(VERSION).tar.gz.asc \
1082d81c2dd9SPhilip Paeps  tzdata$(VERSION).tar.gz.asc
108389abb9f8SPhilip PaepsREARGUARD_ASC = \
108489abb9f8SPhilip Paeps  tzdata$(VERSION)-rearguard.tar.gz.asc
108589abb9f8SPhilip PaepsALL_ASC = $(TRADITIONAL_ASC) $(REARGUARD_ASC) \
1086d81c2dd9SPhilip Paeps  tzdb-$(VERSION).tar.lz.asc
1087d81c2dd9SPhilip Paeps
10889f9fc6bbSPhilip Paepstarballs rearguard_tarballs tailored_tarballs traditional_tarballs \
108989abb9f8SPhilip Paepssignatures rearguard_signatures traditional_signatures: \
10909f9fc6bbSPhilip Paeps  version set-timestamps.out rearguard.zi vanguard.zi
1091ba2b2efdSGlen Barber		VERSION=`cat version` && \
1092dc505d53SPhilip Paeps		$(MAKE) AWK='$(AWK)' VERSION="$$VERSION" $@_version
1093ba2b2efdSGlen Barber
109446bee4edSPhilip Paeps# These *_version rules are intended for use if VERSION is set by some
109546bee4edSPhilip Paeps# other means.  Ordinarily these rules are used only by the above
109646bee4edSPhilip Paeps# non-_version rules, which set VERSION on the 'make' command line.
109789abb9f8SPhilip Paepstarballs_version: traditional_tarballs_version rearguard_tarballs_version \
1098d81c2dd9SPhilip Paeps  tzdb-$(VERSION).tar.lz
109989abb9f8SPhilip Paepsrearguard_tarballs_version: \
110089abb9f8SPhilip Paeps  tzdata$(VERSION)-rearguard.tar.gz
1101ba2b2efdSGlen Barbertraditional_tarballs_version: \
1102ba2b2efdSGlen Barber  tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
11039f9fc6bbSPhilip Paepstailored_tarballs_version: \
11049f9fc6bbSPhilip Paeps  tzdata$(VERSION)-tailored.tar.gz
1105d81c2dd9SPhilip Paepssignatures_version: $(ALL_ASC)
110689abb9f8SPhilip Paepsrearguard_signatures_version: $(REARGUARD_ASC)
1107d81c2dd9SPhilip Paepstraditional_signatures_version: $(TRADITIONAL_ASC)
1108ba2b2efdSGlen Barber
1109ba2b2efdSGlen Barbertzcode$(VERSION).tar.gz: set-timestamps.out
1110ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
1111ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - \
1112ba2b2efdSGlen Barber		    $(COMMON) $(DOCS) $(SOURCES) | \
1113ba2b2efdSGlen Barber		  gzip $(GZIPFLAGS) >$@.out
1114ba2b2efdSGlen Barber		mv $@.out $@
1115ba2b2efdSGlen Barber
1116ba2b2efdSGlen Barbertzdata$(VERSION).tar.gz: set-timestamps.out
1117ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
11189f9fc6bbSPhilip Paeps		tar $(TARFLAGS) -cf - $(TZDATA_DIST) | \
1119ba2b2efdSGlen Barber		  gzip $(GZIPFLAGS) >$@.out
1120ba2b2efdSGlen Barber		mv $@.out $@
1121ba2b2efdSGlen Barber
11229f9fc6bbSPhilip Paeps# Create empty files with a reproducible timestamp.
11239f9fc6bbSPhilip PaepsCREATE_EMPTY = TZ=UTC0 touch -mt 202010122253.00
11249f9fc6bbSPhilip Paeps
11259f9fc6bbSPhilip Paeps# The obsolescent *rearguard* targets and related macros are present
11269f9fc6bbSPhilip Paeps# for backwards compatibility with tz releases 2018e through 2022a.
11279f9fc6bbSPhilip Paeps# They should go away eventually.  To build rearguard tarballs you
11289f9fc6bbSPhilip Paeps# can instead use 'make DATAFORM=rearguard tailored_tarballs'.
1129d81c2dd9SPhilip Paepstzdata$(VERSION)-rearguard.tar.gz: rearguard.zi set-timestamps.out
11309f9fc6bbSPhilip Paeps		rm -fr $@.dir
11319f9fc6bbSPhilip Paeps		mkdir $@.dir
11329f9fc6bbSPhilip Paeps		ln $(TZDATA_DIST) $@.dir
11339f9fc6bbSPhilip Paeps		cd $@.dir && rm -f $(TDATA) $(PACKRATDATA) version
1134d81c2dd9SPhilip Paeps		for f in $(TDATA) $(PACKRATDATA); do \
11359f9fc6bbSPhilip Paeps		  rearf=$@.dir/$$f; \
1136d81c2dd9SPhilip Paeps		  $(AWK) -v DATAFORM=rearguard -f ziguard.awk $$f >$$rearf && \
1137dc505d53SPhilip Paeps		  $(SET_TIMESTAMP_DEP) $$rearf ziguard.awk $$f || exit; \
1138d81c2dd9SPhilip Paeps		done
11399f9fc6bbSPhilip Paeps		sed '1s/$$/-rearguard/' <version >$@.dir/version
1140e7e2d659SPhilip Paeps		: The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
11419f9fc6bbSPhilip Paeps		$(CREATE_EMPTY) $@.dir/pacificnew
11429f9fc6bbSPhilip Paeps		touch -cmr version $@.dir/version
1143d81c2dd9SPhilip Paeps		LC_ALL=C && export LC_ALL && \
11449f9fc6bbSPhilip Paeps		  (cd $@.dir && \
1145e7e2d659SPhilip Paeps		   tar $(TARFLAGS) -cf - \
11469f9fc6bbSPhilip Paeps			$(TZDATA_DIST) pacificnew | \
1147d81c2dd9SPhilip Paeps		     gzip $(GZIPFLAGS)) >$@.out
1148d81c2dd9SPhilip Paeps		mv $@.out $@
1149d81c2dd9SPhilip Paeps
11509f9fc6bbSPhilip Paeps# Create a tailored tarball suitable for TZUpdater and compatible tools.
11519f9fc6bbSPhilip Paeps# For example, 'make DATAFORM=vanguard tailored_tarballs' makes a tarball
11529f9fc6bbSPhilip Paeps# useful for testing whether TZUpdater supports vanguard form.
11539f9fc6bbSPhilip Paeps# The generated tarball is not byte-for-byte equivalent to a hand-tailored
11549f9fc6bbSPhilip Paeps# traditional tarball, as data entries are put into 'etcetera' even if they
11559f9fc6bbSPhilip Paeps# came from some other source file.  However, the effect should be the same
11569f9fc6bbSPhilip Paeps# for ordinary use, which reads all the source files.
11579f9fc6bbSPhilip Paepstzdata$(VERSION)-tailored.tar.gz: set-timestamps.out
11589f9fc6bbSPhilip Paeps		rm -fr $@.dir
11599f9fc6bbSPhilip Paeps		mkdir $@.dir
11609f9fc6bbSPhilip Paeps		: The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
11619f9fc6bbSPhilip Paeps		cd $@.dir && \
11629f9fc6bbSPhilip Paeps		  $(CREATE_EMPTY) $(PRIMARY_YDATA) $(NDATA) backward \
11639f9fc6bbSPhilip Paeps		  `test $(DATAFORM) = vanguard || echo pacificnew`
11649f9fc6bbSPhilip Paeps		(grep '^#' tzdata.zi && echo && cat $(DATAFORM).zi) \
11659f9fc6bbSPhilip Paeps		  >$@.dir/etcetera
11669f9fc6bbSPhilip Paeps		touch -cmr tzdata.zi $@.dir/etcetera
11679f9fc6bbSPhilip Paeps		sed -n \
11689f9fc6bbSPhilip Paeps		  -e '/^# *version  *\(.*\)/h' \
11699f9fc6bbSPhilip Paeps		  -e '/^# *ddeps  */H' \
11709f9fc6bbSPhilip Paeps		  -e '$$!d' \
11719f9fc6bbSPhilip Paeps		  -e 'g' \
11729f9fc6bbSPhilip Paeps		  -e 's/^# *version  *//' \
11739f9fc6bbSPhilip Paeps		  -e 's/\n# *ddeps  */-/' \
11749f9fc6bbSPhilip Paeps		  -e 's/ /-/g' \
11759f9fc6bbSPhilip Paeps		  -e 'p' \
11769f9fc6bbSPhilip Paeps		  <tzdata.zi >$@.dir/version
11779f9fc6bbSPhilip Paeps		touch -cmr version $@.dir/version
11789f9fc6bbSPhilip Paeps		links= && \
11799f9fc6bbSPhilip Paeps		  for file in $(TZDATA_DIST); do \
11809f9fc6bbSPhilip Paeps		    test -f $@.dir/$$file || links="$$links $$file"; \
11819f9fc6bbSPhilip Paeps		  done && \
11829f9fc6bbSPhilip Paeps		  ln $$links $@.dir
11839f9fc6bbSPhilip Paeps		LC_ALL=C && export LC_ALL && \
11849f9fc6bbSPhilip Paeps		  (cd $@.dir && \
11859f9fc6bbSPhilip Paeps		   tar $(TARFLAGS) -cf - * | gzip $(GZIPFLAGS)) >$@.out
11869f9fc6bbSPhilip Paeps		mv $@.out $@
11879f9fc6bbSPhilip Paeps
118889abb9f8SPhilip Paepstzdb-$(VERSION).tar.lz: set-timestamps.out set-tzs-timestamp.out
1189ba2b2efdSGlen Barber		rm -fr tzdb-$(VERSION)
1190ba2b2efdSGlen Barber		mkdir tzdb-$(VERSION)
1191ba2b2efdSGlen Barber		ln $(ENCHILADA) tzdb-$(VERSION)
1192dc505d53SPhilip Paeps		$(SET_TIMESTAMP) tzdb-$(VERSION) tzdb-$(VERSION)/*
1193ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
1194ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out
1195ba2b2efdSGlen Barber		mv $@.out $@
1196ba2b2efdSGlen Barber
1197ba2b2efdSGlen Barbertzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
1198ba2b2efdSGlen Barbertzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
1199d81c2dd9SPhilip Paepstzdata$(VERSION)-rearguard.tar.gz.asc: tzdata$(VERSION)-rearguard.tar.gz
1200ba2b2efdSGlen Barbertzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
1201d81c2dd9SPhilip Paeps$(ALL_ASC):
12022865ab3fSPhilip Paeps		$(GPG) --armor --detach-sign $?
1203ba2b2efdSGlen Barber
120489abb9f8SPhilip PaepsTYPECHECK_CFLAGS = $(CFLAGS) -DTYPECHECK -D__time_t_defined -D_TIME_T
120589abb9f8SPhilip Paepstypecheck: typecheck_long_long typecheck_unsigned
120689abb9f8SPhilip Paepstypecheck_long_long typecheck_unsigned: $(VERSION_DEPS)
120789abb9f8SPhilip Paeps		rm -fr $@.dir
120889abb9f8SPhilip Paeps		mkdir $@.dir
120989abb9f8SPhilip Paeps		ln $(VERSION_DEPS) $@.dir
121089abb9f8SPhilip Paeps		cd $@.dir && \
121189abb9f8SPhilip Paeps		  case $@ in \
121289abb9f8SPhilip Paeps		    *_long_long) i="long long";; \
121389abb9f8SPhilip Paeps		    *_unsigned ) i="unsigned" ;; \
121489abb9f8SPhilip Paeps		  esac && \
121589abb9f8SPhilip Paeps		  typecheck_cflags='' && \
121689abb9f8SPhilip Paeps		  $(MAKE) \
121789abb9f8SPhilip Paeps		    CFLAGS="$(TYPECHECK_CFLAGS) \"-Dtime_t=$$i\"" \
121889abb9f8SPhilip Paeps		    TOPDIR="`pwd`" \
121989abb9f8SPhilip Paeps		    install
122089abb9f8SPhilip Paeps		$@.dir/zdump -i -c 1970,1971 Europe/Rome
122189abb9f8SPhilip Paeps		touch $@
1222ba2b2efdSGlen Barber
12238d7edd17SPhilip Paepszonenames:	tzdata.zi
12248d7edd17SPhilip Paeps		@$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
1225ba2b2efdSGlen Barber
1226ba2b2efdSGlen Barberasctime.o:	private.h tzfile.h
1227ba2b2efdSGlen Barberdate.o:		private.h
1228ba2b2efdSGlen Barberdifftime.o:	private.h
1229ba2b2efdSGlen Barberlocaltime.o:	private.h tzfile.h
1230ba2b2efdSGlen Barberstrftime.o:	private.h tzfile.h
1231ba2b2efdSGlen Barberzdump.o:	version.h
1232ba2b2efdSGlen Barberzic.o:		private.h tzfile.h version.h
1233ba2b2efdSGlen Barber
1234ba2b2efdSGlen Barber.PHONY: ALL INSTALL all
1235cf1ad535SPhilip Paeps.PHONY: check check_mild check_time_t_alternatives
12362c5e84ccSPhilip Paeps.PHONY: check_web check_zishrink
123746bee4edSPhilip Paeps.PHONY: clean clean_misc dummy.zd force_tzs
1238ba2b2efdSGlen Barber.PHONY: install install_data maintainer-clean names
12399f9fc6bbSPhilip Paeps.PHONY: posix_only posix_right public
124089abb9f8SPhilip Paeps.PHONY: rearguard_signatures rearguard_signatures_version
124189abb9f8SPhilip Paeps.PHONY: rearguard_tarballs rearguard_tarballs_version
124289abb9f8SPhilip Paeps.PHONY: right_only right_posix signatures signatures_version
124346bee4edSPhilip Paeps.PHONY: tarballs tarballs_version
124446bee4edSPhilip Paeps.PHONY: traditional_signatures traditional_signatures_version
124546bee4edSPhilip Paeps.PHONY: traditional_tarballs traditional_tarballs_version
12469f9fc6bbSPhilip Paeps.PHONY: tailored_tarballs tailored_tarballs_version
124746bee4edSPhilip Paeps.PHONY: typecheck
1248ba2b2efdSGlen Barber.PHONY: zonenames zones
124946bee4edSPhilip Paeps.PHONY: $(ZDS)
1250