1 # Copyright (C) 1996-2023 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 # <https://www.gnu.org/licenses/>.
18 # Makefile for installing locale data source files.
24 # List with all available character set descriptions.
25 charmaps := $(wildcard charmaps/[A-I]*) $(wildcard charmaps/[J-Z]*)
27 # List with all available character set descriptions.
28 locales := $(wildcard locales/*)
31 subdir-dirs = tests-mbwc
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 \
40 # List of test input files (list sorted alphabetically):
73 gez_ER.UTF-8@abegede \
117 tt_RU.UTF-8@iqtelif \
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) \
136 fmon-tests = n01y12 n02n40 n10y31 n11y41 n12y11 n20n32 n30y20 n41n00 \
137 y01y10 y02n22 y22n42 y30y21 y32n31 y40y00 y42n21
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)) \
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
161 $(locale_test_suite) \
165 tst-c-utf8-consistency \
167 tst-iconv-math-trans \
185 tests-static = bug-setlocale1-static
186 tests += $(tests-static)
187 ifeq (yes,$(build-shared))
189 tests-special += $(objpfx)mtrace-tst-leaks.out
194 tst-localedef-hardlinks
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)/, \
204 install-others := $(addprefix $(inst_i18ndir)/, \
205 $(addsuffix .gz, $(charmaps)) \
209 tests: $(objdir)/iconvdata/gconv-modules
211 tests-static += tst-langinfo-newlocale-static tst-langinfo-setlocale-static
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)
246 en_US.ANSI_X3.4-1968 \
259 gez_ER.UTF-8@abegede \
310 tt_RU.UTF-8@iqtelif \
321 include ../gen-locales.mk
323 $(objpfx)tst-iconv-math-trans.out: $(gen-locales)
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
332 $(inst_i18ndir)/charmaps/%: charmaps/% $(+force)
333 $(make-target-directory)
335 $(INSTALL_DATA) $< $@
337 # Install the charmap files in gzipped format.
338 $(inst_i18ndir)/charmaps/%.gz: charmaps/% $(+force)
339 $(make-target-directory)
341 $(INSTALL_DATA) $< $(@:.gz=)
345 # Install the locale source files in the appropriate directory.
346 $(inst_i18ndir)/locales/%: locales/% $(+force); $(do-install)
348 ifeq ($(run-built-tests),yes)
349 generated-dirs += $(LOCALES)
351 $(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
352 $(addprefix $(objpfx),$(CTYPE_FILES))
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)' \
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 \
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 \
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)' > $@; \
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)' > $@; \
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)'; \
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)'; \
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)' > $@; \
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)' > $@; \
412 # Static use of newlocale is known not to work. See Bug 23164.
413 test-xfail-tst-langinfo-newlocale-static = yes
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)' > $@; \
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)' > $@; \
430 $(objpfx)tst-digits.out: $(objpfx)tst-locale.out
431 $(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES))
436 INSTALL-SUPPORTED-LOCALE-ARCHIVE=$(addprefix install-archive-, $(SUPPORTED-LOCALES))
437 INSTALL-SUPPORTED-LOCALE-FILES=$(addprefix install-files-, $(SUPPORTED-LOCALES))
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
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)
450 $(..)./scripts/mkinstalldirs $(inst_complocaledir)
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"; \
463 echo -n `echo $$locale | sed 's/\([^.\@]*\).*/\1/'`; \
464 echo -n ".$$charset"; \
465 echo -n `echo $$locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \
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 \
474 $(INSTALL-SUPPORTED-LOCALE-ARCHIVE): install-locales-dir
478 $(INSTALL-SUPPORTED-LOCALE-FILES): install-locales-dir
479 @flags="--no-archive --no-hard-links"; \
482 tst-setlocale-ENV = LC_ALL=ja_JP.EUC-JP
483 tst-wctype-ENV = LC_ALL=ja_JP.EUC-JP
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 > $@; \
491 bug-setlocale1-ENV-only = LOCPATH=$(objpfx) LC_CTYPE=de_DE.UTF-8
492 bug-setlocale1-static-ENV-only = $(bug-setlocale1-ENV-only)
494 $(objdir)/iconvdata/gconv-modules:
495 $(MAKE) -C ../iconvdata subdir=iconvdata $@