Makefile revision 1.54
11.41Schristos# Make and install tzdb code and data.
21.41Schristos
31.1Smlelstv# This file is in the public domain, so clarified as of
41.1Smlelstv# 2009-05-17 by Arthur David Olson.
51.1Smlelstv
61.10Schristos# Package name for the code distribution.
71.10SchristosPACKAGE=	tzcode
81.10Schristos
91.34Schristos# Version number for the distribution, overridden in the 'tarballs' rule below.
101.35SchristosVERSION=	unknown
111.9Schristos
121.9Schristos# Email address for bug reports.
131.9SchristosBUGEMAIL=	tz@iana.org
141.6Schristos
151.43Schristos# DATAFORM selects the data format.
161.43Schristos# Available formats represent essentially the same data, albeit
171.43Schristos# possibly with minor discrepancies that users are not likely to notice.
181.43Schristos# To get new features and the best data right away, use:
191.40Schristos#	DATAFORM=	vanguard
201.40Schristos# To wait a while before using new features, to give downstream users
211.40Schristos# time to upgrade zic (the default), use:
221.40Schristos#	DATAFORM=	main
231.40Schristos# To wait even longer for new features, use:
241.40Schristos#	DATAFORM=	rearguard
251.46Schristos# Rearguard users might also want "ZFLAGS = -b fat"; see below.
261.40SchristosDATAFORM=		main
271.40Schristos
281.41Schristos# Change the line below for your timezone (after finding the one you want in
291.41Schristos# one of the $(TDATA) source files, or adding it to a source file).
301.41Schristos# Alternatively, if you discover you've got the wrong timezone, you can just
311.46Schristos# 'zic -l -' to remove it, or 'zic -l rightzone' to change it.
321.1Smlelstv# Use the command
331.1Smlelstv#	make zonenames
341.1Smlelstv# to get a list of the values you can use for LOCALTIME.
351.1Smlelstv
361.51SchristosLOCALTIME=	Factory
371.1Smlelstv
381.44Schristos# The POSIXRULES macro controls interpretation of nonstandard and obsolete
391.44Schristos# POSIX-like TZ settings like TZ='EET-2EEST' that lack DST transition rules.
401.46Schristos# Such a setting uses the rules in a template file to determine
411.46Schristos# "spring forward" and "fall back" days and times; the environment
421.46Schristos# variable itself specifies UT offsets of standard and daylight saving time.
431.44Schristos#
441.46Schristos# If POSIXRULES is '-', no template is installed; this is the default.
451.44Schristos#
461.46Schristos# Any other value for POSIXRULES is obsolete and should not be relied on, as:
471.44Schristos# * It does not work correctly in popular implementations such as GNU/Linux.
481.49Schristos# * It does not work even in tzcode, except for historical timestamps
491.49Schristos#   that precede the last explicit transition in the POSIXRULES file.
501.49Schristos#   Hence it typically does not work for current and future timestamps.
511.44Schristos# In short, software should avoid ruleless settings like TZ='EET-2EEST'
521.44Schristos# and so should not depend on the value of POSIXRULES.
531.46Schristos#
541.46Schristos# If, despite the above, you want a template for handling these settings,
551.46Schristos# you can change the line below (after finding the timezone you want in the
561.46Schristos# one of the $(TDATA) source files, or adding it to a source file).
571.46Schristos# Alternatively, if you discover you've got the wrong timezone, you can just
581.46Schristos# 'zic -p -' to remove it, or 'zic -p rightzone' to change it.
591.46Schristos# Use the command
601.46Schristos#	make zonenames
611.46Schristos# to get a list of the values you can use for POSIXRULES.
621.1Smlelstv
631.46SchristosPOSIXRULES=	-
641.1Smlelstv
651.1Smlelstv# Also see TZDEFRULESTRING below, which takes effect only
661.1Smlelstv# if the time zone files cannot be accessed.
671.1Smlelstv
681.1Smlelstv
691.39Schristos# Installation locations.
701.39Schristos#
711.39Schristos# The defaults are suitable for Debian, except that if REDO is
721.39Schristos# posix_right or right_posix then files that Debian puts under
731.39Schristos# /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
741.39Schristos# put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
751.39Schristos# respectively.  Problems with the Debian approach are discussed in
761.39Schristos# the commentary for the right_posix rule (below).
771.39Schristos
781.39Schristos# Destination directory, which can be used for staging.
791.39Schristos# 'make DESTDIR=/stage install' installs under /stage (e.g., to
801.39Schristos# /stage/etc/localtime instead of to /etc/localtime).  Files under
811.39Schristos# /stage are not intended to work as-is, but can be copied by hand to
821.39Schristos# the root directory later.  If DESTDIR is empty, 'make install' does
831.39Schristos# not stage, but installs directly into production locations.
841.39SchristosDESTDIR =
851.39Schristos
861.39Schristos# Everything is installed into subdirectories of TOPDIR, and used there.
871.39Schristos# TOPDIR should be empty (meaning the root directory),
881.39Schristos# or a directory name that does not end in "/".
891.39Schristos# TOPDIR should be empty or an absolute name unless you're just testing.
901.39SchristosTOPDIR =
911.39Schristos
921.41Schristos# The default local timezone is taken from the file TZDEFAULT.
931.39SchristosTZDEFAULT = $(TOPDIR)/etc/localtime
941.39Schristos
951.39Schristos# The subdirectory containing installed program and data files, and
961.39Schristos# likewise for installed files that can be shared among architectures.
971.39Schristos# These should be relative file names.
981.39SchristosUSRDIR = usr
991.39SchristosUSRSHAREDIR = $(USRDIR)/share
1001.1Smlelstv
1011.41Schristos# "Compiled" timezone information is placed in the "TZDIR" directory
1021.1Smlelstv# (and subdirectories).
1031.38Schristos# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
1041.15SchristosTZDIR_BASENAME=	zoneinfo
1051.39SchristosTZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
1061.1Smlelstv
1071.39Schristos# The "tzselect" and (if you do "make INSTALL") "date" commands go in:
1081.39SchristosBINDIR = $(TOPDIR)/$(USRDIR)/bin
1091.1Smlelstv
1101.39Schristos# The "zdump" command goes in:
1111.39SchristosZDUMPDIR = $(BINDIR)
1121.1Smlelstv
1131.39Schristos# The "zic" command goes in:
1141.39SchristosZICDIR = $(TOPDIR)/$(USRDIR)/sbin
1151.1Smlelstv
1161.1Smlelstv# Manual pages go in subdirectories of. . .
1171.39SchristosMANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
1181.1Smlelstv
1191.39Schristos# Library functions are put in an archive in LIBDIR.
1201.39SchristosLIBDIR = $(TOPDIR)/$(USRDIR)/lib
1211.1Smlelstv
1221.1Smlelstv
1231.41Schristos# Types to try, as an alternative to time_t.
1241.41SchristosTIME_T_ALTERNATIVES = $(TIME_T_ALTERNATIVES_HEAD) $(TIME_T_ALTERNATIVES_TAIL)
1251.49SchristosTIME_T_ALTERNATIVES_HEAD = int_least64_t
1261.49SchristosTIME_T_ALTERNATIVES_TAIL = int_least32_t uint_least32_t uint_least64_t
1271.1Smlelstv
1281.43Schristos# What kind of TZif data files to generate.  (TZif is the binary time
1291.43Schristos# zone data format that zic generates; see Internet RFC 8536.)
1301.37Schristos# If you want only POSIX time, with time values interpreted as
1311.37Schristos# seconds since the epoch (not counting leap seconds), use
1321.1Smlelstv#	REDO=		posix_only
1331.38Schristos# below.  If you want only "right" time, with values interpreted
1341.37Schristos# as seconds since the epoch (counting leap seconds), use
1351.1Smlelstv#	REDO=		right_only
1361.1Smlelstv# below.  If you want both sets of data available, with leap seconds not
1371.1Smlelstv# counted normally, use
1381.1Smlelstv#	REDO=		posix_right
1391.1Smlelstv# below.  If you want both sets of data available, with leap seconds counted
1401.1Smlelstv# normally, use
1411.1Smlelstv#	REDO=		right_posix
1421.32Schristos# below.  POSIX mandates that leap seconds not be counted; for compatibility
1431.37Schristos# with it, use "posix_only" or "posix_right".  Use POSIX time on systems with
1441.37Schristos# leap smearing; this can work better than unsmeared "right" time with
1451.37Schristos# applications that are not leap second aware, and is closer to unsmeared
1461.37Schristos# "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
1471.1Smlelstv
1481.1SmlelstvREDO=		posix_right
1491.1Smlelstv
1501.45Schristos# Whether to put an "Expires" line in the leapseconds file.
1511.45Schristos# Use EXPIRES_LINE=1 to put the line in, 0 to omit it.
1521.45Schristos# The EXPIRES_LINE value matters only if REDO's value contains "right".
1531.45Schristos# If you change EXPIRES_LINE, remove the leapseconds file before running "make".
1541.45Schristos# zic's support for the Expires line was introduced in tzdb 2020a,
1551.49Schristos# and was modified in tzdb 2021b to generate version 4 TZif files.
1561.49Schristos# EXPIRES_LINE defaults to 0 for now so that the leapseconds file
1571.49Schristos# can be given to pre-2020a zic implementations and so that TZif files
1581.49Schristos# built by newer zic implementations can be read by pre-2021b libraries.
1591.45SchristosEXPIRES_LINE=	0
1601.45Schristos
1611.41Schristos# To install data in text form that has all the information of the TZif data,
1621.38Schristos# (optionally incorporating leap second information), use
1631.38Schristos#	TZDATA_TEXT=	tzdata.zi leapseconds
1641.38Schristos# To install text data without leap second information (e.g., because
1651.38Schristos# REDO='posix_only'), use
1661.38Schristos#	TZDATA_TEXT=	tzdata.zi
1671.38Schristos# To avoid installing text data, use
1681.38Schristos#	TZDATA_TEXT=
1691.38Schristos
1701.38SchristosTZDATA_TEXT=	leapseconds tzdata.zi
1711.38Schristos
1721.38Schristos# For backward-compatibility links for old zone names, use
1731.39Schristos#	BACKWARD=	backward
1741.38Schristos# To omit these links, use
1751.38Schristos#	BACKWARD=
1761.38Schristos
1771.39SchristosBACKWARD=	backward
1781.38Schristos
1791.51Schristos# If you want out-of-scope and often-wrong data from the file 'backzone',
1801.51Schristos# but only for entries listed in the backward-compatibility file zone.tab, use
1811.32Schristos#	PACKRATDATA=	backzone
1821.51Schristos#	PACKRATLIST=	zone.tab
1831.51Schristos# If you want all the 'backzone' data, use
1841.51Schristos#	PACKRATDATA=	backzone
1851.51Schristos#	PACKRATLIST=
1861.32Schristos# To omit this data, use
1871.32Schristos#	PACKRATDATA=
1881.51Schristos#	PACKRATLIST=
1891.32Schristos
1901.32SchristosPACKRATDATA=
1911.51SchristosPACKRATLIST=
1921.32Schristos
1931.38Schristos# The name of a locale using the UTF-8 encoding, used during self-tests.
1941.38Schristos# The tests are skipped if the name does not appear to work on this system.
1951.38Schristos
1961.38SchristosUTF8_LOCALE=	en_US.utf8
1971.38Schristos
1981.1Smlelstv# Non-default libraries needed to link.
1991.54Schristos# On some hosts, this should have -lintl unless CFLAGS has -DHAVE_GETTEXT=0.
2001.1SmlelstvLDLIBS=
2011.1Smlelstv
2021.38Schristos# Add the following to the end of the "CFLAGS=" line as needed to override
2031.38Schristos# defaults specified in the source code.  "-DFOO" is equivalent to "-DFOO=1".
2041.38Schristos#  -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
2051.38Schristos#	formats that generate only the last two digits of year numbers
2061.38Schristos#  -DEPOCH_LOCAL if the 'time' function returns local time not UT
2071.38Schristos#  -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
2081.38Schristos#	than what POSIX specifies, assuming local time is UT.
2091.38Schristos#	For example, N is 252460800 on AmigaOS.
2101.32Schristos#  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
2111.38Schristos#  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
2121.54Schristos#  -DHAVE_DECL_TIMEGM=0 if <time.h> does not declare timegm
2131.32Schristos#  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
2141.54Schristos#  -DHAVE_GENERIC=0 if _Generic does not work*
2151.54Schristos#  -DHAVE_GETRANDOM if getrandom works (e.g., GNU/Linux),
2161.54Schristos#	-DHAVE_GETRANDOM=0 to avoid using getrandom
2171.54Schristos#  -DHAVE_GETTEXT if gettext works (e.g., GNU/Linux, FreeBSD, Solaris),
2181.54Schristos#	where LDLIBS also needs to contain -lintl on some hosts;
2191.54Schristos#	-DHAVE_GETTEXT=0 to avoid using gettext
2201.38Schristos#  -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
2211.35Schristos#	ctime_r and asctime_r incompatibly with the POSIX standard
2221.35Schristos#	(Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
2231.54Schristos#  -DHAVE_INTTYPES_H=0 if <inttypes.h> does not work*
2241.16Schristos#  -DHAVE_LINK=0 if your system lacks a link function
2251.23Schristos#  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
2261.23Schristos#  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
2271.23Schristos#	localtime_rz can make zdump significantly faster, but is nonstandard.
2281.49Schristos#  -DHAVE_MALLOC_ERRNO=0 if malloc etc. do not set errno on failure.
2291.32Schristos#  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
2301.32Schristos#	functions like 'link' or variables like 'tzname' required by POSIX
2311.53Schristos#  -DHAVE_SETENV=0 if your system lacks the setenv function
2321.38Schristos#  -DHAVE_SNPRINTF=0 if your system lacks the snprintf function
2331.54Schristos#  -DHAVE_STDCKDINT_H=0 if neither <stdckdint.h> nor substitutes like
2341.54Schristos#	__builtin_add_overflow work*
2351.54Schristos#  -DHAVE_STDINT_H=0 if <stdint.h> does not work*
2361.38Schristos#  -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
2371.28Schristos#  -DHAVE_STRDUP=0 if your system lacks the strdup function
2381.40Schristos#  -DHAVE_STRTOLL=0 if your system lacks the strtoll function
2391.1Smlelstv#  -DHAVE_SYMLINK=0 if your system lacks the symlink function
2401.54Schristos#  -DHAVE_SYS_STAT_H=0 if <sys/stat.h> does not work*
2411.23Schristos#  -DHAVE_TZSET=0 if your system lacks a tzset function
2421.54Schristos#  -DHAVE_UNISTD_H=0 if <unistd.h> does not work*
2431.54Schristos#  -DHAVE_UTMPX_H=0 if <utmpx.h> does not work*
2441.38Schristos#  -Dlocale_t=XXX if your system uses XXX instead of locale_t
2451.40Schristos#  -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
2461.40Schristos#	with external linkage, e.g., applications cannot define 'localtime'.
2471.38Schristos#  -Dssize_t=long on hosts like MS-Windows that lack ssize_t
2481.40Schristos#  -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
2491.40Schristos#	security implications and is not recommended for general use
2501.38Schristos#  -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
2511.23Schristos#	not needed by the main-program tz code, which is single-threaded.
2521.23Schristos#	Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
2531.14Schristos#  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
2541.38Schristos#	This is intended for internal use only; it mangles external names.
2551.1Smlelstv#  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
2561.22Schristos#  -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
2571.1Smlelstv#	the default is system-supplied, typically "/usr/lib/locale"
2581.14Schristos#  -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
2591.38Schristos#	DST transitions if the time zone files cannot be accessed
2601.38Schristos#  -DUNINIT_TRAP if reading uninitialized storage can cause problems
2611.23Schristos#	other than simply getting garbage data
2621.23Schristos#  -DUSE_LTZ=0 to build zdump with the system time zone library
2631.23Schristos#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
2641.46Schristos#  -DZIC_BLOAT_DEFAULT=\"fat\" to default zic's -b option to "fat", and
2651.46Schristos#	similarly for "slim".  Fat TZif files work around incompatibilities
2661.53Schristos#	and bugs in some TZif readers, notably older ones that
2671.53Schristos#	ignore or otherwise mishandle 64-bit data in TZif files;
2681.53Schristos#	however, fat TZif files may trigger bugs in newer TZif readers.
2691.53Schristos#	Slim TZif files are more efficient, and are the default.
2701.1Smlelstv#  -DZIC_MAX_ABBR_LEN_WO_WARN=3
2711.1Smlelstv#	(or some other number) to set the maximum time zone abbreviation length
2721.1Smlelstv#	that zic will accept without a warning (the default is 6)
2731.30Schristos#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
2741.53Schristos#
2751.53Schristos# * Options marked "*" can be omitted if your compiler is C23 compatible.
2761.53Schristos#
2771.38Schristos# Select instrumentation via "make GCC_INSTRUMENT='whatever'".
2781.38SchristosGCC_INSTRUMENT = \
2791.38Schristos  -fsanitize=undefined -fsanitize-address-use-after-scope \
2801.38Schristos  -fsanitize-undefined-trap-on-error -fstack-protector
2811.49Schristos# Omit -fanalyzer from GCC_DEBUG_FLAGS, as it makes GCC too slow.
2821.38SchristosGCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \
2831.38Schristos  $(GCC_INSTRUMENT) \
2841.38Schristos  -Wall -Wextra \
2851.38Schristos  -Walloc-size-larger-than=100000 -Warray-bounds=2 \
2861.51Schristos  -Wbad-function-cast -Wbidi-chars=any,ucn -Wcast-align=strict -Wdate-time \
2871.38Schristos  -Wdeclaration-after-statement -Wdouble-promotion \
2881.49Schristos  -Wduplicated-branches -Wduplicated-cond \
2891.38Schristos  -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
2901.54Schristos  -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op \
2911.38Schristos  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
2921.49Schristos  -Wnull-dereference \
2931.38Schristos  -Wold-style-definition -Woverlength-strings -Wpointer-arith \
2941.49Schristos  -Wshadow -Wshift-overflow=2 -Wstrict-overflow \
2951.49Schristos  -Wstrict-prototypes -Wstringop-overflow=4 \
2961.40Schristos  -Wstringop-truncation -Wsuggest-attribute=cold \
2971.38Schristos  -Wsuggest-attribute=const -Wsuggest-attribute=format \
2981.40Schristos  -Wsuggest-attribute=malloc \
2991.38Schristos  -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
3001.51Schristos  -Wtrampolines -Wundef -Wuninitialized -Wunused-macros -Wuse-after-free=3 \
3011.38Schristos  -Wvariadic-macros -Wvla -Wwrite-strings \
3021.38Schristos  -Wno-address -Wno-format-nonliteral -Wno-sign-compare \
3031.54Schristos  -Wno-type-limits
3041.1Smlelstv#
3051.1Smlelstv# If your system has a "GMT offset" field in its "struct tm"s
3061.1Smlelstv# (or if you decide to add such a field in your system's "time.h" file),
3071.1Smlelstv# add the name to a define such as
3081.1Smlelstv#	-DTM_GMTOFF=tm_gmtoff
3091.23Schristos# to the end of the "CFLAGS=" line.  If not defined, the code attempts to
3101.23Schristos# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
3111.23Schristos# Similarly, if your system has a "zone abbreviation" field, define
3121.1Smlelstv#	-DTM_ZONE=tm_zone
3131.52Schristos# and define NO_TM_ZONE to suppress any guessing.  Although these two fields
3141.52Schristos# not required by POSIX, a future version of POSIX is planned to require them
3151.52Schristos# and they are widely available on GNU/Linux and BSD systems.
3161.1Smlelstv#
3171.38Schristos# The next batch of options control support for external variables
3181.38Schristos# exported by tzcode.  In practice these variables are less useful
3191.38Schristos# than TM_GMTOFF and TM_ZONE.  However, most of them are standardized.
3201.38Schristos# #
3211.38Schristos# # To omit or support the external variable "tzname", add one of:
3221.45Schristos# #	-DHAVE_TZNAME=0 # do not support "tzname"
3231.45Schristos# #	-DHAVE_TZNAME=1 # support "tzname", which is defined by system library
3241.45Schristos# #	-DHAVE_TZNAME=2 # support and define "tzname"
3251.38Schristos# # to the "CFLAGS=" line.  "tzname" is required by POSIX 1988 and later.
3261.38Schristos# # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
3271.38Schristos# # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
3281.38Schristos# # crashes when combined with some platforms' standard libraries,
3291.38Schristos# # presumably due to memory allocation issues.
3301.38Schristos# #
3311.38Schristos# # To omit or support the external variables "timezone" and "daylight", add
3321.45Schristos# #	-DUSG_COMPAT=0 # do not support
3331.45Schristos# #	-DUSG_COMPAT=1 # support, and variables are defined by system library
3341.45Schristos# #	-DUSG_COMPAT=2 # support and define variables
3351.38Schristos# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by
3361.38Schristos# # Unix Systems Group code and are required by POSIX 2008 (with XSI) and later.
3371.38Schristos# # If not defined, the code attempts to guess USG_COMPAT from other macros.
3381.38Schristos# #
3391.38Schristos# # To support the external variable "altzone", add
3401.45Schristos# #	-DALTZONE=0 # do not support
3411.45Schristos# #	-DALTZONE=1 # support "altzone", which is defined by system library
3421.45Schristos# #	-DALTZONE=2 # support and define "altzone"
3431.38Schristos# # to the end of the "CFLAGS=" line; although "altzone" appeared in
3441.38Schristos# # System V Release 3.1 it has not been standardized.
3451.45Schristos# # If not defined, the code attempts to guess ALTZONE from other macros.
3461.38Schristos#
3471.1Smlelstv# If you want functions that were inspired by early versions of X3J11's work,
3481.1Smlelstv# add
3491.1Smlelstv#	-DSTD_INSPIRED
3501.54Schristos# to the end of the "CFLAGS=" line.  This arranges for the following
3511.54Schristos# functions to be added to the time conversion library.
3521.1Smlelstv# "offtime" is like "gmtime" except that it accepts a second (long) argument
3531.1Smlelstv# that gives an offset to add to the time_t when converting it.
3541.1Smlelstv# "timelocal" is equivalent to "mktime".
3551.1Smlelstv# "timeoff" is like "timegm" except that it accepts a second (long) argument
3561.1Smlelstv# that gives an offset to use when converting to a time_t.
3571.1Smlelstv# "posix2time" and "time2posix" are described in an included manual page.
3581.1Smlelstv# X3J11's work does not describe any of these functions.
3591.1Smlelstv# These functions may well disappear in future releases of the time
3601.1Smlelstv# conversion package.
3611.1Smlelstv#
3621.23Schristos# If you don't want functions that were inspired by NetBSD, add
3631.23Schristos#	-DNETBSD_INSPIRED=0
3641.23Schristos# to the end of the "CFLAGS=" line.  Otherwise, the functions
3651.23Schristos# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
3661.23Schristos# time library, and if STD_INSPIRED is also defined the functions
3671.23Schristos# "posix2time_z" and "time2posix_z" are added as well.
3681.23Schristos# The functions ending in "_z" (or "_rz") are like their unsuffixed
3691.23Schristos# (or suffixed-by-"_r") counterparts, except with an extra first
3701.41Schristos# argument of opaque type timezone_t that specifies the timezone.
3711.23Schristos# "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
3721.23Schristos#
3731.1Smlelstv# If you want to allocate state structures in localtime, add
3741.1Smlelstv#	-DALL_STATE
3751.1Smlelstv# to the end of the "CFLAGS=" line.  Storage is obtained by calling malloc.
3761.1Smlelstv#
3771.1Smlelstv# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
3781.1Smlelstv# out by the National Institute of Standards and Technology
3791.1Smlelstv# which claims to test C and Posix conformance.  If you want to pass PCTS, add
3801.1Smlelstv#	-DPCTS
3811.1Smlelstv# to the end of the "CFLAGS=" line.
3821.1Smlelstv#
3831.1Smlelstv# If you want strict compliance with XPG4 as of 1994-04-09, add
3841.1Smlelstv#	-DXPG4_1994_04_09
3851.1Smlelstv# to the end of the "CFLAGS=" line.  This causes "strftime" to always return
3861.38Schristos# 53 as a week number (rather than 52 or 53) for January days before
3871.38Schristos# January's first Monday when a "%V" format is used and January 1
3881.1Smlelstv# falls on a Friday, Saturday, or Sunday.
3891.1Smlelstv
3901.1SmlelstvCFLAGS=
3911.1Smlelstv
3921.9Schristos# Linker flags.  Default to $(LFLAGS) for backwards compatibility
3931.34Schristos# to release 2012h and earlier.
3941.9Schristos
3951.9SchristosLDFLAGS=	$(LFLAGS)
3961.1Smlelstv
3971.32Schristos# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
3981.32Schristos# submake command lines.  The default is no leap seconds.
3991.32Schristos
4001.32SchristosLEAPSECONDS=
4011.32Schristos
4021.32Schristos# The zic command and its arguments.
4031.32Schristos
4041.1Smlelstvzic=		./zic
4051.1SmlelstvZIC=		$(zic) $(ZFLAGS)
4061.1Smlelstv
4071.43Schristos# To shrink the size of installed TZif files,
4081.43Schristos# append "-r @N" to omit data before N-seconds-after-the-Epoch.
4091.53Schristos# To grow the files and work around bugs in older applications,
4101.53Schristos# possibly at the expense of introducing bugs in newer ones,
4111.53Schristos# append "-b fat"; see ZIC_BLOAT_DEFAULT above.
4121.44Schristos# See the zic man page for more about -b and -r.
4131.15SchristosZFLAGS=
4141.15Schristos
4151.41Schristos# How to use zic to install TZif files.
4161.32Schristos
4171.39SchristosZIC_INSTALL=	$(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS)
4181.32Schristos
4191.22Schristos# The name of a Posix-compliant 'awk' on your system.
4201.50Schristos# mawk 1.3.3 and Solaris 10 /usr/bin/awk do not work.
4211.50Schristos# Also, it is better (though not essential) if 'awk' supports UTF-8,
4221.50Schristos# and unfortunately mawk and busybox awk do not support UTF-8.
4231.50Schristos# Try AWK=gawk or AWK=nawk if your awk has the abovementioned problems.
4241.9SchristosAWK=		awk
4251.9Schristos
4261.16Schristos# The full path name of a Posix-compliant shell, preferably one that supports
4271.16Schristos# the Korn shell's 'select' statement as an extension.
4281.16Schristos# These days, Bash is the most popular.
4291.16Schristos# It should be OK to set this to /bin/sh, on platforms where /bin/sh
4301.16Schristos# lacks 'select' or doesn't completely conform to Posix, but /bin/bash
4311.16Schristos# is typically nicer if it works.
4321.9SchristosKSHELL=		/bin/bash
4331.1Smlelstv
4341.42Schristos# Name of curl <https://curl.haxx.se/>, used for HTML validation.
4351.42SchristosCURL=		curl
4361.42Schristos
4371.44Schristos# Name of GNU Privacy Guard <https://gnupg.org/>, used to sign distributions.
4381.44SchristosGPG=		gpg
4391.44Schristos
4401.23Schristos# This expensive test requires USE_LTZ.
4411.23Schristos# To suppress it, define this macro to be empty.
4421.23SchristosCHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
4431.23Schristos
4441.22Schristos# SAFE_CHAR is a regular expression that matches a safe character.
4451.22Schristos# Some parts of this distribution are limited to safe characters;
4461.22Schristos# others can use any UTF-8 character.
4471.22Schristos# For now, the safe characters are a safe subset of ASCII.
4481.9Schristos# The caller must set the shell variable 'sharp' to the character '#',
4491.9Schristos# since Makefile macros cannot contain '#'.
4501.9Schristos# TAB_CHAR is a single tab character, in single quotes.
4511.9SchristosTAB_CHAR=	'	'
4521.22SchristosSAFE_CHARSET1=	$(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
4531.22SchristosSAFE_CHARSET2=	'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
4541.22SchristosSAFE_CHARSET3=	'abcdefghijklmnopqrstuvwxyz{|}~'
4551.29SchristosSAFE_CHARSET=	$(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
4561.29SchristosSAFE_CHAR=	'[]'$(SAFE_CHARSET)'-]'
4571.29Schristos
4581.41Schristos# These characters are Latin-1, and so are likely to be displayable
4591.41Schristos# even in editors with limited character sets.
4601.41SchristosUNUSUAL_OK_LATIN_1 = «°±»½¾×
4611.41Schristos# This IPA symbol is represented in Unicode as the composition of
4621.41Schristos# U+0075 and U+032F, and U+032F is not considered alphabetic by some
4631.41Schristos# grep implementations that do not grok composition.
4641.41SchristosUNUSUAL_OK_IPA = u̯
4651.40Schristos# Non-ASCII non-letters that OK_CHAR allows, as these characters are
4661.41Schristos# useful in commentary.
4671.41SchristosUNUSUAL_OK_CHARSET= $(UNUSUAL_OK_LATIN_1)$(UNUSUAL_OK_IPA)
4681.40Schristos
4691.51Schristos# Put this in a bracket expression to match spaces.
4701.51Schristoss = [:space:]
4711.51Schristos
4721.29Schristos# OK_CHAR matches any character allowed in the distributed files.
4731.40Schristos# This is the same as SAFE_CHAR, except that UNUSUAL_OK_CHARSET and
4741.40Schristos# multibyte letters are also allowed so that commentary can contain a
4751.40Schristos# few safe symbols and people's names and can quote non-English sources.
4761.40Schristos# Other non-letters are limited to ASCII renderings for the
4771.40Schristos# convenience of maintainers using XEmacs 21.5.34, which by default
4781.40Schristos# mishandles Unicode characters U+0100 and greater.
4791.40SchristosOK_CHAR=	'[][:alpha:]$(UNUSUAL_OK_CHARSET)'$(SAFE_CHARSET)'-]'
4801.22Schristos
4811.22Schristos# SAFE_LINE matches a line of safe characters.
4821.29Schristos# SAFE_SHARP_LINE is similar, except any OK character can follow '#';
4831.22Schristos# this is so that comments can contain non-ASCII characters.
4841.29Schristos# OK_LINE matches a line of OK characters.
4851.22SchristosSAFE_LINE=	'^'$(SAFE_CHAR)'*$$'
4861.29SchristosSAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
4871.29SchristosOK_LINE=	'^'$(OK_CHAR)'*$$'
4881.9Schristos
4891.6Schristos# Flags to give 'tar' when making a distribution.
4901.6Schristos# Try to use flags appropriate for GNU tar.
4911.50SchristosGNUTARFLAGS= --format=pax --pax-option='delete=atime,delete=ctime' \
4921.50Schristos  --numeric-owner --owner=0 --group=0 \
4931.50Schristos  --mode=go+u,go-w --sort=name
4941.6SchristosTARFLAGS=	`if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
4951.6Schristos		 then echo $(GNUTARFLAGS); \
4961.6Schristos		 else :; \
4971.6Schristos		 fi`
4981.6Schristos
4991.6Schristos# Flags to give 'gzip' when making a distribution.
5001.38SchristosGZIPFLAGS=	-9n
5011.6Schristos
5021.54Schristos# When comparing .tzs files, use GNU diff's -F'^TZ=' option if supported.
5031.54Schristos# This makes it easier to see which Zone has been affected.
5041.54SchristosDIFF_TZS=	 diff -u$$(! diff -u -F'^TZ=' - - <>/dev/null >&0 2>&1 \
5051.54Schristos			   || echo ' -F^TZ=')
5061.54Schristos
5071.1Smlelstv###############################################################################
5081.1Smlelstv
5091.29Schristos#MAKE=		make
5101.29Schristos
5111.1Smlelstvcc=		cc
5121.39SchristosCC=		$(cc) -DTZDIR='"$(TZDIR)"'
5131.1Smlelstv
5141.16SchristosAR=		ar
5151.16Schristos
5161.16Schristos# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
5171.16SchristosRANLIB=		:
5181.16Schristos
5191.28SchristosTZCOBJS=	zic.o
5201.38SchristosTZDOBJS=	zdump.o localtime.o asctime.o strftime.o
5211.1SmlelstvDATEOBJS=	date.o localtime.o strftime.o asctime.o
5221.45SchristosLIBSRCS=	localtime.c asctime.c difftime.c strftime.c
5231.45SchristosLIBOBJS=	localtime.o asctime.o difftime.o strftime.o
5241.1SmlelstvHEADERS=	tzfile.h private.h
5251.28SchristosNONLIBSRCS=	zic.c zdump.c
5261.45SchristosNEWUCBSRCS=	date.c
5271.23SchristosSOURCES=	$(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
5281.35Schristos			tzselect.ksh workman.sh
5291.1SmlelstvMANS=		newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
5301.1Smlelstv			tzfile.5 tzselect.8 zic.8 zdump.8
5311.16SchristosMANTXTS=	newctime.3.txt newstrftime.3.txt newtzset.3.txt \
5321.16Schristos			time2posix.3.txt \
5331.16Schristos			tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
5341.16Schristos			date.1.txt
5351.38SchristosCOMMON=		calendars CONTRIBUTING LICENSE Makefile \
5361.49Schristos			NEWS README SECURITY theory.html version
5371.39SchristosWEB_PAGES=	tz-art.html tz-how-to.html tz-link.html
5381.43SchristosCHECK_WEB_PAGES=check_theory.html check_tz-art.html \
5391.43Schristos			check_tz-how-to.html check_tz-link.html
5401.23SchristosDOCS=		$(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
5411.1SmlelstvPRIMARY_YDATA=	africa antarctica asia australasia \
5421.1Smlelstv		europe northamerica southamerica
5431.39SchristosYDATA=		$(PRIMARY_YDATA) etcetera
5441.46SchristosNDATA=		factory
5451.46SchristosTDATA_TO_CHECK=	$(YDATA) $(NDATA) backward
5461.39SchristosTDATA=		$(YDATA) $(NDATA) $(BACKWARD)
5471.22SchristosZONETABLES=	zone1970.tab zone.tab
5481.38SchristosTABDATA=	iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
5491.16SchristosLEAP_DEPS=	leapseconds.awk leap-seconds.list
5501.51SchristosTZDATA_ZI_DEPS=	ziguard.awk zishrink.awk version $(TDATA) \
5511.51Schristos		  $(PACKRATDATA) $(PACKRATLIST)
5521.51SchristosDSTDATA_ZI_DEPS= ziguard.awk $(TDATA) $(PACKRATDATA) $(PACKRATLIST)
5531.39SchristosDATA=		$(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
5541.46Schristos			leapseconds $(ZONETABLES)
5551.40SchristosAWK_SCRIPTS=	checklinks.awk checktab.awk leapseconds.awk \
5561.40Schristos			ziguard.awk zishrink.awk
5571.52SchristosMISC=		$(AWK_SCRIPTS)
5581.34SchristosTZS_YEAR=	2050
5591.41SchristosTZS_CUTOFF_FLAG=	-c $(TZS_YEAR)
5601.34SchristosTZS=		to$(TZS_YEAR).tzs
5611.34SchristosTZS_NEW=	to$(TZS_YEAR)new.tzs
5621.49SchristosTZS_DEPS=	$(YDATA) asctime.c localtime.c \
5631.34Schristos			private.h tzfile.h zdump.c zic.c
5641.51SchristosTZDATA_DIST = $(COMMON) $(DATA) $(MISC)
5651.41Schristos# EIGHT_YARDS is just a yard short of the whole ENCHILADA.
5661.51SchristosEIGHT_YARDS = $(TZDATA_DIST) $(DOCS) $(SOURCES) tzdata.zi
5671.41SchristosENCHILADA = $(EIGHT_YARDS) $(TZS)
5681.34Schristos
5691.34Schristos# Consult these files when deciding whether to rebuild the 'version' file.
5701.34Schristos# This list is not the same as the output of 'git ls-files', since
5711.34Schristos# .gitignore is not distributed.
5721.34SchristosVERSION_DEPS= \
5731.49Schristos		calendars CONTRIBUTING LICENSE Makefile NEWS README SECURITY \
5741.34Schristos		africa antarctica asctime.c asia australasia \
5751.34Schristos		backward backzone \
5761.34Schristos		checklinks.awk checktab.awk \
5771.34Schristos		date.1 date.c difftime.c \
5781.34Schristos		etcetera europe factory iso3166.tab \
5791.34Schristos		leap-seconds.list leapseconds.awk localtime.c \
5801.34Schristos		newctime.3 newstrftime.3 newtzset.3 northamerica \
5811.46Schristos		private.h southamerica strftime.c theory.html \
5821.39Schristos		time2posix.3 tz-art.html tz-how-to.html tz-link.html \
5831.34Schristos		tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
5841.46Schristos		workman.sh zdump.8 zdump.c zic.8 zic.c \
5851.40Schristos		ziguard.awk zishrink.awk \
5861.52Schristos		zone.tab zone1970.tab
5871.1Smlelstv
5881.1Smlelstv# And for the benefit of csh users on systems that assume the user
5891.1Smlelstv# shell should be used to handle commands in Makefiles. . .
5901.1Smlelstv
5911.1SmlelstvSHELL=		/bin/sh
5921.1Smlelstv
5931.46Schristosall:		tzselect zic zdump libtz.a $(TABDATA) \
5941.40Schristos		  vanguard.zi main.zi rearguard.zi
5951.1Smlelstv
5961.29SchristosALL:		all date $(ENCHILADA)
5971.1Smlelstv
5981.16Schristosinstall:	all $(DATA) $(REDO) $(MANS)
5991.39Schristos		mkdir -p '$(DESTDIR)$(BINDIR)' \
6001.39Schristos			'$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
6011.39Schristos			'$(DESTDIR)$(LIBDIR)' \
6021.39Schristos			'$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
6031.39Schristos			'$(DESTDIR)$(MANDIR)/man8'
6041.44Schristos		$(ZIC_INSTALL) -l $(LOCALTIME) \
6051.44Schristos			`case '$(POSIXRULES)' in ?*) echo '-p';; esac \
6061.44Schristos			` $(POSIXRULES) \
6071.39Schristos			-t '$(DESTDIR)$(TZDEFAULT)'
6081.39Schristos		cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
6091.39Schristos		cp tzselect '$(DESTDIR)$(BINDIR)/.'
6101.39Schristos		cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
6111.39Schristos		cp zic '$(DESTDIR)$(ZICDIR)/.'
6121.39Schristos		cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
6131.39Schristos		$(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
6141.39Schristos		cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
6151.39Schristos		cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
6161.39Schristos		cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
6171.1Smlelstv
6181.1SmlelstvINSTALL:	ALL install date.1
6191.39Schristos		mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
6201.39Schristos		cp date '$(DESTDIR)$(BINDIR)/.'
6211.39Schristos		cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
6221.1Smlelstv
6231.48Schristos# Calculate version number from git, if available.
6241.48Schristos# Otherwise, use $(VERSION) unless it is "unknown" and there is already
6251.48Schristos# a 'version' file, in which case reuse the existing 'version' contents
6261.48Schristos# and append "-dirty" if the contents do not already end in "-dirty".
6271.34Schristosversion:	$(VERSION_DEPS)
6281.35Schristos		{ (type git) >/dev/null 2>&1 && \
6291.35Schristos		  V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
6301.35Schristos				--abbrev=7 --dirty` || \
6311.48Schristos		  if test '$(VERSION)' = unknown && V=`cat $@`; then \
6321.48Schristos		    case $$V in *-dirty);; *) V=$$V-dirty;; esac; \
6331.48Schristos		  else \
6341.48Schristos		    V='$(VERSION)'; \
6351.48Schristos		  fi; } && \
6361.35Schristos		printf '%s\n' "$$V" >$@.out
6371.35Schristos		mv $@.out $@
6381.34Schristos
6391.51Schristos# These files can be tailored by setting BACKWARD, PACKRATDATA, PACKRATLIST.
6401.40Schristosvanguard.zi main.zi rearguard.zi: $(DSTDATA_ZI_DEPS)
6411.51Schristos		$(AWK) \
6421.51Schristos		  -v DATAFORM=`expr $@ : '\(.*\).zi'` \
6431.51Schristos		  -v PACKRATDATA='$(PACKRATDATA)' \
6441.51Schristos		  -v PACKRATLIST='$(PACKRATLIST)' \
6451.51Schristos		  -f ziguard.awk \
6461.40Schristos		  $(TDATA) $(PACKRATDATA) >$@.out
6471.40Schristos		mv $@.out $@
6481.41Schristos# This file has a version comment that attempts to capture any tailoring
6491.51Schristos# via BACKWARD, DATAFORM, PACKRATDATA, PACKRATLIST, and REDO.
6501.41Schristostzdata.zi:	$(DATAFORM).zi version zishrink.awk
6511.39Schristos		version=`sed 1q version` && \
6521.41Schristos		  LC_ALL=C $(AWK) \
6531.41Schristos		    -v dataform='$(DATAFORM)' \
6541.41Schristos		    -v deps='$(DSTDATA_ZI_DEPS) zishrink.awk' \
6551.41Schristos		    -v redo='$(REDO)' \
6561.41Schristos		    -v version="$$version" \
6571.41Schristos		    -f zishrink.awk \
6581.40Schristos		    $(DATAFORM).zi >$@.out
6591.38Schristos		mv $@.out $@
6601.38Schristos
6611.34Schristosversion.h:	version
6621.35Schristos		VERSION=`cat version` && printf '%s\n' \
6631.35Schristos		  'static char const PKGVERSION[]="($(PACKAGE)) ";' \
6641.35Schristos		  "static char const TZVERSION[]=\"$$VERSION\";" \
6651.35Schristos		  'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
6661.35Schristos		  >$@.out
6671.35Schristos		mv $@.out $@
6681.6Schristos
6691.1Smlelstvzdump:		$(TZDOBJS)
6701.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
6711.1Smlelstv
6721.32Schristoszic:		$(TZCOBJS)
6731.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
6741.1Smlelstv
6751.16Schristosleapseconds:	$(LEAP_DEPS)
6761.45Schristos		$(AWK) -v EXPIRES_LINE=$(EXPIRES_LINE) \
6771.45Schristos		  -f leapseconds.awk leap-seconds.list >$@.out
6781.35Schristos		mv $@.out $@
6791.15Schristos
6801.32Schristos# Arguments to pass to submakes of install_data.
6811.32Schristos# They can be overridden by later submake arguments.
6821.32SchristosINSTALLARGS = \
6831.39Schristos BACKWARD='$(BACKWARD)' \
6841.39Schristos DESTDIR='$(DESTDIR)' \
6851.32Schristos LEAPSECONDS='$(LEAPSECONDS)' \
6861.32Schristos PACKRATDATA='$(PACKRATDATA)' \
6871.51Schristos PACKRATLIST='$(PACKRATLIST)' \
6881.39Schristos TZDEFAULT='$(TZDEFAULT)' \
6891.39Schristos TZDIR='$(TZDIR)' \
6901.32Schristos ZIC='$(ZIC)'
6911.32Schristos
6921.46SchristosINSTALL_DATA_DEPS = zic leapseconds tzdata.zi
6931.41Schristos
6941.41Schristos# 'make install_data' installs one set of TZif files.
6951.41Schristosinstall_data: $(INSTALL_DATA_DEPS)
6961.38Schristos		$(ZIC_INSTALL) tzdata.zi
6971.32Schristos
6981.41Schristosposix_only: $(INSTALL_DATA_DEPS)
6991.32Schristos		$(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
7001.32Schristos
7011.41Schristosright_only: $(INSTALL_DATA_DEPS)
7021.32Schristos		$(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
7031.32Schristos			install_data
7041.1Smlelstv
7051.1Smlelstv# In earlier versions of this makefile, the other two directories were
7061.1Smlelstv# subdirectories of $(TZDIR).  However, this led to configuration errors.
7071.1Smlelstv# For example, with posix_right under the earlier scheme,
7081.1Smlelstv# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
7091.1Smlelstv# but gmtime without leap seconds, which led to problems with applications
7101.1Smlelstv# like sendmail that subtract gmtime from localtime.
7111.1Smlelstv# Therefore, the other two directories are now siblings of $(TZDIR).
7121.1Smlelstv# You must replace all of $(TZDIR) to switch from not using leap seconds
7131.1Smlelstv# to using them, or vice versa.
7141.32Schristosright_posix:	right_only
7151.39Schristos		rm -fr '$(DESTDIR)$(TZDIR)-leaps'
7161.39Schristos		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
7171.39Schristos		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
7181.39Schristos		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
7191.15Schristos
7201.32Schristosposix_right:	posix_only
7211.39Schristos		rm -fr '$(DESTDIR)$(TZDIR)-posix'
7221.39Schristos		ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
7231.39Schristos		  $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
7241.39Schristos		$(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
7251.32Schristos
7261.1Smlelstvzones:		$(REDO)
7271.1Smlelstv
7281.40Schristos# dummy.zd is not a real file; it is mentioned here only so that the
7291.40Schristos# top-level 'make' does not have a syntax error.
7301.40SchristosZDS = dummy.zd
7311.40Schristos# Rule used only by submakes invoked by the $(TZS_NEW) rule.
7321.40Schristos# It is separate so that GNU 'make -j' can run instances in parallel.
7331.40Schristos$(ZDS): zdump
7341.41Schristos		./zdump -i $(TZS_CUTOFF_FLAG) '$(wd)/'$$(expr $@ : '\(.*\).zd') \
7351.41Schristos		  >$@
7361.40Schristos
7371.41SchristosTZS_NEW_DEPS = tzdata.zi zdump zic
7381.41Schristos$(TZS_NEW): $(TZS_NEW_DEPS)
7391.41Schristos		rm -fr tzs$(TZS_YEAR).dir
7401.41Schristos		mkdir tzs$(TZS_YEAR).dir
7411.41Schristos		$(zic) -d tzs$(TZS_YEAR).dir tzdata.zi
7421.38Schristos		$(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
7431.38Schristos		   tzdata.zi | LC_ALL=C sort >$@.out
7441.35Schristos		wd=`pwd` && \
7451.41Schristos		x=`$(AWK) '/^Z/{print "tzs$(TZS_YEAR).dir/" $$2 ".zd"}' \
7461.41Schristos				tzdata.zi \
7471.40Schristos			| LC_ALL=C sort -t . -k 2,2` && \
7481.41Schristos		set x $$x && \
7491.40Schristos		shift && \
7501.40Schristos		ZDS=$$* && \
7511.41Schristos		$(MAKE) wd="$$wd" TZS_CUTOFF_FLAG="$(TZS_CUTOFF_FLAG)" \
7521.41Schristos		  ZDS="$$ZDS" $$ZDS && \
7531.41Schristos		sed 's,^TZ=".*\.dir/,TZ=",' $$ZDS >>$@.out
7541.41Schristos		rm -fr tzs$(TZS_YEAR).dir
7551.40Schristos		mv $@.out $@
7561.34Schristos
7571.41Schristos# If $(TZS) exists but 'make check_tzs' fails, a maintainer should inspect the
7581.34Schristos# failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
7591.34Schristos$(TZS):
7601.41Schristos		touch $@
7611.34Schristos
7621.34Schristosforce_tzs:	$(TZS_NEW)
7631.34Schristos		cp $(TZS_NEW) $(TZS)
7641.34Schristos
7651.16Schristoslibtz.a:	$(LIBOBJS)
7661.37Schristos		rm -f $@
7671.37Schristos		$(AR) -rc $@ $(LIBOBJS)
7681.16Schristos		$(RANLIB) $@
7691.1Smlelstv
7701.1Smlelstvdate:		$(DATEOBJS)
7711.9Schristos		$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
7721.1Smlelstv
7731.34Schristostzselect:	tzselect.ksh version
7741.35Schristos		VERSION=`cat version` && sed \
7751.9Schristos			-e 's|#!/bin/bash|#!$(KSHELL)|g' \
7761.50Schristos			-e 's|AWK=[^}]*|AWK='\''$(AWK)'\''|g' \
7771.9Schristos			-e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
7781.9Schristos			-e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
7791.1Smlelstv			-e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
7801.35Schristos			-e 's|\(TZVERSION\)=.*|\1='"$$VERSION"'|' \
7811.35Schristos			<$@.ksh >$@.out
7821.35Schristos		chmod +x $@.out
7831.35Schristos		mv $@.out $@
7841.1Smlelstv
7851.54Schristoscheck: check_back check_mild
7861.54Schristoscheck_mild:	check_character_set check_white_space check_links \
7871.51Schristos		  check_name_lengths check_slashed_abbrs check_sorted \
7881.51Schristos		  check_tables check_web check_ziguard check_zishrink check_tzs
7891.9Schristos
7901.9Schristoscheck_character_set: $(ENCHILADA)
7911.38Schristos	test ! '$(UTF8_LOCALE)' || \
7921.38Schristos	! printf 'A\304\200B\n' | \
7931.38Schristos	  LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 || { \
7941.38Schristos		LC_ALL='$(UTF8_LOCALE)' && export LC_ALL && \
7951.22Schristos		sharp='#' && \
7961.35Schristos		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
7971.35Schristos			$(MISC) $(SOURCES) $(WEB_PAGES) \
7981.49Schristos			CONTRIBUTING LICENSE README SECURITY \
7991.38Schristos			version tzdata.zi && \
8001.41Schristos		! grep -Env $(SAFE_LINE)'|^UNUSUAL_OK_'$(OK_CHAR)'*$$' \
8011.40Schristos			Makefile && \
8021.39Schristos		! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
8031.46Schristos			leapseconds zone.tab && \
8041.38Schristos		! grep -Env $(OK_LINE) $(ENCHILADA); \
8051.38Schristos	}
8061.41Schristos	touch $@
8071.22Schristos
8081.23Schristoscheck_white_space: $(ENCHILADA)
8091.35Schristos		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
8101.41Schristos		! grep -En "$$pat" \
8111.41Schristos			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
8121.51Schristos		! grep -n '[$s]$$' \
8131.39Schristos			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
8141.41Schristos		touch $@
8151.23Schristos
8161.51SchristosPRECEDES_FILE_NAME = ^(Zone|Link[$s]+[^$s]+)[$s]+
8171.51SchristosFILE_NAME_COMPONENT_TOO_LONG = $(PRECEDES_FILE_NAME)[^$s]*[^/$s]{15}
8181.38Schristos
8191.39Schristoscheck_name_lengths: $(TDATA_TO_CHECK) backzone
8201.39Schristos		! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
8211.39Schristos			$(TDATA_TO_CHECK) backzone
8221.41Schristos		touch $@
8231.38Schristos
8241.51SchristosPRECEDES_STDOFF = ^(Zone[$s]+[^$s]+)?[$s]+
8251.51SchristosSTDOFF = [-+]?[0-9:.]+
8261.51SchristosRULELESS_SAVE = (-|$(STDOFF)[sd]?)
8271.51SchristosRULELESS_SLASHED_ABBRS = \
8281.51Schristos  $(PRECEDES_STDOFF)$(STDOFF)[$s]+$(RULELESS_SAVE)[$s]+[^$s]*/
8291.51Schristos
8301.51Schristoscheck_slashed_abbrs: $(TDATA_TO_CHECK)
8311.51Schristos		! grep -En '$(RULELESS_SLASHED_ABBRS)' $(TDATA_TO_CHECK)
8321.51Schristos		touch $@
8331.51Schristos
8341.23SchristosCHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
8351.23Schristos
8361.23Schristoscheck_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
8371.54Schristos		$(AWK) '/^Link/ {printf "%.5d %s\n", g, $$3} !/./ {g++}' \
8381.53Schristos		  backward | LC_ALL=C sort -cu
8391.23Schristos		$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
8401.41Schristos		touch $@
8411.23Schristos
8421.54Schristoscheck_back:	checklinks.awk $(TDATA_TO_CHECK)
8431.53Schristos		$(AWK) \
8441.53Schristos		  -v DATAFORM=$(DATAFORM) \
8451.53Schristos		  -v backcheck=backward \
8461.53Schristos		  -f checklinks.awk $(TDATA_TO_CHECK)
8471.54Schristos		touch $@
8481.54Schristos
8491.54Schristoscheck_links:	checklinks.awk tzdata.zi
8501.53Schristos		$(AWK) \
8511.53Schristos		  -v DATAFORM=$(DATAFORM) \
8521.53Schristos		  -f checklinks.awk tzdata.zi
8531.41Schristos		touch $@
8541.26Schristos
8551.49Schristoscheck_tables:	checktab.awk $(YDATA) backward $(ZONETABLES)
8561.22Schristos		for tab in $(ZONETABLES); do \
8571.49Schristos		  test "$$tab" = zone.tab && links='$(BACKWARD)' || links=''; \
8581.49Schristos		  $(AWK) -f checktab.awk -v zone_table=$$tab $(YDATA) $$links \
8591.22Schristos		    || exit; \
8601.22Schristos		done
8611.41Schristos		touch $@
8621.1Smlelstv
8631.34Schristoscheck_tzs:	$(TZS) $(TZS_NEW)
8641.41Schristos		if test -s $(TZS); then \
8651.54Schristos		  $(DIFF_TZS) $(TZS) $(TZS_NEW); \
8661.41Schristos		else \
8671.41Schristos		  cp $(TZS_NEW) $(TZS); \
8681.41Schristos		fi
8691.41Schristos		touch $@
8701.34Schristos
8711.42Schristoscheck_web:	$(CHECK_WEB_PAGES)
8721.43Schristoscheck_theory.html: theory.html
8731.42Schristoscheck_tz-art.html: tz-art.html
8741.46Schristoscheck_tz-how-to.html: tz-how-to.html
8751.42Schristoscheck_tz-link.html: tz-link.html
8761.46Schristoscheck_theory.html check_tz-art.html check_tz-how-to.html check_tz-link.html:
8771.42Schristos		$(CURL) -sS --url https://validator.w3.org/nu/ -F out=gnu \
8781.42Schristos		    -F file=@$$(expr $@ : 'check_\(.*\)') -o $@.out && \
8791.42Schristos		  test ! -s $@.out || { cat $@.out; exit 1; }
8801.42Schristos		mv $@.out $@
8811.38Schristos
8821.51Schristoscheck_ziguard: rearguard.zi vanguard.zi ziguard.awk
8831.51Schristos		$(AWK) -v DATAFORM=rearguard -f ziguard.awk vanguard.zi | \
8841.51Schristos		  diff -u rearguard.zi -
8851.51Schristos		$(AWK) -v DATAFORM=vanguard -f ziguard.awk rearguard.zi | \
8861.51Schristos		  diff -u vanguard.zi -
8871.51Schristos		touch $@
8881.51Schristos
8891.40Schristos# Check that zishrink.awk does not alter the data, and that ziguard.awk
8901.40Schristos# preserves main-format data.
8911.41Schristoscheck_zishrink: check_zishrink_posix check_zishrink_right
8921.41Schristoscheck_zishrink_posix check_zishrink_right: \
8931.51Schristos  zic leapseconds $(PACKRATDATA) $(PACKRATLIST) \
8941.51Schristos  $(TDATA) $(DATAFORM).zi tzdata.zi
8951.41Schristos		rm -fr $@.dir $@-t.dir $@-shrunk.dir
8961.41Schristos		mkdir $@.dir $@-t.dir $@-shrunk.dir
8971.41Schristos		case $@ in \
8981.41Schristos		  *_right) leap='-L leapseconds';; \
8991.41Schristos		  *) leap=;; \
9001.41Schristos		esac && \
9011.41Schristos		  $(ZIC) $$leap -d $@.dir $(DATAFORM).zi && \
9021.41Schristos		  $(ZIC) $$leap -d $@-shrunk.dir tzdata.zi && \
9031.51Schristos		  case $(DATAFORM),$(PACKRATLIST) in \
9041.51Schristos		    main,) \
9051.41Schristos		      $(ZIC) $$leap -d $@-t.dir $(TDATA) && \
9061.40Schristos		      $(AWK) '/^Rule/' $(TDATA) | \
9071.41Schristos			$(ZIC) $$leap -d $@-t.dir - $(PACKRATDATA) && \
9081.41Schristos		      diff -r $@.dir $@-t.dir;; \
9091.41Schristos		  esac
9101.41Schristos		diff -r $@.dir $@-shrunk.dir
9111.41Schristos		rm -fr $@.dir $@-t.dir $@-shrunk.dir
9121.41Schristos		touch $@
9131.1Smlelstv
9141.14Schristosclean_misc:
9151.43Schristos		rm -fr check_*.dir
9161.41Schristos		rm -f *.o *.out $(TIME_T_ALTERNATIVES) \
9171.41Schristos		  check_* core typecheck_* \
9181.46Schristos		  date tzselect version.h zdump zic libtz.a
9191.14Schristosclean:		clean_misc
9201.43Schristos		rm -fr *.dir tzdb-*/
9211.43Schristos		rm -f *.zi $(TZS_NEW)
9221.1Smlelstv
9231.1Smlelstvmaintainer-clean: clean
9241.1Smlelstv		@echo 'This command is intended for maintainers to use; it'
9251.1Smlelstv		@echo 'deletes files that may need special tools to rebuild.'
9261.34Schristos		rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
9271.1Smlelstv
9281.1Smlelstvnames:
9291.1Smlelstv		@echo $(ENCHILADA)
9301.1Smlelstv
9311.23Schristospublic:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
9321.16Schristos		tarballs signatures
9331.16Schristos
9341.16Schristosdate.1.txt:	date.1
9351.16Schristosnewctime.3.txt:	newctime.3
9361.16Schristosnewstrftime.3.txt: newstrftime.3
9371.16Schristosnewtzset.3.txt:	newtzset.3
9381.16Schristostime2posix.3.txt: time2posix.3
9391.16Schristostzfile.5.txt:	tzfile.5
9401.16Schristostzselect.8.txt:	tzselect.8
9411.16Schristoszdump.8.txt:	zdump.8
9421.16Schristoszic.8.txt:	zic.8
9431.16Schristos
9441.16Schristos$(MANTXTS):	workman.sh
9451.35Schristos		LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out
9461.35Schristos		mv $@.out $@
9471.9Schristos
9481.48Schristos# Set file timestamps deterministically if possible,
9491.48Schristos# so that tarballs containing the timestamps are reproducible.
9501.48Schristos#
9511.48Schristos# '$(SET_TIMESTAMP_N) N DEST A B C ...' sets the timestamp of the
9521.48Schristos# file DEST to the maximum of the timestamps of the files A B C ...,
9531.48Schristos# plus N if GNU ls and touch are available.
9541.48SchristosSET_TIMESTAMP_N = sh -c '\
9551.48Schristos  n=$$0 dest=$$1; shift; \
9561.48Schristos  touch -cmr `ls -t "$$@" | sed 1q` "$$dest" && \
9571.48Schristos  if test $$n != 0 && \
9581.48Schristos     lsout=`ls -n --time-style="+%s" "$$dest" 2>/dev/null`; then \
9591.48Schristos    set x $$lsout && \
9601.48Schristos    touch -cmd @`expr $$7 + $$n` "$$dest"; \
9611.48Schristos  else :; fi'
9621.48Schristos# If DEST depends on A B C ... in this Makefile, callers should use
9631.48Schristos# $(SET_TIMESTAMP_DEP) DEST A B C ..., for the benefit of any
9641.48Schristos# downstream 'make' that considers equal timestamps to be out of date.
9651.48Schristos# POSIX allows this 'make' behavior, and HP-UX 'make' does it.
9661.48Schristos# If all that matters is that the timestamp be reproducible
9671.48Schristos# and plausible, use $(SET_TIMESTAMP).
9681.48SchristosSET_TIMESTAMP = $(SET_TIMESTAMP_N) 0
9691.48SchristosSET_TIMESTAMP_DEP = $(SET_TIMESTAMP_N) 1
9701.48Schristos
9711.41Schristos# Set the timestamps to those of the git repository, if available,
9721.6Schristos# and if the files have not changed since then.
9731.48Schristos# This uses GNU 'ls --time-style=+%s', which outputs the seconds count,
9741.48Schristos# and GNU 'touch -d@N FILE', where N is the number of seconds since 1970.
9751.48Schristos# If git or GNU is absent, don't bother to sync with git timestamps.
9761.16Schristos# Also, set the timestamp of each prebuilt file like 'leapseconds'
9771.16Schristos# to be the maximum of the files it depends on.
9781.41Schristosset-timestamps.out: $(EIGHT_YARDS)
9791.16Schristos		rm -f $@
9801.35Schristos		if (type git) >/dev/null 2>&1 && \
9811.41Schristos		   files=`git ls-files $(EIGHT_YARDS)` && \
9821.16Schristos		   touch -md @1 test.out; then \
9831.16Schristos		  rm -f test.out && \
9841.16Schristos		  for file in $$files; do \
9851.16Schristos		    if git diff --quiet $$file; then \
9861.16Schristos		      time=`git log -1 --format='tformat:%ct' $$file` && \
9871.16Schristos		      touch -cmd @$$time $$file; \
9881.16Schristos		    else \
9891.16Schristos		      echo >&2 "$$file: warning: does not match repository"; \
9901.16Schristos		    fi || exit; \
9911.16Schristos		  done; \
9921.16Schristos		fi
9931.48Schristos		$(SET_TIMESTAMP_DEP) leapseconds $(LEAP_DEPS)
9941.16Schristos		for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \
9951.48Schristos		  $(SET_TIMESTAMP_DEP) $$file.txt $$file workman.sh || \
9961.16Schristos		    exit; \
9971.6Schristos		done
9981.48Schristos		$(SET_TIMESTAMP_DEP) version $(VERSION_DEPS)
9991.48Schristos		$(SET_TIMESTAMP_DEP) tzdata.zi $(TZDATA_ZI_DEPS)
10001.41Schristos		touch $@
10011.41Schristosset-tzs-timestamp.out: $(TZS)
10021.48Schristos		$(SET_TIMESTAMP_DEP) $(TZS) $(TZS_DEPS)
10031.16Schristos		touch $@
10041.6Schristos
10051.1Smlelstv# The zics below ensure that each data file can stand on its own.
10061.1Smlelstv# We also do an all-files run to catch links to links.
10071.1Smlelstv
10081.41Schristoscheck_public: $(VERSION_DEPS)
10091.41Schristos		rm -fr public.dir
10101.41Schristos		mkdir public.dir
10111.41Schristos		ln $(VERSION_DEPS) public.dir
10121.41Schristos		cd public.dir && $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' ALL
10131.48Schristos		for i in $(TDATA_TO_CHECK) public.dir/tzdata.zi \
10141.48Schristos		    public.dir/vanguard.zi public.dir/main.zi \
10151.48Schristos		    public.dir/rearguard.zi; \
10161.48Schristos		do \
10171.41Schristos		  public.dir/zic -v -d public.dir/zoneinfo $$i 2>&1 || exit; \
10181.9Schristos		done
10191.41Schristos		public.dir/zic -v -d public.dir/zoneinfo-all $(TDATA_TO_CHECK)
10201.49Schristos		:
10211.49Schristos		: Also check 'backzone' syntax.
10221.49Schristos		rm public.dir/main.zi
10231.49Schristos		cd public.dir && $(MAKE) PACKRATDATA=backzone main.zi
10241.49Schristos		public.dir/zic -d public.dir/zoneinfo main.zi
10251.51Schristos		rm public.dir/main.zi
10261.51Schristos		cd public.dir && \
10271.51Schristos		  $(MAKE) PACKRATDATA=backzone PACKRATLIST=zone.tab main.zi
10281.51Schristos		public.dir/zic -d public.dir/zoneinfo main.zi
10291.49Schristos		:
10301.34Schristos		rm -fr public.dir
10311.41Schristos		touch $@
10321.9Schristos
10331.14Schristos# Check that the code works under various alternative
10341.14Schristos# implementations of time_t.
10351.41Schristoscheck_time_t_alternatives: $(TIME_T_ALTERNATIVES)
10361.41Schristos$(TIME_T_ALTERNATIVES_TAIL): $(TIME_T_ALTERNATIVES_HEAD)
10371.41Schristos$(TIME_T_ALTERNATIVES): $(VERSION_DEPS)
10381.41Schristos		rm -fr $@.dir
10391.41Schristos		mkdir $@.dir
10401.41Schristos		ln $(VERSION_DEPS) $@.dir
10411.41Schristos		case $@ in \
10421.49Schristos		  int*32_t) range=-2147483648,2147483648;; \
10431.41Schristos		  u*) range=0,4294967296;; \
10441.41Schristos		  *) range=-4294967296,4294967296;; \
10451.41Schristos		esac && \
10461.41Schristos		wd=`pwd` && \
10471.41Schristos		zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab` && \
10481.41Schristos		if test $@ = $(TIME_T_ALTERNATIVES_HEAD); then \
10491.41Schristos		  range_target=; \
10501.23Schristos		else \
10511.41Schristos		  range_target=to$$range.tzs; \
10521.23Schristos		fi && \
10531.41Schristos		(cd $@.dir && \
10541.41Schristos		  $(MAKE) TOPDIR="$$wd/$@.dir" \
10551.41Schristos		    CFLAGS='$(CFLAGS) -Dtime_tz='"'$@'" \
10561.23Schristos		    REDO='$(REDO)' \
10571.41Schristos			D=$$wd/$@.dir \
10581.41Schristos		    TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
10591.41Schristos		    install $$range_target) && \
10601.41Schristos		test $@ = $(TIME_T_ALTERNATIVES_HEAD) || { \
10611.41Schristos		  (cd $(TIME_T_ALTERNATIVES_HEAD).dir && \
10621.41Schristos		    $(MAKE) TOPDIR="$$wd/$@.dir" \
10631.41Schristos		      TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
10641.41Schristos			D=$$wd/$@.dir \
10651.41Schristos		      to$$range.tzs) && \
10661.54Schristos		  $(DIFF_TZS) $(TIME_T_ALTERNATIVES_HEAD).dir/to$$range.tzs \
10671.41Schristos			  $@.dir/to$$range.tzs && \
10681.41Schristos		  if diff -q Makefile Makefile 2>/dev/null; then \
10691.41Schristos		    quiet_option='-q'; \
10701.41Schristos		  else \
10711.41Schristos		    quiet_option=''; \
10721.41Schristos		  fi && \
10731.41Schristos		    diff $$quiet_option -r $(TIME_T_ALTERNATIVES_HEAD).dir/etc \
10741.41Schristos					   $@.dir/etc && \
10751.41Schristos		    diff $$quiet_option -r \
10761.41Schristos		      $(TIME_T_ALTERNATIVES_HEAD).dir/usr/share \
10771.41Schristos		      $@.dir/usr/share; \
10781.41Schristos		}
10791.41Schristos		touch $@
10801.34Schristos
10811.40SchristosTRADITIONAL_ASC = \
10821.40Schristos  tzcode$(VERSION).tar.gz.asc \
10831.40Schristos  tzdata$(VERSION).tar.gz.asc
10841.41SchristosREARGUARD_ASC = \
10851.41Schristos  tzdata$(VERSION)-rearguard.tar.gz.asc
10861.41SchristosALL_ASC = $(TRADITIONAL_ASC) $(REARGUARD_ASC) \
10871.40Schristos  tzdb-$(VERSION).tar.lz.asc
10881.40Schristos
10891.51Schristostarballs rearguard_tarballs tailored_tarballs traditional_tarballs \
10901.41Schristossignatures rearguard_signatures traditional_signatures: \
10911.51Schristos  version set-timestamps.out rearguard.zi vanguard.zi
10921.35Schristos		VERSION=`cat version` && \
10931.48Schristos		$(MAKE) AWK='$(AWK)' VERSION="$$VERSION" $@_version
10941.35Schristos
10951.40Schristos# These *_version rules are intended for use if VERSION is set by some
10961.40Schristos# other means.  Ordinarily these rules are used only by the above
10971.40Schristos# non-_version rules, which set VERSION on the 'make' command line.
10981.41Schristostarballs_version: traditional_tarballs_version rearguard_tarballs_version \
10991.40Schristos  tzdb-$(VERSION).tar.lz
11001.41Schristosrearguard_tarballs_version: \
11011.41Schristos  tzdata$(VERSION)-rearguard.tar.gz
11021.38Schristostraditional_tarballs_version: \
11031.38Schristos  tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
11041.51Schristostailored_tarballs_version: \
11051.51Schristos  tzdata$(VERSION)-tailored.tar.gz
11061.40Schristossignatures_version: $(ALL_ASC)
11071.41Schristosrearguard_signatures_version: $(REARGUARD_ASC)
11081.40Schristostraditional_signatures_version: $(TRADITIONAL_ASC)
11091.9Schristos
11101.16Schristostzcode$(VERSION).tar.gz: set-timestamps.out
11111.6Schristos		LC_ALL=C && export LC_ALL && \
11121.7Schristos		tar $(TARFLAGS) -cf - \
11131.23Schristos		    $(COMMON) $(DOCS) $(SOURCES) | \
11141.38Schristos		  gzip $(GZIPFLAGS) >$@.out
11151.35Schristos		mv $@.out $@
11161.10Schristos
11171.16Schristostzdata$(VERSION).tar.gz: set-timestamps.out
11181.6Schristos		LC_ALL=C && export LC_ALL && \
11191.51Schristos		tar $(TARFLAGS) -cf - $(TZDATA_DIST) | \
11201.38Schristos		  gzip $(GZIPFLAGS) >$@.out
11211.35Schristos		mv $@.out $@
11221.9Schristos
11231.51Schristos# Create empty files with a reproducible timestamp.
11241.51SchristosCREATE_EMPTY = TZ=UTC0 touch -mt 202010122253.00
11251.51Schristos
11261.51Schristos# The obsolescent *rearguard* targets and related macros are present
11271.51Schristos# for backwards compatibility with tz releases 2018e through 2022a.
11281.51Schristos# They should go away eventually.  To build rearguard tarballs you
11291.51Schristos# can instead use 'make DATAFORM=rearguard tailored_tarballs'.
11301.40Schristostzdata$(VERSION)-rearguard.tar.gz: rearguard.zi set-timestamps.out
11311.51Schristos		rm -fr $@.dir
11321.51Schristos		mkdir $@.dir
11331.51Schristos		ln $(TZDATA_DIST) $@.dir
11341.51Schristos		cd $@.dir && rm -f $(TDATA) $(PACKRATDATA) version
11351.40Schristos		for f in $(TDATA) $(PACKRATDATA); do \
11361.51Schristos		  rearf=$@.dir/$$f; \
11371.40Schristos		  $(AWK) -v DATAFORM=rearguard -f ziguard.awk $$f >$$rearf && \
11381.48Schristos		  $(SET_TIMESTAMP_DEP) $$rearf ziguard.awk $$f || exit; \
11391.40Schristos		done
11401.51Schristos		sed '1s/$$/-rearguard/' <version >$@.dir/version
11411.47Schristos		: The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
11421.51Schristos		$(CREATE_EMPTY) $@.dir/pacificnew
11431.51Schristos		touch -cmr version $@.dir/version
11441.40Schristos		LC_ALL=C && export LC_ALL && \
11451.51Schristos		  (cd $@.dir && \
11461.47Schristos		   tar $(TARFLAGS) -cf - \
11471.51Schristos			$(TZDATA_DIST) pacificnew | \
11481.40Schristos		     gzip $(GZIPFLAGS)) >$@.out
11491.40Schristos		mv $@.out $@
11501.40Schristos
11511.51Schristos# Create a tailored tarball suitable for TZUpdater and compatible tools.
11521.51Schristos# For example, 'make DATAFORM=vanguard tailored_tarballs' makes a tarball
11531.51Schristos# useful for testing whether TZUpdater supports vanguard form.
11541.51Schristos# The generated tarball is not byte-for-byte equivalent to a hand-tailored
11551.51Schristos# traditional tarball, as data entries are put into 'etcetera' even if they
11561.51Schristos# came from some other source file.  However, the effect should be the same
11571.51Schristos# for ordinary use, which reads all the source files.
11581.51Schristostzdata$(VERSION)-tailored.tar.gz: set-timestamps.out
11591.51Schristos		rm -fr $@.dir
11601.51Schristos		mkdir $@.dir
11611.51Schristos		: The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
11621.51Schristos		cd $@.dir && \
11631.51Schristos		  $(CREATE_EMPTY) $(PRIMARY_YDATA) $(NDATA) backward \
11641.51Schristos		  `test $(DATAFORM) = vanguard || echo pacificnew`
11651.51Schristos		(grep '^#' tzdata.zi && echo && cat $(DATAFORM).zi) \
11661.51Schristos		  >$@.dir/etcetera
11671.51Schristos		touch -cmr tzdata.zi $@.dir/etcetera
11681.51Schristos		sed -n \
11691.51Schristos		  -e '/^# *version  *\(.*\)/h' \
11701.51Schristos		  -e '/^# *ddeps  */H' \
11711.51Schristos		  -e '$$!d' \
11721.51Schristos		  -e 'g' \
11731.51Schristos		  -e 's/^# *version  *//' \
11741.51Schristos		  -e 's/\n# *ddeps  */-/' \
11751.51Schristos		  -e 's/ /-/g' \
11761.51Schristos		  -e 'p' \
11771.51Schristos		  <tzdata.zi >$@.dir/version
11781.51Schristos		touch -cmr version $@.dir/version
11791.51Schristos		links= && \
11801.51Schristos		  for file in $(TZDATA_DIST); do \
11811.51Schristos		    test -f $@.dir/$$file || links="$$links $$file"; \
11821.51Schristos		  done && \
11831.51Schristos		  ln $$links $@.dir
11841.51Schristos		LC_ALL=C && export LC_ALL && \
11851.51Schristos		  (cd $@.dir && \
11861.51Schristos		   tar $(TARFLAGS) -cf - * | gzip $(GZIPFLAGS)) >$@.out
11871.51Schristos		mv $@.out $@
11881.51Schristos
11891.41Schristostzdb-$(VERSION).tar.lz: set-timestamps.out set-tzs-timestamp.out
11901.34Schristos		rm -fr tzdb-$(VERSION)
11911.34Schristos		mkdir tzdb-$(VERSION)
11921.34Schristos		ln $(ENCHILADA) tzdb-$(VERSION)
11931.48Schristos		$(SET_TIMESTAMP) tzdb-$(VERSION) tzdb-$(VERSION)/*
11941.34Schristos		LC_ALL=C && export LC_ALL && \
11951.35Schristos		tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out
11961.35Schristos		mv $@.out $@
11971.9Schristos
11981.9Schristostzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
11991.9Schristostzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
12001.40Schristostzdata$(VERSION)-rearguard.tar.gz.asc: tzdata$(VERSION)-rearguard.tar.gz
12011.34Schristostzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
12021.40Schristos$(ALL_ASC):
12031.44Schristos		$(GPG) --armor --detach-sign $?
12041.34Schristos
12051.41SchristosTYPECHECK_CFLAGS = $(CFLAGS) -DTYPECHECK -D__time_t_defined -D_TIME_T
12061.41Schristostypecheck: typecheck_long_long typecheck_unsigned
12071.41Schristostypecheck_long_long typecheck_unsigned: $(VERSION_DEPS)
12081.41Schristos		rm -fr $@.dir
12091.41Schristos		mkdir $@.dir
12101.41Schristos		ln $(VERSION_DEPS) $@.dir
12111.41Schristos		cd $@.dir && \
12121.41Schristos		  case $@ in \
12131.41Schristos		    *_long_long) i="long long";; \
12141.41Schristos		    *_unsigned ) i="unsigned" ;; \
12151.41Schristos		  esac && \
12161.41Schristos		  typecheck_cflags='' && \
12171.41Schristos		  $(MAKE) \
12181.41Schristos		    CFLAGS="$(TYPECHECK_CFLAGS) \"-Dtime_t=$$i\"" \
12191.41Schristos		    TOPDIR="`pwd`" \
12201.41Schristos		    install
12211.41Schristos		$@.dir/zdump -i -c 1970,1971 Europe/Rome
12221.41Schristos		touch $@
12231.1Smlelstv
12241.38Schristoszonenames:	tzdata.zi
12251.38Schristos		@$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
12261.1Smlelstv
12271.1Smlelstvasctime.o:	private.h tzfile.h
12281.1Smlelstvdate.o:		private.h
12291.1Smlelstvdifftime.o:	private.h
12301.1Smlelstvlocaltime.o:	private.h tzfile.h
12311.23Schristosstrftime.o:	private.h tzfile.h
12321.6Schristoszdump.o:	version.h
12331.6Schristoszic.o:		private.h tzfile.h version.h
12341.1Smlelstv
12351.22Schristos.PHONY: ALL INSTALL all
12361.54Schristos.PHONY: check check_mild check_time_t_alternatives
12371.42Schristos.PHONY: check_web check_zishrink
12381.40Schristos.PHONY: clean clean_misc dummy.zd force_tzs
12391.32Schristos.PHONY: install install_data maintainer-clean names
12401.51Schristos.PHONY: posix_only posix_right public
12411.41Schristos.PHONY: rearguard_signatures rearguard_signatures_version
12421.41Schristos.PHONY: rearguard_tarballs rearguard_tarballs_version
12431.41Schristos.PHONY: right_only right_posix signatures signatures_version
12441.40Schristos.PHONY: tarballs tarballs_version
12451.40Schristos.PHONY: traditional_signatures traditional_signatures_version
12461.40Schristos.PHONY: traditional_tarballs traditional_tarballs_version
12471.51Schristos.PHONY: tailored_tarballs tailored_tarballs_version
12481.40Schristos.PHONY: typecheck
12491.22Schristos.PHONY: zonenames zones
12501.40Schristos.PHONY: $(ZDS)
1251