Makefile revision 1.30
11.1Smlelstv# This file is in the public domain, so clarified as of
21.1Smlelstv# 2009-05-17 by Arthur David Olson.
31.1Smlelstv
41.10Schristos# Package name for the code distribution.
51.10SchristosPACKAGE=	tzcode
61.10Schristos
71.6Schristos# Version numbers of the code and data distributions.
81.30SchristosVERSION=	2015f
91.9Schristos
101.9Schristos# Email address for bug reports.
111.9SchristosBUGEMAIL=	tz@iana.org
121.6Schristos
131.1Smlelstv# Change the line below for your time zone (after finding the zone you want in
141.1Smlelstv# the time zone files, or adding it to a time zone file).
151.1Smlelstv# Alternately, if you discover you've got the wrong time zone, you can just
161.1Smlelstv#	zic -l rightzone
171.1Smlelstv# to correct things.
181.1Smlelstv# Use the command
191.1Smlelstv#	make zonenames
201.1Smlelstv# to get a list of the values you can use for LOCALTIME.
211.1Smlelstv
221.4SchristosLOCALTIME=	GMT
231.1Smlelstv
241.1Smlelstv# If you want something other than Eastern United States time as a template
251.1Smlelstv# for handling POSIX-style time zone environment variables,
261.1Smlelstv# change the line below (after finding the zone you want in the
271.1Smlelstv# time zone files, or adding it to a time zone file).
281.1Smlelstv# (When a POSIX-style environment variable is handled, the rules in the
291.1Smlelstv# template file are used to determine "spring forward" and "fall back" days and
301.15Schristos# times; the environment variable itself specifies UT offsets of standard and
311.1Smlelstv# summer time.)
321.1Smlelstv# Alternately, if you discover you've got the wrong time zone, you can just
331.1Smlelstv#	zic -p rightzone
341.1Smlelstv# to correct things.
351.1Smlelstv# Use the command
361.1Smlelstv#	make zonenames
371.1Smlelstv# to get a list of the values you can use for POSIXRULES.
381.1Smlelstv# If you want POSIX compatibility, use "America/New_York".
391.1Smlelstv
401.1SmlelstvPOSIXRULES=	America/New_York
411.1Smlelstv
421.1Smlelstv# Also see TZDEFRULESTRING below, which takes effect only
431.1Smlelstv# if the time zone files cannot be accessed.
441.1Smlelstv
451.1Smlelstv# Everything gets put in subdirectories of. . .
461.1Smlelstv
471.1SmlelstvTOPDIR=		/usr/local
481.1Smlelstv
491.1Smlelstv# "Compiled" time zone information is placed in the "TZDIR" directory
501.1Smlelstv# (and subdirectories).
511.1Smlelstv# Use an absolute path name for TZDIR unless you're just testing the software.
521.1Smlelstv
531.15SchristosTZDIR_BASENAME=	zoneinfo
541.15SchristosTZDIR=		$(TOPDIR)/etc/$(TZDIR_BASENAME)
551.1Smlelstv
561.14Schristos# Types to try, as an alternative to time_t.  int64_t should be first.
571.14SchristosTIME_T_ALTERNATIVES= int64_t int32_t uint32_t uint64_t
581.14Schristos
591.1Smlelstv# The "tzselect", "zic", and "zdump" commands get installed in. . .
601.1Smlelstv
611.1SmlelstvETCDIR=		$(TOPDIR)/etc
621.1Smlelstv
631.1Smlelstv# If you "make INSTALL", the "date" command gets installed in. . .
641.1Smlelstv
651.1SmlelstvBINDIR=		$(TOPDIR)/bin
661.1Smlelstv
671.1Smlelstv# Manual pages go in subdirectories of. . .
681.1Smlelstv
691.1SmlelstvMANDIR=		$(TOPDIR)/man
701.1Smlelstv
711.1Smlelstv# Library functions are put in an archive in LIBDIR.
721.1Smlelstv
731.1SmlelstvLIBDIR=		$(TOPDIR)/lib
741.1Smlelstv
751.1Smlelstv# If you always want time values interpreted as "seconds since the epoch
761.1Smlelstv# (not counting leap seconds)", use
771.1Smlelstv#	REDO=		posix_only
781.1Smlelstv# below.  If you always want right time values interpreted as "seconds since
791.1Smlelstv# the epoch" (counting leap seconds)", use
801.1Smlelstv#	REDO=		right_only
811.1Smlelstv# below.  If you want both sets of data available, with leap seconds not
821.1Smlelstv# counted normally, use
831.1Smlelstv#	REDO=		posix_right
841.1Smlelstv# below.  If you want both sets of data available, with leap seconds counted
851.1Smlelstv# normally, use
861.1Smlelstv#	REDO=		right_posix
871.23Schristos# below.  If you want just POSIX-compatible time values, but with
881.23Schristos# out-of-scope and often-wrong data from the file 'backzone', use
891.23Schristos#	REDO=		posix_packrat
901.1Smlelstv# POSIX mandates that leap seconds not be counted; for compatibility with it,
911.23Schristos# use "posix_only", "posix_right", or "posix_packrat".
921.1Smlelstv
931.1SmlelstvREDO=		posix_right
941.1Smlelstv
951.1Smlelstv# Since "." may not be in PATH...
961.1Smlelstv
971.1SmlelstvYEARISTYPE=	./yearistype
981.1Smlelstv
991.1Smlelstv# Non-default libraries needed to link.
1001.22Schristos# Add -lintl if you want to use 'gettext' on Solaris.
1011.1SmlelstvLDLIBS=
1021.1Smlelstv
1031.1Smlelstv# Add the following to the end of the "CFLAGS=" line as needed.
1041.19Schristos#  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
1051.14Schristos#  -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS)
1061.22Schristos#  -DHAVE_GETTEXT=1 if 'gettext' works (GNU, Linux, Solaris); also see LDLIBS
1071.1Smlelstv#  -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
1081.1Smlelstv#	ctime_r and asctime_r incompatibly with the POSIX standard (Solaris 8).
1091.14Schristos#  -DHAVE_INTTYPES_H=1 if you have a pre-C99 compiler with "inttypes.h"
1101.16Schristos#  -DHAVE_LINK=0 if your system lacks a link function
1111.23Schristos#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
1121.23Schristos#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
1131.23Schristos#	This defaults to 1 if a working localtime_rz seems to be available.
1141.23Schristos#	localtime_rz can make zdump significantly faster, but is nonstandard.
1151.1Smlelstv#  -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h"
1161.23Schristos#  -DHAVE_STRFTIME_L=1 if <time.h> declares locale_t and strftime_l
1171.23Schristos#	This defaults to 0 if _POSIX_VERSION < 200809, 1 otherwise.
1181.28Schristos#  -DHAVE_STRDUP=0 if your system lacks the strdup function
1191.1Smlelstv#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
1201.1Smlelstv#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h"
1211.1Smlelstv#  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h"
1221.23Schristos#  -DHAVE_TZSET=0 if your system lacks a tzset function
1231.1Smlelstv#  -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
1241.14Schristos#  -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
1251.14Schristos#	if you do not want run time warnings about formats that may cause
1261.14Schristos#	year 2000 grief
1271.24Schristos#  -Dssize_t=long on ancient hosts that lack ssize_t
1281.23Schristos#  -DTHREAD_SAFE=1 to make localtime.c thread-safe, as POSIX requires;
1291.23Schristos#	not needed by the main-program tz code, which is single-threaded.
1301.23Schristos#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
1311.14Schristos#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
1321.1Smlelstv#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
1331.22Schristos#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
1341.1Smlelstv#	the default is system-supplied, typically "/usr/lib/locale"
1351.14Schristos#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
1361.23Schristos#  -DUNINIT_TRAP=1 if reading uninitialized storage can cause problems
1371.23Schristos#	other than simply getting garbage data
1381.23Schristos#  -DUSE_LTZ=0 to build zdump with the system time zone library
1391.23Schristos#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
1401.11Schristos#  -DNO_ERROR_IN_DST_GAP=1
1411.11Schristos#	if you want mktime() not to return an error in the DST gap.
1421.1Smlelstv#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
1431.1Smlelstv#	(or some other number) to set the maximum time zone abbreviation length
1441.1Smlelstv#	that zic will accept without a warning (the default is 6)
1451.30Schristos#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
1461.7SchristosGCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
1471.7Schristos	-Wall -Wextra \
1481.28Schristos	-Wbad-function-cast -Wcast-align -Wdate-time \
1491.22Schristos	-Wdeclaration-after-statement \
1501.28Schristos	-Wdouble-promotion \
1511.22Schristos	-Wformat=2 -Winit-self -Wjump-misses-init \
1521.28Schristos	-Wlogical-op -Wmissing-prototypes -Wnested-externs \
1531.28Schristos	-Wold-style-definition -Woverlength-strings -Wpointer-arith \
1541.7Schristos	-Wshadow -Wstrict-prototypes -Wsuggest-attribute=const \
1551.22Schristos	-Wsuggest-attribute=format -Wsuggest-attribute=noreturn \
1561.22Schristos	-Wsuggest-attribute=pure -Wtrampolines \
1571.28Schristos	-Wunused -Wwrite-strings \
1581.28Schristos	-Wno-address -Wno-format-nonliteral -Wno-sign-compare \
1591.28Schristos	-Wno-type-limits -Wno-unused-parameter
1601.1Smlelstv#
1611.1Smlelstv# If you want to use System V compatibility code, add
1621.1Smlelstv#	-DUSG_COMPAT
1631.1Smlelstv# to the end of the "CFLAGS=" line.  This arrange for "timezone" and "daylight"
1641.1Smlelstv# variables to be kept up-to-date by the time conversion functions.  Neither
1651.1Smlelstv# "timezone" nor "daylight" is described in X3J11's work.
1661.1Smlelstv#
1671.1Smlelstv# If your system has a "GMT offset" field in its "struct tm"s
1681.1Smlelstv# (or if you decide to add such a field in your system's "time.h" file),
1691.1Smlelstv# add the name to a define such as
1701.1Smlelstv#	-DTM_GMTOFF=tm_gmtoff
1711.23Schristos# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
1721.23Schristos# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
1731.23Schristos# Similarly, if your system has a "zone abbreviation" field, define
1741.1Smlelstv#	-DTM_ZONE=tm_zone
1751.23Schristos# and define NO_TM_ZONE to suppress any guessing.  These two fields are not
1761.23Schristos# required by POSIX, but are widely available on GNU/Linux and BSD systems.
1771.1Smlelstv#
1781.1Smlelstv# If you want functions that were inspired by early versions of X3J11's work,
1791.1Smlelstv# add
1801.1Smlelstv#	-DSTD_INSPIRED
1811.1Smlelstv# to the end of the "CFLAGS=" line.  This arranges for the functions
1821.1Smlelstv# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
1831.1Smlelstv# "posix2time", and "time2posix" to be added to the time conversion library.
1841.1Smlelstv# "tzsetwall" is like "tzset" except that it arranges for local wall clock
1851.1Smlelstv# time (rather than the time specified in the TZ environment variable)
1861.1Smlelstv# to be used.
1871.1Smlelstv# "offtime" is like "gmtime" except that it accepts a second (long) argument
1881.1Smlelstv# that gives an offset to add to the time_t when converting it.
1891.1Smlelstv# "timelocal" is equivalent to "mktime".
1901.1Smlelstv# "timegm" is like "timelocal" except that it turns a struct tm into
1911.15Schristos# a time_t using UT (rather than local time as "timelocal" does).
1921.1Smlelstv# "timeoff" is like "timegm" except that it accepts a second (long) argument
1931.1Smlelstv# that gives an offset to use when converting to a time_t.
1941.1Smlelstv# "posix2time" and "time2posix" are described in an included manual page.
1951.1Smlelstv# X3J11's work does not describe any of these functions.
1961.1Smlelstv# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
1971.1Smlelstv# These functions may well disappear in future releases of the time
1981.1Smlelstv# conversion package.
1991.1Smlelstv#
2001.23Schristos# If you don't want functions that were inspired by NetBSD, add
2011.23Schristos#	-DNETBSD_INSPIRED=0
2021.23Schristos# to the end of the "CFLAGS=" line.  Otherwise, the functions
2031.23Schristos# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
2041.23Schristos# time library, and if STD_INSPIRED is also defined the functions
2051.23Schristos# "posix2time_z" and "time2posix_z" are added as well.
2061.23Schristos# The functions ending in "_z" (or "_rz") are like their unsuffixed
2071.23Schristos# (or suffixed-by-"_r") counterparts, except with an extra first
2081.23Schristos# argument of opaque type timezone_t that specifies the time zone.
2091.23Schristos# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
2101.23Schristos#
2111.1Smlelstv# If you want to allocate state structures in localtime, add
2121.1Smlelstv#	-DALL_STATE
2131.1Smlelstv# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
2141.1Smlelstv#
2151.1Smlelstv# If you want an "altzone" variable (a la System V Release 3.1), add
2161.1Smlelstv#	-DALTZONE
2171.1Smlelstv# to the end of the "CFLAGS=" line.
2181.1Smlelstv# This variable is not described in X3J11's work.
2191.1Smlelstv#
2201.1Smlelstv# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
2211.1Smlelstv# out by the National Institute of Standards and Technology
2221.1Smlelstv# which claims to test C and Posix conformance.  If you want to pass PCTS, add
2231.1Smlelstv#	-DPCTS
2241.1Smlelstv# to the end of the "CFLAGS=" line.
2251.1Smlelstv#
2261.1Smlelstv# If you want strict compliance with XPG4 as of 1994-04-09, add
2271.1Smlelstv#	-DXPG4_1994_04_09
2281.1Smlelstv# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
2291.1Smlelstv# 53 as a week number (rather than 52 or 53) for those days in January that
2301.1Smlelstv# before the first Monday in January when a "%V" format is used and January 1
2311.1Smlelstv# falls on a Friday, Saturday, or Sunday.
2321.1Smlelstv
2331.1SmlelstvCFLAGS=
2341.1Smlelstv
2351.9Schristos# Linker flags.  Default to $(LFLAGS) for backwards compatibility
2361.9Schristos# to tzcode2012h and earlier.
2371.9Schristos
2381.9SchristosLDFLAGS=	$(LFLAGS)
2391.1Smlelstv
2401.1Smlelstvzic=		./zic
2411.1SmlelstvZIC=		$(zic) $(ZFLAGS)
2421.1Smlelstv
2431.15SchristosZFLAGS=
2441.15Schristos
2451.22Schristos# The name of a Posix-compliant 'awk' on your system.
2461.9SchristosAWK=		awk
2471.9Schristos
2481.16Schristos# The full path name of a Posix-compliant shell, preferably one that supports
2491.16Schristos# the Korn shell's 'select' statement as an extension.
2501.16Schristos# These days, Bash is the most popular.
2511.16Schristos# It should be OK to set this to /bin/sh, on platforms where /bin/sh
2521.16Schristos# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
2531.16Schristos# is typically nicer if it works.
2541.9SchristosKSHELL=		/bin/bash
2551.1Smlelstv
2561.18Schristos# The path where SGML DTDs are kept and the catalog file(s) to use when
2571.18Schristos# validating.  The default is appropriate for Ubuntu 13.10.
2581.10SchristosSGML_TOPDIR= /usr
2591.9SchristosSGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd
2601.9SchristosSGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224
2611.18SchristosSGML_CATALOG_FILES= \
2621.18Schristos  $(SGML_TOPDIR)/share/doc/w3-recs/html/www.w3.org/TR/1999/REC-html401-19991224/HTML4.cat
2631.1Smlelstv
2641.1Smlelstv# The name, arguments and environment of a program to validate your web pages.
2651.1Smlelstv# See <http://www.jclark.com/sp/> for a validator, and
2661.1Smlelstv# <http://validator.w3.org/source/> for a validation library.
2671.1SmlelstvVALIDATE = nsgmls
2681.1SmlelstvVALIDATE_FLAGS = -s -B -wall -wno-unused-param
2691.1SmlelstvVALIDATE_ENV = \
2701.1Smlelstv  SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) \
2711.1Smlelstv  SGML_SEARCH_PATH=$(SGML_SEARCH_PATH) \
2721.1Smlelstv  SP_CHARSET_FIXED=YES \
2731.1Smlelstv  SP_ENCODING=UTF-8
2741.1Smlelstv
2751.23Schristos# This expensive test requires USE_LTZ.
2761.23Schristos# To suppress it, define this macro to be empty.
2771.23SchristosCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
2781.23Schristos
2791.22Schristos# SAFE_CHAR is a regular expression that matches a safe character.
2801.22Schristos# Some parts of this distribution are limited to safe characters;
2811.22Schristos# others can use any UTF-8 character.
2821.22Schristos# For now, the safe characters are a safe subset of ASCII.
2831.9Schristos# The caller must set the shell variable 'sharp' to the character '#',
2841.9Schristos# since Makefile macros cannot contain '#'.
2851.9Schristos# TAB_CHAR is a single tab character, in single quotes.
2861.9SchristosTAB_CHAR=	'	'
2871.22SchristosSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
2881.22SchristosSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
2891.22SchristosSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
2901.29SchristosSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
2911.29SchristosSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
2921.29Schristos
2931.29Schristos# OK_CHAR matches any character allowed in the distributed files.
2941.29Schristos# This is the same as SAFE_CHAR, except that multibyte letters are
2951.29Schristos# also allowed so that commentary can contain people's names and quote
2961.29Schristos# non-English sources.  For non-letters the sources are limited to
2971.22Schristos# ASCII renderings for the convenience of maintainers whose text editors
2981.22Schristos# mishandle UTF-8 by default (e.g., XEmacs 21.4.22).
2991.29SchristosOK_CHAR=	'[][:alpha:]'$(SAFE_CHARSET)'-]'
3001.22Schristos
3011.22Schristos# SAFE_LINE matches a line of safe characters.
3021.29Schristos# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
3031.22Schristos# this is so that comments can contain non-ASCII characters.
3041.29Schristos# OK_LINE matches a line of OK characters.
3051.22SchristosSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
3061.29SchristosSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
3071.29SchristosOK_LINE=	'^'$(OK_CHAR)'*$$'
3081.9Schristos
3091.6Schristos# Flags to give 'tar' when making a distribution.
3101.6Schristos# Try to use flags appropriate for GNU tar.
3111.6SchristosGNUTARFLAGS=	--numeric-owner --owner=0 --group=0 --mode=go+u,go-w
3121.6SchristosTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
3131.6Schristos		 then echo $(GNUTARFLAGS); \
3141.6Schristos		 else :; \
3151.6Schristos		 fi`
3161.6Schristos
3171.6Schristos# Flags to give 'gzip' when making a distribution.
3181.21SapbGZIPFLAGS=	-9 ${GZIP_N_FLAG}
3191.6Schristos
3201.1Smlelstv###############################################################################
3211.1Smlelstv
3221.29Schristos#MAKE=		make
3231.29Schristos
3241.1Smlelstvcc=		cc
3251.1SmlelstvCC=		$(cc) -DTZDIR=\"$(TZDIR)\"
3261.1Smlelstv
3271.16SchristosAR=		ar
3281.16Schristos
3291.16Schristos# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
3301.16SchristosRANLIB=		:
3311.16Schristos
3321.28SchristosTZCOBJS=	zic.o
3331.23SchristosTZDOBJS=	zdump.o localtime.o asctime.o
3341.1SmlelstvDATEOBJS=	date.o localtime.o strftime.o asctime.o
3351.1SmlelstvLIBSRCS=	localtime.c asctime.c difftime.c
3361.1SmlelstvLIBOBJS=	localtime.o asctime.o difftime.o
3371.1SmlelstvHEADERS=	tzfile.h private.h
3381.28SchristosNONLIBSRCS=	zic.c zdump.c
3391.1SmlelstvNEWUCBSRCS=	date.c strftime.c
3401.23SchristosSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
3411.23Schristos			tzselect.ksh workman.sh
3421.1SmlelstvMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
3431.1Smlelstv			tzfile.5 tzselect.8 zic.8 zdump.8
3441.16SchristosMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
3451.16Schristos			time2posix.3.txt \
3461.16Schristos			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
3471.16Schristos			date.1.txt
3481.23SchristosCOMMON=		CONTRIBUTING Makefile NEWS README Theory
3491.22SchristosWEB_PAGES=	tz-art.htm tz-link.htm
3501.23SchristosDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
3511.1SmlelstvPRIMARY_YDATA=	africa antarctica asia australasia \
3521.1Smlelstv		europe northamerica southamerica
3531.4SchristosYDATA=		$(PRIMARY_YDATA) pacificnew etcetera backward
3541.4SchristosNDATA=		systemv factory
3551.16SchristosTDATA=		$(YDATA) $(NDATA)
3561.22SchristosZONETABLES=	zone1970.tab zone.tab
3571.22SchristosTABDATA=	iso3166.tab leapseconds $(ZONETABLES)
3581.16SchristosLEAP_DEPS=	leapseconds.awk leap-seconds.list
3591.23SchristosDATA=		$(YDATA) $(NDATA) backzone $(TABDATA) \
3601.23Schristos			leap-seconds.list yearistype.sh
3611.26SchristosAWK_SCRIPTS=	checklinks.awk checktab.awk leapseconds.awk
3621.23SchristosMISC=		$(AWK_SCRIPTS) zoneinfo2tdf.pl
3631.7SchristosENCHILADA=	$(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC)
3641.1Smlelstv
3651.1Smlelstv# And for the benefit of csh users on systems that assume the user
3661.1Smlelstv# shell should be used to handle commands in Makefiles. . .
3671.1Smlelstv
3681.1SmlelstvSHELL=		/bin/sh
3691.1Smlelstv
3701.16Schristosall:		tzselect zic zdump libtz.a $(TABDATA)
3711.1Smlelstv
3721.29SchristosALL:		all date $(ENCHILADA)
3731.1Smlelstv
3741.16Schristosinstall:	all $(DATA) $(REDO) $(MANS)
3751.16Schristos		mkdir -p $(DESTDIR)$(ETCDIR) $(DESTDIR)$(TZDIR) \
3761.16Schristos			$(DESTDIR)$(LIBDIR) \
3771.16Schristos			$(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \
3781.16Schristos			$(DESTDIR)$(MANDIR)/man8
3791.1Smlelstv		$(ZIC) -y $(YEARISTYPE) \
3801.15Schristos			-d $(DESTDIR)$(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
3811.22Schristos		cp -f iso3166.tab $(ZONETABLES) $(DESTDIR)$(TZDIR)/.
3821.15Schristos		cp tzselect zic zdump $(DESTDIR)$(ETCDIR)/.
3831.16Schristos		cp libtz.a $(DESTDIR)$(LIBDIR)/.
3841.16Schristos		$(RANLIB) $(DESTDIR)$(LIBDIR)/libtz.a
3851.16Schristos		cp -f newctime.3 newtzset.3 $(DESTDIR)$(MANDIR)/man3/.
3861.16Schristos		cp -f tzfile.5 $(DESTDIR)$(MANDIR)/man5/.
3871.16Schristos		cp -f tzselect.8 zdump.8 zic.8 $(DESTDIR)$(MANDIR)/man8/.
3881.1Smlelstv
3891.1SmlelstvINSTALL:	ALL install date.1
3901.16Schristos		mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1
3911.15Schristos		cp date $(DESTDIR)$(BINDIR)/.
3921.16Schristos		cp -f date.1 $(DESTDIR)$(MANDIR)/man1/.
3931.1Smlelstv
3941.6Schristosversion.h:
3951.9Schristos		(echo 'static char const PKGVERSION[]="($(PACKAGE)) ";' && \
3961.9Schristos		 echo 'static char const TZVERSION[]="$(VERSION)";' && \
3971.9Schristos		 echo 'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";') >$@
3981.6Schristos
3991.1Smlelstvzdump:		$(TZDOBJS)
4001.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
4011.1Smlelstv
4021.1Smlelstvzic:		$(TZCOBJS) yearistype
4031.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
4041.1Smlelstv
4051.1Smlelstvyearistype:	yearistype.sh
4061.1Smlelstv		cp yearistype.sh yearistype
4071.1Smlelstv		chmod +x yearistype
4081.1Smlelstv
4091.16Schristosleapseconds:	$(LEAP_DEPS)
4101.15Schristos		$(AWK) -f leapseconds.awk leap-seconds.list >$@
4111.15Schristos
4121.1Smlelstvposix_only:	zic $(TDATA)
4131.15Schristos		$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
4141.15Schristos			-L /dev/null $(TDATA)
4151.1Smlelstv
4161.1Smlelstvright_only:	zic leapseconds $(TDATA)
4171.15Schristos		$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
4181.15Schristos			-L leapseconds $(TDATA)
4191.1Smlelstv
4201.1Smlelstv# In earlier versions of this makefile, the other two directories were
4211.1Smlelstv# subdirectories of $(TZDIR).  However, this led to configuration errors.
4221.1Smlelstv# For example, with posix_right under the earlier scheme,
4231.1Smlelstv# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
4241.1Smlelstv# but gmtime without leap seconds, which led to problems with applications
4251.1Smlelstv# like sendmail that subtract gmtime from localtime.
4261.1Smlelstv# Therefore, the other two directories are now siblings of $(TZDIR).
4271.1Smlelstv# You must replace all of $(TZDIR) to switch from not using leap seconds
4281.1Smlelstv# to using them, or vice versa.
4291.15Schristosright_posix:	right_only leapseconds
4301.15Schristos		rm -fr $(DESTDIR)$(TZDIR)-leaps
4311.15Schristos		ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-leaps || \
4321.15Schristos		  $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-leaps \
4331.15Schristos			-L leapseconds $(TDATA)
4341.15Schristos		$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-posix \
4351.15Schristos			-L /dev/null $(TDATA)
4361.15Schristos
4371.15Schristosposix_right:	posix_only leapseconds
4381.15Schristos		rm -fr $(DESTDIR)$(TZDIR)-posix
4391.15Schristos		ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-posix || \
4401.15Schristos		  $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-posix \
4411.15Schristos			-L /dev/null $(TDATA)
4421.15Schristos		$(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-leaps \
4431.15Schristos			-L leapseconds $(TDATA)
4441.1Smlelstv
4451.23Schristosposix_packrat:	posix_only backzone
4461.23Schristos		$(AWK) '/^Rule/' $(TDATA) | \
4471.23Schristos		  $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
4481.23Schristos			-L /dev/null - backzone
4491.23Schristos
4501.1Smlelstvzones:		$(REDO)
4511.1Smlelstv
4521.16Schristoslibtz.a:	$(LIBOBJS)
4531.16Schristos		$(AR) ru $@ $(LIBOBJS)
4541.16Schristos		$(RANLIB) $@
4551.1Smlelstv
4561.1Smlelstvdate:		$(DATEOBJS)
4571.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
4581.1Smlelstv
4591.1Smlelstvtzselect:	tzselect.ksh
4601.1Smlelstv		sed \
4611.9Schristos			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
4621.1Smlelstv			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
4631.9Schristos			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
4641.9Schristos			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
4651.1Smlelstv			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
4661.9Schristos			-e 's|\(TZVERSION\)=.*|\1=$(VERSION)|' \
4671.1Smlelstv			<$? >$@
4681.1Smlelstv		chmod +x $@
4691.1Smlelstv
4701.26Schristoscheck:		check_character_set check_white_space check_links check_sorted \
4711.23Schristos		  check_tables check_web
4721.9Schristos
4731.9Schristoscheck_character_set: $(ENCHILADA)
4741.22Schristos		LC_ALL=en_US.utf8 && export LC_ALL && \
4751.22Schristos		sharp='#' && \
4761.29Schristos		! grep -Env $(SAFE_LINE) Makefile $(MANS) date.1 $(MANTXTS) \
4771.22Schristos			$(MISC) $(SOURCES) $(WEB_PAGES) && \
4781.23Schristos		! grep -Env $(SAFE_SHARP_LINE) $(TDATA) backzone \
4791.29Schristos			leapseconds yearistype.sh zone.tab && \
4801.29Schristos		! grep -Env $(OK_LINE) $(ENCHILADA)
4811.22Schristos
4821.23Schristoscheck_white_space: $(ENCHILADA)
4831.26Schristos		! grep -En ' '$(TAB_CHAR)"|$$(printf '[\f\r\v]')" $(ENCHILADA)
4841.27Schristos		! grep -n '[[:space:]]$$' $(ENCHILADA)
4851.23Schristos
4861.23SchristosCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
4871.23Schristos
4881.23Schristoscheck_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
4891.23Schristos		$(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu
4901.23Schristos		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
4911.23Schristos		$(AWK) '/^[^#]/ {print $$1}' iso3166.tab | LC_ALL=C sort -cu
4921.23Schristos		$(AWK) '/^[^#]/ {print $$1}' zone.tab | LC_ALL=C sort -c
4931.23Schristos		$(AWK) '/^[^#]/ {print substr($$0, 1, 2)}' zone1970.tab | \
4941.23Schristos		  LC_ALL=C sort -c
4951.23Schristos		$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
4961.23Schristos		  LC_ALL=C sort -cu
4971.23Schristos
4981.26Schristoscheck_links:	checklinks.awk $(TDATA)
4991.26Schristos		$(AWK) -f checklinks.awk $(TDATA)
5001.26Schristos
5011.22Schristoscheck_tables:	checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
5021.22Schristos		for tab in $(ZONETABLES); do \
5031.22Schristos		  $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
5041.22Schristos		    || exit; \
5051.22Schristos		done
5061.1Smlelstv
5071.1Smlelstvcheck_web:	$(WEB_PAGES)
5081.1Smlelstv		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES)
5091.1Smlelstv
5101.14Schristosclean_misc:
5111.6Schristos		rm -f core *.o *.out \
5121.18Schristos		  date tzselect version.h zdump zic yearistype libtz.a
5131.14Schristosclean:		clean_misc
5141.16Schristos		rm -fr tzpublic
5151.1Smlelstv
5161.1Smlelstvmaintainer-clean: clean
5171.1Smlelstv		@echo 'This command is intended for maintainers to use; it'
5181.1Smlelstv		@echo 'deletes files that may need special tools to rebuild.'
5191.16Schristos		rm -f leapseconds $(MANTXTS) *.asc *.tar.gz
5201.1Smlelstv
5211.1Smlelstvnames:
5221.1Smlelstv		@echo $(ENCHILADA)
5231.1Smlelstv
5241.23Schristospublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
5251.16Schristos		tarballs signatures
5261.16Schristos
5271.16Schristosdate.1.txt:	date.1
5281.16Schristosnewctime.3.txt:	newctime.3
5291.16Schristosnewstrftime.3.txt: newstrftime.3
5301.16Schristosnewtzset.3.txt:	newtzset.3
5311.16Schristostime2posix.3.txt: time2posix.3
5321.16Schristostzfile.5.txt:	tzfile.5
5331.16Schristostzselect.8.txt:	tzselect.8
5341.16Schristoszdump.8.txt:	zdump.8
5351.16Schristoszic.8.txt:	zic.8
5361.16Schristos
5371.16Schristos$(MANTXTS):	workman.sh
5381.16Schristos		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@
5391.9Schristos
5401.6Schristos# Set the time stamps to those of the git repository, if available,
5411.6Schristos# and if the files have not changed since then.
5421.6Schristos# This uses GNU 'touch' syntax 'touch -d@N FILE',
5431.6Schristos# where N is the number of seconds since 1970.
5441.16Schristos# If git or GNU 'touch' is absent, don't bother to sync with git timestamps.
5451.16Schristos# Also, set the timestamp of each prebuilt file like 'leapseconds'
5461.16Schristos# to be the maximum of the files it depends on.
5471.16Schristosset-timestamps.out: $(ENCHILADA)
5481.16Schristos		rm -f $@
5491.16Schristos		if files=`git ls-files $(ENCHILADA)` && \
5501.16Schristos		   touch -md @1 test.out; then \
5511.16Schristos		  rm -f test.out && \
5521.16Schristos		  for file in $$files; do \
5531.16Schristos		    if git diff --quiet $$file; then \
5541.16Schristos		      time=`git log -1 --format='tformat:%ct' $$file` && \
5551.16Schristos		      touch -cmd @$$time $$file; \
5561.16Schristos		    else \
5571.16Schristos		      echo >&2 "$$file: warning: does not match repository"; \
5581.16Schristos		    fi || exit; \
5591.16Schristos		  done; \
5601.16Schristos		fi
5611.16Schristos		touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds
5621.16Schristos		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
5631.16Schristos		  touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \
5641.16Schristos		    exit; \
5651.6Schristos		done
5661.16Schristos		touch $@
5671.6Schristos
5681.1Smlelstv# The zics below ensure that each data file can stand on its own.
5691.1Smlelstv# We also do an all-files run to catch links to links.
5701.1Smlelstv
5711.29Schristoscheck_public:
5721.29Schristos		$(MAKE) maintainer-clean
5731.29Schristos		$(MAKE) "CFLAGS=$(GCC_DEBUG_FLAGS)" ALL
5741.9Schristos		mkdir tzpublic
5751.9Schristos		for i in $(TDATA) ; do \
5761.9Schristos		  $(zic) -v -d tzpublic $$i 2>&1 || exit; \
5771.9Schristos		done
5781.9Schristos		$(zic) -v -d tzpublic $(TDATA)
5791.16Schristos		rm -fr tzpublic
5801.9Schristos
5811.14Schristos# Check that the code works under various alternative
5821.14Schristos# implementations of time_t.
5831.14Schristoscheck_time_t_alternatives:
5841.23Schristos		if diff -q Makefile Makefile 2>/dev/null; then \
5851.23Schristos		  quiet_option='-q'; \
5861.23Schristos		else \
5871.23Schristos		  quiet_option=''; \
5881.23Schristos		fi && \
5891.22Schristos		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
5901.14Schristos		for type in $(TIME_T_ALTERNATIVES); do \
5911.16Schristos		  mkdir -p tzpublic/$$type && \
5921.29Schristos		  $(MAKE) clean_misc && \
5931.29Schristos		  $(MAKE) TOPDIR=`pwd`/tzpublic/$$type \
5941.14Schristos		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
5951.23Schristos		    REDO='$(REDO)' \
5961.14Schristos		    install && \
5971.23Schristos		  diff $$quiet_option -r \
5981.23Schristos		    tzpublic/int64_t/etc/zoneinfo \
5991.23Schristos		    tzpublic/$$type/etc/zoneinfo && \
6001.14Schristos		  case $$type in \
6011.14Schristos		  int32_t) range=-2147483648,2147483647;; \
6021.14Schristos		  uint32_t) range=0,4294967296;; \
6031.14Schristos		  int64_t) continue;; \
6041.14Schristos		  *u*) range=0,10000000000;; \
6051.14Schristos		  *) range=-10000000000,10000000000;; \
6061.14Schristos		  esac && \
6071.14Schristos		  echo checking $$type zones ... && \
6081.14Schristos		  tzpublic/int64_t/etc/zdump -V -t $$range $$zones \
6091.14Schristos		      >tzpublic/int64_t.out && \
6101.14Schristos		  tzpublic/$$type/etc/zdump -V -t $$range $$zones \
6111.14Schristos		      >tzpublic/$$type.out && \
6121.14Schristos		  diff -u tzpublic/int64_t.out tzpublic/$$type.out \
6131.14Schristos		    || exit; \
6141.14Schristos		done
6151.16Schristos		rm -fr tzpublic
6161.14Schristos
6171.9Schristostarballs:	tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
6181.9Schristos
6191.16Schristostzcode$(VERSION).tar.gz: set-timestamps.out
6201.6Schristos		LC_ALL=C && export LC_ALL && \
6211.7Schristos		tar $(TARFLAGS) -cf - \
6221.23Schristos		    $(COMMON) $(DOCS) $(SOURCES) | \
6231.17Sapb		  ${TOOL_GZIP} $(GZIPFLAGS) > $@
6241.10Schristos
6251.16Schristostzdata$(VERSION).tar.gz: set-timestamps.out
6261.6Schristos		LC_ALL=C && export LC_ALL && \
6271.23Schristos		tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
6281.17Sapb		  ${TOOL_GZIP} $(GZIPFLAGS) > $@
6291.9Schristos
6301.9Schristossignatures:	tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc
6311.9Schristos
6321.9Schristostzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
6331.9Schristos		gpg --armor --detach-sign $?
6341.9Schristos
6351.9Schristostzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
6361.9Schristos		gpg --armor --detach-sign $?
6371.1Smlelstv
6381.1Smlelstvtypecheck:
6391.29Schristos		$(MAKE) clean
6401.15Schristos		for i in "long long" unsigned; \
6411.1Smlelstv		do \
6421.29Schristos			$(MAKE) CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
6431.1Smlelstv			./zdump -v Europe/Rome ; \
6441.29Schristos			$(MAKE) clean ; \
6451.1Smlelstv		done
6461.1Smlelstv
6471.1Smlelstvzonenames:	$(TDATA)
6481.1Smlelstv		@$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
6491.1Smlelstv
6501.1Smlelstvasctime.o:	private.h tzfile.h
6511.1Smlelstvdate.o:		private.h
6521.1Smlelstvdifftime.o:	private.h
6531.1Smlelstvlocaltime.o:	private.h tzfile.h
6541.23Schristosstrftime.o:	private.h tzfile.h
6551.6Schristoszdump.o:	version.h
6561.6Schristoszic.o:		private.h tzfile.h version.h
6571.1Smlelstv
6581.1Smlelstv.KEEP_STATE:
6591.22Schristos
6601.22Schristos.PHONY: ALL INSTALL all
6611.26Schristos.PHONY: check check_character_set check_links
6621.26Schristos.PHONY: check_public check_sorted check_tables
6631.23Schristos.PHONY: check_time_t_alternatives check_web check_white_space clean clean_misc
6641.23Schristos.PHONY: install maintainer-clean names posix_packrat posix_only posix_right
6651.22Schristos.PHONY: public right_only right_posix signatures tarballs typecheck
6661.22Schristos.PHONY: zonenames zones
667