1 # Copyright (C) 1991-2024 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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/>.
19 # Specific makefile for stdio-common.
21 subdir
:= stdio-common
67 printf_buffer_as_file \
71 printf_buffer_putc_1 \
72 printf_buffer_puts_1 \
73 printf_buffer_to_file \
77 printf_function_invoke \
99 translated_number_width \
109 wprintf_buffer_as_file \
110 wprintf_buffer_done \
111 wprintf_buffer_flush \
112 wprintf_buffer_pad_1 \
113 wprintf_buffer_putc_1 \
114 wprintf_buffer_puts_1 \
115 wprintf_buffer_to_file \
116 wprintf_buffer_write \
117 wprintf_function_invoke \
120 # Exclude fortified routines from being built with _FORTIFY_SOURCE
121 routines_no_fortify
+= \
131 # routines_no_fortify
205 tst-bz11319-fortify2 \
225 tst-memstream-string \
242 tst-scanf-binary-c11 \
243 tst-scanf-binary-c23 \
244 tst-scanf-binary-gnu11 \
245 tst-scanf-binary-gnu89 \
248 tst-scanf-to_inpunct \
260 tst-vfprintf-mbs-prec \
261 tst-vfprintf-user-type \
262 tst-vfprintf-width-i18n \
263 tst-vfprintf-width-prec \
264 tst-vfprintf-width-prec-alloc \
277 errlist-data-aux-shared.S \
279 siglist-aux-shared.S \
284 tst-grouping_iterator \
289 tst-printfsz-islongdouble \
293 ifeq ($(run-built-tests
),yes
)
295 $(objpfx
)tst-printf-bz18872-mem.out \
296 $(objpfx
)tst-printf-bz25691-mem.out \
297 $(objpfx
)tst-printf-fp-free-mem.out \
298 $(objpfx
)tst-printf-fp-leak-mem.out \
299 $(objpfx
)tst-printf.out \
300 $(objpfx
)tst-printfsz-islongdouble.out \
301 $(objpfx
)tst-setvbuf1-cmp.out \
302 $(objpfx
)tst-unbputc.out \
303 $(objpfx
)tst-vfprintf-width-prec-mem.out \
307 tst-printf-bz18872-mem.out \
308 tst-printf-bz18872.c \
309 tst-printf-bz18872.mtrace \
310 tst-printf-bz25691-mem.out \
311 tst-printf-bz25691.mtrace \
312 tst-printf-fp-free-mem.out \
313 tst-printf-fp-free.mtrace \
314 tst-printf-fp-leak-mem.out \
315 tst-printf-fp-leak.mtrace \
316 tst-vfprintf-width-prec-mem.out \
317 tst-vfprintf-width-prec.mtrace \
319 endif # $(run-built-tests)
321 tests-special
+= $(objpfx
)tst-errno-manual.out
325 # The errlist.c is built in two phases because compiler might reorder the
326 # compat_symbol directive prior the object itself and on binutils older
327 # than 2.29 it might generate object sizes different than the expected ones.
328 $(objpfx
)errlist-data-aux-shared.S
: errlist-data-gen.c
329 $(make-target-directory
)
330 $(compile-command.c
) $(pic-cppflags
) $(pic-ccflag
) $(no-stack-protector
) -S
332 $(objpfx
)errlist-data-aux.S
: errlist-data-gen.c
333 $(make-target-directory
)
334 $(compile-command.c
) $(pie-default
) $(no-stack-protector
) -S
337 -include $(objpfx
)errlist-data-aux.S.d
$(objpfx
)errlist-data-aux-shared.S.d
340 $(objpfx
)errlist-data.os
: $(objpfx
)errlist-data-aux-shared.S
341 $(addprefix $(objpfx
)errlist-data
, $(object-suffixes-noshared
)): \
342 $(objpfx
)errlist-data-aux.S
344 $(objpfx
)siglist-aux-shared.S
: siglist-gen.c
345 $(make-target-directory
)
346 $(compile-command.c
) $(pic-cppflags
) $(pic-ccflag
) $(no-stack-protector
) -S
348 $(objpfx
)siglist-aux.S
: siglist-gen.c
349 $(make-target-directory
)
350 $(compile-command.c
) $(pie-default
) $(no-stack-protector
) -S
353 -include $(objpfx
)siglist-aux.S.d
$(objpfx
)siglist-aux-shared.S.d
356 $(objpfx
)siglist.os
: $(objpfx
)siglist-aux-shared.S
357 $(addprefix $(objpfx
)siglist
, $(object-suffixes-noshared
)): \
358 $(objpfx
)siglist-aux.S
360 ifeq ($(run-built-tests
),yes
)
374 include ..
/gen-locales.mk
376 $(objpfx
)bug14.out
: $(gen-locales
)
377 $(objpfx
)scanf13.out
: $(gen-locales
)
378 $(objpfx
)test-vfprintf.out
: $(gen-locales
)
379 $(objpfx
)tst-grouping.out
: $(gen-locales
)
380 $(objpfx
)tst-grouping2.out
: $(gen-locales
)
381 $(objpfx
)tst-grouping_iterator.out
: $(gen-locales
)
382 $(objpfx
)tst-sprintf.out
: $(gen-locales
)
383 $(objpfx
)tst-sscanf.out
: $(gen-locales
)
384 $(objpfx
)tst-swprintf.out
: $(gen-locales
)
385 $(objpfx
)tst-vfprintf-mbs-prec.out
: $(gen-locales
)
386 $(objpfx
)tst-vfprintf-width-i18n.out
: $(gen-locales
)
387 $(objpfx
)tst-grouping3.out
: $(gen-locales
)
388 $(objpfx
)tst-scanf-to_inpunct.out
: $(gen-locales
)
391 tst-printf-bz18872-ENV
= MALLOC_TRACE
=$(objpfx
)tst-printf-bz18872.mtrace \
392 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
393 tst-vfprintf-width-prec-ENV
= \
394 MALLOC_TRACE
=$(objpfx
)tst-vfprintf-width-prec.mtrace \
395 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
396 tst-printf-bz25691-ENV
= \
397 MALLOC_TRACE
=$(objpfx
)tst-printf-bz25691.mtrace \
398 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
399 tst-printf-fp-free-ENV
= \
400 MALLOC_TRACE
=$(objpfx
)tst-printf-fp-free.mtrace \
401 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
402 tst-printf-fp-leak-ENV
= \
403 MALLOC_TRACE
=$(objpfx
)tst-printf-fp-leak.mtrace \
404 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
406 $(objpfx
)tst-unbputc.out
: tst-unbputc.sh
$(objpfx
)tst-unbputc
407 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix)'; \
410 $(objpfx
)tst-printf.out
: tst-printf.sh
$(objpfx
)tst-printf
411 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix)'; \
414 $(objpfx
)tst-printfsz-islongdouble.out
: \
415 tst-printfsz-islongdouble.sh
$(objpfx
)tst-printfsz-islongdouble
416 $(SHELL
) $^
'$(test-program-prefix)' $@
; \
419 # We generate this source because it requires a printf invocation with
421 $(objpfx
)tst-printf-bz18872.c
: tst-printf-bz18872.sh
422 rm -f
$@
&& $(BASH
) $^
> $@.new
&& mv
$@.new
$@
424 $(objpfx
)tst-
%-mem.out
: $(objpfx
)tst-
%.out
425 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-
$*.mtrace
> $@
; \
428 errlist-h
= $(firstword $(wildcard $(addsuffix /errlist.h
,$(sysdirs
) .
)))
430 $(objpfx
)tst-errno-manual.out
: tst-errno-manual.py \
432 $(..
)manual
/errno.texi
433 $(PYTHON
) tst-errno-manual.py
-m
$(..
)manual
/errno.texi \
434 -e
$(errlist-h
) > $@
; \
437 CFLAGS-vfprintf.c
+= -Wno-uninitialized
438 CFLAGS-vfwprintf.c
+= -Wno-uninitialized
440 CFLAGS-tmpfile.c
+= -fexceptions
441 CFLAGS-tmpfile64.c
+= -fexceptions
442 CFLAGS-tempname.c
+= -fexceptions
443 CFLAGS-psignal.c
+= -fexceptions
444 CFLAGS-vprintf.c
+= -fexceptions
445 CFLAGS-cuserid.c
+= -fexceptions
447 CFLAGS-vfprintf.c
+= -fexceptions
448 CFLAGS-fprintf.c
+= -fexceptions
449 CFLAGS-printf.c
+= -fexceptions
450 CFLAGS-vfwprintf.c
+= -fexceptions
451 CFLAGS-vfscanf.c
+= -fexceptions
452 CFLAGS-vfwscanf.c
+= -fexceptions
453 CFLAGS-fscanf.c
+= -fexceptions
454 CFLAGS-scanf.c
+= -fexceptions
455 CFLAGS-isoc99_vfscanf.c
+= -fexceptions
456 CFLAGS-isoc99_vscanf.c
+= -fexceptions
457 CFLAGS-isoc99_fscanf.c
+= -fexceptions
458 CFLAGS-isoc99_scanf.c
+= -fexceptions
459 CFLAGS-isoc23_vfscanf.c
+= -fexceptions
460 CFLAGS-isoc23_vscanf.c
+= -fexceptions
461 CFLAGS-isoc23_fscanf.c
+= -fexceptions
462 CFLAGS-isoc23_scanf.c
+= -fexceptions
464 CFLAGS-dprintf.c
+= $(config-cflags-wno-ignored-attributes
)
466 # Called during static library initialization, so turn stack-protection
467 # off for non-shared builds.
468 CFLAGS-_itoa.o
= $(no-stack-protector
)
469 CFLAGS-_itoa.op
= $(no-stack-protector
)
471 # scanf18.c and scanf19.c test a deprecated extension which is no
472 # longer visible under most conformance levels; see the source files
474 CFLAGS-scanf18.c
+= -std
=gnu89
475 CFLAGS-scanf19.c
+= -std
=gnu89
477 CFLAGS-bug3.c
+= -DOBJPFX
=\"$(objpfx
)\"
478 CFLAGS-bug4.c
+= -DOBJPFX
=\"$(objpfx
)\"
479 CFLAGS-bug5.c
+= -DOBJPFX
=\"$(objpfx
)\"
480 CFLAGS-test-fseek.c
+= -DOBJPFX
=\"$(objpfx
)\"
481 CFLAGS-test-popen.c
+= -DOBJPFX
=\"$(objpfx
)\"
482 CFLAGS-test_rdwr.c
+= -DOBJPFX
=\"$(objpfx
)\"
484 # tst-gets.c tests a deprecated function.
485 CFLAGS-tst-gets.c
+= -Wno-deprecated-declarations
487 # BZ #11319 was first fixed for regular vdprintf, then reopened because
488 # the fortified version had the same bug.
489 CFLAGS-tst-bz11319-fortify2.c
+= $(no-fortify-source
),-D_FORTIFY_SOURCE
=2
491 CFLAGS-tst-memstream-string.c
+= -fno-builtin-fprintf
493 # Some versions of GCC supported for building glibc do not support -std=c23
494 # (added in GCC 14), or the older name -std=c2x (added in GCC 9), so
495 # the test for that version uses -std=c11 and then _ISOC23_SOURCE is defined in
496 # the test as needed.
497 CFLAGS-tst-scanf-binary-c11.c
+= -std
=c11
-DOBJPFX
=\"$(objpfx
)\"
498 CFLAGS-tst-scanf-binary-c23.c
+= -std
=c11
-DOBJPFX
=\"$(objpfx
)\"
499 CFLAGS-tst-scanf-binary-gnu11.c
+= -std
=gnu11
-DOBJPFX
=\"$(objpfx
)\"
500 CFLAGS-tst-scanf-binary-gnu89.c
+= -std
=gnu89
-DOBJPFX
=\"$(objpfx
)\"
502 CPPFLAGS
+= $(libio-mtsafe
)
504 $(objpfx
)tst-setvbuf1.out
: /dev
/null
$(objpfx
)tst-setvbuf1
505 $(test-program-cmd
) > $@
2>&1; \
508 $(objpfx
)tst-setvbuf1-cmp.out
: tst-setvbuf1.expect
$(objpfx
)tst-setvbuf1.out
512 $(objpfx
)tst-printf-round
: $(libm
)
513 $(objpfx
)tst-scanf-round
: $(libm
)