blob: dee7568c7ee37816afe8a7b0026fe7077ecef4cf [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001# Copyright (C) 1998-2016 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# <http://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
27
28generated-dirs += testdata
29
30generated += tzselect
31
32testdata = $(objpfx)testdata
33
34ifeq ($(enable-timezone-tools),yes)
35install-sbin := zic zdump
36install-bin-script = tzselect
37endif
38
39ifeq ($(run-built-tests),yes)
40# List zones generated by separate commands running zic on the host.
41# Each such zic run counts as a separate test.
42test-zones := America/New_York Etc/UTC UTC Europe/Berlin \
43 Australia/Melbourne America/Sao_Paulo Asia/Tokyo \
44 $(posixrules-file)
45tests-special += $(addprefix $(testdata)/, $(test-zones))
46endif
47
48include ../Rules
49
50
51$(objpfx)zic.o $(objpfx)zdump.o: $(objpfx)version.h
52
53$(objpfx)version.h: $(common-objpfx)config.make
54 echo 'static char const TZVERSION[]="$(version)";' \
55 > $@.new
56 mv -f $@.new $@
57
58tz-cflags = -DTZDIR='"$(zonedir)"' \
59 -DTZDEFAULT='"$(localtime-file)"' \
60 -DTZDEFRULES='"$(posixrules-file)"' \
61 -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone \
62 -DHAVE_GETTEXT -DUSE_LTZ=0 -Wno-maybe-uninitialized
63
64# The -Wno-unused-variable flag is used to prevent GCC 6
65# from warning about time_t_min and time_t_max which are
66# defined in private.h but not used.
67CFLAGS-zdump.c = $(tz-cflags)
68CFLAGS-zic.c = $(tz-cflags) -Wno-unused-variable
69
70# We have to make sure the data for testing the tz functions is available.
71# Don't add leapseconds here since test-tz made checks that work only without
72# leapseconds.
73define build-testdata
74$(built-program-cmd) -d $(testdata) -y ./yearistype $<; \
75$(evaluate-test)
76endef
77
78$(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC)
79$(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
80 Europe/Berlin Universal \
81 Australia/Melbourne \
82 America/Sao_Paulo Asia/Tokyo \
83 Europe/London)
84$(objpfx)tst-tzset.out: $(addprefix $(testdata)/XT, 1 2 3 4)
85
86test-tz-ENV = TZDIR=$(testdata)
87tst-timezone-ENV = TZDIR=$(testdata)
88tst-tzset-ENV = TZDIR=$(testdata)
89
90# Note this must come second in the deps list for $(built-program-cmd) to work.
91zic-deps = $(objpfx)zic $(leapseconds) yearistype
92
93$(testdata)/America/New_York: northamerica $(zic-deps)
94 $(build-testdata)
95$(testdata)/$(posixrules-file): $(testdata)/America/New_York
96 $(make-link); $(evaluate-test)
97$(testdata)/Etc/UTC: etcetera $(zic-deps)
98 $(build-testdata)
99# Use a pattern rule to indicate the command produces both targets at once.
100# Two separate targets built separately can collide if in parallel.
101%/UTC %/Universal: simplebackw $(zic-deps) %/Etc/UTC
102 $(build-testdata)
103 { test -r $(@D)/Universal.test-result \
104 && cp $(@D)/Universal.test-result $(@D)/UTC.test-result \
105 && sed -i 's/Universal/UTC/' $(@D)/UTC.test-result ; exit 0; }
106 { test -r $(@D)/UTC.test-result \
107 && cp $(@D)/UTC.test-result $(@D)/Universal.test-result \
108 && sed -i 's/UTC/Universal/' $(@D)/Universal.test-result ; exit 0; }
109$(testdata)/%/Berlin $(testdata)/%/London: europe $(zic-deps)
110 $(build-testdata)
111$(testdata)/Australia/Melbourne: australasia $(zic-deps)
112 $(build-testdata)
113$(testdata)/America/Sao_Paulo: southamerica $(zic-deps)
114 $(build-testdata)
115$(testdata)/Asia/Tokyo: asia $(zic-deps)
116 $(build-testdata)
117
118$(testdata)/XT%: testdata/XT%
119 $(make-target-directory)
120 cp $< $@
121
122$(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
123 sed -e 's|/bin/bash|$(BASH)|' \
124 -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
125 -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
126 -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
127 -e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
128 < $< > $@.new
129 chmod 555 $@.new
130 mv -f $@.new $@