Regenerate configure.
[platform/upstream/glibc.git] / localedata / Makefile
1 # Copyright (C) 1996-2023 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 # <https://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-ctype tst-langinfo-newlocale tst-langinfo-setlocale \
38              tst-langinfo-newlocale-static tst-langinfo-setlocale-static \
39              tst-numeric
40 # List of test input files (list sorted alphabetically):
41 test-input := \
42         am_ET.UTF-8 \
43         az_AZ.UTF-8 \
44         be_BY.UTF-8 \
45         ber_DZ.UTF-8 \
46         ber_MA.UTF-8 \
47         bg_BG.UTF-8 \
48         br_FR.UTF-8 \
49         bs_BA.UTF-8 \
50         C.UTF-8 \
51         ckb_IQ.UTF-8 \
52         cmn_TW.UTF-8 \
53         crh_UA.UTF-8 \
54         cs_CZ.UTF-8 \
55         csb_PL.UTF-8 \
56         cv_RU.UTF-8 \
57         cy_GB.UTF-8 \
58         da_DK.ISO-8859-1 \
59         de_DE.ISO-8859-1 \
60         dsb_DE.UTF-8 \
61         dz_BT.UTF-8 \
62         en_US.ISO-8859-1 \
63         en_US.UTF-8 \
64         eo.UTF-8 \
65         es_ES.UTF-8 \
66         et_EE.UTF-8 \
67         fa_IR.UTF-8 \
68         fi_FI.UTF-8 \
69         fil_PH.UTF-8 \
70         fr_CA.UTF-8 \
71         fr_FR.UTF-8 \
72         fur_IT.UTF-8 \
73         gez_ER.UTF-8@abegede \
74         ha_NG.UTF-8 \
75         hr_HR.ISO-8859-2 \
76         hr_HR.UTF-8 \
77         hsb_DE.UTF-8 \
78         hu_HU.UTF-8 \
79         ig_NG.UTF-8 \
80         ik_CA.UTF-8 \
81         is_IS.UTF-8 \
82         kk_KZ.UTF-8 \
83         ku_TR.UTF-8 \
84         ky_KG.UTF-8 \
85         ln_CD.UTF-8 \
86         lt_LT.UTF-8 \
87         lv_LV.UTF-8 \
88         mi_NZ.UTF-8 \
89         ml_IN.UTF-8 \
90         mn_MN.UTF-8 \
91         mr_IN.UTF-8 \
92         mt_MT.UTF-8 \
93         nan_TW.UTF-8@latin \
94         nb_NO.UTF-8 \
95         om_KE.UTF-8 \
96         or_IN.UTF-8 \
97         os_RU.UTF-8 \
98         pl_PL.UTF-8 \
99         ps_AF.UTF-8 \
100         rif_MA.UTF-8 \
101         ro_RO.UTF-8 \
102         ru_RU.UTF-8 \
103         sah_RU.UTF-8 \
104         sc_IT.UTF-8 \
105         se_NO.UTF-8 \
106         si_LK.UTF-8 \
107         sq_AL.UTF-8 \
108         sr_RS.UTF-8 \
109         sv_SE.ISO-8859-1 \
110         sv_SE.UTF-8 \
111         syr.UTF-8 \
112         szl_PL.UTF-8 \
113         tg_TJ.UTF-8 \
114         tk_TM.UTF-8 \
115         tr_TR.UTF-8 \
116         tt_RU.UTF-8 \
117         tt_RU.UTF-8@iqtelif \
118         ug_CN.UTF-8 \
119         uk_UA.UTF-8 \
120         uz_UZ.UTF-8 \
121         vi_VN.UTF-8 \
122         yi_US.UTF-8 \
123         yo_NG.UTF-8 \
124         zh_CN.UTF-8 \
125         $(NULL)
126
127 test-input-data = $(addsuffix .in, $(test-input))
128 test-output := $(foreach s, .out .xout, \
129                          $(addsuffix $s, $(basename $(test-input))))
130 ld-test-names := test1 test2 test3 test4 test5 test6 test7
131 ld-test-srcs := $(addprefix tests/,$(addsuffix .cm,$(ld-test-names)) \
132                                    $(addsuffix .def,$(ld-test-names)) \
133                                    $(addsuffix .ds,test5 test6) \
134                                    test6.c trans.def)
135
136 fmon-tests = n01y12 n02n40 n10y31 n11y41 n12y11 n20n32 n30y20 n41n00 \
137              y01y10 y02n22 y22n42 y30y21 y32n31 y40y00 y42n21
138
139 generated += $(test-input) $(test-output) sort-test.out tst-locale.out \
140              tst-leaks.mtrace mtrace-tst-leaks.out
141 generated-dirs += $(ld-test-names) tt_TT de_DE.437                      \
142                   $(addprefix tstfmon_,$(fmon-tests))                   \
143
144 ifeq ($(run-built-tests),yes)
145 locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl            \
146                      tst_iswctype tst_iswdigit tst_iswgraph            \
147                      tst_iswlower tst_iswprint tst_iswpunct            \
148                      tst_iswspace tst_iswupper tst_iswxdigit tst_mblen \
149                      tst_mbrlen tst_mbrtowc tst_mbsrtowcs tst_mbstowcs \
150                      tst_mbtowc tst_strcoll tst_strfmon tst_strxfrm    \
151                      tst_swscanf tst_towctrans tst_towlower            \
152                      tst_towupper tst_wcrtomb tst_wcscat tst_wcschr    \
153                      tst_wcscmp tst_wcscoll tst_wcscpy tst_wcscspn     \
154                      tst_wcslen tst_wcsncat tst_wcsncmp tst_wcsncpy    \
155                      tst_wcspbrk tst_wcsrtombs tst_wcsspn tst_wcsstr   \
156                      tst_wcstod tst_wcstok tst_wcstombs tst_wcswidth   \
157                      tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans      \
158                      tst_wctype tst_wcwidth
159
160 tests = \
161   $(locale_test_suite) \
162   bug-iconv-trans \
163   bug-setlocale1 \
164   bug-usesetlocale \
165   tst-c-utf8-consistency \
166   tst-digits \
167   tst-iconv-math-trans \
168   tst-leaks \
169   tst-mbswcs1 \
170   tst-mbswcs2 \
171   tst-mbswcs3 \
172   tst-mbswcs4 \
173   tst-mbswcs5 \
174   tst-mbswcs6 \
175   tst-setlocale \
176   tst-setlocale2 \
177   tst-setlocale3 \
178   tst-sscanf \
179   tst-strfmon1 \
180   tst-wctype \
181   tst-xlocale1 \
182   tst-xlocale2 \
183   # tests
184
185 tests-static = bug-setlocale1-static
186 tests += $(tests-static)
187 ifeq (yes,$(build-shared))
188 ifneq (no,$(PERL))
189 tests-special += $(objpfx)mtrace-tst-leaks.out
190 endif
191 endif
192 endif
193 tests-container = \
194                         tst-localedef-hardlinks
195
196 # Files to install.
197 ifeq ($(INSTALL_UNCOMPRESSED),yes)
198 # This option is for testing inside the testroot container, as the
199 # container does not include a working gunzip program.
200 install-others := $(addprefix $(inst_i18ndir)/, \
201                               $(charmaps) \
202                               $(locales))
203 else
204 install-others := $(addprefix $(inst_i18ndir)/, \
205                               $(addsuffix .gz, $(charmaps)) \
206                               $(locales))
207 endif
208
209 tests: $(objdir)/iconvdata/gconv-modules
210
211 tests-static += tst-langinfo-newlocale-static tst-langinfo-setlocale-static
212
213 ifeq ($(run-built-tests),yes)
214 tests-special += $(objpfx)sort-test.out $(objpfx)tst-fmon.out \
215                  $(objpfx)tst-locale.out $(objpfx)tst-rpmatch.out \
216                  $(objpfx)tst-trans.out $(objpfx)tst-ctype.out \
217                  $(objpfx)tst-langinfo-newlocale.out \
218                  $(objpfx)tst-langinfo-setlocale.out \
219                  $(objpfx)tst-langinfo-newlocale-static.out \
220                  $(objpfx)tst-langinfo-setlocale-static.out \
221                  $(objpfx)tst-numeric.out
222 # We have to generate locales (list sorted alphabetically)
223 LOCALES := \
224         am_ET.UTF-8 \
225         az_AZ.UTF-8 \
226         be_BY.UTF-8 \
227         ber_DZ.UTF-8 \
228         ber_MA.UTF-8 \
229         bg_BG.UTF-8 \
230         br_FR.UTF-8 \
231         bs_BA.UTF-8 \
232         C.UTF-8 \
233         ckb_IQ.UTF-8 \
234         cmn_TW.UTF-8 \
235         crh_UA.UTF-8 \
236         cs_CZ.UTF-8 \
237         csb_PL.UTF-8 \
238         cv_RU.UTF-8 \
239         cy_GB.UTF-8 \
240         da_DK.ISO-8859-1 \
241         de_DE.ISO-8859-1 \
242         de_DE.UTF-8 \
243         dsb_DE.UTF-8 \
244         dz_BT.UTF-8 \
245         en_GB.UTF-8 \
246         en_US.ANSI_X3.4-1968 \
247         en_US.ISO-8859-1\
248         en_US.UTF-8 \
249         eo.UTF-8 \
250         es_ES.UTF-8 \
251         et_EE.UTF-8 \
252         fa_IR.UTF-8 \
253         fi_FI.UTF-8 \
254         fil_PH.UTF-8 \
255         fr_CA.UTF-8 \
256         fr_FR.ISO-8859-1 \
257         fr_FR.UTF-8 \
258         fur_IT.UTF-8 \
259         gez_ER.UTF-8@abegede \
260         ha_NG.UTF-8 \
261         hr_HR.ISO-8859-2 \
262         hr_HR.UTF-8 \
263         hsb_DE.UTF-8 \
264         hu_HU.UTF-8 \
265         ig_NG.UTF-8 \
266         ik_CA.UTF-8 \
267         is_IS.UTF-8 \
268         ja_JP.EUC-JP \
269         ja_JP.SJIS \
270         ja_JP.UTF-8 \
271         kk_KZ.UTF-8 \
272         ku_TR.UTF-8 \
273         ky_KG.UTF-8 \
274         ln_CD.UTF-8 \
275         lt_LT.UTF-8 \
276         lv_LV.UTF-8 \
277         mi_NZ.UTF-8 \
278         ml_IN.UTF-8 \
279         mn_MN.UTF-8 \
280         mr_IN.UTF-8 \
281         mt_MT.UTF-8 \
282         nan_TW.UTF-8@latin \
283         nb_NO.ISO-8859-1 \
284         nb_NO.UTF-8 \
285         nl_NL.UTF-8 \
286         nn_NO.ISO-8859-1 \
287         om_KE.UTF-8 \
288         or_IN.UTF-8 \
289         os_RU.UTF-8 \
290         pl_PL.UTF-8 \
291         ps_AF.UTF-8 \
292         rif_MA.UTF-8 \
293         ro_RO.UTF-8 \
294         ru_RU.UTF-8 \
295         sah_RU.UTF-8 \
296         sc_IT.UTF-8 \
297         se_NO.UTF-8 \
298         si_LK.UTF-8 \
299         sq_AL.UTF-8 \
300         sr_RS.UTF-8 \
301         sv_SE.ISO-8859-1 \
302         sv_SE.UTF-8 \
303         syr.UTF-8 \
304         szl_PL.UTF-8 \
305         tg_TJ.UTF-8 \
306         tk_TM.UTF-8 \
307         tr_TR.ISO-8859-9 \
308         tr_TR.UTF-8 \
309         tt_RU.UTF-8 \
310         tt_RU.UTF-8@iqtelif \
311         ug_CN.UTF-8 \
312         uk_UA.UTF-8 \
313         uz_UZ.UTF-8 \
314         vi_VN.UTF-8 \
315         yi_US.UTF-8 \
316         yo_NG.UTF-8 \
317         zh_CN.UTF-8 \
318         zh_TW.EUC-TW \
319         $(NULL)
320
321 include ../gen-locales.mk
322
323 $(objpfx)tst-iconv-math-trans.out: $(gen-locales)
324 endif
325
326 include ../Rules
327
328 ifeq ($(INSTALL_UNCOMPRESSED),yes)
329 # Install the charmap files as-is.  This option is for testing inside
330 # the testroot container, as the container does not include a working
331 # gunzip program.
332 $(inst_i18ndir)/charmaps/%: charmaps/% $(+force)
333         $(make-target-directory)
334         rm -f $@
335         $(INSTALL_DATA) $< $@
336 else
337 # Install the charmap files in gzipped format.
338 $(inst_i18ndir)/charmaps/%.gz: charmaps/% $(+force)
339         $(make-target-directory)
340         rm -f $(@:.gz=) $@
341         $(INSTALL_DATA) $< $(@:.gz=)
342         gzip -9n $(@:.gz=)
343 endif
344
345 # Install the locale source files in the appropriate directory.
346 $(inst_i18ndir)/locales/%: locales/% $(+force); $(do-install)
347
348 ifeq ($(run-built-tests),yes)
349 generated-dirs += $(LOCALES)
350
351 $(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
352   $(addprefix $(objpfx),$(CTYPE_FILES))
353
354 $(objpfx)sort-test.out: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \
355                        $(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES))
356         $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
357           '$(run-program-env)' '$(test-program-prefix-after-env)' \
358           $(test-input) \
359           > $@; \
360         $(evaluate-test)
361 $(objpfx)tst-fmon.out: tst-fmon.sh $(objpfx)tst-fmon tst-fmon.data \
362                        $(objpfx)sort-test.out \
363                        $(addprefix $(objpfx),$(CTYPE_FILES))
364         $(SHELL) $< $(common-objpfx) '$(run-program-prefix-before-env)' \
365                  '$(run-program-env)' '$(run-program-prefix-after-env)' \
366                  '$(test-program-prefix)' tst-fmon.data \
367           > $@; \
368         $(evaluate-test)
369 $(objpfx)tst-numeric.out: tst-numeric.sh $(objpfx)tst-numeric tst-numeric.data \
370                        $(objpfx)sort-test.out \
371                        $(addprefix $(objpfx),$(CTYPE_FILES))
372         $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' tst-numeric.data \
373           > $@; \
374         $(evaluate-test)
375 $(objpfx)tst-locale.out: tst-locale.sh $(common-objpfx)locale/localedef \
376                          $(ld-test-srcs) $(addprefix $(objpfx),$(CTYPE_FILES))
377         $(SHELL) $< $(common-objpfx) '$(built-program-cmd-before-env)' \
378                  '$(run-program-env)' '$(built-program-cmd-after-env)' > $@; \
379         $(evaluate-test)
380 $(objpfx)tst-rpmatch.out: tst-rpmatch.sh $(objpfx)tst-rpmatch \
381                           $(objpfx)tst-fmon.out \
382                           $(addprefix $(objpfx),$(CTYPE_FILES))
383         $(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
384         $(evaluate-test)
385 $(objpfx)tst-trans.out: tst-trans.sh $(objpfx)tst-trans \
386                         $(addprefix $(objpfx),$(CTYPE_FILES))
387         $(SHELL) $< $(common-objpfx) '$(run-program-prefix-before-env)' \
388                  '$(run-program-env)' '$(run-program-prefix-after-env)' \
389                  '$(test-program-prefix-before-env)' \
390                  '$(test-program-prefix-after-env)'; \
391         $(evaluate-test)
392 $(objpfx)tst-ctype.out: tst-ctype.sh $(objpfx)tst-ctype \
393                         $(objpfx)sort-test.out \
394                         $(addprefix $(objpfx),$(CTYPE_FILES))
395         $(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
396                  '$(run-program-env)' '$(test-program-cmd-after-env)'; \
397         $(evaluate-test)
398 $(objpfx)tst-langinfo-newlocale.out: tst-langinfo.sh \
399                         $(objpfx)tst-langinfo-newlocale \
400                         $(objpfx)sort-test.out \
401                         $(addprefix $(objpfx),$(CTYPE_FILES))
402         $(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
403                  '$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
404         $(evaluate-test)
405 $(objpfx)tst-langinfo-newlocale-static.out: tst-langinfo.sh \
406                         $(objpfx)tst-langinfo-newlocale-static \
407                         $(objpfx)sort-test.out \
408                         $(addprefix $(objpfx),$(CTYPE_FILES))
409         $(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
410                  '$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
411         $(evaluate-test)
412 # Static use of newlocale is known not to work. See Bug 23164.
413 test-xfail-tst-langinfo-newlocale-static = yes
414
415 $(objpfx)tst-langinfo-setlocale.out: tst-langinfo.sh \
416                         $(objpfx)tst-langinfo-setlocale \
417                         $(objpfx)sort-test.out \
418                         $(addprefix $(objpfx),$(CTYPE_FILES))
419         $(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
420                  '$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
421         $(evaluate-test)
422 $(objpfx)tst-langinfo-setlocale-static.out: tst-langinfo.sh \
423                         $(objpfx)tst-langinfo-setlocale-static \
424                         $(objpfx)sort-test.out \
425                         $(addprefix $(objpfx),$(CTYPE_FILES))
426         $(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
427                  '$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
428         $(evaluate-test)
429
430 $(objpfx)tst-digits.out: $(objpfx)tst-locale.out
431 $(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES))
432 endif
433
434 include SUPPORTED
435
436 INSTALL-SUPPORTED-LOCALE-ARCHIVE=$(addprefix install-archive-, $(SUPPORTED-LOCALES))
437 INSTALL-SUPPORTED-LOCALE-FILES=$(addprefix install-files-, $(SUPPORTED-LOCALES))
438
439 # Sometimes the whole collection of locale files should be installed.
440 LOCALEDEF=I18NPATH=. GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
441 $(rtld-prefix) $(common-objpfx)locale/localedef
442 install-locales: install-locale-archive
443
444 # Create and install the locale-archive file.
445 install-locale-archive: $(INSTALL-SUPPORTED-LOCALE-ARCHIVE)
446 # Create and install the locales individually (no archive).
447 install-locale-files: $(INSTALL-SUPPORTED-LOCALE-FILES)
448
449 install-locales-dir:
450         $(..)./scripts/mkinstalldirs $(inst_complocaledir)
451
452 # The SHIFT_JIS and SHIFT_JISX0213 character maps are not ASCII compatible,
453 # therefore we have to use --no-warnings=ascii to disable the ASCII check.
454 # See localedata/gen-locale.sh for the same logic.
455 define build-one-locale
456         locale=`echo $@ | sed -e 's/^install-[a-z]*-//'`; \
457         charset=`echo $$locale | sed -e 's,.*/,,'`; \
458         locale=`echo $$locale | sed -e 's,/[^/]*,,'`; \
459         if [ "$$charset" = 'SHIFT_JIS' ] \
460            || [ "$$charset" = 'SHIFT_JISX0213' ]; then \
461            flags="$$flags --no-warnings=ascii"; \
462         fi; \
463         echo -n `echo $$locale | sed 's/\([^.\@]*\).*/\1/'`; \
464         echo -n ".$$charset"; \
465         echo -n `echo $$locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \
466         echo -n '...'; \
467         input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
468         $(LOCALEDEF) $$flags --alias-file=../intl/locale.alias \
469                      -i locales/$$input -f charmaps/$$charset \
470                      $(addprefix --prefix=,$(install_root)) $$locale \
471         && echo ' done';
472 endef
473
474 $(INSTALL-SUPPORTED-LOCALE-ARCHIVE): install-locales-dir
475         @flags=""; \
476         $(build-one-locale)
477
478 $(INSTALL-SUPPORTED-LOCALE-FILES): install-locales-dir
479         @flags="--no-archive --no-hard-links"; \
480         $(build-one-locale)
481
482 tst-setlocale-ENV = LC_ALL=ja_JP.EUC-JP
483 tst-wctype-ENV = LC_ALL=ja_JP.EUC-JP
484
485 tst-leaks-ENV = MALLOC_TRACE=$(objpfx)tst-leaks.mtrace \
486                 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
487 $(objpfx)mtrace-tst-leaks.out: $(objpfx)tst-leaks.out
488         $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks.mtrace > $@; \
489         $(evaluate-test)
490
491 bug-setlocale1-ENV-only = LOCPATH=$(objpfx) LC_CTYPE=de_DE.UTF-8
492 bug-setlocale1-static-ENV-only = $(bug-setlocale1-ENV-only)
493
494 $(objdir)/iconvdata/gconv-modules:
495         $(MAKE) -C ../iconvdata subdir=iconvdata $@