Debian Codegraph @

stdio-common/Makefile

raw ◀ ▶
Source reconstructed at patch state 1 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 # Copyright (C) 1991-2026 Free Software Foundation, Inc.
2 # Copyright The GNU Toolchain Authors.
3 # This file is part of the GNU C Library.
4
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
14
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <https://www.gnu.org/licenses/>.
18
19 #
20 # Specific makefile for stdio-common.
21 #
22 subdir := stdio-common
23
24 include ../Makeconfig
25
26 # List of markers for printf family function tests.
27 xprintf-funcs := p as d f s sn v vas vd vf vs vsn
28
29 # List of data types and formats for individual per-conversion printf tests.
30 fmt-convs := double ldouble
31 fmts := E e F f G g
32
33 # List of data types grouping all conversions in single printf tests.
34 nonfmt-convs := c char int llong long s short
35 nonfmt-convs += uchar uint ullong ulong ushort
36
37 convs := $(sort $(fmt-convs) $(nonfmt-convs))
38
39 xprintf-srcs := \
40 $(foreach p,$(xprintf-funcs), \
41 $(foreach c,$(convs),tst-printf-format-$(p)-$(c)))
42
43 fmt-xprintf-stems := \
44 $(foreach f,$(fmts), \
45 $(foreach p,$(xprintf-funcs), \
46 $(foreach c,$(fmt-convs), \
47 tst-printf-format-$(p)-$(c)-$(f))))
48 nonfmt-xprintf-stems := \
49 $(foreach p,$(xprintf-funcs), \
50 $(foreach c,$(nonfmt-convs),tst-printf-format-$(p)-$(c)))
51
52 xprintf-stems := $(sort $(fmt-xprintf-stems) $(nonfmt-xprintf-stems))
53
54 # List of markers for scanf family function tests.
55 xscanf-funcs := s f ss v vf vs
56
57 # List of data types and formats for individual per-conversion scanf tests.
58 # Further conversions are provided by sysdeps.
59 xscanf-kinds := char int real uint
60 fmt-xscanf-char-convs := c
61 fmts-xscanf-char := b c s
62 fmt-xscanf-int-convs := char llong short
63 fmts-xscanf-int := d i
64 fmt-xscanf-real-convs :=
65 fmts-xscanf-real := aa a ee e ff f gg g
66 fmt-xscanf-uint-convs := uchar ullong ushort
67 fmts-xscanf-uint := b o u xx x
68
69 xscanf-convs = $(sort $(fmt-xscanf-char-convs) $(fmt-xscanf-int-convs) \
70 $(fmt-xscanf-real-convs) $(fmt-xscanf-uint-convs))
71
72 xscanf-srcs = $(foreach p,$(xscanf-funcs), \
73 $(foreach c,$(xscanf-convs),tst-scanf-format-$(p)-$(c)))
74
75 xscanf-stems = $(sort $(foreach k,$(xscanf-kinds), \
76 $(foreach f,$(fmts-xscanf-$(k)), \
77 $(foreach p,$(xscanf-funcs), \
78 $(foreach c,$(fmt-xscanf-$(k)-convs), \
79 tst-scanf-format-$(p)-$(c)-$(f))))))
80
81 headers := \
82 bits/printf-ldbl.h \
83 bits/stdio_lim.h \
84 printf.h \
85 stdio_ext.h \
86 # headers
87
88 routines := \
89 _fitoa_word \
90 _itoa \
91 _itowa \
92 asprintf \
93 ctermid \
94 cuserid \
95 dprintf \
96 flockfile \
97 fprintf \
98 fscanf \
99 ftrylockfile \
100 funlockfile \
101 gentempfd \
102 getline \
103 getw \
104 grouping_iterator \
105 iovfscanf \
106 isoc23_fscanf \
107 isoc23_scanf \
108 isoc23_sscanf \
109 isoc23_vfscanf \
110 isoc23_vscanf \
111 isoc23_vsscanf \
112 isoc99_fscanf \
113 isoc99_scanf \
114 isoc99_sscanf \
115 isoc99_vfscanf \
116 isoc99_vscanf \
117 isoc99_vsscanf \
118 itoa-digits \
119 itoa-udigits \
120 itowa-digits \
121 perror \
122 printf \
123 printf-prs \
124 printf_buffer_as_file \
125 printf_buffer_done \
126 printf_buffer_flush \
127 printf_buffer_pad_1 \
128 printf_buffer_putc_1 \
129 printf_buffer_puts_1 \
130 printf_buffer_to_file \
131 printf_buffer_write \
132 printf_fp \
133 printf_fphex \
134 printf_function_invoke \
135 printf_size \
136 psiginfo \
137 psignal \
138 putw \
139 reg-modifier \
140 reg-printf \
141 reg-type \
142 remove \
143 rename \
144 renameat \
145 renameat2 \
146 scanf \
147 snprintf \
148 sprintf \
149 sscanf \
150 tempnam \
151 tempname \
152 tmpdir \
153 tmpfile \
154 tmpfile64 \
155 tmpnam \
156 tmpnam_r \
157 translated_number_width \
158 vfprintf \
159 vfprintf-internal \
160 vfscanf \
161 vfscanf-internal \
162 vfwprintf \
163 vfwprintf-internal \
164 vfwscanf \
165 vfwscanf-internal \
166 vprintf \
167 wprintf_buffer_as_file \
168 wprintf_buffer_done \
169 wprintf_buffer_flush \
170 wprintf_buffer_pad_1 \
171 wprintf_buffer_putc_1 \
172 wprintf_buffer_puts_1 \
173 wprintf_buffer_to_file \
174 wprintf_buffer_write \
175 wprintf_function_invoke \
176 # routines
177
178 # Exclude fortified routines from being built with _FORTIFY_SOURCE
179 routines_no_fortify += \
180 asprintf \
181 dprintf \
182 fprintf \
183 printf \
184 snprintf \
185 sprintf \
186 vfprintf \
187 vfwprintf \
188 vprintf \
189 # routines_no_fortify
190
191 aux := \
192 errlist \
193 errlist-data \
194 errname \
195 fxprintf \
196 printf-parsemb \
197 printf-parsewc \
198 siglist \
199 # aux
200
201 tests := \
202 bug-vfprintf-nargs \
203 bug1 \
204 bug3 \
205 bug4 \
206 bug5 \
207 bug6 \
208 bug7 \
209 bug8 \
210 bug9 \
211 bug10 \
212 bug11 \
213 bug12 \
214 bug13 \
215 bug14 \
216 bug16 \
217 bug17 \
218 bug18 \
219 bug18a \
220 bug19 \
221 bug19a \
222 bug2 \
223 bug20 \
224 bug21 \
225 bug22 \
226 bug23 \
227 bug24 \
228 bug25 \
229 bug26 \
230 bug27 \
231 bug29 \
232 errnobug \
233 scanf1 \
234 scanf2 \
235 scanf3 \
236 scanf4 \
237 scanf5 \
238 scanf7 \
239 scanf8 \
240 scanf9 \
241 scanf10 \
242 scanf11 \
243 scanf12 \
244 scanf13 \
245 scanf14 \
246 scanf15 \
247 scanf16 \
248 scanf17 \
249 scanf18 \
250 scanf19 \
251 temptest \
252 test-fseek \
253 test-fwrite \
254 test-popen \
255 test-strerr \
256 test-vfprintf \
257 test_rdwr \
258 tfformat \
259 tiformat \
260 tllformat \
261 tst-bz11319 \
262 tst-bz11319-fortify2 \
263 tst-bz12701-c \
264 tst-cookie \
265 tst-dprintf-length \
266 tst-fclose-devzero \
267 tst-fclose-offset \
268 tst-fdopen \
269 tst-fdopen2 \
270 tst-ferror \
271 tst-fflush-all-input \
272 tst-fflush-mmap \
273 tst-fgets \
274 tst-fgets2 \
275 tst-fileno \
276 tst-fmemopen \
277 tst-fmemopen2 \
278 tst-fmemopen3 \
279 tst-fmemopen4 \
280 tst-fopen \
281 tst-fphex \
282 tst-fphex-wide \
283 tst-fread \
284 tst-freopen2 \
285 tst-freopen3 \
286 tst-freopen4 \
287 tst-freopen5 \
288 tst-freopen6 \
289 tst-freopen64-2 \
290 tst-freopen64-3 \
291 tst-freopen64-4 \
292 tst-freopen64-6 \
293 tst-freopen64-7 \
294 tst-freopen7 \
295 tst-fseek \
296 tst-fseek-mmap \
297 tst-fwrite \
298 tst-fwrite-memstrm \
299 tst-fwrite-overflow \
300 tst-fwrite-pipe \
301 tst-fwrite-pos \
302 tst-fwrite-ro \
303 tst-getline \
304 tst-getline-enomem \
305 tst-gets \
306 tst-grouping \
307 tst-grouping2 \
308 tst-grouping3 \
309 tst-long-dbl-fphex \
310 tst-memstream-string \
311 tst-obprintf \
312 tst-perror \
313 tst-popen \
314 tst-popen2 \
315 tst-printf-binary \
316 tst-printf-intn \
317 tst-printf-macro \
318 tst-printf-oct \
319 tst-printf-round \
320 tst-printfsz \
321 tst-put-error \
322 tst-read-offset \
323 tst-renameat2 \
324 tst-rndseek \
325 tst-scanf-binary-c11 \
326 tst-scanf-binary-c23 \
327 tst-scanf-binary-gnu11 \
328 tst-scanf-binary-gnu89 \
329 tst-scanf-bz27650 \
330 tst-scanf-intn \
331 tst-scanf-nan \
332 tst-scanf-round \
333 tst-scanf-to_inpunct \
334 tst-setvbuf1 \
335 tst-sprintf \
336 tst-sprintf-errno \
337 tst-sprintf2 \
338 tst-sprintf3 \
339 tst-sscanf \
340 tst-swprintf \
341 tst-swscanf \
342 tst-tmpnam \
343 tst-ungetc \
344 tst-ungetc-fflush \
345 tst-ungetc-leak \
346 tst-ungetc-nomem \
347 tst-unlockedio \
348 tst-vfprintf-mbs-prec \
349 tst-vfprintf-user-type \
350 tst-vfprintf-width-i18n \
351 tst-vfprintf-width-prec-alloc \
352 tst-vfscanf-bz34008 \
353 tst-wc-printf \
354 tstdiomisc \
355 tstgetln \
356 tstscanf \
357 xbug \
358 # tests
359
360 # Clang 19 takes a very long time, it ran more than 27 minutes on Intel
361 # Core i7-1195G7 before the process was killed, to compile bug28.c.
362 # The issue was fixed in upstream but check if clang has the version that has the fix:
363 # https://github.com/llvm/llvm-project/commit/99dddef340e566e9d303010f1219f7d7d6d37a11
364 ifneq ($(have-test-clang-19-or-less),yes)
365 tests += \
366 bug28 \
367 # tests
368 endif
369
370 ifeq ($(run-built-tests),yes)
371 ifeq (yes,$(build-shared))
372 ifneq ($(PERL),no)
373 tests += \
374 tst-printf-bz18872 \
375 tst-printf-bz25691 \
376 tst-printf-fp-free \
377 tst-printf-fp-leak \
378 tst-vfprintf-width-prec \
379 # tests
380 endif
381 endif
382 endif
383
384 tests-container += \
385 tst-popen3 \
386 tst-setvbuf2 \
387 tst-setvbuf2-ind
388 # tests-container
389
390 generated += \
391 errlist-data-aux-shared.S \
392 errlist-data-aux.S \
393 siglist-aux-shared.S \
394 siglist-aux.S \
395 # generated
396
397 tests-internal = \
398 tst-grouping_iterator \
399 tst-setvbuf2 \
400 tst-setvbuf2-ind \
401 # tests-internal
402
403 test-srcs = \
404 $(xprintf-srcs) \
405 $(xscanf-srcs) \
406 tst-fwrite-bz29459 \
407 tst-printf \
408 tst-printfsz-islongdouble \
409 tst-unbputc \
410 # test-srcs
411
412 ifeq ($(run-built-tests),yes)
413 tests-special += \
414 $(foreach f,$(xprintf-stems),$(objpfx)$(f).out) \
415 $(foreach f,$(xscanf-stems),$(objpfx)$(f).out) \
416 $(objpfx)tst-fwrite-bz29459.out \
417 $(objpfx)tst-printf.out \
418 $(objpfx)tst-printfsz-islongdouble.out \
419 $(objpfx)tst-setvbuf1-cmp.out \
420 $(objpfx)tst-unbputc.out \
421 # tests-special
422
423 ifeq (yes,$(build-shared))
424 ifneq ($(PERL),no)
425 tests-special += \
426 $(foreach f,$(xprintf-stems),$(objpfx)$(f)-mem.out) \
427 $(foreach f,$(xscanf-stems),$(objpfx)$(f)-mem.out) \
428 $(objpfx)tst-freopen2-mem.out \
429 $(objpfx)tst-freopen3-mem.out \
430 $(objpfx)tst-freopen4-mem.out \
431 $(objpfx)tst-freopen5-mem.out \
432 $(objpfx)tst-freopen6-mem.out \
433 $(objpfx)tst-freopen64-2-mem.out \
434 $(objpfx)tst-freopen64-3-mem.out \
435 $(objpfx)tst-freopen64-4-mem.out \
436 $(objpfx)tst-freopen64-6-mem.out \
437 $(objpfx)tst-getline-enomem-mem.out \
438 $(objpfx)tst-getline-mem.out \
439 $(objpfx)tst-printf-bz18872-mem.out \
440 $(objpfx)tst-printf-bz25691-mem.out \
441 $(objpfx)tst-printf-fp-free-mem.out \
442 $(objpfx)tst-printf-fp-leak-mem.out \
443 $(objpfx)tst-ungetc-leak-mem.out \
444 $(objpfx)tst-vfprintf-width-prec-mem.out \
445 # tests-special
446
447 generated += \
448 $(foreach f,$(xprintf-stems),$(f)-mem.out) \
449 $(foreach f,$(xprintf-stems),$(f).mtrace) \
450 $(foreach f,$(xscanf-stems),$(f)-mem.out) \
451 $(foreach f,$(xscanf-stems),$(f).mtrace) \
452 tst-freopen2-mem.out \
453 tst-freopen2.mtrace \
454 tst-freopen3-mem.out \
455 tst-freopen3.mtrace \
456 tst-freopen4-mem.out \
457 tst-freopen4.mtrace \
458 tst-freopen5-mem.out \
459 tst-freopen5.mtrace \
460 tst-freopen6-mem.out \
461 tst-freopen6.mtrace \
462 tst-freopen64-2-mem.out \
463 tst-freopen64-2.mtrace \
464 tst-freopen64-3-mem.out \
465 tst-freopen64-3.mtrace \
466 tst-freopen64-4-mem.out \
467 tst-freopen64-4.mtrace \
468 tst-freopen64-6-mem.out \
469 tst-freopen64-6.mtrace \
470 tst-getline-enomem-mem.out \
471 tst-getline-enomem.mtrace \
472 tst-getline-mem.out \
473 tst-getline.mtrace \
474 tst-printf-bz18872-mem.out \
475 tst-printf-bz18872.c \
476 tst-printf-bz18872.mtrace \
477 tst-printf-bz25691-mem.out \
478 tst-printf-bz25691.mtrace \
479 tst-printf-fp-free-mem.out \
480 tst-printf-fp-free.mtrace \
481 tst-printf-fp-leak-mem.out \
482 tst-printf-fp-leak.mtrace \
483 tst-scanf-bz27650.mtrace \
484 tst-ungetc-leak-mem.out \
485 tst-ungetc-leak.mtrace \
486 tst-vfprintf-width-prec-mem.out \
487 tst-vfprintf-width-prec.mtrace \
488 # generated
489 endif
490 endif
491 endif # $(run-built-tests)
492
493 # tests-special += $(objpfx)tst-errno-manual.out
494
495 include ../Rules
496
497 # The errlist.c is built in two phases because compiler might reorder the
498 # compat_symbol directive prior the object itself and on binutils older
499 # than 2.29 it might generate object sizes different than the expected ones.
500 $(objpfx)errlist-data-aux-shared.S: errlist-data-gen.c
501 $(make-target-directory)
502 $(filter-out -c,$(compile-command.c)) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
503
504 $(objpfx)errlist-data-aux.S: errlist-data-gen.c
505 $(make-target-directory)
506 $(filter-out -c,$(compile-command.c)) $(pie-default) $(no-stack-protector) -S
507
508 ifndef no_deps
509 -include $(objpfx)errlist-data-aux.S.d $(objpfx)errlist-data-aux-shared.S.d
510 endif
511
512 $(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
513 $(addprefix $(objpfx)errlist-data, $(object-suffixes-noshared)): \
514 $(objpfx)errlist-data-aux.S
515
516 $(objpfx)siglist-aux-shared.S: siglist-gen.c
517 $(make-target-directory)
518 $(filter-out -c,$(compile-command.c)) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
519
520 $(objpfx)siglist-aux.S: siglist-gen.c
521 $(make-target-directory)
522 $(filter-out -c,$(compile-command.c)) $(pie-default) $(no-stack-protector) -S
523
524 ifndef no_deps
525 -include $(objpfx)siglist-aux.S.d $(objpfx)siglist-aux-shared.S.d
526 endif
527
528 $(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
529 $(addprefix $(objpfx)siglist, $(object-suffixes-noshared)): \
530 $(objpfx)siglist-aux.S
531
532 ifeq ($(run-built-tests),yes)
533 LOCALES := \
534 bn_BD.UTF-8 \
535 de_DE.ISO-8859-1 \
536 de_DE.UTF-8 \
537 en_US.ISO-8859-1 \
538 fa_IR.UTF-8 \
539 hi_IN.UTF-8 \
540 ja_JP.EUC-JP \
541 ps_AF.UTF-8 \
542 rw_RW.UTF-8 \
543 tg_TJ.UTF-8 \
544 unm_US.UTF-8 \
545 # LOCALES
546 include ../gen-locales.mk
547
548 $(objpfx)bug14.out: $(gen-locales)
549 $(objpfx)scanf13.out: $(gen-locales)
550 $(objpfx)test-vfprintf.out: $(gen-locales)
551 $(objpfx)tst-grouping.out: $(gen-locales)
552 $(objpfx)tst-grouping2.out: $(gen-locales)
553 $(objpfx)tst-grouping_iterator.out: $(gen-locales)
554 $(objpfx)tst-sprintf.out: $(gen-locales)
555 $(objpfx)tst-sscanf.out: $(gen-locales)
556 $(objpfx)tst-swprintf.out: $(gen-locales)
557 $(objpfx)tst-vfprintf-mbs-prec.out: $(gen-locales)
558 $(objpfx)tst-vfprintf-width-i18n.out: $(gen-locales)
559 $(objpfx)tst-grouping3.out: $(gen-locales)
560 $(objpfx)tst-scanf-to_inpunct.out: $(gen-locales)
561 endif
562
563 tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \
564 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
565 tst-vfprintf-width-prec-ENV = \
566 MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \
567 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
568 tst-vfscanf-bz34008-ENV = \
569 MALLOC_CHECK_=3 \
570 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
571 tst-printf-bz25691-ENV = \
572 MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \
573 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
574 tst-printf-fp-free-ENV = \
575 MALLOC_TRACE=$(objpfx)tst-printf-fp-free.mtrace \
576 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
577 tst-printf-fp-leak-ENV = \
578 MALLOC_TRACE=$(objpfx)tst-printf-fp-leak.mtrace \
579 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
580 tst-scanf-bz27650-ENV = \
581 MALLOC_TRACE=$(objpfx)tst-scanf-bz27650.mtrace \
582 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
583 tst-ungetc-leak-ENV = \
584 MALLOC_TRACE=$(objpfx)tst-ungetc-leak.mtrace \
585 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
586 tst-getline-ENV = \
587 MALLOC_TRACE=$(objpfx)tst-getline.mtrace \
588 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
589 tst-getline-enomem-ENV = \
590 MALLOC_TRACE=$(objpfx)tst-getline-enomem.mtrace \
591 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
592 tst-freopen2-ENV = \
593 MALLOC_TRACE=$(objpfx)tst-freopen2.mtrace \
594 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
595 tst-freopen64-2-ENV = \
596 MALLOC_TRACE=$(objpfx)tst-freopen64-2.mtrace \
597 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
598 tst-freopen3-ENV = \
599 MALLOC_TRACE=$(objpfx)tst-freopen3.mtrace \
600 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
601 tst-freopen64-3-ENV = \
602 MALLOC_TRACE=$(objpfx)tst-freopen64-3.mtrace \
603 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
604 tst-freopen4-ENV = \
605 MALLOC_TRACE=$(objpfx)tst-freopen4.mtrace \
606 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
607 tst-freopen64-4-ENV = \
608 MALLOC_TRACE=$(objpfx)tst-freopen64-4.mtrace \
609 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
610 tst-freopen5-ENV = \
611 MALLOC_TRACE=$(objpfx)tst-freopen5.mtrace \
612 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
613 tst-freopen6-ENV = \
614 MALLOC_TRACE=$(objpfx)tst-freopen6.mtrace \
615 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
616 tst-freopen64-6-ENV = \
617 MALLOC_TRACE=$(objpfx)tst-freopen64-6.mtrace \
618 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so
619
620 $(objpfx)tst-fwrite-bz29459.out: tst-fwrite-bz29459.sh $(objpfx)tst-fwrite-bz29459
621 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
622 $(evaluate-test)
623
624 $(objpfx)tst-unbputc.out: tst-unbputc.sh $(objpfx)tst-unbputc
625 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
626 $(evaluate-test)
627
628 $(objpfx)tst-printf.out: tst-printf.sh $(objpfx)tst-printf
629 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
630 $(evaluate-test)
631
632 # We can't split a quoted recipe line, so do it via an auxiliary variable.
633 make-tst-printf-format-out = \
634 AWK='$(AWK)' BASH='$(BASH)' \
635 $(BASH) $< $@ $(common-objpfx) \
636 '$(run-program-prefix-before-env) \
637 $(run-program-env) \
638 MALLOC_TRACE=$(@:.out=.mtrace) \
639 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so \
640 $(run-program-prefix-after-env)'
641 $(objpfx)tst-printf-format-%.out: \
642 tst-printf-format.sh $(foreach c,$(convs),tst-printf-format-$(c).sh) \
643 $(foreach f,$(xprintf-srcs),$(objpfx)$(f)) tst-printf-format.awk
644 $(make-tst-printf-format-out) > $@; \
645 $(evaluate-test)
646
647 # With scanf format tests reuse the same executable for all the inputs
648 # of the same data type that use a different conversion specifier each.
649 define tst-scanf-format-rule
650 $$(objpfx)tst-scanf-format-$(1)-$(2)-$(3).out: \
651 tst-scanf-format-$(2)-$(3).input $$(objpfx)tst-scanf-format-$(1)-$(2)
652 $$(make-tst-scanf-format-out) > $$@ < $$<; \
653 $$(evaluate-test)
654 endef
655 make-tst-scanf-format-out = \
656 $(test-wrapper-env) \
657 $(run-program-env) \
658 MALLOC_TRACE=$(@:.out=.mtrace) \
659 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so \
660 $(host-test-program-cmd)
661 $(foreach k,$(xscanf-kinds), \
662 $(foreach f,$(fmts-xscanf-$(k)), \
663 $(foreach p,$(xscanf-funcs), \
664 $(foreach c,$(fmt-xscanf-$(k)-convs), \
665 $(eval $(call tst-scanf-format-rule,$(p),$(c),$(f)))))))
666
667 $(objpfx)tst-printfsz-islongdouble.out: \
668 tst-printfsz-islongdouble.sh $(objpfx)tst-printfsz-islongdouble
669 $(SHELL) $^ '$(test-program-prefix)' $@; \
670 $(evaluate-test)
671
672 # We generate this source because it requires a printf invocation with
673 # 10K arguments.
674 $(objpfx)tst-printf-bz18872.c: tst-printf-bz18872.sh
675 rm -f $@ && $(BASH) $^ > [email protected] && mv [email protected] $@
676
677 $(objpfx)tst-%-mem.out: $(objpfx)tst-%.out
678 $(common-objpfx)malloc/mtrace $(objpfx)tst-$*.mtrace > $@; \
679 $(evaluate-test)
680 $(objpfx)tst-printf-format-%-mem.out: $(objpfx)tst-printf-format-%.out
681 { test -r $(objpfx)tst-printf-format-$*.mtrace \
682 || ( echo "$(objpfx)tst-printf-format-$*.mtrace does not exist"; \
683 exit 77; ) \
684 && $(common-objpfx)malloc/mtrace \
685 $(objpfx)tst-printf-format-$*.mtrace; } > $@; \
686 $(evaluate-test)
687
688 errlist-h = $(firstword $(wildcard $(addsuffix /errlist.h,$(sysdirs) .)))
689
690 $(objpfx)tst-errno-manual.out: tst-errno-manual.py \
691 $(errlist-h) \
692 $(..)manual/errno.texi
693 $(PYTHON) tst-errno-manual.py -m $(..)manual/errno.texi \
694 -e $(errlist-h) > $@; \
695 $(evaluate-test)
696
697 CFLAGS-vfprintf.c += -Wno-uninitialized
698 CFLAGS-vfwprintf.c += -Wno-uninitialized
699
700 CFLAGS-tmpfile.c += -fexceptions
701 CFLAGS-tmpfile64.c += -fexceptions
702 CFLAGS-tempname.c += -fexceptions
703 CFLAGS-psignal.c += -fexceptions
704 CFLAGS-vprintf.c += -fexceptions
705 CFLAGS-cuserid.c += -fexceptions
706
707 CFLAGS-vfprintf.c += -fexceptions
708 CFLAGS-fprintf.c += -fexceptions
709 CFLAGS-printf.c += -fexceptions
710 CFLAGS-vfwprintf.c += -fexceptions
711 CFLAGS-vfscanf.c += -fexceptions
712 CFLAGS-vfwscanf.c += -fexceptions
713 CFLAGS-fscanf.c += -fexceptions
714 CFLAGS-scanf.c += -fexceptions
715 CFLAGS-isoc99_vfscanf.c += -fexceptions
716 CFLAGS-isoc99_vscanf.c += -fexceptions
717 CFLAGS-isoc99_fscanf.c += -fexceptions
718 CFLAGS-isoc99_scanf.c += -fexceptions
719 CFLAGS-isoc23_vfscanf.c += -fexceptions
720 CFLAGS-isoc23_vscanf.c += -fexceptions
721 CFLAGS-isoc23_fscanf.c += -fexceptions
722 CFLAGS-isoc23_scanf.c += -fexceptions
723
724 # Called during static library initialization, so turn stack-protection
725 # off for non-shared builds.
726 CFLAGS-_itoa.o = $(no-stack-protector)
727 CFLAGS-_itoa.op = $(no-stack-protector)
728 CFLAGS-_fitoa_word.o = $(no-stack-protector)
729 CFLAGS-_fitoa_word.op = $(no-stack-protector)
730
731 CFLAGS-scanf13.c += $(test-config-cflags-wno-fortify-source)
732
733 # scanf18.c and scanf19.c test a deprecated extension which is no
734 # longer visible under most conformance levels; see the source files
735 # for more detail.
736 CFLAGS-scanf18.c += -std=gnu89
737 CFLAGS-scanf19.c += -std=gnu89
738
739 CFLAGS-bug3.c += -DOBJPFX=\"$(objpfx)\"
740 CFLAGS-bug4.c += -DOBJPFX=\"$(objpfx)\"
741 CFLAGS-bug5.c += -DOBJPFX=\"$(objpfx)\"
742 CFLAGS-test-fseek.c += -DOBJPFX=\"$(objpfx)\"
743 CFLAGS-test-popen.c += -DOBJPFX=\"$(objpfx)\"
744 CFLAGS-test_rdwr.c += -DOBJPFX=\"$(objpfx)\"
745
746 # tst-gets.c tests a deprecated function.
747 CFLAGS-tst-gets.c += -Wno-deprecated-declarations
748
749 # BZ #11319 was first fixed for regular vdprintf, then reopened because
750 # the fortified version had the same bug.
751 CFLAGS-tst-bz11319-fortify2.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
752
753 CFLAGS-tst-memstream-string.c += -fno-builtin-fprintf
754
755 # Some versions of GCC supported for building glibc do not support -std=c23
756 # (added in GCC 14), or the older name -std=c2x (added in GCC 9), so
757 # the test for that version uses -std=c11 and then _ISOC23_SOURCE is defined in
758 # the test as needed.
759 CFLAGS-tst-scanf-binary-c11.c += -std=c11 -DOBJPFX=\"$(objpfx)\"
760 CFLAGS-tst-scanf-binary-c23.c += -std=c11 -DOBJPFX=\"$(objpfx)\"
761 CFLAGS-tst-scanf-binary-gnu11.c += -std=gnu11 -DOBJPFX=\"$(objpfx)\"
762 CFLAGS-tst-scanf-binary-gnu89.c += -std=gnu89 -DOBJPFX=\"$(objpfx)\"
763
764 CPPFLAGS += $(libio-mtsafe)
765
766 make-tst-freopen4-out = \
767 $(run-program-prefix-before-env) \
768 $(run-program-env) \
769 MALLOC_TRACE=$(@:.out=.mtrace) \
770 LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so \
771 $(run-program-prefix-after-env) $<
772
773 freopen4-temp-dir-before = warning: could not remove temporary file:
774 freopen4-temp-dir-after = : No such file or directory
775
776 $(objpfx)tst-freopen4.out: $(objpfx)tst-freopen4
777 $(make-tst-freopen4-out) > $@ && \
778 grep "$(freopen4-temp-dir-before)" $@ \
779 | sed -e "s/$(freopen4-temp-dir-before)//; s/$(freopen4-temp-dir-after)//" \
780 | xargs rm -rf; \
781 $(evaluate-test)
782
783 $(objpfx)tst-freopen64-4.out: $(objpfx)tst-freopen64-4
784 $(make-tst-freopen4-out) > $@ && \
785 grep "$(freopen4-temp-dir-before)" $@ \
786 | sed -e "s/$(freopen4-temp-dir-before)//; s/$(freopen4-temp-dir-after)//" \
787 | xargs rm -rf; \
788 $(evaluate-test)
789
790 $(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
791 $(test-program-cmd) > $@ 2>&1; \
792 $(evaluate-test)
793
794 $(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
795 cmp $^ > $@; \
796 $(evaluate-test)
797
798 CFLAGS-tst-setvbuf2.c += -DIND_PROC=\"$(objpfx)tst-setvbuf2-ind\"
799 $(objpfx)tst-setvbuf2-ind : $(objpfx)tst-setvbuf2-ind.o $(shared-thread-library)
800 $(objpfx)tst-setvbuf2.out: $(objpfx)tst-setvbuf2-ind
801 $(objpfx)tst-setvbuf2 : $(shared-thread-library)
802
803 $(objpfx)tst-printf-round: $(libm)
804 $(objpfx)tst-scanf-round: $(libm)
805
806 # With scanf format tests real conversions depend on libm.
807 define tst-scanf-format-libm-dep
808 $$(objpfx)tst-scanf-format-$(1)-$(2): $$(libm)
809 endef
810 $(foreach p,$(xscanf-funcs), \
811 $(foreach c,$(fmt-xscanf-real-convs), \
812 $(eval $(call tst-scanf-format-libm-dep,$(p),$(c)))))
813
814 $(objpfx)tst-freopen7: $(shared-thread-library)
815 $(objpfx)tst-freopen64-7: $(shared-thread-library)