Makefile revision 328475
1308265Sgjb# This file is in the public domain, so clarified as of
2308265Sgjb# 2009-05-17 by Arthur David Olson.
3308265Sgjb
4308265Sgjb# Package name for the code distribution.
5308265SgjbPACKAGE=	tzcode
6308265Sgjb
7308265Sgjb# Version number for the distribution, overridden in the 'tarballs' rule below.
8308265SgjbVERSION=	unknown
9308265Sgjb
10308265Sgjb# Email address for bug reports.
11308265SgjbBUGEMAIL=	tz@iana.org
12308265Sgjb
13308265Sgjb# Change the line below for your time zone (after finding the zone you want in
14308265Sgjb# the time zone files, or adding it to a time zone file).
15308265Sgjb# Alternately, if you discover you've got the wrong time zone, you can just
16308265Sgjb#	zic -l rightzone
17308265Sgjb# to correct things.
18308265Sgjb# Use the command
19308265Sgjb#	make zonenames
20308265Sgjb# to get a list of the values you can use for LOCALTIME.
21308265Sgjb
22308265SgjbLOCALTIME=	GMT
23308265Sgjb
24308265Sgjb# If you want something other than Eastern United States time as a template
25308265Sgjb# for handling POSIX-style time zone environment variables,
26308265Sgjb# change the line below (after finding the zone you want in the
27308265Sgjb# time zone files, or adding it to a time zone file).
28308265Sgjb# (When a POSIX-style environment variable is handled, the rules in the
29308265Sgjb# template file are used to determine "spring forward" and "fall back" days and
30308265Sgjb# times; the environment variable itself specifies UT offsets of standard and
31308265Sgjb# summer time.)
32308265Sgjb# Alternately, if you discover you've got the wrong time zone, you can just
33308265Sgjb#	zic -p rightzone
34308265Sgjb# to correct things.
35308265Sgjb# Use the command
36308265Sgjb#	make zonenames
37308265Sgjb# to get a list of the values you can use for POSIXRULES.
38308265Sgjb# If you want POSIX compatibility, use "America/New_York".
39308265Sgjb
40308265SgjbPOSIXRULES=	America/New_York
41308265Sgjb
42308265Sgjb# Also see TZDEFRULESTRING below, which takes effect only
43308265Sgjb# if the time zone files cannot be accessed.
44308265Sgjb
45308265Sgjb
46328475Sphilip# Installation locations.
47328475Sphilip#
48328475Sphilip# The defaults are suitable for Debian, except that if REDO is
49328475Sphilip# posix_right or right_posix then files that Debian puts under
50328475Sphilip# /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
51328475Sphilip# put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
52328475Sphilip# respectively.  Problems with the Debian approach are discussed in
53328475Sphilip# the commentary for the right_posix rule (below).
54308265Sgjb
55328475Sphilip# Destination directory, which can be used for staging.
56328475Sphilip# 'make DESTDIR=/stage install' installs under /stage (e.g., to
57328475Sphilip# /stage/etc/localtime instead of to /etc/localtime).  Files under
58328475Sphilip# /stage are not intended to work as-is, but can be copied by hand to
59328475Sphilip# the root directory later.  If DESTDIR is empty, 'make install' does
60328475Sphilip# not stage, but installs directly into production locations.
61328475SphilipDESTDIR =
62328475Sphilip
63328475Sphilip# Everything is installed into subdirectories of TOPDIR, and used there.
64328475Sphilip# TOPDIR should be empty (meaning the root directory),
65328475Sphilip# or a directory name that does not end in "/".
66328475Sphilip# TOPDIR should be empty or an absolute name unless you're just testing.
67328475SphilipTOPDIR =
68328475Sphilip
69328475Sphilip# The default local time zone is taken from the file TZDEFAULT.
70328475SphilipTZDEFAULT = $(TOPDIR)/etc/localtime
71328475Sphilip
72328475Sphilip# The subdirectory containing installed program and data files, and
73328475Sphilip# likewise for installed files that can be shared among architectures.
74328475Sphilip# These should be relative file names.
75328475SphilipUSRDIR = usr
76328475SphilipUSRSHAREDIR = $(USRDIR)/share
77328475Sphilip
78308265Sgjb# "Compiled" time zone information is placed in the "TZDIR" directory
79308265Sgjb# (and subdirectories).
80325159Sphilip# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
81308265SgjbTZDIR_BASENAME=	zoneinfo
82328475SphilipTZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
83308265Sgjb
84328475Sphilip# The "tzselect" and (if you do "make INSTALL") "date" commands go in:
85328475SphilipBINDIR = $(TOPDIR)/$(USRDIR)/bin
86308265Sgjb
87328475Sphilip# The "zdump" command goes in:
88328475SphilipZDUMPDIR = $(BINDIR)
89308265Sgjb
90328475Sphilip# The "zic" command goes in:
91328475SphilipZICDIR = $(TOPDIR)/$(USRDIR)/sbin
92308265Sgjb
93308265Sgjb# Manual pages go in subdirectories of. . .
94328475SphilipMANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
95308265Sgjb
96308265Sgjb# Library functions are put in an archive in LIBDIR.
97328475SphilipLIBDIR = $(TOPDIR)/$(USRDIR)/lib
98308265Sgjb
99308265Sgjb
100328475Sphilip# Types to try, as an alternative to time_t.  int64_t should be first.
101328475SphilipTIME_T_ALTERNATIVES = int64_t int32_t uint32_t uint64_t
102328475Sphilip
103316349Sbapt# If you want only POSIX time, with time values interpreted as
104316349Sbapt# seconds since the epoch (not counting leap seconds), use
105308265Sgjb#	REDO=		posix_only
106325159Sphilip# below.  If you want only "right" time, with values interpreted
107316349Sbapt# as seconds since the epoch (counting leap seconds), use
108308265Sgjb#	REDO=		right_only
109308265Sgjb# below.  If you want both sets of data available, with leap seconds not
110308265Sgjb# counted normally, use
111308265Sgjb#	REDO=		posix_right
112308265Sgjb# below.  If you want both sets of data available, with leap seconds counted
113308265Sgjb# normally, use
114308265Sgjb#	REDO=		right_posix
115308265Sgjb# below.  POSIX mandates that leap seconds not be counted; for compatibility
116316349Sbapt# with it, use "posix_only" or "posix_right".  Use POSIX time on systems with
117316349Sbapt# leap smearing; this can work better than unsmeared "right" time with
118316349Sbapt# applications that are not leap second aware, and is closer to unsmeared
119316349Sbapt# "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
120308265Sgjb
121308265SgjbREDO=		posix_right
122308265Sgjb
123325159Sphilip# To install data in text form that has all the information of the binary data,
124325159Sphilip# (optionally incorporating leap second information), use
125325159Sphilip#	TZDATA_TEXT=	tzdata.zi leapseconds
126325159Sphilip# To install text data without leap second information (e.g., because
127325159Sphilip# REDO='posix_only'), use
128325159Sphilip#	TZDATA_TEXT=	tzdata.zi
129325159Sphilip# To avoid installing text data, use
130325159Sphilip#	TZDATA_TEXT=
131325159Sphilip
132325159SphilipTZDATA_TEXT=	leapseconds tzdata.zi
133325159Sphilip
134325159Sphilip# For backward-compatibility links for old zone names, use
135328475Sphilip#	BACKWARD=	backward
136328475Sphilip# If you also want the link US/Pacific-New, even though it is confusing
137328475Sphilip# and is planned to be removed from the database eventually, use
138325159Sphilip#	BACKWARD=	backward pacificnew
139325159Sphilip# To omit these links, use
140325159Sphilip#	BACKWARD=
141325159Sphilip
142328475SphilipBACKWARD=	backward
143325159Sphilip
144308265Sgjb# If you want out-of-scope and often-wrong data from the file 'backzone', use
145308265Sgjb#	PACKRATDATA=	backzone
146308265Sgjb# To omit this data, use
147308265Sgjb#	PACKRATDATA=
148308265Sgjb
149308265SgjbPACKRATDATA=
150308265Sgjb
151325159Sphilip# The name of a locale using the UTF-8 encoding, used during self-tests.
152325159Sphilip# The tests are skipped if the name does not appear to work on this system.
153325159Sphilip
154325159SphilipUTF8_LOCALE=	en_US.utf8
155325159Sphilip
156308265Sgjb# Since "." may not be in PATH...
157308265Sgjb
158308265SgjbYEARISTYPE=	./yearistype
159308265Sgjb
160308265Sgjb# Non-default libraries needed to link.
161308265SgjbLDLIBS=
162308265Sgjb
163325159Sphilip# Add the following to the end of the "CFLAGS=" line as needed to override
164325159Sphilip# defaults specified in the source code.  "-DFOO" is equivalent to "-DFOO=1".
165308265Sgjb#  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
166325159Sphilip#  -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
167325159Sphilip#	formats that generate only the last two digits of year numbers
168325159Sphilip#  -DEPOCH_LOCAL if the 'time' function returns local time not UT
169325159Sphilip#  -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
170325159Sphilip#	than what POSIX specifies, assuming local time is UT.
171325159Sphilip#	For example, N is 252460800 on AmigaOS.
172308265Sgjb#  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
173325159Sphilip#  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
174308265Sgjb#  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
175325159Sphilip#  -DHAVE_GENERIC=0 if _Generic does not work
176325159Sphilip#  -DHAVE_GETTEXT if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris)
177325159Sphilip#  -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
178308265Sgjb#	ctime_r and asctime_r incompatibly with the POSIX standard
179308265Sgjb#	(Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
180325159Sphilip#  -DHAVE_INTTYPES_H if you have a non-C99 compiler with <inttypes.h>
181308265Sgjb#  -DHAVE_LINK=0 if your system lacks a link function
182308265Sgjb#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
183308265Sgjb#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
184308265Sgjb#	localtime_rz can make zdump significantly faster, but is nonstandard.
185308265Sgjb#  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
186308265Sgjb#	functions like 'link' or variables like 'tzname' required by POSIX
187325159Sphilip#  -DHAVE_SNPRINTF=0 if your system lacks the snprintf function
188325159Sphilip#  -DHAVE_STDBOOL_H if you have a non-C99 compiler with <stdbool.h>
189325159Sphilip#  -DHAVE_STDINT_H if you have a non-C99 compiler with <stdint.h>
190325159Sphilip#  -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
191308265Sgjb#  -DHAVE_STRDUP=0 if your system lacks the strdup function
192308265Sgjb#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
193325159Sphilip#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a <sys/stat.h>
194325159Sphilip#  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a <sys/wait.h>
195308265Sgjb#  -DHAVE_TZSET=0 if your system lacks a tzset function
196325159Sphilip#  -DHAVE_UNISTD_H=0 if your compiler lacks a <unistd.h>
197325159Sphilip#  -Dlocale_t=XXX if your system uses XXX instead of locale_t
198325159Sphilip#  -Dssize_t=long on hosts like MS-Windows that lack ssize_t
199325159Sphilip#  -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
200308265Sgjb#	not needed by the main-program tz code, which is single-threaded.
201308265Sgjb#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
202308265Sgjb#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
203325159Sphilip#	This is intended for internal use only; it mangles external names.
204308265Sgjb#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
205308265Sgjb#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
206308265Sgjb#	the default is system-supplied, typically "/usr/lib/locale"
207308265Sgjb#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
208308265Sgjb#	DST transitions if the time zone files cannot be accessed
209325159Sphilip#  -DUNINIT_TRAP if reading uninitialized storage can cause problems
210308265Sgjb#	other than simply getting garbage data
211308265Sgjb#  -DUSE_LTZ=0 to build zdump with the system time zone library
212308265Sgjb#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
213308265Sgjb#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
214308265Sgjb#	(or some other number) to set the maximum time zone abbreviation length
215308265Sgjb#	that zic will accept without a warning (the default is 6)
216308265Sgjb#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
217325159Sphilip# Select instrumentation via "make GCC_INSTRUMENT='whatever'".
218325159SphilipGCC_INSTRUMENT = \
219325159Sphilip  -fsanitize=undefined -fsanitize-address-use-after-scope \
220325159Sphilip  -fsanitize-undefined-trap-on-error -fstack-protector
221325159SphilipGCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \
222325159Sphilip  $(GCC_INSTRUMENT) \
223325159Sphilip  -Wall -Wextra \
224325159Sphilip  -Walloc-size-larger-than=100000 -Warray-bounds=2 \
225325159Sphilip  -Wbad-function-cast -Wcast-align -Wdate-time \
226325159Sphilip  -Wdeclaration-after-statement -Wdouble-promotion \
227325159Sphilip  -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
228325159Sphilip  -Winit-self -Wjump-misses-init -Wlogical-op \
229325159Sphilip  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
230325159Sphilip  -Wold-style-definition -Woverlength-strings -Wpointer-arith \
231325159Sphilip  -Wshadow -Wshift-overflow=2 -Wstrict-prototypes -Wstringop-overflow=5 \
232325159Sphilip  -Wsuggest-attribute=const -Wsuggest-attribute=format \
233325159Sphilip  -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
234325159Sphilip  -Wtrampolines -Wundef -Wuninitialized -Wunused \
235325159Sphilip  -Wvariadic-macros -Wvla -Wwrite-strings \
236325159Sphilip  -Wno-address -Wno-format-nonliteral -Wno-sign-compare \
237325159Sphilip  -Wno-type-limits -Wno-unused-parameter
238308265Sgjb#
239308265Sgjb# If your system has a "GMT offset" field in its "struct tm"s
240308265Sgjb# (or if you decide to add such a field in your system's "time.h" file),
241308265Sgjb# add the name to a define such as
242308265Sgjb#	-DTM_GMTOFF=tm_gmtoff
243308265Sgjb# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
244308265Sgjb# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
245308265Sgjb# Similarly, if your system has a "zone abbreviation" field, define
246308265Sgjb#	-DTM_ZONE=tm_zone
247308265Sgjb# and define NO_TM_ZONE to suppress any guessing.  These two fields are not
248308265Sgjb# required by POSIX, but are widely available on GNU/Linux and BSD systems.
249308265Sgjb#
250325159Sphilip# The next batch of options control support for external variables
251325159Sphilip# exported by tzcode.  In practice these variables are less useful
252325159Sphilip# than TM_GMTOFF and TM_ZONE.  However, most of them are standardized.
253325159Sphilip# #
254325159Sphilip# # To omit or support the external variable "tzname", add one of:
255325159Sphilip# #	-DHAVE_TZNAME=0
256325159Sphilip# #	-DHAVE_TZNAME=1
257325159Sphilip# # to the "CFLAGS=" line.  "tzname" is required by POSIX 1988 and later.
258325159Sphilip# # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
259325159Sphilip# # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
260325159Sphilip# # crashes when combined with some platforms' standard libraries,
261325159Sphilip# # presumably due to memory allocation issues.
262325159Sphilip# #
263325159Sphilip# # To omit or support the external variables "timezone" and "daylight", add
264325159Sphilip# #	-DUSG_COMPAT=0
265325159Sphilip# #	-DUSG_COMPAT=1
266325159Sphilip# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by
267325159Sphilip# # Unix Systems Group code and are required by POSIX 2008 (with XSI) and later.
268325159Sphilip# # If not defined, the code attempts to guess USG_COMPAT from other macros.
269325159Sphilip# #
270325159Sphilip# # To support the external variable "altzone", add
271325159Sphilip# #	-DALTZONE
272325159Sphilip# # to the end of the "CFLAGS=" line; although "altzone" appeared in
273325159Sphilip# # System V Release 3.1 it has not been standardized.
274325159Sphilip#
275308265Sgjb# If you want functions that were inspired by early versions of X3J11's work,
276308265Sgjb# add
277308265Sgjb#	-DSTD_INSPIRED
278308265Sgjb# to the end of the "CFLAGS=" line.  This arranges for the functions
279308265Sgjb# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
280308265Sgjb# "posix2time", and "time2posix" to be added to the time conversion library.
281308265Sgjb# "tzsetwall" is like "tzset" except that it arranges for local wall clock
282308265Sgjb# time (rather than the time specified in the TZ environment variable)
283308265Sgjb# to be used.
284308265Sgjb# "offtime" is like "gmtime" except that it accepts a second (long) argument
285308265Sgjb# that gives an offset to add to the time_t when converting it.
286308265Sgjb# "timelocal" is equivalent to "mktime".
287308265Sgjb# "timegm" is like "timelocal" except that it turns a struct tm into
288308265Sgjb# a time_t using UT (rather than local time as "timelocal" does).
289308265Sgjb# "timeoff" is like "timegm" except that it accepts a second (long) argument
290308265Sgjb# that gives an offset to use when converting to a time_t.
291308265Sgjb# "posix2time" and "time2posix" are described in an included manual page.
292308265Sgjb# X3J11's work does not describe any of these functions.
293308265Sgjb# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
294308265Sgjb# These functions may well disappear in future releases of the time
295308265Sgjb# conversion package.
296308265Sgjb#
297308265Sgjb# If you don't want functions that were inspired by NetBSD, add
298308265Sgjb#	-DNETBSD_INSPIRED=0
299308265Sgjb# to the end of the "CFLAGS=" line.  Otherwise, the functions
300308265Sgjb# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
301308265Sgjb# time library, and if STD_INSPIRED is also defined the functions
302308265Sgjb# "posix2time_z" and "time2posix_z" are added as well.
303308265Sgjb# The functions ending in "_z" (or "_rz") are like their unsuffixed
304308265Sgjb# (or suffixed-by-"_r") counterparts, except with an extra first
305308265Sgjb# argument of opaque type timezone_t that specifies the time zone.
306308265Sgjb# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
307308265Sgjb#
308308265Sgjb# If you want to allocate state structures in localtime, add
309308265Sgjb#	-DALL_STATE
310308265Sgjb# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
311308265Sgjb#
312308265Sgjb# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
313308265Sgjb# out by the National Institute of Standards and Technology
314308265Sgjb# which claims to test C and Posix conformance.  If you want to pass PCTS, add
315308265Sgjb#	-DPCTS
316308265Sgjb# to the end of the "CFLAGS=" line.
317308265Sgjb#
318308265Sgjb# If you want strict compliance with XPG4 as of 1994-04-09, add
319308265Sgjb#	-DXPG4_1994_04_09
320308265Sgjb# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
321325159Sphilip# 53 as a week number (rather than 52 or 53) for January days before
322325159Sphilip# January's first Monday when a "%V" format is used and January 1
323308265Sgjb# falls on a Friday, Saturday, or Sunday.
324308265Sgjb
325308265SgjbCFLAGS=
326308265Sgjb
327308265Sgjb# Linker flags.  Default to $(LFLAGS) for backwards compatibility
328308265Sgjb# to release 2012h and earlier.
329308265Sgjb
330308265SgjbLDFLAGS=	$(LFLAGS)
331308265Sgjb
332308265Sgjb# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
333308265Sgjb# submake command lines.  The default is no leap seconds.
334308265Sgjb
335308265SgjbLEAPSECONDS=
336308265Sgjb
337308265Sgjb# The zic command and its arguments.
338308265Sgjb
339308265Sgjbzic=		./zic
340308265SgjbZIC=		$(zic) $(ZFLAGS)
341308265Sgjb
342308265SgjbZFLAGS=
343308265Sgjb
344308265Sgjb# How to use zic to install tz binary files.
345308265Sgjb
346328475SphilipZIC_INSTALL=	$(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS)
347308265Sgjb
348308265Sgjb# The name of a Posix-compliant 'awk' on your system.
349308265SgjbAWK=		awk
350308265Sgjb
351308265Sgjb# The full path name of a Posix-compliant shell, preferably one that supports
352308265Sgjb# the Korn shell's 'select' statement as an extension.
353308265Sgjb# These days, Bash is the most popular.
354308265Sgjb# It should be OK to set this to /bin/sh, on platforms where /bin/sh
355308265Sgjb# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
356308265Sgjb# is typically nicer if it works.
357308265SgjbKSHELL=		/bin/bash
358308265Sgjb
359308265Sgjb# The path where SGML DTDs are kept and the catalog file(s) to use when
360308265Sgjb# validating.  The default should work on both Debian and Red Hat.
361308265SgjbSGML_TOPDIR= /usr
362308265SgjbSGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd
363308265SgjbSGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224
364308265SgjbSGML_CATALOG_FILES= \
365308265Sgjb  $(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
366308265Sgjb
367308265Sgjb# The name, arguments and environment of a program to validate your web pages.
368308265Sgjb# See <http://openjade.sourceforge.net/doc/> for a validator, and
369308265Sgjb# <https://validator.w3.org/source/> for a validation library.
370325159Sphilip# Set VALIDATE=':' if you do not have such a program.
371308265SgjbVALIDATE = nsgmls
372308265SgjbVALIDATE_FLAGS = -s -B -wall -wno-unused-param
373308265SgjbVALIDATE_ENV = \
374328475Sphilip  SGML_CATALOG_FILES='$(SGML_CATALOG_FILES)' \
375328475Sphilip  SGML_SEARCH_PATH='$(SGML_SEARCH_PATH)' \
376308265Sgjb  SP_CHARSET_FIXED=YES \
377308265Sgjb  SP_ENCODING=UTF-8
378308265Sgjb
379308265Sgjb# This expensive test requires USE_LTZ.
380308265Sgjb# To suppress it, define this macro to be empty.
381308265SgjbCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
382308265Sgjb
383308265Sgjb# SAFE_CHAR is a regular expression that matches a safe character.
384308265Sgjb# Some parts of this distribution are limited to safe characters;
385308265Sgjb# others can use any UTF-8 character.
386308265Sgjb# For now, the safe characters are a safe subset of ASCII.
387308265Sgjb# The caller must set the shell variable 'sharp' to the character '#',
388308265Sgjb# since Makefile macros cannot contain '#'.
389308265Sgjb# TAB_CHAR is a single tab character, in single quotes.
390308265SgjbTAB_CHAR=	'	'
391308265SgjbSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
392308265SgjbSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
393308265SgjbSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
394308265SgjbSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
395308265SgjbSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
396308265Sgjb
397308265Sgjb# OK_CHAR matches any character allowed in the distributed files.
398308265Sgjb# This is the same as SAFE_CHAR, except that multibyte letters are
399308265Sgjb# also allowed so that commentary can contain people's names and quote
400308265Sgjb# non-English sources.  For non-letters the sources are limited to
401308265Sgjb# ASCII renderings for the convenience of maintainers whose text editors
402308265Sgjb# mishandle UTF-8 by default (e.g., XEmacs 21.4.22).
403308265SgjbOK_CHAR=	'[][:alpha:]'$(SAFE_CHARSET)'-]'
404308265Sgjb
405308265Sgjb# SAFE_LINE matches a line of safe characters.
406308265Sgjb# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
407308265Sgjb# this is so that comments can contain non-ASCII characters.
408308265Sgjb# OK_LINE matches a line of OK characters.
409308265SgjbSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
410308265SgjbSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
411308265SgjbOK_LINE=	'^'$(OK_CHAR)'*$$'
412308265Sgjb
413308265Sgjb# Flags to give 'tar' when making a distribution.
414308265Sgjb# Try to use flags appropriate for GNU tar.
415308265SgjbGNUTARFLAGS= --numeric-owner --owner=0 --group=0 --mode=go+u,go-w --sort=name
416308265SgjbTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
417308265Sgjb		 then echo $(GNUTARFLAGS); \
418308265Sgjb		 else :; \
419308265Sgjb		 fi`
420308265Sgjb
421308265Sgjb# Flags to give 'gzip' when making a distribution.
422308265SgjbGZIPFLAGS=	-9n
423308265Sgjb
424308265Sgjb###############################################################################
425308265Sgjb
426308265Sgjb#MAKE=		make
427308265Sgjb
428308265Sgjbcc=		cc
429328475SphilipCC=		$(cc) -DTZDIR='"$(TZDIR)"'
430308265Sgjb
431308265SgjbAR=		ar
432308265Sgjb
433308265Sgjb# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
434308265SgjbRANLIB=		:
435308265Sgjb
436308265SgjbTZCOBJS=	zic.o
437325159SphilipTZDOBJS=	zdump.o localtime.o asctime.o strftime.o
438308265SgjbDATEOBJS=	date.o localtime.o strftime.o asctime.o
439308265SgjbLIBSRCS=	localtime.c asctime.c difftime.c
440308265SgjbLIBOBJS=	localtime.o asctime.o difftime.o
441308265SgjbHEADERS=	tzfile.h private.h
442308265SgjbNONLIBSRCS=	zic.c zdump.c
443308265SgjbNEWUCBSRCS=	date.c strftime.c
444308265SgjbSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
445308265Sgjb			tzselect.ksh workman.sh
446308265SgjbMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
447308265Sgjb			tzfile.5 tzselect.8 zic.8 zdump.8
448308265SgjbMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
449308265Sgjb			time2posix.3.txt \
450308265Sgjb			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
451308265Sgjb			date.1.txt
452325159SphilipCOMMON=		calendars CONTRIBUTING LICENSE Makefile \
453325159Sphilip			NEWS README theory.html version
454328475SphilipWEB_PAGES=	tz-art.html tz-how-to.html tz-link.html
455308265SgjbDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
456308265SgjbPRIMARY_YDATA=	africa antarctica asia australasia \
457308265Sgjb		europe northamerica southamerica
458328475SphilipYDATA=		$(PRIMARY_YDATA) etcetera
459308265SgjbNDATA=		systemv factory
460328475SphilipTDATA_TO_CHECK=	$(YDATA) $(NDATA) backward pacificnew
461328475SphilipTDATA=		$(YDATA) $(NDATA) $(BACKWARD)
462308265SgjbZONETABLES=	zone1970.tab zone.tab
463325159SphilipTABDATA=	iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
464308265SgjbLEAP_DEPS=	leapseconds.awk leap-seconds.list
465328475SphilipTZDATA_ZI_DEPS=	zishrink.awk version $(TDATA) $(PACKRATDATA)
466328475SphilipDATA=		$(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
467325159Sphilip			leapseconds yearistype.sh $(ZONETABLES)
468325159SphilipAWK_SCRIPTS=	checklinks.awk checktab.awk leapseconds.awk zishrink.awk
469308265SgjbMISC=		$(AWK_SCRIPTS) zoneinfo2tdf.pl
470308265SgjbTZS_YEAR=	2050
471308265SgjbTZS=		to$(TZS_YEAR).tzs
472308265SgjbTZS_NEW=	to$(TZS_YEAR)new.tzs
473308265SgjbTZS_DEPS=	$(PRIMARY_YDATA) asctime.c localtime.c \
474308265Sgjb			private.h tzfile.h zdump.c zic.c
475325159SphilipENCHILADA=	$(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS) tzdata.zi
476308265Sgjb
477308265Sgjb# Consult these files when deciding whether to rebuild the 'version' file.
478308265Sgjb# This list is not the same as the output of 'git ls-files', since
479308265Sgjb# .gitignore is not distributed.
480308265SgjbVERSION_DEPS= \
481325159Sphilip		calendars CONTRIBUTING LICENSE Makefile NEWS README \
482308265Sgjb		africa antarctica asctime.c asia australasia \
483308265Sgjb		backward backzone \
484308265Sgjb		checklinks.awk checktab.awk \
485308265Sgjb		date.1 date.c difftime.c \
486308265Sgjb		etcetera europe factory iso3166.tab \
487308265Sgjb		leap-seconds.list leapseconds.awk localtime.c \
488308265Sgjb		newctime.3 newstrftime.3 newtzset.3 northamerica \
489308265Sgjb		pacificnew private.h \
490325159Sphilip		southamerica strftime.c systemv theory.html \
491328475Sphilip		time2posix.3 tz-art.html tz-how-to.html tz-link.html \
492308265Sgjb		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
493308265Sgjb		workman.sh yearistype.sh \
494308265Sgjb		zdump.8 zdump.c zic.8 zic.c \
495308265Sgjb		zone.tab zone1970.tab zoneinfo2tdf.pl
496308265Sgjb
497308265Sgjb# And for the benefit of csh users on systems that assume the user
498308265Sgjb# shell should be used to handle commands in Makefiles. . .
499308265Sgjb
500308265SgjbSHELL=		/bin/sh
501308265Sgjb
502308265Sgjball:		tzselect yearistype zic zdump libtz.a $(TABDATA)
503308265Sgjb
504308265SgjbALL:		all date $(ENCHILADA)
505308265Sgjb
506308265Sgjbinstall:	all $(DATA) $(REDO) $(MANS)
507328475Sphilip		mkdir -p '$(DESTDIR)$(BINDIR)' \
508328475Sphilip			'$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
509328475Sphilip			'$(DESTDIR)$(LIBDIR)' \
510328475Sphilip			'$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
511328475Sphilip			'$(DESTDIR)$(MANDIR)/man8'
512328475Sphilip		$(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES) \
513328475Sphilip			-t '$(DESTDIR)$(TZDEFAULT)'
514328475Sphilip		cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
515328475Sphilip		cp tzselect '$(DESTDIR)$(BINDIR)/.'
516328475Sphilip		cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
517328475Sphilip		cp zic '$(DESTDIR)$(ZICDIR)/.'
518328475Sphilip		cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
519328475Sphilip		$(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
520328475Sphilip		cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
521328475Sphilip		cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
522328475Sphilip		cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
523308265Sgjb
524308265SgjbINSTALL:	ALL install date.1
525328475Sphilip		mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
526328475Sphilip		cp date '$(DESTDIR)$(BINDIR)/.'
527328475Sphilip		cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
528308265Sgjb
529308265Sgjbversion:	$(VERSION_DEPS)
530308265Sgjb		{ (type git) >/dev/null 2>&1 && \
531308265Sgjb		  V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
532308265Sgjb				--abbrev=7 --dirty` || \
533328475Sphilip		  V='$(VERSION)'; } && \
534308265Sgjb		printf '%s\n' "$$V" >$@.out
535308265Sgjb		mv $@.out $@
536308265Sgjb
537325159Sphilip# This file can be tailored by setting BACKWARD, PACKRATDATA, etc.
538325159Sphiliptzdata.zi:	$(TZDATA_ZI_DEPS)
539328475Sphilip		version=`sed 1q version` && \
540328475Sphilip		  LC_ALL=C $(AWK) -v version="$$version" -f zishrink.awk \
541328475Sphilip		    $(TDATA) $(PACKRATDATA) >$@.out
542325159Sphilip		mv $@.out $@
543325159Sphilip
544308265Sgjbversion.h:	version
545308265Sgjb		VERSION=`cat version` && printf '%s\n' \
546308265Sgjb		  'static char const PKGVERSION[]="($(PACKAGE)) ";' \
547308265Sgjb		  "static char const TZVERSION[]=\"$$VERSION\";" \
548308265Sgjb		  'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
549308265Sgjb		  >$@.out
550308265Sgjb		mv $@.out $@
551308265Sgjb
552308265Sgjbzdump:		$(TZDOBJS)
553308265Sgjb		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
554308265Sgjb
555308265Sgjbzic:		$(TZCOBJS)
556308265Sgjb		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
557308265Sgjb
558308265Sgjbyearistype:	yearistype.sh
559308265Sgjb		cp yearistype.sh yearistype
560308265Sgjb		chmod +x yearistype
561308265Sgjb
562308265Sgjbleapseconds:	$(LEAP_DEPS)
563308265Sgjb		$(AWK) -f leapseconds.awk leap-seconds.list >$@.out
564308265Sgjb		mv $@.out $@
565308265Sgjb
566308265Sgjb# Arguments to pass to submakes of install_data.
567308265Sgjb# They can be overridden by later submake arguments.
568308265SgjbINSTALLARGS = \
569328475Sphilip BACKWARD='$(BACKWARD)' \
570328475Sphilip DESTDIR='$(DESTDIR)' \
571308265Sgjb LEAPSECONDS='$(LEAPSECONDS)' \
572308265Sgjb PACKRATDATA='$(PACKRATDATA)' \
573328475Sphilip TZDEFAULT='$(TZDEFAULT)' \
574328475Sphilip TZDIR='$(TZDIR)' \
575328475Sphilip YEARISTYPE='$(YEARISTYPE)' \
576308265Sgjb ZIC='$(ZIC)'
577308265Sgjb
578308265Sgjb# 'make install_data' installs one set of tz binary files.
579325159Sphilipinstall_data:	zic leapseconds yearistype tzdata.zi
580325159Sphilip		$(ZIC_INSTALL) tzdata.zi
581308265Sgjb
582308265Sgjbposix_only:
583308265Sgjb		$(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
584308265Sgjb
585308265Sgjbright_only:
586308265Sgjb		$(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
587308265Sgjb			install_data
588308265Sgjb
589308265Sgjb# In earlier versions of this makefile, the other two directories were
590308265Sgjb# subdirectories of $(TZDIR).  However, this led to configuration errors.
591308265Sgjb# For example, with posix_right under the earlier scheme,
592308265Sgjb# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
593308265Sgjb# but gmtime without leap seconds, which led to problems with applications
594308265Sgjb# like sendmail that subtract gmtime from localtime.
595308265Sgjb# Therefore, the other two directories are now siblings of $(TZDIR).
596308265Sgjb# You must replace all of $(TZDIR) to switch from not using leap seconds
597308265Sgjb# to using them, or vice versa.
598308265Sgjbright_posix:	right_only
599328475Sphilip		rm -fr '$(DESTDIR)$(TZDIR)-leaps'
600328475Sphilip		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
601328475Sphilip		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
602328475Sphilip		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
603308265Sgjb
604308265Sgjbposix_right:	posix_only
605328475Sphilip		rm -fr '$(DESTDIR)$(TZDIR)-posix'
606328475Sphilip		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
607328475Sphilip		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
608328475Sphilip		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
609308265Sgjb
610308265Sgjb# This obsolescent rule is present for backwards compatibility with
611308265Sgjb# tz releases 2014g through 2015g.  It should go away eventually.
612308265Sgjbposix_packrat:
613308265Sgjb		$(MAKE) $(INSTALLARGS) PACKRATDATA=backzone posix_only
614308265Sgjb
615308265Sgjbzones:		$(REDO)
616308265Sgjb
617325159Sphilip$(TZS_NEW):	tzdata.zi zdump zic
618308265Sgjb		mkdir -p tzs.dir
619325159Sphilip		$(zic) -d tzs.dir tzdata.zi
620325159Sphilip		$(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
621325159Sphilip		   tzdata.zi | LC_ALL=C sort >$@.out
622308265Sgjb		wd=`pwd` && \
623308265Sgjb		zones=`$(AWK) -v wd="$$wd" \
624325159Sphilip				'/^Z/{print wd "/tzs.dir/" $$2}' tzdata.zi \
625308265Sgjb			 | LC_ALL=C sort` && \
626308265Sgjb		./zdump -i -c $(TZS_YEAR) $$zones >>$@.out
627308265Sgjb		sed 's,^TZ=".*tzs\.dir/,TZ=",' $@.out >$@.sed.out
628308265Sgjb		rm -fr tzs.dir $@.out
629308265Sgjb		mv $@.sed.out $@
630308265Sgjb
631308265Sgjb# If $(TZS) does not already exist (e.g., old-format tarballs), create it.
632308265Sgjb# If it exists but 'make check_tzs' fails, a maintainer should inspect the
633308265Sgjb# failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
634308265Sgjb$(TZS):
635308265Sgjb		$(MAKE) force_tzs
636308265Sgjb
637308265Sgjbforce_tzs:	$(TZS_NEW)
638308265Sgjb		cp $(TZS_NEW) $(TZS)
639308265Sgjb
640308265Sgjblibtz.a:	$(LIBOBJS)
641309792Sbapt		rm -f $@
642309792Sbapt		$(AR) -rc $@ $(LIBOBJS)
643308265Sgjb		$(RANLIB) $@
644308265Sgjb
645308265Sgjbdate:		$(DATEOBJS)
646308265Sgjb		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
647308265Sgjb
648308265Sgjbtzselect:	tzselect.ksh version
649308265Sgjb		VERSION=`cat version` && sed \
650308265Sgjb			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
651308265Sgjb			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
652308265Sgjb			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
653308265Sgjb			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
654308265Sgjb			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
655308265Sgjb			-e 's|\(TZVERSION\)=.*|\1='"$$VERSION"'|' \
656308265Sgjb			<$@.ksh >$@.out
657308265Sgjb		chmod +x $@.out
658308265Sgjb		mv $@.out $@
659308265Sgjb
660325159Sphilipcheck:		check_character_set check_white_space check_links \
661325159Sphilip		  check_name_lengths check_sorted \
662325159Sphilip		  check_tables check_web check_zishrink check_tzs
663308265Sgjb
664308265Sgjbcheck_character_set: $(ENCHILADA)
665325159Sphilip	test ! '$(UTF8_LOCALE)' || \
666325159Sphilip	! printf 'A\304\200B\n' | \
667325159Sphilip	  LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 || { \
668325159Sphilip		LC_ALL='$(UTF8_LOCALE)' && export LC_ALL && \
669308265Sgjb		sharp='#' && \
670308265Sgjb		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
671308265Sgjb			$(MISC) $(SOURCES) $(WEB_PAGES) \
672325159Sphilip			CONTRIBUTING LICENSE Makefile README \
673325159Sphilip			version tzdata.zi && \
674328475Sphilip		! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
675308265Sgjb			leapseconds yearistype.sh zone.tab && \
676325159Sphilip		! grep -Env $(OK_LINE) $(ENCHILADA); \
677325159Sphilip	}
678308265Sgjb
679308265Sgjbcheck_white_space: $(ENCHILADA)
680308265Sgjb		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
681308265Sgjb		! grep -En "$$pat" $(ENCHILADA)
682328475Sphilip		! grep -n '[[:space:]]$$' \
683328475Sphilip			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
684308265Sgjb
685325159SphilipPRECEDES_FILE_NAME = ^(Zone|Link[[:space:]]+[^[:space:]]+)[[:space:]]+
686325159SphilipFILE_NAME_COMPONENT_TOO_LONG = \
687325159Sphilip  $(PRECEDES_FILE_NAME)[^[:space:]]*[^/[:space:]]{15}
688325159Sphilip
689328475Sphilipcheck_name_lengths: $(TDATA_TO_CHECK) backzone
690328475Sphilip		! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
691328475Sphilip			$(TDATA_TO_CHECK) backzone
692325159Sphilip
693308265SgjbCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
694308265Sgjb
695308265Sgjbcheck_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
696308265Sgjb		$(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu
697308265Sgjb		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
698308265Sgjb		$(AWK) '/^[^#]/ {print $$1}' iso3166.tab | LC_ALL=C sort -cu
699308265Sgjb		$(AWK) '/^[^#]/ {print $$1}' zone.tab | LC_ALL=C sort -c
700308265Sgjb		$(AWK) '/^[^#]/ {print substr($$0, 1, 2)}' zone1970.tab | \
701308265Sgjb		  LC_ALL=C sort -c
702308265Sgjb		$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
703308265Sgjb		  LC_ALL=C sort -cu
704308265Sgjb
705328475Sphilipcheck_links:	checklinks.awk $(TDATA_TO_CHECK)
706328475Sphilip		$(AWK) -f checklinks.awk $(TDATA_TO_CHECK)
707325159Sphilip		$(AWK) -f checklinks.awk tzdata.zi
708308265Sgjb
709308265Sgjbcheck_tables:	checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
710308265Sgjb		for tab in $(ZONETABLES); do \
711308265Sgjb		  $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
712308265Sgjb		    || exit; \
713308265Sgjb		done
714308265Sgjb
715308265Sgjbcheck_tzs:	$(TZS) $(TZS_NEW)
716308265Sgjb		diff -u $(TZS) $(TZS_NEW)
717308265Sgjb
718325159Sphilip# This checks only the HTML 4.01 strict page.
719325159Sphilip# To check the the other pages, use <https://validator.w3.org/>.
720325159Sphilipcheck_web:	tz-how-to.html
721325159Sphilip		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) tz-how-to.html
722308265Sgjb
723325159Sphilip# Check that tzdata.zi generates the same binary data that its sources do.
724325159Sphilipcheck_zishrink: tzdata.zi zic leapseconds $(PACKRATDATA) $(TDATA)
725325159Sphilip		for type in posix right; do \
726325159Sphilip		  mkdir -p time_t.dir/$$type time_t.dir/$$type-shrunk && \
727325159Sphilip		  case $$type in \
728325159Sphilip		    right) leap='-L leapseconds';; \
729325159Sphilip	            *) leap=;; \
730325159Sphilip		  esac && \
731325159Sphilip		  $(ZIC) $$leap -d time_t.dir/$$type $(TDATA) && \
732325159Sphilip		  $(AWK) '/^Rule/' $(TDATA) | \
733325159Sphilip		    $(ZIC) $$leap -d time_t.dir/$$type - $(PACKRATDATA) && \
734325159Sphilip		  $(ZIC) $$leap -d time_t.dir/$$type-shrunk tzdata.zi && \
735325159Sphilip		  diff -r time_t.dir/$$type time_t.dir/$$type-shrunk || exit; \
736325159Sphilip		done
737325159Sphilip		rm -fr time_t.dir
738325159Sphilip
739308265Sgjbclean_misc:
740308265Sgjb		rm -f core *.o *.out \
741308265Sgjb		  date tzselect version.h zdump zic yearistype libtz.a
742308265Sgjbclean:		clean_misc
743325159Sphilip		rm -fr *.dir tzdata.zi tzdb-*/ $(TZS_NEW)
744308265Sgjb
745308265Sgjbmaintainer-clean: clean
746308265Sgjb		@echo 'This command is intended for maintainers to use; it'
747308265Sgjb		@echo 'deletes files that may need special tools to rebuild.'
748308265Sgjb		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
749308265Sgjb
750308265Sgjbnames:
751308265Sgjb		@echo $(ENCHILADA)
752308265Sgjb
753308265Sgjbpublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
754308265Sgjb		tarballs signatures
755308265Sgjb
756308265Sgjbdate.1.txt:	date.1
757308265Sgjbnewctime.3.txt:	newctime.3
758308265Sgjbnewstrftime.3.txt: newstrftime.3
759308265Sgjbnewtzset.3.txt:	newtzset.3
760308265Sgjbtime2posix.3.txt: time2posix.3
761308265Sgjbtzfile.5.txt:	tzfile.5
762308265Sgjbtzselect.8.txt:	tzselect.8
763308265Sgjbzdump.8.txt:	zdump.8
764308265Sgjbzic.8.txt:	zic.8
765308265Sgjb
766308265Sgjb$(MANTXTS):	workman.sh
767308265Sgjb		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out
768308265Sgjb		mv $@.out $@
769308265Sgjb
770308265Sgjb# Set the time stamps to those of the git repository, if available,
771308265Sgjb# and if the files have not changed since then.
772308265Sgjb# This uses GNU 'touch' syntax 'touch -d@N FILE',
773308265Sgjb# where N is the number of seconds since 1970.
774308265Sgjb# If git or GNU 'touch' is absent, don't bother to sync with git timestamps.
775308265Sgjb# Also, set the timestamp of each prebuilt file like 'leapseconds'
776308265Sgjb# to be the maximum of the files it depends on.
777308265Sgjbset-timestamps.out: $(ENCHILADA)
778308265Sgjb		rm -f $@
779308265Sgjb		if (type git) >/dev/null 2>&1 && \
780308265Sgjb		   files=`git ls-files $(ENCHILADA)` && \
781308265Sgjb		   touch -md @1 test.out; then \
782308265Sgjb		  rm -f test.out && \
783308265Sgjb		  for file in $$files; do \
784308265Sgjb		    if git diff --quiet $$file; then \
785308265Sgjb		      time=`git log -1 --format='tformat:%ct' $$file` && \
786308265Sgjb		      touch -cmd @$$time $$file; \
787308265Sgjb		    else \
788308265Sgjb		      echo >&2 "$$file: warning: does not match repository"; \
789308265Sgjb		    fi || exit; \
790308265Sgjb		  done; \
791308265Sgjb		fi
792308265Sgjb		touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds
793308265Sgjb		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
794308265Sgjb		  touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \
795308265Sgjb		    exit; \
796308265Sgjb		done
797325159Sphilip		touch -cmr `ls -t $(TZDATA_ZI_DEPS) | sed 1q` tzdata.zi
798308265Sgjb		touch -cmr `ls -t $(TZS_DEPS) | sed 1q` $(TZS)
799308265Sgjb		touch -cmr `ls -t $(VERSION_DEPS) | sed 1q` version
800308265Sgjb		touch $@
801308265Sgjb
802308265Sgjb# The zics below ensure that each data file can stand on its own.
803308265Sgjb# We also do an all-files run to catch links to links.
804308265Sgjb
805308265Sgjbcheck_public:
806308265Sgjb		$(MAKE) maintainer-clean
807328475Sphilip		$(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' ALL
808308265Sgjb		mkdir -p public.dir
809328475Sphilip		for i in $(TDATA_TO_CHECK) tzdata.zi; do \
810308265Sgjb		  $(zic) -v -d public.dir $$i 2>&1 || exit; \
811308265Sgjb		done
812328475Sphilip		$(zic) -v -d public.dir $(TDATA_TO_CHECK)
813308265Sgjb		rm -fr public.dir
814308265Sgjb
815308265Sgjb# Check that the code works under various alternative
816308265Sgjb# implementations of time_t.
817308265Sgjbcheck_time_t_alternatives:
818308265Sgjb		if diff -q Makefile Makefile 2>/dev/null; then \
819308265Sgjb		  quiet_option='-q'; \
820308265Sgjb		else \
821308265Sgjb		  quiet_option=''; \
822308265Sgjb		fi && \
823308265Sgjb		wd=`pwd` && \
824308265Sgjb		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
825308265Sgjb		for type in $(TIME_T_ALTERNATIVES); do \
826308265Sgjb		  mkdir -p time_t.dir/$$type && \
827308265Sgjb		  $(MAKE) clean_misc && \
828308265Sgjb		  $(MAKE) TOPDIR="$$wd/time_t.dir/$$type" \
829308265Sgjb		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
830308265Sgjb		    REDO='$(REDO)' \
831308265Sgjb		    install && \
832308265Sgjb		  diff $$quiet_option -r \
833328475Sphilip		    time_t.dir/int64_t/etc \
834328475Sphilip		    time_t.dir/$$type/etc && \
835328475Sphilip		  diff $$quiet_option -r \
836328475Sphilip		    time_t.dir/int64_t/usr/share \
837328475Sphilip		    time_t.dir/$$type/usr/share && \
838308265Sgjb		  case $$type in \
839308265Sgjb		  int32_t) range=-2147483648,2147483647;; \
840308265Sgjb		  uint32_t) range=0,4294967296;; \
841308265Sgjb		  int64_t) continue;; \
842308265Sgjb		  *u*) range=0,10000000000;; \
843308265Sgjb		  *) range=-10000000000,10000000000;; \
844308265Sgjb		  esac && \
845308265Sgjb		  echo checking $$type zones ... && \
846328475Sphilip		  time_t.dir/int64_t/usr/bin/zdump -V -t $$range $$zones \
847308265Sgjb		      >time_t.dir/int64_t.out && \
848328475Sphilip		  time_t.dir/$$type/usr/bin/zdump -V -t $$range $$zones \
849308265Sgjb		      >time_t.dir/$$type.out && \
850308265Sgjb		  diff -u time_t.dir/int64_t.out time_t.dir/$$type.out \
851308265Sgjb		    || exit; \
852308265Sgjb		done
853308265Sgjb		rm -fr time_t.dir
854308265Sgjb
855308265Sgjbtarballs traditional_tarballs signatures traditional_signatures: version
856308265Sgjb		VERSION=`cat version` && \
857308265Sgjb		$(MAKE) VERSION="$$VERSION" $@_version
858308265Sgjb
859308265Sgjbtarballs_version: traditional_tarballs_version tzdb-$(VERSION).tar.lz
860308265Sgjbtraditional_tarballs_version: \
861308265Sgjb  tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
862308265Sgjbsignatures_version: traditional_signatures_version tzdb-$(VERSION).tar.lz.asc
863308265Sgjbtraditional_signatures_version: \
864308265Sgjb  tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc \
865308265Sgjb
866308265Sgjbtzcode$(VERSION).tar.gz: set-timestamps.out
867308265Sgjb		LC_ALL=C && export LC_ALL && \
868308265Sgjb		tar $(TARFLAGS) -cf - \
869308265Sgjb		    $(COMMON) $(DOCS) $(SOURCES) | \
870308265Sgjb		  gzip $(GZIPFLAGS) >$@.out
871308265Sgjb		mv $@.out $@
872308265Sgjb
873308265Sgjbtzdata$(VERSION).tar.gz: set-timestamps.out
874308265Sgjb		LC_ALL=C && export LC_ALL && \
875308265Sgjb		tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
876308265Sgjb		  gzip $(GZIPFLAGS) >$@.out
877308265Sgjb		mv $@.out $@
878308265Sgjb
879308265Sgjbtzdb-$(VERSION).tar.lz: set-timestamps.out
880308265Sgjb		rm -fr tzdb-$(VERSION)
881308265Sgjb		mkdir tzdb-$(VERSION)
882308265Sgjb		ln $(ENCHILADA) tzdb-$(VERSION)
883308265Sgjb		touch -cmr `ls -t tzdb-$(VERSION)/* | sed 1q` tzdb-$(VERSION)
884308265Sgjb		LC_ALL=C && export LC_ALL && \
885308265Sgjb		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out
886308265Sgjb		mv $@.out $@
887308265Sgjb
888308265Sgjbtzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
889308265Sgjb		gpg --armor --detach-sign $?
890308265Sgjb
891308265Sgjbtzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
892308265Sgjb		gpg --armor --detach-sign $?
893308265Sgjb
894308265Sgjbtzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
895308265Sgjb		gpg --armor --detach-sign $?
896308265Sgjb
897308265Sgjbtypecheck:
898308265Sgjb		$(MAKE) clean
899308265Sgjb		for i in "long long" unsigned; \
900308265Sgjb		do \
901308265Sgjb			$(MAKE) CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
902308265Sgjb			./zdump -v Europe/Rome ; \
903308265Sgjb			$(MAKE) clean ; \
904308265Sgjb		done
905308265Sgjb
906325159Sphilipzonenames:	tzdata.zi
907325159Sphilip		@$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
908308265Sgjb
909308265Sgjbasctime.o:	private.h tzfile.h
910308265Sgjbdate.o:		private.h
911308265Sgjbdifftime.o:	private.h
912308265Sgjblocaltime.o:	private.h tzfile.h
913308265Sgjbstrftime.o:	private.h tzfile.h
914308265Sgjbzdump.o:	version.h
915308265Sgjbzic.o:		private.h tzfile.h version.h
916308265Sgjb
917308265Sgjb.KEEP_STATE:
918308265Sgjb
919308265Sgjb.PHONY: ALL INSTALL all
920308265Sgjb.PHONY: check check_character_set check_links
921308265Sgjb.PHONY: check_public check_sorted check_tables
922308265Sgjb.PHONY: check_time_t_alternatives check_tzs check_web check_white_space
923325159Sphilip.PHONY: check_zishrink
924308265Sgjb.PHONY: clean clean_misc force_tzs
925308265Sgjb.PHONY: install install_data maintainer-clean names
926308265Sgjb.PHONY: posix_only posix_packrat posix_right
927308265Sgjb.PHONY: public right_only right_posix signatures signatures_version
928308265Sgjb.PHONY: tarballs tarballs_version typecheck
929308265Sgjb.PHONY: zonenames zones
930