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 \
100 translated_number_width \
110 wprintf_buffer_as_file \
111 wprintf_buffer_done \
112 wprintf_buffer_flush \
113 wprintf_buffer_pad_1 \
114 wprintf_buffer_putc_1 \
115 wprintf_buffer_puts_1 \
116 wprintf_buffer_to_file \
117 wprintf_buffer_write \
118 wprintf_function_invoke \
121 # Exclude fortified routines from being built with _FORTIFY_SOURCE
122 routines_no_fortify
+= \
132 # routines_no_fortify
206 tst-bz11319-fortify2 \
226 tst-memstream-string \
243 tst-scanf-binary-c11 \
244 tst-scanf-binary-c23 \
245 tst-scanf-binary-gnu11 \
246 tst-scanf-binary-gnu89 \
249 tst-scanf-to_inpunct \
261 tst-vfprintf-mbs-prec \
262 tst-vfprintf-user-type \
263 tst-vfprintf-width-i18n \
264 tst-vfprintf-width-prec \
265 tst-vfprintf-width-prec-alloc \
278 errlist-data-aux-shared.S \
280 siglist-aux-shared.S \
285 tst-grouping_iterator \
290 tst-printfsz-islongdouble \
294 ifeq ($(run-built-tests
),yes
)
296 $(objpfx
)tst-printf-bz18872-mem.out \
297 $(objpfx
)tst-printf-bz25691-mem.out \
298 $(objpfx
)tst-printf-fp-free-mem.out \
299 $(objpfx
)tst-printf-fp-leak-mem.out \
300 $(objpfx
)tst-printf.out \
301 $(objpfx
)tst-printfsz-islongdouble.out \
302 $(objpfx
)tst-setvbuf1-cmp.out \
303 $(objpfx
)tst-unbputc.out \
304 $(objpfx
)tst-vfprintf-width-prec-mem.out \
308 tst-printf-bz18872-mem.out \
309 tst-printf-bz18872.c \
310 tst-printf-bz18872.mtrace \
311 tst-printf-bz25691-mem.out \
312 tst-printf-bz25691.mtrace \
313 tst-printf-fp-free-mem.out \
314 tst-printf-fp-free.mtrace \
315 tst-printf-fp-leak-mem.out \
316 tst-printf-fp-leak.mtrace \
317 tst-vfprintf-width-prec-mem.out \
318 tst-vfprintf-width-prec.mtrace \
320 endif # $(run-built-tests)
322 tests-special
+= $(objpfx
)tst-errno-manual.out
326 # The errlist.c is built in two phases because compiler might reorder the
327 # compat_symbol directive prior the object itself and on binutils older
328 # than 2.29 it might generate object sizes different than the expected ones.
329 $(objpfx
)errlist-data-aux-shared.S
: errlist-data-gen.c
330 $(make-target-directory
)
331 $(compile-command.c
) $(pic-cppflags
) $(pic-ccflag
) $(no-stack-protector
) -S
333 $(objpfx
)errlist-data-aux.S
: errlist-data-gen.c
334 $(make-target-directory
)
335 $(compile-command.c
) $(pie-default
) $(no-stack-protector
) -S
338 -include $(objpfx
)errlist-data-aux.S.d
$(objpfx
)errlist-data-aux-shared.S.d
341 $(objpfx
)errlist-data.os
: $(objpfx
)errlist-data-aux-shared.S
342 $(addprefix $(objpfx
)errlist-data
, $(object-suffixes-noshared
)): \
343 $(objpfx
)errlist-data-aux.S
345 $(objpfx
)siglist-aux-shared.S
: siglist-gen.c
346 $(make-target-directory
)
347 $(compile-command.c
) $(pic-cppflags
) $(pic-ccflag
) $(no-stack-protector
) -S
349 $(objpfx
)siglist-aux.S
: siglist-gen.c
350 $(make-target-directory
)
351 $(compile-command.c
) $(pie-default
) $(no-stack-protector
) -S
354 -include $(objpfx
)siglist-aux.S.d
$(objpfx
)siglist-aux-shared.S.d
357 $(objpfx
)siglist.os
: $(objpfx
)siglist-aux-shared.S
358 $(addprefix $(objpfx
)siglist
, $(object-suffixes-noshared
)): \
359 $(objpfx
)siglist-aux.S
361 ifeq ($(run-built-tests
),yes
)
375 include ..
/gen-locales.mk
377 $(objpfx
)bug14.out
: $(gen-locales
)
378 $(objpfx
)scanf13.out
: $(gen-locales
)
379 $(objpfx
)test-vfprintf.out
: $(gen-locales
)
380 $(objpfx
)tst-grouping.out
: $(gen-locales
)
381 $(objpfx
)tst-grouping2.out
: $(gen-locales
)
382 $(objpfx
)tst-grouping_iterator.out
: $(gen-locales
)
383 $(objpfx
)tst-sprintf.out
: $(gen-locales
)
384 $(objpfx
)tst-sscanf.out
: $(gen-locales
)
385 $(objpfx
)tst-swprintf.out
: $(gen-locales
)
386 $(objpfx
)tst-vfprintf-mbs-prec.out
: $(gen-locales
)
387 $(objpfx
)tst-vfprintf-width-i18n.out
: $(gen-locales
)
388 $(objpfx
)tst-grouping3.out
: $(gen-locales
)
389 $(objpfx
)tst-scanf-to_inpunct.out
: $(gen-locales
)
392 tst-printf-bz18872-ENV
= MALLOC_TRACE
=$(objpfx
)tst-printf-bz18872.mtrace \
393 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
394 tst-vfprintf-width-prec-ENV
= \
395 MALLOC_TRACE
=$(objpfx
)tst-vfprintf-width-prec.mtrace \
396 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
397 tst-printf-bz25691-ENV
= \
398 MALLOC_TRACE
=$(objpfx
)tst-printf-bz25691.mtrace \
399 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
400 tst-printf-fp-free-ENV
= \
401 MALLOC_TRACE
=$(objpfx
)tst-printf-fp-free.mtrace \
402 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
403 tst-printf-fp-leak-ENV
= \
404 MALLOC_TRACE
=$(objpfx
)tst-printf-fp-leak.mtrace \
405 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
407 $(objpfx
)tst-unbputc.out
: tst-unbputc.sh
$(objpfx
)tst-unbputc
408 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix)'; \
411 $(objpfx
)tst-printf.out
: tst-printf.sh
$(objpfx
)tst-printf
412 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix)'; \
415 $(objpfx
)tst-printfsz-islongdouble.out
: \
416 tst-printfsz-islongdouble.sh
$(objpfx
)tst-printfsz-islongdouble
417 $(SHELL
) $^
'$(test-program-prefix)' $@
; \
420 # We generate this source because it requires a printf invocation with
422 $(objpfx
)tst-printf-bz18872.c
: tst-printf-bz18872.sh
423 rm -f
$@
&& $(BASH
) $^
> $@.new
&& mv
$@.new
$@
425 $(objpfx
)tst-
%-mem.out
: $(objpfx
)tst-
%.out
426 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-
$*.mtrace
> $@
; \
429 errlist-h
= $(firstword $(wildcard $(addsuffix /errlist.h
,$(sysdirs
) .
)))
431 $(objpfx
)tst-errno-manual.out
: tst-errno-manual.py \
433 $(..
)manual
/errno.texi
434 $(PYTHON
) tst-errno-manual.py
-m
$(..
)manual
/errno.texi \
435 -e
$(errlist-h
) > $@
; \
438 CFLAGS-vfprintf.c
+= -Wno-uninitialized
439 CFLAGS-vfwprintf.c
+= -Wno-uninitialized
441 CFLAGS-tmpfile.c
+= -fexceptions
442 CFLAGS-tmpfile64.c
+= -fexceptions
443 CFLAGS-tempname.c
+= -fexceptions
444 CFLAGS-psignal.c
+= -fexceptions
445 CFLAGS-vprintf.c
+= -fexceptions
446 CFLAGS-cuserid.c
+= -fexceptions
448 CFLAGS-vfprintf.c
+= -fexceptions
449 CFLAGS-fprintf.c
+= -fexceptions
450 CFLAGS-printf.c
+= -fexceptions
451 CFLAGS-vfwprintf.c
+= -fexceptions
452 CFLAGS-vfscanf.c
+= -fexceptions
453 CFLAGS-vfwscanf.c
+= -fexceptions
454 CFLAGS-fscanf.c
+= -fexceptions
455 CFLAGS-scanf.c
+= -fexceptions
456 CFLAGS-isoc99_vfscanf.c
+= -fexceptions
457 CFLAGS-isoc99_vscanf.c
+= -fexceptions
458 CFLAGS-isoc99_fscanf.c
+= -fexceptions
459 CFLAGS-isoc99_scanf.c
+= -fexceptions
460 CFLAGS-isoc23_vfscanf.c
+= -fexceptions
461 CFLAGS-isoc23_vscanf.c
+= -fexceptions
462 CFLAGS-isoc23_fscanf.c
+= -fexceptions
463 CFLAGS-isoc23_scanf.c
+= -fexceptions
465 CFLAGS-dprintf.c
+= $(config-cflags-wno-ignored-attributes
)
467 # Called during static library initialization, so turn stack-protection
468 # off for non-shared builds.
469 CFLAGS-_itoa.o
= $(no-stack-protector
)
470 CFLAGS-_itoa.op
= $(no-stack-protector
)
472 # scanf18.c and scanf19.c test a deprecated extension which is no
473 # longer visible under most conformance levels; see the source files
475 CFLAGS-scanf18.c
+= -std
=gnu89
476 CFLAGS-scanf19.c
+= -std
=gnu89
478 CFLAGS-bug3.c
+= -DOBJPFX
=\"$(objpfx
)\"
479 CFLAGS-bug4.c
+= -DOBJPFX
=\"$(objpfx
)\"
480 CFLAGS-bug5.c
+= -DOBJPFX
=\"$(objpfx
)\"
481 CFLAGS-test-fseek.c
+= -DOBJPFX
=\"$(objpfx
)\"
482 CFLAGS-test-popen.c
+= -DOBJPFX
=\"$(objpfx
)\"
483 CFLAGS-test_rdwr.c
+= -DOBJPFX
=\"$(objpfx
)\"
485 # tst-gets.c tests a deprecated function.
486 CFLAGS-tst-gets.c
+= -Wno-deprecated-declarations
488 # BZ #11319 was first fixed for regular vdprintf, then reopened because
489 # the fortified version had the same bug.
490 CFLAGS-tst-bz11319-fortify2.c
+= $(no-fortify-source
),-D_FORTIFY_SOURCE
=2
492 CFLAGS-tst-memstream-string.c
+= -fno-builtin-fprintf
494 # Some versions of GCC supported for building glibc do not support -std=c23
495 # (added in GCC 14), or the older name -std=c2x (added in GCC 9), so
496 # the test for that version uses -std=c11 and then _ISOC23_SOURCE is defined in
497 # the test as needed.
498 CFLAGS-tst-scanf-binary-c11.c
+= -std
=c11
-DOBJPFX
=\"$(objpfx
)\"
499 CFLAGS-tst-scanf-binary-c23.c
+= -std
=c11
-DOBJPFX
=\"$(objpfx
)\"
500 CFLAGS-tst-scanf-binary-gnu11.c
+= -std
=gnu11
-DOBJPFX
=\"$(objpfx
)\"
501 CFLAGS-tst-scanf-binary-gnu89.c
+= -std
=gnu89
-DOBJPFX
=\"$(objpfx
)\"
503 CPPFLAGS
+= $(libio-mtsafe
)
505 $(objpfx
)tst-setvbuf1.out
: /dev
/null
$(objpfx
)tst-setvbuf1
506 $(test-program-cmd
) > $@
2>&1; \
509 $(objpfx
)tst-setvbuf1-cmp.out
: tst-setvbuf1.expect
$(objpfx
)tst-setvbuf1.out
513 $(objpfx
)tst-printf-round
: $(libm
)
514 $(objpfx
)tst-scanf-round
: $(libm
)