xref: /freebsd/contrib/tzdata/Makefile (revision 2c5e84cc266a4058d8aa28891756d823e5c43961)
189abb9f8SPhilip Paeps# Make and install tzdb code and data.
289abb9f8SPhilip Paeps
3ba2b2efdSGlen Barber# This file is in the public domain, so clarified as of
4ba2b2efdSGlen Barber# 2009-05-17 by Arthur David Olson.
5ba2b2efdSGlen Barber
6ba2b2efdSGlen Barber# Package name for the code distribution.
7ba2b2efdSGlen BarberPACKAGE=	tzcode
8ba2b2efdSGlen Barber
9ba2b2efdSGlen Barber# Version number for the distribution, overridden in the 'tarballs' rule below.
10ba2b2efdSGlen BarberVERSION=	unknown
11ba2b2efdSGlen Barber
12ba2b2efdSGlen Barber# Email address for bug reports.
13ba2b2efdSGlen BarberBUGEMAIL=	tz@iana.org
14ba2b2efdSGlen Barber
1546bee4edSPhilip Paeps# Choose source data features.  To get new features right away, use:
1646bee4edSPhilip Paeps#	DATAFORM=	vanguard
1746bee4edSPhilip Paeps# To wait a while before using new features, to give downstream users
1846bee4edSPhilip Paeps# time to upgrade zic (the default), use:
1946bee4edSPhilip Paeps#	DATAFORM=	main
2046bee4edSPhilip Paeps# To wait even longer for new features, use:
2146bee4edSPhilip Paeps#	DATAFORM=	rearguard
2246bee4edSPhilip PaepsDATAFORM=		main
2346bee4edSPhilip Paeps
2489abb9f8SPhilip Paeps# Change the line below for your timezone (after finding the one you want in
2589abb9f8SPhilip Paeps# one of the $(TDATA) source files, or adding it to a source file).
26d81c2dd9SPhilip Paeps# Alternatively, if you discover you've got the wrong timezone, you can just
27ba2b2efdSGlen Barber#	zic -l rightzone
28ba2b2efdSGlen Barber# to correct things.
29ba2b2efdSGlen Barber# Use the command
30ba2b2efdSGlen Barber#	make zonenames
31ba2b2efdSGlen Barber# to get a list of the values you can use for LOCALTIME.
32ba2b2efdSGlen Barber
33ba2b2efdSGlen BarberLOCALTIME=	GMT
34ba2b2efdSGlen Barber
35ba2b2efdSGlen Barber# If you want something other than Eastern United States time as a template
36ba2b2efdSGlen Barber# for handling POSIX-style timezone environment variables,
3789abb9f8SPhilip Paeps# change the line below (after finding the timezone you want in the
3889abb9f8SPhilip Paeps# one of the $(TDATA) source files, or adding it to a source file).
3946bee4edSPhilip Paeps# When a POSIX-style environment variable is handled, the rules in the
40ba2b2efdSGlen Barber# template file are used to determine "spring forward" and "fall back" days and
41ba2b2efdSGlen Barber# times; the environment variable itself specifies UT offsets of standard and
4246bee4edSPhilip Paeps# daylight saving time.
43d81c2dd9SPhilip Paeps# Alternatively, if you discover you've got the wrong timezone, you can just
44ba2b2efdSGlen Barber#	zic -p rightzone
45ba2b2efdSGlen Barber# to correct things.
46ba2b2efdSGlen Barber# Use the command
47ba2b2efdSGlen Barber#	make zonenames
48ba2b2efdSGlen Barber# to get a list of the values you can use for POSIXRULES.
49ba2b2efdSGlen Barber# If you want POSIX compatibility, use "America/New_York".
50ba2b2efdSGlen Barber
51ba2b2efdSGlen BarberPOSIXRULES=	America/New_York
52ba2b2efdSGlen Barber
53ba2b2efdSGlen Barber# Also see TZDEFRULESTRING below, which takes effect only
54ba2b2efdSGlen Barber# if the time zone files cannot be accessed.
55ba2b2efdSGlen Barber
56ba2b2efdSGlen Barber
57f2fcff28SPhilip Paeps# Installation locations.
58f2fcff28SPhilip Paeps#
59f2fcff28SPhilip Paeps# The defaults are suitable for Debian, except that if REDO is
60f2fcff28SPhilip Paeps# posix_right or right_posix then files that Debian puts under
61f2fcff28SPhilip Paeps# /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
62f2fcff28SPhilip Paeps# put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
63f2fcff28SPhilip Paeps# respectively.  Problems with the Debian approach are discussed in
64f2fcff28SPhilip Paeps# the commentary for the right_posix rule (below).
65f2fcff28SPhilip Paeps
66f2fcff28SPhilip Paeps# Destination directory, which can be used for staging.
67f2fcff28SPhilip Paeps# 'make DESTDIR=/stage install' installs under /stage (e.g., to
68f2fcff28SPhilip Paeps# /stage/etc/localtime instead of to /etc/localtime).  Files under
69f2fcff28SPhilip Paeps# /stage are not intended to work as-is, but can be copied by hand to
70f2fcff28SPhilip Paeps# the root directory later.  If DESTDIR is empty, 'make install' does
71f2fcff28SPhilip Paeps# not stage, but installs directly into production locations.
72f2fcff28SPhilip PaepsDESTDIR =
73f2fcff28SPhilip Paeps
74f2fcff28SPhilip Paeps# Everything is installed into subdirectories of TOPDIR, and used there.
75f2fcff28SPhilip Paeps# TOPDIR should be empty (meaning the root directory),
76f2fcff28SPhilip Paeps# or a directory name that does not end in "/".
77f2fcff28SPhilip Paeps# TOPDIR should be empty or an absolute name unless you're just testing.
78f2fcff28SPhilip PaepsTOPDIR =
79f2fcff28SPhilip Paeps
80f2fcff28SPhilip Paeps# The default local timezone is taken from the file TZDEFAULT.
81f2fcff28SPhilip PaepsTZDEFAULT = $(TOPDIR)/etc/localtime
82f2fcff28SPhilip Paeps
83f2fcff28SPhilip Paeps# The subdirectory containing installed program and data files, and
84f2fcff28SPhilip Paeps# likewise for installed files that can be shared among architectures.
85f2fcff28SPhilip Paeps# These should be relative file names.
86f2fcff28SPhilip PaepsUSRDIR = usr
87f2fcff28SPhilip PaepsUSRSHAREDIR = $(USRDIR)/share
88ba2b2efdSGlen Barber
89ba2b2efdSGlen Barber# "Compiled" timezone information is placed in the "TZDIR" directory
90ba2b2efdSGlen Barber# (and subdirectories).
918d7edd17SPhilip Paeps# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
92ba2b2efdSGlen BarberTZDIR_BASENAME=	zoneinfo
93f2fcff28SPhilip PaepsTZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
94f2fcff28SPhilip Paeps
95f2fcff28SPhilip Paeps# The "tzselect" and (if you do "make INSTALL") "date" commands go in:
96f2fcff28SPhilip PaepsBINDIR = $(TOPDIR)/$(USRDIR)/bin
97f2fcff28SPhilip Paeps
98f2fcff28SPhilip Paeps# The "zdump" command goes in:
99f2fcff28SPhilip PaepsZDUMPDIR = $(BINDIR)
100f2fcff28SPhilip Paeps
101f2fcff28SPhilip Paeps# The "zic" command goes in:
102f2fcff28SPhilip PaepsZICDIR = $(TOPDIR)/$(USRDIR)/sbin
103f2fcff28SPhilip Paeps
104f2fcff28SPhilip Paeps# Manual pages go in subdirectories of. . .
105f2fcff28SPhilip PaepsMANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
106f2fcff28SPhilip Paeps
107f2fcff28SPhilip Paeps# Library functions are put in an archive in LIBDIR.
108f2fcff28SPhilip PaepsLIBDIR = $(TOPDIR)/$(USRDIR)/lib
109f2fcff28SPhilip Paeps
110ba2b2efdSGlen Barber
11189abb9f8SPhilip Paeps# Types to try, as an alternative to time_t.
11289abb9f8SPhilip PaepsTIME_T_ALTERNATIVES = $(TIME_T_ALTERNATIVES_HEAD) $(TIME_T_ALTERNATIVES_TAIL)
11389abb9f8SPhilip PaepsTIME_T_ALTERNATIVES_HEAD = int64_t
11489abb9f8SPhilip PaepsTIME_T_ALTERNATIVES_TAIL = int32_t uint32_t uint64_t
115ba2b2efdSGlen Barber
11689abb9f8SPhilip Paeps# What kind of TZif data files to generate.
11789abb9f8SPhilip Paeps# (TZif is the binary time zone data format that zic generates.)
118dc135c6eSBaptiste Daroussin# If you want only POSIX time, with time values interpreted as
119dc135c6eSBaptiste Daroussin# seconds since the epoch (not counting leap seconds), use
120ba2b2efdSGlen Barber#	REDO=		posix_only
1218d7edd17SPhilip Paeps# below.  If you want only "right" time, with values interpreted
122dc135c6eSBaptiste Daroussin# as seconds since the epoch (counting leap seconds), use
123ba2b2efdSGlen Barber#	REDO=		right_only
124ba2b2efdSGlen Barber# below.  If you want both sets of data available, with leap seconds not
125ba2b2efdSGlen Barber# counted normally, use
126ba2b2efdSGlen Barber#	REDO=		posix_right
127ba2b2efdSGlen Barber# below.  If you want both sets of data available, with leap seconds counted
128ba2b2efdSGlen Barber# normally, use
129ba2b2efdSGlen Barber#	REDO=		right_posix
130ba2b2efdSGlen Barber# below.  POSIX mandates that leap seconds not be counted; for compatibility
131dc135c6eSBaptiste Daroussin# with it, use "posix_only" or "posix_right".  Use POSIX time on systems with
132dc135c6eSBaptiste Daroussin# leap smearing; this can work better than unsmeared "right" time with
133dc135c6eSBaptiste Daroussin# applications that are not leap second aware, and is closer to unsmeared
134dc135c6eSBaptiste Daroussin# "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
135ba2b2efdSGlen Barber
136ba2b2efdSGlen BarberREDO=		posix_right
137ba2b2efdSGlen Barber
13889abb9f8SPhilip Paeps# To install data in text form that has all the information of the TZif data,
1398d7edd17SPhilip Paeps# (optionally incorporating leap second information), use
1408d7edd17SPhilip Paeps#	TZDATA_TEXT=	tzdata.zi leapseconds
1418d7edd17SPhilip Paeps# To install text data without leap second information (e.g., because
1428d7edd17SPhilip Paeps# REDO='posix_only'), use
1438d7edd17SPhilip Paeps#	TZDATA_TEXT=	tzdata.zi
1448d7edd17SPhilip Paeps# To avoid installing text data, use
1458d7edd17SPhilip Paeps#	TZDATA_TEXT=
1468d7edd17SPhilip Paeps
1478d7edd17SPhilip PaepsTZDATA_TEXT=	leapseconds tzdata.zi
1488d7edd17SPhilip Paeps
1498d7edd17SPhilip Paeps# For backward-compatibility links for old zone names, use
150f2fcff28SPhilip Paeps#	BACKWARD=	backward
151f2fcff28SPhilip Paeps# If you also want the link US/Pacific-New, even though it is confusing
152f2fcff28SPhilip Paeps# and is planned to be removed from the database eventually, use
1538d7edd17SPhilip Paeps#	BACKWARD=	backward pacificnew
1548d7edd17SPhilip Paeps# To omit these links, use
1558d7edd17SPhilip Paeps#	BACKWARD=
1568d7edd17SPhilip Paeps
157f2fcff28SPhilip PaepsBACKWARD=	backward
1588d7edd17SPhilip Paeps
159ba2b2efdSGlen Barber# If you want out-of-scope and often-wrong data from the file 'backzone', use
160ba2b2efdSGlen Barber#	PACKRATDATA=	backzone
161ba2b2efdSGlen Barber# To omit this data, use
162ba2b2efdSGlen Barber#	PACKRATDATA=
163ba2b2efdSGlen Barber
164ba2b2efdSGlen BarberPACKRATDATA=
165ba2b2efdSGlen Barber
1668d7edd17SPhilip Paeps# The name of a locale using the UTF-8 encoding, used during self-tests.
1678d7edd17SPhilip Paeps# The tests are skipped if the name does not appear to work on this system.
1688d7edd17SPhilip Paeps
1698d7edd17SPhilip PaepsUTF8_LOCALE=	en_US.utf8
1708d7edd17SPhilip Paeps
171ba2b2efdSGlen Barber# Since "." may not be in PATH...
172ba2b2efdSGlen Barber
173ba2b2efdSGlen BarberYEARISTYPE=	./yearistype
174ba2b2efdSGlen Barber
175ba2b2efdSGlen Barber# Non-default libraries needed to link.
176ba2b2efdSGlen BarberLDLIBS=
177ba2b2efdSGlen Barber
1788d7edd17SPhilip Paeps# Add the following to the end of the "CFLAGS=" line as needed to override
1798d7edd17SPhilip Paeps# defaults specified in the source code.  "-DFOO" is equivalent to "-DFOO=1".
1808d7edd17SPhilip Paeps#  -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
1818d7edd17SPhilip Paeps#	formats that generate only the last two digits of year numbers
1828d7edd17SPhilip Paeps#  -DEPOCH_LOCAL if the 'time' function returns local time not UT
183ba2b2efdSGlen Barber#  -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
184ba2b2efdSGlen Barber#	than what POSIX specifies, assuming local time is UT.
185ba2b2efdSGlen Barber#	For example, N is 252460800 on AmigaOS.
1868d7edd17SPhilip Paeps#  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
1878d7edd17SPhilip Paeps#  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
1888d7edd17SPhilip Paeps#  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
1898d7edd17SPhilip Paeps#  -DHAVE_GENERIC=0 if _Generic does not work
1908d7edd17SPhilip Paeps#  -DHAVE_GETTEXT if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris)
1918d7edd17SPhilip Paeps#  -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
1928d7edd17SPhilip Paeps#	ctime_r and asctime_r incompatibly with the POSIX standard
1938d7edd17SPhilip Paeps#	(Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
1948d7edd17SPhilip Paeps#  -DHAVE_INTTYPES_H if you have a non-C99 compiler with <inttypes.h>
1958d7edd17SPhilip Paeps#  -DHAVE_LINK=0 if your system lacks a link function
1968d7edd17SPhilip Paeps#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
1978d7edd17SPhilip Paeps#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
1988d7edd17SPhilip Paeps#	localtime_rz can make zdump significantly faster, but is nonstandard.
1998d7edd17SPhilip Paeps#  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
2008d7edd17SPhilip Paeps#	functions like 'link' or variables like 'tzname' required by POSIX
2018d7edd17SPhilip Paeps#  -DHAVE_SNPRINTF=0 if your system lacks the snprintf function
2028d7edd17SPhilip Paeps#  -DHAVE_STDBOOL_H if you have a non-C99 compiler with <stdbool.h>
2038d7edd17SPhilip Paeps#  -DHAVE_STDINT_H if you have a non-C99 compiler with <stdint.h>
2048d7edd17SPhilip Paeps#  -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
2058d7edd17SPhilip Paeps#  -DHAVE_STRDUP=0 if your system lacks the strdup function
20646bee4edSPhilip Paeps#  -DHAVE_STRTOLL=0 if your system lacks the strtoll function
2078d7edd17SPhilip Paeps#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
2088d7edd17SPhilip Paeps#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a <sys/stat.h>
2098d7edd17SPhilip Paeps#  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a <sys/wait.h>
2108d7edd17SPhilip Paeps#  -DHAVE_TZSET=0 if your system lacks a tzset function
2118d7edd17SPhilip Paeps#  -DHAVE_UNISTD_H=0 if your compiler lacks a <unistd.h>
2128d7edd17SPhilip Paeps#  -Dlocale_t=XXX if your system uses XXX instead of locale_t
21346bee4edSPhilip Paeps#  -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
21446bee4edSPhilip Paeps#	with external linkage, e.g., applications cannot define 'localtime'.
2158d7edd17SPhilip Paeps#  -Dssize_t=long on hosts like MS-Windows that lack ssize_t
21646bee4edSPhilip Paeps#  -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
21746bee4edSPhilip Paeps#	security implications and is not recommended for general use
2188d7edd17SPhilip Paeps#  -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
219ba2b2efdSGlen Barber#	not needed by the main-program tz code, which is single-threaded.
220ba2b2efdSGlen Barber#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
221ba2b2efdSGlen Barber#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
2228d7edd17SPhilip Paeps#	This is intended for internal use only; it mangles external names.
223ba2b2efdSGlen Barber#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
224ba2b2efdSGlen Barber#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
225ba2b2efdSGlen Barber#	the default is system-supplied, typically "/usr/lib/locale"
226ba2b2efdSGlen Barber#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
227ba2b2efdSGlen Barber#	DST transitions if the time zone files cannot be accessed
2288d7edd17SPhilip Paeps#  -DUNINIT_TRAP if reading uninitialized storage can cause problems
229ba2b2efdSGlen Barber#	other than simply getting garbage data
230ba2b2efdSGlen Barber#  -DUSE_LTZ=0 to build zdump with the system time zone library
231ba2b2efdSGlen Barber#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
232ba2b2efdSGlen Barber#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
233ba2b2efdSGlen Barber#	(or some other number) to set the maximum time zone abbreviation length
234ba2b2efdSGlen Barber#	that zic will accept without a warning (the default is 6)
235ba2b2efdSGlen Barber#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
2368d7edd17SPhilip Paeps# Select instrumentation via "make GCC_INSTRUMENT='whatever'".
2378d7edd17SPhilip PaepsGCC_INSTRUMENT = \
2388d7edd17SPhilip Paeps  -fsanitize=undefined -fsanitize-address-use-after-scope \
2398d7edd17SPhilip Paeps  -fsanitize-undefined-trap-on-error -fstack-protector
2408d7edd17SPhilip PaepsGCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \
2418d7edd17SPhilip Paeps  $(GCC_INSTRUMENT) \
242ba2b2efdSGlen Barber  -Wall -Wextra \
2438d7edd17SPhilip Paeps  -Walloc-size-larger-than=100000 -Warray-bounds=2 \
244d81c2dd9SPhilip Paeps  -Wbad-function-cast -Wcast-align=strict -Wdate-time \
2458d7edd17SPhilip Paeps  -Wdeclaration-after-statement -Wdouble-promotion \
2468d7edd17SPhilip Paeps  -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
2478d7edd17SPhilip Paeps  -Winit-self -Wjump-misses-init -Wlogical-op \
2488d7edd17SPhilip Paeps  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
249ba2b2efdSGlen Barber  -Wold-style-definition -Woverlength-strings -Wpointer-arith \
250d81c2dd9SPhilip Paeps  -Wshadow -Wshift-overflow=2 -Wstrict-prototypes -Wstringop-overflow=4 \
251d81c2dd9SPhilip Paeps  -Wstringop-truncation -Wsuggest-attribute=cold \
2528d7edd17SPhilip Paeps  -Wsuggest-attribute=const -Wsuggest-attribute=format \
253d81c2dd9SPhilip Paeps  -Wsuggest-attribute=malloc \
2548d7edd17SPhilip Paeps  -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
2558d7edd17SPhilip Paeps  -Wtrampolines -Wundef -Wuninitialized -Wunused \
2568d7edd17SPhilip Paeps  -Wvariadic-macros -Wvla -Wwrite-strings \
257ba2b2efdSGlen Barber  -Wno-address -Wno-format-nonliteral -Wno-sign-compare \
258ba2b2efdSGlen Barber  -Wno-type-limits -Wno-unused-parameter
259ba2b2efdSGlen Barber#
260ba2b2efdSGlen Barber# If your system has a "GMT offset" field in its "struct tm"s
261ba2b2efdSGlen Barber# (or if you decide to add such a field in your system's "time.h" file),
262ba2b2efdSGlen Barber# add the name to a define such as
263ba2b2efdSGlen Barber#	-DTM_GMTOFF=tm_gmtoff
264ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
265ba2b2efdSGlen Barber# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
266ba2b2efdSGlen Barber# Similarly, if your system has a "zone abbreviation" field, define
267ba2b2efdSGlen Barber#	-DTM_ZONE=tm_zone
268ba2b2efdSGlen Barber# and define NO_TM_ZONE to suppress any guessing.  These two fields are not
269ba2b2efdSGlen Barber# required by POSIX, but are widely available on GNU/Linux and BSD systems.
270ba2b2efdSGlen Barber#
2718d7edd17SPhilip Paeps# The next batch of options control support for external variables
2728d7edd17SPhilip Paeps# exported by tzcode.  In practice these variables are less useful
2738d7edd17SPhilip Paeps# than TM_GMTOFF and TM_ZONE.  However, most of them are standardized.
2748d7edd17SPhilip Paeps# #
2758d7edd17SPhilip Paeps# # To omit or support the external variable "tzname", add one of:
2768d7edd17SPhilip Paeps# #	-DHAVE_TZNAME=0
2778d7edd17SPhilip Paeps# #	-DHAVE_TZNAME=1
2788d7edd17SPhilip Paeps# # to the "CFLAGS=" line.  "tzname" is required by POSIX 1988 and later.
2798d7edd17SPhilip Paeps# # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
2808d7edd17SPhilip Paeps# # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
2818d7edd17SPhilip Paeps# # crashes when combined with some platforms' standard libraries,
2828d7edd17SPhilip Paeps# # presumably due to memory allocation issues.
2838d7edd17SPhilip Paeps# #
2848d7edd17SPhilip Paeps# # To omit or support the external variables "timezone" and "daylight", add
2858d7edd17SPhilip Paeps# #	-DUSG_COMPAT=0
2868d7edd17SPhilip Paeps# #	-DUSG_COMPAT=1
2878d7edd17SPhilip Paeps# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by
2888d7edd17SPhilip Paeps# # Unix Systems Group code and are required by POSIX 2008 (with XSI) and later.
2898d7edd17SPhilip Paeps# # If not defined, the code attempts to guess USG_COMPAT from other macros.
2908d7edd17SPhilip Paeps# #
2918d7edd17SPhilip Paeps# # To support the external variable "altzone", add
2928d7edd17SPhilip Paeps# #	-DALTZONE
2938d7edd17SPhilip Paeps# # to the end of the "CFLAGS=" line; although "altzone" appeared in
2948d7edd17SPhilip Paeps# # System V Release 3.1 it has not been standardized.
2958d7edd17SPhilip Paeps#
296ba2b2efdSGlen Barber# If you want functions that were inspired by early versions of X3J11's work,
297ba2b2efdSGlen Barber# add
298ba2b2efdSGlen Barber#	-DSTD_INSPIRED
299ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  This arranges for the functions
300ba2b2efdSGlen Barber# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
301ba2b2efdSGlen Barber# "posix2time", and "time2posix" to be added to the time conversion library.
302ba2b2efdSGlen Barber# "tzsetwall" is like "tzset" except that it arranges for local wall clock
30389abb9f8SPhilip Paeps# time (rather than the timezone specified in the TZ environment variable)
304ba2b2efdSGlen Barber# to be used.
305ba2b2efdSGlen Barber# "offtime" is like "gmtime" except that it accepts a second (long) argument
306ba2b2efdSGlen Barber# that gives an offset to add to the time_t when converting it.
307ba2b2efdSGlen Barber# "timelocal" is equivalent to "mktime".
308ba2b2efdSGlen Barber# "timegm" is like "timelocal" except that it turns a struct tm into
309ba2b2efdSGlen Barber# a time_t using UT (rather than local time as "timelocal" does).
310ba2b2efdSGlen Barber# "timeoff" is like "timegm" except that it accepts a second (long) argument
311ba2b2efdSGlen Barber# that gives an offset to use when converting to a time_t.
312ba2b2efdSGlen Barber# "posix2time" and "time2posix" are described in an included manual page.
313ba2b2efdSGlen Barber# X3J11's work does not describe any of these functions.
314ba2b2efdSGlen Barber# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
315ba2b2efdSGlen Barber# These functions may well disappear in future releases of the time
316ba2b2efdSGlen Barber# conversion package.
317ba2b2efdSGlen Barber#
318ba2b2efdSGlen Barber# If you don't want functions that were inspired by NetBSD, add
319ba2b2efdSGlen Barber#	-DNETBSD_INSPIRED=0
320ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  Otherwise, the functions
321ba2b2efdSGlen Barber# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
322ba2b2efdSGlen Barber# time library, and if STD_INSPIRED is also defined the functions
323ba2b2efdSGlen Barber# "posix2time_z" and "time2posix_z" are added as well.
324ba2b2efdSGlen Barber# The functions ending in "_z" (or "_rz") are like their unsuffixed
325ba2b2efdSGlen Barber# (or suffixed-by-"_r") counterparts, except with an extra first
326ba2b2efdSGlen Barber# argument of opaque type timezone_t that specifies the timezone.
327ba2b2efdSGlen Barber# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
328ba2b2efdSGlen Barber#
329ba2b2efdSGlen Barber# If you want to allocate state structures in localtime, add
330ba2b2efdSGlen Barber#	-DALL_STATE
331ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
332ba2b2efdSGlen Barber#
333ba2b2efdSGlen Barber# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
334ba2b2efdSGlen Barber# out by the National Institute of Standards and Technology
335ba2b2efdSGlen Barber# which claims to test C and Posix conformance.  If you want to pass PCTS, add
336ba2b2efdSGlen Barber#	-DPCTS
337ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.
338ba2b2efdSGlen Barber#
339ba2b2efdSGlen Barber# If you want strict compliance with XPG4 as of 1994-04-09, add
340ba2b2efdSGlen Barber#	-DXPG4_1994_04_09
341ba2b2efdSGlen Barber# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
3428d7edd17SPhilip Paeps# 53 as a week number (rather than 52 or 53) for January days before
3438d7edd17SPhilip Paeps# January's first Monday when a "%V" format is used and January 1
344ba2b2efdSGlen Barber# falls on a Friday, Saturday, or Sunday.
345ba2b2efdSGlen Barber
346ba2b2efdSGlen BarberCFLAGS=
347ba2b2efdSGlen Barber
348ba2b2efdSGlen Barber# Linker flags.  Default to $(LFLAGS) for backwards compatibility
349ba2b2efdSGlen Barber# to release 2012h and earlier.
350ba2b2efdSGlen Barber
351ba2b2efdSGlen BarberLDFLAGS=	$(LFLAGS)
352ba2b2efdSGlen Barber
353ba2b2efdSGlen Barber# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
354ba2b2efdSGlen Barber# submake command lines.  The default is no leap seconds.
355ba2b2efdSGlen Barber
356ba2b2efdSGlen BarberLEAPSECONDS=
357ba2b2efdSGlen Barber
358ba2b2efdSGlen Barber# The zic command and its arguments.
359ba2b2efdSGlen Barber
360ba2b2efdSGlen Barberzic=		./zic
361ba2b2efdSGlen BarberZIC=		$(zic) $(ZFLAGS)
362ba2b2efdSGlen Barber
363ba2b2efdSGlen BarberZFLAGS=
364ba2b2efdSGlen Barber
36589abb9f8SPhilip Paeps# How to use zic to install TZif files.
366ba2b2efdSGlen Barber
367f2fcff28SPhilip PaepsZIC_INSTALL=	$(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS)
368ba2b2efdSGlen Barber
369ba2b2efdSGlen Barber# The name of a Posix-compliant 'awk' on your system.
37089abb9f8SPhilip Paeps# Older 'mawk' versions, such as the 'mawk' in Ubuntu 16.04, might dump core;
37189abb9f8SPhilip Paeps# on Ubuntu you can work around this with
37289abb9f8SPhilip Paeps#	AWK=		gawk
373ba2b2efdSGlen BarberAWK=		awk
374ba2b2efdSGlen Barber
375ba2b2efdSGlen Barber# The full path name of a Posix-compliant shell, preferably one that supports
376ba2b2efdSGlen Barber# the Korn shell's 'select' statement as an extension.
377ba2b2efdSGlen Barber# These days, Bash is the most popular.
378ba2b2efdSGlen Barber# It should be OK to set this to /bin/sh, on platforms where /bin/sh
379ba2b2efdSGlen Barber# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
380ba2b2efdSGlen Barber# is typically nicer if it works.
381ba2b2efdSGlen BarberKSHELL=		/bin/bash
382ba2b2efdSGlen Barber
383*2c5e84ccSPhilip Paeps# Name of curl <https://curl.haxx.se/>, used for HTML validation.
384*2c5e84ccSPhilip PaepsCURL=		curl
385*2c5e84ccSPhilip Paeps
386ba2b2efdSGlen Barber# The path where SGML DTDs are kept and the catalog file(s) to use when
387*2c5e84ccSPhilip Paeps# validating HTML 4.01.  The default should work on both Debian and Red Hat.
388ba2b2efdSGlen BarberSGML_TOPDIR= /usr
389ba2b2efdSGlen BarberSGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd
390ba2b2efdSGlen BarberSGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224
391ba2b2efdSGlen BarberSGML_CATALOG_FILES= \
392ba2b2efdSGlen 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
393ba2b2efdSGlen Barber
394*2c5e84ccSPhilip Paeps# The name, arguments and environment of a program to validate HTML 4.01.
395ba2b2efdSGlen Barber# See <http://openjade.sourceforge.net/doc/> for a validator, and
396ba2b2efdSGlen Barber# <https://validator.w3.org/source/> for a validation library.
3978d7edd17SPhilip Paeps# Set VALIDATE=':' if you do not have such a program.
398ba2b2efdSGlen BarberVALIDATE = nsgmls
399ba2b2efdSGlen BarberVALIDATE_FLAGS = -s -B -wall -wno-unused-param
400ba2b2efdSGlen BarberVALIDATE_ENV = \
401f2fcff28SPhilip Paeps  SGML_CATALOG_FILES='$(SGML_CATALOG_FILES)' \
402f2fcff28SPhilip Paeps  SGML_SEARCH_PATH='$(SGML_SEARCH_PATH)' \
403ba2b2efdSGlen Barber  SP_CHARSET_FIXED=YES \
404ba2b2efdSGlen Barber  SP_ENCODING=UTF-8
405ba2b2efdSGlen Barber
406ba2b2efdSGlen Barber# This expensive test requires USE_LTZ.
407ba2b2efdSGlen Barber# To suppress it, define this macro to be empty.
408ba2b2efdSGlen BarberCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
409ba2b2efdSGlen Barber
410ba2b2efdSGlen Barber# SAFE_CHAR is a regular expression that matches a safe character.
411ba2b2efdSGlen Barber# Some parts of this distribution are limited to safe characters;
412ba2b2efdSGlen Barber# others can use any UTF-8 character.
413ba2b2efdSGlen Barber# For now, the safe characters are a safe subset of ASCII.
414ba2b2efdSGlen Barber# The caller must set the shell variable 'sharp' to the character '#',
415ba2b2efdSGlen Barber# since Makefile macros cannot contain '#'.
416ba2b2efdSGlen Barber# TAB_CHAR is a single tab character, in single quotes.
417ba2b2efdSGlen BarberTAB_CHAR=	'	'
418ba2b2efdSGlen BarberSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
419ba2b2efdSGlen BarberSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
420ba2b2efdSGlen BarberSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
421ba2b2efdSGlen BarberSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
422ba2b2efdSGlen BarberSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
423ba2b2efdSGlen Barber
42489abb9f8SPhilip Paeps# These characters are Latin-1, and so are likely to be displayable
42589abb9f8SPhilip Paeps# even in editors with limited character sets.
42689abb9f8SPhilip PaepsUNUSUAL_OK_LATIN_1 = «°±»½¾×
42789abb9f8SPhilip Paeps# This IPA symbol is represented in Unicode as the composition of
42889abb9f8SPhilip Paeps# U+0075 and U+032F, and U+032F is not considered alphabetic by some
42989abb9f8SPhilip Paeps# grep implementations that do not grok composition.
43089abb9f8SPhilip PaepsUNUSUAL_OK_IPA = u̯
43146bee4edSPhilip Paeps# Non-ASCII non-letters that OK_CHAR allows, as these characters are
43289abb9f8SPhilip Paeps# useful in commentary.
43389abb9f8SPhilip PaepsUNUSUAL_OK_CHARSET= $(UNUSUAL_OK_LATIN_1)$(UNUSUAL_OK_IPA)
43446bee4edSPhilip Paeps
435ba2b2efdSGlen Barber# OK_CHAR matches any character allowed in the distributed files.
43646bee4edSPhilip Paeps# This is the same as SAFE_CHAR, except that UNUSUAL_OK_CHARSET and
43746bee4edSPhilip Paeps# multibyte letters are also allowed so that commentary can contain a
43846bee4edSPhilip Paeps# few safe symbols and people's names and can quote non-English sources.
43946bee4edSPhilip Paeps# Other non-letters are limited to ASCII renderings for the
44046bee4edSPhilip Paeps# convenience of maintainers using XEmacs 21.5.34, which by default
44146bee4edSPhilip Paeps# mishandles Unicode characters U+0100 and greater.
44246bee4edSPhilip PaepsOK_CHAR=	'[][:alpha:]$(UNUSUAL_OK_CHARSET)'$(SAFE_CHARSET)'-]'
443ba2b2efdSGlen Barber
444ba2b2efdSGlen Barber# SAFE_LINE matches a line of safe characters.
445ba2b2efdSGlen Barber# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
446ba2b2efdSGlen Barber# this is so that comments can contain non-ASCII characters.
447ba2b2efdSGlen Barber# OK_LINE matches a line of OK characters.
448ba2b2efdSGlen BarberSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
449ba2b2efdSGlen BarberSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
450ba2b2efdSGlen BarberOK_LINE=	'^'$(OK_CHAR)'*$$'
451ba2b2efdSGlen Barber
452ba2b2efdSGlen Barber# Flags to give 'tar' when making a distribution.
453ba2b2efdSGlen Barber# Try to use flags appropriate for GNU tar.
454ba2b2efdSGlen BarberGNUTARFLAGS= --numeric-owner --owner=0 --group=0 --mode=go+u,go-w --sort=name
455ba2b2efdSGlen BarberTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
456ba2b2efdSGlen Barber		 then echo $(GNUTARFLAGS); \
457ba2b2efdSGlen Barber		 else :; \
458ba2b2efdSGlen Barber		 fi`
459ba2b2efdSGlen Barber
460ba2b2efdSGlen Barber# Flags to give 'gzip' when making a distribution.
461ba2b2efdSGlen BarberGZIPFLAGS=	-9n
462ba2b2efdSGlen Barber
463ba2b2efdSGlen Barber###############################################################################
464ba2b2efdSGlen Barber
465ba2b2efdSGlen Barber#MAKE=		make
466ba2b2efdSGlen Barber
467ba2b2efdSGlen Barbercc=		cc
468f2fcff28SPhilip PaepsCC=		$(cc) -DTZDIR='"$(TZDIR)"'
469ba2b2efdSGlen Barber
470ba2b2efdSGlen BarberAR=		ar
471ba2b2efdSGlen Barber
472ba2b2efdSGlen Barber# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
473ba2b2efdSGlen BarberRANLIB=		:
474ba2b2efdSGlen Barber
475ba2b2efdSGlen BarberTZCOBJS=	zic.o
4768d7edd17SPhilip PaepsTZDOBJS=	zdump.o localtime.o asctime.o strftime.o
477ba2b2efdSGlen BarberDATEOBJS=	date.o localtime.o strftime.o asctime.o
478ba2b2efdSGlen BarberLIBSRCS=	localtime.c asctime.c difftime.c
479ba2b2efdSGlen BarberLIBOBJS=	localtime.o asctime.o difftime.o
480ba2b2efdSGlen BarberHEADERS=	tzfile.h private.h
481ba2b2efdSGlen BarberNONLIBSRCS=	zic.c zdump.c
482ba2b2efdSGlen BarberNEWUCBSRCS=	date.c strftime.c
483ba2b2efdSGlen BarberSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
484ba2b2efdSGlen Barber			tzselect.ksh workman.sh
485ba2b2efdSGlen BarberMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
486ba2b2efdSGlen Barber			tzfile.5 tzselect.8 zic.8 zdump.8
487ba2b2efdSGlen BarberMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
488ba2b2efdSGlen Barber			time2posix.3.txt \
489ba2b2efdSGlen Barber			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
490ba2b2efdSGlen Barber			date.1.txt
4918d7edd17SPhilip PaepsCOMMON=		calendars CONTRIBUTING LICENSE Makefile \
4928d7edd17SPhilip Paeps			NEWS README theory.html version
493f2fcff28SPhilip PaepsWEB_PAGES=	tz-art.html tz-how-to.html tz-link.html
494*2c5e84ccSPhilip PaepsCHECK_WEB_PAGES=check_tz-art.html check_tz-how-to.html check_tz-link.html
495ba2b2efdSGlen BarberDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
496ba2b2efdSGlen BarberPRIMARY_YDATA=	africa antarctica asia australasia \
497ba2b2efdSGlen Barber		europe northamerica southamerica
498afb91be3SPhilip PaepsYDATA=		$(PRIMARY_YDATA) etcetera
499ba2b2efdSGlen BarberNDATA=		systemv factory
500afb91be3SPhilip PaepsTDATA_TO_CHECK=	$(YDATA) $(NDATA) backward pacificnew
501afb91be3SPhilip PaepsTDATA=		$(YDATA) $(NDATA) $(BACKWARD)
502ba2b2efdSGlen BarberZONETABLES=	zone1970.tab zone.tab
5038d7edd17SPhilip PaepsTABDATA=	iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
504ba2b2efdSGlen BarberLEAP_DEPS=	leapseconds.awk leap-seconds.list
50546bee4edSPhilip PaepsTZDATA_ZI_DEPS=	ziguard.awk zishrink.awk version $(TDATA) $(PACKRATDATA)
50646bee4edSPhilip PaepsDSTDATA_ZI_DEPS= ziguard.awk $(TDATA) $(PACKRATDATA)
507afb91be3SPhilip PaepsDATA=		$(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
5088d7edd17SPhilip Paeps			leapseconds yearistype.sh $(ZONETABLES)
50946bee4edSPhilip PaepsAWK_SCRIPTS=	checklinks.awk checktab.awk leapseconds.awk \
51046bee4edSPhilip Paeps			ziguard.awk zishrink.awk
511ba2b2efdSGlen BarberMISC=		$(AWK_SCRIPTS) zoneinfo2tdf.pl
512ba2b2efdSGlen BarberTZS_YEAR=	2050
51389abb9f8SPhilip PaepsTZS_CUTOFF_FLAG=	-c $(TZS_YEAR)
514ba2b2efdSGlen BarberTZS=		to$(TZS_YEAR).tzs
515ba2b2efdSGlen BarberTZS_NEW=	to$(TZS_YEAR)new.tzs
516ba2b2efdSGlen BarberTZS_DEPS=	$(PRIMARY_YDATA) asctime.c localtime.c \
517ba2b2efdSGlen Barber			private.h tzfile.h zdump.c zic.c
51889abb9f8SPhilip Paeps# EIGHT_YARDS is just a yard short of the whole ENCHILADA.
51989abb9f8SPhilip PaepsEIGHT_YARDS = $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) tzdata.zi
52089abb9f8SPhilip PaepsENCHILADA = $(EIGHT_YARDS) $(TZS)
521ba2b2efdSGlen Barber
522ba2b2efdSGlen Barber# Consult these files when deciding whether to rebuild the 'version' file.
523ba2b2efdSGlen Barber# This list is not the same as the output of 'git ls-files', since
524ba2b2efdSGlen Barber# .gitignore is not distributed.
525ba2b2efdSGlen BarberVERSION_DEPS= \
5268d7edd17SPhilip Paeps		calendars CONTRIBUTING LICENSE Makefile NEWS README \
527ba2b2efdSGlen Barber		africa antarctica asctime.c asia australasia \
528ba2b2efdSGlen Barber		backward backzone \
529ba2b2efdSGlen Barber		checklinks.awk checktab.awk \
530ba2b2efdSGlen Barber		date.1 date.c difftime.c \
531ba2b2efdSGlen Barber		etcetera europe factory iso3166.tab \
532ba2b2efdSGlen Barber		leap-seconds.list leapseconds.awk localtime.c \
533ba2b2efdSGlen Barber		newctime.3 newstrftime.3 newtzset.3 northamerica \
534ba2b2efdSGlen Barber		pacificnew private.h \
5358d7edd17SPhilip Paeps		southamerica strftime.c systemv theory.html \
536f2fcff28SPhilip Paeps		time2posix.3 tz-art.html tz-how-to.html tz-link.html \
537ba2b2efdSGlen Barber		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
538ba2b2efdSGlen Barber		workman.sh yearistype.sh \
539ba2b2efdSGlen Barber		zdump.8 zdump.c zic.8 zic.c \
540d81c2dd9SPhilip Paeps		ziguard.awk zishrink.awk \
541ba2b2efdSGlen Barber		zone.tab zone1970.tab zoneinfo2tdf.pl
542ba2b2efdSGlen Barber
543ba2b2efdSGlen Barber# And for the benefit of csh users on systems that assume the user
544ba2b2efdSGlen Barber# shell should be used to handle commands in Makefiles. . .
545ba2b2efdSGlen Barber
546ba2b2efdSGlen BarberSHELL=		/bin/sh
547ba2b2efdSGlen Barber
54846bee4edSPhilip Paepsall:		tzselect yearistype zic zdump libtz.a $(TABDATA) \
54946bee4edSPhilip Paeps		  vanguard.zi main.zi rearguard.zi
550ba2b2efdSGlen Barber
551ba2b2efdSGlen BarberALL:		all date $(ENCHILADA)
552ba2b2efdSGlen Barber
553ba2b2efdSGlen Barberinstall:	all $(DATA) $(REDO) $(MANS)
554f2fcff28SPhilip Paeps		mkdir -p '$(DESTDIR)$(BINDIR)' \
555f2fcff28SPhilip Paeps			'$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
556f2fcff28SPhilip Paeps			'$(DESTDIR)$(LIBDIR)' \
557f2fcff28SPhilip Paeps			'$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
558f2fcff28SPhilip Paeps			'$(DESTDIR)$(MANDIR)/man8'
559f2fcff28SPhilip Paeps		$(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES) \
560f2fcff28SPhilip Paeps			-t '$(DESTDIR)$(TZDEFAULT)'
561f2fcff28SPhilip Paeps		cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
562f2fcff28SPhilip Paeps		cp tzselect '$(DESTDIR)$(BINDIR)/.'
563f2fcff28SPhilip Paeps		cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
564f2fcff28SPhilip Paeps		cp zic '$(DESTDIR)$(ZICDIR)/.'
565f2fcff28SPhilip Paeps		cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
566f2fcff28SPhilip Paeps		$(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
567f2fcff28SPhilip Paeps		cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
568f2fcff28SPhilip Paeps		cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
569f2fcff28SPhilip Paeps		cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
570ba2b2efdSGlen Barber
571ba2b2efdSGlen BarberINSTALL:	ALL install date.1
572f2fcff28SPhilip Paeps		mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
573f2fcff28SPhilip Paeps		cp date '$(DESTDIR)$(BINDIR)/.'
574f2fcff28SPhilip Paeps		cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
575ba2b2efdSGlen Barber
576ba2b2efdSGlen Barberversion:	$(VERSION_DEPS)
577ba2b2efdSGlen Barber		{ (type git) >/dev/null 2>&1 && \
578ba2b2efdSGlen Barber		  V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
579ba2b2efdSGlen Barber				--abbrev=7 --dirty` || \
580f2fcff28SPhilip Paeps		  V='$(VERSION)'; } && \
581ba2b2efdSGlen Barber		printf '%s\n' "$$V" >$@.out
582ba2b2efdSGlen Barber		mv $@.out $@
583ba2b2efdSGlen Barber
58489abb9f8SPhilip Paeps# These files can be tailored by setting BACKWARD and PACKRATDATA.
58546bee4edSPhilip Paepsvanguard.zi main.zi rearguard.zi: $(DSTDATA_ZI_DEPS)
586d81c2dd9SPhilip Paeps		$(AWK) -v DATAFORM=`expr $@ : '\(.*\).zi'` -f ziguard.awk \
587d81c2dd9SPhilip Paeps		  $(TDATA) $(PACKRATDATA) >$@.out
58846bee4edSPhilip Paeps		mv $@.out $@
58989abb9f8SPhilip Paeps# This file has a version comment that attempts to capture any tailoring
59089abb9f8SPhilip Paeps# via BACKWARD, DATAFORM, PACKRATDATA, and REDO.
59189abb9f8SPhilip Paepstzdata.zi:	$(DATAFORM).zi version zishrink.awk
592f2fcff28SPhilip Paeps		version=`sed 1q version` && \
59389abb9f8SPhilip Paeps		  LC_ALL=C $(AWK) \
59489abb9f8SPhilip Paeps		    -v dataform='$(DATAFORM)' \
59589abb9f8SPhilip Paeps		    -v deps='$(DSTDATA_ZI_DEPS) zishrink.awk' \
59689abb9f8SPhilip Paeps		    -v redo='$(REDO)' \
59789abb9f8SPhilip Paeps		    -v version="$$version" \
59889abb9f8SPhilip Paeps		    -f zishrink.awk \
59946bee4edSPhilip Paeps		    $(DATAFORM).zi >$@.out
6008d7edd17SPhilip Paeps		mv $@.out $@
6018d7edd17SPhilip Paeps
602ba2b2efdSGlen Barberversion.h:	version
603ba2b2efdSGlen Barber		VERSION=`cat version` && printf '%s\n' \
604ba2b2efdSGlen Barber		  'static char const PKGVERSION[]="($(PACKAGE)) ";' \
605ba2b2efdSGlen Barber		  "static char const TZVERSION[]=\"$$VERSION\";" \
606ba2b2efdSGlen Barber		  'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
607ba2b2efdSGlen Barber		  >$@.out
608ba2b2efdSGlen Barber		mv $@.out $@
609ba2b2efdSGlen Barber
610ba2b2efdSGlen Barberzdump:		$(TZDOBJS)
611ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
612ba2b2efdSGlen Barber
613ba2b2efdSGlen Barberzic:		$(TZCOBJS)
614ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
615ba2b2efdSGlen Barber
616ba2b2efdSGlen Barberyearistype:	yearistype.sh
617ba2b2efdSGlen Barber		cp yearistype.sh yearistype
618ba2b2efdSGlen Barber		chmod +x yearistype
619ba2b2efdSGlen Barber
620ba2b2efdSGlen Barberleapseconds:	$(LEAP_DEPS)
621ba2b2efdSGlen Barber		$(AWK) -f leapseconds.awk leap-seconds.list >$@.out
622ba2b2efdSGlen Barber		mv $@.out $@
623ba2b2efdSGlen Barber
624ba2b2efdSGlen Barber# Arguments to pass to submakes of install_data.
625ba2b2efdSGlen Barber# They can be overridden by later submake arguments.
626ba2b2efdSGlen BarberINSTALLARGS = \
627f2fcff28SPhilip Paeps BACKWARD='$(BACKWARD)' \
628f2fcff28SPhilip Paeps DESTDIR='$(DESTDIR)' \
629ba2b2efdSGlen Barber LEAPSECONDS='$(LEAPSECONDS)' \
630ba2b2efdSGlen Barber PACKRATDATA='$(PACKRATDATA)' \
631f2fcff28SPhilip Paeps TZDEFAULT='$(TZDEFAULT)' \
632f2fcff28SPhilip Paeps TZDIR='$(TZDIR)' \
633f2fcff28SPhilip Paeps YEARISTYPE='$(YEARISTYPE)' \
634ba2b2efdSGlen Barber ZIC='$(ZIC)'
635ba2b2efdSGlen Barber
63689abb9f8SPhilip PaepsINSTALL_DATA_DEPS = zic leapseconds yearistype tzdata.zi
63789abb9f8SPhilip Paeps
63889abb9f8SPhilip Paeps# 'make install_data' installs one set of TZif files.
63989abb9f8SPhilip Paepsinstall_data: $(INSTALL_DATA_DEPS)
6408d7edd17SPhilip Paeps		$(ZIC_INSTALL) tzdata.zi
641ba2b2efdSGlen Barber
64289abb9f8SPhilip Paepsposix_only: $(INSTALL_DATA_DEPS)
643ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
644ba2b2efdSGlen Barber
64589abb9f8SPhilip Paepsright_only: $(INSTALL_DATA_DEPS)
646ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
647ba2b2efdSGlen Barber			install_data
648ba2b2efdSGlen Barber
649ba2b2efdSGlen Barber# In earlier versions of this makefile, the other two directories were
650ba2b2efdSGlen Barber# subdirectories of $(TZDIR).  However, this led to configuration errors.
651ba2b2efdSGlen Barber# For example, with posix_right under the earlier scheme,
652ba2b2efdSGlen Barber# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
653ba2b2efdSGlen Barber# but gmtime without leap seconds, which led to problems with applications
654ba2b2efdSGlen Barber# like sendmail that subtract gmtime from localtime.
655ba2b2efdSGlen Barber# Therefore, the other two directories are now siblings of $(TZDIR).
656ba2b2efdSGlen Barber# You must replace all of $(TZDIR) to switch from not using leap seconds
657ba2b2efdSGlen Barber# to using them, or vice versa.
658ba2b2efdSGlen Barberright_posix:	right_only
659f2fcff28SPhilip Paeps		rm -fr '$(DESTDIR)$(TZDIR)-leaps'
660f2fcff28SPhilip Paeps		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
661f2fcff28SPhilip Paeps		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
662f2fcff28SPhilip Paeps		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
663ba2b2efdSGlen Barber
664ba2b2efdSGlen Barberposix_right:	posix_only
665f2fcff28SPhilip Paeps		rm -fr '$(DESTDIR)$(TZDIR)-posix'
666f2fcff28SPhilip Paeps		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
667f2fcff28SPhilip Paeps		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
668f2fcff28SPhilip Paeps		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
669ba2b2efdSGlen Barber
670ba2b2efdSGlen Barber# This obsolescent rule is present for backwards compatibility with
671ba2b2efdSGlen Barber# tz releases 2014g through 2015g.  It should go away eventually.
67289abb9f8SPhilip Paepsposix_packrat: $(INSTALL_DATA_DEPS)
673ba2b2efdSGlen Barber		$(MAKE) $(INSTALLARGS) PACKRATDATA=backzone posix_only
674ba2b2efdSGlen Barber
675ba2b2efdSGlen Barberzones:		$(REDO)
676ba2b2efdSGlen Barber
67746bee4edSPhilip Paeps# dummy.zd is not a real file; it is mentioned here only so that the
67846bee4edSPhilip Paeps# top-level 'make' does not have a syntax error.
67946bee4edSPhilip PaepsZDS = dummy.zd
68046bee4edSPhilip Paeps# Rule used only by submakes invoked by the $(TZS_NEW) rule.
68146bee4edSPhilip Paeps# It is separate so that GNU 'make -j' can run instances in parallel.
68246bee4edSPhilip Paeps$(ZDS): zdump
68389abb9f8SPhilip Paeps		./zdump -i $(TZS_CUTOFF_FLAG) '$(wd)/'$$(expr $@ : '\(.*\).zd') \
68489abb9f8SPhilip Paeps		  >$@
68546bee4edSPhilip Paeps
68689abb9f8SPhilip PaepsTZS_NEW_DEPS = tzdata.zi zdump zic
68789abb9f8SPhilip Paeps$(TZS_NEW): $(TZS_NEW_DEPS)
68889abb9f8SPhilip Paeps		rm -fr tzs$(TZS_YEAR).dir
68989abb9f8SPhilip Paeps		mkdir tzs$(TZS_YEAR).dir
69089abb9f8SPhilip Paeps		$(zic) -d tzs$(TZS_YEAR).dir tzdata.zi
6918d7edd17SPhilip Paeps		$(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
6928d7edd17SPhilip Paeps		   tzdata.zi | LC_ALL=C sort >$@.out
693ba2b2efdSGlen Barber		wd=`pwd` && \
69489abb9f8SPhilip Paeps		x=`$(AWK) '/^Z/{print "tzs$(TZS_YEAR).dir/" $$2 ".zd"}' \
69589abb9f8SPhilip Paeps				tzdata.zi \
69646bee4edSPhilip Paeps			| LC_ALL=C sort -t . -k 2,2` && \
69789abb9f8SPhilip Paeps		set x $$x && \
69846bee4edSPhilip Paeps		shift && \
69946bee4edSPhilip Paeps		ZDS=$$* && \
70089abb9f8SPhilip Paeps		$(MAKE) wd="$$wd" TZS_CUTOFF_FLAG="$(TZS_CUTOFF_FLAG)" \
70189abb9f8SPhilip Paeps		  ZDS="$$ZDS" $$ZDS && \
70289abb9f8SPhilip Paeps		sed 's,^TZ=".*\.dir/,TZ=",' $$ZDS >>$@.out
70389abb9f8SPhilip Paeps		rm -fr tzs$(TZS_YEAR).dir
70446bee4edSPhilip Paeps		mv $@.out $@
705ba2b2efdSGlen Barber
70689abb9f8SPhilip Paeps# If $(TZS) exists but 'make check_tzs' fails, a maintainer should inspect the
707ba2b2efdSGlen Barber# failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
708ba2b2efdSGlen Barber$(TZS):
70989abb9f8SPhilip Paeps		touch $@
710ba2b2efdSGlen Barber
711ba2b2efdSGlen Barberforce_tzs:	$(TZS_NEW)
712ba2b2efdSGlen Barber		cp $(TZS_NEW) $(TZS)
713ba2b2efdSGlen Barber
714ba2b2efdSGlen Barberlibtz.a:	$(LIBOBJS)
715e350c46aSBaptiste Daroussin		rm -f $@
716e350c46aSBaptiste Daroussin		$(AR) -rc $@ $(LIBOBJS)
717ba2b2efdSGlen Barber		$(RANLIB) $@
718ba2b2efdSGlen Barber
719ba2b2efdSGlen Barberdate:		$(DATEOBJS)
720ba2b2efdSGlen Barber		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
721ba2b2efdSGlen Barber
722ba2b2efdSGlen Barbertzselect:	tzselect.ksh version
723ba2b2efdSGlen Barber		VERSION=`cat version` && sed \
724ba2b2efdSGlen Barber			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
725ba2b2efdSGlen Barber			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
726ba2b2efdSGlen Barber			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
727ba2b2efdSGlen Barber			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
728ba2b2efdSGlen Barber			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
729ba2b2efdSGlen Barber			-e 's|\(TZVERSION\)=.*|\1='"$$VERSION"'|' \
730ba2b2efdSGlen Barber			<$@.ksh >$@.out
731ba2b2efdSGlen Barber		chmod +x $@.out
732ba2b2efdSGlen Barber		mv $@.out $@
733ba2b2efdSGlen Barber
7348d7edd17SPhilip Paepscheck:		check_character_set check_white_space check_links \
7358d7edd17SPhilip Paeps		  check_name_lengths check_sorted \
7368d7edd17SPhilip Paeps		  check_tables check_web check_zishrink check_tzs
737ba2b2efdSGlen Barber
738ba2b2efdSGlen Barbercheck_character_set: $(ENCHILADA)
7398d7edd17SPhilip Paeps	test ! '$(UTF8_LOCALE)' || \
7408d7edd17SPhilip Paeps	! printf 'A\304\200B\n' | \
7418d7edd17SPhilip Paeps	  LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 || { \
7428d7edd17SPhilip Paeps		LC_ALL='$(UTF8_LOCALE)' && export LC_ALL && \
743ba2b2efdSGlen Barber		sharp='#' && \
744ba2b2efdSGlen Barber		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
745ba2b2efdSGlen Barber			$(MISC) $(SOURCES) $(WEB_PAGES) \
74646bee4edSPhilip Paeps			CONTRIBUTING LICENSE README \
7478d7edd17SPhilip Paeps			version tzdata.zi && \
74889abb9f8SPhilip Paeps		! grep -Env $(SAFE_LINE)'|^UNUSUAL_OK_'$(OK_CHAR)'*$$' \
74946bee4edSPhilip Paeps			Makefile && \
750afb91be3SPhilip Paeps		! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
751ba2b2efdSGlen Barber			leapseconds yearistype.sh zone.tab && \
7528d7edd17SPhilip Paeps		! grep -Env $(OK_LINE) $(ENCHILADA); \
7538d7edd17SPhilip Paeps	}
75489abb9f8SPhilip Paeps	touch $@
755ba2b2efdSGlen Barber
756ba2b2efdSGlen Barbercheck_white_space: $(ENCHILADA)
757ba2b2efdSGlen Barber		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
75889abb9f8SPhilip Paeps		! grep -En "$$pat" \
75989abb9f8SPhilip Paeps			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
760afb91be3SPhilip Paeps		! grep -n '[[:space:]]$$' \
761afb91be3SPhilip Paeps			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
76289abb9f8SPhilip Paeps		touch $@
763ba2b2efdSGlen Barber
7648d7edd17SPhilip PaepsPRECEDES_FILE_NAME = ^(Zone|Link[[:space:]]+[^[:space:]]+)[[:space:]]+
7658d7edd17SPhilip PaepsFILE_NAME_COMPONENT_TOO_LONG = \
7668d7edd17SPhilip Paeps  $(PRECEDES_FILE_NAME)[^[:space:]]*[^/[:space:]]{15}
7678d7edd17SPhilip Paeps
768afb91be3SPhilip Paepscheck_name_lengths: $(TDATA_TO_CHECK) backzone
769afb91be3SPhilip Paeps		! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
770afb91be3SPhilip Paeps			$(TDATA_TO_CHECK) backzone
77189abb9f8SPhilip Paeps		touch $@
7728d7edd17SPhilip Paeps
773ba2b2efdSGlen BarberCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
774ba2b2efdSGlen Barber
775ba2b2efdSGlen Barbercheck_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
776ba2b2efdSGlen Barber		$(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu
777ba2b2efdSGlen Barber		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
778ba2b2efdSGlen Barber		$(AWK) '/^[^#]/ {print $$1}' iso3166.tab | LC_ALL=C sort -cu
779ba2b2efdSGlen Barber		$(AWK) '/^[^#]/ {print $$1}' zone.tab | LC_ALL=C sort -c
780ba2b2efdSGlen Barber		$(AWK) '/^[^#]/ {print substr($$0, 1, 2)}' zone1970.tab | \
781ba2b2efdSGlen Barber		  LC_ALL=C sort -c
782ba2b2efdSGlen Barber		$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
783ba2b2efdSGlen Barber		  LC_ALL=C sort -cu
78489abb9f8SPhilip Paeps		touch $@
785ba2b2efdSGlen Barber
78646bee4edSPhilip Paepscheck_links:	checklinks.awk $(TDATA_TO_CHECK) tzdata.zi
787afb91be3SPhilip Paeps		$(AWK) -f checklinks.awk $(TDATA_TO_CHECK)
7888d7edd17SPhilip Paeps		$(AWK) -f checklinks.awk tzdata.zi
78989abb9f8SPhilip Paeps		touch $@
790ba2b2efdSGlen Barber
791ba2b2efdSGlen Barbercheck_tables:	checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
792ba2b2efdSGlen Barber		for tab in $(ZONETABLES); do \
793ba2b2efdSGlen Barber		  $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
794ba2b2efdSGlen Barber		    || exit; \
795ba2b2efdSGlen Barber		done
79689abb9f8SPhilip Paeps		touch $@
797ba2b2efdSGlen Barber
798ba2b2efdSGlen Barbercheck_tzs:	$(TZS) $(TZS_NEW)
79989abb9f8SPhilip Paeps		if test -s $(TZS); then \
80089abb9f8SPhilip Paeps		  diff -u $(TZS) $(TZS_NEW); \
80189abb9f8SPhilip Paeps		else \
80289abb9f8SPhilip Paeps		  cp $(TZS_NEW) $(TZS); \
80389abb9f8SPhilip Paeps		fi
80489abb9f8SPhilip Paeps		touch $@
805ba2b2efdSGlen Barber
806*2c5e84ccSPhilip Paepscheck_web:	$(CHECK_WEB_PAGES)
807*2c5e84ccSPhilip Paepscheck_tz-art.html: tz-art.html
808*2c5e84ccSPhilip Paepscheck_tz-link.html: tz-link.html
809*2c5e84ccSPhilip Paepscheck_tz-art.html check_tz-link.html:
810*2c5e84ccSPhilip Paeps		$(CURL) -sS --url https://validator.w3.org/nu/ -F out=gnu \
811*2c5e84ccSPhilip Paeps		    -F file=@$$(expr $@ : 'check_\(.*\)') -o $@.out && \
812*2c5e84ccSPhilip Paeps		  test ! -s $@.out || { cat $@.out; exit 1; }
813*2c5e84ccSPhilip Paeps		mv $@.out $@
814*2c5e84ccSPhilip Paepscheck_tz-how-to.html: tz-how-to.html
8158d7edd17SPhilip Paeps		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) tz-how-to.html
81689abb9f8SPhilip Paeps		touch $@
8178d7edd17SPhilip Paeps
81846bee4edSPhilip Paeps# Check that zishrink.awk does not alter the data, and that ziguard.awk
81946bee4edSPhilip Paeps# preserves main-format data.
82089abb9f8SPhilip Paepscheck_zishrink: check_zishrink_posix check_zishrink_right
82189abb9f8SPhilip Paepscheck_zishrink_posix check_zishrink_right: \
82289abb9f8SPhilip Paeps  zic leapseconds $(PACKRATDATA) $(TDATA) $(DATAFORM).zi tzdata.zi
82389abb9f8SPhilip Paeps		rm -fr $@.dir $@-t.dir $@-shrunk.dir
82489abb9f8SPhilip Paeps		mkdir $@.dir $@-t.dir $@-shrunk.dir
82589abb9f8SPhilip Paeps		case $@ in \
82689abb9f8SPhilip Paeps		  *_right) leap='-L leapseconds';; \
8278d7edd17SPhilip Paeps		  *) leap=;; \
8288d7edd17SPhilip Paeps		esac && \
82989abb9f8SPhilip Paeps		  $(ZIC) $$leap -d $@.dir $(DATAFORM).zi && \
83089abb9f8SPhilip Paeps		  $(ZIC) $$leap -d $@-shrunk.dir tzdata.zi && \
83146bee4edSPhilip Paeps		  case $(DATAFORM) in \
83246bee4edSPhilip Paeps		    main) \
83389abb9f8SPhilip Paeps		      $(ZIC) $$leap -d $@-t.dir $(TDATA) && \
8348d7edd17SPhilip Paeps		      $(AWK) '/^Rule/' $(TDATA) | \
83589abb9f8SPhilip Paeps			$(ZIC) $$leap -d $@-t.dir - $(PACKRATDATA) && \
83689abb9f8SPhilip Paeps		      diff -r $@.dir $@-t.dir;; \
83789abb9f8SPhilip Paeps		  esac
83889abb9f8SPhilip Paeps		diff -r $@.dir $@-shrunk.dir
83989abb9f8SPhilip Paeps		rm -fr $@.dir $@-t.dir $@-shrunk.dir
84089abb9f8SPhilip Paeps		touch $@
841ba2b2efdSGlen Barber
842ba2b2efdSGlen Barberclean_misc:
84389abb9f8SPhilip Paeps		rm -f *.o *.out $(TIME_T_ALTERNATIVES) \
84489abb9f8SPhilip Paeps		  check_* core typecheck_* \
845ba2b2efdSGlen Barber		  date tzselect version.h zdump zic yearistype libtz.a
846ba2b2efdSGlen Barberclean:		clean_misc
84746bee4edSPhilip Paeps		rm -fr *.dir *.zi tzdb-*/ $(TZS_NEW)
848ba2b2efdSGlen Barber
849ba2b2efdSGlen Barbermaintainer-clean: clean
850ba2b2efdSGlen Barber		@echo 'This command is intended for maintainers to use; it'
851ba2b2efdSGlen Barber		@echo 'deletes files that may need special tools to rebuild.'
852ba2b2efdSGlen Barber		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
853ba2b2efdSGlen Barber
854ba2b2efdSGlen Barbernames:
855ba2b2efdSGlen Barber		@echo $(ENCHILADA)
856ba2b2efdSGlen Barber
857ba2b2efdSGlen Barberpublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
858ba2b2efdSGlen Barber		tarballs signatures
859ba2b2efdSGlen Barber
860ba2b2efdSGlen Barberdate.1.txt:	date.1
861ba2b2efdSGlen Barbernewctime.3.txt:	newctime.3
862ba2b2efdSGlen Barbernewstrftime.3.txt: newstrftime.3
863ba2b2efdSGlen Barbernewtzset.3.txt:	newtzset.3
864ba2b2efdSGlen Barbertime2posix.3.txt: time2posix.3
865ba2b2efdSGlen Barbertzfile.5.txt:	tzfile.5
866ba2b2efdSGlen Barbertzselect.8.txt:	tzselect.8
867ba2b2efdSGlen Barberzdump.8.txt:	zdump.8
868ba2b2efdSGlen Barberzic.8.txt:	zic.8
869ba2b2efdSGlen Barber
870ba2b2efdSGlen Barber$(MANTXTS):	workman.sh
871ba2b2efdSGlen Barber		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out
872ba2b2efdSGlen Barber		mv $@.out $@
873ba2b2efdSGlen Barber
874ba2b2efdSGlen Barber# Set the timestamps to those of the git repository, if available,
875ba2b2efdSGlen Barber# and if the files have not changed since then.
876ba2b2efdSGlen Barber# This uses GNU 'touch' syntax 'touch -d@N FILE',
877ba2b2efdSGlen Barber# where N is the number of seconds since 1970.
878ba2b2efdSGlen Barber# If git or GNU 'touch' is absent, don't bother to sync with git timestamps.
879ba2b2efdSGlen Barber# Also, set the timestamp of each prebuilt file like 'leapseconds'
880ba2b2efdSGlen Barber# to be the maximum of the files it depends on.
88189abb9f8SPhilip Paepsset-timestamps.out: $(EIGHT_YARDS)
882ba2b2efdSGlen Barber		rm -f $@
883ba2b2efdSGlen Barber		if (type git) >/dev/null 2>&1 && \
88489abb9f8SPhilip Paeps		   files=`git ls-files $(EIGHT_YARDS)` && \
885ba2b2efdSGlen Barber		   touch -md @1 test.out; then \
886ba2b2efdSGlen Barber		  rm -f test.out && \
887ba2b2efdSGlen Barber		  for file in $$files; do \
888ba2b2efdSGlen Barber		    if git diff --quiet $$file; then \
889ba2b2efdSGlen Barber		      time=`git log -1 --format='tformat:%ct' $$file` && \
890ba2b2efdSGlen Barber		      touch -cmd @$$time $$file; \
891ba2b2efdSGlen Barber		    else \
892ba2b2efdSGlen Barber		      echo >&2 "$$file: warning: does not match repository"; \
893ba2b2efdSGlen Barber		    fi || exit; \
894ba2b2efdSGlen Barber		  done; \
895ba2b2efdSGlen Barber		fi
896ba2b2efdSGlen Barber		touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds
897ba2b2efdSGlen Barber		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
898ba2b2efdSGlen Barber		  touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \
899ba2b2efdSGlen Barber		    exit; \
900ba2b2efdSGlen Barber		done
9018d7edd17SPhilip Paeps		touch -cmr `ls -t $(TZDATA_ZI_DEPS) | sed 1q` tzdata.zi
902ba2b2efdSGlen Barber		touch -cmr `ls -t $(VERSION_DEPS) | sed 1q` version
903ba2b2efdSGlen Barber		touch $@
90489abb9f8SPhilip Paepsset-tzs-timestamp.out: $(TZS)
90589abb9f8SPhilip Paeps		touch -cmr `ls -t $(TZS_DEPS) | sed 1q` $(TZS)
90689abb9f8SPhilip Paeps		touch $@
907ba2b2efdSGlen Barber
908ba2b2efdSGlen Barber# The zics below ensure that each data file can stand on its own.
909ba2b2efdSGlen Barber# We also do an all-files run to catch links to links.
910ba2b2efdSGlen Barber
91189abb9f8SPhilip Paepscheck_public: $(VERSION_DEPS)
912ba2b2efdSGlen Barber		rm -fr public.dir
91389abb9f8SPhilip Paeps		mkdir public.dir
91489abb9f8SPhilip Paeps		ln $(VERSION_DEPS) public.dir
91589abb9f8SPhilip Paeps		cd public.dir && $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' ALL
91689abb9f8SPhilip Paeps		for i in $(TDATA_TO_CHECK) public.dir/tzdata.zi; do \
91789abb9f8SPhilip Paeps		  public.dir/zic -v -d public.dir/zoneinfo $$i 2>&1 || exit; \
91889abb9f8SPhilip Paeps		done
91989abb9f8SPhilip Paeps		public.dir/zic -v -d public.dir/zoneinfo-all $(TDATA_TO_CHECK)
92089abb9f8SPhilip Paeps		rm -fr public.dir
92189abb9f8SPhilip Paeps		touch $@
922ba2b2efdSGlen Barber
923ba2b2efdSGlen Barber# Check that the code works under various alternative
924ba2b2efdSGlen Barber# implementations of time_t.
92589abb9f8SPhilip Paepscheck_time_t_alternatives: $(TIME_T_ALTERNATIVES)
92689abb9f8SPhilip Paeps$(TIME_T_ALTERNATIVES_TAIL): $(TIME_T_ALTERNATIVES_HEAD)
92789abb9f8SPhilip Paeps$(TIME_T_ALTERNATIVES): $(VERSION_DEPS)
92889abb9f8SPhilip Paeps		rm -fr $@.dir
92989abb9f8SPhilip Paeps		mkdir $@.dir
93089abb9f8SPhilip Paeps		ln $(VERSION_DEPS) $@.dir
93189abb9f8SPhilip Paeps		case $@ in \
93289abb9f8SPhilip Paeps		  int32_t) range=-2147483648,2147483648;; \
93389abb9f8SPhilip Paeps		  u*) range=0,4294967296;; \
93489abb9f8SPhilip Paeps		  *) range=-4294967296,4294967296;; \
93589abb9f8SPhilip Paeps		esac && \
93689abb9f8SPhilip Paeps		wd=`pwd` && \
93789abb9f8SPhilip Paeps		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
93889abb9f8SPhilip Paeps		if test $@ = $(TIME_T_ALTERNATIVES_HEAD); then \
93989abb9f8SPhilip Paeps		  range_target=; \
94089abb9f8SPhilip Paeps		else \
94189abb9f8SPhilip Paeps		  range_target=to$$range.tzs; \
94289abb9f8SPhilip Paeps		fi && \
94389abb9f8SPhilip Paeps		(cd $@.dir && \
94489abb9f8SPhilip Paeps		  $(MAKE) TOPDIR="$$wd/$@.dir" \
94589abb9f8SPhilip Paeps		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$@'" \
94689abb9f8SPhilip Paeps		    REDO='$(REDO)' \
94789abb9f8SPhilip Paeps			D=$$wd/$@.dir \
94889abb9f8SPhilip Paeps		    TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
94989abb9f8SPhilip Paeps		    install $$range_target) && \
95089abb9f8SPhilip Paeps		test $@ = $(TIME_T_ALTERNATIVES_HEAD) || { \
95189abb9f8SPhilip Paeps		  (cd $(TIME_T_ALTERNATIVES_HEAD).dir && \
95289abb9f8SPhilip Paeps		    $(MAKE) TOPDIR="$$wd/$@.dir" \
95389abb9f8SPhilip Paeps		      TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
95489abb9f8SPhilip Paeps			D=$$wd/$@.dir \
95589abb9f8SPhilip Paeps		      to$$range.tzs) && \
95689abb9f8SPhilip Paeps		  diff -u $(TIME_T_ALTERNATIVES_HEAD).dir/to$$range.tzs \
95789abb9f8SPhilip Paeps			  $@.dir/to$$range.tzs && \
958ba2b2efdSGlen Barber		  if diff -q Makefile Makefile 2>/dev/null; then \
959ba2b2efdSGlen Barber		    quiet_option='-q'; \
960ba2b2efdSGlen Barber		  else \
961ba2b2efdSGlen Barber		    quiet_option=''; \
962ba2b2efdSGlen Barber		  fi && \
96389abb9f8SPhilip Paeps		    diff $$quiet_option -r $(TIME_T_ALTERNATIVES_HEAD).dir/etc \
96489abb9f8SPhilip Paeps					   $@.dir/etc && \
965ba2b2efdSGlen Barber		    diff $$quiet_option -r \
96689abb9f8SPhilip Paeps		      $(TIME_T_ALTERNATIVES_HEAD).dir/usr/share \
96789abb9f8SPhilip Paeps		      $@.dir/usr/share; \
96889abb9f8SPhilip Paeps		}
96989abb9f8SPhilip Paeps		touch $@
970ba2b2efdSGlen Barber
971d81c2dd9SPhilip PaepsTRADITIONAL_ASC = \
972d81c2dd9SPhilip Paeps  tzcode$(VERSION).tar.gz.asc \
973d81c2dd9SPhilip Paeps  tzdata$(VERSION).tar.gz.asc
97489abb9f8SPhilip PaepsREARGUARD_ASC = \
97589abb9f8SPhilip Paeps  tzdata$(VERSION)-rearguard.tar.gz.asc
97689abb9f8SPhilip PaepsALL_ASC = $(TRADITIONAL_ASC) $(REARGUARD_ASC) \
977d81c2dd9SPhilip Paeps  tzdb-$(VERSION).tar.lz.asc
978d81c2dd9SPhilip Paeps
97989abb9f8SPhilip Paepstarballs rearguard_tarballs traditional_tarballs \
98089abb9f8SPhilip Paepssignatures rearguard_signatures traditional_signatures: \
98189abb9f8SPhilip Paeps  version set-timestamps.out rearguard.zi
982ba2b2efdSGlen Barber		VERSION=`cat version` && \
983ba2b2efdSGlen Barber		$(MAKE) VERSION="$$VERSION" $@_version
984ba2b2efdSGlen Barber
98546bee4edSPhilip Paeps# These *_version rules are intended for use if VERSION is set by some
98646bee4edSPhilip Paeps# other means.  Ordinarily these rules are used only by the above
98746bee4edSPhilip Paeps# non-_version rules, which set VERSION on the 'make' command line.
98889abb9f8SPhilip Paepstarballs_version: traditional_tarballs_version rearguard_tarballs_version \
989d81c2dd9SPhilip Paeps  tzdb-$(VERSION).tar.lz
99089abb9f8SPhilip Paepsrearguard_tarballs_version: \
99189abb9f8SPhilip Paeps  tzdata$(VERSION)-rearguard.tar.gz
992ba2b2efdSGlen Barbertraditional_tarballs_version: \
993ba2b2efdSGlen Barber  tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
994d81c2dd9SPhilip Paepssignatures_version: $(ALL_ASC)
99589abb9f8SPhilip Paepsrearguard_signatures_version: $(REARGUARD_ASC)
996d81c2dd9SPhilip Paepstraditional_signatures_version: $(TRADITIONAL_ASC)
997ba2b2efdSGlen Barber
998ba2b2efdSGlen Barbertzcode$(VERSION).tar.gz: set-timestamps.out
999ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
1000ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - \
1001ba2b2efdSGlen Barber		    $(COMMON) $(DOCS) $(SOURCES) | \
1002ba2b2efdSGlen Barber		  gzip $(GZIPFLAGS) >$@.out
1003ba2b2efdSGlen Barber		mv $@.out $@
1004ba2b2efdSGlen Barber
1005ba2b2efdSGlen Barbertzdata$(VERSION).tar.gz: set-timestamps.out
1006ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
1007ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
1008ba2b2efdSGlen Barber		  gzip $(GZIPFLAGS) >$@.out
1009ba2b2efdSGlen Barber		mv $@.out $@
1010ba2b2efdSGlen Barber
1011d81c2dd9SPhilip Paepstzdata$(VERSION)-rearguard.tar.gz: rearguard.zi set-timestamps.out
1012d81c2dd9SPhilip Paeps		rm -fr tzdata$(VERSION)-rearguard.dir
1013d81c2dd9SPhilip Paeps		mkdir tzdata$(VERSION)-rearguard.dir
1014d81c2dd9SPhilip Paeps		ln $(COMMON) $(DATA) $(MISC) tzdata$(VERSION)-rearguard.dir
1015d81c2dd9SPhilip Paeps		cd tzdata$(VERSION)-rearguard.dir && \
1016d81c2dd9SPhilip Paeps		  rm -f $(TDATA) $(PACKRATDATA) version
1017d81c2dd9SPhilip Paeps		for f in $(TDATA) $(PACKRATDATA); do \
1018d81c2dd9SPhilip Paeps		  rearf=tzdata$(VERSION)-rearguard.dir/$$f; \
1019d81c2dd9SPhilip Paeps		  $(AWK) -v DATAFORM=rearguard -f ziguard.awk $$f >$$rearf && \
1020d81c2dd9SPhilip Paeps		  touch -cmr `ls -t ziguard.awk $$f` $$rearf || exit; \
1021d81c2dd9SPhilip Paeps		done
1022d81c2dd9SPhilip Paeps		sed '1s/$$/-rearguard/' \
1023d81c2dd9SPhilip Paeps		  <version >tzdata$(VERSION)-rearguard.dir/version
1024d81c2dd9SPhilip Paeps		touch -cmr version tzdata$(VERSION)-rearguard.dir/version
1025d81c2dd9SPhilip Paeps		LC_ALL=C && export LC_ALL && \
1026d81c2dd9SPhilip Paeps		  (cd tzdata$(VERSION)-rearguard.dir && \
1027d81c2dd9SPhilip Paeps		   tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
1028d81c2dd9SPhilip Paeps		     gzip $(GZIPFLAGS)) >$@.out
1029d81c2dd9SPhilip Paeps		mv $@.out $@
1030d81c2dd9SPhilip Paeps
103189abb9f8SPhilip Paepstzdb-$(VERSION).tar.lz: set-timestamps.out set-tzs-timestamp.out
1032ba2b2efdSGlen Barber		rm -fr tzdb-$(VERSION)
1033ba2b2efdSGlen Barber		mkdir tzdb-$(VERSION)
1034ba2b2efdSGlen Barber		ln $(ENCHILADA) tzdb-$(VERSION)
1035ba2b2efdSGlen Barber		touch -cmr `ls -t tzdb-$(VERSION)/* | sed 1q` tzdb-$(VERSION)
1036ba2b2efdSGlen Barber		LC_ALL=C && export LC_ALL && \
1037ba2b2efdSGlen Barber		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out
1038ba2b2efdSGlen Barber		mv $@.out $@
1039ba2b2efdSGlen Barber
1040ba2b2efdSGlen Barbertzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
1041ba2b2efdSGlen Barbertzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
1042d81c2dd9SPhilip Paepstzdata$(VERSION)-rearguard.tar.gz.asc: tzdata$(VERSION)-rearguard.tar.gz
1043ba2b2efdSGlen Barbertzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
1044d81c2dd9SPhilip Paeps$(ALL_ASC):
104589abb9f8SPhilip Paeps		gpg2 --armor --detach-sign $?
1046ba2b2efdSGlen Barber
104789abb9f8SPhilip PaepsTYPECHECK_CFLAGS = $(CFLAGS) -DTYPECHECK -D__time_t_defined -D_TIME_T
104889abb9f8SPhilip Paepstypecheck: typecheck_long_long typecheck_unsigned
104989abb9f8SPhilip Paepstypecheck_long_long typecheck_unsigned: $(VERSION_DEPS)
105089abb9f8SPhilip Paeps		rm -fr $@.dir
105189abb9f8SPhilip Paeps		mkdir $@.dir
105289abb9f8SPhilip Paeps		ln $(VERSION_DEPS) $@.dir
105389abb9f8SPhilip Paeps		cd $@.dir && \
105489abb9f8SPhilip Paeps		  case $@ in \
105589abb9f8SPhilip Paeps		    *_long_long) i="long long";; \
105689abb9f8SPhilip Paeps		    *_unsigned ) i="unsigned" ;; \
105789abb9f8SPhilip Paeps		  esac && \
105889abb9f8SPhilip Paeps		  typecheck_cflags='' && \
105989abb9f8SPhilip Paeps		  $(MAKE) \
106089abb9f8SPhilip Paeps		    CFLAGS="$(TYPECHECK_CFLAGS) \"-Dtime_t=$$i\"" \
106189abb9f8SPhilip Paeps		    TOPDIR="`pwd`" \
106289abb9f8SPhilip Paeps		    install
106389abb9f8SPhilip Paeps		$@.dir/zdump -i -c 1970,1971 Europe/Rome
106489abb9f8SPhilip Paeps		touch $@
1065ba2b2efdSGlen Barber
10668d7edd17SPhilip Paepszonenames:	tzdata.zi
10678d7edd17SPhilip Paeps		@$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
1068ba2b2efdSGlen Barber
1069ba2b2efdSGlen Barberasctime.o:	private.h tzfile.h
1070ba2b2efdSGlen Barberdate.o:		private.h
1071ba2b2efdSGlen Barberdifftime.o:	private.h
1072ba2b2efdSGlen Barberlocaltime.o:	private.h tzfile.h
1073ba2b2efdSGlen Barberstrftime.o:	private.h tzfile.h
1074ba2b2efdSGlen Barberzdump.o:	version.h
1075ba2b2efdSGlen Barberzic.o:		private.h tzfile.h version.h
1076ba2b2efdSGlen Barber
1077ba2b2efdSGlen Barber.KEEP_STATE:
1078ba2b2efdSGlen Barber
1079ba2b2efdSGlen Barber.PHONY: ALL INSTALL all
108089abb9f8SPhilip Paeps.PHONY: check check_time_t_alternatives
1081*2c5e84ccSPhilip Paeps.PHONY: check_web check_zishrink
108246bee4edSPhilip Paeps.PHONY: clean clean_misc dummy.zd force_tzs
1083ba2b2efdSGlen Barber.PHONY: install install_data maintainer-clean names
108489abb9f8SPhilip Paeps.PHONY: posix_only posix_packrat posix_right public
108589abb9f8SPhilip Paeps.PHONY: rearguard_signatures rearguard_signatures_version
108689abb9f8SPhilip Paeps.PHONY: rearguard_tarballs rearguard_tarballs_version
108789abb9f8SPhilip Paeps.PHONY: right_only right_posix signatures signatures_version
108846bee4edSPhilip Paeps.PHONY: tarballs tarballs_version
108946bee4edSPhilip Paeps.PHONY: traditional_signatures traditional_signatures_version
109046bee4edSPhilip Paeps.PHONY: traditional_tarballs traditional_tarballs_version
109146bee4edSPhilip Paeps.PHONY: typecheck
1092ba2b2efdSGlen Barber.PHONY: zonenames zones
109346bee4edSPhilip Paeps.PHONY: $(ZDS)
1094