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