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