1# Copyright (C) 1998-2022 Free Software Foundation, Inc. 2# This file is part of the GNU C Library. 3 4# The GNU C Library is free software; you can redistribute it and/or 5# modify it under the terms of the GNU Lesser General Public 6# License as published by the Free Software Foundation; either 7# version 2.1 of the License, or (at your option) any later version. 8 9# The GNU C Library is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# Lesser General Public License for more details. 13 14# You should have received a copy of the GNU Lesser General Public 15# License along with the GNU C Library; if not, see 16# <https://www.gnu.org/licenses/>. 17 18# 19# Makefile for timezone information 20# 21subdir := timezone 22 23include ../Makeconfig 24 25others := zdump zic 26tests := test-tz tst-timezone tst-tzset tst-bz28707 27 28generated-dirs += testdata 29 30generated += tzselect 31 32testdata = $(objpfx)testdata 33 34ifeq ($(enable-timezone-tools),yes) 35install-sbin := zic 36install-bin := zdump 37install-bin-script = tzselect 38endif 39 40ifeq ($(run-built-tests),yes) 41# List zones generated by separate commands running zic on the host. 42# Each such zic run counts as a separate test. 43test-zones := America/New_York Etc/UTC UTC Europe/Berlin \ 44 Australia/Melbourne America/Sao_Paulo Asia/Tokyo \ 45 $(posixrules-file) 46tests-special += $(addprefix $(testdata)/, $(test-zones)) 47endif 48 49include ../Rules 50 51 52$(objpfx)zic.o $(objpfx)zdump.o: $(objpfx)version.h 53 54$(objpfx)version.h: $(common-objpfx)config.make 55 echo 'static char const TZVERSION[]="$(version)";' \ 56 > $@.new 57 mv -f $@.new $@ 58 59tz-cflags = -DTZDIR='"$(zonedir)"' \ 60 -DTZDEFAULT='"$(localtime-file)"' \ 61 -DTZDEFRULES='"$(posixrules-file)"' \ 62 -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone \ 63 -DHAVE_GETTEXT -DUSE_LTZ=0 -D_ISOMAC -DTZ_DOMAIN='"libc"' \ 64 -include $(common-objpfx)config.h -Wno-maybe-uninitialized 65 66# The -Wno-unused-variable flag is used to prevent GCC 6 67# from warning about time_t_min and time_t_max which are 68# defined in private.h but not used. 69CFLAGS-zdump.c += $(tz-cflags) 70CFLAGS-zic.c += $(tz-cflags) -Wno-unused-variable 71 72# We have to make sure the data for testing the tz functions is available. 73# Don't add leapseconds here since test-tz made checks that work only without 74# leapseconds. 75define build-testdata 76$(built-program-cmd) -d $(testdata) -y ./yearistype $<; \ 77$(evaluate-test) 78endef 79 80$(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC) 81$(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \ 82 Europe/Berlin Universal \ 83 Australia/Melbourne \ 84 America/New_York \ 85 America/Sao_Paulo Asia/Tokyo \ 86 Europe/London) 87$(objpfx)tst-tzset.out: $(addprefix $(testdata)/XT, 1 2 3 4) 88$(objpfx)tst-bz28707.out: $(testdata)/XT5 89 90test-tz-ENV = TZDIR=$(testdata) 91tst-timezone-ENV = TZDIR=$(testdata) 92tst-tzset-ENV = TZDIR=$(testdata) 93tst-bz28707-ENV = TZDIR=$(testdata) 94 95# Note this must come second in the deps list for $(built-program-cmd) to work. 96zic-deps = $(objpfx)zic $(leapseconds) yearistype 97 98$(testdata)/America/New_York: northamerica $(zic-deps) 99 $(build-testdata) 100$(testdata)/$(posixrules-file): $(testdata)/America/New_York 101 $(make-link); $(evaluate-test) 102$(testdata)/Etc/UTC: etcetera $(zic-deps) 103 $(build-testdata) 104# Use a pattern rule to indicate the command produces both targets at once. 105# Two separate targets built separately can collide if in parallel. 106%/UTC %/Universal: simplebackw $(zic-deps) %/Etc/UTC 107 $(build-testdata) 108 { test -r $(@D)/Universal.test-result \ 109 && cp $(@D)/Universal.test-result $(@D)/UTC.test-result \ 110 && sed -i 's/Universal/UTC/' $(@D)/UTC.test-result ; exit 0; } 111 { test -r $(@D)/UTC.test-result \ 112 && cp $(@D)/UTC.test-result $(@D)/Universal.test-result \ 113 && sed -i 's/UTC/Universal/' $(@D)/Universal.test-result ; exit 0; } 114$(testdata)/%/Berlin $(testdata)/%/London: europe $(zic-deps) 115 $(build-testdata) 116$(testdata)/Australia/Melbourne: australasia $(zic-deps) 117 $(build-testdata) 118$(testdata)/America/Sao_Paulo: southamerica $(zic-deps) 119 $(build-testdata) 120$(testdata)/Asia/Tokyo: asia $(zic-deps) 121 $(build-testdata) 122 123$(testdata)/XT%: testdata/XT% 124 $(make-target-directory) 125 cp $< $@ 126 127$(testdata)/XT5: testdata/gen-XT5.sh 128 $(make-target-directory) 129 $(SHELL) $< > $@.tmp 130 mv $@.tmp $@ 131 132$(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make 133 sed -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \ 134 -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \ 135 -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \ 136 -e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \ 137 < $< > $@.new 138 chmod 555 $@.new 139 mv -f $@.new $@ 140