Put TZDIR’s definition in a new file tzdir.h instead of using macros that do not always work with recursive ‘make’ invocations. This follows up on the recent changes to make the Makefile more POSIX-compatible. * .gitignore: Ignore tzdir.h. * Makefile (DTZDIR): Remove. All uses removed. (tzdir.h): New target rule. (clean_misc): Remove tzdir.h. (check_public): Pass TZDIR, not TZDIR. (localtime.o, zic.o): Depend on tzdir.h. * NEWS: Mention this. * localtime.c, zic.c: Include tzdir.h. * tzfile.h (TZDIR): Remove; now defined by tzdir.h. --- .gitignore | 1 + Makefile | 27 ++++++++++++++------------- NEWS | 2 ++ localtime.c | 1 + tzfile.h | 4 ---- zic.c | 1 + 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index cf3b8250..d50d176d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ ChangeLog check_* date leapseconds +tzdir.h tzselect version version.h diff --git a/Makefile b/Makefile index edbc4d16..6e8e8fd9 100644 --- a/Makefile +++ b/Makefile @@ -549,10 +549,6 @@ RANLIB= : ############################################################################### -# $(CC) option to specify TZDIR, appropriately quoted. -# It is separate from CFLAGS so that CFLAGS and TZDIR can be set independently. -DTZDIR = -DTZDIR='"$(TZDIR)"' - TZCOBJS= zic.o TZDOBJS= zdump.o localtime.o asctime.o strftime.o DATEOBJS= date.o localtime.o strftime.o asctime.o @@ -690,6 +686,13 @@ tzdata.zi: $(DATAFORM).zi version zishrink.awk $(DATAFORM).zi >$@.out mv $@.out $@ +tzdir.h: + printf '%s\n' >$@.out \ + '#ifndef TZDIR' \ + '# define TZDIR "$(TZDIR)" /* TZif directory */' \ + '#endif' + mv $@.out $@ + version.h: version VERSION=`cat version` && printf '%s\n' \ 'static char const PKGVERSION[]="($(PACKAGE)) ";' \ @@ -699,10 +702,10 @@ version.h: version mv $@.out $@ zdump: $(TZDOBJS) - $(CC) -o $@ $(DTZDIR) $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS) + $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS) zic: $(TZCOBJS) - $(CC) -o $@ $(DTZDIR) $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS) + $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS) leapseconds: $(LEAP_DEPS) $(AWK) -v EXPIRES_LINE=$(EXPIRES_LINE) \ @@ -800,7 +803,7 @@ libtz.a: $(LIBOBJS) $(RANLIB) $@ date: $(DATEOBJS) - $(CC) -o $@ $(DTZDIR) $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS) + $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS) tzselect: tzselect.ksh version VERSION=`cat version` && sed \ @@ -947,7 +950,7 @@ clean_misc: rm -fr check_*.dir typecheck_*.dir rm -f *.o *.out $(TIME_T_ALTERNATIVES) \ check_* core typecheck_* \ - date tzselect version.h zdump zic libtz.a + date tzdir.h tzselect version.h zdump zic libtz.a clean: clean_misc rm -fr *.dir tzdb-*/ rm -f *.zi $(TZS_NEW) @@ -1052,7 +1055,7 @@ check_public: $(VERSION_DEPS) mkdir public.dir ln $(VERSION_DEPS) public.dir cd public.dir \ - && $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' DTZDIR=$(DTZDIR) ALL + && $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' TZDIR='$(TZDIR)' ALL for i in $(TDATA_TO_CHECK) public.dir/tzdata.zi \ public.dir/vanguard.zi public.dir/main.zi \ public.dir/rearguard.zi; \ @@ -1096,7 +1099,6 @@ $(TIME_T_ALTERNATIVES): $(VERSION_DEPS) (cd $@.dir && \ $(MAKE) TOPDIR="$$wd/$@.dir" \ CFLAGS='$(CFLAGS) -Dtime_tz='"'$@'" \ - DTZDIR=$(DTZDIR) \ REDO='$(REDO)' \ D=$$wd/$@.dir \ TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \ @@ -1260,7 +1262,6 @@ typecheck_long_long typecheck_unsigned: $(VERSION_DEPS) typecheck_cflags='' && \ $(MAKE) \ CFLAGS="$(TYPECHECK_CFLAGS) \"-Dtime_t=$$i\"" \ - DTZDIR=$(DTZDIR) \ TOPDIR="`pwd`" \ install $@.dir/zdump -i -c 1970,1971 Europe/Rome @@ -1272,10 +1273,10 @@ zonenames: tzdata.zi asctime.o: private.h tzfile.h date.o: private.h difftime.o: private.h -localtime.o: private.h tzfile.h +localtime.o: private.h tzfile.h tzdir.h strftime.o: private.h tzfile.h zdump.o: version.h -zic.o: private.h tzfile.h version.h +zic.o: private.h tzfile.h tzdir.h version.h .PHONY: ALL INSTALL all .PHONY: check check_mild check_time_t_alternatives diff --git a/NEWS b/NEWS index b7884c2d..0f033eca 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,8 @@ Unreleased, experimental changes * It no longer uses its own 'cc' in place of CC. * It now uses ARFLAGS, with default specified by POSIX. * It does not use LFLAGS incompatibly with POSIX. + Due to the CC changes, TZDIR is now #defined in a file tzfile.h + built by 'make', not in a $(CC) -D option. Changes to commentary diff --git a/localtime.c b/localtime.c index f65a4295..319fd4ee 100644 --- a/localtime.c +++ b/localtime.c @@ -15,6 +15,7 @@ #define LOCALTIME_IMPLEMENTATION #include "private.h" +#include "tzdir.h" #include "tzfile.h" #include <fcntl.h> diff --git a/tzfile.h b/tzfile.h index 9cbdcff5..fcb7ab1d 100644 --- a/tzfile.h +++ b/tzfile.h @@ -21,10 +21,6 @@ ** Information about time zone files. */ -#ifndef TZDIR -# define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */ -#endif /* !defined TZDIR */ - #ifndef TZDEFAULT # define TZDEFAULT "/etc/localtime" #endif /* !defined TZDEFAULT */ diff --git a/zic.c b/zic.c index cb473bdc..e10cb21b 100644 --- a/zic.c +++ b/zic.c @@ -14,6 +14,7 @@ #include "version.h" #include "private.h" +#include "tzdir.h" #include "tzfile.h" #include <fcntl.h> -- 2.40.1