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