12
12
# Lesser General Public License for more details.
14
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
15
# License along with the GNU C Library; if not, see
16
# <http://www.gnu.org/licenses/>.
20
19
# Makefile for timezone information
24
distribute := tzfile.h private.h scheck.c ialloc.c yearistype \
25
iso3166.tab zone.tab tzselect.ksh checktab.awk \
28
23
extra-objs := scheck.o ialloc.o
30
25
others := zdump zic
31
26
tests := test-tz tst-timezone
28
# pacificnew doesn't compile; if it is to be used, it should be included in
33
30
tzbases := africa antarctica asia australasia europe northamerica \
34
31
southamerica etcetera factory \
35
32
solar87 solar88 solar89
36
33
tzlinks := backward systemv
37
34
tzfiles := $(tzbases) $(tzlinks)
38
# pacificnew doesn't compile; if it is to be used, it should be included in
40
distribute += $(tzfiles) leapseconds pacificnew simplebackw
42
36
generated := $(addprefix z.,$(tzfiles))
43
37
install-sbin := zic zdump
51
45
CPPFLAGS-zic = -DNOT_IN_libc
53
# z.* use this variable.
58
ifndef avoid-generated
59
ifndef inhibit_timezone_rules
60
-include $(addprefix $(objpfx)z.,$(tzfiles))
64
# Make these absolute file names.
65
installed-localtime-file := $(firstword $(filter /%,$(inst_localtime-file)) \
66
$(addprefix $(inst_zonedir)/, \
68
installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
69
$(addprefix $(inst_zonedir)/, \
72
install-others = $(addprefix $(inst_zonedir)/,$(zonenames) \
73
$(zonenames:%=posix/%) \
74
$(zonenames:%=right/%)) \
75
$(installed-localtime-file) $(installed-posixrules-file)
77
47
ifeq ($(have-ksh),yes)
78
install-others += $(inst_zonedir)/iso3166.tab $(inst_zonedir)/zone.tab
79
48
install-bin-script = tzselect
80
49
generated += tzselect
86
$(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
87
# Kludge alert: we use an implicit rule (in what we are generating here)
88
# because that is the only way to tell Make that the one command builds all
90
# The extra kludge for the $(tzlinks) files is necessary since running zic
91
# this file requires all other files to exist. Blech!
92
$(make-target-directory)
93
(echo 'define $*-zones' ;\
94
$(AWK) '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^ ;\
96
echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))' ;\
97
echo 'ifdef $*-zones' ;\
98
if test x$(findstring $*, $(tzlinks)) != x; then \
99
echo '$$(addprefix $$(inst_zonedir)/right/,$$($*-zones)): \';\
100
echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/right/,$$($$t-zones)))' ;\
101
echo '$$(addprefix $$(inst_zonedir)/posix/,$$($*-zones)): \';\
102
echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/posix/,$$($$t-zones)))' ;\
103
echo '$$(addprefix $$(inst_zonedir)/,$$($*-zones)): \' ;\
104
echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/,$$($$t-zones)))' ;\
106
echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/right/,$$($*-zones)): \' ;) > $@.new
108
ifeq (no,$(cross-compiling))
109
(echo '$< $$(objpfx)zic leapseconds yearistype' ;) >> $@.new
111
(echo '$< $$(objpfx)cross-zic leapseconds yearistype' ;) >> $@.new
114
(echo ' $$(tzcompile)' ;\
115
echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/posix/,$$($*-zones)): \' ;) >> $@.new
117
ifeq (no,$(cross-compiling))
118
(echo '$< $$(objpfx)zic /dev/null yearistype' ;) >> $@.new
120
(echo '$< $$(objpfx)cross-zic /dev/null yearistype' ;) >> $@.new
123
(echo ' $$(tzcompile)' ;\
124
echo '$$(addprefix $$(dir $$(inst_zonedir))zone%/,$$($*-zones)): \' ;) >> $@.new
126
ifeq (no,$(cross-compiling))
127
(echo '$< $$(objpfx)zic $$(leapseconds) yearistype' ;) >> $@.new
129
(echo '$< $$(objpfx)cross-zic $$(leapseconds) yearistype' ;) >> $@.new
132
(echo ' $$(tzcompile)' ;\
134
echo 'zonenames := $$(zonenames) $$($*-zones)' ;) >> $@.new
137
.PHONY: echo-zonenames
139
@echo 'Known zones: $(zonenames)'
142
# We have to use `-d $(inst_zonedir)' to explictly tell zic where to
143
# place the output files although $(zonedir) is compiled in. But the
144
# user might have set $(install_root) on the command line of `make install'.
145
ifeq (no,$(cross-compiling))
146
zic-cmd = $(built-program-cmd) -d $(inst_zonedir)
148
zic-cmd = $(objpfx)cross-zic -d $(inst_zonedir)
150
tzcompile = $(zic-cmd)$(target-zone-flavor) -L $(word 3,$^) \
151
-y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
153
# The source files specify the zone names relative to the -d directory,
154
# so for the posix/ and right/ flavors we need to pass -d $(inst_zonedir)/posix
155
# and the like. This magic extracts /posix or /right if it's the first
156
# component after $(inst_zonedir) in the target name $@.
157
target-zone-flavor = $(filter /posix /right, \
158
/$(firstword $(subst /, , \
159
$(patsubst $(inst_zonedir)/%,%,$@))))
162
$(installed-localtime-file): $(inst_zonedir)/$(localtime) $(objpfx)zic \
164
$(make-target-directory)
165
if test -r $@; then \
166
echo Site timezone NOT reset to Factory.; \
169
$(SHELL) $(..)scripts/rellns-sh $< $@T; \
174
$(installed-posixrules-file): $(inst_zonedir)/$(posixrules) $(objpfx)zic \
176
$(zic-cmd) -p $(posixrules)
179
55
zic-objs = zic.o ialloc.o scheck.o
181
57
$(objpfx)zic: $(addprefix $(objpfx), $(zic-objs))
183
59
$(addprefix $(objpfx)cross-,$(zic-objs)): $(objpfx)cross-%.o: %.c
184
gcc $< -c $(OUTPUT_OPTION) $(CFLAGS-$*.c) $(CPPFLAGS-$*) \
60
$(BUILD_CC) $< -c $(OUTPUT_OPTION) $(CFLAGS-$*.c) $(CPPFLAGS-$*) \
185
61
-DCROSS_ZIC $(compile-mkdep-flags)
187
63
$(objpfx)cross-zic: $(addprefix $(objpfx)cross-,$(zic-objs))
188
gcc $(addprefix $(objpfx)cross-,$(zic-objs)) -o $@
64
$(BUILD_CC) $(addprefix $(objpfx)cross-,$(zic-objs)) -o $@
190
66
tz-cflags = -DTZDIR='"$(zonedir)"' \
191
67
-DTZDEFAULT='"$(localtime-file)"' \