1 # Copyright (C) 1991, 1992, 1993, 1994 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
24 headers := time.h sys/time.h sys/timeb.h
25 distribute := tzfile.h private.h scheck.c ialloc.c emkdir.c yearistype
26 extra-objs = scheck.o ialloc.o emkdir.o zonenames $(tzfiles:%=z.%)
28 routines := offtime asctime clock ctime difftime gmtime \
29 localtime mktime strftime time __tzset tzfile \
30 __gettod settod adjtime getitmr \
31 __getitmr __adjtime __settod \
32 __setitmr tzset gettod setitmr \
33 stime dysize timegm timelocal ftime
36 others := ap zdump zic
37 tests := test_time clocktest
39 tzfiles := africa antarctica asia australasia europe northamerica \
40 southamerica etcetera factory systemv backward
41 # pacificnew doesn't compile; if it is to be used, it should be included in
43 distribute := $(distribute) $(tzfiles) leapseconds pacificnew
45 install-sbin := zic zdump
47 include ../Makeconfig # Get objpfx defined so we can use it below.
49 # zonenames uses this variable.
54 include $(objpfx)zonenames
56 # Make these absolute file names.
57 installed-localtime-file := $(firstword $(filter /%,$(localtime-file)) \
58 $(addprefix $(zonedir)/, \
60 installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \
61 $(addprefix $(zonedir)/, \
64 ifndef cross-compiling
65 # Don't try to install the zoneinfo files since we can't run zic.
66 install-others = $(addprefix $(zonedir)/,$(zonenames)) \
67 $(installed-localtime-file) $(installed-posixrules-file)
73 $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
74 # Kludge alert: we use an implicit rule (in what we are generating here)
75 # because that is the only way to tell Make that the one command builds all
77 (echo 'define $*-zones' ;\
78 awk '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^;\
80 echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))' ;\
81 echo 'ifdef $*-zones' ;\
82 echo '$$(addprefix $$(datadir)/zone%/,$$($*-zones)): \' ;\
83 echo '$< $$(objpfx)zic leapseconds yearistype' ;\
84 echo ' $$(tzcompile)' ;\
86 echo 'zonenames := $$(zonenames) $$($*-zones)' ;\
89 $(objpfx)zonenames: Makefile
90 (for file in $(tzfiles); do \
91 echo "include \$$(objpfx)z.$$file"; \
95 .PHONY: echo-zonenames
96 echo-zonenames: zonenames
97 @echo 'Known zones: $(zonenames)'
100 # Although $(zonedir) gets compiled into zic, it is useful to always
101 # specify it with -d on the command line so that it can be overridden on
102 # the command line of `make install' (e.g., "make install prefix=/foo").
103 zic-cmd = $(dir $(word 2,$^))$(notdir $(word 2,$^)) -d $(zonedir)
105 $(zic-cmd) -L $(word 3,$^) -y $(dir $(word 4,$^))$(notdir $(word 4,$^)) $<
109 $(installed-localtime-file): $(zonedir)/$(localtime) $(objpfx)zic
110 $(zic-cmd) -l $(localtime)
113 $(installed-posixrules-file): $(zonedir)/$(posixrules) $(objpfx)zic
114 $(zic-cmd) -p $(posixrules)
118 $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o $(objpfx)emkdir.o
120 $(objpfx)tzfile.o: tzfile.c; $(tz-cc)
121 $(objpfx)zic.o: zic.c; $(tz-cc)
123 # Some versions of GNU make have a bug with backslashes in define directives.
124 tz-cc = $(COMPILE.c) $(+gcc-nowarn) \
125 -DTZDIR='"$(zonedir)"' \
126 -DTZDEFAULT='"$(localtime-file)"' \
127 -DTZDEFRULES='"$(posixrules-file)"' \