Makefile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. # Copyright (C) 1991-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. # Sub-makefile for string portion of library.
  16. #
  17. subdir := string
  18. include ../Makeconfig
  19. headers := \
  20. argz.h \
  21. bits/byteswap.h \
  22. bits/endian.h \
  23. bits/endianness.h \
  24. bits/string_fortified.h \
  25. bits/strings_fortified.h \
  26. bits/uintn-identity.h \
  27. byteswap.h \
  28. endian.h \
  29. envz.h \
  30. memory.h \
  31. string.h \
  32. strings.h \
  33. # headers
  34. routines := \
  35. _strerror \
  36. argz-addsep \
  37. argz-append \
  38. argz-count \
  39. argz-create \
  40. argz-ctsep \
  41. argz-delete \
  42. argz-extract \
  43. argz-insert \
  44. argz-next \
  45. argz-replace \
  46. argz-stringify \
  47. basename \
  48. bcopy \
  49. bzero \
  50. envz \
  51. explicit_bzero \
  52. ffs \
  53. ffsll \
  54. memccpy \
  55. memchr \
  56. memcmp \
  57. memcmpeq \
  58. memcpy \
  59. memfrob \
  60. memmem \
  61. memmove \
  62. mempcpy \
  63. memrchr \
  64. memset \
  65. memset_explicit \
  66. rawmemchr \
  67. sigabbrev_np \
  68. sigdescr_np \
  69. stpcpy \
  70. stpncpy \
  71. strcasecmp \
  72. strcasecmp_l \
  73. strcasestr \
  74. strcat \
  75. strchr \
  76. strchrnul \
  77. strcmp \
  78. strcoll \
  79. strcoll_l \
  80. strcpy \
  81. strcspn \
  82. strdup \
  83. strerror \
  84. strerror_l \
  85. strerrordesc_np \
  86. strerrorname_np \
  87. strfry \
  88. string-inlines \
  89. strlcat \
  90. strlcpy \
  91. strlen \
  92. strncase \
  93. strncase_l \
  94. strncat \
  95. strncmp \
  96. strncpy \
  97. strndup \
  98. strnlen \
  99. strpbrk \
  100. strrchr \
  101. strsep \
  102. strsignal \
  103. strspn \
  104. strstr \
  105. strtok \
  106. strtok_r \
  107. strverscmp \
  108. strxfrm \
  109. strxfrm_l \
  110. swab \
  111. wordcopy \
  112. xpg-strerror \
  113. # routines
  114. # Exclude fortified routines from being built with _FORTIFY_SOURCE
  115. routines_no_fortify += \
  116. bzero \
  117. explicit_bzero \
  118. memcpy \
  119. memmove \
  120. mempcpy \
  121. memset \
  122. memset_explicit \
  123. stpcpy \
  124. stpncpy \
  125. strcat \
  126. strcpy \
  127. strlcat \
  128. strlcpy \
  129. strncat \
  130. strncpy \
  131. # routines_no_fortify
  132. tests := \
  133. bug-envz1 \
  134. bug-strcoll1 \
  135. bug-strcoll2 \
  136. bug-strncat1 \
  137. bug-strpbrk1 \
  138. bug-strspn1 \
  139. bug-strtok1 \
  140. inl-tester \
  141. noinl-tester \
  142. stratcliff \
  143. test-bcopy \
  144. test-bzero \
  145. test-endian-file-scope \
  146. test-endian-sign-conversion \
  147. test-endian-types \
  148. test-explicit_bzero \
  149. test-ffs \
  150. test-memccpy \
  151. test-memchr \
  152. test-memcmp \
  153. test-memcmpeq \
  154. test-memcpy \
  155. test-memcpy-large \
  156. test-memmem \
  157. test-memmove \
  158. test-mempcpy \
  159. test-memrchr \
  160. test-memset \
  161. test-memset_explicit \
  162. test-rawmemchr \
  163. test-sig_np \
  164. test-stpcpy \
  165. test-stpncpy \
  166. test-strcasecmp \
  167. test-strcasestr \
  168. test-strcat \
  169. test-strchr \
  170. test-strchrnul \
  171. test-strcmp \
  172. test-strcpy \
  173. test-strcspn \
  174. test-strdup \
  175. test-strlen \
  176. test-strncasecmp \
  177. test-strncat \
  178. test-strncmp \
  179. test-strncpy \
  180. test-strndup \
  181. test-strnlen \
  182. test-strnlen-nonarray \
  183. test-strpbrk \
  184. test-strrchr \
  185. test-strspn \
  186. test-strstr \
  187. testcopy \
  188. tester \
  189. tst-bswap \
  190. tst-cmp \
  191. tst-const \
  192. tst-endian \
  193. tst-inlcall \
  194. tst-memmove-overflow \
  195. tst-strerror-fail \
  196. tst-strfry \
  197. tst-strlcat \
  198. tst-strlcat2 \
  199. tst-strlcpy \
  200. tst-strlcpy2 \
  201. tst-strlen \
  202. tst-strtok \
  203. tst-strtok_r \
  204. tst-strxfrm \
  205. tst-strxfrm2 \
  206. tst-svc \
  207. tst-svc2 \
  208. tst-xbzero-opt \
  209. tst-xmemset-opt \
  210. # tests
  211. tests-static-internal := \
  212. test-memswap \
  213. # tests-static-internal
  214. tests-internal := \
  215. $(tests-static-internal) \
  216. # tests-internal
  217. tests-static := \
  218. $(tests-static-internal) \
  219. # tests-static
  220. # Both tests require the .mo translation files generated by msgfmt.
  221. tests-translation := \
  222. tst-strerror \
  223. tst-strsignal \
  224. # tests-translation
  225. tests-container += $(tests-translation)
  226. ifeq ($(MSGFMT),:)
  227. tests-unsupported += $(tests-translation)
  228. endif
  229. # This test allocates a lot of memory and can run for a long time.
  230. xtests += tst-strcoll-overflow
  231. # This test runs for a long time.
  232. xtests += test-strncmp-nonarray
  233. # This test needs libdl.
  234. ifeq (yes,$(build-shared))
  235. tests += test-strerror-errno
  236. endif
  237. ifeq ($(run-built-tests),yes)
  238. tests-special += $(objpfx)tst-svc-cmp.out
  239. endif
  240. include ../Rules
  241. CFLAGS-tester.c += $(test-config-cflags-wno-fortify-source)
  242. CFLAGS-inl-tester.c += -fno-builtin \
  243. $(test-config-cflags-wno-fortify-source)
  244. CFLAGS-noinl-tester.c += -fno-builtin \
  245. $(test-config-cflags-wno-fortify-source)
  246. CFLAGS-tst-strlen.c += -fno-builtin
  247. CFLAGS-stratcliff.c += -fno-builtin
  248. CFLAGS-test-ffs.c += -fno-builtin
  249. CFLAGS-tst-inlcall.c += -fno-builtin
  250. CFLAGS-tst-xbzero-opt.c += -O3
  251. CFLAGS-tst-xmemset-opt.c += -O3
  252. CFLAGS-test-endian-sign-conversion.c += -Werror -Wsign-conversion
  253. # BZ 21006: Resolve all functions but at least explicit_bzero at startup.
  254. # Otherwise the test fails on s390x as the memcpy in prepare_test_buffer is
  255. # done by loading r4 / r5 with the test_pattern and using store multiple
  256. # instruction to store r4 / r5 to buf. If explicit_bzero would be resolved in
  257. # setup_explicit_clear, r4 / r5 would be stored to stack by _dl_runtime_resolve
  258. # and the call to memmem in count_test_patterns will find a hit of the
  259. # test_pattern on the stack.
  260. LDFLAGS-tst-xbzero-opt = -z now
  261. LDFLAGS-tst-xmemset-opt = -z now
  262. # Called during TLS initialization.
  263. CFLAGS-memcpy.c += $(no-stack-protector)
  264. CFLAGS-wordcopy.c += $(no-stack-protector)
  265. # Called during static initialization
  266. CFLAGS-strncmp.c += $(no-stack-protector)
  267. CFLAGS-memset.c += $(no-stack-protector)
  268. ifeq ($(run-built-tests),yes)
  269. $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
  270. cmp $^ > $@; \
  271. $(evaluate-test)
  272. LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
  273. tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
  274. da_DK.ISO-8859-1 en_GB.UTF-8 pt_BR.UTF-8
  275. include ../gen-locales.mk
  276. $(objpfx)test-strcasecmp.out: $(gen-locales)
  277. $(objpfx)test-strncasecmp.out: $(gen-locales)
  278. $(objpfx)tst-strxfrm.out: $(gen-locales)
  279. $(objpfx)tst-strxfrm2.out: $(gen-locales)
  280. # bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
  281. $(objpfx)bug-strcoll2.out: $(gen-locales)
  282. $(objpfx)tst-strcoll-overflow.out: $(gen-locales)
  283. $(objpfx)tst-strsignal.out: $(gen-locales)
  284. $(objpfx)tst-strerror.out: $(gen-locales)
  285. endif