1# Copyright (C) 1991-2022 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#
21subdir	:= string
22
23include ../Makeconfig
24
25headers := \
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
41routines := \
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  rawmemchr \
73  sigabbrev_np \
74  sigdescr_np \
75  stpcpy \
76  stpncpy \
77  strcasecmp \
78  strcasecmp_l \
79  strcasestr \
80  strcat \
81  strchr \
82  strchrnul \
83  strcmp \
84  strcoll \
85  strcoll_l \
86  strcpy \
87  strcspn \
88  strdup \
89  strerror \
90  strerror_l \
91  strerrordesc_np \
92  strerrorname_np \
93  strfry \
94  string-inlines \
95  strlen \
96  strncase \
97  strncase_l \
98  strncat \
99  strncmp \
100  strncpy \
101  strndup \
102  strnlen \
103  strpbrk \
104  strrchr \
105  strsep \
106  strsignal \
107  strspn \
108  strstr \
109  strtok \
110  strtok_r \
111  strverscmp \
112  strxfrm \
113  strxfrm_l \
114  swab \
115  wordcopy \
116  xpg-strerror \
117# routines
118
119tests := \
120  bug-envz1 \
121  bug-strcoll1 \
122  bug-strcoll2 \
123  bug-strncat1 \
124  bug-strpbrk1 \
125  bug-strspn1 \
126  bug-strtok1 \
127  inl-tester \
128  noinl-tester \
129  stratcliff \
130  test-bcopy \
131  test-bzero \
132  test-endian-file-scope \
133  test-endian-sign-conversion \
134  test-endian-types \
135  test-explicit_bzero \
136  test-ffs \
137  test-memccpy \
138  test-memchr \
139  test-memcmp \
140  test-memcmpeq \
141  test-memcpy \
142  test-memcpy-large \
143  test-memmem \
144  test-memmove \
145  test-mempcpy \
146  test-memrchr \
147  test-memset \
148  test-rawmemchr \
149  test-sig_np \
150  test-stpcpy \
151  test-stpncpy \
152  test-strcasecmp \
153  test-strcasestr \
154  test-strcat \
155  test-strchr \
156  test-strchrnul \
157  test-strcmp \
158  test-strcpy \
159  test-strcspn \
160  test-strlen \
161  test-strncasecmp \
162  test-strncat \
163  test-strncmp \
164  test-strncpy \
165  test-strnlen \
166  test-strpbrk \
167  test-strrchr \
168  test-strspn \
169  test-strstr \
170  testcopy \
171  tester \
172  tst-bswap \
173  tst-cmp \
174  tst-endian \
175  tst-inlcall \
176  tst-memmove-overflow \
177  tst-strfry \
178  tst-strlen \
179  tst-strtok \
180  tst-strtok_r \
181  tst-strxfrm \
182  tst-strxfrm2 \
183  tst-svc \
184  tst-svc2 \
185  tst-xbzero-opt \
186# tests
187
188# Both tests require the .mo translation files generated by msgfmt.
189tests-translation := \
190  tst-strerror \
191  tst-strsignal \
192# tests-translation
193
194tests-container   += $(tests-translation)
195ifeq ($(MSGFMT),:)
196tests-unsupported += $(tests-translation)
197endif
198
199# This test allocates a lot of memory and can run for a long time.
200xtests = tst-strcoll-overflow
201
202# This test needs libdl.
203ifeq (yes,$(build-shared))
204tests += test-strerror-errno
205endif
206
207ifeq ($(run-built-tests),yes)
208tests-special += $(objpfx)tst-svc-cmp.out
209endif
210
211include ../Rules
212
213CFLAGS-inl-tester.c += -fno-builtin
214CFLAGS-noinl-tester.c += -fno-builtin
215CFLAGS-tst-strlen.c += -fno-builtin
216CFLAGS-stratcliff.c += -fno-builtin
217CFLAGS-test-ffs.c += -fno-builtin
218CFLAGS-tst-inlcall.c += -fno-builtin
219CFLAGS-tst-xbzero-opt.c += -O3
220CFLAGS-test-endian-sign-conversion.c += -Werror -Wsign-conversion
221# BZ 21006: Resolve all functions but at least explicit_bzero at startup.
222# Otherwise the test fails on s390x as the memcpy in prepare_test_buffer is
223# done by loading r4 / r5 with the test_pattern and using store multiple
224# instruction to store r4 / r5 to buf.  If explicit_bzero would be resolved in
225# setup_explicit_clear, r4 / r5 would be stored to stack by _dl_runtime_resolve
226# and the call to memmem in count_test_patterns will find a hit of the
227# test_pattern on the stack.
228LDFLAGS-tst-xbzero-opt = -z now
229
230# Called during TLS initialization.
231CFLAGS-memcpy.c += $(no-stack-protector)
232CFLAGS-wordcopy.c += $(no-stack-protector)
233
234ifeq ($(run-built-tests),yes)
235$(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
236	cmp $^ > $@; \
237	$(evaluate-test)
238
239LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
240           tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \
241	   da_DK.ISO-8859-1 en_GB.UTF-8 pt_BR.UTF-8
242include ../gen-locales.mk
243
244$(objpfx)test-strcasecmp.out: $(gen-locales)
245$(objpfx)test-strncasecmp.out: $(gen-locales)
246$(objpfx)tst-strxfrm.out: $(gen-locales)
247$(objpfx)tst-strxfrm2.out: $(gen-locales)
248# bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1.
249$(objpfx)bug-strcoll2.out: $(gen-locales)
250$(objpfx)tst-strcoll-overflow.out: $(gen-locales)
251$(objpfx)tst-strsignal.out: $(gen-locales)
252$(objpfx)tst-strerror.out: $(gen-locales)
253
254endif
255