[tz] [PROPOSED PATCH 5/9] zdump: use tz library unless USE_LTZ is 0

Paul Eggert eggert at cs.ucla.edu
Mon Aug 25 06:59:49 UTC 2014

This fixes some schizophrenia in the build, which linked zdump to
the tz library code but did not compile zdump with the tz library API.
* zdump.c (USE_LTZ): New macro.
Use it, not time_tz, to decide whether to include private.h.
* Makefile, NEWS: Document this.
* Makefile (CHECK_TIME_T_ALTERNATIVES): New macro.
(public): Use it.
 Makefile |  8 +++++++-
 NEWS     |  5 +++++
 zdump.c  | 10 ++++++----
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 968773f..0a8696c 100644
--- a/Makefile
+++ b/Makefile
@@ -136,6 +136,8 @@ LDLIBS=
 #	DST transitions if the time zone files cannot be accessed
 #  -DUNINIT_TRAP=1 if reading uninitialized storage can cause problems
 #	other than simply getting garbage data
+#  -DUSE_LTZ=0 to build zdump with the system time zone library
+#	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
 #	(or some other number) to set the maximum time zone abbreviation length
 #	that zic will accept without a warning (the default is 6)
@@ -258,6 +260,10 @@ VALIDATE_ENV = \
+# This expensive test requires USE_LTZ.
+# To suppress it, define this macro to be empty.
+CHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives
 # SAFE_CHAR is a regular expression that matches a safe character.
 # Some parts of this distribution are limited to safe characters;
 # others can use any UTF-8 character.
@@ -488,7 +494,7 @@ maintainer-clean: clean
 		@echo $(ENCHILADA)
-public:		check check_public check_time_t_alternatives \
+public:		check check_public $(CHECK_TIME_T_ALTERNATIVES) \
 		tarballs signatures
 date.1.txt:	date.1
diff --git a/NEWS b/NEWS
index 3d69b1f..9cf4b04 100644
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,11 @@ Unreleased, experimental changes
     more likely to guess right for ambiguous time stamps near
     transitions where tm_isdst does not change.
+    zdump now builds with the tz library unless USE_LTZ is defined to 0,
+    This lets zdump use tz features even if the system library lacks them.
+    To build zdump with the system library, use 'make CFLAGS=-DUSE_LTZ=0
     tzselect -c now uses a hybrid distance measure that works better
     in Africa.  (Thanks to Alan Barrett for noting the problem.)
diff --git a/zdump.c b/zdump.c
index c417b20..594e5fd 100644
--- a/zdump.c
+++ b/zdump.c
@@ -9,12 +9,14 @@
 ** This code has been made independent of the rest of the time
 ** conversion package to increase confidence in the verification it provides.
 ** You can use this code to help in verifying other implementations.
-** However, include private.h when debugging, so that it overrides
-** time_t consistently with the rest of the package.
+** To do this, compile with -DUSE_LTZ=0 and link without the tz library.
-#ifdef time_tz
+#ifndef USE_LTZ
+# define USE_LTZ 1
+#if USE_LTZ
 # include "private.h"

More information about the tz mailing list