Makefile revision 1.2 1 1.2 kre # Make and install tzdb code and data.
2 1.1 apb # This file is in the public domain, so clarified as of
3 1.1 apb # 2009-05-17 by Arthur David Olson.
4 1.2 kre # Request POSIX conformance; this must be the first non-comment line.
5 1.2 kre .POSIX:
6 1.2 kre # On older platforms you may need to scrounge for POSIX conformance.
7 1.2 kre # For example, on Solaris 10 (2005) with Sun Studio 12 aka Sun C 5.9 (2007),
8 1.2 kre # use 'PATH=/usr/xpg4/bin:$PATH make CC=c99'.
9 1.2 kre
10 1.2 kre # To affect how this Makefile works, you can run a shell script like this:
11 1.2 kre #
12 1.2 kre # #!/bin/sh
13 1.2 kre # make CC='gcc -std=gnu23' "$@"
14 1.2 kre #
15 1.2 kre # This example script is appropriate for a circa 2024 GNU/Linux system
16 1.2 kre # where a non-default setting enables this package's optional use of C23.
17 1.2 kre #
18 1.2 kre # Alternatively, you can simply edit this Makefile to tailor the following
19 1.2 kre # macro definitions.
20 1.2 kre
21 1.2 kre ###############################################################################
22 1.2 kre # Start of macros that one plausibly might want to tailor.
23 1.1 apb
24 1.1 apb # Package name for the code distribution.
25 1.1 apb PACKAGE= tzcode
26 1.1 apb
27 1.2 kre # Version number for the distribution, overridden in the 'tarballs' rule below.
28 1.2 kre VERSION= unknown
29 1.1 apb
30 1.1 apb # Email address for bug reports.
31 1.1 apb BUGEMAIL= tz@iana.org
32 1.1 apb
33 1.2 kre # DATAFORM selects the data format.
34 1.2 kre # Available formats represent essentially the same data, albeit
35 1.2 kre # possibly with minor discrepancies that users are not likely to notice.
36 1.2 kre # To get new features and the best data right away, use:
37 1.2 kre # DATAFORM= vanguard
38 1.2 kre # To wait a while before using new features, to give downstream users
39 1.2 kre # time to upgrade zic (the default), use:
40 1.2 kre # DATAFORM= main
41 1.2 kre # To wait even longer for new features, use:
42 1.2 kre # DATAFORM= rearguard
43 1.2 kre # Rearguard users might also want "ZFLAGS = -b fat"; see below.
44 1.2 kre DATAFORM= main
45 1.2 kre
46 1.2 kre # Change the line below for your timezone (after finding the one you want in
47 1.2 kre # one of the $(TDATA) source files, or adding it to a source file).
48 1.2 kre # Alternatively, if you discover you've got the wrong timezone, you can just
49 1.2 kre # 'zic -l -' to remove it, or 'zic -l rightzone' to change it.
50 1.1 apb # Use the command
51 1.1 apb # make zonenames
52 1.1 apb # to get a list of the values you can use for LOCALTIME.
53 1.1 apb
54 1.2 kre LOCALTIME= Factory
55 1.1 apb
56 1.2 kre # The POSIXRULES macro controls interpretation of POSIX-like TZ
57 1.2 kre # settings like TZ='EET-2EEST' that lack DST transition rules.
58 1.2 kre # If POSIXRULES is '-', no template is installed; this is the default.
59 1.2 kre # Any other value for POSIXRULES is obsolete and should not be relied on, as:
60 1.2 kre # * It does not work correctly in popular implementations such as GNU/Linux.
61 1.2 kre # * It does not work even in tzcode, except for historical timestamps
62 1.2 kre # that precede the last explicit transition in the POSIXRULES file.
63 1.2 kre # Hence it typically does not work for current and future timestamps.
64 1.2 kre # If, despite the above, you want a template for handling these settings,
65 1.2 kre # you can change the line below (after finding the timezone you want in the
66 1.2 kre # one of the $(TDATA) source files, or adding it to a source file).
67 1.2 kre # Alternatively, if you discover you've got the wrong timezone, you can just
68 1.2 kre # 'zic -p -' to remove it, or 'zic -p rightzone' to change it.
69 1.1 apb # Use the command
70 1.1 apb # make zonenames
71 1.1 apb # to get a list of the values you can use for POSIXRULES.
72 1.1 apb
73 1.2 kre POSIXRULES= -
74 1.1 apb
75 1.1 apb # Also see TZDEFRULESTRING below, which takes effect only
76 1.2 kre # if POSIXRULES is '-' or if the template file cannot be accessed.
77 1.1 apb
78 1.1 apb
79 1.2 kre # Installation locations.
80 1.2 kre #
81 1.2 kre # The defaults are suitable for Debian, except that if REDO is
82 1.2 kre # posix_right or right_posix then files that Debian puts under
83 1.2 kre # /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead
84 1.2 kre # put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps,
85 1.2 kre # respectively. Problems with the Debian approach are discussed in
86 1.2 kre # the commentary for the right_posix rule (below).
87 1.2 kre
88 1.2 kre # Destination directory, which can be used for staging.
89 1.2 kre # 'make DESTDIR=/stage install' installs under /stage (e.g., to
90 1.2 kre # /stage/etc/localtime instead of to /etc/localtime). Files under
91 1.2 kre # /stage are not intended to work as-is, but can be copied by hand to
92 1.2 kre # the root directory later. If DESTDIR is empty, 'make install' does
93 1.2 kre # not stage, but installs directly into production locations.
94 1.2 kre DESTDIR =
95 1.2 kre
96 1.2 kre # Everything is installed into subdirectories of TOPDIR, and used there.
97 1.2 kre # TOPDIR should be empty (meaning the root directory),
98 1.2 kre # or a directory name that does not end in "/".
99 1.2 kre # TOPDIR should be empty or an absolute name unless you're just testing.
100 1.2 kre TOPDIR =
101 1.2 kre
102 1.2 kre # The default local timezone is taken from the file TZDEFAULT.
103 1.2 kre TZDEFAULT = $(TOPDIR)/etc/localtime
104 1.2 kre
105 1.2 kre # The subdirectory containing installed program and data files, and
106 1.2 kre # likewise for installed files that can be shared among architectures.
107 1.2 kre # These should be relative file names.
108 1.2 kre USRDIR = usr
109 1.2 kre USRSHAREDIR = $(USRDIR)/share
110 1.1 apb
111 1.2 kre # "Compiled" timezone information is placed in the "TZDIR" directory
112 1.1 apb # (and subdirectories).
113 1.2 kre # TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty.
114 1.1 apb TZDIR_BASENAME= zoneinfo
115 1.2 kre TZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(TZDIR_BASENAME)
116 1.1 apb
117 1.2 kre # The "tzselect" and (if you do "make INSTALL") "date" commands go in:
118 1.2 kre BINDIR = $(TOPDIR)/$(USRDIR)/bin
119 1.1 apb
120 1.2 kre # The "zdump" command goes in:
121 1.2 kre ZDUMPDIR = $(BINDIR)
122 1.1 apb
123 1.2 kre # The "zic" command goes in:
124 1.2 kre ZICDIR = $(TOPDIR)/$(USRDIR)/sbin
125 1.1 apb
126 1.1 apb # Manual pages go in subdirectories of. . .
127 1.2 kre MANDIR = $(TOPDIR)/$(USRSHAREDIR)/man
128 1.1 apb
129 1.1 apb # Library functions are put in an archive in LIBDIR.
130 1.2 kre LIBDIR = $(TOPDIR)/$(USRDIR)/lib
131 1.1 apb
132 1.1 apb
133 1.2 kre # Types to try, as an alternative to time_t.
134 1.2 kre TIME_T_ALTERNATIVES = $(TIME_T_ALTERNATIVES_HEAD) $(TIME_T_ALTERNATIVES_TAIL)
135 1.2 kre TIME_T_ALTERNATIVES_HEAD = int_least64_t.ck
136 1.2 kre TIME_T_ALTERNATIVES_TAIL = int_least32_t.ck uint_least32_t.ck \
137 1.2 kre uint_least64_t.ck
138 1.2 kre
139 1.2 kre # What kind of TZif data files to generate. (TZif is the binary time
140 1.2 kre # zone data format that zic generates; see Internet RFC 8536.)
141 1.2 kre # If you want only POSIX time, with time values interpreted as
142 1.2 kre # seconds since the epoch (not counting leap seconds), use
143 1.1 apb # REDO= posix_only
144 1.2 kre # below. If you want only "right" time, with values interpreted
145 1.2 kre # as seconds since the epoch (counting leap seconds), use
146 1.1 apb # REDO= right_only
147 1.1 apb # below. If you want both sets of data available, with leap seconds not
148 1.1 apb # counted normally, use
149 1.1 apb # REDO= posix_right
150 1.1 apb # below. If you want both sets of data available, with leap seconds counted
151 1.1 apb # normally, use
152 1.1 apb # REDO= right_posix
153 1.2 kre # below. POSIX mandates that leap seconds not be counted; for compatibility
154 1.2 kre # with it, use "posix_only" or "posix_right". Use POSIX time on systems with
155 1.2 kre # leap smearing; this can work better than unsmeared "right" time with
156 1.2 kre # applications that are not leap second aware, and is closer to unsmeared
157 1.2 kre # "right" time than unsmeared POSIX time is (e.g., 0.5 vs 1.0 s max error).
158 1.1 apb
159 1.1 apb REDO= posix_right
160 1.1 apb
161 1.2 kre # Whether to put an "Expires" line in the leapseconds file.
162 1.2 kre # Use EXPIRES_LINE=1 to put the line in, 0 to omit it.
163 1.2 kre # The EXPIRES_LINE value matters only if REDO's value contains "right".
164 1.2 kre # If you change EXPIRES_LINE, remove the leapseconds file before running "make".
165 1.2 kre # zic's support for the Expires line was introduced in tzdb 2020a,
166 1.2 kre # and was modified in tzdb 2021b to generate version 4 TZif files.
167 1.2 kre # EXPIRES_LINE defaults to 0 for now so that the leapseconds file
168 1.2 kre # can be given to pre-2020a zic implementations and so that TZif files
169 1.2 kre # built by newer zic implementations can be read by pre-2021b libraries.
170 1.2 kre EXPIRES_LINE= 0
171 1.2 kre
172 1.2 kre # To install data in text form that has all the information of the TZif data,
173 1.2 kre # (optionally incorporating leap second information), use
174 1.2 kre # TZDATA_TEXT= tzdata.zi leapseconds
175 1.2 kre # To install text data without leap second information (e.g., because
176 1.2 kre # REDO='posix_only'), use
177 1.2 kre # TZDATA_TEXT= tzdata.zi
178 1.2 kre # To avoid installing text data, use
179 1.2 kre # TZDATA_TEXT=
180 1.2 kre
181 1.2 kre TZDATA_TEXT= leapseconds tzdata.zi
182 1.2 kre
183 1.2 kre # For backward-compatibility links for old zone names, use
184 1.2 kre # BACKWARD= backward
185 1.2 kre # To omit these links, use
186 1.2 kre # BACKWARD=
187 1.2 kre
188 1.2 kre BACKWARD= backward
189 1.2 kre
190 1.2 kre # If you want out-of-scope and often-wrong data from the file 'backzone',
191 1.2 kre # but only for entries listed in the backward-compatibility file zone.tab, use
192 1.2 kre # PACKRATDATA= backzone
193 1.2 kre # PACKRATLIST= zone.tab
194 1.2 kre # If you want all the 'backzone' data, use
195 1.2 kre # PACKRATDATA= backzone
196 1.2 kre # PACKRATLIST=
197 1.2 kre # To omit this data, use
198 1.2 kre # PACKRATDATA=
199 1.2 kre # PACKRATLIST=
200 1.1 apb
201 1.2 kre PACKRATDATA=
202 1.2 kre PACKRATLIST=
203 1.2 kre
204 1.2 kre # The name of a locale using the UTF-8 encoding, used during self-tests.
205 1.2 kre # The tests are skipped if the name does not appear to work on this system.
206 1.2 kre
207 1.2 kre UTF8_LOCALE= en_US.utf8
208 1.1 apb
209 1.1 apb # Non-default libraries needed to link.
210 1.2 kre # On some hosts, this should have -lintl unless CFLAGS has -DHAVE_GETTEXT=0.
211 1.1 apb LDLIBS=
212 1.1 apb
213 1.2 kre # Add the following to an uncommented "CFLAGS=" line as needed
214 1.2 kre # to override defaults specified in the source code or by the system.
215 1.2 kre # "-DFOO" is equivalent to "-DFOO=1".
216 1.2 kre # -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime
217 1.2 kre # formats that generate only the last two digits of year numbers
218 1.2 kre # -DEPOCH_LOCAL if the 'time' function returns local time not UT
219 1.2 kre # -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
220 1.2 kre # than what POSIX specifies, assuming local time is UT.
221 1.2 kre # For example, N is 252460800 on AmigaOS.
222 1.2 kre # -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
223 1.2 kre # on POSIX platforms predating POSIX.1-2024
224 1.2 kre # -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
225 1.2 kre # -DHAVE_DECL_TIMEGM=0 if <time.h> does not declare timegm
226 1.2 kre # -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
227 1.2 kre # -DHAVE__GENERIC=0 if _Generic does not work*
228 1.2 kre # -DHAVE_GETRANDOM if getrandom works (e.g., GNU/Linux),
229 1.2 kre # -DHAVE_GETRANDOM=0 to avoid using getrandom
230 1.2 kre # -DHAVE_GETTEXT if gettext works (e.g., GNU/Linux, FreeBSD, Solaris),
231 1.2 kre # where LDLIBS also needs to contain -lintl on some hosts;
232 1.2 kre # -DHAVE_GETTEXT=0 to avoid using gettext
233 1.2 kre # -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
234 1.2 kre # ctime_r and asctime_r incompatibly with POSIX.1-2017 and earlier
235 1.2 kre # (Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
236 1.2 kre # -DHAVE_INTTYPES_H=0 if <inttypes.h> does not work*+
237 1.1 apb # -DHAVE_LINK=0 if your system lacks a link function
238 1.2 kre # -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
239 1.2 kre # -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
240 1.2 kre # localtime_rz can make zdump significantly faster, but is nonstandard.
241 1.2 kre # -DHAVE_MALLOC_ERRNO=0 if malloc etc. do not set errno on failure.
242 1.2 kre # -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
243 1.2 kre # functions like 'link' or variables like 'tzname' required by POSIX
244 1.2 kre # -DHAVE_SETENV=0 if your system lacks the setenv function
245 1.2 kre # -DHAVE_SNPRINTF=0 if your system lacks the snprintf function+
246 1.2 kre # -DHAVE_STDCKDINT_H=0 if neither <stdckdint.h> nor substitutes like
247 1.2 kre # __builtin_add_overflow work*
248 1.2 kre # -DHAVE_STDINT_H=0 if <stdint.h> does not work*+
249 1.2 kre # -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
250 1.2 kre # -DHAVE_STRDUP=0 if your system lacks the strdup function
251 1.2 kre # -DHAVE_STRTOLL=0 if your system lacks the strtoll function+
252 1.1 apb # -DHAVE_SYMLINK=0 if your system lacks the symlink function
253 1.2 kre # -DHAVE_SYS_STAT_H=0 if <sys/stat.h> does not work*
254 1.2 kre # -DHAVE_TZSET=0 if your system lacks a tzset function
255 1.2 kre # -DHAVE_UNISTD_H=0 if <unistd.h> does not work*
256 1.2 kre # -DHAVE_UTMPX_H=0 if <utmpx.h> does not work*
257 1.2 kre # -Dlocale_t=XXX if your system uses XXX instead of locale_t
258 1.2 kre # -DPORT_TO_C89 if tzcode should also run on mostly-C89 platforms+
259 1.2 kre # Typically it is better to use a later standard. For example,
260 1.2 kre # with GCC 4.9.4 (2016), prefer '-std=gnu11' to '-DPORT_TO_C89'.
261 1.2 kre # Even with -DPORT_TO_C89, the code needs at least one C99
262 1.2 kre # feature (integers at least 64 bits wide) and maybe more.
263 1.2 kre # -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
264 1.2 kre # with external linkage, e.g., applications cannot define 'localtime'.
265 1.2 kre # -Dssize_t=long on hosts like MS-Windows that lack ssize_t
266 1.2 kre # -DSUPPORT_C89=0 if the tzcode library should not support C89 callers
267 1.2 kre # Although -DSUPPORT_C89=0 might work around latent bugs in callers,
268 1.2 kre # it does not conform to POSIX.
269 1.2 kre # -DSUPPORT_POSIX2008 if the library should support older POSIX callers+
270 1.2 kre # However, this might cause problems in POSIX.1-2024-or-later callers.
271 1.2 kre # -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
272 1.2 kre # security implications and is not recommended for general use
273 1.2 kre # -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
274 1.2 kre # not needed by the main-program tz code, which is single-threaded.
275 1.2 kre # Append other compiler flags as needed, e.g., -pthread on GNU/Linux.
276 1.1 apb # -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
277 1.2 kre # This is intended for internal use only; it mangles external names.
278 1.1 apb # -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
279 1.1 apb # -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
280 1.1 apb # the default is system-supplied, typically "/usr/lib/locale"
281 1.1 apb # -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
282 1.2 kre # DST transitions for proleptic format TZ strings lacking them,
283 1.2 kre # in the usual case where POSIXRULES is '-'. If not specified,
284 1.2 kre # TZDEFRULESTRING defaults to US rules for future DST transitions.
285 1.2 kre # This mishandles some past timestamps, as US DST rules have changed.
286 1.2 kre # It also mishandles settings like TZ='EET-2EEST' for eastern Europe,
287 1.2 kre # as Europe and US DST rules differ.
288 1.2 kre # -DTZNAME_MAXIMUM=N to limit time zone abbreviations to N bytes (default 255)
289 1.2 kre # -DUNINIT_TRAP if reading uninitialized storage can cause problems
290 1.2 kre # other than simply getting garbage data
291 1.2 kre # -DUSE_LTZ=0 to build zdump with the system time zone library
292 1.2 kre # Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
293 1.2 kre # -DZIC_BLOAT_DEFAULT=\"fat\" to default zic's -b option to "fat", and
294 1.2 kre # similarly for "slim". Fat TZif files work around incompatibilities
295 1.2 kre # and bugs in some TZif readers, notably older ones that
296 1.2 kre # ignore or otherwise mishandle 64-bit data in TZif files;
297 1.2 kre # however, fat TZif files may trigger bugs in newer TZif readers.
298 1.2 kre # Slim TZif files are more efficient, and are the default.
299 1.1 apb # -DZIC_MAX_ABBR_LEN_WO_WARN=3
300 1.1 apb # (or some other number) to set the maximum time zone abbreviation length
301 1.1 apb # that zic will accept without a warning (the default is 6)
302 1.2 kre # -g to generate symbolic debugging info
303 1.2 kre # -Idir to include from directory 'dir'
304 1.2 kre # -O0 to disable optimization; other -O options to enable more optimization
305 1.2 kre # -Uname to remove any definition of the macro 'name'
306 1.2 kre # $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
307 1.2 kre #
308 1.2 kre # * Options marked "*" can be omitted if your compiler is C23 compatible.
309 1.2 kre # * Options marked "+" are obsolescent and are planned to be removed
310 1.2 kre # once the code assumes C99 or later (say in the year 2029)
311 1.2 kre # and POSIX.1-2024 or later (say in the year 2034).
312 1.2 kre #
313 1.2 kre # Select instrumentation via "make GCC_INSTRUMENT='whatever'".
314 1.2 kre GCC_INSTRUMENT = \
315 1.2 kre -fsanitize=undefined -fsanitize-address-use-after-scope \
316 1.2 kre -fsanitize-undefined-trap-on-error -fstack-protector
317 1.2 kre # Omit -fanalyzer from GCC_DEBUG_FLAGS, as it makes GCC too slow.
318 1.2 kre GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 \
319 1.2 kre $(GCC_INSTRUMENT) \
320 1.2 kre -Wall -Wextra \
321 1.2 kre -Walloc-size-larger-than=100000 -Warray-bounds=2 \
322 1.2 kre -Wbad-function-cast -Wbidi-chars=any,ucn -Wcast-align=strict -Wdate-time \
323 1.2 kre -Wdeclaration-after-statement -Wdouble-promotion \
324 1.2 kre -Wduplicated-branches -Wduplicated-cond -Wflex-array-member-not-at-end \
325 1.2 kre -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
326 1.2 kre -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op \
327 1.2 kre -Wmissing-declarations -Wmissing-prototypes \
328 1.2 kre -Wmissing-variable-declarations -Wnested-externs \
329 1.2 kre -Wnull-dereference \
330 1.2 kre -Wold-style-definition -Woverlength-strings -Wpointer-arith \
331 1.2 kre -Wshadow -Wshift-overflow=2 -Wstrict-overflow \
332 1.2 kre -Wstrict-prototypes -Wstringop-overflow=4 \
333 1.2 kre -Wstringop-truncation -Wsuggest-attribute=cold \
334 1.2 kre -Wsuggest-attribute=const -Wsuggest-attribute=format \
335 1.2 kre -Wsuggest-attribute=malloc \
336 1.2 kre -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \
337 1.2 kre -Wtrampolines -Wundef -Wunused-macros -Wuse-after-free=3 \
338 1.2 kre -Wvariadic-macros -Wvla -Wwrite-strings \
339 1.2 kre -Wno-format-nonliteral -Wno-sign-compare
340 1.1 apb #
341 1.1 apb # If your system has a "GMT offset" field in its "struct tm"s
342 1.1 apb # (or if you decide to add such a field in your system's "time.h" file),
343 1.1 apb # add the name to a define such as
344 1.1 apb # -DTM_GMTOFF=tm_gmtoff
345 1.2 kre # to the end of the "CFLAGS=" line. If not defined, the code attempts to
346 1.2 kre # guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this.
347 1.2 kre # Similarly, if your system has a "zone abbreviation" field, define
348 1.2 kre # -DTM_ZONE=tm_zone
349 1.2 kre # and define NO_TM_ZONE to suppress any guessing.
350 1.2 kre # Although POSIX.1-2024 requires these fields and they are widely available
351 1.2 kre # on GNU/Linux and BSD systems, some older systems lack them.
352 1.1 apb #
353 1.2 kre # The next batch of options control support for external variables
354 1.2 kre # exported by tzcode. In practice these variables are less useful
355 1.2 kre # than TM_GMTOFF and TM_ZONE. However, most of them are standardized.
356 1.2 kre # #
357 1.2 kre # # To omit or support the external variable "tzname", add one of:
358 1.2 kre # # -DHAVE_TZNAME=0 # do not support "tzname"
359 1.2 kre # # -DHAVE_TZNAME=1 # support "tzname", which is defined by system library
360 1.2 kre # # -DHAVE_TZNAME=2 # support and define "tzname"
361 1.2 kre # # to the "CFLAGS=" line. Although "tzname" is required by POSIX.1-1988
362 1.2 kre # # and later, its contents are unspecified if you use a geographical TZ
363 1.2 kre # # and the variable is planned to be removed in a future POSIX edition.
364 1.2 kre # # If not defined, the code attempts to guess HAVE_TZNAME from other macros.
365 1.2 kre # # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause
366 1.2 kre # # crashes when combined with some platforms' standard libraries,
367 1.2 kre # # presumably due to memory allocation issues.
368 1.2 kre # #
369 1.2 kre # # To omit or support the external variables "timezone" and "daylight", add
370 1.2 kre # # -DUSG_COMPAT=0 # do not support
371 1.2 kre # # -DUSG_COMPAT=1 # support, and variables are defined by system library
372 1.2 kre # # -DUSG_COMPAT=2 # support and define variables
373 1.2 kre # # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by Unix
374 1.2 kre # # Systems Group code and are required by POSIX.1-2008 and later (with XSI),
375 1.2 kre # # although their contents are unspecified if you use a geographical TZ
376 1.2 kre # # and the variables are planned to be removed in a future edition of POSIX.
377 1.2 kre # # If not defined, the code attempts to guess USG_COMPAT from other macros.
378 1.2 kre # #
379 1.2 kre # # To support the external variable "altzone", add
380 1.2 kre # # -DALTZONE=0 # do not support
381 1.2 kre # # -DALTZONE=1 # support "altzone", which is defined by system library
382 1.2 kre # # -DALTZONE=2 # support and define "altzone"
383 1.2 kre # # to the end of the "CFLAGS=" line; although "altzone" appeared in
384 1.2 kre # # System V Release 3.1 it has not been standardized.
385 1.2 kre # # If not defined, the code attempts to guess ALTZONE from other macros.
386 1.1 apb #
387 1.1 apb # If you want functions that were inspired by early versions of X3J11's work,
388 1.1 apb # add
389 1.1 apb # -DSTD_INSPIRED
390 1.2 kre # to the end of the "CFLAGS=" line. This arranges for the following
391 1.2 kre # functions to be added to the time conversion library.
392 1.1 apb # "offtime" is like "gmtime" except that it accepts a second (long) argument
393 1.1 apb # that gives an offset to add to the time_t when converting it.
394 1.2 kre # I.e., "offtime" is like calling "localtime_rz" with a fixed-offset zone.
395 1.2 kre # "timelocal" is nearly equivalent to "mktime".
396 1.1 apb # "timeoff" is like "timegm" except that it accepts a second (long) argument
397 1.1 apb # that gives an offset to use when converting to a time_t.
398 1.2 kre # I.e., "timeoff" is like calling "mktime_z" with a fixed-offset zone.
399 1.1 apb # "posix2time" and "time2posix" are described in an included manual page.
400 1.1 apb # X3J11's work does not describe any of these functions.
401 1.1 apb # These functions may well disappear in future releases of the time
402 1.1 apb # conversion package.
403 1.1 apb #
404 1.2 kre # If you don't want functions that were inspired by NetBSD, add
405 1.2 kre # -DNETBSD_INSPIRED=0
406 1.2 kre # to the end of the "CFLAGS=" line. Otherwise, the functions
407 1.2 kre # "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
408 1.2 kre # time library, and if STD_INSPIRED is also defined to nonzero the functions
409 1.2 kre # "posix2time_z" and "time2posix_z" are added as well.
410 1.2 kre # The functions ending in "_z" (or "_rz") are like their unsuffixed
411 1.2 kre # (or suffixed-by-"_r") counterparts, except with an extra first
412 1.2 kre # argument of opaque type timezone_t that specifies the timezone.
413 1.2 kre # "tzalloc" allocates a timezone_t value, and "tzfree" frees it.
414 1.2 kre #
415 1.1 apb # If you want to allocate state structures in localtime, add
416 1.1 apb # -DALL_STATE
417 1.1 apb # to the end of the "CFLAGS=" line. Storage is obtained by calling malloc.
418 1.1 apb #
419 1.1 apb # NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
420 1.1 apb # out by the National Institute of Standards and Technology
421 1.2 kre # which claims to test C and POSIX conformance. If you want to pass PCTS, add
422 1.1 apb # -DPCTS
423 1.1 apb # to the end of the "CFLAGS=" line.
424 1.1 apb #
425 1.1 apb # If you want strict compliance with XPG4 as of 1994-04-09, add
426 1.1 apb # -DXPG4_1994_04_09
427 1.1 apb # to the end of the "CFLAGS=" line. This causes "strftime" to always return
428 1.2 kre # 53 as a week number (rather than 52 or 53) for January days before
429 1.2 kre # January's first Monday when a "%V" format is used and January 1
430 1.1 apb # falls on a Friday, Saturday, or Sunday.
431 1.2 kre #
432 1.2 kre # POSIX says CFLAGS defaults to "-O 1".
433 1.2 kre # Uncomment the following line and edit its contents as needed.
434 1.2 kre
435 1.2 kre #CFLAGS= -O 1
436 1.1 apb
437 1.1 apb
438 1.2 kre # The name of a POSIX-like library archiver, its flags, C compiler,
439 1.2 kre # linker flags, and 'make' utility. Ordinarily the defaults suffice.
440 1.2 kre # The commented-out values are the defaults specified by POSIX.1-2024.
441 1.2 kre #AR = ar
442 1.2 kre #ARFLAGS = -rv
443 1.2 kre #CC = c17
444 1.2 kre #LDFLAGS =
445 1.2 kre #MAKE = make
446 1.2 kre
447 1.2 kre # Where to fetch leap-seconds.list from.
448 1.2 kre leaplist_URI = \
449 1.2 kre https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list
450 1.2 kre # The file is generated by the IERS Earth Orientation Centre, in Paris.
451 1.2 kre leaplist_TZ = Europe/Paris
452 1.1 apb
453 1.2 kre # The zic command and its arguments.
454 1.1 apb
455 1.1 apb zic= ./zic
456 1.1 apb ZIC= $(zic) $(ZFLAGS)
457 1.1 apb
458 1.2 kre # To shrink the size of installed TZif files,
459 1.2 kre # append "-r @N" to omit data before N-seconds-after-the-Epoch.
460 1.2 kre # To grow the files and work around bugs in older applications,
461 1.2 kre # possibly at the expense of introducing bugs in newer ones,
462 1.2 kre # append "-b fat"; see ZIC_BLOAT_DEFAULT above.
463 1.2 kre # See the zic man page for more about -b and -r.
464 1.1 apb ZFLAGS=
465 1.1 apb
466 1.2 kre # How to use zic to install TZif files.
467 1.2 kre
468 1.2 kre ZIC_INSTALL= $(ZIC) -d '$(DESTDIR)$(TZDIR)'
469 1.2 kre
470 1.2 kre # The name of a POSIX-compliant 'awk' on your system.
471 1.2 kre # mawk 1.3.3 and Solaris 10 /usr/bin/awk do not work.
472 1.2 kre # Also, it is better (though not essential) if 'awk' supports UTF-8,
473 1.2 kre # and unfortunately mawk and busybox awk do not support UTF-8.
474 1.2 kre # Try AWK=gawk or AWK=nawk if your awk has the abovementioned problems.
475 1.1 apb AWK= awk
476 1.1 apb
477 1.2 kre # The full path name of a POSIX-compliant shell, preferably one that supports
478 1.1 apb # the Korn shell's 'select' statement as an extension.
479 1.1 apb # These days, Bash is the most popular.
480 1.1 apb # It should be OK to set this to /bin/sh, on platforms where /bin/sh
481 1.2 kre # lacks 'select' or doesn't completely conform to POSIX, but /bin/bash
482 1.1 apb # is typically nicer if it works.
483 1.1 apb KSHELL= /bin/bash
484 1.1 apb
485 1.2 kre # Name of curl <https://curl.haxx.se/>, used for HTML validation
486 1.2 kre # and to fetch leap-seconds.list from upstream.
487 1.2 kre # Set CURL=: to disable use of the Internet.
488 1.2 kre CURL= curl
489 1.2 kre
490 1.2 kre # Name of GNU Privacy Guard <https://gnupg.org/>, used to sign distributions.
491 1.2 kre GPG= gpg
492 1.2 kre
493 1.2 kre # This expensive test requires USE_LTZ.
494 1.2 kre # To suppress it, define this macro to be empty.
495 1.2 kre CHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
496 1.1 apb
497 1.1 apb # SAFE_CHAR is a regular expression that matches a safe character.
498 1.1 apb # Some parts of this distribution are limited to safe characters;
499 1.1 apb # others can use any UTF-8 character.
500 1.1 apb # For now, the safe characters are a safe subset of ASCII.
501 1.1 apb # The caller must set the shell variable 'sharp' to the character '#',
502 1.1 apb # since Makefile macros cannot contain '#'.
503 1.1 apb # TAB_CHAR is a single tab character, in single quotes.
504 1.1 apb TAB_CHAR= ' '
505 1.1 apb SAFE_CHARSET1= $(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@'
506 1.1 apb SAFE_CHARSET2= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`'
507 1.1 apb SAFE_CHARSET3= 'abcdefghijklmnopqrstuvwxyz{|}~'
508 1.2 kre SAFE_CHARSET= $(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
509 1.2 kre SAFE_CHAR= '[]'$(SAFE_CHARSET)'-]'
510 1.2 kre
511 1.2 kre # These non-alphabetic, non-ASCII printable characters are Latin-1,
512 1.2 kre # and so are likely displayable even in editors like XEmacs 21
513 1.2 kre # that have limited display capabilities.
514 1.2 kre UNUSUAL_OK_LATIN_1 =
515 1.2 kre # Non-ASCII non-letters that OK_CHAR allows, as these characters are
516 1.2 kre # useful in commentary.
517 1.2 kre UNUSUAL_OK_CHARSET= $(UNUSUAL_OK_LATIN_1)
518 1.2 kre
519 1.2 kre # Put this in a bracket expression to match spaces.
520 1.2 kre s = [:space:]
521 1.2 kre
522 1.2 kre # OK_CHAR matches any character allowed in the distributed files.
523 1.2 kre # This is the same as SAFE_CHAR, except that UNUSUAL_OK_CHARSET and
524 1.2 kre # multibyte letters are also allowed so that commentary can contain a
525 1.2 kre # few safe symbols and people's names and can quote non-English sources.
526 1.2 kre # Other non-letters are limited to ASCII renderings for the
527 1.2 kre # convenience of maintainers using XEmacs 21.5.34, which by default
528 1.2 kre # mishandles Unicode characters U+0100 and greater.
529 1.2 kre OK_CHAR= '[][:alpha:]$(UNUSUAL_OK_CHARSET)'$(SAFE_CHARSET)'-]'
530 1.1 apb
531 1.1 apb # SAFE_LINE matches a line of safe characters.
532 1.2 kre # SAFE_SHARP_LINE is similar, except any OK character can follow '#';
533 1.1 apb # this is so that comments can contain non-ASCII characters.
534 1.2 kre # OK_LINE matches a line of OK characters.
535 1.1 apb SAFE_LINE= '^'$(SAFE_CHAR)'*$$'
536 1.2 kre SAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$'
537 1.2 kre OK_LINE= '^'$(OK_CHAR)'*$$'
538 1.1 apb
539 1.1 apb # Flags to give 'tar' when making a distribution.
540 1.1 apb # Try to use flags appropriate for GNU tar.
541 1.2 kre GNUTARFLAGS= --format=pax --pax-option=delete=atime,delete=ctime \
542 1.2 kre --numeric-owner --owner=0 --group=0 \
543 1.2 kre --mode=go+u,go-w --sort=name
544 1.2 kre SETUP_TAR= \
545 1.2 kre export LC_ALL=C && \
546 1.2 kre if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; then \
547 1.2 kre TAR='tar $(GNUTARFLAGS)'; \
548 1.2 kre else \
549 1.2 kre TAR=tar; \
550 1.2 kre fi
551 1.1 apb
552 1.1 apb # Flags to give 'gzip' when making a distribution.
553 1.1 apb GZIPFLAGS= -9n
554 1.1 apb
555 1.2 kre # When comparing .tzs files, use GNU diff's -F'^TZ=' option if supported.
556 1.2 kre # This makes it easier to see which Zone has been affected.
557 1.2 kre SETUP_DIFF_TZS = \
558 1.2 kre if diff -u -F'^TZ=' - - <>/dev/null >&0 2>&1; then \
559 1.2 kre DIFF_TZS='diff -u -F^TZ='; \
560 1.2 kre else \
561 1.2 kre DIFF_TZS='diff -u'; \
562 1.2 kre fi
563 1.2 kre
564 1.2 kre # ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib.
565 1.2 kre RANLIB= :
566 1.1 apb
567 1.2 kre # POSIX prohibits defining or using SHELL. However, csh users on systems
568 1.2 kre # that use the user shell for Makefile commands may need to define SHELL.
569 1.2 kre #SHELL= /bin/sh
570 1.1 apb
571 1.2 kre # End of macros that one plausibly might want to tailor.
572 1.2 kre ###############################################################################
573 1.1 apb
574 1.1 apb
575 1.2 kre TZCOBJS= zic.o
576 1.2 kre TZDOBJS= zdump.o localtime.o strftime.o
577 1.2 kre DATEOBJS= date.o localtime.o strftime.o
578 1.2 kre LIBSRCS= localtime.c asctime.c difftime.c strftime.c
579 1.2 kre LIBOBJS= localtime.o asctime.o difftime.o strftime.o
580 1.1 apb HEADERS= tzfile.h private.h
581 1.2 kre NONLIBSRCS= zic.c zdump.c
582 1.2 kre NEWUCBSRCS= date.c
583 1.2 kre SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \
584 1.2 kre tzselect.ksh workman.sh
585 1.1 apb MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
586 1.1 apb tzfile.5 tzselect.8 zic.8 zdump.8
587 1.1 apb MANTXTS= newctime.3.txt newstrftime.3.txt newtzset.3.txt \
588 1.1 apb time2posix.3.txt \
589 1.1 apb tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
590 1.1 apb date.1.txt
591 1.2 kre COMMON= calendars CONTRIBUTING LICENSE Makefile \
592 1.2 kre NEWS README SECURITY theory.html version
593 1.2 kre WEB_PAGES= tz-art.html tz-how-to.html tz-link.html
594 1.2 kre CHECK_WEB_PAGES=theory.ck tz-art.ck tz-how-to.ck tz-link.ck
595 1.2 kre DOCS= $(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
596 1.1 apb PRIMARY_YDATA= africa antarctica asia australasia \
597 1.1 apb europe northamerica southamerica
598 1.2 kre YDATA= $(PRIMARY_YDATA) etcetera
599 1.2 kre NDATA= factory
600 1.2 kre TDATA_TO_CHECK= $(YDATA) $(NDATA) backward
601 1.2 kre TDATA= $(YDATA) $(NDATA) $(BACKWARD)
602 1.2 kre ZONETABLES= zone.tab zone1970.tab zonenow.tab
603 1.2 kre TABDATA= iso3166.tab $(TZDATA_TEXT) $(ZONETABLES)
604 1.1 apb LEAP_DEPS= leapseconds.awk leap-seconds.list
605 1.2 kre TZDATA_ZI_DEPS= ziguard.awk zishrink.awk version $(TDATA) \
606 1.2 kre $(PACKRATDATA) $(PACKRATLIST)
607 1.2 kre DSTDATA_ZI_DEPS= ziguard.awk $(TDATA) $(PACKRATDATA) $(PACKRATLIST)
608 1.2 kre DATA= $(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \
609 1.2 kre leapseconds $(ZONETABLES)
610 1.2 kre AWK_SCRIPTS= checklinks.awk checknow.awk checktab.awk leapseconds.awk \
611 1.2 kre ziguard.awk zishrink.awk
612 1.2 kre MISC= $(AWK_SCRIPTS)
613 1.2 kre TZS_YEAR= 2050
614 1.2 kre TZS_CUTOFF_FLAG= -c $(TZS_YEAR)
615 1.2 kre TZS= to$(TZS_YEAR).tzs
616 1.2 kre TZS_NEW= to$(TZS_YEAR)new.tzs
617 1.2 kre TZS_DEPS= $(YDATA) asctime.c localtime.c \
618 1.2 kre private.h tzfile.h zdump.c zic.c
619 1.2 kre TZDATA_DIST = $(COMMON) $(DATA) $(MISC)
620 1.2 kre # EIGHT_YARDS is just a yard short of the whole ENCHILADA.
621 1.2 kre EIGHT_YARDS = $(TZDATA_DIST) $(DOCS) $(SOURCES) tzdata.zi
622 1.2 kre ENCHILADA = $(EIGHT_YARDS) $(TZS)
623 1.2 kre
624 1.2 kre # Consult these files when deciding whether to rebuild the 'version' file.
625 1.2 kre # This list is not the same as the output of 'git ls-files', since
626 1.2 kre # .gitignore is not distributed.
627 1.2 kre VERSION_DEPS= \
628 1.2 kre calendars CONTRIBUTING LICENSE Makefile NEWS README SECURITY \
629 1.2 kre africa antarctica asctime.c asia australasia \
630 1.2 kre backward backzone \
631 1.2 kre checklinks.awk checknow.awk checktab.awk \
632 1.2 kre date.1 date.c difftime.c \
633 1.2 kre etcetera europe factory iso3166.tab \
634 1.2 kre leap-seconds.list leapseconds.awk localtime.c \
635 1.2 kre newctime.3 newstrftime.3 newtzset.3 northamerica \
636 1.2 kre private.h southamerica strftime.c theory.html \
637 1.2 kre time2posix.3 tz-art.html tz-how-to.html tz-link.html \
638 1.2 kre tzfile.5 tzfile.h tzselect.8 tzselect.ksh \
639 1.2 kre workman.sh zdump.8 zdump.c zic.8 zic.c \
640 1.2 kre ziguard.awk zishrink.awk \
641 1.2 kre zone.tab zone1970.tab zonenow.tab
642 1.1 apb
643 1.2 kre all: tzselect zic zdump libtz.a $(TABDATA) \
644 1.2 kre vanguard.zi main.zi rearguard.zi
645 1.1 apb
646 1.2 kre ALL: all date $(ENCHILADA)
647 1.1 apb
648 1.1 apb install: all $(DATA) $(REDO) $(MANS)
649 1.2 kre mkdir -p '$(DESTDIR)$(BINDIR)' \
650 1.2 kre '$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \
651 1.2 kre '$(DESTDIR)$(LIBDIR)' \
652 1.2 kre '$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
653 1.2 kre '$(DESTDIR)$(MANDIR)/man8'
654 1.2 kre $(ZIC_INSTALL) -l $(LOCALTIME) \
655 1.2 kre -p $(POSIXRULES) \
656 1.2 kre -t '$(DESTDIR)$(TZDEFAULT)'
657 1.2 kre cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.'
658 1.2 kre cp tzselect '$(DESTDIR)$(BINDIR)/.'
659 1.2 kre cp zdump '$(DESTDIR)$(ZDUMPDIR)/.'
660 1.2 kre cp zic '$(DESTDIR)$(ZICDIR)/.'
661 1.2 kre cp libtz.a '$(DESTDIR)$(LIBDIR)/.'
662 1.2 kre $(RANLIB) '$(DESTDIR)$(LIBDIR)/libtz.a'
663 1.2 kre cp -f newctime.3 newtzset.3 '$(DESTDIR)$(MANDIR)/man3/.'
664 1.2 kre cp -f tzfile.5 '$(DESTDIR)$(MANDIR)/man5/.'
665 1.2 kre cp -f tzselect.8 zdump.8 zic.8 '$(DESTDIR)$(MANDIR)/man8/.'
666 1.1 apb
667 1.1 apb INSTALL: ALL install date.1
668 1.2 kre mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1'
669 1.2 kre cp date '$(DESTDIR)$(BINDIR)/.'
670 1.2 kre cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.'
671 1.2 kre
672 1.2 kre # Calculate version number from git, if available.
673 1.2 kre # Otherwise, use $(VERSION) unless it is "unknown" and there is already
674 1.2 kre # a 'version' file, in which case reuse the existing 'version' contents
675 1.2 kre # and append "-dirty" if the contents do not already end in "-dirty".
676 1.2 kre version: $(VERSION_DEPS)
677 1.2 kre { (type git) >/dev/null 2>&1 && \
678 1.2 kre V=$$(git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \
679 1.2 kre --abbrev=7 --dirty) || \
680 1.2 kre if test '$(VERSION)' = unknown && read -r V <$@; then \
681 1.2 kre V=$${V%-dirty}-dirty; \
682 1.2 kre else \
683 1.2 kre V='$(VERSION)'; \
684 1.2 kre fi; } && \
685 1.2 kre printf '%s\n' "$$V" >$@.out
686 1.2 kre mv $@.out $@
687 1.2 kre
688 1.2 kre # These files can be tailored by setting BACKWARD, PACKRATDATA, PACKRATLIST.
689 1.2 kre vanguard.zi main.zi rearguard.zi: $(DSTDATA_ZI_DEPS)
690 1.2 kre $(AWK) \
691 1.2 kre -v DATAFORM=$(@:.zi=) \
692 1.2 kre -v PACKRATDATA='$(PACKRATDATA)' \
693 1.2 kre -v PACKRATLIST='$(PACKRATLIST)' \
694 1.2 kre -f ziguard.awk \
695 1.2 kre $(TDATA) $(PACKRATDATA) >$@.out
696 1.2 kre mv $@.out $@
697 1.2 kre # This file has a version comment that attempts to capture any tailoring
698 1.2 kre # via BACKWARD, DATAFORM, PACKRATDATA, PACKRATLIST, and REDO.
699 1.2 kre tzdata.zi: $(DATAFORM).zi version zishrink.awk
700 1.2 kre read -r version <version && \
701 1.2 kre LC_ALL=C $(AWK) \
702 1.2 kre -v dataform='$(DATAFORM)' \
703 1.2 kre -v deps='$(DSTDATA_ZI_DEPS) zishrink.awk' \
704 1.2 kre -v redo='$(REDO)' \
705 1.2 kre -v version="$$version" \
706 1.2 kre -f zishrink.awk \
707 1.2 kre $(DATAFORM).zi >$@.out
708 1.2 kre mv $@.out $@
709 1.2 kre
710 1.2 kre tzdir.h:
711 1.2 kre printf '%s\n' >$@.out \
712 1.2 kre '#ifndef TZDEFAULT' \
713 1.2 kre '# define TZDEFAULT "$(TZDEFAULT)" /* default zone */' \
714 1.2 kre '#endif' \
715 1.2 kre '#ifndef TZDIR' \
716 1.2 kre '# define TZDIR "$(TZDIR)" /* TZif directory */' \
717 1.2 kre '#endif'
718 1.2 kre mv $@.out $@
719 1.2 kre
720 1.2 kre version.h: version
721 1.2 kre read -r VERSION <version && printf '%s\n' \
722 1.2 kre 'static char const PKGVERSION[]="($(PACKAGE)) ";' \
723 1.2 kre "static char const TZVERSION[]=\"$$VERSION\";" \
724 1.2 kre 'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \
725 1.2 kre >$@.out
726 1.2 kre mv $@.out $@
727 1.1 apb
728 1.1 apb zdump: $(TZDOBJS)
729 1.1 apb $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
730 1.1 apb
731 1.2 kre zic: $(TZCOBJS)
732 1.1 apb $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
733 1.1 apb
734 1.2 kre leapseconds: $(LEAP_DEPS)
735 1.2 kre $(AWK) -v EXPIRES_LINE=$(EXPIRES_LINE) \
736 1.2 kre -f leapseconds.awk leap-seconds.list >$@.out
737 1.2 kre mv $@.out $@
738 1.2 kre
739 1.2 kre # Awk script to extract a Git-style author from leap-seconds.list comments.
740 1.2 kre EXTRACT_AUTHOR = \
741 1.2 kre author_line { sub(/^.[[:space:]]*/, ""); \
742 1.2 kre sub(/:[[:space:]]*/, " <"); \
743 1.2 kre printf "%s>\n", $$0; \
744 1.2 kre success = 1; \
745 1.2 kre exit \
746 1.2 kre } \
747 1.2 kre /Questions or comments to:/ { author_line = 1 } \
748 1.2 kre END { exit !success }
749 1.2 kre
750 1.2 kre # Fetch leap-seconds.list from upstream.
751 1.2 kre fetch-leap-seconds.list:
752 1.2 kre $(CURL) -OR $(leaplist_URI)
753 1.2 kre
754 1.2 kre # Fetch leap-seconds.list from upstream and commit it to the local repository.
755 1.2 kre commit-leap-seconds.list: fetch-leap-seconds.list
756 1.2 kre author=$$($(AWK) '$(EXTRACT_AUTHOR)' leap-seconds.list) && \
757 1.2 kre date=$$(TZ=$(leaplist_TZ) stat -c%y leap-seconds.list) && \
758 1.2 kre git commit --author="$$author" --date="$$date" -m'make $@' \
759 1.2 kre leap-seconds.list
760 1.2 kre
761 1.2 kre # Arguments to pass to submakes.
762 1.2 kre # They can be overridden by later submake arguments.
763 1.2 kre INSTALLARGS = \
764 1.2 kre BACKWARD='$(BACKWARD)' \
765 1.2 kre DESTDIR='$(DESTDIR)' \
766 1.2 kre PACKRATDATA='$(PACKRATDATA)' \
767 1.2 kre PACKRATLIST='$(PACKRATLIST)' \
768 1.2 kre TZDEFAULT='$(TZDEFAULT)' \
769 1.2 kre TZDIR='$(TZDIR)' \
770 1.2 kre ZIC='$(ZIC)'
771 1.2 kre
772 1.2 kre INSTALL_DATA_DEPS = zic leapseconds tzdata.zi
773 1.1 apb
774 1.2 kre posix_only: $(INSTALL_DATA_DEPS)
775 1.2 kre $(ZIC_INSTALL) tzdata.zi
776 1.1 apb
777 1.2 kre right_only: $(INSTALL_DATA_DEPS)
778 1.2 kre $(ZIC_INSTALL) -L leapseconds tzdata.zi
779 1.1 apb
780 1.1 apb # In earlier versions of this makefile, the other two directories were
781 1.1 apb # subdirectories of $(TZDIR). However, this led to configuration errors.
782 1.1 apb # For example, with posix_right under the earlier scheme,
783 1.1 apb # TZ='right/Australia/Adelaide' got you localtime with leap seconds,
784 1.1 apb # but gmtime without leap seconds, which led to problems with applications
785 1.1 apb # like sendmail that subtract gmtime from localtime.
786 1.1 apb # Therefore, the other two directories are now siblings of $(TZDIR).
787 1.1 apb # You must replace all of $(TZDIR) to switch from not using leap seconds
788 1.1 apb # to using them, or vice versa.
789 1.2 kre right_posix: right_only
790 1.2 kre rm -fr '$(DESTDIR)$(TZDIR)-leaps'
791 1.2 kre ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \
792 1.2 kre $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
793 1.2 kre $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
794 1.2 kre
795 1.2 kre posix_right: posix_only
796 1.2 kre rm -fr '$(DESTDIR)$(TZDIR)-posix'
797 1.2 kre ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \
798 1.2 kre $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only
799 1.2 kre $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only
800 1.1 apb
801 1.1 apb zones: $(REDO)
802 1.1 apb
803 1.2 kre # dummy.zd is not a real file; it is mentioned here only so that the
804 1.2 kre # top-level 'make' does not have a syntax error.
805 1.2 kre ZDS = dummy.zd
806 1.2 kre # Rule used only by submakes invoked by the $(TZS_NEW) rule.
807 1.2 kre # It is separate so that GNU 'make -j' can run instances in parallel.
808 1.2 kre $(ZDS): zdump
809 1.2 kre ./zdump -i $(TZS_CUTOFF_FLAG) "$$PWD/$(@:.zd=)" >$@
810 1.2 kre
811 1.2 kre TZS_NEW_DEPS = tzdata.zi zdump zic
812 1.2 kre $(TZS_NEW): $(TZS_NEW_DEPS)
813 1.2 kre rm -fr tzs$(TZS_YEAR).dir
814 1.2 kre mkdir tzs$(TZS_YEAR).dir
815 1.2 kre $(zic) -d tzs$(TZS_YEAR).dir tzdata.zi
816 1.2 kre $(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \
817 1.2 kre tzdata.zi | LC_ALL=C sort >$@.out
818 1.2 kre x=$$($(AWK) '/^Z/{print "tzs$(TZS_YEAR).dir/" $$2 ".zd"}' \
819 1.2 kre tzdata.zi \
820 1.2 kre | LC_ALL=C sort -t . -k 2,2) && \
821 1.2 kre set x $$x && \
822 1.2 kre shift && \
823 1.2 kre ZDS=$$* && \
824 1.2 kre $(MAKE) TZS_CUTOFF_FLAG="$(TZS_CUTOFF_FLAG)" \
825 1.2 kre ZDS="$$ZDS" $$ZDS && \
826 1.2 kre sed 's,^TZ=".*\.dir/,TZ=",' $$ZDS >>$@.out
827 1.2 kre rm -fr tzs$(TZS_YEAR).dir
828 1.2 kre mv $@.out $@
829 1.2 kre
830 1.2 kre # If $(TZS) exists but 'make tzs.ck' fails, a maintainer should inspect the
831 1.2 kre # failed output and fix the inconsistency, perhaps by running 'make force_tzs'.
832 1.2 kre $(TZS):
833 1.2 kre touch $@
834 1.2 kre
835 1.2 kre force_tzs: $(TZS_NEW)
836 1.2 kre cp $(TZS_NEW) $(TZS)
837 1.2 kre
838 1.1 apb libtz.a: $(LIBOBJS)
839 1.2 kre rm -f $@
840 1.2 kre $(AR) $(ARFLAGS) $@ $(LIBOBJS)
841 1.1 apb $(RANLIB) $@
842 1.1 apb
843 1.1 apb date: $(DATEOBJS)
844 1.1 apb $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS)
845 1.1 apb
846 1.2 kre tzselect: tzselect.ksh version
847 1.2 kre read -r VERSION <version && sed \
848 1.2 kre -e "s'#!/bin/bash'#!"'$(KSHELL)'\' \
849 1.2 kre -e s\''\(AWK\)=[^}]*'\''\1=\'\''$(AWK)\'\'\' \
850 1.2 kre -e s\''\(PKGVERSION\)=.*'\''\1=\'\''($(PACKAGE)) \'\'\' \
851 1.2 kre -e s\''\(REPORT_BUGS_TO\)=.*'\''\1=\'\''$(BUGEMAIL)\'\'\' \
852 1.2 kre -e s\''\(TZDIR\)=[^}]*'\''\1=\'\''$(TZDIR)\'\'\' \
853 1.2 kre -e s\''\(TZVERSION\)=.*'\''\1=\'"'$$VERSION\\''" \
854 1.2 kre <$@.ksh >$@.out
855 1.2 kre chmod +x $@.out
856 1.2 kre mv $@.out $@
857 1.2 kre
858 1.2 kre check: check_mild back.ck
859 1.2 kre check_mild: check_web check_zishrink \
860 1.2 kre character-set.ck white-space.ck links.ck mainguard.ck \
861 1.2 kre name-lengths.ck now.ck slashed-abbrs.ck sorted.ck \
862 1.2 kre tables.ck ziguard.ck tzs.ck
863 1.2 kre
864 1.2 kre # True if UTF8_LOCALE does not work;
865 1.2 kre # otherwise, false but with LC_ALL set to $(UTF8_LOCALE).
866 1.2 kre UTF8_LOCALE_MISSING = \
867 1.2 kre { test ! '$(UTF8_LOCALE)' \
868 1.2 kre || ! printf 'A\304\200B\n' \
869 1.2 kre | LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 \
870 1.2 kre || { export LC_ALL='$(UTF8_LOCALE)'; false; }; }
871 1.1 apb
872 1.2 kre character-set.ck: $(ENCHILADA)
873 1.2 kre $(UTF8_LOCALE_MISSING) || { \
874 1.1 apb sharp='#' && \
875 1.1 apb ! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
876 1.2 kre $(MISC) $(SOURCES) $(WEB_PAGES) \
877 1.2 kre CONTRIBUTING LICENSE README SECURITY \
878 1.2 kre version tzdata.zi && \
879 1.2 kre ! grep -Env $(SAFE_LINE)'|^UNUSUAL_OK_'$(OK_CHAR)'*$$' \
880 1.2 kre Makefile && \
881 1.2 kre ! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \
882 1.2 kre leapseconds zone.tab && \
883 1.2 kre ! grep -Env $(OK_LINE) $(ENCHILADA); \
884 1.2 kre }
885 1.2 kre touch $@
886 1.2 kre
887 1.2 kre white-space.ck: $(ENCHILADA)
888 1.2 kre $(UTF8_LOCALE_MISSING) || { \
889 1.2 kre enchilada='$(ENCHILADA)' && \
890 1.2 kre patfmt=' \t|[\f\r\v]' && pat=$$(printf "$$patfmt\\n") && \
891 1.2 kre ! grep -En "$$pat|[$s]\$$" \
892 1.2 kre $${enchilada%leap-seconds.list*} \
893 1.2 kre $${enchilada#*leap-seconds.list}; \
894 1.2 kre }
895 1.2 kre touch $@
896 1.2 kre
897 1.2 kre PRECEDES_FILE_NAME = ^(Zone|Link[$s]+[^$s]+)[$s]+
898 1.2 kre FILE_NAME_COMPONENT_TOO_LONG = $(PRECEDES_FILE_NAME)[^$s]*[^/$s]{15}
899 1.2 kre
900 1.2 kre name-lengths.ck: $(TDATA_TO_CHECK) backzone
901 1.2 kre :;! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \
902 1.2 kre $(TDATA_TO_CHECK) backzone
903 1.2 kre touch $@
904 1.2 kre
905 1.2 kre mainguard.ck: main.zi
906 1.2 kre test '$(PACKRATLIST)' || \
907 1.2 kre cat $(TDATA) $(PACKRATDATA) | diff -u - main.zi
908 1.2 kre touch $@
909 1.2 kre
910 1.2 kre PRECEDES_STDOFF = ^(Zone[$s]+[^$s]+)?[$s]+
911 1.2 kre STDOFF = [-+]?[0-9:.]+
912 1.2 kre RULELESS_SAVE = (-|$(STDOFF)[sd]?)
913 1.2 kre RULELESS_SLASHED_ABBRS = \
914 1.2 kre $(PRECEDES_STDOFF)$(STDOFF)[$s]+$(RULELESS_SAVE)[$s]+[^$s]*/
915 1.2 kre
916 1.2 kre slashed-abbrs.ck: $(TDATA_TO_CHECK)
917 1.2 kre :;! grep -En '$(RULELESS_SLASHED_ABBRS)' $(TDATA_TO_CHECK)
918 1.2 kre touch $@
919 1.2 kre
920 1.2 kre CHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
921 1.2 kre
922 1.2 kre sorted.ck: backward backzone
923 1.2 kre $(AWK) '/^Link/ {printf "%.5d %s\n", g, $$3} !/./ {g++}' \
924 1.2 kre backward | LC_ALL=C sort -cu
925 1.2 kre $(AWK) '/^Zone.*\// {print $$2}' backzone | LC_ALL=C sort -cu
926 1.2 kre touch $@
927 1.2 kre
928 1.2 kre back.ck: checklinks.awk $(TDATA_TO_CHECK)
929 1.2 kre $(AWK) \
930 1.2 kre -v DATAFORM=$(DATAFORM) \
931 1.2 kre -f checklinks.awk $(TDATA_TO_CHECK)
932 1.2 kre touch $@
933 1.1 apb
934 1.2 kre links.ck: checklinks.awk tzdata.zi
935 1.2 kre $(AWK) \
936 1.2 kre -v DATAFORM=$(DATAFORM) \
937 1.2 kre -f checklinks.awk tzdata.zi
938 1.2 kre touch $@
939 1.2 kre
940 1.2 kre # Check timestamps from now through 28 years from now, to make sure
941 1.2 kre # that zonenow.tab contains all sequences of planned timestamps,
942 1.2 kre # without any duplicate sequences. In theory this might require
943 1.2 kre # 2800+ years but that would take a long time to check.
944 1.2 kre CHECK_NOW_TIMESTAMP = $$(./date +%s)
945 1.2 kre CHECK_NOW_FUTURE_YEARS = 28
946 1.2 kre CHECK_NOW_FUTURE_SECS = $(CHECK_NOW_FUTURE_YEARS) * 366 * 24 * 60 * 60
947 1.2 kre now.ck: checknow.awk date tzdata.zi zdump zic zone1970.tab zonenow.tab
948 1.2 kre touch $@
949 1.2 kre # Original code:
950 1.2 kre check_now_original: checknow.awk date tzdata.zi zdump zic zone1970.tab zonenow.tab
951 1.2 kre rm -fr $@d
952 1.2 kre mkdir $@d
953 1.2 kre ./zic -d $@d tzdata.zi
954 1.2 kre now=$(CHECK_NOW_TIMESTAMP) && \
955 1.2 kre future=$$(($(CHECK_NOW_FUTURE_SECS) + $$now)) && \
956 1.2 kre ./zdump -i -t $$now,$$future \
957 1.2 kre $$(find "$$PWD/$@d"/????*/ -type f) \
958 1.2 kre >$@d/zdump-now.tab && \
959 1.2 kre ./zdump -i -t 0,$$future \
960 1.2 kre $$(find "$$PWD/$@d" -name Etc -prune \
961 1.2 kre -o -type f ! -name '*.tab' -print) \
962 1.2 kre >$@d/zdump-1970.tab
963 1.2 kre $(AWK) \
964 1.2 kre -v zdump_table=$@d/zdump-now.tab \
965 1.2 kre -f checknow.awk zonenow.tab
966 1.2 kre $(AWK) \
967 1.2 kre 'BEGIN {print "-\t-\tUTC"} /^Zone/ {print "-\t-\t" $$2}' \
968 1.2 kre $(PRIMARY_YDATA) backward factory | \
969 1.2 kre $(AWK) \
970 1.2 kre -v zdump_table=$@d/zdump-1970.tab \
971 1.2 kre -f checknow.awk
972 1.2 kre rm -fr $@d
973 1.2 kre touch $@
974 1.2 kre
975 1.2 kre tables.ck: checktab.awk $(YDATA) backward zone.tab zone1970.tab
976 1.1 apb for tab in $(ZONETABLES); do \
977 1.2 kre test "$$tab" = zone.tab && links='$(BACKWARD)' || links=''; \
978 1.2 kre $(AWK) -f checktab.awk -v zone_table=$$tab $(YDATA) $$links \
979 1.1 apb || exit; \
980 1.1 apb done
981 1.2 kre touch $@
982 1.2 kre
983 1.2 kre tzs.ck: $(TZS) $(TZS_NEW)
984 1.2 kre if test -s $(TZS); then \
985 1.2 kre $(SETUP_DIFF_TZS) && $$DIFF_TZS $(TZS) $(TZS_NEW); \
986 1.2 kre else \
987 1.2 kre cp $(TZS_NEW) $(TZS); \
988 1.2 kre fi
989 1.2 kre touch $@
990 1.2 kre
991 1.2 kre check_web: $(CHECK_WEB_PAGES)
992 1.2 kre .SUFFIXES: .ck .html
993 1.2 kre .html.ck:
994 1.2 kre { ! ($(CURL) --version) >/dev/null 2>&1 || \
995 1.2 kre $(CURL) -sS --url https://validator.w3.org/nu/ -F out=gnu \
996 1.2 kre -F file=@$<; } >$@.out && \
997 1.2 kre test ! -s $@.out || { cat $@.out; exit 1; }
998 1.2 kre mv $@.out $@
999 1.2 kre
1000 1.2 kre ziguard.ck: rearguard.zi vanguard.zi ziguard.awk
1001 1.2 kre $(AWK) -v DATAFORM=rearguard -f ziguard.awk vanguard.zi | \
1002 1.2 kre diff -u rearguard.zi -
1003 1.2 kre $(AWK) -v DATAFORM=vanguard -f ziguard.awk rearguard.zi | \
1004 1.2 kre diff -u vanguard.zi -
1005 1.2 kre touch $@
1006 1.1 apb
1007 1.2 kre # Check that zishrink.awk does not alter the data, and that ziguard.awk
1008 1.2 kre # preserves main-format data.
1009 1.2 kre check_zishrink: zishrink-posix.ck zishrink-right.ck
1010 1.2 kre zishrink-posix.ck zishrink-right.ck: \
1011 1.2 kre zic leapseconds $(PACKRATDATA) $(PACKRATLIST) \
1012 1.2 kre $(TDATA) $(DATAFORM).zi tzdata.zi
1013 1.2 kre rm -fr $@d t-$@d shrunk-$@d
1014 1.2 kre mkdir $@d t-$@d shrunk-$@d
1015 1.2 kre case $@ in \
1016 1.2 kre *right*) leap='-L leapseconds';; \
1017 1.2 kre *) leap=;; \
1018 1.2 kre esac && \
1019 1.2 kre $(ZIC) $$leap -d $@d $(DATAFORM).zi && \
1020 1.2 kre $(ZIC) $$leap -d shrunk-$@d tzdata.zi && \
1021 1.2 kre case $(DATAFORM),$(PACKRATLIST) in \
1022 1.2 kre main,) \
1023 1.2 kre $(ZIC) $$leap -d t-$@d $(TDATA) && \
1024 1.2 kre $(AWK) '/^Rule/' $(TDATA) | \
1025 1.2 kre $(ZIC) $$leap -d t-$@d - $(PACKRATDATA) && \
1026 1.2 kre diff -r $@d t-$@d;; \
1027 1.2 kre esac
1028 1.2 kre diff -r $@d shrunk-$@d
1029 1.2 kre rm -fr $@d t-$@d shrunk-$@d
1030 1.2 kre touch $@
1031 1.1 apb
1032 1.1 apb clean_misc:
1033 1.2 kre rm -fr *.ckd *.dir
1034 1.2 kre rm -f *.ck *.core *.o *.out core core.* \
1035 1.2 kre date tzdir.h tzselect version.h zdump zic libtz.a
1036 1.1 apb clean: clean_misc
1037 1.2 kre rm -fr tzdb-*/
1038 1.2 kre rm -f *.zi $(TZS_NEW)
1039 1.1 apb
1040 1.1 apb maintainer-clean: clean
1041 1.1 apb @echo 'This command is intended for maintainers to use; it'
1042 1.1 apb @echo 'deletes files that may need special tools to rebuild.'
1043 1.2 kre rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.*
1044 1.1 apb
1045 1.1 apb names:
1046 1.1 apb @echo $(ENCHILADA)
1047 1.1 apb
1048 1.2 kre public: check public.ck $(CHECK_TIME_T_ALTERNATIVES) \
1049 1.1 apb tarballs signatures
1050 1.1 apb
1051 1.1 apb date.1.txt: date.1
1052 1.1 apb newctime.3.txt: newctime.3
1053 1.1 apb newstrftime.3.txt: newstrftime.3
1054 1.1 apb newtzset.3.txt: newtzset.3
1055 1.1 apb time2posix.3.txt: time2posix.3
1056 1.1 apb tzfile.5.txt: tzfile.5
1057 1.1 apb tzselect.8.txt: tzselect.8
1058 1.1 apb zdump.8.txt: zdump.8
1059 1.1 apb zic.8.txt: zic.8
1060 1.1 apb
1061 1.1 apb $(MANTXTS): workman.sh
1062 1.2 kre LC_ALL=C sh workman.sh $(@:.txt=) >$@.out
1063 1.2 kre mv $@.out $@
1064 1.2 kre
1065 1.2 kre # Set file timestamps deterministically if possible,
1066 1.2 kre # so that tarballs containing the timestamps are reproducible.
1067 1.2 kre #
1068 1.2 kre # '$(SET_TIMESTAMP_N) N DEST A B C ...' sets the timestamp of the
1069 1.2 kre # file DEST to the maximum of the timestamps of the files A B C ...,
1070 1.2 kre # plus N if GNU ls and touch are available.
1071 1.2 kre SET_TIMESTAMP_N = sh -c '\
1072 1.2 kre n=$$0 dest=$$1; shift; \
1073 1.2 kre <"$$dest" && \
1074 1.2 kre if test $$n != 0 && \
1075 1.2 kre lsout=$$(ls -nt --time-style="+%s" "$$@" 2>/dev/null); then \
1076 1.2 kre set x $$lsout && \
1077 1.2 kre timestamp=$$(($$7 + $$n)) && \
1078 1.2 kre echo "+ touch -md @$$timestamp $$dest" && \
1079 1.2 kre touch -md @$$timestamp "$$dest"; \
1080 1.2 kre else \
1081 1.2 kre newest=$$(ls -t "$$@" | sed 1q) && \
1082 1.2 kre echo "+ touch -mr $$newest $$dest" && \
1083 1.2 kre touch -mr "$$newest" "$$dest"; \
1084 1.2 kre fi'
1085 1.2 kre # If DEST depends on A B C ... in this Makefile, callers should use
1086 1.2 kre # $(SET_TIMESTAMP_DEP) DEST A B C ..., for the benefit of any
1087 1.2 kre # downstream 'make' that considers equal timestamps to be out of date.
1088 1.2 kre # POSIX allows this 'make' behavior, and HP-UX 'make' does it.
1089 1.2 kre # If all that matters is that the timestamp be reproducible
1090 1.2 kre # and plausible, use $(SET_TIMESTAMP).
1091 1.2 kre SET_TIMESTAMP = $(SET_TIMESTAMP_N) 0
1092 1.2 kre SET_TIMESTAMP_DEP = $(SET_TIMESTAMP_N) 1
1093 1.1 apb
1094 1.2 kre # Set the timestamps to those of the git repository, if available,
1095 1.1 apb # and if the files have not changed since then.
1096 1.2 kre # This uses GNU 'ls --time-style=+%s', which outputs the seconds count,
1097 1.2 kre # and GNU 'touch -d@N FILE', where N is the number of seconds since 1970.
1098 1.2 kre # If git or GNU is absent, don't bother to sync with git timestamps.
1099 1.1 apb # Also, set the timestamp of each prebuilt file like 'leapseconds'
1100 1.1 apb # to be the maximum of the files it depends on.
1101 1.2 kre set-timestamps.out: $(EIGHT_YARDS)
1102 1.1 apb rm -f $@
1103 1.2 kre if (type git) >/dev/null 2>&1 && \
1104 1.2 kre files=$$(git ls-files $(EIGHT_YARDS)) && \
1105 1.1 apb touch -md @1 test.out; then \
1106 1.1 apb rm -f test.out && \
1107 1.1 apb for file in $$files; do \
1108 1.1 apb if git diff --quiet $$file; then \
1109 1.2 kre time=$$(TZ=UTC0 git log -1 \
1110 1.2 kre --format='tformat:%cd' \
1111 1.2 kre --date='format:%Y-%m-%dT%H:%M:%SZ' \
1112 1.2 kre $$file) && \
1113 1.2 kre echo "+ touch -md $$time $$file" && \
1114 1.2 kre touch -md $$time $$file; \
1115 1.1 apb else \
1116 1.1 apb echo >&2 "$$file: warning: does not match repository"; \
1117 1.1 apb fi || exit; \
1118 1.1 apb done; \
1119 1.1 apb fi
1120 1.2 kre $(SET_TIMESTAMP_DEP) leapseconds $(LEAP_DEPS)
1121 1.2 kre for file in $(MANTXTS); do \
1122 1.2 kre $(SET_TIMESTAMP_DEP) $$file $${file%.txt} workman.sh || \
1123 1.1 apb exit; \
1124 1.1 apb done
1125 1.2 kre $(SET_TIMESTAMP_DEP) version $(VERSION_DEPS)
1126 1.2 kre $(SET_TIMESTAMP_DEP) tzdata.zi $(TZDATA_ZI_DEPS)
1127 1.2 kre touch $@
1128 1.2 kre set-tzs-timestamp.out: $(TZS)
1129 1.2 kre $(SET_TIMESTAMP_DEP) $(TZS) $(TZS_DEPS)
1130 1.1 apb touch $@
1131 1.1 apb
1132 1.1 apb # The zics below ensure that each data file can stand on its own.
1133 1.1 apb # We also do an all-files run to catch links to links.
1134 1.1 apb
1135 1.2 kre public.ck: $(VERSION_DEPS)
1136 1.2 kre rm -fr $@d
1137 1.2 kre mkdir $@d
1138 1.2 kre ln $(VERSION_DEPS) $@d
1139 1.2 kre cd $@d \
1140 1.2 kre && $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' TZDIR='$(TZDIR)' ALL
1141 1.2 kre for i in $(TDATA_TO_CHECK) \
1142 1.2 kre tzdata.zi vanguard.zi main.zi rearguard.zi; \
1143 1.2 kre do \
1144 1.2 kre $@d/zic -v -d $@d/zoneinfo $@d/$$i || exit; \
1145 1.1 apb done
1146 1.2 kre $@d/zic -v -d $@d/zoneinfo-all $(TDATA_TO_CHECK)
1147 1.2 kre :
1148 1.2 kre : Also check 'backzone' syntax.
1149 1.2 kre rm $@d/main.zi
1150 1.2 kre cd $@d && $(MAKE) PACKRATDATA=backzone main.zi
1151 1.2 kre $@d/zic -d $@d/zoneinfo main.zi
1152 1.2 kre rm $@d/main.zi
1153 1.2 kre cd $@d && \
1154 1.2 kre $(MAKE) PACKRATDATA=backzone PACKRATLIST=zone.tab main.zi
1155 1.2 kre $@d/zic -d $@d/zoneinfo main.zi
1156 1.2 kre :
1157 1.2 kre rm -fr $@d
1158 1.2 kre touch $@
1159 1.1 apb
1160 1.1 apb # Check that the code works under various alternative
1161 1.1 apb # implementations of time_t.
1162 1.2 kre check_time_t_alternatives: $(TIME_T_ALTERNATIVES)
1163 1.2 kre $(TIME_T_ALTERNATIVES_TAIL): $(TIME_T_ALTERNATIVES_HEAD)
1164 1.2 kre $(TIME_T_ALTERNATIVES): $(VERSION_DEPS)
1165 1.2 kre rm -fr $@d
1166 1.2 kre mkdir $@d
1167 1.2 kre ln $(VERSION_DEPS) $@d
1168 1.2 kre case $@ in \
1169 1.2 kre *32_t*) range=-2147483648,2147483648;; \
1170 1.2 kre u*) range=0,4294967296;; \
1171 1.2 kre *) range=-4294967296,4294967296;; \
1172 1.2 kre esac && \
1173 1.2 kre wd=$$PWD && \
1174 1.2 kre zones=$$($(AWK) '/^[^#]/ { print $$3 }' <zone1970.tab) && \
1175 1.2 kre if test $@ = $(TIME_T_ALTERNATIVES_HEAD); then \
1176 1.2 kre range_target=; \
1177 1.2 kre else \
1178 1.2 kre range_target=to$$range.tzs; \
1179 1.2 kre fi && \
1180 1.2 kre (cd $@d && \
1181 1.2 kre $(MAKE) TOPDIR="$$wd/$@d" \
1182 1.2 kre CFLAGS='$(CFLAGS) -Dtime_tz='"'$(@:.ck=)'" \
1183 1.2 kre REDO='$(REDO)' \
1184 1.2 kre D="$$wd/$@d" \
1185 1.2 kre TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
1186 1.2 kre install $$range_target) && \
1187 1.2 kre test $@ = $(TIME_T_ALTERNATIVES_HEAD) || { \
1188 1.2 kre (cd $(TIME_T_ALTERNATIVES_HEAD)d && \
1189 1.2 kre $(MAKE) TOPDIR="$$wd/$@d" \
1190 1.2 kre TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
1191 1.2 kre D="$$wd/$@d" \
1192 1.2 kre to$$range.tzs) && \
1193 1.2 kre $(SETUP_DIFF_TZS) && \
1194 1.2 kre $$DIFF_TZS $(TIME_T_ALTERNATIVES_HEAD)d/to$$range.tzs \
1195 1.2 kre $@d/to$$range.tzs && \
1196 1.2 kre if diff -q Makefile Makefile 2>/dev/null; then \
1197 1.2 kre quiet_option='-q'; \
1198 1.2 kre else \
1199 1.2 kre quiet_option=''; \
1200 1.2 kre fi && \
1201 1.2 kre diff $$quiet_option -r $(TIME_T_ALTERNATIVES_HEAD)d/etc \
1202 1.2 kre $@d/etc && \
1203 1.2 kre diff $$quiet_option -r \
1204 1.2 kre $(TIME_T_ALTERNATIVES_HEAD)d/usr/share \
1205 1.2 kre $@d/usr/share; \
1206 1.2 kre }
1207 1.2 kre touch $@
1208 1.1 apb
1209 1.2 kre TRADITIONAL_ASC = \
1210 1.2 kre tzcode$(VERSION).tar.gz.asc \
1211 1.2 kre tzdata$(VERSION).tar.gz.asc
1212 1.2 kre REARGUARD_ASC = \
1213 1.2 kre tzdata$(VERSION)-rearguard.tar.gz.asc
1214 1.2 kre ALL_ASC = $(TRADITIONAL_ASC) $(REARGUARD_ASC) \
1215 1.2 kre tzdb-$(VERSION).tar.lz.asc
1216 1.2 kre
1217 1.2 kre tarballs rearguard_tarballs tailored_tarballs traditional_tarballs \
1218 1.2 kre signatures rearguard_signatures traditional_signatures: \
1219 1.2 kre version set-timestamps.out rearguard.zi vanguard.zi
1220 1.2 kre read -r VERSION <version && \
1221 1.2 kre $(MAKE) AWK='$(AWK)' VERSION="$$VERSION" $@_version
1222 1.2 kre
1223 1.2 kre # These *_version rules are intended for use if VERSION is set by some
1224 1.2 kre # other means. Ordinarily these rules are used only by the above
1225 1.2 kre # non-_version rules, which set VERSION on the 'make' command line.
1226 1.2 kre tarballs_version: traditional_tarballs_version rearguard_tarballs_version \
1227 1.2 kre tzdb-$(VERSION).tar.lz
1228 1.2 kre rearguard_tarballs_version: \
1229 1.2 kre tzdata$(VERSION)-rearguard.tar.gz
1230 1.2 kre traditional_tarballs_version: \
1231 1.2 kre tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
1232 1.2 kre tailored_tarballs_version: \
1233 1.2 kre tzdata$(VERSION)-tailored.tar.gz
1234 1.2 kre signatures_version: $(ALL_ASC)
1235 1.2 kre rearguard_signatures_version: $(REARGUARD_ASC)
1236 1.2 kre traditional_signatures_version: $(TRADITIONAL_ASC)
1237 1.1 apb
1238 1.1 apb tzcode$(VERSION).tar.gz: set-timestamps.out
1239 1.2 kre $(SETUP_TAR) && \
1240 1.2 kre $$TAR -cf - \
1241 1.2 kre $(COMMON) $(DOCS) $(SOURCES) | \
1242 1.2 kre gzip $(GZIPFLAGS) >$@.out
1243 1.2 kre mv $@.out $@
1244 1.1 apb
1245 1.1 apb tzdata$(VERSION).tar.gz: set-timestamps.out
1246 1.2 kre $(SETUP_TAR) && \
1247 1.2 kre $$TAR -cf - $(TZDATA_DIST) | \
1248 1.2 kre gzip $(GZIPFLAGS) >$@.out
1249 1.2 kre mv $@.out $@
1250 1.2 kre
1251 1.2 kre # Create empty files with a reproducible timestamp.
1252 1.2 kre CREATE_EMPTY = TZ=UTC0 touch -mt 202010122253.00
1253 1.2 kre
1254 1.2 kre # The obsolescent *rearguard* targets and related macros are present
1255 1.2 kre # for backwards compatibility with tz releases 2018e through 2022a.
1256 1.2 kre # They should go away eventually. To build rearguard tarballs you
1257 1.2 kre # can instead use 'make DATAFORM=rearguard tailored_tarballs'.
1258 1.2 kre tzdata$(VERSION)-rearguard.tar.gz: rearguard.zi set-timestamps.out
1259 1.2 kre rm -fr $@.dir
1260 1.2 kre mkdir $@.dir
1261 1.2 kre ln $(TZDATA_DIST) $@.dir
1262 1.2 kre cd $@.dir && rm -f $(TDATA) $(PACKRATDATA) version
1263 1.2 kre for f in $(TDATA) $(PACKRATDATA); do \
1264 1.2 kre rearf=$@.dir/$$f; \
1265 1.2 kre $(AWK) -v DATAFORM=rearguard -f ziguard.awk $$f >$$rearf && \
1266 1.2 kre $(SET_TIMESTAMP_DEP) $$rearf ziguard.awk $$f || exit; \
1267 1.2 kre done
1268 1.2 kre sed '1s/$$/-rearguard/' <version >$@.dir/version
1269 1.2 kre : The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
1270 1.2 kre $(CREATE_EMPTY) $@.dir/pacificnew
1271 1.2 kre touch -mr version $@.dir/version
1272 1.2 kre $(SETUP_TAR) && \
1273 1.2 kre (cd $@.dir && \
1274 1.2 kre $$TAR -cf - \
1275 1.2 kre $(TZDATA_DIST) pacificnew | \
1276 1.2 kre gzip $(GZIPFLAGS)) >$@.out
1277 1.2 kre mv $@.out $@
1278 1.2 kre
1279 1.2 kre # Create a tailored tarball suitable for TZUpdater and compatible tools.
1280 1.2 kre # For example, 'make DATAFORM=vanguard tailored_tarballs' makes a tarball
1281 1.2 kre # useful for testing whether TZUpdater supports vanguard form.
1282 1.2 kre # The generated tarball is not byte-for-byte equivalent to a hand-tailored
1283 1.2 kre # traditional tarball, as data entries are put into 'etcetera' even if they
1284 1.2 kre # came from some other source file. However, the effect should be the same
1285 1.2 kre # for ordinary use, which reads all the source files.
1286 1.2 kre tzdata$(VERSION)-tailored.tar.gz: set-timestamps.out
1287 1.2 kre rm -fr $@.dir
1288 1.2 kre mkdir $@.dir
1289 1.2 kre : The dummy pacificnew pacifies TZUpdater 2.3.1 and earlier.
1290 1.2 kre if test $(DATAFORM) = vanguard; then \
1291 1.2 kre pacificnew=; \
1292 1.2 kre else \
1293 1.2 kre pacificnew=pacificnew; \
1294 1.2 kre fi && \
1295 1.2 kre cd $@.dir && \
1296 1.2 kre $(CREATE_EMPTY) $(PRIMARY_YDATA) $(NDATA) backward \
1297 1.2 kre $$pacificnew
1298 1.2 kre (grep '^#' tzdata.zi && echo && cat $(DATAFORM).zi) \
1299 1.2 kre >$@.dir/etcetera
1300 1.2 kre touch -mr tzdata.zi $@.dir/etcetera
1301 1.2 kre sed -n \
1302 1.2 kre -e '/^# *version *\(.*\)/h' \
1303 1.2 kre -e '/^# *ddeps */H' \
1304 1.2 kre -e '$$!d' \
1305 1.2 kre -e 'g' \
1306 1.2 kre -e 's/^# *version *//' \
1307 1.2 kre -e 's/\n# *ddeps */-/' \
1308 1.2 kre -e 's/ /-/g' \
1309 1.2 kre -e 'p' \
1310 1.2 kre <tzdata.zi >$@.dir/version
1311 1.2 kre touch -mr version $@.dir/version
1312 1.2 kre links= && \
1313 1.2 kre for file in $(TZDATA_DIST); do \
1314 1.2 kre test -f $@.dir/$$file || links="$$links $$file"; \
1315 1.2 kre done && \
1316 1.2 kre ln $$links $@.dir
1317 1.2 kre $(SETUP_TAR) && \
1318 1.2 kre (cd $@.dir && \
1319 1.2 kre $$TAR -cf - * | gzip $(GZIPFLAGS)) >$@.out
1320 1.2 kre mv $@.out $@
1321 1.2 kre
1322 1.2 kre tzdb-$(VERSION).tar.lz: set-timestamps.out set-tzs-timestamp.out
1323 1.2 kre rm -fr tzdb-$(VERSION)
1324 1.2 kre mkdir tzdb-$(VERSION)
1325 1.2 kre ln $(ENCHILADA) tzdb-$(VERSION)
1326 1.2 kre $(SET_TIMESTAMP) tzdb-$(VERSION) tzdb-$(VERSION)/*
1327 1.2 kre $(SETUP_TAR) && \
1328 1.2 kre $$TAR -cf - tzdb-$(VERSION) | lzip -9 >$@.out
1329 1.2 kre mv $@.out $@
1330 1.1 apb
1331 1.1 apb tzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz
1332 1.1 apb tzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz
1333 1.2 kre tzdata$(VERSION)-rearguard.tar.gz.asc: tzdata$(VERSION)-rearguard.tar.gz
1334 1.2 kre tzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz
1335 1.2 kre $(ALL_ASC):
1336 1.2 kre $(GPG) --armor --detach-sign $?
1337 1.2 kre
1338 1.2 kre TYPECHECK_CFLAGS = $(CFLAGS) -DTYPECHECK -D__time_t_defined -D_TIME_T
1339 1.2 kre typecheck: long-long.ck unsigned.ck
1340 1.2 kre long-long.ck unsigned.ck: $(VERSION_DEPS)
1341 1.2 kre rm -fr $@d
1342 1.2 kre mkdir $@d
1343 1.2 kre ln $(VERSION_DEPS) $@d
1344 1.2 kre cd $@d && \
1345 1.2 kre case $@ in \
1346 1.2 kre long-long.*) i="long long";; \
1347 1.2 kre unsigned.* ) i="unsigned" ;; \
1348 1.2 kre esac && \
1349 1.2 kre $(MAKE) \
1350 1.2 kre CFLAGS="$(TYPECHECK_CFLAGS) \"-Dtime_t=$$i\"" \
1351 1.2 kre TOPDIR="$$PWD" \
1352 1.2 kre install
1353 1.2 kre $@d/zdump -i -c 1970,1971 Europe/Rome
1354 1.2 kre touch $@
1355 1.1 apb
1356 1.2 kre zonenames: tzdata.zi
1357 1.2 kre @$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi
1358 1.1 apb
1359 1.1 apb asctime.o: private.h tzfile.h
1360 1.1 apb date.o: private.h
1361 1.1 apb difftime.o: private.h
1362 1.2 kre localtime.o: private.h tzfile.h tzdir.h
1363 1.2 kre strftime.o: private.h tzfile.h
1364 1.1 apb zdump.o: version.h
1365 1.2 kre zic.o: private.h tzfile.h tzdir.h version.h
1366 1.1 apb
1367 1.1 apb .PHONY: ALL INSTALL all
1368 1.2 kre .PHONY: check check_mild check_time_t_alternatives
1369 1.2 kre .PHONY: check_web check_zishrink
1370 1.2 kre .PHONY: clean clean_misc commit-leap-seconds.list dummy.zd
1371 1.2 kre .PHONY: fetch-leap-seconds.list force_tzs
1372 1.2 kre .PHONY: install maintainer-clean names
1373 1.2 kre .PHONY: posix_only posix_right public
1374 1.2 kre .PHONY: rearguard_signatures rearguard_signatures_version
1375 1.2 kre .PHONY: rearguard_tarballs rearguard_tarballs_version
1376 1.2 kre .PHONY: right_only right_posix signatures signatures_version
1377 1.2 kre .PHONY: tarballs tarballs_version
1378 1.2 kre .PHONY: traditional_signatures traditional_signatures_version
1379 1.2 kre .PHONY: traditional_tarballs traditional_tarballs_version
1380 1.2 kre .PHONY: tailored_tarballs tailored_tarballs_version
1381 1.2 kre .PHONY: typecheck
1382 1.1 apb .PHONY: zonenames zones
1383 1.2 kre .PHONY: $(ZDS)
1384