xref: /freebsd/contrib/tzdata/Makefile (revision e350c46ae554cbbcea0e62f796612d94d82914f2)
1ba2b2efdSGlen Barber# This file is in the public domain, so clarified as of
2ba2b2efdSGlen Barber# 2009-05-17 by Arthur David Olson.
3ba2b2efdSGlen Barber
4ba2b2efdSGlen Barber# Package name for the code distribution.
5ba2b2efdSGlen BarberPACKAGE=	tzcode
6ba2b2efdSGlen Barber
7ba2b2efdSGlen Barber# Version number for the distribution, overridden in the 'tarballs' rule below.
8ba2b2efdSGlen BarberVERSION=	unknown
9ba2b2efdSGlen Barber
10ba2b2efdSGlen Barber# Email address for bug reports.
11ba2b2efdSGlen BarberBUGEMAIL=	tz@iana.org
12ba2b2efdSGlen Barber
13ba2b2efdSGlen Barber# Change the line below for your time zone (after finding the zone you want in
14ba2b2efdSGlen Barber# the time zone files, or adding it to a time zone file).
15ba2b2efdSGlen Barber# Alternately, if you discover you've got the wrong time zone, you can just
16ba2b2efdSGlen Barber#	zic -l rightzone
17ba2b2efdSGlen Barber# to correct things.
18ba2b2efdSGlen Barber# Use the command
19ba2b2efdSGlen Barber#	make zonenames
20ba2b2efdSGlen Barber# to get a list of the values you can use for LOCALTIME.
21ba2b2efdSGlen Barber
22ba2b2efdSGlen BarberLOCALTIME=	GMT
23ba2b2efdSGlen Barber
24ba2b2efdSGlen Barber# If you want something other than Eastern United States time as a template
25ba2b2efdSGlen Barber# for handling POSIX-style time zone environment variables,
26ba2b2efdSGlen Barber# change the line below (after finding the zone you want in the
27ba2b2efdSGlen Barber# time zone files, or adding it to a time zone file).
28ba2b2efdSGlen Barber# (When a POSIX-style environment variable is handled, the rules in the
29ba2b2efdSGlen Barber# template file are used to determine "spring forward" and "fall back" days and
30ba2b2efdSGlen Barber# times; the environment variable itself specifies UT offsets of standard and
31ba2b2efdSGlen Barber# summer time.)
32ba2b2efdSGlen Barber# Alternately, if you discover you've got the wrong time zone, you can just
33ba2b2efdSGlen Barber#	zic -p rightzone
34ba2b2efdSGlen Barber# to correct things.
35ba2b2efdSGlen Barber# Use the command
36ba2b2efdSGlen Barber#	make zonenames
37ba2b2efdSGlen Barber# to get a list of the values you can use for POSIXRULES.
38ba2b2efdSGlen Barber# If you want POSIX compatibility, use "America/New_York".
39ba2b2efdSGlen Barber
40ba2b2efdSGlen BarberPOSIXRULES=	America/New_York
41ba2b2efdSGlen Barber
42ba2b2efdSGlen Barber# Also see TZDEFRULESTRING below, which takes effect only
43ba2b2efdSGlen Barber# if the time zone files cannot be accessed.
44ba2b2efdSGlen Barber
45ba2b2efdSGlen Barber# Everything gets put in subdirectories of. . .
46ba2b2efdSGlen Barber
47ba2b2efdSGlen BarberTOPDIR=		/usr/local
48ba2b2efdSGlen Barber
49ba2b2efdSGlen Barber# "Compiled" time zone information is placed in the "TZDIR" directory
50ba2b2efdSGlen Barber# (and subdirectories).
51ba2b2efdSGlen Barber# Use an absolute path name for TZDIR unless you're just testing the software.
52ba2b2efdSGlen Barber
53ba2b2efdSGlen BarberTZDIR_BASENAME=	zoneinfo
54ba2b2efdSGlen BarberTZDIR=		$(TOPDIR)/etc/$(TZDIR_BASENAME)
55ba2b2efdSGlen Barber
56ba2b2efdSGlen Barber# Types to try, as an alternative to time_t.  int64_t should be first.
57ba2b2efdSGlen BarberTIME_T_ALTERNATIVES= int64_t int32_t uint32_t uint64_t
58ba2b2efdSGlen Barber
59ba2b2efdSGlen Barber# The "tzselect", "zic", and "zdump" commands get installed in. . .
60ba2b2efdSGlen Barber
61ba2b2efdSGlen BarberETCDIR=		$(TOPDIR)/etc
62ba2b2efdSGlen Barber
63ba2b2efdSGlen Barber# If you "make INSTALL", the "date" command gets installed in. . .
64ba2b2efdSGlen Barber
65ba2b2efdSGlen BarberBINDIR=		$(TOPDIR)/bin
66ba2b2efdSGlen Barber
67ba2b2efdSGlen Barber# Manual pages go in subdirectories of. . .
68ba2b2efdSGlen Barber
69ba2b2efdSGlen BarberMANDIR=		$(TOPDIR)/man
70ba2b2efdSGlen Barber
71ba2b2efdSGlen Barber# Library functions are put in an archive in LIBDIR.
72ba2b2efdSGlen Barber
73ba2b2efdSGlen BarberLIBDIR=		$(TOPDIR)/lib
74ba2b2efdSGlen Barber
75ba2b2efdSGlen Barber# If you always want time values interpreted as "seconds since the epoch
76ba2b2efdSGlen Barber# (not counting leap seconds)", use
77ba2b2efdSGlen Barber#	REDO=		posix_only
78ba2b2efdSGlen Barber# below.  If you always want right time values interpreted as "seconds since
79ba2b2efdSGlen Barber# the epoch" (counting leap seconds)", use
80ba2b2efdSGlen Barber#	REDO=		right_only
81ba2b2efdSGlen Barber# below.  If you want both sets of data available, with leap seconds not
82ba2b2efdSGlen Barber# counted normally, use
83ba2b2efdSGlen Barber#	REDO=		posix_right
84ba2b2efdSGlen Barber# below.  If you want both sets of data available, with leap seconds counted
85ba2b2efdSGlen Barber# normally, use
86ba2b2efdSGlen Barber#	REDO=		right_posix
87ba2b2efdSGlen Barber# below.  POSIX mandates that leap seconds not be counted; for compatibility
88ba2b2efdSGlen Barber# with it, use "posix_only" or "posix_right".
89ba2b2efdSGlen Barber
90ba2b2efdSGlen BarberREDO=		posix_right
91ba2b2efdSGlen Barber
92ba2b2efdSGlen Barber# If you want out-of-scope and often-wrong data from the file 'backzone', use
93ba2b2efdSGlen Barber#	PACKRATDATA=	backzone
94ba2b2efdSGlen Barber# To omit this data, use
95ba2b2efdSGlen Barber#	PACKRATDATA=
96ba2b2efdSGlen Barber
97ba2b2efdSGlen BarberPACKRATDATA=
98ba2b2efdSGlen Barber
99ba2b2efdSGlen Barber# Since "." may not be in PATH...
100ba2b2efdSGlen Barber
101ba2b2efdSGlen BarberYEARISTYPE=	./yearistype
102ba2b2efdSGlen Barber
103ba2b2efdSGlen Barber# Non-default libraries needed to link.
104ba2b2efdSGlen BarberLDLIBS=
105ba2b2efdSGlen Barber
106ba2b2efdSGlen Barber# Add the following to the end of the "CFLAGS=" line as needed.
107ba2b2efdSGlen Barber#  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
108ba2b2efdSGlen Barber#  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
109ba2b2efdSGlen Barber#  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
110ba2b2efdSGlen Barber#  -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS)
111ba2b2efdSGlen Barber#  -DHAVE_GETTEXT=1 if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris)
112ba2b2efdSGlen Barber#  -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
113ba2b2efdSGlen Barber#	ctime_r and asctime_r incompatibly with the POSIX standard
114ba2b2efdSGlen Barber#	(Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
115ba2b2efdSGlen Barber#  -DHAVE_INTTYPES_H=1 if you have a pre-C99 compiler with "inttypes.h"
116ba2b2efdSGlen Barber#  -DHAVE_LINK=0 if your system lacks a link function
117ba2b2efdSGlen Barber#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
118ba2b2efdSGlen Barber#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
119ba2b2efdSGlen Barber#	This defaults to 1 if a working localtime_rz seems to be available.
120ba2b2efdSGlen Barber#	localtime_rz can make zdump significantly faster, but is nonstandard.
121ba2b2efdSGlen Barber#  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
122ba2b2efdSGlen Barber#	functions like 'link' or variables like 'tzname' required by POSIX
123ba2b2efdSGlen Barber#  -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h"
124ba2b2efdSGlen Barber#  -DHAVE_STRFTIME_L=1 if <time.h> declares locale_t and strftime_l
125ba2b2efdSGlen Barber#	This defaults to 0 if _POSIX_VERSION < 200809, 1 otherwise.
126ba2b2efdSGlen Barber#  -DHAVE_STRDUP=0 if your system lacks the strdup function
127ba2b2efdSGlen Barber#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
128ba2b2efdSGlen Barber#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h"
129ba2b2efdSGlen Barber#  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h"
130ba2b2efdSGlen Barber#  -DHAVE_TZSET=0 if your system lacks a tzset function
131ba2b2efdSGlen Barber#  -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
132ba2b2efdSGlen Barber#  -DEPOCH_LOCAL=1 if the 'time' function returns local time not UT
133ba2b2efdSGlen Barber#  -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
134ba2b2efdSGlen Barber#	than what POSIX specifies, assuming local time is UT.
135ba2b2efdSGlen Barber#	For example, N is 252460800 on AmigaOS.
136ba2b2efdSGlen Barber#  -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
137ba2b2efdSGlen Barber#	if you do not want run time warnings about formats that may cause
138ba2b2efdSGlen Barber#	year 2000 grief
139ba2b2efdSGlen Barber#  -Dssize_t=long on ancient hosts that lack ssize_t
140ba2b2efdSGlen Barber#  -DTHREAD_SAFE=1 to make localtime.c thread-safe, as POSIX requires;
141ba2b2efdSGlen Barber#	not needed by the main-program tz code, which is single-threaded.
142ba2b2efdSGlen Barber#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
143ba2b2efdSGlen Barber#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
144ba2b2efdSGlen Barber#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
145ba2b2efdSGlen Barber#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
146ba2b2efdSGlen Barber#	the default is system-supplied, typically "/usr/lib/locale"
147ba2b2efdSGlen Barber#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
148ba2b2efdSGlen Barber#	DST transitions if the time zone files cannot be accessed
149ba2b2efdSGlen Barber#  -DUNINIT_TRAP=1 if reading uninitialized storage can cause problems
150ba2b2efdSGlen Barber#	other than simply getting garbage data
151ba2b2efdSGlen Barber#  -DUSE_LTZ=0 to build zdump with the system time zone library
152ba2b2efdSGlen Barber#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
153ba2b2efdSGlen Barber#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
154ba2b2efdSGlen Barber#	(or some other number) to set the maximum time zone abbreviation length
155ba2b2efdSGlen Barber#	that zic will accept without a warning (the default is 6)
156ba2b2efdSGlen Barber#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
157ba2b2efdSGlen BarberGCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
158ba2b2efdSGlen Barber	-Wall -Wextra \
159ba2b2efdSGlen Barber	-Wbad-function-cast -Wcast-align -Wdate-time \
160ba2b2efdSGlen Barber	-Wdeclaration-after-statement \
161ba2b2efdSGlen Barber	-Wdouble-promotion \
162ba2b2efdSGlen Barber	-Wformat=2 -Winit-self -Wjump-misses-init \
163ba2b2efdSGlen Barber	-Wlogical-op -Wmissing-prototypes -Wnested-externs \
164ba2b2efdSGlen Barber	-Wold-style-definition -Woverlength-strings -Wpointer-arith \
165ba2b2efdSGlen Barber	-Wshadow -Wstrict-prototypes -Wsuggest-attribute=const \
166ba2b2efdSGlen Barber	-Wsuggest-attribute=format -Wsuggest-attribute=noreturn \
167ba2b2efdSGlen Barber	-Wsuggest-attribute=pure -Wtrampolines \
168ba2b2efdSGlen Barber	-Wunused -Wwrite-strings \
169ba2b2efdSGlen Barber	-Wno-address -Wno-format-nonliteral -Wno-sign-compare \
170ba2b2efdSGlen Barber	-Wno-type-limits -Wno-unused-parameter
171ba2b2efdSGlen Barber#
172ba2b2efdSGlen Barber# If you want to use System V compatibility code, add
173ba2b2efdSGlen Barber#	-DUSG_COMPAT
174ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  This arrange for "timezone" and "daylight"
175ba2b2efdSGlen Barber# variables to be kept up-to-date by the time conversion functions.  Neither
176ba2b2efdSGlen Barber# "timezone" nor "daylight" is described in X3J11's work.
177ba2b2efdSGlen Barber#
178ba2b2efdSGlen Barber# If your system has a "GMT offset" field in its "struct tm"s
179ba2b2efdSGlen Barber# (or if you decide to add such a field in your system's "time.h" file),
180ba2b2efdSGlen Barber# add the name to a define such as
181ba2b2efdSGlen Barber#	-DTM_GMTOFF=tm_gmtoff
182ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
183ba2b2efdSGlen Barber# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
184ba2b2efdSGlen Barber# Similarly, if your system has a "zone abbreviation" field, define
185ba2b2efdSGlen Barber#	-DTM_ZONE=tm_zone
186ba2b2efdSGlen Barber# and define NO_TM_ZONE to suppress any guessing.  These two fields are not
187ba2b2efdSGlen Barber# required by POSIX, but are widely available on GNU/Linux and BSD systems.
188ba2b2efdSGlen Barber#
189ba2b2efdSGlen Barber# If you want functions that were inspired by early versions of X3J11's work,
190ba2b2efdSGlen Barber# add
191ba2b2efdSGlen Barber#	-DSTD_INSPIRED
192ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  This arranges for the functions
193ba2b2efdSGlen Barber# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
194ba2b2efdSGlen Barber# "posix2time", and "time2posix" to be added to the time conversion library.
195ba2b2efdSGlen Barber# "tzsetwall" is like "tzset" except that it arranges for local wall clock
196ba2b2efdSGlen Barber# time (rather than the time specified in the TZ environment variable)
197ba2b2efdSGlen Barber# to be used.
198ba2b2efdSGlen Barber# "offtime" is like "gmtime" except that it accepts a second (long) argument
199ba2b2efdSGlen Barber# that gives an offset to add to the time_t when converting it.
200ba2b2efdSGlen Barber# "timelocal" is equivalent to "mktime".
201ba2b2efdSGlen Barber# "timegm" is like "timelocal" except that it turns a struct tm into
202ba2b2efdSGlen Barber# a time_t using UT (rather than local time as "timelocal" does).
203ba2b2efdSGlen Barber# "timeoff" is like "timegm" except that it accepts a second (long) argument
204ba2b2efdSGlen Barber# that gives an offset to use when converting to a time_t.
205ba2b2efdSGlen Barber# "posix2time" and "time2posix" are described in an included manual page.
206ba2b2efdSGlen Barber# X3J11's work does not describe any of these functions.
207ba2b2efdSGlen Barber# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
208ba2b2efdSGlen Barber# These functions may well disappear in future releases of the time
209ba2b2efdSGlen Barber# conversion package.
210ba2b2efdSGlen Barber#
211ba2b2efdSGlen Barber# If you don't want functions that were inspired by NetBSD, add
212ba2b2efdSGlen Barber#	-DNETBSD_INSPIRED=0
213ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  Otherwise, the functions
214ba2b2efdSGlen Barber# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
215ba2b2efdSGlen Barber# time library, and if STD_INSPIRED is also defined the functions
216ba2b2efdSGlen Barber# "posix2time_z" and "time2posix_z" are added as well.
217ba2b2efdSGlen Barber# The functions ending in "_z" (or "_rz") are like their unsuffixed
218ba2b2efdSGlen Barber# (or suffixed-by-"_r") counterparts, except with an extra first
219ba2b2efdSGlen Barber# argument of opaque type timezone_t that specifies the time zone.
220ba2b2efdSGlen Barber# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
221ba2b2efdSGlen Barber#
222ba2b2efdSGlen Barber# If you want to allocate state structures in localtime, add
223ba2b2efdSGlen Barber#	-DALL_STATE
224ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
225ba2b2efdSGlen Barber#
226ba2b2efdSGlen Barber# If you want an "altzone" variable (a la System V Release 3.1), add
227ba2b2efdSGlen Barber#	-DALTZONE
228ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.
229ba2b2efdSGlen Barber# This variable is not described in X3J11's work.
230ba2b2efdSGlen Barber#
231ba2b2efdSGlen Barber# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
232ba2b2efdSGlen Barber# out by the National Institute of Standards and Technology
233ba2b2efdSGlen Barber# which claims to test C and Posix conformance.  If you want to pass PCTS, add
234ba2b2efdSGlen Barber#	-DPCTS
235ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.
236ba2b2efdSGlen Barber#
237ba2b2efdSGlen Barber# If you want strict compliance with XPG4 as of 1994-04-09, add
238ba2b2efdSGlen Barber#	-DXPG4_1994_04_09
239ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
240ba2b2efdSGlen Barber# 53 as a week number (rather than 52 or 53) for those days in January that
241ba2b2efdSGlen Barber# before the first Monday in January when a "%V" format is used and January 1
242ba2b2efdSGlen Barber# falls on a Friday, Saturday, or Sunday.
243ba2b2efdSGlen Barber
244ba2b2efdSGlen BarberCFLAGS=
245ba2b2efdSGlen Barber
246ba2b2efdSGlen Barber# Linker flags.  Default to $(LFLAGS) for backwards compatibility
247ba2b2efdSGlen Barber# to release 2012h and earlier.
248ba2b2efdSGlen Barber
249ba2b2efdSGlen BarberLDFLAGS=	$(LFLAGS)
250ba2b2efdSGlen Barber
251ba2b2efdSGlen Barber# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
252ba2b2efdSGlen Barber# submake command lines.  The default is no leap seconds.
253ba2b2efdSGlen Barber
254ba2b2efdSGlen BarberLEAPSECONDS=
255ba2b2efdSGlen Barber
256ba2b2efdSGlen Barber# The zic command and its arguments.
257ba2b2efdSGlen Barber
258ba2b2efdSGlen Barberzic=		./zic
259ba2b2efdSGlen BarberZIC=		$(zic) $(ZFLAGS)
260ba2b2efdSGlen Barber
261ba2b2efdSGlen BarberZFLAGS=
262ba2b2efdSGlen Barber
263ba2b2efdSGlen Barber# How to use zic to install tz binary files.
264ba2b2efdSGlen Barber
265ba2b2efdSGlen BarberZIC_INSTALL=	$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) $(LEAPSECONDS)
266ba2b2efdSGlen Barber
267ba2b2efdSGlen Barber# The name of a Posix-compliant 'awk' on your system.
268ba2b2efdSGlen BarberAWK=		awk
269ba2b2efdSGlen Barber
270ba2b2efdSGlen Barber# The full path name of a Posix-compliant shell, preferably one that supports
271ba2b2efdSGlen Barber# the Korn shell's 'select' statement as an extension.
272ba2b2efdSGlen Barber# These days, Bash is the most popular.
273ba2b2efdSGlen Barber# It should be OK to set this to /bin/sh, on platforms where /bin/sh
274ba2b2efdSGlen Barber# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
275ba2b2efdSGlen Barber# is typically nicer if it works.
276ba2b2efdSGlen BarberKSHELL=		/bin/bash
277ba2b2efdSGlen Barber
278ba2b2efdSGlen Barber# The path where SGML DTDs are kept and the catalog file(s) to use when
279ba2b2efdSGlen Barber# validating.  The default should work on both Debian and Red Hat.
280ba2b2efdSGlen BarberSGML_TOPDIR= /usr
281ba2b2efdSGlen BarberSGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd
282ba2b2efdSGlen BarberSGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224
283ba2b2efdSGlen BarberSGML_CATALOG_FILES= \
284ba2b2efdSGlen Barber  $(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
285ba2b2efdSGlen Barber
286ba2b2efdSGlen Barber# The name, arguments and environment of a program to validate your web pages.
287ba2b2efdSGlen Barber# See <http://openjade.sourceforge.net/doc/> for a validator, and
288ba2b2efdSGlen Barber# <https://validator.w3.org/source/> for a validation library.
289ba2b2efdSGlen BarberVALIDATE = nsgmls
290ba2b2efdSGlen BarberVALIDATE_FLAGS = -s -B -wall -wno-unused-param
291ba2b2efdSGlen BarberVALIDATE_ENV = \
292ba2b2efdSGlen Barber  SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) \
293ba2b2efdSGlen Barber  SGML_SEARCH_PATH=$(SGML_SEARCH_PATH) \
294ba2b2efdSGlen Barber  SP_CHARSET_FIXED=YES \
295ba2b2efdSGlen Barber  SP_ENCODING=UTF-8
296ba2b2efdSGlen Barber
297ba2b2efdSGlen Barber# This expensive test requires USE_LTZ.
298ba2b2efdSGlen Barber# To suppress it, define this macro to be empty.
299ba2b2efdSGlen BarberCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
300ba2b2efdSGlen Barber
301ba2b2efdSGlen Barber# SAFE_CHAR is a regular expression that matches a safe character.
302ba2b2efdSGlen Barber# Some parts of this distribution are limited to safe characters;
303ba2b2efdSGlen Barber# others can use any UTF-8 character.
304ba2b2efdSGlen Barber# For now, the safe characters are a safe subset of ASCII.
305ba2b2efdSGlen Barber# The caller must set the shell variable 'sharp' to the character '#',
306ba2b2efdSGlen Barber# since Makefile macros cannot contain '#'.
307ba2b2efdSGlen Barber# TAB_CHAR is a single tab character, in single quotes.
308ba2b2efdSGlen BarberTAB_CHAR=	'	'
309ba2b2efdSGlen BarberSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
310ba2b2efdSGlen BarberSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
311ba2b2efdSGlen BarberSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
312ba2b2efdSGlen BarberSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
313ba2b2efdSGlen BarberSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
314ba2b2efdSGlen Barber
315ba2b2efdSGlen Barber# OK_CHAR matches any character allowed in the distributed files.
316ba2b2efdSGlen Barber# This is the same as SAFE_CHAR, except that multibyte letters are
317ba2b2efdSGlen Barber# also allowed so that commentary can contain people's names and quote
318ba2b2efdSGlen Barber# non-English sources.  For non-letters the sources are limited to
319ba2b2efdSGlen Barber# ASCII renderings for the convenience of maintainers whose text editors
320ba2b2efdSGlen Barber# mishandle UTF-8 by default (e.g., XEmacs 21.4.22).
321ba2b2efdSGlen BarberOK_CHAR=	'[][:alpha:]'$(SAFE_CHARSET)'-]'
322ba2b2efdSGlen Barber
323ba2b2efdSGlen Barber# SAFE_LINE matches a line of safe characters.
324ba2b2efdSGlen Barber# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
325ba2b2efdSGlen Barber# this is so that comments can contain non-ASCII characters.
326ba2b2efdSGlen Barber# OK_LINE matches a line of OK characters.
327ba2b2efdSGlen BarberSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
328ba2b2efdSGlen BarberSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
329ba2b2efdSGlen BarberOK_LINE=	'^'$(OK_CHAR)'*$$'
330ba2b2efdSGlen Barber
331ba2b2efdSGlen Barber# Flags to give 'tar' when making a distribution.
332ba2b2efdSGlen Barber# Try to use flags appropriate for GNU tar.
333ba2b2efdSGlen BarberGNUTARFLAGS= --numeric-owner --owner=0 --group=0 --mode=go+u,go-w --sort=name
334ba2b2efdSGlen BarberTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
335ba2b2efdSGlen Barber		 then echo $(GNUTARFLAGS); \
336ba2b2efdSGlen Barber		 else :; \
337ba2b2efdSGlen Barber		 fi`
338ba2b2efdSGlen Barber
339ba2b2efdSGlen Barber# Flags to give 'gzip' when making a distribution.
340ba2b2efdSGlen BarberGZIPFLAGS=	-9n
341ba2b2efdSGlen Barber
342ba2b2efdSGlen Barber###############################################################################
343ba2b2efdSGlen Barber
344ba2b2efdSGlen Barber#MAKE=		make
345ba2b2efdSGlen Barber
346ba2b2efdSGlen Barbercc=		cc
347ba2b2efdSGlen BarberCC=		$(cc) -DTZDIR=\"$(TZDIR)\"
348ba2b2efdSGlen Barber
349ba2b2efdSGlen BarberAR=		ar
350ba2b2efdSGlen Barber
351ba2b2efdSGlen Barber# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
352ba2b2efdSGlen BarberRANLIB=		:
353ba2b2efdSGlen Barber
354ba2b2efdSGlen BarberTZCOBJS=	zic.o
355ba2b2efdSGlen BarberTZDOBJS=	zdump.o localtime.o asctime.o
356ba2b2efdSGlen BarberDATEOBJS=	date.o localtime.o strftime.o asctime.o
357ba2b2efdSGlen BarberLIBSRCS=	localtime.c asctime.c difftime.c
358ba2b2efdSGlen BarberLIBOBJS=	localtime.o asctime.o difftime.o
359ba2b2efdSGlen BarberHEADERS=	tzfile.h private.h
360ba2b2efdSGlen BarberNONLIBSRCS=	zic.c zdump.c
361ba2b2efdSGlen BarberNEWUCBSRCS=	date.c strftime.c
362ba2b2efdSGlen BarberSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
363ba2b2efdSGlen Barber			tzselect.ksh workman.sh
364ba2b2efdSGlen BarberMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
365ba2b2efdSGlen Barber			tzfile.5 tzselect.8 zic.8 zdump.8
366ba2b2efdSGlen BarberMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
367ba2b2efdSGlen Barber			time2posix.3.txt \
368ba2b2efdSGlen Barber			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
369ba2b2efdSGlen Barber			date.1.txt
370ba2b2efdSGlen BarberCOMMON=		CONTRIBUTING LICENSE Makefile NEWS README Theory version
371ba2b2efdSGlen BarberWEB_PAGES=	tz-art.htm tz-how-to.html tz-link.htm
372ba2b2efdSGlen BarberDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
373ba2b2efdSGlen BarberPRIMARY_YDATA=	africa antarctica asia australasia \
374ba2b2efdSGlen Barber		europe northamerica southamerica
375ba2b2efdSGlen BarberYDATA=		$(PRIMARY_YDATA) pacificnew etcetera backward
376ba2b2efdSGlen BarberNDATA=		systemv factory
377ba2b2efdSGlen BarberTDATA=		$(YDATA) $(NDATA)
378ba2b2efdSGlen BarberZONETABLES=	zone1970.tab zone.tab
379ba2b2efdSGlen BarberTABDATA=	iso3166.tab leapseconds $(ZONETABLES)
380ba2b2efdSGlen BarberLEAP_DEPS=	leapseconds.awk leap-seconds.list
381ba2b2efdSGlen BarberDATA=		$(YDATA) $(NDATA) backzone $(TABDATA) \
382ba2b2efdSGlen Barber			leap-seconds.list yearistype.sh
383ba2b2efdSGlen BarberAWK_SCRIPTS=	checklinks.awk checktab.awk leapseconds.awk
384ba2b2efdSGlen BarberMISC=		$(AWK_SCRIPTS) zoneinfo2tdf.pl
385ba2b2efdSGlen BarberTZS_YEAR=	2050
386ba2b2efdSGlen BarberTZS=		to$(TZS_YEAR).tzs
387ba2b2efdSGlen BarberTZS_NEW=	to$(TZS_YEAR)new.tzs
388ba2b2efdSGlen BarberTZS_DEPS=	$(PRIMARY_YDATA) asctime.c localtime.c \
389ba2b2efdSGlen Barber			private.h tzfile.h zdump.c zic.c
390ba2b2efdSGlen BarberENCHILADA=	$(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS)
391ba2b2efdSGlen Barber
392ba2b2efdSGlen Barber# Consult these files when deciding whether to rebuild the 'version' file.
393ba2b2efdSGlen Barber# This list is not the same as the output of 'git ls-files', since
394ba2b2efdSGlen Barber# .gitignore is not distributed.
395ba2b2efdSGlen BarberVERSION_DEPS= \
396ba2b2efdSGlen Barber		CONTRIBUTING LICENSE Makefile NEWS README Theory \
397ba2b2efdSGlen Barber		africa antarctica asctime.c asia australasia \
398ba2b2efdSGlen Barber		backward backzone \
399ba2b2efdSGlen Barber		checklinks.awk checktab.awk \
400ba2b2efdSGlen Barber		date.1 date.c difftime.c \
401ba2b2efdSGlen Barber		etcetera europe factory iso3166.tab \
402ba2b2efdSGlen Barber		leap-seconds.list leapseconds.awk localtime.c \
403ba2b2efdSGlen Barber		newctime.3 newstrftime.3 newtzset.3 northamerica \
404ba2b2efdSGlen Barber		pacificnew private.h \
405ba2b2efdSGlen Barber		southamerica strftime.c systemv \
406ba2b2efdSGlen Barber		time2posix.3 tz-art.htm tz-how-to.html tz-link.htm \
407ba2b2efdSGlen Barber		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
408ba2b2efdSGlen Barber		workman.sh yearistype.sh \
409ba2b2efdSGlen Barber		zdump.8 zdump.c zic.8 zic.c \
410ba2b2efdSGlen Barber		zone.tab zone1970.tab zoneinfo2tdf.pl
411ba2b2efdSGlen Barber
412ba2b2efdSGlen Barber# And for the benefit of csh users on systems that assume the user
413ba2b2efdSGlen Barber# shell should be used to handle commands in Makefiles. . .
414ba2b2efdSGlen Barber
415ba2b2efdSGlen BarberSHELL=		/bin/sh
416ba2b2efdSGlen Barber
417ba2b2efdSGlen Barberall:		tzselect yearistype zic zdump libtz.a $(TABDATA)
418ba2b2efdSGlen Barber
419ba2b2efdSGlen BarberALL:		all date $(ENCHILADA)
420ba2b2efdSGlen Barber
421ba2b2efdSGlen Barberinstall:	all $(DATA) $(REDO) $(MANS)
422ba2b2efdSGlen Barber		mkdir -p $(DESTDIR)$(ETCDIR) $(DESTDIR)$(TZDIR) \
423ba2b2efdSGlen Barber			$(DESTDIR)$(LIBDIR) \
424ba2b2efdSGlen Barber			$(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \
425ba2b2efdSGlen Barber			$(DESTDIR)$(MANDIR)/man8
426ba2b2efdSGlen Barber		$(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES)
427ba2b2efdSGlen Barber		cp -f iso3166.tab $(ZONETABLES) $(DESTDIR)$(TZDIR)/.
428ba2b2efdSGlen Barber		cp tzselect zic zdump $(DESTDIR)$(ETCDIR)/.
429ba2b2efdSGlen Barber		cp libtz.a $(DESTDIR)$(LIBDIR)/.
430ba2b2efdSGlen Barber		$(RANLIB) $(DESTDIR)$(LIBDIR)/libtz.a
431ba2b2efdSGlen Barber		cp -f newctime.3 newtzset.3 $(DESTDIR)$(MANDIR)/man3/.
432ba2b2efdSGlen Barber		cp -f tzfile.5 $(DESTDIR)$(MANDIR)/man5/.
433ba2b2efdSGlen Barber		cp -f tzselect.8 zdump.8 zic.8 $(DESTDIR)$(MANDIR)/man8/.
434ba2b2efdSGlen Barber
435ba2b2efdSGlen BarberINSTALL:	ALL install date.1
436ba2b2efdSGlen Barber		mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1
437ba2b2efdSGlen Barber		cp date $(DESTDIR)$(BINDIR)/.
438ba2b2efdSGlen Barber		cp -f date.1 $(DESTDIR)$(MANDIR)/man1/.
439ba2b2efdSGlen Barber
440ba2b2efdSGlen Barberversion:	$(VERSION_DEPS)
441ba2b2efdSGlen Barber		{ (type git) >/dev/null 2>&1 && \
442ba2b2efdSGlen Barber		  V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
443ba2b2efdSGlen Barber				--abbrev=7 --dirty` || \
444ba2b2efdSGlen Barber		  V=$(VERSION); } && \
445ba2b2efdSGlen Barber		printf '%s\n' "$$V" >$@.out
446ba2b2efdSGlen Barber		mv $@.out $@
447ba2b2efdSGlen Barber
448ba2b2efdSGlen Barberversion.h:	version
449ba2b2efdSGlen Barber		VERSION=`cat version` && printf '%s\n' \
450ba2b2efdSGlen Barber		  'static char const PKGVERSION[]="($(PACKAGE)) ";' \
451ba2b2efdSGlen Barber		  "static char const TZVERSION[]=\"$$VERSION\";" \
452ba2b2efdSGlen Barber		  'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
453ba2b2efdSGlen Barber		  >$@.out
454ba2b2efdSGlen Barber		mv $@.out $@
455ba2b2efdSGlen Barber
456ba2b2efdSGlen Barberzdump:		$(TZDOBJS)
457ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
458ba2b2efdSGlen Barber
459ba2b2efdSGlen Barberzic:		$(TZCOBJS)
460ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
461ba2b2efdSGlen Barber
462ba2b2efdSGlen Barberyearistype:	yearistype.sh
463ba2b2efdSGlen Barber		cp yearistype.sh yearistype
464ba2b2efdSGlen Barber		chmod +x yearistype
465ba2b2efdSGlen Barber
466ba2b2efdSGlen Barberleapseconds:	$(LEAP_DEPS)
467ba2b2efdSGlen Barber		$(AWK) -f leapseconds.awk leap-seconds.list >$@.out
468ba2b2efdSGlen Barber		mv $@.out $@
469ba2b2efdSGlen Barber
470ba2b2efdSGlen Barber# Arguments to pass to submakes of install_data.
471ba2b2efdSGlen Barber# They can be overridden by later submake arguments.
472ba2b2efdSGlen BarberINSTALLARGS = \
473ba2b2efdSGlen Barber DESTDIR=$(DESTDIR) \
474ba2b2efdSGlen Barber LEAPSECONDS='$(LEAPSECONDS)' \
475ba2b2efdSGlen Barber PACKRATDATA='$(PACKRATDATA)' \
476ba2b2efdSGlen Barber TZDIR=$(TZDIR) \
477ba2b2efdSGlen Barber YEARISTYPE=$(YEARISTYPE) \
478ba2b2efdSGlen Barber ZIC='$(ZIC)'
479ba2b2efdSGlen Barber
480ba2b2efdSGlen Barber# 'make install_data' installs one set of tz binary files.
481ba2b2efdSGlen Barber# It can be tailored by setting LEAPSECONDS, PACKRATDATA, etc.
482ba2b2efdSGlen Barberinstall_data:	zic leapseconds yearistype $(PACKRATDATA) $(TDATA)
483ba2b2efdSGlen Barber		$(ZIC_INSTALL) $(TDATA)
484ba2b2efdSGlen Barber		$(AWK) '/^Rule/' $(TDATA) | $(ZIC_INSTALL) - $(PACKRATDATA)
485ba2b2efdSGlen Barber
486ba2b2efdSGlen Barberposix_only:
487ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
488ba2b2efdSGlen Barber
489ba2b2efdSGlen Barberright_only:
490ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
491ba2b2efdSGlen Barber			install_data
492ba2b2efdSGlen Barber
493ba2b2efdSGlen Barber# In earlier versions of this makefile, the other two directories were
494ba2b2efdSGlen Barber# subdirectories of $(TZDIR).  However, this led to configuration errors.
495ba2b2efdSGlen Barber# For example, with posix_right under the earlier scheme,
496ba2b2efdSGlen Barber# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
497ba2b2efdSGlen Barber# but gmtime without leap seconds, which led to problems with applications
498ba2b2efdSGlen Barber# like sendmail that subtract gmtime from localtime.
499ba2b2efdSGlen Barber# Therefore, the other two directories are now siblings of $(TZDIR).
500ba2b2efdSGlen Barber# You must replace all of $(TZDIR) to switch from not using leap seconds
501ba2b2efdSGlen Barber# to using them, or vice versa.
502ba2b2efdSGlen Barberright_posix:	right_only
503ba2b2efdSGlen Barber		rm -fr $(DESTDIR)$(TZDIR)-leaps
504ba2b2efdSGlen Barber		ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-leaps || \
505ba2b2efdSGlen Barber		  $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-leaps right_only
506ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-posix posix_only
507ba2b2efdSGlen Barber
508ba2b2efdSGlen Barberposix_right:	posix_only
509ba2b2efdSGlen Barber		rm -fr $(DESTDIR)$(TZDIR)-posix
510ba2b2efdSGlen Barber		ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-posix || \
511ba2b2efdSGlen Barber		  $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-posix posix_only
512ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-leaps right_only
513ba2b2efdSGlen Barber
514ba2b2efdSGlen Barber# This obsolescent rule is present for backwards compatibility with
515ba2b2efdSGlen Barber# tz releases 2014g through 2015g.  It should go away eventually.
516ba2b2efdSGlen Barberposix_packrat:
517ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) PACKRATDATA=backzone posix_only
518ba2b2efdSGlen Barber
519ba2b2efdSGlen Barberzones:		$(REDO)
520ba2b2efdSGlen Barber
521ba2b2efdSGlen Barber$(TZS_NEW):	$(TDATA) zdump zic
522ba2b2efdSGlen Barber		mkdir -p tzs.dir
523ba2b2efdSGlen Barber		$(zic) -d tzs.dir $(TDATA)
524ba2b2efdSGlen Barber		$(AWK) '/^Link/{print $$1 "\t" $$2 "\t" $$3}' \
525ba2b2efdSGlen Barber		   $(TDATA) | LC_ALL=C sort >$@.out
526ba2b2efdSGlen Barber		wd=`pwd` && \
527ba2b2efdSGlen Barber		zones=`$(AWK) -v wd="$$wd" \
528ba2b2efdSGlen Barber				'/^Zone/{print wd "/tzs.dir/" $$2}' $(TDATA) \
529ba2b2efdSGlen Barber			 | LC_ALL=C sort` && \
530ba2b2efdSGlen Barber		./zdump -i -c $(TZS_YEAR) $$zones >>$@.out
531ba2b2efdSGlen Barber		sed 's,^TZ=".*tzs\.dir/,TZ=",' $@.out >$@.sed.out
532ba2b2efdSGlen Barber		rm -fr tzs.dir $@.out
533ba2b2efdSGlen Barber		mv $@.sed.out $@
534ba2b2efdSGlen Barber
535ba2b2efdSGlen Barber# If $(TZS) does not already exist (e.g., old-format tarballs), create it.
536ba2b2efdSGlen Barber# If it exists but 'make check_tzs' fails, a maintainer should inspect the
537ba2b2efdSGlen Barber# failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
538ba2b2efdSGlen Barber$(TZS):
539ba2b2efdSGlen Barber		$(MAKE) force_tzs
540ba2b2efdSGlen Barber
541ba2b2efdSGlen Barberforce_tzs:	$(TZS_NEW)
542ba2b2efdSGlen Barber		cp $(TZS_NEW) $(TZS)
543ba2b2efdSGlen Barber
544ba2b2efdSGlen Barberlibtz.a:	$(LIBOBJS)
545*e350c46aSBaptiste Daroussin		rm -f $@
546*e350c46aSBaptiste Daroussin		$(AR) -rc $@ $(LIBOBJS)
547ba2b2efdSGlen Barber		$(RANLIB) $@
548ba2b2efdSGlen Barber
549ba2b2efdSGlen Barberdate:		$(DATEOBJS)
550ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
551ba2b2efdSGlen Barber
552ba2b2efdSGlen Barbertzselect:	tzselect.ksh version
553ba2b2efdSGlen Barber		VERSION=`cat version` && sed \
554ba2b2efdSGlen Barber			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
555ba2b2efdSGlen Barber			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
556ba2b2efdSGlen Barber			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
557ba2b2efdSGlen Barber			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
558ba2b2efdSGlen Barber			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
559ba2b2efdSGlen Barber			-e 's|\(TZVERSION\)=.*|\1='"$$VERSION"'|' \
560ba2b2efdSGlen Barber			<$@.ksh >$@.out
561ba2b2efdSGlen Barber		chmod +x $@.out
562ba2b2efdSGlen Barber		mv $@.out $@
563ba2b2efdSGlen Barber
564ba2b2efdSGlen Barbercheck:		check_character_set check_white_space check_links check_sorted \
565ba2b2efdSGlen Barber		  check_tables check_tzs check_web
566ba2b2efdSGlen Barber
567ba2b2efdSGlen Barbercheck_character_set: $(ENCHILADA)
568ba2b2efdSGlen Barber		LC_ALL=en_US.utf8 && export LC_ALL && \
569ba2b2efdSGlen Barber		sharp='#' && \
570ba2b2efdSGlen Barber		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
571ba2b2efdSGlen Barber			$(MISC) $(SOURCES) $(WEB_PAGES) \
572ba2b2efdSGlen Barber			CONTRIBUTING LICENSE Makefile README version && \
573ba2b2efdSGlen Barber		! grep -Env $(SAFE_SHARP_LINE) $(TDATA) backzone \
574ba2b2efdSGlen Barber			leapseconds yearistype.sh zone.tab && \
575ba2b2efdSGlen Barber		! grep -Env $(OK_LINE) $(ENCHILADA)
576ba2b2efdSGlen Barber
577ba2b2efdSGlen Barbercheck_white_space: $(ENCHILADA)
578ba2b2efdSGlen Barber		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
579ba2b2efdSGlen Barber		! grep -En "$$pat" $(ENCHILADA)
580ba2b2efdSGlen Barber		! grep -n '[[:space:]]$$' $(ENCHILADA)
581ba2b2efdSGlen Barber
582ba2b2efdSGlen BarberCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
583ba2b2efdSGlen Barber
584ba2b2efdSGlen Barbercheck_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
585ba2b2efdSGlen Barber		$(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu
586ba2b2efdSGlen Barber		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
587ba2b2efdSGlen Barber		$(AWK) '/^[^#]/ {print $$1}' iso3166.tab | LC_ALL=C sort -cu
588ba2b2efdSGlen Barber		$(AWK) '/^[^#]/ {print $$1}' zone.tab | LC_ALL=C sort -c
589ba2b2efdSGlen Barber		$(AWK) '/^[^#]/ {print substr($$0, 1, 2)}' zone1970.tab | \
590ba2b2efdSGlen Barber		  LC_ALL=C sort -c
591ba2b2efdSGlen Barber		$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
592ba2b2efdSGlen Barber		  LC_ALL=C sort -cu
593ba2b2efdSGlen Barber
594ba2b2efdSGlen Barbercheck_links:	checklinks.awk $(TDATA)
595ba2b2efdSGlen Barber		$(AWK) -f checklinks.awk $(TDATA)
596ba2b2efdSGlen Barber
597ba2b2efdSGlen Barbercheck_tables:	checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
598ba2b2efdSGlen Barber		for tab in $(ZONETABLES); do \
599ba2b2efdSGlen Barber		  $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
600ba2b2efdSGlen Barber		    || exit; \
601ba2b2efdSGlen Barber		done
602ba2b2efdSGlen Barber
603ba2b2efdSGlen Barbercheck_tzs:	$(TZS) $(TZS_NEW)
604ba2b2efdSGlen Barber		diff -u $(TZS) $(TZS_NEW)
605ba2b2efdSGlen Barber
606ba2b2efdSGlen Barbercheck_web:	$(WEB_PAGES)
607ba2b2efdSGlen Barber		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES)
608ba2b2efdSGlen Barber
609ba2b2efdSGlen Barberclean_misc:
610ba2b2efdSGlen Barber		rm -f core *.o *.out \
611ba2b2efdSGlen Barber		  date tzselect version.h zdump zic yearistype libtz.a
612ba2b2efdSGlen Barberclean:		clean_misc
613ba2b2efdSGlen Barber		rm -fr *.dir tzdb-*/ $(TZS_NEW)
614ba2b2efdSGlen Barber
615ba2b2efdSGlen Barbermaintainer-clean: clean
616ba2b2efdSGlen Barber		@echo 'This command is intended for maintainers to use; it'
617ba2b2efdSGlen Barber		@echo 'deletes files that may need special tools to rebuild.'
618ba2b2efdSGlen Barber		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
619ba2b2efdSGlen Barber
620ba2b2efdSGlen Barbernames:
621ba2b2efdSGlen Barber		@echo $(ENCHILADA)
622ba2b2efdSGlen Barber
623ba2b2efdSGlen Barberpublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
624ba2b2efdSGlen Barber		tarballs signatures
625ba2b2efdSGlen Barber
626ba2b2efdSGlen Barberdate.1.txt:	date.1
627ba2b2efdSGlen Barbernewctime.3.txt:	newctime.3
628ba2b2efdSGlen Barbernewstrftime.3.txt: newstrftime.3
629ba2b2efdSGlen Barbernewtzset.3.txt:	newtzset.3
630ba2b2efdSGlen Barbertime2posix.3.txt: time2posix.3
631ba2b2efdSGlen Barbertzfile.5.txt:	tzfile.5
632ba2b2efdSGlen Barbertzselect.8.txt:	tzselect.8
633ba2b2efdSGlen Barberzdump.8.txt:	zdump.8
634ba2b2efdSGlen Barberzic.8.txt:	zic.8
635ba2b2efdSGlen Barber
636ba2b2efdSGlen Barber$(MANTXTS):	workman.sh
637ba2b2efdSGlen Barber		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out
638ba2b2efdSGlen Barber		mv $@.out $@
639ba2b2efdSGlen Barber
640ba2b2efdSGlen Barber# Set the time stamps to those of the git repository, if available,
641ba2b2efdSGlen Barber# and if the files have not changed since then.
642ba2b2efdSGlen Barber# This uses GNU 'touch' syntax 'touch -d@N FILE',
643ba2b2efdSGlen Barber# where N is the number of seconds since 1970.
644ba2b2efdSGlen Barber# If git or GNU 'touch' is absent, don't bother to sync with git timestamps.
645ba2b2efdSGlen Barber# Also, set the timestamp of each prebuilt file like 'leapseconds'
646ba2b2efdSGlen Barber# to be the maximum of the files it depends on.
647ba2b2efdSGlen Barberset-timestamps.out: $(ENCHILADA)
648ba2b2efdSGlen Barber		rm -f $@
649ba2b2efdSGlen Barber		if (type git) >/dev/null 2>&1 && \
650ba2b2efdSGlen Barber		   files=`git ls-files $(ENCHILADA)` && \
651ba2b2efdSGlen Barber		   touch -md @1 test.out; then \
652ba2b2efdSGlen Barber		  rm -f test.out && \
653ba2b2efdSGlen Barber		  for file in $$files; do \
654ba2b2efdSGlen Barber		    if git diff --quiet $$file; then \
655ba2b2efdSGlen Barber		      time=`git log -1 --format='tformat:%ct' $$file` && \
656ba2b2efdSGlen Barber		      touch -cmd @$$time $$file; \
657ba2b2efdSGlen Barber		    else \
658ba2b2efdSGlen Barber		      echo >&2 "$$file: warning: does not match repository"; \
659ba2b2efdSGlen Barber		    fi || exit; \
660ba2b2efdSGlen Barber		  done; \
661ba2b2efdSGlen Barber		fi
662ba2b2efdSGlen Barber		touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds
663ba2b2efdSGlen Barber		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
664ba2b2efdSGlen Barber		  touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \
665ba2b2efdSGlen Barber		    exit; \
666ba2b2efdSGlen Barber		done
667ba2b2efdSGlen Barber		touch -cmr `ls -t $(TZS_DEPS) | sed 1q` $(TZS)
668ba2b2efdSGlen Barber		touch -cmr `ls -t $(VERSION_DEPS) | sed 1q` version
669ba2b2efdSGlen Barber		touch $@
670ba2b2efdSGlen Barber
671ba2b2efdSGlen Barber# The zics below ensure that each data file can stand on its own.
672ba2b2efdSGlen Barber# We also do an all-files run to catch links to links.
673ba2b2efdSGlen Barber
674ba2b2efdSGlen Barbercheck_public:
675ba2b2efdSGlen Barber		$(MAKE) maintainer-clean
676ba2b2efdSGlen Barber		$(MAKE) "CFLAGS=$(GCC_DEBUG_FLAGS)" ALL
677ba2b2efdSGlen Barber		mkdir -p public.dir
678ba2b2efdSGlen Barber		for i in $(TDATA) ; do \
679ba2b2efdSGlen Barber		  $(zic) -v -d public.dir $$i 2>&1 || exit; \
680ba2b2efdSGlen Barber		done
681ba2b2efdSGlen Barber		$(zic) -v -d public.dir $(TDATA)
682ba2b2efdSGlen Barber		rm -fr public.dir
683ba2b2efdSGlen Barber
684ba2b2efdSGlen Barber# Check that the code works under various alternative
685ba2b2efdSGlen Barber# implementations of time_t.
686ba2b2efdSGlen Barbercheck_time_t_alternatives:
687ba2b2efdSGlen Barber		if diff -q Makefile Makefile 2>/dev/null; then \
688ba2b2efdSGlen Barber		  quiet_option='-q'; \
689ba2b2efdSGlen Barber		else \
690ba2b2efdSGlen Barber		  quiet_option=''; \
691ba2b2efdSGlen Barber		fi && \
692ba2b2efdSGlen Barber		wd=`pwd` && \
693ba2b2efdSGlen Barber		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
694ba2b2efdSGlen Barber		for type in $(TIME_T_ALTERNATIVES); do \
695ba2b2efdSGlen Barber		  mkdir -p time_t.dir/$$type && \
696ba2b2efdSGlen Barber		  $(MAKE) clean_misc && \
697ba2b2efdSGlen Barber		  $(MAKE) TOPDIR="$$wd/time_t.dir/$$type" \
698ba2b2efdSGlen Barber		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
699ba2b2efdSGlen Barber		    REDO='$(REDO)' \
700ba2b2efdSGlen Barber		    install && \
701ba2b2efdSGlen Barber		  diff $$quiet_option -r \
702ba2b2efdSGlen Barber		    time_t.dir/int64_t/etc/zoneinfo \
703ba2b2efdSGlen Barber		    time_t.dir/$$type/etc/zoneinfo && \
704ba2b2efdSGlen Barber		  case $$type in \
705ba2b2efdSGlen Barber		  int32_t) range=-2147483648,2147483647;; \
706ba2b2efdSGlen Barber		  uint32_t) range=0,4294967296;; \
707ba2b2efdSGlen Barber		  int64_t) continue;; \
708ba2b2efdSGlen Barber		  *u*) range=0,10000000000;; \
709ba2b2efdSGlen Barber		  *) range=-10000000000,10000000000;; \
710ba2b2efdSGlen Barber		  esac && \
711ba2b2efdSGlen Barber		  echo checking $$type zones ... && \
712ba2b2efdSGlen Barber		  time_t.dir/int64_t/etc/zdump -V -t $$range $$zones \
713ba2b2efdSGlen Barber		      >time_t.dir/int64_t.out && \
714ba2b2efdSGlen Barber		  time_t.dir/$$type/etc/zdump -V -t $$range $$zones \
715ba2b2efdSGlen Barber		      >time_t.dir/$$type.out && \
716ba2b2efdSGlen Barber		  diff -u time_t.dir/int64_t.out time_t.dir/$$type.out \
717ba2b2efdSGlen Barber		    || exit; \
718ba2b2efdSGlen Barber		done
719ba2b2efdSGlen Barber		rm -fr time_t.dir
720ba2b2efdSGlen Barber
721ba2b2efdSGlen Barbertarballs traditional_tarballs signatures traditional_signatures: version
722ba2b2efdSGlen Barber		VERSION=`cat version` && \
723ba2b2efdSGlen Barber		$(MAKE) VERSION="$$VERSION" $@_version
724ba2b2efdSGlen Barber
725ba2b2efdSGlen Barbertarballs_version: traditional_tarballs_version tzdb-$(VERSION).tar.lz
726ba2b2efdSGlen Barbertraditional_tarballs_version: \
727ba2b2efdSGlen Barber  tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
728ba2b2efdSGlen Barbersignatures_version: traditional_signatures_version tzdb-$(VERSION).tar.lz.asc
729ba2b2efdSGlen Barbertraditional_signatures_version: \
730ba2b2efdSGlen Barber  tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc \
731ba2b2efdSGlen Barber
732ba2b2efdSGlen Barbertzcode$(VERSION).tar.gz: set-timestamps.out
733ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
734ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - \
735ba2b2efdSGlen Barber		    $(COMMON) $(DOCS) $(SOURCES) | \
736ba2b2efdSGlen Barber		  gzip $(GZIPFLAGS) >$@.out
737ba2b2efdSGlen Barber		mv $@.out $@
738ba2b2efdSGlen Barber
739ba2b2efdSGlen Barbertzdata$(VERSION).tar.gz: set-timestamps.out
740ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
741ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
742ba2b2efdSGlen Barber		  gzip $(GZIPFLAGS) >$@.out
743ba2b2efdSGlen Barber		mv $@.out $@
744ba2b2efdSGlen Barber
745ba2b2efdSGlen Barbertzdb-$(VERSION).tar.lz: set-timestamps.out
746ba2b2efdSGlen Barber		rm -fr tzdb-$(VERSION)
747ba2b2efdSGlen Barber		mkdir tzdb-$(VERSION)
748ba2b2efdSGlen Barber		ln $(ENCHILADA) tzdb-$(VERSION)
749ba2b2efdSGlen Barber		touch -cmr `ls -t tzdb-$(VERSION)/* | sed 1q` tzdb-$(VERSION)
750ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
751ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out
752ba2b2efdSGlen Barber		mv $@.out $@
753ba2b2efdSGlen Barber
754ba2b2efdSGlen Barbertzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
755ba2b2efdSGlen Barber		gpg --armor --detach-sign $?
756ba2b2efdSGlen Barber
757ba2b2efdSGlen Barbertzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
758ba2b2efdSGlen Barber		gpg --armor --detach-sign $?
759ba2b2efdSGlen Barber
760ba2b2efdSGlen Barbertzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
761ba2b2efdSGlen Barber		gpg --armor --detach-sign $?
762ba2b2efdSGlen Barber
763ba2b2efdSGlen Barbertypecheck:
764ba2b2efdSGlen Barber		$(MAKE) clean
765ba2b2efdSGlen Barber		for i in "long long" unsigned; \
766ba2b2efdSGlen Barber		do \
767ba2b2efdSGlen Barber			$(MAKE) CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
768ba2b2efdSGlen Barber			./zdump -v Europe/Rome ; \
769ba2b2efdSGlen Barber			$(MAKE) clean ; \
770ba2b2efdSGlen Barber		done
771ba2b2efdSGlen Barber
772ba2b2efdSGlen Barberzonenames:	$(TDATA)
773ba2b2efdSGlen Barber		@$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
774ba2b2efdSGlen Barber
775ba2b2efdSGlen Barberasctime.o:	private.h tzfile.h
776ba2b2efdSGlen Barberdate.o:		private.h
777ba2b2efdSGlen Barberdifftime.o:	private.h
778ba2b2efdSGlen Barberlocaltime.o:	private.h tzfile.h
779ba2b2efdSGlen Barberstrftime.o:	private.h tzfile.h
780ba2b2efdSGlen Barberzdump.o:	version.h
781ba2b2efdSGlen Barberzic.o:		private.h tzfile.h version.h
782ba2b2efdSGlen Barber
783ba2b2efdSGlen Barber.KEEP_STATE:
784ba2b2efdSGlen Barber
785ba2b2efdSGlen Barber.PHONY: ALL INSTALL all
786ba2b2efdSGlen Barber.PHONY: check check_character_set check_links
787ba2b2efdSGlen Barber.PHONY: check_public check_sorted check_tables
788ba2b2efdSGlen Barber.PHONY: check_time_t_alternatives check_tzs check_web check_white_space
789ba2b2efdSGlen Barber.PHONY: clean clean_misc force_tzs
790ba2b2efdSGlen Barber.PHONY: install install_data maintainer-clean names
791ba2b2efdSGlen Barber.PHONY: posix_only posix_packrat posix_right
792ba2b2efdSGlen Barber.PHONY: public right_only right_posix signatures signatures_version
793ba2b2efdSGlen Barber.PHONY: tarballs tarballs_version typecheck
794ba2b2efdSGlen Barber.PHONY: zonenames zones
795