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