update from main archive 970121
[glibc.git] / time / Makefile
blob7f8513cc6a807ca18119d015000d4c61d17e6000
1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 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.
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.
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.
20 # Makefile for time routines
22 subdir := time
24 headers := time.h sys/time.h sys/timeb.h timebits.h
25 distribute := tzfile.h private.h scheck.c ialloc.c yearistype \
26 iso3166.tab zone.tab tzselect.ksh checktab.awk \
27 README
28 extra-objs = scheck.o ialloc.o $(tzfiles:%=z.%)
30 routines := offtime asctime clock ctime ctime_r difftime \
31 gmtime localtime mktime strftime time tzset \
32 tzfile gettimeofday settimeofday adjtime \
33 getitimer setitimer \
34 stime dysize timegm ftime \
35 strptime
37 others := ap zdump zic
38 tests := test_time clocktest test-tz
40 # Before the test-tz test can be run we need the data to be installed.
41 tests: install-test-data
44 tzfiles := africa antarctica asia australasia europe northamerica \
45 southamerica etcetera factory systemv backward \
46 solar87 solar88 solar89
47 # pacificnew doesn't compile; if it is to be used, it should be included in
48 # northamerica.
49 distribute += $(tzfiles) leapseconds pacificnew simplebackw
51 install-sbin := zic zdump
53 generated-dirs = testdata
55 all: # Make this the default target; it will be defined in Rules.
57 include ../Makeconfig # Get objpfx defined so we can use it below.
59 # z.* use this variable.
60 define nl
63 endef
64 -include $(addprefix $(objpfx)z.,$(tzfiles))
66 # Make these absolute file names.
67 installed-localtime-file := $(firstword $(filter /%,$(localtime-file)) \
68 $(addprefix $(inst_zonedir)/, \
69 $(localtime-file)))
70 installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
71 $(addprefix $(inst_zonedir)/, \
72 $(posixrules-file)))
74 ifeq ($(cross-compiling),no)
75 # Don't try to install the zoneinfo files since we can't run zic.
76 install-others = $(addprefix $(inst_zonedir)/,$(zonenames) \
77 $(zonenames:%=posix/%) \
78 $(zonenames:%=right/%)) \
79 $(installed-localtime-file) $(installed-posixrules-file)
80 endif
82 ifeq ($(have-ksh),yes)
83 install-others += $(inst_zonedir)/iso3166.tab $(inst_zonedir)/zone.tab
84 install-bin += tzselect
85 endif
87 include ../Rules
90 $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
91 # Kludge alert: we use an implicit rule (in what we are generating here)
92 # because that is the only way to tell Make that the one command builds all
93 # the files.
94 (echo 'define $*-zones' ;\
95 awk '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^;\
96 echo 'endef' ;\
97 echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))' ;\
98 echo 'ifdef $*-zones' ;\
99 echo '$$(addprefix $$(datadir)/zone%/right/,$$($*-zones)): \' ;\
100 echo '$< $$(objpfx)zic leapseconds yearistype' ;\
101 echo ' $$(tzcompile)' ;\
102 echo '$$(addprefix $$(datadir)/zone%/posix/,$$($*-zones)): \' ;\
103 echo '$< $$(objpfx)zic /dev/null yearistype' ;\
104 echo ' $$(tzcompile)' ;\
105 echo '$$(addprefix $$(datadir)/zone%/,$$($*-zones)): \' ;\
106 echo '$< $$(objpfx)zic $$(leapseconds) yearistype' ;\
107 echo ' $$(tzcompile)' ;\
108 echo 'endif' ;\
109 echo 'zonenames := $$(zonenames) $$($*-zones)' ;\
110 ) > $@.new
111 mv $@.new $@
113 .PHONY: echo-zonenames
114 echo-zonenames:
115 @echo 'Known zones: $(zonenames)'
118 # We have to use `-d $(inst_zonedir)' to explictly tell zic where to
119 # place the output files although $(zonedir) is compiled in. But the
120 # user might have set $(install_root) on the command line of `make install'.
121 zic-cmd = $(built-program-cmd) -d $(inst_zonedir)
122 tzcompile = $(zic-cmd)$(target-zone-flavor) -L $(word 3,$^) \
123 -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
125 # The source files specify the zone names relative to the -d directory,
126 # so for the posix/ and right/ flavors we need to pass -d $(inst_zonedir)/posix
127 # and the like. This magic extracts /posix or /right if it's the first
128 # component after $(inst_zonedir) in the target name $@.
129 target-zone-flavor = $(filter /posix /right, \
130 /$(firstword $(subst /, , \
131 $(patsubst $(inst_zonedir)/%,%,$@))))
133 ifdef localtime
134 $(installed-localtime-file): $(inst_zonedir)/$(localtime) $(objpfx)zic
135 $(make-target-directory)
136 if test -r $@; then \
137 echo Site timezone NOT reset to Factory.; \
138 else \
139 rm -f $@T; \
140 $(SHELL) $(..)/rellns-sh $< $@T; \
141 mv -f $@T $@; \
143 endif
144 ifdef posixrules
145 $(installed-posixrules-file): $(inst_zonedir)/$(posixrules) $(objpfx)zic
146 $(zic-cmd) -p $(posixrules)
147 endif
150 $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
152 tz-cflags = -DTZDIR='"$(zonedir)"' \
153 -DTZDEFAULT='"$(localtime-file)"' \
154 -DTZDEFRULES='"$(posixrules-file)"'
156 CFLAGS-zdump.c = -Wno-strict-prototypes -DNOID
157 CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags)
158 CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID
159 CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID
160 CFLAGS-tzfile.c = $(tz-cflags)
162 # We have to make sure the data for testing the tz functions is available.
163 .PHONY: install-test-data
164 install-test-data: northamerica $(objpfx)zic $(leapseconds) yearistype \
165 etcetera simplebackw
166 -mkdir $(objpfx)testdata
167 $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
168 -y yearistype northamerica
169 $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
170 -y yearistype etcetera
171 $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
172 -y yearistype simplebackw
173 test-tz-ENV = TZDIR=$(objpfx)testdata
176 $(objpfx)tzselect: tzselect.ksh
177 sed -e 's%@KSH@%$(KSH)%g' \
178 -e 's%@TZDIR@%$(zonedir)%g' < $< > $@.new
179 chmod 555 $@.new
180 mv -f $@.new $@
182 $(addprefix $(inst_zonedir)/,iso3166.tab zone.tab): $(inst_zonedir)/%: %
183 $(do-install)