Update.
[platform/upstream/glibc.git] / timezone / Makefile
1 # Copyright (C) 1998 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 Library General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # 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 # Library General Public License for more details.
13
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB.  If not,
16 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
18
19 #
20 #       Makefile for timezone information
21 #
22 subdir  := timezone
23
24 distribute := tzfile.h private.h scheck.c ialloc.c yearistype   \
25               iso3166.tab zone.tab tzselect.ksh checktab.awk    \
26               README
27
28 extra-objs := scheck.o ialloc.o
29
30 others  := zdump zic
31 tests   := test-tz
32
33 tzbases := africa antarctica asia australasia europe northamerica \
34            southamerica etcetera factory systemv \
35            solar87 solar88 solar89
36 tzlinks := backward
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
41
42 install-sbin := zic zdump
43
44 generated-dirs = testdata
45
46 all: # Make this the default target; it will be defined in Rules.
47
48 include ../Makeconfig   # Get objpfx defined so we can use it below.
49
50 # z.* use this variable.
51 define nl
52
53
54 endef
55 ifneq ($(no_deps),t)
56 -include $(addprefix $(objpfx)z.,$(tzfiles))
57 endif
58
59 # Make these absolute file names.
60 installed-localtime-file := $(firstword $(filter /%,$(inst_localtime-file)) \
61                                         $(addprefix $(inst_zonedir)/, \
62                                                     $(localtime-file)))
63 installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
64                                          $(addprefix $(inst_zonedir)/, \
65                                                      $(posixrules-file)))
66
67 ifeq ($(cross-compiling),no)
68 # Don't try to install the zoneinfo files since we can't run zic.
69 install-others = $(addprefix $(inst_zonedir)/,$(zonenames) \
70                                               $(zonenames:%=posix/%) \
71                                               $(zonenames:%=right/%)) \
72                  $(installed-localtime-file) $(installed-posixrules-file)
73 endif
74
75 ifeq ($(have-ksh),yes)
76 install-others += $(inst_zonedir)/iso3166.tab $(inst_zonedir)/zone.tab
77 install-bin += tzselect
78 generated += tzselect
79 endif
80
81 include ../Rules
82
83
84 $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
85 # Kludge alert: we use an implicit rule (in what we are generating here)
86 # because that is the only way to tell Make that the one command builds all
87 # the files.
88 # The extra kludge for the $(tzlinks) files is necessary since running zic
89 # this file requires all other files to exist.  Blech!
90         (echo 'define $*-zones'                                             ;\
91          awk '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^   ;\
92          echo 'endef'                                                       ;\
93          echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))'                 ;\
94          echo 'ifdef $*-zones'                                              ;\
95          if test x$(findstring $*, $(tzlinks)) != x; then                    \
96            echo '$$(addprefix $$(inst_zonedir)/right/,$$($*-zones)): \';\
97            echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/right/,
98 $$($$t-zones)))' ;\
99            echo '$$(addprefix $$(inst_zonedir)/posix/,$$($*-zones)): \';\
100            echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/posix/,
101 $$($$t-zones)))' ;\
102            echo '$$(addprefix $$(inst_zonedir)/,$$($*-zones)): \'           ;\
103            echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/,$$($$t
104 -zones)))' ;\
105          fi                                                                 ;\
106          echo '$$(addprefix $$(inst_datadir)/zone%/right/,$$($*-zones)): \' ;\
107          echo '$< $$(objpfx)zic leapseconds yearistype'                     ;\
108          echo ' $$(tzcompile)'                                              ;\
109          echo '$$(addprefix $$(inst_datadir)/zone%/posix/,$$($*-zones)): \' ;\
110          echo '$< $$(objpfx)zic /dev/null yearistype'                       ;\
111          echo ' $$(tzcompile)'                                              ;\
112          echo '$$(addprefix $$(inst_datadir)/zone%/,$$($*-zones)): \'       ;\
113          echo '$< $$(objpfx)zic $$(leapseconds) yearistype'                 ;\
114          echo ' $$(tzcompile)'                                              ;\
115          echo 'endif'                                                       ;\
116          echo 'zonenames := $$(zonenames) $$($*-zones)'                     ;\
117         ) > $@.new
118         mv $@.new $@
119
120 .PHONY: echo-zonenames
121 echo-zonenames:
122         @echo 'Known zones: $(zonenames)'
123
124
125 # We have to use `-d $(inst_zonedir)' to explictly tell zic where to
126 # place the output files although $(zonedir) is compiled in.  But the
127 # user might have set $(install_root) on the command line of `make install'.
128 zic-cmd = $(built-program-cmd) -d $(inst_zonedir)
129 tzcompile = $(zic-cmd)$(target-zone-flavor) -L $(word 3,$^) \
130             -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
131
132 # The source files specify the zone names relative to the -d directory,
133 # so for the posix/ and right/ flavors we need to pass -d $(inst_zonedir)/posix
134 # and the like.  This magic extracts /posix or /right if it's the first
135 # component after $(inst_zonedir) in the target name $@.
136 target-zone-flavor = $(filter /posix /right, \
137                               /$(firstword $(subst /, , \
138                                           $(patsubst $(inst_zonedir)/%,%,$@))))
139
140 ifdef localtime
141 $(installed-localtime-file): $(inst_zonedir)/$(localtime) $(objpfx)zic
142         $(make-target-directory)
143         if test -r $@; then \
144           echo Site timezone NOT reset to Factory.; \
145         else \
146           rm -f $@T; \
147           $(SHELL) $(..)/rellns-sh $< $@T; \
148           mv -f $@T $@; \
149         fi
150 endif
151 ifdef posixrules
152 $(installed-posixrules-file): $(inst_zonedir)/$(posixrules) $(objpfx)zic
153         $(zic-cmd) -p $(posixrules)
154 endif
155
156
157 $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
158
159 tz-cflags = -DTZDIR='"$(zonedir)"' \
160             -DTZDEFAULT='"$(localtime-file)"' \
161             -DTZDEFRULES='"$(posixrules-file)"'
162
163 CFLAGS-zdump.c = -Wno-strict-prototypes -DNOID
164 CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags)
165 CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID
166 CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID
167 CFLAGS-tzfile.c = $(tz-cflags)
168 CFLAGS-tzset.c = $(tz-cflags)
169
170 # We have to make sure the data for testing the tz functions is available.
171 $(objpfx)test-tz.out: $(addprefix $(objpfx)testdata/, America/New_York \
172                                                       Etc/UTC UTC)
173
174 $(objpfx)testdata/America/New_York: northamerica $(objpfx)zic \
175                                     $(leapseconds) yearistype
176         $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
177           -y yearistype northamerica
178 $(objpfx)testdata/Etc/UTC: etcetera $(objpfx)zic $(leapseconds) yearistype
179         $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
180           -y yearistype etcetera
181 $(objpfx)testdata/UTC: simplebackw $(objpfx)zic $(objpfx)testdata/Etc/UTC \
182                        $(leapseconds) yearistype
183         $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
184           -y yearistype simplebackw
185
186 test-tz-ENV = TZDIR=$(objpfx)testdata
187
188
189 $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
190         sed -e 's%@KSH@%$(KSH)%g' \
191             -e 's%@TZDIR@%$(zonedir)%g' < $< > $@.new
192         chmod 555 $@.new
193         mv -f $@.new $@
194
195 $(addprefix $(inst_zonedir)/,iso3166.tab zone.tab): $(inst_zonedir)/%: %
196         $(do-install)