* time/tzfile.h, time/private.h, time/zdump.c, time/zic.c,
[glibc.git] / time / Makefile
blobdd5014104a6f4fb78ed67c88bb2ca0cdb20e94e4
1 # Copyright (C) 1991, 92, 93, 94, 95, 96 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
16 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 # Cambridge, MA 02139, 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 extra-objs = scheck.o ialloc.o $(tzfiles:%=z.%)
28 routines := offtime asctime clock ctime difftime gmtime \
29 localtime mktime strftime time tzset tzfile \
30 gettimeofday settimeofday adjtime \
31 getitimer setitimer \
32 stime dysize timegm ftime \
33 strptime
35 others := ap zdump zic
36 tests := test_time clocktest test-tz
38 tzfiles := africa antarctica asia australasia europe northamerica \
39 southamerica etcetera factory systemv backward
40 # pacificnew doesn't compile; if it is to be used, it should be included in
41 # northamerica.
42 distribute := $(distribute) $(tzfiles) leapseconds pacificnew
44 install-sbin := zic zdump
46 all: # Make this the default target; it will be defined in Rules.
48 include ../Makeconfig # Get objpfx defined so we can use it below.
50 # z.* use this variable.
51 define nl
54 endef
55 -include $(addprefix $(objpfx)z.,$(tzfiles))
57 # Make these absolute file names.
58 installed-localtime-file := $(firstword $(filter /%,$(localtime-file)) \
59 $(addprefix $(zonedir)/, \
60 $(localtime-file)))
61 installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
62 $(addprefix $(zonedir)/, \
63 $(posixrules-file)))
65 ifeq ($(cross-compiling),no)
66 # Don't try to install the zoneinfo files since we can't run zic.
67 install-others = $(addprefix $(zonedir)/,$(zonenames) \
68 $(zonenames:%=posix/%) \
69 $(zonenames:%=right/%)) \
70 $(installed-localtime-file) $(installed-posixrules-file)
71 endif
73 include ../Rules
76 $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
77 # Kludge alert: we use an implicit rule (in what we are generating here)
78 # because that is the only way to tell Make that the one command builds all
79 # the files.
80 (echo 'define $*-zones' ;\
81 awk '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^;\
82 echo 'endef' ;\
83 echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))' ;\
84 echo 'ifdef $*-zones' ;\
85 echo '$$(addprefix $$(datadir)/zone%/right/,$$($*-zones)): \' ;\
86 echo '$< $$(objpfx)zic leapseconds yearistype' ;\
87 echo ' $$(tzcompile)' ;\
88 echo '$$(addprefix $$(datadir)/zone%/posix/,$$($*-zones)): \' ;\
89 echo '$< $$(objpfx)zic /dev/null yearistype' ;\
90 echo ' $$(tzcompile)' ;\
91 echo '$$(addprefix $$(datadir)/zone%/,$$($*-zones)): \' ;\
92 echo '$< $$(objpfx)zic $$(leapseconds) yearistype' ;\
93 echo ' $$(tzcompile)' ;\
94 echo 'endif' ;\
95 echo 'zonenames := $$(zonenames) $$($*-zones)' ;\
96 ) > $@.new
97 mv $@.new $@
99 .PHONY: echo-zonenames
100 echo-zonenames: zonenames
101 @echo 'Known zones: $(zonenames)'
104 # Although $(zonedir) gets compiled into zic, it is useful to always
105 # specify it with -d on the command line so that it can be overridden on
106 # the command line of `make install' (e.g., "make install prefix=/foo").
107 zic-cmd = $(built-program-cmd) -d $(zonedir)
108 tzcompile = $(zic-cmd)$(target-zone-flavor) -L $(word 3,$^) \
109 -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
111 # The source files specify the zone names relative to the -d directory,
112 # so for the posix/ and right/ flavors we need to pass -d $(zonedir)/posix
113 # and the like. This magic extracts /posix or /right if it's the first
114 # component after $(zonedir) in the target name $@.
115 target-zone-flavor = $(filter /posix /right, \
116 /$(firstword $(subst /, , \
117 $(patsubst $(zonedir)/%,%,$@))))
119 ifdef localtime
120 $(installed-localtime-file): $(zonedir)/$(localtime) $(objpfx)zic
121 $(zic-cmd) -l $(localtime)
122 endif
123 ifdef posixrules
124 $(installed-posixrules-file): $(zonedir)/$(posixrules) $(objpfx)zic
125 $(zic-cmd) -p $(posixrules)
126 endif
129 $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
131 tz-cflags = -DTZDIR='"$(zonedir)"' \
132 -DTZDEFAULT='"$(localtime-file)"' \
133 -DTZDEFRULES='"$(posixrules-file)"'
135 CFLAGS-zdump.c = -Wno-strict-prototypes -DNOID
136 CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags)
137 CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID
138 CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID
139 CFLAGS-tzfile.c = $(tz-cflags)