xref: /minix3/lib/libc/time/Makefile (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
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=	2015g
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#  -DUNINIT_TRAP=1 if reading uninitialized storage can cause problems
137#	other than simply getting garbage data
138#  -DUSE_LTZ=0 to build zdump with the system time zone library
139#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
140#  -DNO_ERROR_IN_DST_GAP=1
141#	if you want mktime() not to return an error in the DST gap.
142#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
143#	(or some other number) to set the maximum time zone abbreviation length
144#	that zic will accept without a warning (the default is 6)
145#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
146GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
147	-Wall -Wextra \
148	-Wbad-function-cast -Wcast-align -Wdate-time \
149	-Wdeclaration-after-statement \
150	-Wdouble-promotion \
151	-Wformat=2 -Winit-self -Wjump-misses-init \
152	-Wlogical-op -Wmissing-prototypes -Wnested-externs \
153	-Wold-style-definition -Woverlength-strings -Wpointer-arith \
154	-Wshadow -Wstrict-prototypes -Wsuggest-attribute=const \
155	-Wsuggest-attribute=format -Wsuggest-attribute=noreturn \
156	-Wsuggest-attribute=pure -Wtrampolines \
157	-Wunused -Wwrite-strings \
158	-Wno-address -Wno-format-nonliteral -Wno-sign-compare \
159	-Wno-type-limits -Wno-unused-parameter
160#
161# If you want to use System V compatibility code, add
162#	-DUSG_COMPAT
163# to the end of the "CFLAGS=" line.  This arrange for "timezone" and "daylight"
164# variables to be kept up-to-date by the time conversion functions.  Neither
165# "timezone" nor "daylight" is described in X3J11's work.
166#
167# If your system has a "GMT offset" field in its "struct tm"s
168# (or if you decide to add such a field in your system's "time.h" file),
169# add the name to a define such as
170#	-DTM_GMTOFF=tm_gmtoff
171# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
172# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
173# Similarly, if your system has a "zone abbreviation" field, define
174#	-DTM_ZONE=tm_zone
175# and define NO_TM_ZONE to suppress any guessing.  These two fields are not
176# required by POSIX, but are widely available on GNU/Linux and BSD systems.
177#
178# If you want functions that were inspired by early versions of X3J11's work,
179# add
180#	-DSTD_INSPIRED
181# to the end of the "CFLAGS=" line.  This arranges for the functions
182# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
183# "posix2time", and "time2posix" to be added to the time conversion library.
184# "tzsetwall" is like "tzset" except that it arranges for local wall clock
185# time (rather than the time specified in the TZ environment variable)
186# to be used.
187# "offtime" is like "gmtime" except that it accepts a second (long) argument
188# that gives an offset to add to the time_t when converting it.
189# "timelocal" is equivalent to "mktime".
190# "timegm" is like "timelocal" except that it turns a struct tm into
191# a time_t using UT (rather than local time as "timelocal" does).
192# "timeoff" is like "timegm" except that it accepts a second (long) argument
193# that gives an offset to use when converting to a time_t.
194# "posix2time" and "time2posix" are described in an included manual page.
195# X3J11's work does not describe any of these functions.
196# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
197# These functions may well disappear in future releases of the time
198# conversion package.
199#
200# If you don't want functions that were inspired by NetBSD, add
201#	-DNETBSD_INSPIRED=0
202# to the end of the "CFLAGS=" line.  Otherwise, the functions
203# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
204# time library, and if STD_INSPIRED is also defined the functions
205# "posix2time_z" and "time2posix_z" are added as well.
206# The functions ending in "_z" (or "_rz") are like their unsuffixed
207# (or suffixed-by-"_r") counterparts, except with an extra first
208# argument of opaque type timezone_t that specifies the time zone.
209# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
210#
211# If you want to allocate state structures in localtime, add
212#	-DALL_STATE
213# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
214#
215# If you want an "altzone" variable (a la System V Release 3.1), add
216#	-DALTZONE
217# to the end of the "CFLAGS=" line.
218# This variable is not described in X3J11's work.
219#
220# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
221# out by the National Institute of Standards and Technology
222# which claims to test C and Posix conformance.  If you want to pass PCTS, add
223#	-DPCTS
224# to the end of the "CFLAGS=" line.
225#
226# If you want strict compliance with XPG4 as of 1994-04-09, add
227#	-DXPG4_1994_04_09
228# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
229# 53 as a week number (rather than 52 or 53) for those days in January that
230# before the first Monday in January when a "%V" format is used and January 1
231# falls on a Friday, Saturday, or Sunday.
232
233CFLAGS=
234
235# Linker flags.  Default to $(LFLAGS) for backwards compatibility
236# to tzcode2012h and earlier.
237
238LDFLAGS=	$(LFLAGS)
239
240zic=		./zic
241ZIC=		$(zic) $(ZFLAGS)
242
243ZFLAGS=
244
245# The name of a Posix-compliant 'awk' on your system.
246AWK=		awk
247
248# The full path name of a Posix-compliant shell, preferably one that supports
249# the Korn shell's 'select' statement as an extension.
250# These days, Bash is the most popular.
251# It should be OK to set this to /bin/sh, on platforms where /bin/sh
252# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
253# is typically nicer if it works.
254KSHELL=		/bin/bash
255
256# The path where SGML DTDs are kept and the catalog file(s) to use when
257# validating.  The default is appropriate for Ubuntu 13.10.
258SGML_TOPDIR= /usr
259SGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd
260SGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224
261SGML_CATALOG_FILES= \
262  $(SGML_TOPDIR)/share/doc/w3-recs/html/www.w3.org/TR/1999/REC-html401-19991224/HTML4.cat
263
264# The name, arguments and environment of a program to validate your web pages.
265# See <http://www.jclark.com/sp/> for a validator, and
266# <http://validator.w3.org/source/> for a validation library.
267VALIDATE = nsgmls
268VALIDATE_FLAGS = -s -B -wall -wno-unused-param
269VALIDATE_ENV = \
270  SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) \
271  SGML_SEARCH_PATH=$(SGML_SEARCH_PATH) \
272  SP_CHARSET_FIXED=YES \
273  SP_ENCODING=UTF-8
274
275# This expensive test requires USE_LTZ.
276# To suppress it, define this macro to be empty.
277CHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
278
279# SAFE_CHAR is a regular expression that matches a safe character.
280# Some parts of this distribution are limited to safe characters;
281# others can use any UTF-8 character.
282# For now, the safe characters are a safe subset of ASCII.
283# The caller must set the shell variable 'sharp' to the character '#',
284# since Makefile macros cannot contain '#'.
285# TAB_CHAR is a single tab character, in single quotes.
286TAB_CHAR=	'	'
287SAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
288SAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
289SAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
290SAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
291SAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
292
293# OK_CHAR matches any character allowed in the distributed files.
294# This is the same as SAFE_CHAR, except that multibyte letters are
295# also allowed so that commentary can contain people's names and quote
296# non-English sources.  For non-letters the sources are limited to
297# ASCII renderings for the convenience of maintainers whose text editors
298# mishandle UTF-8 by default (e.g., XEmacs 21.4.22).
299OK_CHAR=	'[][:alpha:]'$(SAFE_CHARSET)'-]'
300
301# SAFE_LINE matches a line of safe characters.
302# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
303# this is so that comments can contain non-ASCII characters.
304# OK_LINE matches a line of OK characters.
305SAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
306SAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
307OK_LINE=	'^'$(OK_CHAR)'*$$'
308
309# Flags to give 'tar' when making a distribution.
310# Try to use flags appropriate for GNU tar.
311GNUTARFLAGS=	--numeric-owner --owner=0 --group=0 --mode=go+u,go-w
312TARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
313		 then echo $(GNUTARFLAGS); \
314		 else :; \
315		 fi`
316
317# Flags to give 'gzip' when making a distribution.
318GZIPFLAGS=	-9 ${GZIP_N_FLAG}
319
320###############################################################################
321
322#MAKE=		make
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
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
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=	checklinks.awk 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 $(ENCHILADA)
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_links check_sorted \
471		  check_tables check_web
472
473check_character_set: $(ENCHILADA)
474		LC_ALL=en_US.utf8 && export LC_ALL && \
475		sharp='#' && \
476		! grep -Env $(SAFE_LINE) Makefile $(MANS) date.1 $(MANTXTS) \
477			$(MISC) $(SOURCES) $(WEB_PAGES) && \
478		! grep -Env $(SAFE_SHARP_LINE) $(TDATA) backzone \
479			leapseconds yearistype.sh zone.tab && \
480		! grep -Env $(OK_LINE) $(ENCHILADA)
481
482check_white_space: $(ENCHILADA)
483		! grep -En ' '$(TAB_CHAR)"|$$(printf '[\f\r\v]')" $(ENCHILADA)
484		! grep -n '[[:space:]]$$' $(ENCHILADA)
485
486CHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
487
488check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
489		$(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu
490		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
491		$(AWK) '/^[^#]/ {print $$1}' iso3166.tab | LC_ALL=C sort -cu
492		$(AWK) '/^[^#]/ {print $$1}' zone.tab | LC_ALL=C sort -c
493		$(AWK) '/^[^#]/ {print substr($$0, 1, 2)}' zone1970.tab | \
494		  LC_ALL=C sort -c
495		$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
496		  LC_ALL=C sort -cu
497
498check_links:	checklinks.awk $(TDATA)
499		$(AWK) -f checklinks.awk $(TDATA)
500
501check_tables:	checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
502		for tab in $(ZONETABLES); do \
503		  $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
504		    || exit; \
505		done
506
507check_web:	$(WEB_PAGES)
508		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES)
509
510clean_misc:
511		rm -f core *.o *.out \
512		  date tzselect version.h zdump zic yearistype libtz.a
513clean:		clean_misc
514		rm -fr tzpublic
515
516maintainer-clean: clean
517		@echo 'This command is intended for maintainers to use; it'
518		@echo 'deletes files that may need special tools to rebuild.'
519		rm -f leapseconds $(MANTXTS) *.asc *.tar.gz
520
521names:
522		@echo $(ENCHILADA)
523
524public:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
525		tarballs signatures
526
527date.1.txt:	date.1
528newctime.3.txt:	newctime.3
529newstrftime.3.txt: newstrftime.3
530newtzset.3.txt:	newtzset.3
531time2posix.3.txt: time2posix.3
532tzfile.5.txt:	tzfile.5
533tzselect.8.txt:	tzselect.8
534zdump.8.txt:	zdump.8
535zic.8.txt:	zic.8
536
537$(MANTXTS):	workman.sh
538		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@
539
540# Set the time stamps to those of the git repository, if available,
541# and if the files have not changed since then.
542# This uses GNU 'touch' syntax 'touch -d@N FILE',
543# where N is the number of seconds since 1970.
544# If git or GNU 'touch' is absent, don't bother to sync with git timestamps.
545# Also, set the timestamp of each prebuilt file like 'leapseconds'
546# to be the maximum of the files it depends on.
547set-timestamps.out: $(ENCHILADA)
548		rm -f $@
549		if files=`git ls-files $(ENCHILADA)` && \
550		   touch -md @1 test.out; then \
551		  rm -f test.out && \
552		  for file in $$files; do \
553		    if git diff --quiet $$file; then \
554		      time=`git log -1 --format='tformat:%ct' $$file` && \
555		      touch -cmd @$$time $$file; \
556		    else \
557		      echo >&2 "$$file: warning: does not match repository"; \
558		    fi || exit; \
559		  done; \
560		fi
561		touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds
562		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
563		  touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \
564		    exit; \
565		done
566		touch $@
567
568# The zics below ensure that each data file can stand on its own.
569# We also do an all-files run to catch links to links.
570
571check_public:
572		$(MAKE) maintainer-clean
573		$(MAKE) "CFLAGS=$(GCC_DEBUG_FLAGS)" ALL
574		mkdir tzpublic
575		for i in $(TDATA) ; do \
576		  $(zic) -v -d tzpublic $$i 2>&1 || exit; \
577		done
578		$(zic) -v -d tzpublic $(TDATA)
579		rm -fr tzpublic
580
581# Check that the code works under various alternative
582# implementations of time_t.
583check_time_t_alternatives:
584		if diff -q Makefile Makefile 2>/dev/null; then \
585		  quiet_option='-q'; \
586		else \
587		  quiet_option=''; \
588		fi && \
589		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
590		for type in $(TIME_T_ALTERNATIVES); do \
591		  mkdir -p tzpublic/$$type && \
592		  $(MAKE) clean_misc && \
593		  $(MAKE) TOPDIR=`pwd`/tzpublic/$$type \
594		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
595		    REDO='$(REDO)' \
596		    install && \
597		  diff $$quiet_option -r \
598		    tzpublic/int64_t/etc/zoneinfo \
599		    tzpublic/$$type/etc/zoneinfo && \
600		  case $$type in \
601		  int32_t) range=-2147483648,2147483647;; \
602		  uint32_t) range=0,4294967296;; \
603		  int64_t) continue;; \
604		  *u*) range=0,10000000000;; \
605		  *) range=-10000000000,10000000000;; \
606		  esac && \
607		  echo checking $$type zones ... && \
608		  tzpublic/int64_t/etc/zdump -V -t $$range $$zones \
609		      >tzpublic/int64_t.out && \
610		  tzpublic/$$type/etc/zdump -V -t $$range $$zones \
611		      >tzpublic/$$type.out && \
612		  diff -u tzpublic/int64_t.out tzpublic/$$type.out \
613		    || exit; \
614		done
615		rm -fr tzpublic
616
617tarballs:	tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
618
619tzcode$(VERSION).tar.gz: set-timestamps.out
620		LC_ALL=C && export LC_ALL && \
621		tar $(TARFLAGS) -cf - \
622		    $(COMMON) $(DOCS) $(SOURCES) | \
623		  ${TOOL_GZIP} $(GZIPFLAGS) > $@
624
625tzdata$(VERSION).tar.gz: set-timestamps.out
626		LC_ALL=C && export LC_ALL && \
627		tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
628		  ${TOOL_GZIP} $(GZIPFLAGS) > $@
629
630signatures:	tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc
631
632tzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
633		gpg --armor --detach-sign $?
634
635tzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
636		gpg --armor --detach-sign $?
637
638typecheck:
639		$(MAKE) clean
640		for i in "long long" unsigned; \
641		do \
642			$(MAKE) CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
643			./zdump -v Europe/Rome ; \
644			$(MAKE) clean ; \
645		done
646
647zonenames:	$(TDATA)
648		@$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
649
650asctime.o:	private.h tzfile.h
651date.o:		private.h
652difftime.o:	private.h
653localtime.o:	private.h tzfile.h
654strftime.o:	private.h tzfile.h
655zdump.o:	version.h
656zic.o:		private.h tzfile.h version.h
657
658.KEEP_STATE:
659
660.PHONY: ALL INSTALL all
661.PHONY: check check_character_set check_links
662.PHONY: check_public check_sorted check_tables
663.PHONY: check_time_t_alternatives check_web check_white_space clean clean_misc
664.PHONY: install maintainer-clean names posix_packrat posix_only posix_right
665.PHONY: public right_only right_posix signatures tarballs typecheck
666.PHONY: zonenames zones
667