Makefile 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # Copyright (C) 1997-2026 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3. # The GNU C Library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Lesser General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2.1 of the License, or (at your option) any later version.
  7. # The GNU C Library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. # You should have received a copy of the GNU Lesser General Public
  12. # License along with the GNU C Library; if not, see
  13. # <https://www.gnu.org/licenses/>.
  14. #
  15. # Makefile for iconv.
  16. #
  17. subdir := iconv
  18. include ../Makeconfig
  19. headers = iconv.h gconv.h
  20. routines = iconv_open iconv iconv_close \
  21. gconv_open gconv gconv_close gconv_db gconv_conf \
  22. gconv_builtin gconv_simple gconv_trans gconv_cache
  23. routines += gconv_dl gconv_charset
  24. vpath %.c ../locale/programs ../intl
  25. iconv_prog-modules = iconv_charmap charmap charmap-dir linereader \
  26. dummy-repertoire simple-hash xstrdup xmalloc \
  27. record-status
  28. iconvconfig-modules = strtab xmalloc xasprintf xstrdup hash-string
  29. extra-objs = $(iconv_prog-modules:=.o) $(iconvconfig-modules:=.o)
  30. CFLAGS-iconv_prog.c += -I../locale/programs
  31. CFLAGS-iconv_charmap.c += -I../locale/programs
  32. CFLAGS-dummy-repertoire.c += -I../locale/programs
  33. CFLAGS-charmap.c += -DCHARMAP_PATH='"$(i18ndir)/charmaps"' \
  34. -DDEFAULT_CHARMAP=null_pointer -DNEED_NULL_POINTER
  35. CFLAGS-linereader.c += -DNO_TRANSLITERATION
  36. CFLAGS-simple-hash.c += -I../locale
  37. tests = \
  38. tst-iconv1 \
  39. tst-iconv2 \
  40. tst-iconv3 \
  41. tst-iconv4 \
  42. tst-iconv5 \
  43. tst-iconv6 \
  44. tst-iconv7 \
  45. tst-iconv8 \
  46. tst-iconv9 \
  47. tst-iconv-mt \
  48. tst-iconv-opt \
  49. # tests
  50. test-srcs := \
  51. tst-translit-mchar \
  52. # test-srcs
  53. tests-internal = \
  54. tst-iconv-sticky-input-error \
  55. # tests-internal
  56. others = iconv_prog iconvconfig
  57. install-others-programs = $(inst_bindir)/iconv
  58. install-sbin = iconvconfig
  59. CFLAGS-gconv_cache.c += -DGCONV_DIR='"$(gconvdir)"'
  60. CFLAGS-gconv_conf.c += -DGCONV_PATH='"$(gconvdir)"'
  61. CFLAGS-iconvconfig.c += -DGCONV_PATH='"$(gconvdir)"' -DGCONV_DIR='"$(gconvdir)"'
  62. # Set libof-* for each routine.
  63. cpp-srcs-left := $(iconv_prog-modules) $(iconvconfig-modules)
  64. lib := iconvprogs
  65. include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
  66. ifeq ($(run-built-tests),yes)
  67. xtests-special += $(objpfx)test-iconvconfig.out
  68. tests-special += \
  69. $(objpfx)tst-iconv_prog-buffer-large.out \
  70. $(objpfx)tst-iconv_prog-buffer-tiny.out \
  71. $(objpfx)tst-iconv_prog-buffer.out \
  72. $(objpfx)tst-iconv_prog.out \
  73. $(objpfx)tst-iconvconfig.out \
  74. $(objpfx)tst-translit-mchar.out \
  75. # tests-special
  76. endif
  77. # Make a copy of the file because gconv module names are constructed
  78. # relative to the path of the configuration file.
  79. $(objpfx)gconv-modules: test-gconv-modules
  80. cp $< $@
  81. $(objpfx)tst-iconv-mt: $(shared-thread-library)
  82. ifeq (yes,$(build-shared))
  83. tests += tst-gconv-init-failure
  84. modules-names += tst-gconv-init-failure-mod
  85. modules-names-tests += tst-gconv-init-failure-mod
  86. extra-test-objs += tst-gconv-init-failure-mod.os
  87. $(objpfx)tst-gconv-init-failure-mod.so: $(libsupport)
  88. $(objpfx)tst-gconv-init-failure.out: \
  89. $(objpfx)gconv-modules $(objpfx)tst-gconv-init-failure-mod.so
  90. endif
  91. generated-dirs += tst-translit
  92. include ../Rules
  93. ifeq ($(run-built-tests),yes)
  94. # We have to generate locales (list sorted alphabetically)
  95. LOCALES := \
  96. C.UTF-8 \
  97. en_US.UTF-8 \
  98. # LOCALES
  99. include ../gen-locales.mk
  100. $(objpfx)tst-iconv-opt.out: $(gen-locales)
  101. $(objpfx)tst-iconv9.out: $(gen-locales)
  102. endif
  103. $(inst_bindir)/iconv: $(objpfx)iconv_prog $(+force)
  104. $(do-install-program)
  105. $(objpfx)iconv_prog: $(iconv_prog-modules:%=$(objpfx)%.o)
  106. $(objpfx)iconvconfig: $(iconvconfig-modules:%=$(objpfx)%.o)
  107. $(objpfx)test-iconvconfig.out: $(objpfx)iconvconfig
  108. (set -e; \
  109. tmp=$(objpfx)gconv-modules.cache.$$$$; \
  110. rm -f $$tmp; \
  111. $(run-program-prefix) $(objpfx)iconvconfig \
  112. --output=$$tmp --nostdlib $(inst_gconvdir); \
  113. cmp $$tmp $(inst_gconvdir)/gconv-modules.cache; \
  114. rm -f $$tmp) > $@; \
  115. $(evaluate-test)
  116. $(objpfx)tst-iconv_prog.out: tst-iconv_prog.sh $(objpfx)iconv_prog
  117. $(BASH) $< $(common-objdir) '$(test-wrapper-env)' \
  118. '$(run-program-env)' '$(rpath-link)' > $@; \
  119. $(evaluate-test)
  120. $(objpfx)tst-translit-mchar.out: tst-translit-mchar.sh \
  121. $(objpfx)tst-translit-mchar \
  122. tst-translit-locale
  123. $(SHELL) $< $(common-objpfx) '$(run-program-prefix-before-env)' \
  124. '$(run-program-env)' '$(run-program-prefix-after-env)' \
  125. $< > $@; \
  126. $(evaluate-test)
  127. $(objpfx)tst-iconv_prog-buffer.out: \
  128. tst-iconv_prog-buffer.sh $(objpfx)iconv_prog
  129. $(BASH) $< $(common-objdir) '$(run-program-prefix)' > $@; \
  130. $(evaluate-test)
  131. $(objpfx)tst-iconv_prog-buffer-tiny.out: \
  132. tst-iconv_prog-buffer.sh $(objpfx)iconv_prog
  133. $(BASH) $< $(common-objdir) '$(run-program-prefix)' \
  134. '--buffer-size=1' > $@; \
  135. $(evaluate-test)
  136. $(objpfx)tst-iconv_prog-buffer-large.out: \
  137. tst-iconv_prog-buffer.sh $(objpfx)iconv_prog
  138. $(BASH) $< $(common-objdir) '$(run-program-prefix)' '' '22' > $@; \
  139. $(evaluate-test)
  140. $(objpfx)tst-iconvconfig.out: tst-iconvconfig.sh $(objpfx)iconvconfig
  141. $(BASH) $< $(common-objdir) '$(test-wrapper-env)' \
  142. '$(run-program-env)' '$(rpath-link)' > $@; \
  143. $(evaluate-test)