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