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