Makefile revision 1.40
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.34Schristos# Version number for the distribution, overridden in the 'tarballs' rule below.
81.35SchristosVERSION=	unknown
91.9Schristos
101.9Schristos# Email address for bug reports.
111.9SchristosBUGEMAIL=	tz@iana.org
121.6Schristos
131.40Schristos# Choose source data features.  To get new features right away, use:
141.40Schristos#	DATAFORM=	vanguard
151.40Schristos# To wait a while before using new features, to give downstream users
161.40Schristos# time to upgrade zic (the default), use:
171.40Schristos#	DATAFORM=	main
181.40Schristos# To wait even longer for new features, use:
191.40Schristos#	DATAFORM=	rearguard
201.40SchristosDATAFORM=		main
211.40Schristos
221.1Smlelstv# Change the line below for your time zone (after finding the zone you want in
231.1Smlelstv# the time zone files, or adding it to a time zone file).
241.40Schristos# Alternatively, if you discover you've got the wrong time zone, you can just
251.1Smlelstv#	zic -l rightzone
261.1Smlelstv# to correct things.
271.1Smlelstv# Use the command
281.1Smlelstv#	make zonenames
291.1Smlelstv# to get a list of the values you can use for LOCALTIME.
301.1Smlelstv
311.4SchristosLOCALTIME=	GMT
321.1Smlelstv
331.1Smlelstv# If you want something other than Eastern United States time as a template
341.1Smlelstv# for handling POSIX-style time zone environment variables,
351.1Smlelstv# change the line below (after finding the zone you want in the
361.1Smlelstv# time zone files, or adding it to a time zone file).
371.40Schristos# When a POSIX-style environment variable is handled, the rules in the
381.1Smlelstv# template file are used to determine "spring forward" and "fall back" days and
391.15Schristos# times; the environment variable itself specifies UT offsets of standard and
401.40Schristos# daylight saving time.
411.40Schristos# Alternatively, if you discover you've got the wrong time zone, you can just
421.1Smlelstv#	zic -p rightzone
431.1Smlelstv# to correct things.
441.1Smlelstv# Use the command
451.1Smlelstv#	make zonenames
461.1Smlelstv# to get a list of the values you can use for POSIXRULES.
471.1Smlelstv# If you want POSIX compatibility, use "America/New_York".
481.1Smlelstv
491.1SmlelstvPOSIXRULES=	America/New_York
501.1Smlelstv
511.1Smlelstv# Also see TZDEFRULESTRING below, which takes effect only
521.1Smlelstv# if the time zone files cannot be accessed.
531.1Smlelstv
541.1Smlelstv
551.39Schristos# Installation locations.
561.39Schristos#
571.39Schristos# The defaults are suitable for Debian, except that if REDO is
581.39Schristos# posix_right or right_posix then files that Debian puts under
591.39Schristos# /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
601.39Schristos# put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
611.39Schristos# respectively.  Problems with the Debian approach are discussed in
621.39Schristos# the commentary for the right_posix rule (below).
631.39Schristos
641.39Schristos# Destination directory, which can be used for staging.
651.39Schristos# 'make DESTDIR=/stage install' installs under /stage (e.g., to
661.39Schristos# /stage/etc/localtime instead of to /etc/localtime).  Files under
671.39Schristos# /stage are not intended to work as-is, but can be copied by hand to
681.39Schristos# the root directory later.  If DESTDIR is empty, 'make install' does
691.39Schristos# not stage, but installs directly into production locations.
701.39SchristosDESTDIR =
711.39Schristos
721.39Schristos# Everything is installed into subdirectories of TOPDIR, and used there.
731.39Schristos# TOPDIR should be empty (meaning the root directory),
741.39Schristos# or a directory name that does not end in "/".
751.39Schristos# TOPDIR should be empty or an absolute name unless you're just testing.
761.39SchristosTOPDIR =
771.39Schristos
781.39Schristos# The default local time zone is taken from the file TZDEFAULT.
791.39SchristosTZDEFAULT = $(TOPDIR)/etc/localtime
801.39Schristos
811.39Schristos# The subdirectory containing installed program and data files, and
821.39Schristos# likewise for installed files that can be shared among architectures.
831.39Schristos# These should be relative file names.
841.39SchristosUSRDIR = usr
851.39SchristosUSRSHAREDIR = $(USRDIR)/share
861.1Smlelstv
871.1Smlelstv# "Compiled" time zone information is placed in the "TZDIR" directory
881.1Smlelstv# (and subdirectories).
891.38Schristos# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
901.15SchristosTZDIR_BASENAME=	zoneinfo
911.39SchristosTZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
921.1Smlelstv
931.39Schristos# The "tzselect" and (if you do "make INSTALL") "date" commands go in:
941.39SchristosBINDIR = $(TOPDIR)/$(USRDIR)/bin
951.1Smlelstv
961.39Schristos# The "zdump" command goes in:
971.39SchristosZDUMPDIR = $(BINDIR)
981.1Smlelstv
991.39Schristos# The "zic" command goes in:
1001.39SchristosZICDIR = $(TOPDIR)/$(USRDIR)/sbin
1011.1Smlelstv
1021.1Smlelstv# Manual pages go in subdirectories of. . .
1031.39SchristosMANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
1041.1Smlelstv
1051.39Schristos# Library functions are put in an archive in LIBDIR.
1061.39SchristosLIBDIR = $(TOPDIR)/$(USRDIR)/lib
1071.1Smlelstv
1081.1Smlelstv
1091.39Schristos# Types to try, as an alternative to time_t.  int64_t should be first.
1101.39SchristosTIME_T_ALTERNATIVES = int64_t int32_t uint32_t uint64_t
1111.1Smlelstv
1121.37Schristos# If you want only POSIX time, with time values interpreted as
1131.37Schristos# seconds since the epoch (not counting leap seconds), use
1141.1Smlelstv#	REDO=		posix_only
1151.38Schristos# below.  If you want only "right" time, with values interpreted
1161.37Schristos# as seconds since the epoch (counting leap seconds), use
1171.1Smlelstv#	REDO=		right_only
1181.1Smlelstv# below.  If you want both sets of data available, with leap seconds not
1191.1Smlelstv# counted normally, use
1201.1Smlelstv#	REDO=		posix_right
1211.1Smlelstv# below.  If you want both sets of data available, with leap seconds counted
1221.1Smlelstv# normally, use
1231.1Smlelstv#	REDO=		right_posix
1241.32Schristos# below.  POSIX mandates that leap seconds not be counted; for compatibility
1251.37Schristos# with it, use "posix_only" or "posix_right".  Use POSIX time on systems with
1261.37Schristos# leap smearing; this can work better than unsmeared "right" time with
1271.37Schristos# applications that are not leap second aware, and is closer to unsmeared
1281.37Schristos# "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
1291.1Smlelstv
1301.1SmlelstvREDO=		posix_right
1311.1Smlelstv
1321.38Schristos# To install data in text form that has all the information of the binary data,
1331.38Schristos# (optionally incorporating leap second information), use
1341.38Schristos#	TZDATA_TEXT=	tzdata.zi leapseconds
1351.38Schristos# To install text data without leap second information (e.g., because
1361.38Schristos# REDO='posix_only'), use
1371.38Schristos#	TZDATA_TEXT=	tzdata.zi
1381.38Schristos# To avoid installing text data, use
1391.38Schristos#	TZDATA_TEXT=
1401.38Schristos
1411.38SchristosTZDATA_TEXT=	leapseconds tzdata.zi
1421.38Schristos
1431.38Schristos# For backward-compatibility links for old zone names, use
1441.39Schristos#	BACKWARD=	backward
1451.39Schristos# If you also want the link US/Pacific-New, even though it is confusing
1461.39Schristos# and is planned to be removed from the database eventually, use
1471.38Schristos#	BACKWARD=	backward pacificnew
1481.38Schristos# To omit these links, use
1491.38Schristos#	BACKWARD=
1501.38Schristos
1511.39SchristosBACKWARD=	backward
1521.38Schristos
1531.32Schristos# If you want out-of-scope and often-wrong data from the file 'backzone', use
1541.32Schristos#	PACKRATDATA=	backzone
1551.32Schristos# To omit this data, use
1561.32Schristos#	PACKRATDATA=
1571.32Schristos
1581.32SchristosPACKRATDATA=
1591.32Schristos
1601.38Schristos# The name of a locale using the UTF-8 encoding, used during self-tests.
1611.38Schristos# The tests are skipped if the name does not appear to work on this system.
1621.38Schristos
1631.38SchristosUTF8_LOCALE=	en_US.utf8
1641.38Schristos
1651.1Smlelstv# Since "." may not be in PATH...
1661.1Smlelstv
1671.1SmlelstvYEARISTYPE=	./yearistype
1681.1Smlelstv
1691.1Smlelstv# Non-default libraries needed to link.
1701.1SmlelstvLDLIBS=
1711.1Smlelstv
1721.38Schristos# Add the following to the end of the "CFLAGS=" line as needed to override
1731.38Schristos# defaults specified in the source code.  "-DFOO" is equivalent to "-DFOO=1".
1741.19Schristos#  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
1751.38Schristos#  -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
1761.38Schristos#	formats that generate only the last two digits of year numbers
1771.38Schristos#  -DEPOCH_LOCAL if the 'time' function returns local time not UT
1781.38Schristos#  -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
1791.38Schristos#	than what POSIX specifies, assuming local time is UT.
1801.38Schristos#	For example, N is 252460800 on AmigaOS.
1811.32Schristos#  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
1821.38Schristos#  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
1831.32Schristos#  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
1841.38Schristos#  -DHAVE_GENERIC=0 if _Generic does not work
1851.38Schristos#  -DHAVE_GETTEXT if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris)
1861.38Schristos#  -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
1871.35Schristos#	ctime_r and asctime_r incompatibly with the POSIX standard
1881.35Schristos#	(Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
1891.38Schristos#  -DHAVE_INTTYPES_H if you have a non-C99 compiler with <inttypes.h>
1901.16Schristos#  -DHAVE_LINK=0 if your system lacks a link function
1911.23Schristos#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
1921.23Schristos#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
1931.23Schristos#	localtime_rz can make zdump significantly faster, but is nonstandard.
1941.32Schristos#  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
1951.32Schristos#	functions like 'link' or variables like 'tzname' required by POSIX
1961.38Schristos#  -DHAVE_SNPRINTF=0 if your system lacks the snprintf function
1971.38Schristos#  -DHAVE_STDBOOL_H if you have a non-C99 compiler with <stdbool.h>
1981.38Schristos#  -DHAVE_STDINT_H if you have a non-C99 compiler with <stdint.h>
1991.38Schristos#  -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
2001.28Schristos#  -DHAVE_STRDUP=0 if your system lacks the strdup function
2011.40Schristos#  -DHAVE_STRTOLL=0 if your system lacks the strtoll function
2021.1Smlelstv#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
2031.38Schristos#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a <sys/stat.h>
2041.38Schristos#  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a <sys/wait.h>
2051.23Schristos#  -DHAVE_TZSET=0 if your system lacks a tzset function
2061.38Schristos#  -DHAVE_UNISTD_H=0 if your compiler lacks a <unistd.h>
2071.38Schristos#  -Dlocale_t=XXX if your system uses XXX instead of locale_t
2081.40Schristos#  -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
2091.40Schristos#	with external linkage, e.g., applications cannot define 'localtime'.
2101.38Schristos#  -Dssize_t=long on hosts like MS-Windows that lack ssize_t
2111.40Schristos#  -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
2121.40Schristos#	security implications and is not recommended for general use
2131.38Schristos#  -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
2141.23Schristos#	not needed by the main-program tz code, which is single-threaded.
2151.23Schristos#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
2161.14Schristos#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
2171.38Schristos#	This is intended for internal use only; it mangles external names.
2181.1Smlelstv#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
2191.22Schristos#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
2201.1Smlelstv#	the default is system-supplied, typically "/usr/lib/locale"
2211.14Schristos#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
2221.38Schristos#	DST transitions if the time zone files cannot be accessed
2231.38Schristos#  -DUNINIT_TRAP if reading uninitialized storage can cause problems
2241.23Schristos#	other than simply getting garbage data
2251.23Schristos#  -DUSE_LTZ=0 to build zdump with the system time zone library
2261.23Schristos#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
2271.1Smlelstv#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
2281.1Smlelstv#	(or some other number) to set the maximum time zone abbreviation length
2291.1Smlelstv#	that zic will accept without a warning (the default is 6)
2301.30Schristos#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
2311.38Schristos# Select instrumentation via "make GCC_INSTRUMENT='whatever'".
2321.38SchristosGCC_INSTRUMENT = \
2331.38Schristos  -fsanitize=undefined -fsanitize-address-use-after-scope \
2341.38Schristos  -fsanitize-undefined-trap-on-error -fstack-protector
2351.38SchristosGCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \
2361.38Schristos  $(GCC_INSTRUMENT) \
2371.38Schristos  -Wall -Wextra \
2381.38Schristos  -Walloc-size-larger-than=100000 -Warray-bounds=2 \
2391.40Schristos  -Wbad-function-cast -Wcast-align=strict -Wdate-time \
2401.38Schristos  -Wdeclaration-after-statement -Wdouble-promotion \
2411.38Schristos  -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
2421.38Schristos  -Winit-self -Wjump-misses-init -Wlogical-op \
2431.38Schristos  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
2441.38Schristos  -Wold-style-definition -Woverlength-strings -Wpointer-arith \
2451.40Schristos  -Wshadow -Wshift-overflow=2 -Wstrict-prototypes -Wstringop-overflow=4 \
2461.40Schristos  -Wstringop-truncation -Wsuggest-attribute=cold \
2471.38Schristos  -Wsuggest-attribute=const -Wsuggest-attribute=format \
2481.40Schristos  -Wsuggest-attribute=malloc \
2491.38Schristos  -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
2501.38Schristos  -Wtrampolines -Wundef -Wuninitialized -Wunused \
2511.38Schristos  -Wvariadic-macros -Wvla -Wwrite-strings \
2521.38Schristos  -Wno-address -Wno-format-nonliteral -Wno-sign-compare \
2531.38Schristos  -Wno-type-limits -Wno-unused-parameter
2541.1Smlelstv#
2551.1Smlelstv# If your system has a "GMT offset" field in its "struct tm"s
2561.1Smlelstv# (or if you decide to add such a field in your system's "time.h" file),
2571.1Smlelstv# add the name to a define such as
2581.1Smlelstv#	-DTM_GMTOFF=tm_gmtoff
2591.23Schristos# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
2601.23Schristos# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
2611.23Schristos# Similarly, if your system has a "zone abbreviation" field, define
2621.1Smlelstv#	-DTM_ZONE=tm_zone
2631.23Schristos# and define NO_TM_ZONE to suppress any guessing.  These two fields are not
2641.23Schristos# required by POSIX, but are widely available on GNU/Linux and BSD systems.
2651.1Smlelstv#
2661.38Schristos# The next batch of options control support for external variables
2671.38Schristos# exported by tzcode.  In practice these variables are less useful
2681.38Schristos# than TM_GMTOFF and TM_ZONE.  However, most of them are standardized.
2691.38Schristos# #
2701.38Schristos# # To omit or support the external variable "tzname", add one of:
2711.38Schristos# #	-DHAVE_TZNAME=0
2721.38Schristos# #	-DHAVE_TZNAME=1
2731.38Schristos# # to the "CFLAGS=" line.  "tzname" is required by POSIX 1988 and later.
2741.38Schristos# # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
2751.38Schristos# # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
2761.38Schristos# # crashes when combined with some platforms' standard libraries,
2771.38Schristos# # presumably due to memory allocation issues.
2781.38Schristos# #
2791.38Schristos# # To omit or support the external variables "timezone" and "daylight", add
2801.38Schristos# #	-DUSG_COMPAT=0
2811.38Schristos# #	-DUSG_COMPAT=1
2821.38Schristos# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by
2831.38Schristos# # Unix Systems Group code and are required by POSIX 2008 (with XSI) and later.
2841.38Schristos# # If not defined, the code attempts to guess USG_COMPAT from other macros.
2851.38Schristos# #
2861.38Schristos# # To support the external variable "altzone", add
2871.38Schristos# #	-DALTZONE
2881.38Schristos# # to the end of the "CFLAGS=" line; although "altzone" appeared in
2891.38Schristos# # System V Release 3.1 it has not been standardized.
2901.38Schristos#
2911.1Smlelstv# If you want functions that were inspired by early versions of X3J11's work,
2921.1Smlelstv# add
2931.1Smlelstv#	-DSTD_INSPIRED
2941.1Smlelstv# to the end of the "CFLAGS=" line.  This arranges for the functions
2951.1Smlelstv# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
2961.1Smlelstv# "posix2time", and "time2posix" to be added to the time conversion library.
2971.1Smlelstv# "tzsetwall" is like "tzset" except that it arranges for local wall clock
2981.1Smlelstv# time (rather than the time specified in the TZ environment variable)
2991.1Smlelstv# to be used.
3001.1Smlelstv# "offtime" is like "gmtime" except that it accepts a second (long) argument
3011.1Smlelstv# that gives an offset to add to the time_t when converting it.
3021.1Smlelstv# "timelocal" is equivalent to "mktime".
3031.1Smlelstv# "timegm" is like "timelocal" except that it turns a struct tm into
3041.15Schristos# a time_t using UT (rather than local time as "timelocal" does).
3051.1Smlelstv# "timeoff" is like "timegm" except that it accepts a second (long) argument
3061.1Smlelstv# that gives an offset to use when converting to a time_t.
3071.1Smlelstv# "posix2time" and "time2posix" are described in an included manual page.
3081.1Smlelstv# X3J11's work does not describe any of these functions.
3091.1Smlelstv# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
3101.1Smlelstv# These functions may well disappear in future releases of the time
3111.1Smlelstv# conversion package.
3121.1Smlelstv#
3131.23Schristos# If you don't want functions that were inspired by NetBSD, add
3141.23Schristos#	-DNETBSD_INSPIRED=0
3151.23Schristos# to the end of the "CFLAGS=" line.  Otherwise, the functions
3161.23Schristos# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
3171.23Schristos# time library, and if STD_INSPIRED is also defined the functions
3181.23Schristos# "posix2time_z" and "time2posix_z" are added as well.
3191.23Schristos# The functions ending in "_z" (or "_rz") are like their unsuffixed
3201.23Schristos# (or suffixed-by-"_r") counterparts, except with an extra first
3211.23Schristos# argument of opaque type timezone_t that specifies the time zone.
3221.23Schristos# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
3231.23Schristos#
3241.1Smlelstv# If you want to allocate state structures in localtime, add
3251.1Smlelstv#	-DALL_STATE
3261.1Smlelstv# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
3271.1Smlelstv#
3281.1Smlelstv# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
3291.1Smlelstv# out by the National Institute of Standards and Technology
3301.1Smlelstv# which claims to test C and Posix conformance.  If you want to pass PCTS, add
3311.1Smlelstv#	-DPCTS
3321.1Smlelstv# to the end of the "CFLAGS=" line.
3331.1Smlelstv#
3341.1Smlelstv# If you want strict compliance with XPG4 as of 1994-04-09, add
3351.1Smlelstv#	-DXPG4_1994_04_09
3361.1Smlelstv# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
3371.38Schristos# 53 as a week number (rather than 52 or 53) for January days before
3381.38Schristos# January's first Monday when a "%V" format is used and January 1
3391.1Smlelstv# falls on a Friday, Saturday, or Sunday.
3401.1Smlelstv
3411.1SmlelstvCFLAGS=
3421.1Smlelstv
3431.9Schristos# Linker flags.  Default to $(LFLAGS) for backwards compatibility
3441.34Schristos# to release 2012h and earlier.
3451.9Schristos
3461.9SchristosLDFLAGS=	$(LFLAGS)
3471.1Smlelstv
3481.32Schristos# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
3491.32Schristos# submake command lines.  The default is no leap seconds.
3501.32Schristos
3511.32SchristosLEAPSECONDS=
3521.32Schristos
3531.32Schristos# The zic command and its arguments.
3541.32Schristos
3551.1Smlelstvzic=		./zic
3561.1SmlelstvZIC=		$(zic) $(ZFLAGS)
3571.1Smlelstv
3581.15SchristosZFLAGS=
3591.15Schristos
3601.34Schristos# How to use zic to install tz binary files.
3611.32Schristos
3621.39SchristosZIC_INSTALL=	$(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS)
3631.32Schristos
3641.22Schristos# The name of a Posix-compliant 'awk' on your system.
3651.9SchristosAWK=		awk
3661.9Schristos
3671.16Schristos# The full path name of a Posix-compliant shell, preferably one that supports
3681.16Schristos# the Korn shell's 'select' statement as an extension.
3691.16Schristos# These days, Bash is the most popular.
3701.16Schristos# It should be OK to set this to /bin/sh, on platforms where /bin/sh
3711.16Schristos# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
3721.16Schristos# is typically nicer if it works.
3731.9SchristosKSHELL=		/bin/bash
3741.1Smlelstv
3751.18Schristos# The path where SGML DTDs are kept and the catalog file(s) to use when
3761.34Schristos# validating.  The default should work on both Debian and Red Hat.
3771.10SchristosSGML_TOPDIR= /usr
3781.9SchristosSGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd
3791.9SchristosSGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224
3801.18SchristosSGML_CATALOG_FILES= \
3811.34Schristos  $(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
3821.1Smlelstv
3831.1Smlelstv# The name, arguments and environment of a program to validate your web pages.
3841.34Schristos# See <http://openjade.sourceforge.net/doc/> for a validator, and
3851.34Schristos# <https://validator.w3.org/source/> for a validation library.
3861.38Schristos# Set VALIDATE=':' if you do not have such a program.
3871.1SmlelstvVALIDATE = nsgmls
3881.1SmlelstvVALIDATE_FLAGS = -s -B -wall -wno-unused-param
3891.1SmlelstvVALIDATE_ENV = \
3901.39Schristos  SGML_CATALOG_FILES='$(SGML_CATALOG_FILES)' \
3911.39Schristos  SGML_SEARCH_PATH='$(SGML_SEARCH_PATH)' \
3921.1Smlelstv  SP_CHARSET_FIXED=YES \
3931.1Smlelstv  SP_ENCODING=UTF-8
3941.1Smlelstv
3951.23Schristos# This expensive test requires USE_LTZ.
3961.23Schristos# To suppress it, define this macro to be empty.
3971.23SchristosCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
3981.23Schristos
3991.22Schristos# SAFE_CHAR is a regular expression that matches a safe character.
4001.22Schristos# Some parts of this distribution are limited to safe characters;
4011.22Schristos# others can use any UTF-8 character.
4021.22Schristos# For now, the safe characters are a safe subset of ASCII.
4031.9Schristos# The caller must set the shell variable 'sharp' to the character '#',
4041.9Schristos# since Makefile macros cannot contain '#'.
4051.9Schristos# TAB_CHAR is a single tab character, in single quotes.
4061.9SchristosTAB_CHAR=	'	'
4071.22SchristosSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
4081.22SchristosSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
4091.22SchristosSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
4101.29SchristosSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
4111.29SchristosSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
4121.29Schristos
4131.40Schristos# Non-ASCII non-letters that OK_CHAR allows, as these characters are
4141.40Schristos# useful in commentary.  XEmacs 21.5.34 displays them correctly,
4151.40Schristos# presumably because they are Latin-1.
4161.40SchristosUNUSUAL_OK_CHARSET= °±½¾×
4171.40Schristos
4181.29Schristos# OK_CHAR matches any character allowed in the distributed files.
4191.40Schristos# This is the same as SAFE_CHAR, except that UNUSUAL_OK_CHARSET and
4201.40Schristos# multibyte letters are also allowed so that commentary can contain a
4211.40Schristos# few safe symbols and people's names and can quote non-English sources.
4221.40Schristos# Other non-letters are limited to ASCII renderings for the
4231.40Schristos# convenience of maintainers using XEmacs 21.5.34, which by default
4241.40Schristos# mishandles Unicode characters U+0100 and greater.
4251.40SchristosOK_CHAR=	'[][:alpha:]$(UNUSUAL_OK_CHARSET)'$(SAFE_CHARSET)'-]'
4261.22Schristos
4271.22Schristos# SAFE_LINE matches a line of safe characters.
4281.29Schristos# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
4291.22Schristos# this is so that comments can contain non-ASCII characters.
4301.29Schristos# OK_LINE matches a line of OK characters.
4311.22SchristosSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
4321.29SchristosSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
4331.29SchristosOK_LINE=	'^'$(OK_CHAR)'*$$'
4341.9Schristos
4351.6Schristos# Flags to give 'tar' when making a distribution.
4361.6Schristos# Try to use flags appropriate for GNU tar.
4371.34SchristosGNUTARFLAGS= --numeric-owner --owner=0 --group=0 --mode=go+u,go-w --sort=name
4381.6SchristosTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
4391.6Schristos		 then echo $(GNUTARFLAGS); \
4401.6Schristos		 else :; \
4411.6Schristos		 fi`
4421.6Schristos
4431.6Schristos# Flags to give 'gzip' when making a distribution.
4441.38SchristosGZIPFLAGS=	-9n
4451.6Schristos
4461.1Smlelstv###############################################################################
4471.1Smlelstv
4481.29Schristos#MAKE=		make
4491.29Schristos
4501.1Smlelstvcc=		cc
4511.39SchristosCC=		$(cc) -DTZDIR='"$(TZDIR)"'
4521.1Smlelstv
4531.16SchristosAR=		ar
4541.16Schristos
4551.16Schristos# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
4561.16SchristosRANLIB=		:
4571.16Schristos
4581.28SchristosTZCOBJS=	zic.o
4591.38SchristosTZDOBJS=	zdump.o localtime.o asctime.o strftime.o
4601.1SmlelstvDATEOBJS=	date.o localtime.o strftime.o asctime.o
4611.1SmlelstvLIBSRCS=	localtime.c asctime.c difftime.c
4621.1SmlelstvLIBOBJS=	localtime.o asctime.o difftime.o
4631.1SmlelstvHEADERS=	tzfile.h private.h
4641.28SchristosNONLIBSRCS=	zic.c zdump.c
4651.1SmlelstvNEWUCBSRCS=	date.c strftime.c
4661.23SchristosSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
4671.35Schristos			tzselect.ksh workman.sh
4681.1SmlelstvMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
4691.1Smlelstv			tzfile.5 tzselect.8 zic.8 zdump.8
4701.16SchristosMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
4711.16Schristos			time2posix.3.txt \
4721.16Schristos			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
4731.16Schristos			date.1.txt
4741.38SchristosCOMMON=		calendars CONTRIBUTING LICENSE Makefile \
4751.38Schristos			NEWS README theory.html version
4761.39SchristosWEB_PAGES=	tz-art.html tz-how-to.html tz-link.html
4771.23SchristosDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
4781.1SmlelstvPRIMARY_YDATA=	africa antarctica asia australasia \
4791.1Smlelstv		europe northamerica southamerica
4801.39SchristosYDATA=		$(PRIMARY_YDATA) etcetera
4811.4SchristosNDATA=		systemv factory
4821.39SchristosTDATA_TO_CHECK=	$(YDATA) $(NDATA) backward pacificnew
4831.39SchristosTDATA=		$(YDATA) $(NDATA) $(BACKWARD)
4841.22SchristosZONETABLES=	zone1970.tab zone.tab
4851.38SchristosTABDATA=	iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
4861.16SchristosLEAP_DEPS=	leapseconds.awk leap-seconds.list
4871.40SchristosTZDATA_ZI_DEPS=	ziguard.awk zishrink.awk version $(TDATA) $(PACKRATDATA)
4881.40SchristosDSTDATA_ZI_DEPS= ziguard.awk $(TDATA) $(PACKRATDATA)
4891.39SchristosDATA=		$(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
4901.38Schristos			leapseconds yearistype.sh $(ZONETABLES)
4911.40SchristosAWK_SCRIPTS=	checklinks.awk checktab.awk leapseconds.awk \
4921.40Schristos			ziguard.awk zishrink.awk
4931.23SchristosMISC=		$(AWK_SCRIPTS) zoneinfo2tdf.pl
4941.34SchristosTZS_YEAR=	2050
4951.34SchristosTZS=		to$(TZS_YEAR).tzs
4961.34SchristosTZS_NEW=	to$(TZS_YEAR)new.tzs
4971.34SchristosTZS_DEPS=	$(PRIMARY_YDATA) asctime.c localtime.c \
4981.34Schristos			private.h tzfile.h zdump.c zic.c
4991.38SchristosENCHILADA=	$(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS) tzdata.zi
5001.34Schristos
5011.34Schristos# Consult these files when deciding whether to rebuild the 'version' file.
5021.34Schristos# This list is not the same as the output of 'git ls-files', since
5031.34Schristos# .gitignore is not distributed.
5041.34SchristosVERSION_DEPS= \
5051.38Schristos		calendars CONTRIBUTING LICENSE Makefile NEWS README \
5061.34Schristos		africa antarctica asctime.c asia australasia \
5071.34Schristos		backward backzone \
5081.34Schristos		checklinks.awk checktab.awk \
5091.34Schristos		date.1 date.c difftime.c \
5101.34Schristos		etcetera europe factory iso3166.tab \
5111.34Schristos		leap-seconds.list leapseconds.awk localtime.c \
5121.34Schristos		newctime.3 newstrftime.3 newtzset.3 northamerica \
5131.34Schristos		pacificnew private.h \
5141.38Schristos		southamerica strftime.c systemv theory.html \
5151.39Schristos		time2posix.3 tz-art.html tz-how-to.html tz-link.html \
5161.34Schristos		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
5171.34Schristos		workman.sh yearistype.sh \
5181.34Schristos		zdump.8 zdump.c zic.8 zic.c \
5191.40Schristos		ziguard.awk zishrink.awk \
5201.34Schristos		zone.tab zone1970.tab zoneinfo2tdf.pl
5211.1Smlelstv
5221.1Smlelstv# And for the benefit of csh users on systems that assume the user
5231.1Smlelstv# shell should be used to handle commands in Makefiles. . .
5241.1Smlelstv
5251.1SmlelstvSHELL=		/bin/sh
5261.1Smlelstv
5271.40Schristosall:		tzselect yearistype zic zdump libtz.a $(TABDATA) \
5281.40Schristos		  vanguard.zi main.zi rearguard.zi
5291.1Smlelstv
5301.29SchristosALL:		all date $(ENCHILADA)
5311.1Smlelstv
5321.16Schristosinstall:	all $(DATA) $(REDO) $(MANS)
5331.39Schristos		mkdir -p '$(DESTDIR)$(BINDIR)' \
5341.39Schristos			'$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
5351.39Schristos			'$(DESTDIR)$(LIBDIR)' \
5361.39Schristos			'$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
5371.39Schristos			'$(DESTDIR)$(MANDIR)/man8'
5381.39Schristos		$(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES) \
5391.39Schristos			-t '$(DESTDIR)$(TZDEFAULT)'
5401.39Schristos		cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
5411.39Schristos		cp tzselect '$(DESTDIR)$(BINDIR)/.'
5421.39Schristos		cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
5431.39Schristos		cp zic '$(DESTDIR)$(ZICDIR)/.'
5441.39Schristos		cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
5451.39Schristos		$(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
5461.39Schristos		cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
5471.39Schristos		cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
5481.39Schristos		cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
5491.1Smlelstv
5501.1SmlelstvINSTALL:	ALL install date.1
5511.39Schristos		mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
5521.39Schristos		cp date '$(DESTDIR)$(BINDIR)/.'
5531.39Schristos		cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
5541.1Smlelstv
5551.34Schristosversion:	$(VERSION_DEPS)
5561.35Schristos		{ (type git) >/dev/null 2>&1 && \
5571.35Schristos		  V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
5581.35Schristos				--abbrev=7 --dirty` || \
5591.39Schristos		  V='$(VERSION)'; } && \
5601.35Schristos		printf '%s\n' "$$V" >$@.out
5611.35Schristos		mv $@.out $@
5621.34Schristos
5631.40Schristos# These files can be tailored by setting BACKWARD, PACKRATDATA, etc.
5641.40Schristosvanguard.zi main.zi rearguard.zi: $(DSTDATA_ZI_DEPS)
5651.40Schristos		$(AWK) -v DATAFORM=`expr $@ : '\(.*\).zi'` -f ziguard.awk \
5661.40Schristos		  $(TDATA) $(PACKRATDATA) >$@.out
5671.40Schristos		mv $@.out $@
5681.40Schristostzdata.zi:	$(DATAFORM).zi version
5691.39Schristos		version=`sed 1q version` && \
5701.39Schristos		  LC_ALL=C $(AWK) -v version="$$version" -f zishrink.awk \
5711.40Schristos		    $(DATAFORM).zi >$@.out
5721.38Schristos		mv $@.out $@
5731.38Schristos
5741.34Schristosversion.h:	version
5751.35Schristos		VERSION=`cat version` && printf '%s\n' \
5761.35Schristos		  'static char const PKGVERSION[]="($(PACKAGE)) ";' \
5771.35Schristos		  "static char const TZVERSION[]=\"$$VERSION\";" \
5781.35Schristos		  'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
5791.35Schristos		  >$@.out
5801.35Schristos		mv $@.out $@
5811.6Schristos
5821.1Smlelstvzdump:		$(TZDOBJS)
5831.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
5841.1Smlelstv
5851.32Schristoszic:		$(TZCOBJS)
5861.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
5871.1Smlelstv
5881.1Smlelstvyearistype:	yearistype.sh
5891.1Smlelstv		cp yearistype.sh yearistype
5901.1Smlelstv		chmod +x yearistype
5911.1Smlelstv
5921.16Schristosleapseconds:	$(LEAP_DEPS)
5931.35Schristos		$(AWK) -f leapseconds.awk leap-seconds.list >$@.out
5941.35Schristos		mv $@.out $@
5951.15Schristos
5961.32Schristos# Arguments to pass to submakes of install_data.
5971.32Schristos# They can be overridden by later submake arguments.
5981.32SchristosINSTALLARGS = \
5991.39Schristos BACKWARD='$(BACKWARD)' \
6001.39Schristos DESTDIR='$(DESTDIR)' \
6011.32Schristos LEAPSECONDS='$(LEAPSECONDS)' \
6021.32Schristos PACKRATDATA='$(PACKRATDATA)' \
6031.39Schristos TZDEFAULT='$(TZDEFAULT)' \
6041.39Schristos TZDIR='$(TZDIR)' \
6051.39Schristos YEARISTYPE='$(YEARISTYPE)' \
6061.32Schristos ZIC='$(ZIC)'
6071.32Schristos
6081.32Schristos# 'make install_data' installs one set of tz binary files.
6091.38Schristosinstall_data:	zic leapseconds yearistype tzdata.zi
6101.38Schristos		$(ZIC_INSTALL) tzdata.zi
6111.32Schristos
6121.32Schristosposix_only:
6131.32Schristos		$(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
6141.32Schristos
6151.32Schristosright_only:
6161.32Schristos		$(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
6171.32Schristos			install_data
6181.1Smlelstv
6191.1Smlelstv# In earlier versions of this makefile, the other two directories were
6201.1Smlelstv# subdirectories of $(TZDIR).  However, this led to configuration errors.
6211.1Smlelstv# For example, with posix_right under the earlier scheme,
6221.1Smlelstv# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
6231.1Smlelstv# but gmtime without leap seconds, which led to problems with applications
6241.1Smlelstv# like sendmail that subtract gmtime from localtime.
6251.1Smlelstv# Therefore, the other two directories are now siblings of $(TZDIR).
6261.1Smlelstv# You must replace all of $(TZDIR) to switch from not using leap seconds
6271.1Smlelstv# to using them, or vice versa.
6281.32Schristosright_posix:	right_only
6291.39Schristos		rm -fr '$(DESTDIR)$(TZDIR)-leaps'
6301.39Schristos		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
6311.39Schristos		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
6321.39Schristos		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
6331.15Schristos
6341.32Schristosposix_right:	posix_only
6351.39Schristos		rm -fr '$(DESTDIR)$(TZDIR)-posix'
6361.39Schristos		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
6371.39Schristos		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
6381.39Schristos		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
6391.32Schristos
6401.32Schristos# This obsolescent rule is present for backwards compatibility with
6411.32Schristos# tz releases 2014g through 2015g.  It should go away eventually.
6421.32Schristosposix_packrat:
6431.32Schristos		$(MAKE) $(INSTALLARGS) PACKRATDATA=backzone posix_only
6441.23Schristos
6451.1Smlelstvzones:		$(REDO)
6461.1Smlelstv
6471.40Schristos# dummy.zd is not a real file; it is mentioned here only so that the
6481.40Schristos# top-level 'make' does not have a syntax error.
6491.40SchristosZDS = dummy.zd
6501.40Schristos# Rule used only by submakes invoked by the $(TZS_NEW) rule.
6511.40Schristos# It is separate so that GNU 'make -j' can run instances in parallel.
6521.40Schristos$(ZDS): zdump
6531.40Schristos		./zdump -i -c $(TZS_YEAR) '$(wd)/'$$(expr $@ : '\(.*\).zd') >$@
6541.40Schristos
6551.38Schristos$(TZS_NEW):	tzdata.zi zdump zic
6561.40Schristos		rm -fr tzs.dir
6571.40Schristos		mkdir tzs.dir
6581.38Schristos		$(zic) -d tzs.dir tzdata.zi
6591.38Schristos		$(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
6601.38Schristos		   tzdata.zi | LC_ALL=C sort >$@.out
6611.35Schristos		wd=`pwd` && \
6621.40Schristos		set x `$(AWK) '/^Z/{print "tzs.dir/" $$2 ".zd"}' tzdata.zi \
6631.40Schristos			| LC_ALL=C sort -t . -k 2,2` && \
6641.40Schristos		shift && \
6651.40Schristos		ZDS=$$* && \
6661.40Schristos		$(MAKE) wd="$$wd" TZS_YEAR=$(TZS_YEAR) ZDS="$$ZDS" $$ZDS && \
6671.40Schristos		sed 's,^TZ=".*tzs\.dir/,TZ=",' $$ZDS >>$@.out
6681.40Schristos		rm -fr tzs.dir
6691.40Schristos		mv $@.out $@
6701.34Schristos
6711.34Schristos# If $(TZS) does not already exist (e.g., old-format tarballs), create it.
6721.34Schristos# If it exists but 'make check_tzs' fails, a maintainer should inspect the
6731.34Schristos# failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
6741.34Schristos$(TZS):
6751.34Schristos		$(MAKE) force_tzs
6761.34Schristos
6771.34Schristosforce_tzs:	$(TZS_NEW)
6781.34Schristos		cp $(TZS_NEW) $(TZS)
6791.34Schristos
6801.16Schristoslibtz.a:	$(LIBOBJS)
6811.37Schristos		rm -f $@
6821.37Schristos		$(AR) -rc $@ $(LIBOBJS)
6831.16Schristos		$(RANLIB) $@
6841.1Smlelstv
6851.1Smlelstvdate:		$(DATEOBJS)
6861.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
6871.1Smlelstv
6881.34Schristostzselect:	tzselect.ksh version
6891.35Schristos		VERSION=`cat version` && sed \
6901.9Schristos			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
6911.1Smlelstv			-e 's|AWK=[^}]*|AWK=$(AWK)|g' \
6921.9Schristos			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
6931.9Schristos			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
6941.1Smlelstv			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
6951.35Schristos			-e 's|\(TZVERSION\)=.*|\1='"$$VERSION"'|' \
6961.35Schristos			<$@.ksh >$@.out
6971.35Schristos		chmod +x $@.out
6981.35Schristos		mv $@.out $@
6991.1Smlelstv
7001.38Schristoscheck:		check_character_set check_white_space check_links \
7011.38Schristos		  check_name_lengths check_sorted \
7021.38Schristos		  check_tables check_web check_zishrink check_tzs
7031.9Schristos
7041.9Schristoscheck_character_set: $(ENCHILADA)
7051.38Schristos	test ! '$(UTF8_LOCALE)' || \
7061.38Schristos	! printf 'A\304\200B\n' | \
7071.38Schristos	  LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 || { \
7081.38Schristos		LC_ALL='$(UTF8_LOCALE)' && export LC_ALL && \
7091.22Schristos		sharp='#' && \
7101.35Schristos		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
7111.35Schristos			$(MISC) $(SOURCES) $(WEB_PAGES) \
7121.40Schristos			CONTRIBUTING LICENSE README \
7131.38Schristos			version tzdata.zi && \
7141.40Schristos		! grep -Env $(SAFE_LINE)'|^UNUSUAL_OK_CHARSET='$(OK_CHAR)'*$$' \
7151.40Schristos			Makefile && \
7161.39Schristos		! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
7171.29Schristos			leapseconds yearistype.sh zone.tab && \
7181.38Schristos		! grep -Env $(OK_LINE) $(ENCHILADA); \
7191.38Schristos	}
7201.22Schristos
7211.23Schristoscheck_white_space: $(ENCHILADA)
7221.35Schristos		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
7231.35Schristos		! grep -En "$$pat" $(ENCHILADA)
7241.39Schristos		! grep -n '[[:space:]]$$' \
7251.39Schristos			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
7261.23Schristos
7271.38SchristosPRECEDES_FILE_NAME = ^(Zone|Link[[:space:]]+[^[:space:]]+)[[:space:]]+
7281.38SchristosFILE_NAME_COMPONENT_TOO_LONG = \
7291.38Schristos  $(PRECEDES_FILE_NAME)[^[:space:]]*[^/[:space:]]{15}
7301.38Schristos
7311.39Schristoscheck_name_lengths: $(TDATA_TO_CHECK) backzone
7321.39Schristos		! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
7331.39Schristos			$(TDATA_TO_CHECK) backzone
7341.38Schristos
7351.23SchristosCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
7361.23Schristos
7371.23Schristoscheck_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
7381.23Schristos		$(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu
7391.23Schristos		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
7401.23Schristos		$(AWK) '/^[^#]/ {print $$1}' iso3166.tab | LC_ALL=C sort -cu
7411.23Schristos		$(AWK) '/^[^#]/ {print $$1}' zone.tab | LC_ALL=C sort -c
7421.23Schristos		$(AWK) '/^[^#]/ {print substr($$0, 1, 2)}' zone1970.tab | \
7431.23Schristos		  LC_ALL=C sort -c
7441.23Schristos		$(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \
7451.23Schristos		  LC_ALL=C sort -cu
7461.23Schristos
7471.40Schristoscheck_links:	checklinks.awk $(TDATA_TO_CHECK) tzdata.zi
7481.39Schristos		$(AWK) -f checklinks.awk $(TDATA_TO_CHECK)
7491.38Schristos		$(AWK) -f checklinks.awk tzdata.zi
7501.26Schristos
7511.22Schristoscheck_tables:	checktab.awk $(PRIMARY_YDATA) $(ZONETABLES)
7521.22Schristos		for tab in $(ZONETABLES); do \
7531.22Schristos		  $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \
7541.22Schristos		    || exit; \
7551.22Schristos		done
7561.1Smlelstv
7571.34Schristoscheck_tzs:	$(TZS) $(TZS_NEW)
7581.34Schristos		diff -u $(TZS) $(TZS_NEW)
7591.34Schristos
7601.38Schristos# This checks only the HTML 4.01 strict page.
7611.38Schristos# To check the the other pages, use <https://validator.w3.org/>.
7621.38Schristoscheck_web:	tz-how-to.html
7631.38Schristos		$(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) tz-how-to.html
7641.38Schristos
7651.40Schristos# Check that zishrink.awk does not alter the data, and that ziguard.awk
7661.40Schristos# preserves main-format data.
7671.40Schristoscheck_zishrink: zic leapseconds $(PACKRATDATA) $(TDATA) \
7681.40Schristos		  $(DATAFORM).zi tzdata.zi
7691.38Schristos		for type in posix right; do \
7701.40Schristos		  mkdir -p time_t.dir/$$type time_t.dir/$$type-t \
7711.40Schristos		    time_t.dir/$$type-shrunk && \
7721.38Schristos		  case $$type in \
7731.38Schristos		    right) leap='-L leapseconds';; \
7741.38Schristos	            *) leap=;; \
7751.38Schristos		  esac && \
7761.40Schristos		  $(ZIC) $$leap -d time_t.dir/$$type $(DATAFORM).zi && \
7771.40Schristos		  case $(DATAFORM) in \
7781.40Schristos		    main) \
7791.40Schristos		      $(ZIC) $$leap -d time_t.dir/$$type-t $(TDATA) && \
7801.40Schristos		      $(AWK) '/^Rule/' $(TDATA) | \
7811.40Schristos			$(ZIC) $$leap -d time_t.dir/$$type-t - \
7821.40Schristos			  $(PACKRATDATA) && \
7831.40Schristos		      diff -r time_t.dir/$$type time_t.dir/$$type-t;; \
7841.40Schristos		  esac && \
7851.38Schristos		  $(ZIC) $$leap -d time_t.dir/$$type-shrunk tzdata.zi && \
7861.38Schristos		  diff -r time_t.dir/$$type time_t.dir/$$type-shrunk || exit; \
7871.38Schristos		done
7881.38Schristos		rm -fr time_t.dir
7891.1Smlelstv
7901.14Schristosclean_misc:
7911.6Schristos		rm -f core *.o *.out \
7921.18Schristos		  date tzselect version.h zdump zic yearistype libtz.a
7931.14Schristosclean:		clean_misc
7941.40Schristos		rm -fr *.dir *.zi tzdb-*/ $(TZS_NEW)
7951.1Smlelstv
7961.1Smlelstvmaintainer-clean: clean
7971.1Smlelstv		@echo 'This command is intended for maintainers to use; it'
7981.1Smlelstv		@echo 'deletes files that may need special tools to rebuild.'
7991.34Schristos		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
8001.1Smlelstv
8011.1Smlelstvnames:
8021.1Smlelstv		@echo $(ENCHILADA)
8031.1Smlelstv
8041.23Schristospublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
8051.16Schristos		tarballs signatures
8061.16Schristos
8071.16Schristosdate.1.txt:	date.1
8081.16Schristosnewctime.3.txt:	newctime.3
8091.16Schristosnewstrftime.3.txt: newstrftime.3
8101.16Schristosnewtzset.3.txt:	newtzset.3
8111.16Schristostime2posix.3.txt: time2posix.3
8121.16Schristostzfile.5.txt:	tzfile.5
8131.16Schristostzselect.8.txt:	tzselect.8
8141.16Schristoszdump.8.txt:	zdump.8
8151.16Schristoszic.8.txt:	zic.8
8161.16Schristos
8171.16Schristos$(MANTXTS):	workman.sh
8181.35Schristos		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out
8191.35Schristos		mv $@.out $@
8201.9Schristos
8211.6Schristos# Set the time stamps to those of the git repository, if available,
8221.6Schristos# and if the files have not changed since then.
8231.6Schristos# This uses GNU 'touch' syntax 'touch -d@N FILE',
8241.6Schristos# where N is the number of seconds since 1970.
8251.16Schristos# If git or GNU 'touch' is absent, don't bother to sync with git timestamps.
8261.16Schristos# Also, set the timestamp of each prebuilt file like 'leapseconds'
8271.16Schristos# to be the maximum of the files it depends on.
8281.16Schristosset-timestamps.out: $(ENCHILADA)
8291.16Schristos		rm -f $@
8301.35Schristos		if (type git) >/dev/null 2>&1 && \
8311.35Schristos		   files=`git ls-files $(ENCHILADA)` && \
8321.16Schristos		   touch -md @1 test.out; then \
8331.16Schristos		  rm -f test.out && \
8341.16Schristos		  for file in $$files; do \
8351.16Schristos		    if git diff --quiet $$file; then \
8361.16Schristos		      time=`git log -1 --format='tformat:%ct' $$file` && \
8371.16Schristos		      touch -cmd @$$time $$file; \
8381.16Schristos		    else \
8391.16Schristos		      echo >&2 "$$file: warning: does not match repository"; \
8401.16Schristos		    fi || exit; \
8411.16Schristos		  done; \
8421.16Schristos		fi
8431.16Schristos		touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds
8441.16Schristos		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
8451.16Schristos		  touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \
8461.16Schristos		    exit; \
8471.6Schristos		done
8481.38Schristos		touch -cmr `ls -t $(TZDATA_ZI_DEPS) | sed 1q` tzdata.zi
8491.35Schristos		touch -cmr `ls -t $(TZS_DEPS) | sed 1q` $(TZS)
8501.35Schristos		touch -cmr `ls -t $(VERSION_DEPS) | sed 1q` version
8511.16Schristos		touch $@
8521.6Schristos
8531.1Smlelstv# The zics below ensure that each data file can stand on its own.
8541.1Smlelstv# We also do an all-files run to catch links to links.
8551.1Smlelstv
8561.29Schristoscheck_public:
8571.29Schristos		$(MAKE) maintainer-clean
8581.39Schristos		$(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' ALL
8591.34Schristos		mkdir -p public.dir
8601.39Schristos		for i in $(TDATA_TO_CHECK) tzdata.zi; do \
8611.34Schristos		  $(zic) -v -d public.dir $$i 2>&1 || exit; \
8621.9Schristos		done
8631.39Schristos		$(zic) -v -d public.dir $(TDATA_TO_CHECK)
8641.34Schristos		rm -fr public.dir
8651.9Schristos
8661.14Schristos# Check that the code works under various alternative
8671.14Schristos# implementations of time_t.
8681.14Schristoscheck_time_t_alternatives:
8691.23Schristos		if diff -q Makefile Makefile 2>/dev/null; then \
8701.23Schristos		  quiet_option='-q'; \
8711.23Schristos		else \
8721.23Schristos		  quiet_option=''; \
8731.23Schristos		fi && \
8741.35Schristos		wd=`pwd` && \
8751.22Schristos		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
8761.14Schristos		for type in $(TIME_T_ALTERNATIVES); do \
8771.34Schristos		  mkdir -p time_t.dir/$$type && \
8781.29Schristos		  $(MAKE) clean_misc && \
8791.35Schristos		  $(MAKE) TOPDIR="$$wd/time_t.dir/$$type" \
8801.14Schristos		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \
8811.23Schristos		    REDO='$(REDO)' \
8821.14Schristos		    install && \
8831.23Schristos		  diff $$quiet_option -r \
8841.39Schristos		    time_t.dir/int64_t/etc \
8851.39Schristos		    time_t.dir/$$type/etc && \
8861.39Schristos		  diff $$quiet_option -r \
8871.39Schristos		    time_t.dir/int64_t/usr/share \
8881.39Schristos		    time_t.dir/$$type/usr/share && \
8891.14Schristos		  case $$type in \
8901.14Schristos		  int32_t) range=-2147483648,2147483647;; \
8911.14Schristos		  uint32_t) range=0,4294967296;; \
8921.14Schristos		  int64_t) continue;; \
8931.14Schristos		  *u*) range=0,10000000000;; \
8941.14Schristos		  *) range=-10000000000,10000000000;; \
8951.14Schristos		  esac && \
8961.14Schristos		  echo checking $$type zones ... && \
8971.39Schristos		  time_t.dir/int64_t/usr/bin/zdump -V -t $$range $$zones \
8981.34Schristos		      >time_t.dir/int64_t.out && \
8991.39Schristos		  time_t.dir/$$type/usr/bin/zdump -V -t $$range $$zones \
9001.34Schristos		      >time_t.dir/$$type.out && \
9011.34Schristos		  diff -u time_t.dir/int64_t.out time_t.dir/$$type.out \
9021.14Schristos		    || exit; \
9031.14Schristos		done
9041.34Schristos		rm -fr time_t.dir
9051.34Schristos
9061.40SchristosTRADITIONAL_ASC = \
9071.40Schristos  tzcode$(VERSION).tar.gz.asc \
9081.40Schristos  tzdata$(VERSION).tar.gz.asc
9091.40SchristosALL_ASC = $(TRADITIONAL_ASC) \
9101.40Schristos  tzdata$(VERSION)-rearguard.tar.gz.asc \
9111.40Schristos  tzdb-$(VERSION).tar.lz.asc
9121.40Schristos
9131.35Schristostarballs traditional_tarballs signatures traditional_signatures: version
9141.35Schristos		VERSION=`cat version` && \
9151.35Schristos		$(MAKE) VERSION="$$VERSION" $@_version
9161.35Schristos
9171.40Schristos# These *_version rules are intended for use if VERSION is set by some
9181.40Schristos# other means.  Ordinarily these rules are used only by the above
9191.40Schristos# non-_version rules, which set VERSION on the 'make' command line.
9201.40Schristostarballs_version: traditional_tarballs_version \
9211.40Schristos  tzdata$(VERSION)-rearguard.tar.gz \
9221.40Schristos  tzdb-$(VERSION).tar.lz
9231.38Schristostraditional_tarballs_version: \
9241.38Schristos  tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
9251.40Schristossignatures_version: $(ALL_ASC)
9261.40Schristostraditional_signatures_version: $(TRADITIONAL_ASC)
9271.9Schristos
9281.16Schristostzcode$(VERSION).tar.gz: set-timestamps.out
9291.6Schristos		LC_ALL=C && export LC_ALL && \
9301.7Schristos		tar $(TARFLAGS) -cf - \
9311.23Schristos		    $(COMMON) $(DOCS) $(SOURCES) | \
9321.38Schristos		  gzip $(GZIPFLAGS) >$@.out
9331.35Schristos		mv $@.out $@
9341.10Schristos
9351.16Schristostzdata$(VERSION).tar.gz: set-timestamps.out
9361.6Schristos		LC_ALL=C && export LC_ALL && \
9371.23Schristos		tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
9381.38Schristos		  gzip $(GZIPFLAGS) >$@.out
9391.35Schristos		mv $@.out $@
9401.9Schristos
9411.40Schristostzdata$(VERSION)-rearguard.tar.gz: rearguard.zi set-timestamps.out
9421.40Schristos		rm -fr tzdata$(VERSION)-rearguard.dir
9431.40Schristos		mkdir tzdata$(VERSION)-rearguard.dir
9441.40Schristos		ln $(COMMON) $(DATA) $(MISC) tzdata$(VERSION)-rearguard.dir
9451.40Schristos		cd tzdata$(VERSION)-rearguard.dir && \
9461.40Schristos		  rm -f $(TDATA) $(PACKRATDATA) version
9471.40Schristos		for f in $(TDATA) $(PACKRATDATA); do \
9481.40Schristos		  rearf=tzdata$(VERSION)-rearguard.dir/$$f; \
9491.40Schristos		  $(AWK) -v DATAFORM=rearguard -f ziguard.awk $$f >$$rearf && \
9501.40Schristos		  touch -cmr `ls -t ziguard.awk $$f` $$rearf || exit; \
9511.40Schristos		done
9521.40Schristos		sed '1s/$$/-rearguard/' \
9531.40Schristos		  <version >tzdata$(VERSION)-rearguard.dir/version
9541.40Schristos		touch -cmr version tzdata$(VERSION)-rearguard.dir/version
9551.40Schristos		LC_ALL=C && export LC_ALL && \
9561.40Schristos		  (cd tzdata$(VERSION)-rearguard.dir && \
9571.40Schristos		   tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \
9581.40Schristos		     gzip $(GZIPFLAGS)) >$@.out
9591.40Schristos		mv $@.out $@
9601.40Schristos
9611.34Schristostzdb-$(VERSION).tar.lz: set-timestamps.out
9621.34Schristos		rm -fr tzdb-$(VERSION)
9631.34Schristos		mkdir tzdb-$(VERSION)
9641.34Schristos		ln $(ENCHILADA) tzdb-$(VERSION)
9651.35Schristos		touch -cmr `ls -t tzdb-$(VERSION)/* | sed 1q` tzdb-$(VERSION)
9661.34Schristos		LC_ALL=C && export LC_ALL && \
9671.35Schristos		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out
9681.35Schristos		mv $@.out $@
9691.9Schristos
9701.9Schristostzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
9711.9Schristostzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
9721.40Schristostzdata$(VERSION)-rearguard.tar.gz.asc: tzdata$(VERSION)-rearguard.tar.gz
9731.34Schristostzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
9741.40Schristos$(ALL_ASC):
9751.34Schristos		gpg --armor --detach-sign $?
9761.34Schristos
9771.1Smlelstvtypecheck:
9781.29Schristos		$(MAKE) clean
9791.15Schristos		for i in "long long" unsigned; \
9801.1Smlelstv		do \
9811.29Schristos			$(MAKE) CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
9821.1Smlelstv			./zdump -v Europe/Rome ; \
9831.29Schristos			$(MAKE) clean ; \
9841.1Smlelstv		done
9851.1Smlelstv
9861.38Schristoszonenames:	tzdata.zi
9871.38Schristos		@$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
9881.1Smlelstv
9891.1Smlelstvasctime.o:	private.h tzfile.h
9901.1Smlelstvdate.o:		private.h
9911.1Smlelstvdifftime.o:	private.h
9921.1Smlelstvlocaltime.o:	private.h tzfile.h
9931.23Schristosstrftime.o:	private.h tzfile.h
9941.6Schristoszdump.o:	version.h
9951.6Schristoszic.o:		private.h tzfile.h version.h
9961.1Smlelstv
9971.1Smlelstv.KEEP_STATE:
9981.22Schristos
9991.22Schristos.PHONY: ALL INSTALL all
10001.40Schristos.PHONY: check check_character_set check_links check_name_lengths
10011.26Schristos.PHONY: check_public check_sorted check_tables
10021.34Schristos.PHONY: check_time_t_alternatives check_tzs check_web check_white_space
10031.38Schristos.PHONY: check_zishrink
10041.40Schristos.PHONY: clean clean_misc dummy.zd force_tzs
10051.32Schristos.PHONY: install install_data maintainer-clean names
10061.32Schristos.PHONY: posix_only posix_packrat posix_right
10071.34Schristos.PHONY: public right_only right_posix signatures signatures_version
10081.40Schristos.PHONY: tarballs tarballs_version
10091.40Schristos.PHONY: traditional_signatures traditional_signatures_version
10101.40Schristos.PHONY: traditional_tarballs traditional_tarballs_version
10111.40Schristos.PHONY: typecheck
10121.22Schristos.PHONY: zonenames zones
10131.40Schristos.PHONY: $(ZDS)
1014