Make time zone file parser more robust [BZ #17715]
[glibc.git] / timezone / Makefile
blob5f185458bce92e2be970f2199676d7429c5c8cc6
1 # Copyright (C) 1998-2015 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 Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the 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 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <http://www.gnu.org/licenses/>.
19 # Makefile for timezone information
21 subdir := timezone
23 include ../Makeconfig
25 extra-objs := scheck.o ialloc.o
27 others := zdump zic
28 tests := test-tz tst-timezone tst-tzset
30 # pacificnew doesn't compile; if it is to be used, it should be included in
31 # northamerica.
32 tzbases := africa antarctica asia australasia europe northamerica \
33 southamerica etcetera factory \
34 solar87 solar88 solar89
35 tzlinks := backward systemv
36 tzfiles := $(tzbases) $(tzlinks)
38 generated += $(addprefix z.,$(tzfiles))
39 install-sbin := zic zdump
41 generated-dirs += testdata
43 install-bin-script = tzselect
44 generated += tzselect
46 testdata = $(objpfx)testdata
48 ifeq ($(run-built-tests),yes)
49 # List zones generated by separate commands running zic on the host.
50 # Each such zic run counts as a separate test.
51 test-zones := America/New_York Etc/UTC UTC Europe/Berlin \
52 Australia/Melbourne America/Sao_Paulo Asia/Tokyo
53 tests-special += $(addprefix $(testdata)/, $(test-zones))
54 endif
56 include ../Rules
59 $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o
61 $(objpfx)zic.o $(objpfx)zdump.o: $(objpfx)version.h
63 $(objpfx)version.h: $(common-objpfx)config.make
64 echo 'static char const TZVERSION[]="$(version)";' \
65 > $@.new
66 mv -f $@.new $@
68 tz-cflags = -DTZDIR='"$(zonedir)"' \
69 -DTZDEFAULT='"$(localtime-file)"' \
70 -DTZDEFRULES='"$(posixrules-file)"' \
71 -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone
73 CFLAGS-zdump.c = -fwrapv -Wno-strict-prototypes -DNOID $(tz-cflags) \
74 -DHAVE_GETTEXT
75 CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags) -DHAVE_GETTEXT
76 CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID -DHAVE_GETTEXT
77 CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID -DHAVE_GETTEXT
79 # We have to make sure the data for testing the tz functions is available.
80 # Don't add leapseconds here since test-tz made checks that work only without
81 # leapseconds.
82 define build-testdata
83 $(built-program-cmd) -d $(testdata) -y ./yearistype $<; \
84 $(evaluate-test)
85 endef
87 $(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC)
88 $(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
89 Europe/Berlin Universal \
90 Australia/Melbourne \
91 America/Sao_Paulo Asia/Tokyo \
92 Europe/London)
93 $(objpfx)tst-tzset.out: $(addprefix $(testdata)/XT, 1 2 3 4)
95 test-tz-ENV = TZDIR=$(testdata)
96 tst-timezone-ENV = TZDIR=$(testdata)
97 tst-tzset-ENV = TZDIR=$(testdata)
99 # Note this must come second in the deps list for $(built-program-cmd) to work.
100 zic-deps = $(objpfx)zic $(leapseconds) yearistype
102 $(testdata)/America/New_York: northamerica $(zic-deps)
103 $(build-testdata)
104 $(testdata)/Etc/UTC: etcetera $(zic-deps)
105 $(build-testdata)
106 # Use a pattern rule to indicate the command produces both targets at once.
107 # Two separate targets built separately can collide if in parallel.
108 %/UTC %/Universal: simplebackw $(zic-deps) %/Etc/UTC
109 $(build-testdata)
110 $(testdata)/%/Berlin $(testdata)/%/London: europe $(zic-deps)
111 $(build-testdata)
112 $(testdata)/Australia/Melbourne: australasia $(zic-deps)
113 $(build-testdata)
114 $(testdata)/America/Sao_Paulo: southamerica $(zic-deps)
115 $(build-testdata)
116 $(testdata)/Asia/Tokyo: asia $(zic-deps)
117 $(build-testdata)
119 $(testdata)/XT%: testdata/XT%
120 cp $< $@
122 $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
123 sed -e 's|/bin/bash|$(BASH)|' \
124 -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
125 -e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
126 -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
127 -e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
128 < $< > $@.new
129 chmod 555 $@.new
130 mv -f $@.new $@