Makefile revision 333312
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
13331662Sphilip# Choose source data features.  To get new features right away, use:
14331662Sphilip#	DATAFORM=	vanguard
15331662Sphilip# To wait a while before using new features, to give downstream users
16331662Sphilip# time to upgrade zic (the default), use:
17331662Sphilip#	DATAFORM=	main
18331662Sphilip# To wait even longer for new features, use:
19331662Sphilip#	DATAFORM=	rearguard
20331662SphilipDATAFORM=		main
21331662Sphilip
22308265Sgjb# Change the line below for your time zone (after finding the zone you want in
23308265Sgjb# the time zone files, or adding it to a time zone file).
24333312Sphilip# Alternatively, if you discover you've got the wrong time zone, you can just
25308265Sgjb#	zic -l rightzone
26308265Sgjb# to correct things.
27308265Sgjb# Use the command
28308265Sgjb#	make zonenames
29308265Sgjb# to get a list of the values you can use for LOCALTIME.
30308265Sgjb
31308265SgjbLOCALTIME=	GMT
32308265Sgjb
33308265Sgjb# If you want something other than Eastern United States time as a template
34308265Sgjb# for handling POSIX-style time zone environment variables,
35308265Sgjb# change the line below (after finding the zone you want in the
36308265Sgjb# time zone files, or adding it to a time zone file).
37331662Sphilip# When a POSIX-style environment variable is handled, the rules in the
38308265Sgjb# template file are used to determine "spring forward" and "fall back" days and
39308265Sgjb# times; the environment variable itself specifies UT offsets of standard and
40331662Sphilip# daylight saving time.
41333312Sphilip# Alternatively, if you discover you've got the wrong time zone, you can just
42308265Sgjb#	zic -p rightzone
43308265Sgjb# to correct things.
44308265Sgjb# Use the command
45308265Sgjb#	make zonenames
46308265Sgjb# to get a list of the values you can use for POSIXRULES.
47308265Sgjb# If you want POSIX compatibility, use "America/New_York".
48308265Sgjb
49308265SgjbPOSIXRULES=	America/New_York
50308265Sgjb
51308265Sgjb# Also see TZDEFRULESTRING below, which takes effect only
52308265Sgjb# if the time zone files cannot be accessed.
53308265Sgjb
54308265Sgjb
55328475Sphilip# Installation locations.
56328475Sphilip#
57328475Sphilip# The defaults are suitable for Debian, except that if REDO is
58328475Sphilip# posix_right or right_posix then files that Debian puts under
59328475Sphilip# /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
60328475Sphilip# put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
61328475Sphilip# respectively.  Problems with the Debian approach are discussed in
62328475Sphilip# the commentary for the right_posix rule (below).
63308265Sgjb
64328475Sphilip# Destination directory, which can be used for staging.
65328475Sphilip# 'make DESTDIR=/stage install' installs under /stage (e.g., to
66328475Sphilip# /stage/etc/localtime instead of to /etc/localtime).  Files under
67328475Sphilip# /stage are not intended to work as-is, but can be copied by hand to
68328475Sphilip# the root directory later.  If DESTDIR is empty, 'make install' does
69328475Sphilip# not stage, but installs directly into production locations.
70328475SphilipDESTDIR =
71328475Sphilip
72328475Sphilip# Everything is installed into subdirectories of TOPDIR, and used there.
73328475Sphilip# TOPDIR should be empty (meaning the root directory),
74328475Sphilip# or a directory name that does not end in "/".
75328475Sphilip# TOPDIR should be empty or an absolute name unless you're just testing.
76328475SphilipTOPDIR =
77328475Sphilip
78328475Sphilip# The default local time zone is taken from the file TZDEFAULT.
79328475SphilipTZDEFAULT = $(TOPDIR)/etc/localtime
80328475Sphilip
81328475Sphilip# The subdirectory containing installed program and data files, and
82328475Sphilip# likewise for installed files that can be shared among architectures.
83328475Sphilip# These should be relative file names.
84328475SphilipUSRDIR = usr
85328475SphilipUSRSHAREDIR = $(USRDIR)/share
86328475Sphilip
87308265Sgjb# "Compiled" time zone information is placed in the "TZDIR" directory
88308265Sgjb# (and subdirectories).
89325159Sphilip# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
90308265SgjbTZDIR_BASENAME=	zoneinfo
91328475SphilipTZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
92308265Sgjb
93328475Sphilip# The "tzselect" and (if you do "make INSTALL") "date" commands go in:
94328475SphilipBINDIR = $(TOPDIR)/$(USRDIR)/bin
95308265Sgjb
96328475Sphilip# The "zdump" command goes in:
97328475SphilipZDUMPDIR = $(BINDIR)
98308265Sgjb
99328475Sphilip# The "zic" command goes in:
100328475SphilipZICDIR = $(TOPDIR)/$(USRDIR)/sbin
101308265Sgjb
102308265Sgjb# Manual pages go in subdirectories of. . .
103328475SphilipMANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
104308265Sgjb
105308265Sgjb# Library functions are put in an archive in LIBDIR.
106328475SphilipLIBDIR = $(TOPDIR)/$(USRDIR)/lib
107308265Sgjb
108308265Sgjb
109328475Sphilip# Types to try, as an alternative to time_t.  int64_t should be first.
110328475SphilipTIME_T_ALTERNATIVES = int64_t int32_t uint32_t uint64_t
111328475Sphilip
112316349Sbapt# If you want only POSIX time, with time values interpreted as
113316349Sbapt# seconds since the epoch (not counting leap seconds), use
114308265Sgjb#	REDO=		posix_only
115325159Sphilip# below.  If you want only "right" time, with values interpreted
116316349Sbapt# as seconds since the epoch (counting leap seconds), use
117308265Sgjb#	REDO=		right_only
118308265Sgjb# below.  If you want both sets of data available, with leap seconds not
119308265Sgjb# counted normally, use
120308265Sgjb#	REDO=		posix_right
121308265Sgjb# below.  If you want both sets of data available, with leap seconds counted
122308265Sgjb# normally, use
123308265Sgjb#	REDO=		right_posix
124308265Sgjb# below.  POSIX mandates that leap seconds not be counted; for compatibility
125316349Sbapt# with it, use "posix_only" or "posix_right".  Use POSIX time on systems with
126316349Sbapt# leap smearing; this can work better than unsmeared "right" time with
127316349Sbapt# applications that are not leap second aware, and is closer to unsmeared
128316349Sbapt# "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
129308265Sgjb
130308265SgjbREDO=		posix_right
131308265Sgjb
132325159Sphilip# To install data in text form that has all the information of the binary data,
133325159Sphilip# (optionally incorporating leap second information), use
134325159Sphilip#	TZDATA_TEXT=	tzdata.zi leapseconds
135325159Sphilip# To install text data without leap second information (e.g., because
136325159Sphilip# REDO='posix_only'), use
137325159Sphilip#	TZDATA_TEXT=	tzdata.zi
138325159Sphilip# To avoid installing text data, use
139325159Sphilip#	TZDATA_TEXT=
140325159Sphilip
141325159SphilipTZDATA_TEXT=	leapseconds tzdata.zi
142325159Sphilip
143325159Sphilip# For backward-compatibility links for old zone names, use
144328475Sphilip#	BACKWARD=	backward
145328475Sphilip# If you also want the link US/Pacific-New, even though it is confusing
146328475Sphilip# and is planned to be removed from the database eventually, use
147325159Sphilip#	BACKWARD=	backward pacificnew
148325159Sphilip# To omit these links, use
149325159Sphilip#	BACKWARD=
150325159Sphilip
151328475SphilipBACKWARD=	backward
152325159Sphilip
153308265Sgjb# If you want out-of-scope and often-wrong data from the file 'backzone', use
154308265Sgjb#	PACKRATDATA=	backzone
155308265Sgjb# To omit this data, use
156308265Sgjb#	PACKRATDATA=
157308265Sgjb
158308265SgjbPACKRATDATA=
159308265Sgjb
160325159Sphilip# The name of a locale using the UTF-8 encoding, used during self-tests.
161325159Sphilip# The tests are skipped if the name does not appear to work on this system.
162325159Sphilip
163325159SphilipUTF8_LOCALE=	en_US.utf8
164325159Sphilip
165308265Sgjb# Since "." may not be in PATH...
166308265Sgjb
167308265SgjbYEARISTYPE=	./yearistype
168308265Sgjb
169308265Sgjb# Non-default libraries needed to link.
170308265SgjbLDLIBS=
171308265Sgjb
172325159Sphilip# Add the following to the end of the "CFLAGS=" line as needed to override
173325159Sphilip# defaults specified in the source code.  "-DFOO" is equivalent to "-DFOO=1".
174308265Sgjb#  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
175325159Sphilip#  -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
176325159Sphilip#	formats that generate only the last two digits of year numbers
177325159Sphilip#  -DEPOCH_LOCAL if the 'time' function returns local time not UT
178325159Sphilip#  -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
179325159Sphilip#	than what POSIX specifies, assuming local time is UT.
180325159Sphilip#	For example, N is 252460800 on AmigaOS.
181308265Sgjb#  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
182325159Sphilip#  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
183308265Sgjb#  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
184325159Sphilip#  -DHAVE_GENERIC=0 if _Generic does not work
185325159Sphilip#  -DHAVE_GETTEXT if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris)
186325159Sphilip#  -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
187308265Sgjb#	ctime_r and asctime_r incompatibly with the POSIX standard
188308265Sgjb#	(Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
189325159Sphilip#  -DHAVE_INTTYPES_H if you have a non-C99 compiler with <inttypes.h>
190308265Sgjb#  -DHAVE_LINK=0 if your system lacks a link function
191308265Sgjb#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
192308265Sgjb#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
193308265Sgjb#	localtime_rz can make zdump significantly faster, but is nonstandard.
194308265Sgjb#  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
195308265Sgjb#	functions like 'link' or variables like 'tzname' required by POSIX
196325159Sphilip#  -DHAVE_SNPRINTF=0 if your system lacks the snprintf function
197325159Sphilip#  -DHAVE_STDBOOL_H if you have a non-C99 compiler with <stdbool.h>
198325159Sphilip#  -DHAVE_STDINT_H if you have a non-C99 compiler with <stdint.h>
199325159Sphilip#  -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
200308265Sgjb#  -DHAVE_STRDUP=0 if your system lacks the strdup function
201331662Sphilip#  -DHAVE_STRTOLL=0 if your system lacks the strtoll function
202308265Sgjb#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
203325159Sphilip#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a <sys/stat.h>
204325159Sphilip#  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a <sys/wait.h>
205308265Sgjb#  -DHAVE_TZSET=0 if your system lacks a tzset function
206325159Sphilip#  -DHAVE_UNISTD_H=0 if your compiler lacks a <unistd.h>
207325159Sphilip#  -Dlocale_t=XXX if your system uses XXX instead of locale_t
208331662Sphilip#  -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
209331662Sphilip#	with external linkage, e.g., applications cannot define 'localtime'.
210325159Sphilip#  -Dssize_t=long on hosts like MS-Windows that lack ssize_t
211331662Sphilip#  -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
212331662Sphilip#	security implications and is not recommended for general use
213325159Sphilip#  -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
214308265Sgjb#	not needed by the main-program tz code, which is single-threaded.
215308265Sgjb#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
216308265Sgjb#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
217325159Sphilip#	This is intended for internal use only; it mangles external names.
218308265Sgjb#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
219308265Sgjb#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
220308265Sgjb#	the default is system-supplied, typically "/usr/lib/locale"
221308265Sgjb#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
222308265Sgjb#	DST transitions if the time zone files cannot be accessed
223325159Sphilip#  -DUNINIT_TRAP if reading uninitialized storage can cause problems
224308265Sgjb#	other than simply getting garbage data
225308265Sgjb#  -DUSE_LTZ=0 to build zdump with the system time zone library
226308265Sgjb#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
227308265Sgjb#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
228308265Sgjb#	(or some other number) to set the maximum time zone abbreviation length
229308265Sgjb#	that zic will accept without a warning (the default is 6)
230308265Sgjb#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
231325159Sphilip# Select instrumentation via "make GCC_INSTRUMENT='whatever'".
232325159SphilipGCC_INSTRUMENT = \
233325159Sphilip  -fsanitize=undefined -fsanitize-address-use-after-scope \
234325159Sphilip  -fsanitize-undefined-trap-on-error -fstack-protector
235325159SphilipGCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \
236325159Sphilip  $(GCC_INSTRUMENT) \
237325159Sphilip  -Wall -Wextra \
238325159Sphilip  -Walloc-size-larger-than=100000 -Warray-bounds=2 \
239333312Sphilip  -Wbad-function-cast -Wcast-align=strict -Wdate-time \
240325159Sphilip  -Wdeclaration-after-statement -Wdouble-promotion \
241325159Sphilip  -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
242325159Sphilip  -Winit-self -Wjump-misses-init -Wlogical-op \
243325159Sphilip  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
244325159Sphilip  -Wold-style-definition -Woverlength-strings -Wpointer-arith \
245333312Sphilip  -Wshadow -Wshift-overflow=2 -Wstrict-prototypes -Wstringop-overflow=4 \
246333312Sphilip  -Wstringop-truncation -Wsuggest-attribute=cold \
247325159Sphilip  -Wsuggest-attribute=const -Wsuggest-attribute=format \
248333312Sphilip  -Wsuggest-attribute=malloc \
249325159Sphilip  -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
250325159Sphilip  -Wtrampolines -Wundef -Wuninitialized -Wunused \
251325159Sphilip  -Wvariadic-macros -Wvla -Wwrite-strings \
252325159Sphilip  -Wno-address -Wno-format-nonliteral -Wno-sign-compare \
253325159Sphilip  -Wno-type-limits -Wno-unused-parameter
254308265Sgjb#
255308265Sgjb# If your system has a "GMT offset" field in its "struct tm"s
256308265Sgjb# (or if you decide to add such a field in your system's "time.h" file),
257308265Sgjb# add the name to a define such as
258308265Sgjb#	-DTM_GMTOFF=tm_gmtoff
259308265Sgjb# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
260308265Sgjb# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
261308265Sgjb# Similarly, if your system has a "zone abbreviation" field, define
262308265Sgjb#	-DTM_ZONE=tm_zone
263308265Sgjb# and define NO_TM_ZONE to suppress any guessing.  These two fields are not
264308265Sgjb# required by POSIX, but are widely available on GNU/Linux and BSD systems.
265308265Sgjb#
266325159Sphilip# The next batch of options control support for external variables
267325159Sphilip# exported by tzcode.  In practice these variables are less useful
268325159Sphilip# than TM_GMTOFF and TM_ZONE.  However, most of them are standardized.
269325159Sphilip# #
270325159Sphilip# # To omit or support the external variable "tzname", add one of:
271325159Sphilip# #	-DHAVE_TZNAME=0
272325159Sphilip# #	-DHAVE_TZNAME=1
273325159Sphilip# # to the "CFLAGS=" line.  "tzname" is required by POSIX 1988 and later.
274325159Sphilip# # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
275325159Sphilip# # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
276325159Sphilip# # crashes when combined with some platforms' standard libraries,
277325159Sphilip# # presumably due to memory allocation issues.
278325159Sphilip# #
279325159Sphilip# # To omit or support the external variables "timezone" and "daylight", add
280325159Sphilip# #	-DUSG_COMPAT=0
281325159Sphilip# #	-DUSG_COMPAT=1
282325159Sphilip# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by
283325159Sphilip# # Unix Systems Group code and are required by POSIX 2008 (with XSI) and later.
284325159Sphilip# # If not defined, the code attempts to guess USG_COMPAT from other macros.
285325159Sphilip# #
286325159Sphilip# # To support the external variable "altzone", add
287325159Sphilip# #	-DALTZONE
288325159Sphilip# # to the end of the "CFLAGS=" line; although "altzone" appeared in
289325159Sphilip# # System V Release 3.1 it has not been standardized.
290325159Sphilip#
291308265Sgjb# If you want functions that were inspired by early versions of X3J11's work,
292308265Sgjb# add
293308265Sgjb#	-DSTD_INSPIRED
294308265Sgjb# to the end of the "CFLAGS=" line.  This arranges for the functions
295308265Sgjb# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
296308265Sgjb# "posix2time", and "time2posix" to be added to the time conversion library.
297308265Sgjb# "tzsetwall" is like "tzset" except that it arranges for local wall clock
298308265Sgjb# time (rather than the time specified in the TZ environment variable)
299308265Sgjb# to be used.
300308265Sgjb# "offtime" is like "gmtime" except that it accepts a second (long) argument
301308265Sgjb# that gives an offset to add to the time_t when converting it.
302308265Sgjb# "timelocal" is equivalent to "mktime".
303308265Sgjb# "timegm" is like "timelocal" except that it turns a struct tm into
304308265Sgjb# a time_t using UT (rather than local time as "timelocal" does).
305308265Sgjb# "timeoff" is like "timegm" except that it accepts a second (long) argument
306308265Sgjb# that gives an offset to use when converting to a time_t.
307308265Sgjb# "posix2time" and "time2posix" are described in an included manual page.
308308265Sgjb# X3J11's work does not describe any of these functions.
309308265Sgjb# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
310308265Sgjb# These functions may well disappear in future releases of the time
311308265Sgjb# conversion package.
312308265Sgjb#
313308265Sgjb# If you don't want functions that were inspired by NetBSD, add
314308265Sgjb#	-DNETBSD_INSPIRED=0
315308265Sgjb# to the end of the "CFLAGS=" line.  Otherwise, the functions
316308265Sgjb# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
317308265Sgjb# time library, and if STD_INSPIRED is also defined the functions
318308265Sgjb# "posix2time_z" and "time2posix_z" are added as well.
319308265Sgjb# The functions ending in "_z" (or "_rz") are like their unsuffixed
320308265Sgjb# (or suffixed-by-"_r") counterparts, except with an extra first
321308265Sgjb# argument of opaque type timezone_t that specifies the time zone.
322308265Sgjb# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
323308265Sgjb#
324308265Sgjb# If you want to allocate state structures in localtime, add
325308265Sgjb#	-DALL_STATE
326308265Sgjb# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
327308265Sgjb#
328308265Sgjb# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
329308265Sgjb# out by the National Institute of Standards and Technology
330308265Sgjb# which claims to test C and Posix conformance.  If you want to pass PCTS, add
331308265Sgjb#	-DPCTS
332308265Sgjb# to the end of the "CFLAGS=" line.
333308265Sgjb#
334308265Sgjb# If you want strict compliance with XPG4 as of 1994-04-09, add
335308265Sgjb#	-DXPG4_1994_04_09
336308265Sgjb# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
337325159Sphilip# 53 as a week number (rather than 52 or 53) for January days before
338325159Sphilip# January's first Monday when a "%V" format is used and January 1
339308265Sgjb# falls on a Friday, Saturday, or Sunday.
340308265Sgjb
341308265SgjbCFLAGS=
342308265Sgjb
343308265Sgjb# Linker flags.  Default to $(LFLAGS) for backwards compatibility
344308265Sgjb# to release 2012h and earlier.
345308265Sgjb
346308265SgjbLDFLAGS=	$(LFLAGS)
347308265Sgjb
348308265Sgjb# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
349308265Sgjb# submake command lines.  The default is no leap seconds.
350308265Sgjb
351308265SgjbLEAPSECONDS=
352308265Sgjb
353308265Sgjb# The zic command and its arguments.
354308265Sgjb
355308265Sgjbzic=		./zic
356308265SgjbZIC=		$(zic) $(ZFLAGS)
357308265Sgjb
358308265SgjbZFLAGS=
359308265Sgjb
360308265Sgjb# How to use zic to install tz binary files.
361308265Sgjb
362328475SphilipZIC_INSTALL=	$(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS)
363308265Sgjb
364308265Sgjb# The name of a Posix-compliant 'awk' on your system.
365308265SgjbAWK=		awk
366308265Sgjb
367308265Sgjb# The full path name of a Posix-compliant shell, preferably one that supports
368308265Sgjb# the Korn shell's 'select' statement as an extension.
369308265Sgjb# These days, Bash is the most popular.
370308265Sgjb# It should be OK to set this to /bin/sh, on platforms where /bin/sh
371308265Sgjb# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
372308265Sgjb# is typically nicer if it works.
373308265SgjbKSHELL=		/bin/bash
374308265Sgjb
375308265Sgjb# The path where SGML DTDs are kept and the catalog file(s) to use when
376308265Sgjb# validating.  The default should work on both Debian and Red Hat.
377308265SgjbSGML_TOPDIR= /usr
378308265SgjbSGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd
379308265SgjbSGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224
380308265SgjbSGML_CATALOG_FILES= \
381308265Sgjb  $(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
382308265Sgjb
383308265Sgjb# The name, arguments and environment of a program to validate your web pages.
384308265Sgjb# See <http://openjade.sourceforge.net/doc/> for a validator, and
385308265Sgjb# <https://validator.w3.org/source/> for a validation library.
386325159Sphilip# Set VALIDATE=':' if you do not have such a program.
387308265SgjbVALIDATE = nsgmls
388308265SgjbVALIDATE_FLAGS = -s -B -wall -wno-unused-param
389308265SgjbVALIDATE_ENV = \
390328475Sphilip  SGML_CATALOG_FILES='$(SGML_CATALOG_FILES)' \
391328475Sphilip  SGML_SEARCH_PATH='$(SGML_SEARCH_PATH)' \
392308265Sgjb  SP_CHARSET_FIXED=YES \
393308265Sgjb  SP_ENCODING=UTF-8
394308265Sgjb
395308265Sgjb# This expensive test requires USE_LTZ.
396308265Sgjb# To suppress it, define this macro to be empty.
397308265SgjbCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
398308265Sgjb
399308265Sgjb# SAFE_CHAR is a regular expression that matches a safe character.
400308265Sgjb# Some parts of this distribution are limited to safe characters;
401308265Sgjb# others can use any UTF-8 character.
402308265Sgjb# For now, the safe characters are a safe subset of ASCII.
403308265Sgjb# The caller must set the shell variable 'sharp' to the character '#',
404308265Sgjb# since Makefile macros cannot contain '#'.
405308265Sgjb# TAB_CHAR is a single tab character, in single quotes.
406308265SgjbTAB_CHAR=	'	'
407308265SgjbSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
408308265SgjbSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
409308265SgjbSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
410308265SgjbSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
411308265SgjbSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
412308265Sgjb
413331662Sphilip# Non-ASCII non-letters that OK_CHAR allows, as these characters are
414331662Sphilip# useful in commentary.  XEmacs 21.5.34 displays them correctly,
415331662Sphilip# presumably because they are Latin-1.
416331662SphilipUNUSUAL_OK_CHARSET= ����������
417331662Sphilip
418308265Sgjb# OK_CHAR matches any character allowed in the distributed files.
419331662Sphilip# This is the same as SAFE_CHAR, except that UNUSUAL_OK_CHARSET and
420331662Sphilip# multibyte letters are also allowed so that commentary can contain a
421331662Sphilip# few safe symbols and people's names and can quote non-English sources.
422331662Sphilip# Other non-letters are limited to ASCII renderings for the
423331662Sphilip# convenience of maintainers using XEmacs 21.5.34, which by default
424331662Sphilip# mishandles Unicode characters U+0100 and greater.
425331662SphilipOK_CHAR=	'[][:alpha:]$(UNUSUAL_OK_CHARSET)'$(SAFE_CHARSET)'-]'
426308265Sgjb
427308265Sgjb# SAFE_LINE matches a line of safe characters.
428308265Sgjb# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
429308265Sgjb# this is so that comments can contain non-ASCII characters.
430308265Sgjb# OK_LINE matches a line of OK characters.
431308265SgjbSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
432308265SgjbSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
433308265SgjbOK_LINE=	'^'$(OK_CHAR)'*$$'
434308265Sgjb
435308265Sgjb# Flags to give 'tar' when making a distribution.
436308265Sgjb# Try to use flags appropriate for GNU tar.
437308265SgjbGNUTARFLAGS= --numeric-owner --owner=0 --group=0 --mode=go+u,go-w --sort=name
438308265SgjbTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
439308265Sgjb		 then echo $(GNUTARFLAGS); \
440308265Sgjb		 else :; \
441308265Sgjb		 fi`
442308265Sgjb
443308265Sgjb# Flags to give 'gzip' when making a distribution.
444308265SgjbGZIPFLAGS=	-9n
445308265Sgjb
446308265Sgjb###############################################################################
447308265Sgjb
448308265Sgjb#MAKE=		make
449308265Sgjb
450308265Sgjbcc=		cc
451328475SphilipCC=		$(cc) -DTZDIR='"$(TZDIR)"'
452308265Sgjb
453308265SgjbAR=		ar
454308265Sgjb
455308265Sgjb# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
456308265SgjbRANLIB=		:
457308265Sgjb
458308265SgjbTZCOBJS=	zic.o
459325159SphilipTZDOBJS=	zdump.o localtime.o asctime.o strftime.o
460308265SgjbDATEOBJS=	date.o localtime.o strftime.o asctime.o
461308265SgjbLIBSRCS=	localtime.c asctime.c difftime.c
462308265SgjbLIBOBJS=	localtime.o asctime.o difftime.o
463308265SgjbHEADERS=	tzfile.h private.h
464308265SgjbNONLIBSRCS=	zic.c zdump.c
465308265SgjbNEWUCBSRCS=	date.c strftime.c
466308265SgjbSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
467308265Sgjb			tzselect.ksh workman.sh
468308265SgjbMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
469308265Sgjb			tzfile.5 tzselect.8 zic.8 zdump.8
470308265SgjbMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
471308265Sgjb			time2posix.3.txt \
472308265Sgjb			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
473308265Sgjb			date.1.txt
474325159SphilipCOMMON=		calendars CONTRIBUTING LICENSE Makefile \
475325159Sphilip			NEWS README theory.html version
476328475SphilipWEB_PAGES=	tz-art.html tz-how-to.html tz-link.html
477308265SgjbDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
478308265SgjbPRIMARY_YDATA=	africa antarctica asia australasia \
479308265Sgjb		europe northamerica southamerica
480328475SphilipYDATA=		$(PRIMARY_YDATA) etcetera
481308265SgjbNDATA=		systemv factory
482328475SphilipTDATA_TO_CHECK=	$(YDATA) $(NDATA) backward pacificnew
483328475SphilipTDATA=		$(YDATA) $(NDATA) $(BACKWARD)
484308265SgjbZONETABLES=	zone1970.tab zone.tab
485325159SphilipTABDATA=	iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
486308265SgjbLEAP_DEPS=	leapseconds.awk leap-seconds.list
487331662SphilipTZDATA_ZI_DEPS=	ziguard.awk zishrink.awk version $(TDATA) $(PACKRATDATA)
488331662SphilipDSTDATA_ZI_DEPS= ziguard.awk $(TDATA) $(PACKRATDATA)
489328475SphilipDATA=		$(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
490325159Sphilip			leapseconds yearistype.sh $(ZONETABLES)
491331662SphilipAWK_SCRIPTS=	checklinks.awk checktab.awk leapseconds.awk \
492331662Sphilip			ziguard.awk zishrink.awk
493308265SgjbMISC=		$(AWK_SCRIPTS) zoneinfo2tdf.pl
494308265SgjbTZS_YEAR=	2050
495308265SgjbTZS=		to$(TZS_YEAR).tzs
496308265SgjbTZS_NEW=	to$(TZS_YEAR)new.tzs
497308265SgjbTZS_DEPS=	$(PRIMARY_YDATA) asctime.c localtime.c \
498308265Sgjb			private.h tzfile.h zdump.c zic.c
499325159SphilipENCHILADA=	$(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS) tzdata.zi
500308265Sgjb
501308265Sgjb# Consult these files when deciding whether to rebuild the 'version' file.
502308265Sgjb# This list is not the same as the output of 'git ls-files', since
503308265Sgjb# .gitignore is not distributed.
504308265SgjbVERSION_DEPS= \
505325159Sphilip		calendars CONTRIBUTING LICENSE Makefile NEWS README \
506308265Sgjb		africa antarctica asctime.c asia australasia \
507308265Sgjb		backward backzone \
508308265Sgjb		checklinks.awk checktab.awk \
509308265Sgjb		date.1 date.c difftime.c \
510308265Sgjb		etcetera europe factory iso3166.tab \
511308265Sgjb		leap-seconds.list leapseconds.awk localtime.c \
512308265Sgjb		newctime.3 newstrftime.3 newtzset.3 northamerica \
513308265Sgjb		pacificnew private.h \
514325159Sphilip		southamerica strftime.c systemv theory.html \
515328475Sphilip		time2posix.3 tz-art.html tz-how-to.html tz-link.html \
516308265Sgjb		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
517308265Sgjb		workman.sh yearistype.sh \
518308265Sgjb		zdump.8 zdump.c zic.8 zic.c \
519333312Sphilip		ziguard.awk zishrink.awk \
520308265Sgjb		zone.tab zone1970.tab zoneinfo2tdf.pl
521308265Sgjb
522308265Sgjb# And for the benefit of csh users on systems that assume the user
523308265Sgjb# shell should be used to handle commands in Makefiles. . .
524308265Sgjb
525308265SgjbSHELL=		/bin/sh
526308265Sgjb
527331662Sphilipall:		tzselect yearistype zic zdump libtz.a $(TABDATA) \
528331662Sphilip		  vanguard.zi main.zi rearguard.zi
529308265Sgjb
530308265SgjbALL:		all date $(ENCHILADA)
531308265Sgjb
532308265Sgjbinstall:	all $(DATA) $(REDO) $(MANS)
533328475Sphilip		mkdir -p '$(DESTDIR)$(BINDIR)' \
534328475Sphilip			'$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
535328475Sphilip			'$(DESTDIR)$(LIBDIR)' \
536328475Sphilip			'$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
537328475Sphilip			'$(DESTDIR)$(MANDIR)/man8'
538328475Sphilip		$(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES) \
539328475Sphilip			-t '$(DESTDIR)$(TZDEFAULT)'
540328475Sphilip		cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
541328475Sphilip		cp tzselect '$(DESTDIR)$(BINDIR)/.'
542328475Sphilip		cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
543328475Sphilip		cp zic '$(DESTDIR)$(ZICDIR)/.'
544328475Sphilip		cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
545328475Sphilip		$(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
546328475Sphilip		cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
547328475Sphilip		cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
548328475Sphilip		cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
549308265Sgjb
550308265SgjbINSTALL:	ALL install date.1
551328475Sphilip		mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
552328475Sphilip		cp date '$(DESTDIR)$(BINDIR)/.'
553328475Sphilip		cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
554308265Sgjb
555308265Sgjbversion:	$(VERSION_DEPS)
556308265Sgjb		{ (type git) >/dev/null 2>&1 && \
557308265Sgjb		  V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
558308265Sgjb				--abbrev=7 --dirty` || \
559328475Sphilip		  V='$(VERSION)'; } && \
560308265Sgjb		printf '%s\n' "$$V" >$@.out
561308265Sgjb		mv $@.out $@
562308265Sgjb
563331662Sphilip# These files can be tailored by setting BACKWARD, PACKRATDATA, etc.
564331662Sphilipvanguard.zi main.zi rearguard.zi: $(DSTDATA_ZI_DEPS)
565333312Sphilip		$(AWK) -v DATAFORM=`expr $@ : '\(.*\).zi'` -f ziguard.awk \
566333312Sphilip		  $(TDATA) $(PACKRATDATA) >$@.out
567331662Sphilip		mv $@.out $@
568331662Sphiliptzdata.zi:	$(DATAFORM).zi version
569328475Sphilip		version=`sed 1q version` && \
570328475Sphilip		  LC_ALL=C $(AWK) -v version="$$version" -f zishrink.awk \
571331662Sphilip		    $(DATAFORM).zi >$@.out
572325159Sphilip		mv $@.out $@
573325159Sphilip
574308265Sgjbversion.h:	version
575308265Sgjb		VERSION=`cat version` && printf '%s\n' \
576308265Sgjb		  'static char const PKGVERSION[]="($(PACKAGE)) ";' \
577308265Sgjb		  "static char const TZVERSION[]=\"$$VERSION\";" \
578308265Sgjb		  'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
579308265Sgjb		  >$@.out
580308265Sgjb		mv $@.out $@
581308265Sgjb
582308265Sgjbzdump:		$(TZDOBJS)
583308265Sgjb		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
584308265Sgjb
585308265Sgjbzic:		$(TZCOBJS)
586308265Sgjb		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
587308265Sgjb
588308265Sgjbyearistype:	yearistype.sh
589308265Sgjb		cp yearistype.sh yearistype
590308265Sgjb		chmod +x yearistype
591308265Sgjb
592308265Sgjbleapseconds:	$(LEAP_DEPS)
593308265Sgjb		$(AWK) -f leapseconds.awk leap-seconds.list >$@.out
594308265Sgjb		mv $@.out $@
595308265Sgjb
596308265Sgjb# Arguments to pass to submakes of install_data.
597308265Sgjb# They can be overridden by later submake arguments.
598308265SgjbINSTALLARGS = \
599328475Sphilip BACKWARD='$(BACKWARD)' \
600328475Sphilip DESTDIR='$(DESTDIR)' \
601308265Sgjb LEAPSECONDS='$(LEAPSECONDS)' \
602308265Sgjb PACKRATDATA='$(PACKRATDATA)' \
603328475Sphilip TZDEFAULT='$(TZDEFAULT)' \
604328475Sphilip TZDIR='$(TZDIR)' \
605328475Sphilip YEARISTYPE='$(YEARISTYPE)' \
606308265Sgjb ZIC='$(ZIC)'
607308265Sgjb
608308265Sgjb# 'make install_data' installs one set of tz binary files.
609325159Sphilipinstall_data:	zic leapseconds yearistype tzdata.zi
610325159Sphilip		$(ZIC_INSTALL) tzdata.zi
611308265Sgjb
612308265Sgjbposix_only:
613308265Sgjb		$(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
614308265Sgjb
615308265Sgjbright_only:
616308265Sgjb		$(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
617308265Sgjb			install_data
618308265Sgjb
619308265Sgjb# In earlier versions of this makefile, the other two directories were
620308265Sgjb# subdirectories of $(TZDIR).  However, this led to configuration errors.
621308265Sgjb# For example, with posix_right under the earlier scheme,
622308265Sgjb# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
623308265Sgjb# but gmtime without leap seconds, which led to problems with applications
624308265Sgjb# like sendmail that subtract gmtime from localtime.
625308265Sgjb# Therefore, the other two directories are now siblings of $(TZDIR).
626308265Sgjb# You must replace all of $(TZDIR) to switch from not using leap seconds
627308265Sgjb# to using them, or vice versa.
628308265Sgjbright_posix:	right_only
629328475Sphilip		rm -fr '$(DESTDIR)$(TZDIR)-leaps'
630328475Sphilip		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
631328475Sphilip		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
632328475Sphilip		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
633308265Sgjb
634308265Sgjbposix_right:	posix_only
635328475Sphilip		rm -fr '$(DESTDIR)$(TZDIR)-posix'
636328475Sphilip		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
637328475Sphilip		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
638328475Sphilip		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
639308265Sgjb
640308265Sgjb# This obsolescent rule is present for backwards compatibility with
641308265Sgjb# tz releases 2014g through 2015g.  It should go away eventually.
642308265Sgjbposix_packrat:
643308265Sgjb		$(MAKE) $(INSTALLARGS) PACKRATDATA=backzone posix_only
644308265Sgjb
645308265Sgjbzones:		$(REDO)
646308265Sgjb
647331662Sphilip# dummy.zd is not a real file; it is mentioned here only so that the
648331662Sphilip# top-level 'make' does not have a syntax error.
649331662SphilipZDS = dummy.zd
650331662Sphilip# Rule used only by submakes invoked by the $(TZS_NEW) rule.
651331662Sphilip# It is separate so that GNU 'make -j' can run instances in parallel.
652331662Sphilip$(ZDS): zdump
653331662Sphilip		./zdump -i -c $(TZS_YEAR) '$(wd)/'$$(expr $@ : '\(.*\).zd') >$@
654331662Sphilip
655325159Sphilip$(TZS_NEW):	tzdata.zi zdump zic
656331662Sphilip		rm -fr tzs.dir
657331662Sphilip		mkdir tzs.dir
658325159Sphilip		$(zic) -d tzs.dir tzdata.zi
659325159Sphilip		$(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
660325159Sphilip		   tzdata.zi | LC_ALL=C sort >$@.out
661308265Sgjb		wd=`pwd` && \
662331662Sphilip		set x `$(AWK) '/^Z/{print "tzs.dir/" $$2 ".zd"}' tzdata.zi \
663331662Sphilip			| LC_ALL=C sort -t . -k 2,2` && \
664331662Sphilip		shift && \
665331662Sphilip		ZDS=$$* && \
666331662Sphilip		$(MAKE) wd="$$wd" TZS_YEAR=$(TZS_YEAR) ZDS="$$ZDS" $$ZDS && \
667331662Sphilip		sed 's,^TZ=".*tzs\.dir/,TZ=",' $$ZDS >>$@.out
668331662Sphilip		rm -fr tzs.dir
669331662Sphilip		mv $@.out $@
670308265Sgjb
671308265Sgjb# If $(TZS) does not already exist (e.g., old-format tarballs), create it.
672308265Sgjb# If it exists but 'make check_tzs' fails, a maintainer should inspect the
673308265Sgjb# failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
674308265Sgjb$(TZS):
675308265Sgjb		$(MAKE) force_tzs
676308265Sgjb
677308265Sgjbforce_tzs:	$(TZS_NEW)
678308265Sgjb		cp $(TZS_NEW) $(TZS)
679308265Sgjb
680308265Sgjblibtz.a:	$(LIBOBJS)
681309792Sbapt		rm -f $@
682309792Sbapt		$(AR) -rc $@ $(LIBOBJS)
683308265Sgjb		$(RANLIB) $@
684308265Sgjb
685308265Sgjbdate:		$(DATEOBJS)
686308265Sgjb		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
687308265Sgjb
688308265Sgjbtzselect:	tzselect.ksh version
689308265Sgjb		VERSION=`cat version` && sed \
690308265Sgjb			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
691308265Sgjb			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
692308265Sgjb			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
693308265Sgjb			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
694308265Sgjb			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
695308265Sgjb			-e 's|\(TZVERSION\)=.*|\1='"$$VERSION"'|' \
696308265Sgjb			<$@.ksh >$@.out
697308265Sgjb		chmod +x $@.out
698308265Sgjb		mv $@.out $@
699308265Sgjb
700325159Sphilipcheck:		check_character_set check_white_space check_links \
701325159Sphilip		  check_name_lengths check_sorted \
702325159Sphilip		  check_tables check_web check_zishrink check_tzs
703308265Sgjb
704308265Sgjbcheck_character_set: $(ENCHILADA)
705325159Sphilip	test ! '$(UTF8_LOCALE)' || \
706325159Sphilip	! printf 'A\304\200B\n' | \
707325159Sphilip	  LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 || { \
708325159Sphilip		LC_ALL='$(UTF8_LOCALE)' && export LC_ALL && \
709308265Sgjb		sharp='#' && \
710308265Sgjb		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
711308265Sgjb			$(MISC) $(SOURCES) $(WEB_PAGES) \
712331662Sphilip			CONTRIBUTING LICENSE README \
713325159Sphilip			version tzdata.zi && \
714331662Sphilip		! grep -Env $(SAFE_LINE)'|^UNUSUAL_OK_CHARSET='$(OK_CHAR)'*$$' \
715331662Sphilip			Makefile && \
716328475Sphilip		! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
717308265Sgjb			leapseconds yearistype.sh zone.tab && \
718325159Sphilip		! grep -Env $(OK_LINE) $(ENCHILADA); \
719325159Sphilip	}
720308265Sgjb
721308265Sgjbcheck_white_space: $(ENCHILADA)
722308265Sgjb		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
723308265Sgjb		! grep -En "$$pat" $(ENCHILADA)
724328475Sphilip		! grep -n '[[:space:]]$$' \
725328475Sphilip			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
726308265Sgjb
727325159SphilipPRECEDES_FILE_NAME = ^(Zone|Link[[:space:]]+[^[:space:]]+)[[:space:]]+
728325159SphilipFILE_NAME_COMPONENT_TOO_LONG = \
729325159Sphilip  $(PRECEDES_FILE_NAME)[^[:space:]]*[^/[:space:]]{15}
730325159Sphilip
731328475Sphilipcheck_name_lengths: $(TDATA_TO_CHECK) backzone
732328475Sphilip		! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
733328475Sphilip			$(TDATA_TO_CHECK) backzone
734325159Sphilip
735308265SgjbCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
736308265Sgjb
737308265Sgjbcheck_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
738308265Sgjb		$(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu
739308265Sgjb		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
740308265Sgjb		$(AWK) '/^[^#]/ {print $$1}' iso3166.tab | LC_ALL=C sort -cu
741308265Sgjb		$(AWK) '/^[^#]/ {print $$1}' zone.tab | LC_ALL=C sort -c
742308265Sgjb		$(AWK) '/^[^#]/ {print substr($$0, 1, 2)}' zone1970.tab | \
743308265Sgjb		  LC_ALL=C sort -c
744308265Sgjb		$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
745308265Sgjb		  LC_ALL=C sort -cu
746308265Sgjb
747331662Sphilipcheck_links:	checklinks.awk $(TDATA_TO_CHECK) tzdata.zi
748328475Sphilip		$(AWK) -f checklinks.awk $(TDATA_TO_CHECK)
749325159Sphilip		$(AWK) -f checklinks.awk tzdata.zi
750308265Sgjb
751308265Sgjbcheck_tables:	checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
752308265Sgjb		for tab in $(ZONETABLES); do \
753308265Sgjb		  $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
754308265Sgjb		    || exit; \
755308265Sgjb		done
756308265Sgjb
757308265Sgjbcheck_tzs:	$(TZS) $(TZS_NEW)
758308265Sgjb		diff -u $(TZS) $(TZS_NEW)
759308265Sgjb
760325159Sphilip# This checks only the HTML 4.01 strict page.
761325159Sphilip# To check the the other pages, use <https://validator.w3.org/>.
762325159Sphilipcheck_web:	tz-how-to.html
763325159Sphilip		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) tz-how-to.html
764308265Sgjb
765331662Sphilip# Check that zishrink.awk does not alter the data, and that ziguard.awk
766331662Sphilip# preserves main-format data.
767331662Sphilipcheck_zishrink: zic leapseconds $(PACKRATDATA) $(TDATA) \
768331662Sphilip		  $(DATAFORM).zi tzdata.zi
769325159Sphilip		for type in posix right; do \
770331662Sphilip		  mkdir -p time_t.dir/$$type time_t.dir/$$type-t \
771331662Sphilip		    time_t.dir/$$type-shrunk && \
772325159Sphilip		  case $$type in \
773325159Sphilip		    right) leap='-L leapseconds';; \
774325159Sphilip	            *) leap=;; \
775325159Sphilip		  esac && \
776331662Sphilip		  $(ZIC) $$leap -d time_t.dir/$$type $(DATAFORM).zi && \
777331662Sphilip		  case $(DATAFORM) in \
778331662Sphilip		    main) \
779331662Sphilip		      $(ZIC) $$leap -d time_t.dir/$$type-t $(TDATA) && \
780331662Sphilip		      $(AWK) '/^Rule/' $(TDATA) | \
781331662Sphilip			$(ZIC) $$leap -d time_t.dir/$$type-t - \
782331662Sphilip			  $(PACKRATDATA) && \
783331662Sphilip		      diff -r time_t.dir/$$type time_t.dir/$$type-t;; \
784331662Sphilip		  esac && \
785325159Sphilip		  $(ZIC) $$leap -d time_t.dir/$$type-shrunk tzdata.zi && \
786325159Sphilip		  diff -r time_t.dir/$$type time_t.dir/$$type-shrunk || exit; \
787325159Sphilip		done
788325159Sphilip		rm -fr time_t.dir
789325159Sphilip
790308265Sgjbclean_misc:
791308265Sgjb		rm -f core *.o *.out \
792308265Sgjb		  date tzselect version.h zdump zic yearistype libtz.a
793308265Sgjbclean:		clean_misc
794331662Sphilip		rm -fr *.dir *.zi tzdb-*/ $(TZS_NEW)
795308265Sgjb
796308265Sgjbmaintainer-clean: clean
797308265Sgjb		@echo 'This command is intended for maintainers to use; it'
798308265Sgjb		@echo 'deletes files that may need special tools to rebuild.'
799308265Sgjb		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
800308265Sgjb
801308265Sgjbnames:
802308265Sgjb		@echo $(ENCHILADA)
803308265Sgjb
804308265Sgjbpublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
805308265Sgjb		tarballs signatures
806308265Sgjb
807308265Sgjbdate.1.txt:	date.1
808308265Sgjbnewctime.3.txt:	newctime.3
809308265Sgjbnewstrftime.3.txt: newstrftime.3
810308265Sgjbnewtzset.3.txt:	newtzset.3
811308265Sgjbtime2posix.3.txt: time2posix.3
812308265Sgjbtzfile.5.txt:	tzfile.5
813308265Sgjbtzselect.8.txt:	tzselect.8
814308265Sgjbzdump.8.txt:	zdump.8
815308265Sgjbzic.8.txt:	zic.8
816308265Sgjb
817308265Sgjb$(MANTXTS):	workman.sh
818308265Sgjb		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out
819308265Sgjb		mv $@.out $@
820308265Sgjb
821308265Sgjb# Set the time stamps to those of the git repository, if available,
822308265Sgjb# and if the files have not changed since then.
823308265Sgjb# This uses GNU 'touch' syntax 'touch -d@N FILE',
824308265Sgjb# where N is the number of seconds since 1970.
825308265Sgjb# If git or GNU 'touch' is absent, don't bother to sync with git timestamps.
826308265Sgjb# Also, set the timestamp of each prebuilt file like 'leapseconds'
827308265Sgjb# to be the maximum of the files it depends on.
828308265Sgjbset-timestamps.out: $(ENCHILADA)
829308265Sgjb		rm -f $@
830308265Sgjb		if (type git) >/dev/null 2>&1 && \
831308265Sgjb		   files=`git ls-files $(ENCHILADA)` && \
832308265Sgjb		   touch -md @1 test.out; then \
833308265Sgjb		  rm -f test.out && \
834308265Sgjb		  for file in $$files; do \
835308265Sgjb		    if git diff --quiet $$file; then \
836308265Sgjb		      time=`git log -1 --format='tformat:%ct' $$file` && \
837308265Sgjb		      touch -cmd @$$time $$file; \
838308265Sgjb		    else \
839308265Sgjb		      echo >&2 "$$file: warning: does not match repository"; \
840308265Sgjb		    fi || exit; \
841308265Sgjb		  done; \
842308265Sgjb		fi
843308265Sgjb		touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds
844308265Sgjb		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
845308265Sgjb		  touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \
846308265Sgjb		    exit; \
847308265Sgjb		done
848325159Sphilip		touch -cmr `ls -t $(TZDATA_ZI_DEPS) | sed 1q` tzdata.zi
849308265Sgjb		touch -cmr `ls -t $(TZS_DEPS) | sed 1q` $(TZS)
850308265Sgjb		touch -cmr `ls -t $(VERSION_DEPS) | sed 1q` version
851308265Sgjb		touch $@
852308265Sgjb
853308265Sgjb# The zics below ensure that each data file can stand on its own.
854308265Sgjb# We also do an all-files run to catch links to links.
855308265Sgjb
856308265Sgjbcheck_public:
857308265Sgjb		$(MAKE) maintainer-clean
858328475Sphilip		$(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' ALL
859308265Sgjb		mkdir -p public.dir
860328475Sphilip		for i in $(TDATA_TO_CHECK) tzdata.zi; do \
861308265Sgjb		  $(zic) -v -d public.dir $$i 2>&1 || exit; \
862308265Sgjb		done
863328475Sphilip		$(zic) -v -d public.dir $(TDATA_TO_CHECK)
864308265Sgjb		rm -fr public.dir
865308265Sgjb
866308265Sgjb# Check that the code works under various alternative
867308265Sgjb# implementations of time_t.
868308265Sgjbcheck_time_t_alternatives:
869308265Sgjb		if diff -q Makefile Makefile 2>/dev/null; then \
870308265Sgjb		  quiet_option='-q'; \
871308265Sgjb		else \
872308265Sgjb		  quiet_option=''; \
873308265Sgjb		fi && \
874308265Sgjb		wd=`pwd` && \
875308265Sgjb		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
876308265Sgjb		for type in $(TIME_T_ALTERNATIVES); do \
877308265Sgjb		  mkdir -p time_t.dir/$$type && \
878308265Sgjb		  $(MAKE) clean_misc && \
879308265Sgjb		  $(MAKE) TOPDIR="$$wd/time_t.dir/$$type" \
880308265Sgjb		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
881308265Sgjb		    REDO='$(REDO)' \
882308265Sgjb		    install && \
883308265Sgjb		  diff $$quiet_option -r \
884328475Sphilip		    time_t.dir/int64_t/etc \
885328475Sphilip		    time_t.dir/$$type/etc && \
886328475Sphilip		  diff $$quiet_option -r \
887328475Sphilip		    time_t.dir/int64_t/usr/share \
888328475Sphilip		    time_t.dir/$$type/usr/share && \
889308265Sgjb		  case $$type in \
890308265Sgjb		  int32_t) range=-2147483648,2147483647;; \
891308265Sgjb		  uint32_t) range=0,4294967296;; \
892308265Sgjb		  int64_t) continue;; \
893308265Sgjb		  *u*) range=0,10000000000;; \
894308265Sgjb		  *) range=-10000000000,10000000000;; \
895308265Sgjb		  esac && \
896308265Sgjb		  echo checking $$type zones ... && \
897328475Sphilip		  time_t.dir/int64_t/usr/bin/zdump -V -t $$range $$zones \
898308265Sgjb		      >time_t.dir/int64_t.out && \
899328475Sphilip		  time_t.dir/$$type/usr/bin/zdump -V -t $$range $$zones \
900308265Sgjb		      >time_t.dir/$$type.out && \
901308265Sgjb		  diff -u time_t.dir/int64_t.out time_t.dir/$$type.out \
902308265Sgjb		    || exit; \
903308265Sgjb		done
904308265Sgjb		rm -fr time_t.dir
905308265Sgjb
906333312SphilipTRADITIONAL_ASC = \
907333312Sphilip  tzcode$(VERSION).tar.gz.asc \
908333312Sphilip  tzdata$(VERSION).tar.gz.asc
909333312SphilipALL_ASC = $(TRADITIONAL_ASC) \
910333312Sphilip  tzdata$(VERSION)-rearguard.tar.gz.asc \
911333312Sphilip  tzdb-$(VERSION).tar.lz.asc
912333312Sphilip
913308265Sgjbtarballs traditional_tarballs signatures traditional_signatures: version
914308265Sgjb		VERSION=`cat version` && \
915308265Sgjb		$(MAKE) VERSION="$$VERSION" $@_version
916308265Sgjb
917331662Sphilip# These *_version rules are intended for use if VERSION is set by some
918331662Sphilip# other means.  Ordinarily these rules are used only by the above
919331662Sphilip# non-_version rules, which set VERSION on the 'make' command line.
920333312Sphiliptarballs_version: traditional_tarballs_version \
921333312Sphilip  tzdata$(VERSION)-rearguard.tar.gz \
922333312Sphilip  tzdb-$(VERSION).tar.lz
923308265Sgjbtraditional_tarballs_version: \
924308265Sgjb  tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
925333312Sphilipsignatures_version: $(ALL_ASC)
926333312Sphiliptraditional_signatures_version: $(TRADITIONAL_ASC)
927308265Sgjb
928308265Sgjbtzcode$(VERSION).tar.gz: set-timestamps.out
929308265Sgjb		LC_ALL=C && export LC_ALL && \
930308265Sgjb		tar $(TARFLAGS) -cf - \
931308265Sgjb		    $(COMMON) $(DOCS) $(SOURCES) | \
932308265Sgjb		  gzip $(GZIPFLAGS) >$@.out
933308265Sgjb		mv $@.out $@
934308265Sgjb
935308265Sgjbtzdata$(VERSION).tar.gz: set-timestamps.out
936308265Sgjb		LC_ALL=C && export LC_ALL && \
937308265Sgjb		tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
938308265Sgjb		  gzip $(GZIPFLAGS) >$@.out
939308265Sgjb		mv $@.out $@
940308265Sgjb
941333312Sphiliptzdata$(VERSION)-rearguard.tar.gz: rearguard.zi set-timestamps.out
942333312Sphilip		rm -fr tzdata$(VERSION)-rearguard.dir
943333312Sphilip		mkdir tzdata$(VERSION)-rearguard.dir
944333312Sphilip		ln $(COMMON) $(DATA) $(MISC) tzdata$(VERSION)-rearguard.dir
945333312Sphilip		cd tzdata$(VERSION)-rearguard.dir && \
946333312Sphilip		  rm -f $(TDATA) $(PACKRATDATA) version
947333312Sphilip		for f in $(TDATA) $(PACKRATDATA); do \
948333312Sphilip		  rearf=tzdata$(VERSION)-rearguard.dir/$$f; \
949333312Sphilip		  $(AWK) -v DATAFORM=rearguard -f ziguard.awk $$f >$$rearf && \
950333312Sphilip		  touch -cmr `ls -t ziguard.awk $$f` $$rearf || exit; \
951333312Sphilip		done
952333312Sphilip		sed '1s/$$/-rearguard/' \
953333312Sphilip		  <version >tzdata$(VERSION)-rearguard.dir/version
954333312Sphilip		touch -cmr version tzdata$(VERSION)-rearguard.dir/version
955333312Sphilip		LC_ALL=C && export LC_ALL && \
956333312Sphilip		  (cd tzdata$(VERSION)-rearguard.dir && \
957333312Sphilip		   tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
958333312Sphilip		     gzip $(GZIPFLAGS)) >$@.out
959333312Sphilip		mv $@.out $@
960333312Sphilip
961308265Sgjbtzdb-$(VERSION).tar.lz: set-timestamps.out
962308265Sgjb		rm -fr tzdb-$(VERSION)
963308265Sgjb		mkdir tzdb-$(VERSION)
964308265Sgjb		ln $(ENCHILADA) tzdb-$(VERSION)
965308265Sgjb		touch -cmr `ls -t tzdb-$(VERSION)/* | sed 1q` tzdb-$(VERSION)
966308265Sgjb		LC_ALL=C && export LC_ALL && \
967308265Sgjb		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out
968308265Sgjb		mv $@.out $@
969308265Sgjb
970308265Sgjbtzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
971308265Sgjbtzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
972333312Sphiliptzdata$(VERSION)-rearguard.tar.gz.asc: tzdata$(VERSION)-rearguard.tar.gz
973308265Sgjbtzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
974333312Sphilip$(ALL_ASC):
975308265Sgjb		gpg --armor --detach-sign $?
976308265Sgjb
977308265Sgjbtypecheck:
978308265Sgjb		$(MAKE) clean
979308265Sgjb		for i in "long long" unsigned; \
980308265Sgjb		do \
981308265Sgjb			$(MAKE) CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
982308265Sgjb			./zdump -v Europe/Rome ; \
983308265Sgjb			$(MAKE) clean ; \
984308265Sgjb		done
985308265Sgjb
986325159Sphilipzonenames:	tzdata.zi
987325159Sphilip		@$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
988308265Sgjb
989308265Sgjbasctime.o:	private.h tzfile.h
990308265Sgjbdate.o:		private.h
991308265Sgjbdifftime.o:	private.h
992308265Sgjblocaltime.o:	private.h tzfile.h
993308265Sgjbstrftime.o:	private.h tzfile.h
994308265Sgjbzdump.o:	version.h
995308265Sgjbzic.o:		private.h tzfile.h version.h
996308265Sgjb
997308265Sgjb.KEEP_STATE:
998308265Sgjb
999308265Sgjb.PHONY: ALL INSTALL all
1000331662Sphilip.PHONY: check check_character_set check_links check_name_lengths
1001308265Sgjb.PHONY: check_public check_sorted check_tables
1002308265Sgjb.PHONY: check_time_t_alternatives check_tzs check_web check_white_space
1003325159Sphilip.PHONY: check_zishrink
1004331662Sphilip.PHONY: clean clean_misc dummy.zd force_tzs
1005308265Sgjb.PHONY: install install_data maintainer-clean names
1006308265Sgjb.PHONY: posix_only posix_packrat posix_right
1007308265Sgjb.PHONY: public right_only right_posix signatures signatures_version
1008331662Sphilip.PHONY: tarballs tarballs_version
1009331662Sphilip.PHONY: traditional_signatures traditional_signatures_version
1010331662Sphilip.PHONY: traditional_tarballs traditional_tarballs_version
1011331662Sphilip.PHONY: typecheck
1012308265Sgjb.PHONY: zonenames zones
1013331662Sphilip.PHONY: $(ZDS)
1014