2.3.3-96
[glibc/history.git] / timezone / Makefile
blobcf2c7d7f424684b08b346dfdefb899a31fcdcd4e
1 # Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 # 02111-1307 USA.
20 # Makefile for timezone information
22 subdir := timezone
24 distribute := tzfile.h private.h scheck.c ialloc.c yearistype \
25 iso3166.tab zone.tab tzselect.ksh checktab.awk \
26 README
28 extra-objs := scheck.o ialloc.o
30 others := zdump zic
31 tests := test-tz tst-timezone
33 tzbases := africa antarctica asia australasia europe northamerica \
34 southamerica etcetera factory \
35 solar87 solar88 solar89
36 tzlinks := backward systemv
37 tzfiles := $(tzbases) $(tzlinks)
38 # pacificnew doesn't compile; if it is to be used, it should be included in
39 # northamerica.
40 distribute += $(tzfiles) leapseconds pacificnew simplebackw
42 generated := $(addprefix z.,$(tzfiles))
43 install-sbin := zic zdump
45 generated-dirs = testdata
47 all: # Make this the default target; it will be defined in Rules.
49 include ../Makeconfig # Get objpfx defined so we can use it below.
51 CPPFLAGS-zic = -DNOT_IN_libc
53 # z.* use this variable.
54 define nl
57 endef
58 ifndef avoid-generated
59 ifndef inhibit_timezone_rules
60 -include $(addprefix $(objpfx)z.,$(tzfiles))
61 endif
62 endif
64 # Make these absolute file names.
65 installed-localtime-file := $(firstword $(filter /%,$(inst_localtime-file)) \
66 $(addprefix $(inst_zonedir)/, \
67 $(localtime-file)))
68 installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
69 $(addprefix $(inst_zonedir)/, \
70 $(posixrules-file)))
72 ifeq ($(cross-compiling),no)
73 # Don't try to install the zoneinfo files since we can't run zic.
74 install-others = $(addprefix $(inst_zonedir)/,$(zonenames) \
75 $(zonenames:%=posix/%) \
76 $(zonenames:%=right/%)) \
77 $(installed-localtime-file) $(installed-posixrules-file)
78 endif
80 ifeq ($(have-ksh),yes)
81 install-others += $(inst_zonedir)/iso3166.tab $(inst_zonedir)/zone.tab
82 install-bin-script = tzselect
83 generated += tzselect
84 endif
86 include ../Rules
89 $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
90 # Kludge alert: we use an implicit rule (in what we are generating here)
91 # because that is the only way to tell Make that the one command builds all
92 # the files.
93 # The extra kludge for the $(tzlinks) files is necessary since running zic
94 # this file requires all other files to exist. Blech!
95 $(make-target-directory)
96 (echo 'define $*-zones' ;\
97 $(AWK) '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^ ;\
98 echo 'endef' ;\
99 echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))' ;\
100 echo 'ifdef $*-zones' ;\
101 if test x$(findstring $*, $(tzlinks)) != x; then \
102 echo '$$(addprefix $$(inst_zonedir)/right/,$$($*-zones)): \';\
103 echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/right/,$$($$t-zones)))' ;\
104 echo '$$(addprefix $$(inst_zonedir)/posix/,$$($*-zones)): \';\
105 echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/posix/,$$($$t-zones)))' ;\
106 echo '$$(addprefix $$(inst_zonedir)/,$$($*-zones)): \' ;\
107 echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/,$$($$t-zones)))' ;\
108 fi ;\
109 echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/right/,$$($*-zones)): \' ;\
110 echo '$< $$(objpfx)zic leapseconds yearistype' ;\
111 echo ' $$(tzcompile)' ;\
112 echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/posix/,$$($*-zones)): \' ;\
113 echo '$< $$(objpfx)zic /dev/null yearistype' ;\
114 echo ' $$(tzcompile)' ;\
115 echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/,$$($*-zones)): \' ;\
116 echo '$< $$(objpfx)zic $$(leapseconds) yearistype' ;\
117 echo ' $$(tzcompile)' ;\
118 echo 'endif' ;\
119 echo 'zonenames := $$(zonenames) $$($*-zones)' ;\
120 ) > $@.new
121 mv $@.new $@
123 .PHONY: echo-zonenames
124 echo-zonenames:
125 @echo 'Known zones: $(zonenames)'
128 # We have to use `-d $(inst_zonedir)' to explictly tell zic where to
129 # place the output files although $(zonedir) is compiled in. But the
130 # user might have set $(install_root) on the command line of `make install'.
131 zic-cmd = $(built-program-cmd) -d $(inst_zonedir)
132 tzcompile = $(zic-cmd)$(target-zone-flavor) -L $(word 3,$^) \
133 -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
135 # The source files specify the zone names relative to the -d directory,
136 # so for the posix/ and right/ flavors we need to pass -d $(inst_zonedir)/posix
137 # and the like. This magic extracts /posix or /right if it's the first
138 # component after $(inst_zonedir) in the target name $@.
139 target-zone-flavor = $(filter /posix /right, \
140 /$(firstword $(subst /, , \
141 $(patsubst $(inst_zonedir)/%,%,$@))))
143 ifdef localtime
144 $(installed-localtime-file): $(inst_zonedir)/$(localtime) $(objpfx)zic \
145 $(+force)
146 $(make-target-directory)
147 if test -r $@; then \
148 echo Site timezone NOT reset to Factory.; \
149 else \
150 rm -f $@T; \
151 $(SHELL) $(..)scripts/rellns-sh $< $@T; \
152 mv -f $@T $@; \
154 endif
155 ifdef posixrules
156 $(installed-posixrules-file): $(inst_zonedir)/$(posixrules) $(objpfx)zic \
157 $(+force)
158 $(zic-cmd) -p $(posixrules)
159 endif
162 $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
164 tz-cflags = -DTZDIR='"$(zonedir)"' \
165 -DTZDEFAULT='"$(localtime-file)"' \
166 -DTZDEFRULES='"$(posixrules-file)"' \
167 -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone
169 CFLAGS-zdump.c = -Wno-strict-prototypes -DNOID $(tz-cflags) -DHAVE_GETTEXT
170 CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags) -DHAVE_GETTEXT
171 CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID -DHAVE_GETTEXT
172 CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID -DHAVE_GETTEXT
174 # We have to make sure the data for testing the tz functions is available.
175 # Don't add leapseconds here since test-tz made checks that work only without
176 # leapseconds.
177 testdata = $(objpfx)testdata
178 define build-testdata
179 GCONV_PATH=${common-objpfx}iconvdata LANGUAGE=C LC_ALL=C \
180 $(built-program-cmd) -d $(testdata) -y ./yearistype $<
181 endef
183 $(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC)
184 $(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
185 Europe/Berlin Universal \
186 Australia/Melbourne \
187 America/Sao_Paulo Asia/Tokyo \
188 Europe/London)
190 test-tz-ENV = TZDIR=$(testdata)
191 tst-timezone-ENV = TZDIR=$(testdata)
193 $(testdata)/America/New_York: northamerica $(objpfx)zic $(leapseconds) \
194 yearistype
195 $(build-testdata)
196 $(testdata)/Etc/UTC: etcetera $(objpfx)zic $(leapseconds) yearistype
197 $(build-testdata)
198 $(testdata)/UTC: simplebackw $(objpfx)zic $(testdata)/Etc/UTC \
199 $(leapseconds) yearistype
200 $(build-testdata)
201 $(testdata)/Europe/Berlin: europe $(objpfx)zic $(leapseconds) yearistype
202 $(build-testdata)
203 $(testdata)/Universal: simplebackw $(objpfx)zic $(testdata)/Etc/UTC \
204 $(leapseconds) yearistype
205 $(build-testdata)
206 $(testdata)/Australia/Melbourne: australasia $(objpfx)zic $(leapseconds) \
207 yearistype
208 $(build-testdata)
209 $(testdata)/America/Sao_Paulo: southamerica $(objpfx)zic $(leapseconds) \
210 yearistype
211 $(build-testdata)
212 $(testdata)/Asia/Tokyo: asia $(objpfx)zic $(leapseconds) yearistype
213 $(build-testdata)
214 $(testdata)/Europe/London: europe $(objpfx)zic $(leapseconds) yearistype
215 $(build-testdata)
218 $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
219 sed -e 's%@KSH@%$(KSH)%g' \
220 -e 's%@TZDIR@%$(zonedir)%g' < $< > $@.new
221 chmod 555 $@.new
222 mv -f $@.new $@
224 $(addprefix $(inst_zonedir)/,iso3166.tab zone.tab): \
225 $(inst_zonedir)/%: % $(+force)
226 $(do-install)