]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdio-common/Makefile
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / stdio-common / Makefile
CommitLineData
dff8da6b 1# Copyright (C) 1991-2024 Free Software Foundation, Inc.
deab9dea
RM
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
41bdb6e2
AJ
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.
deab9dea
RM
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
41bdb6e2 12# Lesser General Public License for more details.
deab9dea 13
41bdb6e2 14# You should have received a copy of the GNU Lesser General Public
59ba27a6 15# License along with the GNU C Library; if not, see
5a82c748 16# <https://www.gnu.org/licenses/>.
deab9dea
RM
17
18#
19# Specific makefile for stdio-common.
20#
21subdir := stdio-common
22
a5f891ac
JM
23include ../Makeconfig
24
c3004417
CD
25headers := \
26 bits/printf-ldbl.h \
27 bits/stdio_lim.h \
28 printf.h \
29 stdio_ext.h \
30 # headers
deab9dea 31
46c75c9a
FW
32routines := \
33 _itoa \
34 _itowa \
35 asprintf \
36 ctermid \
37 cuserid \
38 dprintf \
39 flockfile \
40 fprintf \
41 fscanf \
42 ftrylockfile \
43 funlockfile \
44 gentempfd \
45 getline \
46 getw \
ffde06c9 47 grouping_iterator \
46c75c9a 48 iovfscanf \
dee2bea0
JM
49 isoc23_fscanf \
50 isoc23_scanf \
51 isoc23_sscanf \
52 isoc23_vfscanf \
53 isoc23_vscanf \
54 isoc23_vsscanf \
c3004417
CD
55 isoc99_fscanf \
56 isoc99_scanf \
57 isoc99_sscanf \
58 isoc99_vfscanf \
59 isoc99_vscanf \
60 isoc99_vsscanf \
46c75c9a
FW
61 itoa-digits \
62 itoa-udigits \
63 itowa-digits \
64 perror \
65 printf \
66 printf-prs \
659fe9fd
FW
67 printf_buffer_as_file \
68 printf_buffer_done \
69 printf_buffer_flush \
70 printf_buffer_pad_1 \
71 printf_buffer_putc_1 \
72 printf_buffer_puts_1 \
73 printf_buffer_to_file \
74 printf_buffer_write \
46c75c9a
FW
75 printf_fp \
76 printf_fphex \
c7bf2e99 77 printf_function_invoke \
46c75c9a
FW
78 printf_size \
79 psiginfo \
80 psignal \
81 putw \
82 reg-modifier \
83 reg-printf \
84 reg-type \
85 remove \
86 rename \
87 renameat \
88 renameat2 \
89 scanf \
90 snprintf \
91 sprintf \
92 sscanf \
93 tempnam \
94 tempname \
95 tmpfile \
96 tmpfile64 \
97 tmpnam \
98 tmpnam_r \
46378560 99 translated_number_width \
46c75c9a
FW
100 vfprintf \
101 vfprintf-internal \
102 vfscanf \
103 vfscanf-internal \
104 vfwprintf \
105 vfwprintf-internal \
106 vfwscanf \
107 vfwscanf-internal \
108 vprintf \
659fe9fd
FW
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 \
c7bf2e99 117 wprintf_function_invoke \
46c75c9a
FW
118 # routines
119
20c894d2
FB
120# Exclude fortified routines from being built with _FORTIFY_SOURCE
121routines_no_fortify += \
122 asprintf \
123 dprintf \
124 fprintf \
125 printf \
126 snprintf \
127 sprintf \
128 vfprintf \
129 vfwprintf \
130 vprintf \
131 # routines_no_fortify
132
46c75c9a
FW
133aux := \
134 errlist \
900fa257 135 errlist-data \
592b6d00 136 errname \
46c75c9a
FW
137 fxprintf \
138 printf-parsemb \
139 printf-parsewc \
140 siglist \
141 # aux
142
143tests := \
144 bug-vfprintf-nargs \
145 bug1 \
b9125aea
CD
146 bug3 \
147 bug4 \
148 bug5 \
149 bug6 \
150 bug7 \
151 bug8 \
152 bug9 \
46c75c9a
FW
153 bug10 \
154 bug11 \
155 bug12 \
156 bug13 \
157 bug14 \
158 bug16 \
159 bug17 \
160 bug18 \
161 bug18a \
162 bug19 \
163 bug19a \
164 bug2 \
165 bug20 \
166 bug21 \
167 bug22 \
168 bug23 \
46c75c9a
FW
169 bug24 \
170 bug25 \
171 bug26 \
b9125aea
CD
172 bug27 \
173 bug28 \
174 bug29 \
46c75c9a
FW
175 errnobug \
176 scanf1 \
b9125aea
CD
177 scanf2 \
178 scanf3 \
179 scanf4 \
180 scanf5 \
181 scanf7 \
182 scanf8 \
183 scanf9 \
46c75c9a
FW
184 scanf10 \
185 scanf11 \
186 scanf12 \
187 scanf13 \
188 scanf14 \
46c75c9a
FW
189 scanf15 \
190 scanf16 \
46c75c9a 191 scanf17 \
b9125aea
CD
192 scanf18 \
193 scanf19 \
46c75c9a
FW
194 temptest \
195 test-fseek \
196 test-fwrite \
197 test-popen \
198 test-strerr \
199 test-vfprintf \
200 test_rdwr \
201 tfformat \
202 tiformat \
203 tllformat \
204 tst-bz11319 \
205 tst-bz11319-fortify2 \
206 tst-cookie \
f5c65fa9 207 tst-dprintf-length \
46c75c9a
FW
208 tst-fdopen \
209 tst-ferror \
210 tst-fgets \
211 tst-fileno \
212 tst-fmemopen \
213 tst-fmemopen2 \
214 tst-fmemopen3 \
215 tst-fmemopen4 \
216 tst-fphex \
217 tst-fphex-wide \
218 tst-fseek \
219 tst-fwrite \
220 tst-gets \
221 tst-grouping \
ca6466e8 222 tst-grouping2 \
c980549c 223 tst-grouping3 \
46c75c9a 224 tst-long-dbl-fphex \
0060a6de 225 tst-memstream-string \
46c75c9a
FW
226 tst-obprintf \
227 tst-perror \
228 tst-popen \
229 tst-popen2 \
230 tst-printf-binary \
231 tst-printf-bz18872 \
232 tst-printf-bz25691 \
233 tst-printf-fp-free \
234 tst-printf-fp-leak \
5f83b267 235 tst-printf-intn \
2f39e44a 236 tst-printf-oct \
46c75c9a
FW
237 tst-printf-round \
238 tst-printfsz \
239 tst-put-error \
240 tst-renameat2 \
241 tst-rndseek \
dee2bea0
JM
242 tst-scanf-binary-c11 \
243 tst-scanf-binary-c2x \
244 tst-scanf-binary-gnu11 \
245 tst-scanf-binary-gnu89 \
cdbf8229 246 tst-scanf-intn \
46c75c9a 247 tst-scanf-round \
320ac7ee 248 tst-scanf-to_inpunct \
46c75c9a
FW
249 tst-setvbuf1 \
250 tst-sprintf \
251 tst-sprintf-errno \
252 tst-sprintf2 \
253 tst-sprintf3 \
254 tst-sscanf \
255 tst-swprintf \
256 tst-swscanf \
257 tst-tmpnam \
258 tst-ungetc \
259 tst-unlockedio \
260 tst-vfprintf-mbs-prec \
261 tst-vfprintf-user-type \
c3004417 262 tst-vfprintf-width-i18n \
46c75c9a
FW
263 tst-vfprintf-width-prec \
264 tst-vfprintf-width-prec-alloc \
265 tst-wc-printf \
266 tstdiomisc \
267 tstgetln \
268 tstscanf \
269 xbug \
270 # tests
03992356 271
e7223fa1
AZ
272tests-container += \
273 tst-popen3
c3004417 274 # tests-container
e7223fa1 275
900fa257
AZ
276generated += \
277 errlist-data-aux-shared.S \
278 errlist-data-aux.S \
6fad891d
AZ
279 siglist-aux-shared.S \
280 siglist-aux.S \
900fa257 281 # generated
deab9dea 282
ffde06c9
FW
283tests-internal = \
284 tst-grouping_iterator \
285 # tests-internal
286
c3004417
CD
287test-srcs = \
288 tst-printf \
289 tst-printfsz-islongdouble \
290 tst-unbputc \
291 # test-srcs
6f98fd7e 292
f214606a 293ifeq ($(run-built-tests),yes)
46c75c9a
FW
294tests-special += \
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 \
304 # tests-special
305
306generated += \
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 \
318 # generated
319endif # $(run-built-tests)
f214606a 320
f13d2601
AZ
321tests-special += $(objpfx)tst-errno-manual.out
322
deab9dea 323include ../Rules
0793d348 324
900fa257
AZ
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
331
332$(objpfx)errlist-data-aux.S: errlist-data-gen.c
333 $(make-target-directory)
334 $(compile-command.c) $(pie-default) $(no-stack-protector) -S
335
3d7d5c10
AS
336ifndef no_deps
337-include $(objpfx)errlist-data-aux.S.d $(objpfx)errlist-data-aux-shared.S.d
338endif
339
900fa257 340$(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
a46956e6
AS
341$(addprefix $(objpfx)errlist-data, $(object-suffixes-noshared)): \
342 $(objpfx)errlist-data-aux.S
900fa257 343
6fad891d
AZ
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
347
348$(objpfx)siglist-aux.S: siglist-gen.c
349 $(make-target-directory)
350 $(compile-command.c) $(pie-default) $(no-stack-protector) -S
351
3d7d5c10
AS
352ifndef no_deps
353-include $(objpfx)siglist-aux.S.d $(objpfx)siglist-aux-shared.S.d
354endif
355
6fad891d 356$(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
a46956e6
AS
357$(addprefix $(objpfx)siglist, $(object-suffixes-noshared)): \
358 $(objpfx)siglist-aux.S
6fad891d 359
f881f6ff 360ifeq ($(run-built-tests),yes)
46c75c9a
FW
361LOCALES := \
362 de_DE.ISO-8859-1 \
363 de_DE.UTF-8 \
364 en_US.ISO-8859-1 \
320ac7ee 365 fa_IR.UTF-8 \
21bb8382 366 hi_IN.UTF-8 \
e297d33c 367 ja_JP.EUC-JP \
46c75c9a 368 ps_AF.UTF-8 \
ffde06c9 369 tg_TJ.UTF-8 \
c3004417 370 # LOCALES
f881f6ff
AS
371include ../gen-locales.mk
372
373$(objpfx)bug14.out: $(gen-locales)
374$(objpfx)scanf13.out: $(gen-locales)
375$(objpfx)test-vfprintf.out: $(gen-locales)
376$(objpfx)tst-grouping.out: $(gen-locales)
ca6466e8 377$(objpfx)tst-grouping2.out: $(gen-locales)
ffde06c9 378$(objpfx)tst-grouping_iterator.out: $(gen-locales)
f881f6ff
AS
379$(objpfx)tst-sprintf.out: $(gen-locales)
380$(objpfx)tst-sscanf.out: $(gen-locales)
381$(objpfx)tst-swprintf.out: $(gen-locales)
84d8c5bc 382$(objpfx)tst-vfprintf-mbs-prec.out: $(gen-locales)
21bb8382 383$(objpfx)tst-vfprintf-width-i18n.out: $(gen-locales)
c980549c 384$(objpfx)tst-grouping3.out: $(gen-locales)
320ac7ee 385$(objpfx)tst-scanf-to_inpunct.out: $(gen-locales)
f881f6ff
AS
386endif
387
2d2d9f2b
SP
388tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \
389 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
fdcf1c94 390tst-vfprintf-width-prec-ENV = \
2d2d9f2b
SP
391 MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \
392 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
910a835d 393tst-printf-bz25691-ENV = \
2d2d9f2b
SP
394 MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \
395 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
ede56038 396tst-printf-fp-free-ENV = \
2d2d9f2b
SP
397 MALLOC_TRACE=$(objpfx)tst-printf-fp-free.mtrace \
398 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
90663e9c 399tst-printf-fp-leak-ENV = \
2d2d9f2b
SP
400 MALLOC_TRACE=$(objpfx)tst-printf-fp-leak.mtrace \
401 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
560b0446 402
57c69bef 403$(objpfx)tst-unbputc.out: tst-unbputc.sh $(objpfx)tst-unbputc
8f8052c2 404 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
f0881698 405 $(evaluate-test)
6f98fd7e 406
57c69bef 407$(objpfx)tst-printf.out: tst-printf.sh $(objpfx)tst-printf
8f8052c2 408 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
f0881698 409 $(evaluate-test)
560b0446 410
b7b88cea
GG
411$(objpfx)tst-printfsz-islongdouble.out: \
412 tst-printfsz-islongdouble.sh $(objpfx)tst-printfsz-islongdouble
413 $(SHELL) $^ '$(test-program-prefix)' $@; \
414 $(evaluate-test)
415
560b0446
PP
416# We generate this source because it requires a printf invocation with
417# 10K arguments.
418$(objpfx)tst-printf-bz18872.c: tst-printf-bz18872.sh
419 rm -f $@ && $(BASH) $^ > $@.new && mv $@.new $@
420
fdcf1c94
FW
421$(objpfx)tst-%-mem.out: $(objpfx)tst-%.out
422 $(common-objpfx)malloc/mtrace $(objpfx)tst-$*.mtrace > $@; \
560b0446 423 $(evaluate-test)
95b04192 424
f13d2601
AZ
425errlist-h = $(firstword $(wildcard $(addsuffix /errlist.h,$(sysdirs) .)))
426
427$(objpfx)tst-errno-manual.out: tst-errno-manual.py \
428 $(errlist-h) \
429 $(..)manual/errno.texi
430 $(PYTHON) tst-errno-manual.py -m $(..)manual/errno.texi \
431 -e $(errlist-h) > $@; \
432 $(evaluate-test)
433
36975e8e
L
434CFLAGS-vfprintf.c += -Wno-uninitialized
435CFLAGS-vfwprintf.c += -Wno-uninitialized
ec4b0518 436
36975e8e
L
437CFLAGS-tmpfile.c += -fexceptions
438CFLAGS-tmpfile64.c += -fexceptions
439CFLAGS-tempname.c += -fexceptions
440CFLAGS-psignal.c += -fexceptions
441CFLAGS-vprintf.c += -fexceptions
442CFLAGS-cuserid.c += -fexceptions
874aa523 443
56ab3869
JM
444CFLAGS-vfprintf.c += -fexceptions
445CFLAGS-fprintf.c += -fexceptions
446CFLAGS-printf.c += -fexceptions
447CFLAGS-vfwprintf.c += -fexceptions
448CFLAGS-vfscanf.c += -fexceptions
449CFLAGS-vfwscanf.c += -fexceptions
450CFLAGS-fscanf.c += -fexceptions
451CFLAGS-scanf.c += -fexceptions
452CFLAGS-isoc99_vfscanf.c += -fexceptions
453CFLAGS-isoc99_vscanf.c += -fexceptions
454CFLAGS-isoc99_fscanf.c += -fexceptions
455CFLAGS-isoc99_scanf.c += -fexceptions
dee2bea0
JM
456CFLAGS-isoc23_vfscanf.c += -fexceptions
457CFLAGS-isoc23_vscanf.c += -fexceptions
458CFLAGS-isoc23_fscanf.c += -fexceptions
459CFLAGS-isoc23_scanf.c += -fexceptions
73299943 460
8d98c7c0
AZ
461CFLAGS-dprintf.c += $(config-cflags-wno-ignored-attributes)
462
434eca87
AZ
463# Called during static library initialization, so turn stack-protection
464# off for non-shared builds.
465CFLAGS-_itoa.o = $(no-stack-protector)
466CFLAGS-_itoa.op = $(no-stack-protector)
467
b9125aea 468# scanf18.c and scanf19.c test a deprecated extension which is no
03992356
ZW
469# longer visible under most conformance levels; see the source files
470# for more detail.
b9125aea
CD
471CFLAGS-scanf18.c += -std=gnu89
472CFLAGS-scanf19.c += -std=gnu89
874aa523 473
27f10a09
JM
474CFLAGS-bug3.c += -DOBJPFX=\"$(objpfx)\"
475CFLAGS-bug4.c += -DOBJPFX=\"$(objpfx)\"
476CFLAGS-bug5.c += -DOBJPFX=\"$(objpfx)\"
477CFLAGS-test-fseek.c += -DOBJPFX=\"$(objpfx)\"
478CFLAGS-test-popen.c += -DOBJPFX=\"$(objpfx)\"
479CFLAGS-test_rdwr.c += -DOBJPFX=\"$(objpfx)\"
480
7caa5054
ZW
481# tst-gets.c tests a deprecated function.
482CFLAGS-tst-gets.c += -Wno-deprecated-declarations
483
4e2f43f8
ZW
484# BZ #11319 was first fixed for regular vdprintf, then reopened because
485# the fortified version had the same bug.
20c894d2 486CFLAGS-tst-bz11319-fortify2.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2
4e2f43f8 487
0060a6de
FW
488CFLAGS-tst-memstream-string.c += -fno-builtin-fprintf
489
dee2bea0
JM
490# Some versions of GCC supported for building glibc do not support -std=c2x, so
491# the test for that version uses -std=c11 and then _ISOC2X_SOURCE is defined in
492# the test as needed.
493CFLAGS-tst-scanf-binary-c11.c += -std=c11 -DOBJPFX=\"$(objpfx)\"
494CFLAGS-tst-scanf-binary-c2x.c += -std=c11 -DOBJPFX=\"$(objpfx)\"
495CFLAGS-tst-scanf-binary-gnu11.c += -std=gnu11 -DOBJPFX=\"$(objpfx)\"
496CFLAGS-tst-scanf-binary-gnu89.c += -std=gnu89 -DOBJPFX=\"$(objpfx)\"
497
c75ccd4c 498CPPFLAGS += $(libio-mtsafe)
75684bd7 499
6e89caf1 500$(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
f0881698
JM
501 $(test-program-cmd) > $@ 2>&1; \
502 $(evaluate-test)
6e89caf1
JM
503
504$(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
f0881698
JM
505 cmp $^ > $@; \
506 $(evaluate-test)
784761be 507
79520f4b 508$(objpfx)tst-printf-round: $(libm)
646c2833 509$(objpfx)tst-scanf-round: $(libm)