]> git.ipfire.org Git - thirdparty/glibc.git/blob - time/Makefile
af03fa2961fea7dcfaaaa438b6105657d89eabba
[thirdparty/glibc.git] / time / Makefile
1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 time routines
21 #
22 subdir := time
23
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 extra-objs = scheck.o ialloc.o $(tzfiles:%=z.%)
28
29 routines := offtime asctime clock ctime ctime_r difftime \
30 gmtime localtime mktime strftime time tzset \
31 tzfile gettimeofday settimeofday adjtime \
32 getitimer setitimer \
33 stime dysize timegm ftime \
34 strptime
35
36 others := ap zdump zic
37 tests := test_time clocktest test-tz
38
39 # Before the test-tz test can be run we need the data to be installed.
40 tests: install-test-data
41
42
43 tzfiles := africa antarctica asia australasia europe northamerica \
44 southamerica etcetera factory systemv backward \
45 solar87 solar88 solar89
46 # pacificnew doesn't compile; if it is to be used, it should be included in
47 # northamerica.
48 distribute := $(distribute) $(tzfiles) leapseconds pacificnew simplebackw
49
50 install-sbin := zic zdump
51
52 generated-dirs = testdata
53
54 all: # Make this the default target; it will be defined in Rules.
55
56 include ../Makeconfig # Get objpfx defined so we can use it below.
57
58 # z.* use this variable.
59 define nl
60
61
62 endef
63 -include $(addprefix $(objpfx)z.,$(tzfiles))
64
65 # Make these absolute file names.
66 installed-localtime-file := $(firstword $(filter /%,$(localtime-file)) \
67 $(addprefix $(zonedir)/, \
68 $(localtime-file)))
69 installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
70 $(addprefix $(zonedir)/, \
71 $(posixrules-file)))
72
73 ifeq ($(cross-compiling),no)
74 # Don't try to install the zoneinfo files since we can't run zic.
75 install-others = $(addprefix $(zonedir)/,$(zonenames) \
76 $(zonenames:%=posix/%) \
77 $(zonenames:%=right/%)) \
78 $(installed-localtime-file) $(installed-posixrules-file)
79 endif
80
81 ifeq ($(have-ksh),yes)
82 install-others += $(zonedir)/iso3166.tab $(zonedir)/zone.tab
83 install-bin += tzselect
84 endif
85
86 include ../Rules
87
88
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 (echo 'define $*-zones' ;\
94 awk '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^;\
95 echo 'endef' ;\
96 echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))' ;\
97 echo 'ifdef $*-zones' ;\
98 echo '$$(addprefix $$(datadir)/zone%/right/,$$($*-zones)): \' ;\
99 echo '$< $$(objpfx)zic leapseconds yearistype' ;\
100 echo ' $$(tzcompile)' ;\
101 echo '$$(addprefix $$(datadir)/zone%/posix/,$$($*-zones)): \' ;\
102 echo '$< $$(objpfx)zic /dev/null yearistype' ;\
103 echo ' $$(tzcompile)' ;\
104 echo '$$(addprefix $$(datadir)/zone%/,$$($*-zones)): \' ;\
105 echo '$< $$(objpfx)zic $$(leapseconds) yearistype' ;\
106 echo ' $$(tzcompile)' ;\
107 echo 'endif' ;\
108 echo 'zonenames := $$(zonenames) $$($*-zones)' ;\
109 ) > $@.new
110 mv $@.new $@
111
112 .PHONY: echo-zonenames
113 echo-zonenames:
114 @echo 'Known zones: $(zonenames)'
115
116
117 # Although $(zonedir) gets compiled into zic, it is useful to always
118 # specify it with -d on the command line so that it can be overridden on
119 # the command line of `make install' (e.g., "make install prefix=/foo").
120 zic-cmd = $(built-program-cmd) -d $(zonedir)
121 tzcompile = $(zic-cmd)$(target-zone-flavor) -L $(word 3,$^) \
122 -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
123
124 # The source files specify the zone names relative to the -d directory,
125 # so for the posix/ and right/ flavors we need to pass -d $(zonedir)/posix
126 # and the like. This magic extracts /posix or /right if it's the first
127 # component after $(zonedir) in the target name $@.
128 target-zone-flavor = $(filter /posix /right, \
129 /$(firstword $(subst /, , \
130 $(patsubst $(zonedir)/%,%,$@))))
131
132 ifdef localtime
133 $(installed-localtime-file): $(zonedir)/$(localtime) $(objpfx)zic
134 $(make-target-directory)
135 if test -r $@; then \
136 echo Site timezone NOT reset to Factory.; \
137 else \
138 rm -f $@T; \
139 $(SHELL) $(..)/rellns-sh $< $@T; \
140 mv -f $@T $@; \
141 fi
142 endif
143 ifdef posixrules
144 $(installed-posixrules-file): $(zonedir)/$(posixrules) $(objpfx)zic
145 $(zic-cmd) -p $(posixrules)
146 endif
147
148
149 $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
150
151 tz-cflags = -DTZDIR='"$(zonedir)"' \
152 -DTZDEFAULT='"$(localtime-file)"' \
153 -DTZDEFRULES='"$(posixrules-file)"'
154
155 CFLAGS-zdump.c = -Wno-strict-prototypes -DNOID
156 CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags)
157 CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID
158 CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID
159 CFLAGS-tzfile.c = $(tz-cflags)
160
161 # We have to make sure the data for testing the tz functions is available.
162 .PHONY: install-test-data
163 install-test-data: northamerica $(objpfx)zic $(leapseconds) yearistype \
164 etcetera simplebackw
165 -mkdir $(objpfx)testdata
166 $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
167 -y yearistype northamerica
168 $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
169 -y yearistype etcetera
170 $(built-program-cmd) -d $(objpfx)testdata -L $(leapseconds) \
171 -y yearistype simplebackw
172 test-tz-ENV = TZDIR=$(objpfx)testdata
173
174
175 $(objpfx)tzselect: tzselect.ksh
176 sed -e 's%@KSH@%$(KSH)%g' \
177 -e 's%@TZDIR@%$(zonedir)%g' < $< > $@.new
178 chmod 555 $@.new
179 mv -f $@.new $@
180
181 $(addprefix $(zonedir)/,iso3166.tab zone.tab): $(zonedir)/%: %; $(do-install)