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