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