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