xref: /netbsd-src/external/public-domain/tz/dist/Makefile (revision 80d9064ac03cbb6a4174695f0d5b237c8766d3d0)
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 numbers of the code and data distributions.
8VERSION=	2014g
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.  If you want just POSIX-compatible time values, but with
88# out-of-scope and often-wrong data from the file 'backzone', use
89#	REDO=		posix_packrat
90# POSIX mandates that leap seconds not be counted; for compatibility with it,
91# use "posix_only", "posix_right", or "posix_packrat".
92
93REDO=		posix_right
94
95# Since "." may not be in PATH...
96
97YEARISTYPE=	./yearistype
98
99# Non-default libraries needed to link.
100# Add -lintl if you want to use 'gettext' on Solaris.
101LDLIBS=
102
103# Add the following to the end of the "CFLAGS=" line as needed.
104#  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
105#  -DHAVE_ADJTIME=0 if 'adjtime' does not exist (SVR0?)
106#  -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS)
107#  -DHAVE_GETTEXT=1 if 'gettext' works (GNU, Linux, Solaris); also see LDLIBS
108#  -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
109#	ctime_r and asctime_r incompatibly with the POSIX standard (Solaris 8).
110#  -DHAVE_INTTYPES_H=1 if you have a pre-C99 compiler with "inttypes.h"
111#  -DHAVE_LINK=0 if your system lacks a link function
112#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
113#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
114#	This defaults to 1 if a working localtime_rz seems to be available.
115#	localtime_rz can make zdump significantly faster, but is nonstandard.
116#  -DHAVE_SETTIMEOFDAY=0 if settimeofday does not exist (SVR0?)
117#  -DHAVE_SETTIMEOFDAY=1 if settimeofday has just 1 arg (SVR4)
118#  -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD)
119#  -DHAVE_SETTIMEOFDAY=3 if settimeofday ignores 2nd arg (4.4BSD)
120#  -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h"
121#  -DHAVE_STRFTIME_L=1 if <time.h> declares locale_t and strftime_l
122#	This defaults to 0 if _POSIX_VERSION < 200809, 1 otherwise.
123#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
124#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h"
125#  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h"
126#  -DHAVE_TZSET=0 if your system lacks a tzset function
127#  -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
128#  -DHAVE_UTMPX_H=1 if your compiler has a "utmpx.h"
129#  -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
130#	if you do not want run time warnings about formats that may cause
131#	year 2000 grief
132#  -DTHREAD_SAFE=1 to make localtime.c thread-safe, as POSIX requires;
133#	not needed by the main-program tz code, which is single-threaded.
134#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
135#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
136#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
137#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
138#	the default is system-supplied, typically "/usr/lib/locale"
139#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
140#	DST transitions if the time zone files cannot be accessed
141#  -DUNINIT_TRAP=1 if reading uninitialized storage can cause problems
142#	other than simply getting garbage data
143#  -DUSE_LTZ=0 to build zdump with the system time zone library
144#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
145#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
146#	(or some other number) to set the maximum time zone abbreviation length
147#	that zic will accept without a warning (the default is 6)
148#  $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
149GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
150	-Wall -Wextra \
151	-Wbad-function-cast -Wcast-align -Wcast-qual \
152	-Wdeclaration-after-statement \
153	-Wformat=2 -Winit-self -Wjump-misses-init \
154	-Wmissing-declarations -Wmissing-noreturn -Wmissing-prototypes \
155	-Wnested-externs -Wno-address -Wno-cast-qual \
156	-Wno-format-nonliteral -Wno-sign-compare -Wno-sign-conversion \
157	-Wno-type-limits \
158	-Wno-unused-parameter -Woverlength-strings -Wpointer-arith \
159	-Wshadow -Wstrict-prototypes -Wsuggest-attribute=const \
160	-Wsuggest-attribute=format -Wsuggest-attribute=noreturn \
161	-Wsuggest-attribute=pure -Wtrampolines \
162	-Wwrite-strings
163#
164# If you want to use System V compatibility code, add
165#	-DUSG_COMPAT
166# to the end of the "CFLAGS=" line.  This arrange for "timezone" and "daylight"
167# variables to be kept up-to-date by the time conversion functions.  Neither
168# "timezone" nor "daylight" is described in X3J11's work.
169#
170# If your system has a "GMT offset" field in its "struct tm"s
171# (or if you decide to add such a field in your system's "time.h" file),
172# add the name to a define such as
173#	-DTM_GMTOFF=tm_gmtoff
174# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
175# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
176# Similarly, if your system has a "zone abbreviation" field, define
177#	-DTM_ZONE=tm_zone
178# and define NO_TM_ZONE to suppress any guessing.  These two fields are not
179# required by POSIX, but are widely available on GNU/Linux and BSD systems.
180#
181# If you want functions that were inspired by early versions of X3J11's work,
182# add
183#	-DSTD_INSPIRED
184# to the end of the "CFLAGS=" line.  This arranges for the functions
185# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
186# "posix2time", and "time2posix" to be added to the time conversion library.
187# "tzsetwall" is like "tzset" except that it arranges for local wall clock
188# time (rather than the time specified in the TZ environment variable)
189# to be used.
190# "offtime" is like "gmtime" except that it accepts a second (long) argument
191# that gives an offset to add to the time_t when converting it.
192# "timelocal" is equivalent to "mktime".
193# "timegm" is like "timelocal" except that it turns a struct tm into
194# a time_t using UT (rather than local time as "timelocal" does).
195# "timeoff" is like "timegm" except that it accepts a second (long) argument
196# that gives an offset to use when converting to a time_t.
197# "posix2time" and "time2posix" are described in an included manual page.
198# X3J11's work does not describe any of these functions.
199# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
200# These functions may well disappear in future releases of the time
201# conversion package.
202#
203# If you don't want functions that were inspired by NetBSD, add
204#	-DNETBSD_INSPIRED=0
205# to the end of the "CFLAGS=" line.  Otherwise, the functions
206# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
207# time library, and if STD_INSPIRED is also defined the functions
208# "posix2time_z" and "time2posix_z" are added as well.
209# The functions ending in "_z" (or "_rz") are like their unsuffixed
210# (or suffixed-by-"_r") counterparts, except with an extra first
211# argument of opaque type timezone_t that specifies the time zone.
212# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
213#
214# If you want to allocate state structures in localtime, add
215#	-DALL_STATE
216# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
217#
218# If you want an "altzone" variable (a la System V Release 3.1), add
219#	-DALTZONE
220# to the end of the "CFLAGS=" line.
221# This variable is not described in X3J11's work.
222#
223# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
224# out by the National Institute of Standards and Technology
225# which claims to test C and Posix conformance.  If you want to pass PCTS, add
226#	-DPCTS
227# to the end of the "CFLAGS=" line.
228#
229# If you want strict compliance with XPG4 as of 1994-04-09, add
230#	-DXPG4_1994_04_09
231# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
232# 53 as a week number (rather than 52 or 53) for those days in January that
233# before the first Monday in January when a "%V" format is used and January 1
234# falls on a Friday, Saturday, or Sunday.
235
236CFLAGS=
237
238# Linker flags.  Default to $(LFLAGS) for backwards compatibility
239# to tzcode2012h and earlier.
240
241LDFLAGS=	$(LFLAGS)
242
243zic=		./zic
244ZIC=		$(zic) $(ZFLAGS)
245
246ZFLAGS=
247
248# The name of a Posix-compliant 'awk' on your system.
249AWK=		awk
250
251# The full path name of a Posix-compliant shell, preferably one that supports
252# the Korn shell's 'select' statement as an extension.
253# These days, Bash is the most popular.
254# It should be OK to set this to /bin/sh, on platforms where /bin/sh
255# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
256# is typically nicer if it works.
257KSHELL=		/bin/bash
258
259# The path where SGML DTDs are kept and the catalog file(s) to use when
260# validating.  The default is appropriate for Ubuntu 13.10.
261SGML_TOPDIR= /usr
262SGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd
263SGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224
264SGML_CATALOG_FILES= \
265  $(SGML_TOPDIR)/share/doc/w3-recs/html/www.w3.org/TR/1999/REC-html401-19991224/HTML4.cat
266
267# The name, arguments and environment of a program to validate your web pages.
268# See <http://www.jclark.com/sp/> for a validator, and
269# <http://validator.w3.org/source/> for a validation library.
270VALIDATE = nsgmls
271VALIDATE_FLAGS = -s -B -wall -wno-unused-param
272VALIDATE_ENV = \
273  SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) \
274  SGML_SEARCH_PATH=$(SGML_SEARCH_PATH) \
275  SP_CHARSET_FIXED=YES \
276  SP_ENCODING=UTF-8
277
278# This expensive test requires USE_LTZ.
279# To suppress it, define this macro to be empty.
280CHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
281
282# SAFE_CHAR is a regular expression that matches a safe character.
283# Some parts of this distribution are limited to safe characters;
284# others can use any UTF-8 character.
285# For now, the safe characters are a safe subset of ASCII.
286# The caller must set the shell variable 'sharp' to the character '#',
287# since Makefile macros cannot contain '#'.
288# TAB_CHAR is a single tab character, in single quotes.
289TAB_CHAR=	'	'
290SAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
291SAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
292SAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
293SAFE_CHARSET=	]$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)-
294SAFE_CHAR=	'['$(SAFE_CHARSET)']'
295# NONSYM_CHAR is a regular expression that matches any character
296# except for a small number of symbols, where we prefer to stick with
297# ASCII renderings for the convenience of maintainers whose text editors
298# mishandle UTF-8 by default (e.g., XEmacs 21.4.22).
299NONSYM_CHAR=	'[^–—°′″≈≠≤≥±−×÷∞←→↔·•§¶«»‘’‚‛“”„‟‹›「」『』〝〞〟]'
300
301# SAFE_LINE matches a line of safe characters.
302# SAFE_SHARP_LINE is similar, except any character can follow '#';
303# this is so that comments can contain non-ASCII characters.
304# NONSYM_LINE matches a line of non-symbols.
305# VALID_LINE matches a line of any validly-encoded characters.
306SAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
307SAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(NONSYM_CHAR)'*)?$$'
308NONSYM_LINE=	'^'$(NONSYM_CHAR)'*$$'
309VALID_LINE=	'^.*$$'
310
311# Flags to give 'tar' when making a distribution.
312# Try to use flags appropriate for GNU tar.
313GNUTARFLAGS=	--numeric-owner --owner=0 --group=0 --mode=go+u,go-w
314TARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
315		 then echo $(GNUTARFLAGS); \
316		 else :; \
317		 fi`
318
319# Flags to give 'gzip' when making a distribution.
320GZIPFLAGS=	-9n
321
322###############################################################################
323
324cc=		cc
325CC=		$(cc) -DTZDIR=\"$(TZDIR)\"
326
327AR=		ar
328
329# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
330RANLIB=		:
331
332TZCOBJS=	zic.o scheck.o ialloc.o
333TZDOBJS=	zdump.o localtime.o asctime.o
334DATEOBJS=	date.o localtime.o strftime.o asctime.o
335LIBSRCS=	localtime.c asctime.c difftime.c
336LIBOBJS=	localtime.o asctime.o difftime.o
337HEADERS=	tzfile.h private.h
338NONLIBSRCS=	zic.c zdump.c scheck.c ialloc.c
339NEWUCBSRCS=	date.c strftime.c
340SOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
341			tzselect.ksh workman.sh
342MANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
343			tzfile.5 tzselect.8 zic.8 zdump.8
344MANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
345			time2posix.3.txt \
346			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
347			date.1.txt
348COMMON=		CONTRIBUTING Makefile NEWS README Theory
349WEB_PAGES=	tz-art.htm tz-link.htm
350DOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
351PRIMARY_YDATA=	africa antarctica asia australasia \
352		europe northamerica southamerica
353YDATA=		$(PRIMARY_YDATA) pacificnew etcetera backward
354NDATA=		systemv factory
355TDATA=		$(YDATA) $(NDATA)
356ZONETABLES=	zone1970.tab zone.tab
357TABDATA=	iso3166.tab leapseconds $(ZONETABLES)
358LEAP_DEPS=	leapseconds.awk leap-seconds.list
359DATA=		$(YDATA) $(NDATA) backzone $(TABDATA) \
360			leap-seconds.list yearistype.sh
361AWK_SCRIPTS=	checktab.awk leapseconds.awk
362MISC=		$(AWK_SCRIPTS) zoneinfo2tdf.pl
363ENCHILADA=	$(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC)
364
365# And for the benefit of csh users on systems that assume the user
366# shell should be used to handle commands in Makefiles. . .
367
368SHELL=		/bin/sh
369
370all:		tzselect zic zdump libtz.a $(TABDATA)
371
372ALL:		all date
373
374install:	all $(DATA) $(REDO) $(MANS)
375		mkdir -p $(DESTDIR)$(ETCDIR) $(DESTDIR)$(TZDIR) \
376			$(DESTDIR)$(LIBDIR) \
377			$(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \
378			$(DESTDIR)$(MANDIR)/man8
379		$(ZIC) -y $(YEARISTYPE) \
380			-d $(DESTDIR)$(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
381		cp -f iso3166.tab $(ZONETABLES) $(DESTDIR)$(TZDIR)/.
382		cp tzselect zic zdump $(DESTDIR)$(ETCDIR)/.
383		cp libtz.a $(DESTDIR)$(LIBDIR)/.
384		$(RANLIB) $(DESTDIR)$(LIBDIR)/libtz.a
385		cp -f newctime.3 newtzset.3 $(DESTDIR)$(MANDIR)/man3/.
386		cp -f tzfile.5 $(DESTDIR)$(MANDIR)/man5/.
387		cp -f tzselect.8 zdump.8 zic.8 $(DESTDIR)$(MANDIR)/man8/.
388
389INSTALL:	ALL install date.1
390		mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1
391		cp date $(DESTDIR)$(BINDIR)/.
392		cp -f date.1 $(DESTDIR)$(MANDIR)/man1/.
393
394version.h:
395		(echo 'static char const PKGVERSION[]="($(PACKAGE)) ";' && \
396		 echo 'static char const TZVERSION[]="$(VERSION)";' && \
397		 echo 'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";') >$@
398
399zdump:		$(TZDOBJS)
400		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
401
402zic:		$(TZCOBJS) yearistype
403		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
404
405yearistype:	yearistype.sh
406		cp yearistype.sh yearistype
407		chmod +x yearistype
408
409leapseconds:	$(LEAP_DEPS)
410		$(AWK) -f leapseconds.awk leap-seconds.list >$@
411
412posix_only:	zic $(TDATA)
413		$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
414			-L /dev/null $(TDATA)
415
416right_only:	zic leapseconds $(TDATA)
417		$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
418			-L leapseconds $(TDATA)
419
420# In earlier versions of this makefile, the other two directories were
421# subdirectories of $(TZDIR).  However, this led to configuration errors.
422# For example, with posix_right under the earlier scheme,
423# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
424# but gmtime without leap seconds, which led to problems with applications
425# like sendmail that subtract gmtime from localtime.
426# Therefore, the other two directories are now siblings of $(TZDIR).
427# You must replace all of $(TZDIR) to switch from not using leap seconds
428# to using them, or vice versa.
429right_posix:	right_only leapseconds
430		rm -fr $(DESTDIR)$(TZDIR)-leaps
431		ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-leaps || \
432		  $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-leaps \
433			-L leapseconds $(TDATA)
434		$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-posix \
435			-L /dev/null $(TDATA)
436
437posix_right:	posix_only leapseconds
438		rm -fr $(DESTDIR)$(TZDIR)-posix
439		ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-posix || \
440		  $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-posix \
441			-L /dev/null $(TDATA)
442		$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-leaps \
443			-L leapseconds $(TDATA)
444
445posix_packrat:	posix_only backzone
446		$(AWK) '/^Rule/' $(TDATA) | \
447		  $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
448			-L /dev/null - backzone
449
450zones:		$(REDO)
451
452libtz.a:	$(LIBOBJS)
453		$(AR) ru $@ $(LIBOBJS)
454		$(RANLIB) $@
455
456date:		$(DATEOBJS)
457		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
458
459tzselect:	tzselect.ksh
460		sed \
461			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
462			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
463			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
464			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
465			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
466			-e 's|\(TZVERSION\)=.*|\1=$(VERSION)|' \
467			<$? >$@
468		chmod +x $@
469
470check:		check_character_set check_white_space check_tables check_web
471
472check_character_set: $(ENCHILADA)
473		LC_ALL=en_US.utf8 && export LC_ALL && \
474		sharp='#' && \
475		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
476			$(MISC) $(SOURCES) $(WEB_PAGES) && \
477		! grep -Env $(SAFE_SHARP_LINE) $(TDATA) backzone \
478			iso3166.tab leapseconds yearistype.sh zone.tab && \
479		test $$(grep -Ecv $(SAFE_SHARP_LINE) Makefile) -eq 1 && \
480		! grep -Env $(NONSYM_LINE) CONTRIBUTING NEWS README Theory \
481			$(MANS) date.1 zone1970.tab && \
482		! grep -Env $(VALID_LINE) $(ENCHILADA)
483
484check_white_space: $(ENCHILADA)
485		! grep -n ' '$(TAB_CHAR) $(ENCHILADA)
486		! grep -n '[[:space:]]$$' $(ENCHILADA)
487		! grep -n "$$(printf '[\f\r\v]\n')" $(ENCHILADA)
488
489check_tables:	checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
490		for tab in $(ZONETABLES); do \
491		  $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
492		    || exit; \
493		done
494
495check_web:	$(WEB_PAGES)
496		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES)
497
498clean_misc:
499		rm -f core *.o *.out \
500		  date tzselect version.h zdump zic yearistype libtz.a
501clean:		clean_misc
502		rm -fr tzpublic
503
504maintainer-clean: clean
505		@echo 'This command is intended for maintainers to use; it'
506		@echo 'deletes files that may need special tools to rebuild.'
507		rm -f leapseconds $(MANTXTS) *.asc *.tar.gz
508
509names:
510		@echo $(ENCHILADA)
511
512public:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
513		tarballs signatures
514
515date.1.txt:	date.1
516newctime.3.txt:	newctime.3
517newstrftime.3.txt: newstrftime.3
518newtzset.3.txt:	newtzset.3
519time2posix.3.txt: time2posix.3
520tzfile.5.txt:	tzfile.5
521tzselect.8.txt:	tzselect.8
522zdump.8.txt:	zdump.8
523zic.8.txt:	zic.8
524
525$(MANTXTS):	workman.sh
526		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@
527
528# Set the time stamps to those of the git repository, if available,
529# and if the files have not changed since then.
530# This uses GNU 'touch' syntax 'touch -d@N FILE',
531# where N is the number of seconds since 1970.
532# If git or GNU 'touch' is absent, don't bother to sync with git timestamps.
533# Also, set the timestamp of each prebuilt file like 'leapseconds'
534# to be the maximum of the files it depends on.
535set-timestamps.out: $(ENCHILADA)
536		rm -f $@
537		if files=`git ls-files $(ENCHILADA)` && \
538		   touch -md @1 test.out; then \
539		  rm -f test.out && \
540		  for file in $$files; do \
541		    if git diff --quiet $$file; then \
542		      time=`git log -1 --format='tformat:%ct' $$file` && \
543		      touch -cmd @$$time $$file; \
544		    else \
545		      echo >&2 "$$file: warning: does not match repository"; \
546		    fi || exit; \
547		  done; \
548		fi
549		touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds
550		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
551		  touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \
552		    exit; \
553		done
554		touch $@
555
556# The zics below ensure that each data file can stand on its own.
557# We also do an all-files run to catch links to links.
558
559check_public:	$(ENCHILADA)
560		make maintainer-clean
561		make "CFLAGS=$(GCC_DEBUG_FLAGS)" $(ENCHILADA) all
562		mkdir tzpublic
563		for i in $(TDATA) ; do \
564		  $(zic) -v -d tzpublic $$i 2>&1 || exit; \
565		done
566		$(zic) -v -d tzpublic $(TDATA)
567		rm -fr tzpublic
568
569# Check that the code works under various alternative
570# implementations of time_t.
571check_time_t_alternatives:
572		if diff -q Makefile Makefile 2>/dev/null; then \
573		  quiet_option='-q'; \
574		else \
575		  quiet_option=''; \
576		fi && \
577		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
578		for type in $(TIME_T_ALTERNATIVES); do \
579		  mkdir -p tzpublic/$$type && \
580		  make clean_misc && \
581		  make TOPDIR=`pwd`/tzpublic/$$type \
582		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
583		    REDO='$(REDO)' \
584		    install && \
585		  diff $$quiet_option -r \
586		    tzpublic/int64_t/etc/zoneinfo \
587		    tzpublic/$$type/etc/zoneinfo && \
588		  case $$type in \
589		  int32_t) range=-2147483648,2147483647;; \
590		  uint32_t) range=0,4294967296;; \
591		  int64_t) continue;; \
592		  *u*) range=0,10000000000;; \
593		  *) range=-10000000000,10000000000;; \
594		  esac && \
595		  echo checking $$type zones ... && \
596		  tzpublic/int64_t/etc/zdump -V -t $$range $$zones \
597		      >tzpublic/int64_t.out && \
598		  tzpublic/$$type/etc/zdump -V -t $$range $$zones \
599		      >tzpublic/$$type.out && \
600		  diff -u tzpublic/int64_t.out tzpublic/$$type.out \
601		    || exit; \
602		done
603		rm -fr tzpublic
604
605tarballs:	tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
606
607tzcode$(VERSION).tar.gz: set-timestamps.out
608		LC_ALL=C && export LC_ALL && \
609		tar $(TARFLAGS) -cf - \
610		    $(COMMON) $(DOCS) $(SOURCES) | \
611		  gzip $(GZIPFLAGS) > $@
612
613tzdata$(VERSION).tar.gz: set-timestamps.out
614		LC_ALL=C && export LC_ALL && \
615		tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
616		  gzip $(GZIPFLAGS) > $@
617
618signatures:	tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc
619
620tzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
621		gpg --armor --detach-sign $?
622
623tzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
624		gpg --armor --detach-sign $?
625
626typecheck:
627		make clean
628		for i in "long long" unsigned; \
629		do \
630			make CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
631			./zdump -v Europe/Rome ; \
632			make clean ; \
633		done
634
635zonenames:	$(TDATA)
636		@$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
637
638asctime.o:	private.h tzfile.h
639date.o:		private.h
640difftime.o:	private.h
641ialloc.o:	private.h
642localtime.o:	private.h tzfile.h
643scheck.o:	private.h
644strftime.o:	private.h tzfile.h
645zdump.o:	version.h
646zic.o:		private.h tzfile.h version.h
647
648.KEEP_STATE:
649
650.PHONY: ALL INSTALL all
651.PHONY: check check_character_set check_public check_tables
652.PHONY: check_time_t_alternatives check_web check_white_space clean clean_misc
653.PHONY: install maintainer-clean names posix_packrat posix_only posix_right
654.PHONY: public right_only right_posix signatures tarballs typecheck
655.PHONY: zonenames zones
656