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