blob: 24c93c60519352093119ee240f5d3e9886d3d8e4 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# Copyright (C) 1998-2015 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
25extra-objs := scheck.o ialloc.o
26
27others := zdump zic
28tests := test-tz tst-timezone tst-tzset
29
30# pacificnew doesn't compile; if it is to be used, it should be included in
31# northamerica.
32tzbases := africa antarctica asia australasia europe northamerica \
33 southamerica etcetera factory \
34 solar87 solar88 solar89
35tzlinks := backward systemv
36tzfiles := $(tzbases) $(tzlinks)
37
38generated += $(addprefix z.,$(tzfiles))
39install-sbin := zic zdump
40
41generated-dirs += testdata
42
43install-bin-script = tzselect
44generated += tzselect
45
46testdata = $(objpfx)testdata
47
48ifeq ($(run-built-tests),yes)
49# List zones generated by separate commands running zic on the host.
50# Each such zic run counts as a separate test.
51test-zones := America/New_York Etc/UTC UTC Europe/Berlin \
52 Australia/Melbourne America/Sao_Paulo Asia/Tokyo
53tests-special += $(addprefix $(testdata)/, $(test-zones))
54endif
55
56include ../Rules
57
58
59$(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
60
61$(objpfx)zic.o $(objpfx)zdump.o: $(objpfx)version.h
62
63$(objpfx)version.h: $(common-objpfx)config.make
64 echo 'static char const TZVERSION[]="$(version)";' \
65 > $@.new
66 mv -f $@.new $@
67
68tz-cflags = -DTZDIR='"$(zonedir)"' \
69 -DTZDEFAULT='"$(localtime-file)"' \
70 -DTZDEFRULES='"$(posixrules-file)"' \
71 -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone
72
73CFLAGS-zdump.c = -fwrapv -Wno-strict-prototypes -DNOID $(tz-cflags) \
74 -DHAVE_GETTEXT
75CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags) -DHAVE_GETTEXT
76CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID -DHAVE_GETTEXT
77CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID -DHAVE_GETTEXT
78
79# We have to make sure the data for testing the tz functions is available.
80# Don't add leapseconds here since test-tz made checks that work only without
81# leapseconds.
82define build-testdata
83$(built-program-cmd) -d $(testdata) -y ./yearistype $<; \
84$(evaluate-test)
85endef
86
87$(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC)
88$(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
89 Europe/Berlin Universal \
90 Australia/Melbourne \
91 America/Sao_Paulo Asia/Tokyo \
92 Europe/London)
93$(objpfx)tst-tzset.out: $(addprefix $(testdata)/XT, 1 2 3 4)
94
95test-tz-ENV = TZDIR=$(testdata)
96tst-timezone-ENV = TZDIR=$(testdata)
97tst-tzset-ENV = TZDIR=$(testdata)
98
99# Note this must come second in the deps list for $(built-program-cmd) to work.
100zic-deps = $(objpfx)zic $(leapseconds) yearistype
101
102$(testdata)/America/New_York: northamerica $(zic-deps)
103 $(build-testdata)
104$(testdata)/Etc/UTC: etcetera $(zic-deps)
105 $(build-testdata)
106# Use a pattern rule to indicate the command produces both targets at once.
107# Two separate targets built separately can collide if in parallel.
108%/UTC %/Universal: simplebackw $(zic-deps) %/Etc/UTC
109 $(build-testdata)
110 { test -r $(@D)/Universal.test-result \
111 && cp $(@D)/Universal.test-result $(@D)/UTC.test-result \
112 && sed -i 's/Universal/UTC/' $(@D)/UTC.test-result ; exit 0; }
113 { test -r $(@D)/UTC.test-result \
114 && cp $(@D)/UTC.test-result $(@D)/Universal.test-result \
115 && sed -i 's/UTC/Universal/' $(@D)/Universal.test-result ; exit 0; }
116$(testdata)/%/Berlin $(testdata)/%/London: europe $(zic-deps)
117 $(build-testdata)
118$(testdata)/Australia/Melbourne: australasia $(zic-deps)
119 $(build-testdata)
120$(testdata)/America/Sao_Paulo: southamerica $(zic-deps)
121 $(build-testdata)
122$(testdata)/Asia/Tokyo: asia $(zic-deps)
123 $(build-testdata)
124
125$(testdata)/XT%: testdata/XT%
126 cp $< $@
127
128$(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
129 sed -e 's|/bin/bash|$(BASH)|' \
130 -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
131 -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
132 -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
133 -e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
134 < $< > $@.new
135 chmod 555 $@.new
136 mv -f $@.new $@