fix nl_langinfo with static linking (BZ #16915)
[platform/upstream/glibc.git] / localedata / Makefile
1 # Copyright (C) 1996-2014 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 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.
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 # Lesser General Public License for more details.
13
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/>.
17
18 # Makefile for installing locale data source files.
19
20 subdir := localedata
21
22 include ../Makeconfig
23
24 # List with all available character set descriptions.
25 charmaps := $(wildcard charmaps/[A-I]*) $(wildcard charmaps/[J-Z]*)
26
27 # List with all available character set descriptions.
28 locales := $(wildcard locales/*)
29
30
31 subdir-dirs = tests-mbwc
32 vpath %.c tests-mbwc
33 vpath %.h tests-mbwc
34
35
36 test-srcs := collate-test xfrm-test tst-fmon tst-rpmatch tst-trans \
37              tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \
38              tst-ctype tst-wctype tst-langinfo tst-langinfo-static tst-numeric
39 test-input := de_DE.ISO-8859-1 en_US.ISO-8859-1 da_DK.ISO-8859-1 \
40               hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 tr_TR.UTF-8 fr_FR.UTF-8 \
41               si_LK.UTF-8
42 test-input-data = $(addsuffix .in, $(basename $(test-input)))
43 test-output := $(foreach s, .out .xout, \
44                          $(addsuffix $s, $(basename $(test-input))))
45 ld-test-names := test1 test2 test3 test4 test5 test6 test7
46 ld-test-srcs := $(addprefix tests/,$(addsuffix .cm,$(ld-test-names)) \
47                                    $(addsuffix .def,$(ld-test-names)) \
48                                    $(addsuffix .ds,test5 test6) \
49                                    test6.c trans.def)
50
51 fmon-tests = n01y12 n02n40 n10y31 n11y41 n12y11 n20n32 n30y20 n41n00 \
52              y01y10 y02n22 y22n42 y30y21 y32n31 y40y00 y42n21
53
54 generated += $(test-input) $(test-output) sort-test.out tst-locale.out \
55              tst-mbswcs.out tst-leaks.mtrace mtrace-tst-leaks.out
56 generated-dirs += $(ld-test-names) tt_TT de_DE.437                      \
57                   $(addprefix tstfmon_,$(fmon-tests))                   \
58
59 ifeq ($(run-built-tests),yes)
60 locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl            \
61                      tst_iswctype tst_iswdigit tst_iswgraph            \
62                      tst_iswlower tst_iswprint tst_iswpunct            \
63                      tst_iswspace tst_iswupper tst_iswxdigit tst_mblen \
64                      tst_mbrlen tst_mbrtowc tst_mbsrtowcs tst_mbstowcs \
65                      tst_mbtowc tst_strcoll tst_strfmon tst_strxfrm    \
66                      tst_swscanf tst_towctrans tst_towlower            \
67                      tst_towupper tst_wcrtomb tst_wcscat tst_wcschr    \
68                      tst_wcscmp tst_wcscoll tst_wcscpy tst_wcscspn     \
69                      tst_wcslen tst_wcsncat tst_wcsncmp tst_wcsncpy    \
70                      tst_wcspbrk tst_wcsrtombs tst_wcsspn tst_wcsstr   \
71                      tst_wcstod tst_wcstok tst_wcstombs tst_wcswidth   \
72                      tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans      \
73                      tst_wctype tst_wcwidth
74
75 tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \
76         tst-leaks tst-mbswcs6 tst-xlocale1 tst-xlocale2 bug-usesetlocale \
77         tst-strfmon1 tst-sscanf bug-setlocale1 tst-setlocale2
78 tests-static = bug-setlocale1-static
79 tests += $(tests-static)
80 ifeq (yes,$(build-shared))
81 ifneq (no,$(PERL))
82 tests-special += $(objpfx)mtrace-tst-leaks.out
83 endif
84 endif
85 endif
86
87 # Files to install.
88 install-others := $(addprefix $(inst_i18ndir)/, \
89                               $(addsuffix .gz, $(charmaps)) \
90                               $(locales))
91
92 tests: $(objdir)/iconvdata/gconv-modules
93
94 tests-special += $(objpfx)sort-test.out $(objpfx)tst-fmon.out \
95                  $(objpfx)tst-locale.out $(objpfx)tst-rpmatch.out \
96                  $(objpfx)tst-trans.out $(objpfx)tst-mbswcs.out \
97                  $(objpfx)tst-ctype.out $(objpfx)tst-wctype.out \
98                  $(objpfx)tst-langinfo.out $(objpfx)tst-langinfo-static.out \
99                  $(objpfx)tst-numeric.out
100 tests-static += tst-langinfo-static
101
102 ifeq ($(run-built-tests),yes)
103 # We have to generate locales
104 LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 \
105            en_US.ISO-8859-1 en_US.UTF-8 ja_JP.EUC-JP da_DK.ISO-8859-1 \
106            hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 ja_JP.SJIS fr_FR.ISO-8859-1 \
107            nb_NO.ISO-8859-1 nn_NO.ISO-8859-1 tr_TR.UTF-8 cs_CZ.UTF-8 \
108            zh_TW.EUC-TW fa_IR.UTF-8 fr_FR.UTF-8 ja_JP.UTF-8 si_LK.UTF-8 \
109            tr_TR.ISO-8859-9
110 LOCALE_SRCS := $(shell echo "$(LOCALES)"|sed 's/\([^ .]*\)[^ ]*/\1/g')
111 CHARMAPS := $(shell echo "$(LOCALES)" | \
112                     sed -e 's/[^ .]*[.]\([^ ]*\)/\1/g' -e s/SJIS/SHIFT_JIS/g)
113 CTYPE_FILES = $(addsuffix /LC_CTYPE,$(LOCALES))
114 tests-special += $(addprefix $(objpfx),$(CTYPE_FILES))
115 endif
116
117 include ../Rules
118
119 # Install the charmap files in gzipped format.
120 $(inst_i18ndir)/charmaps/%.gz: charmaps/% $(+force)
121         $(make-target-directory)
122         rm -f $(@:.gz=) $@
123         $(INSTALL_DATA) $< $(@:.gz=)
124         gzip -9n $(@:.gz=)
125
126 # Install the locale source files in the appropriate directory.
127 $(inst_i18ndir)/locales/%: locales/% $(+force); $(do-install)
128
129 # gcc does not know all the format specifiers we are using here.
130 CFLAGS-tst-mbswcs1.c = -Wno-format
131 CFLAGS-tst-mbswcs2.c = -Wno-format
132 CFLAGS-tst-mbswcs3.c = -Wno-format
133 CFLAGS-tst-mbswcs4.c = -Wno-format
134 CFLAGS-tst-mbswcs5.c = -Wno-format
135 CFLAGS-tst-trans.c = -Wno-format
136
137
138 ifeq ($(run-built-tests),yes)
139 generated-dirs += $(LOCALES)
140
141 # Dependency for the locale files.  We actually make it depend only on
142 # one of the files.
143 $(addprefix $(objpfx),$(CTYPE_FILES)): %: \
144   gen-locale.sh $(common-objpfx)locale/localedef Makefile \
145   $(addprefix charmaps/,$(CHARMAPS)) $(addprefix locales/,$(LOCALE_SRCS))
146         @$(SHELL) gen-locale.sh $(common-objpfx) '$(built-program-cmd)' $@; \
147         $(evaluate-test)
148
149 $(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
150   $(addprefix $(objpfx),$(CTYPE_FILES))
151
152 $(objpfx)sort-test.out: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \
153                        $(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES))
154         $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' $(test-input) \
155           > $@; \
156         $(evaluate-test)
157 $(objpfx)tst-fmon.out: tst-fmon.sh $(objpfx)tst-fmon tst-fmon.data \
158                        $(objpfx)sort-test.out \
159                        $(addprefix $(objpfx),$(CTYPE_FILES))
160         $(SHELL) $< $(common-objpfx) '$(run-program-prefix)' \
161                 '$(test-program-prefix)' tst-fmon.data  \
162           > $@; \
163         $(evaluate-test)
164 $(objpfx)tst-numeric.out: tst-numeric.sh $(objpfx)tst-numeric tst-numeric.data \
165                        $(objpfx)sort-test.out \
166                        $(addprefix $(objpfx),$(CTYPE_FILES))
167         $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' tst-numeric.data \
168           > $@; \
169         $(evaluate-test)
170 $(objpfx)tst-locale.out: tst-locale.sh $(common-objpfx)locale/localedef \
171                          $(ld-test-srcs) $(addprefix $(objpfx),$(CTYPE_FILES))
172         $(SHELL) $< $(common-objpfx) '$(built-program-cmd)' > $@; \
173         $(evaluate-test)
174 $(objpfx)tst-rpmatch.out: tst-rpmatch.sh $(objpfx)tst-rpmatch \
175                           $(objpfx)tst-fmon.out \
176                           $(addprefix $(objpfx),$(CTYPE_FILES))
177         $(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
178         $(evaluate-test)
179 $(objpfx)tst-trans.out: tst-trans.sh $(objpfx)tst-trans \
180                         $(addprefix $(objpfx),$(CTYPE_FILES))
181         $(SHELL) $< $(common-objpfx) '$(run-program-prefix)' '$(test-program-prefix)'; \
182         $(evaluate-test)
183 $(objpfx)tst-mbswcs.out: tst-mbswcs.sh $(objpfx)tst-mbswcs1 \
184                          $(objpfx)tst-mbswcs2 $(objpfx)tst-mbswcs3 \
185                          $(objpfx)tst-mbswcs4 $(objpfx)tst-mbswcs5 \
186                          $(addprefix $(objpfx),$(CTYPE_FILES))
187         $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
188         $(evaluate-test)
189 $(objpfx)tst-ctype.out: tst-ctype.sh $(objpfx)tst-ctype \
190                         $(objpfx)sort-test.out \
191                         $(addprefix $(objpfx),$(CTYPE_FILES))
192         $(SHELL) $< $(common-objpfx) '$(test-program-cmd)'; \
193         $(evaluate-test)
194 $(objpfx)tst-wctype.out: tst-wctype.sh $(objpfx)tst-wctype \
195                         $(objpfx)sort-test.out tst-wctype.input \
196                         $(addprefix $(objpfx),$(CTYPE_FILES))
197         $(SHELL) $< $(common-objpfx) '$(test-program-cmd)'; \
198         $(evaluate-test)
199 $(objpfx)tst-langinfo.out: tst-langinfo.sh $(objpfx)tst-langinfo \
200                         $(objpfx)sort-test.out \
201                         $(addprefix $(objpfx),$(CTYPE_FILES))
202         $(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
203         $(evaluate-test)
204 $(objpfx)tst-langinfo-static.out: tst-langinfo.sh $(objpfx)tst-langinfo-static \
205                         $(objpfx)sort-test.out \
206                         $(addprefix $(objpfx),$(CTYPE_FILES))
207         $(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
208         $(evaluate-test)
209 $(objpfx)tst-digits.out: $(objpfx)tst-locale.out
210 $(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES))
211 endif
212
213 include SUPPORTED
214
215 INSTALL-SUPPORTED-LOCALES=$(addprefix install-, $(SUPPORTED-LOCALES))
216
217 # Sometimes the whole collection of locale files should be installed.
218 LOCALEDEF=I18NPATH=. GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
219 $(common-objpfx)elf/ld.so --library-path $(rpath-link) $(common-objpfx)locale/localedef
220 install-locales: $(INSTALL-SUPPORTED-LOCALES)
221
222 install-locales-dir:
223         $(..)./scripts/mkinstalldirs $(inst_localedir)
224
225 $(INSTALL-SUPPORTED-LOCALES): install-locales-dir
226         @locale=`echo $@ | sed -e 's/^install-//'`; \
227         charset=`echo $$locale | sed -e 's,.*/,,'`; \
228         locale=`echo $$locale | sed -e 's,/[^/]*,,'`; \
229         echo -n `echo $$locale | sed 's/\([^.\@]*\).*/\1/'`; \
230         echo -n ".$$charset"; \
231         echo -n `echo $$locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \
232         echo -n '...'; \
233         input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
234         $(LOCALEDEF) --alias-file=../intl/locale.alias \
235                      -i locales/$$input -c -f charmaps/$$charset \
236                      $(addprefix --prefix=,$(install_root)) $$locale; \
237         echo ' done'; \
238
239 # The mbwc-tests need some environment setup to find the locale data files
240 TEST_MBWC_ENV:= LOCPATH=$(common-objpfx)localedata
241 tst_iswalnum-ENV = $(TEST_MBWC_ENV)
242 tst_iswalpha-ENV = $(TEST_MBWC_ENV)
243 tst_iswcntrl-ENV = $(TEST_MBWC_ENV)
244 tst_iswctype-ENV = $(TEST_MBWC_ENV)
245 tst_iswdigit-ENV = $(TEST_MBWC_ENV)
246 tst_iswgraph-ENV = $(TEST_MBWC_ENV)
247 tst_iswlower-ENV = $(TEST_MBWC_ENV)
248 tst_iswprint-ENV = $(TEST_MBWC_ENV)
249 tst_iswpunct-ENV = $(TEST_MBWC_ENV)
250 tst_iswspace-ENV = $(TEST_MBWC_ENV)
251 tst_iswupper-ENV = $(TEST_MBWC_ENV)
252 tst_iswxdigit-ENV = $(TEST_MBWC_ENV)
253 tst_mblen-ENV = $(TEST_MBWC_ENV)
254 tst_mbrlen-ENV = $(TEST_MBWC_ENV)
255 tst_mbrtowc-ENV = $(TEST_MBWC_ENV)
256 tst_mbsrtowcs-ENV = $(TEST_MBWC_ENV)
257 tst_mbstowcs-ENV = $(TEST_MBWC_ENV)
258 tst_mbtowc-ENV = $(TEST_MBWC_ENV)
259 tst_strcoll-ENV = $(TEST_MBWC_ENV)
260 tst_strfmon-ENV = $(TEST_MBWC_ENV)
261 tst_strxfrm-ENV = $(TEST_MBWC_ENV)
262 tst_swscanf-ENV = $(TEST_MBWC_ENV)
263 tst_towctrans-ENV = $(TEST_MBWC_ENV)
264 tst_towlower-ENV = $(TEST_MBWC_ENV)
265 tst_towupper-ENV = $(TEST_MBWC_ENV)
266 tst_wcrtomb-ENV = $(TEST_MBWC_ENV)
267 tst_wcscat-ENV = $(TEST_MBWC_ENV)
268 tst_wcschr-ENV = $(TEST_MBWC_ENV)
269 tst_wcscmp-ENV = $(TEST_MBWC_ENV)
270 tst_wcscoll-ENV = $(TEST_MBWC_ENV)
271 tst_wcscpy-ENV = $(TEST_MBWC_ENV)
272 tst_wcscspn-ENV = $(TEST_MBWC_ENV)
273 tst_wcslen-ENV = $(TEST_MBWC_ENV)
274 tst_wcsncat-ENV = $(TEST_MBWC_ENV)
275 tst_wcsncmp-ENV = $(TEST_MBWC_ENV)
276 tst_wcsncpy-ENV = $(TEST_MBWC_ENV)
277 tst_wcspbrk-ENV = $(TEST_MBWC_ENV)
278 tst_wcsrtombs-ENV = $(TEST_MBWC_ENV)
279 tst_wcsspn-ENV = $(TEST_MBWC_ENV)
280 tst_wcsstr-ENV = $(TEST_MBWC_ENV)
281 tst_wcstod-ENV = $(TEST_MBWC_ENV)
282 tst_wcstok-ENV = $(TEST_MBWC_ENV)
283 tst_wcstombs-ENV = $(TEST_MBWC_ENV)
284 tst_wcswidth-ENV = $(TEST_MBWC_ENV)
285 tst_wcsxfrm-ENV = $(TEST_MBWC_ENV)
286 tst_wctob-ENV = $(TEST_MBWC_ENV)
287 tst_wctomb-ENV = $(TEST_MBWC_ENV)
288 tst_wctrans-ENV = $(TEST_MBWC_ENV)
289 tst_wctype-ENV = $(TEST_MBWC_ENV)
290 tst_wcwidth-ENV = $(TEST_MBWC_ENV)
291 tst-digits-ENV = $(TEST_MBWC_ENV)
292 tst-mbswcs6-ENV = $(TEST_MBWC_ENV)
293 tst-xlocale1-ENV = $(TEST_MBWC_ENV)
294 tst-xlocale2-ENV = $(TEST_MBWC_ENV)
295 tst-strfmon1-ENV = $(TEST_MBWC_ENV)
296 tst-strptime-ENV = $(TEST_MBWC_ENV)
297
298 tst-setlocale-ENV = LOCPATH=$(common-objpfx)localedata LC_ALL=ja_JP.EUC-JP
299
300 bug-iconv-trans-ENV = LOCPATH=$(common-objpfx)localedata
301
302 tst-sscanf-ENV = LOCPATH=$(common-objpfx)localedata
303
304 tst-leaks-ENV = MALLOC_TRACE=$(objpfx)tst-leaks.mtrace \
305                 LOCPATH=$(common-objpfx)localedata
306 $(objpfx)mtrace-tst-leaks.out: $(objpfx)tst-leaks.out
307         $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks.mtrace > $@; \
308         $(evaluate-test)
309
310 bug-setlocale1-ENV = LOCPATH=$(common-objpfx)localedata
311 bug-setlocale1-ARGS = -- $(host-test-program-cmd)
312 bug-setlocale1-static-ENV = $(bug-setlocale1-ENV)
313 bug-setlocale1-static-ARGS = $(bug-setlocale1-ARGS)
314 tst-setlocale2-ENV = LOCPATH=$(common-objpfx)localedata
315
316 $(objdir)/iconvdata/gconv-modules:
317         $(MAKE) -C ../iconvdata subdir=iconvdata $@