]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdio-common/Makefile
stdlib: Describe __cxa_finalize usage in function comment
[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 \
686d5420 95 tmpdir \
46c75c9a
FW
96 tmpfile \
97 tmpfile64 \
98 tmpnam \
99 tmpnam_r \
46378560 100 translated_number_width \
46c75c9a
FW
101 vfprintf \
102 vfprintf-internal \
103 vfscanf \
104 vfscanf-internal \
105 vfwprintf \
106 vfwprintf-internal \
107 vfwscanf \
108 vfwscanf-internal \
109 vprintf \
659fe9fd
FW
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 \
c7bf2e99 118 wprintf_function_invoke \
46c75c9a
FW
119 # routines
120
20c894d2
FB
121# Exclude fortified routines from being built with _FORTIFY_SOURCE
122routines_no_fortify += \
123 asprintf \
124 dprintf \
125 fprintf \
126 printf \
127 snprintf \
128 sprintf \
129 vfprintf \
130 vfwprintf \
131 vprintf \
132 # routines_no_fortify
133
46c75c9a
FW
134aux := \
135 errlist \
900fa257 136 errlist-data \
592b6d00 137 errname \
46c75c9a
FW
138 fxprintf \
139 printf-parsemb \
140 printf-parsewc \
141 siglist \
142 # aux
143
144tests := \
145 bug-vfprintf-nargs \
146 bug1 \
b9125aea
CD
147 bug3 \
148 bug4 \
149 bug5 \
150 bug6 \
151 bug7 \
152 bug8 \
153 bug9 \
46c75c9a
FW
154 bug10 \
155 bug11 \
156 bug12 \
157 bug13 \
158 bug14 \
159 bug16 \
160 bug17 \
161 bug18 \
162 bug18a \
163 bug19 \
164 bug19a \
165 bug2 \
166 bug20 \
167 bug21 \
168 bug22 \
169 bug23 \
46c75c9a
FW
170 bug24 \
171 bug25 \
172 bug26 \
b9125aea
CD
173 bug27 \
174 bug28 \
175 bug29 \
46c75c9a
FW
176 errnobug \
177 scanf1 \
b9125aea
CD
178 scanf2 \
179 scanf3 \
180 scanf4 \
181 scanf5 \
182 scanf7 \
183 scanf8 \
184 scanf9 \
46c75c9a
FW
185 scanf10 \
186 scanf11 \
187 scanf12 \
188 scanf13 \
189 scanf14 \
46c75c9a
FW
190 scanf15 \
191 scanf16 \
46c75c9a 192 scanf17 \
b9125aea
CD
193 scanf18 \
194 scanf19 \
46c75c9a
FW
195 temptest \
196 test-fseek \
197 test-fwrite \
198 test-popen \
199 test-strerr \
200 test-vfprintf \
201 test_rdwr \
202 tfformat \
203 tiformat \
204 tllformat \
205 tst-bz11319 \
206 tst-bz11319-fortify2 \
207 tst-cookie \
f5c65fa9 208 tst-dprintf-length \
46c75c9a
FW
209 tst-fdopen \
210 tst-ferror \
211 tst-fgets \
212 tst-fileno \
213 tst-fmemopen \
214 tst-fmemopen2 \
215 tst-fmemopen3 \
216 tst-fmemopen4 \
217 tst-fphex \
218 tst-fphex-wide \
219 tst-fseek \
220 tst-fwrite \
221 tst-gets \
222 tst-grouping \
ca6466e8 223 tst-grouping2 \
c980549c 224 tst-grouping3 \
46c75c9a 225 tst-long-dbl-fphex \
0060a6de 226 tst-memstream-string \
46c75c9a
FW
227 tst-obprintf \
228 tst-perror \
229 tst-popen \
230 tst-popen2 \
231 tst-printf-binary \
232 tst-printf-bz18872 \
233 tst-printf-bz25691 \
234 tst-printf-fp-free \
235 tst-printf-fp-leak \
5f83b267 236 tst-printf-intn \
2f39e44a 237 tst-printf-oct \
46c75c9a
FW
238 tst-printf-round \
239 tst-printfsz \
240 tst-put-error \
241 tst-renameat2 \
242 tst-rndseek \
dee2bea0 243 tst-scanf-binary-c11 \
83d8d289 244 tst-scanf-binary-c23 \
dee2bea0
JM
245 tst-scanf-binary-gnu11 \
246 tst-scanf-binary-gnu89 \
cdbf8229 247 tst-scanf-intn \
46c75c9a 248 tst-scanf-round \
320ac7ee 249 tst-scanf-to_inpunct \
46c75c9a
FW
250 tst-setvbuf1 \
251 tst-sprintf \
252 tst-sprintf-errno \
253 tst-sprintf2 \
254 tst-sprintf3 \
255 tst-sscanf \
256 tst-swprintf \
257 tst-swscanf \
258 tst-tmpnam \
259 tst-ungetc \
260 tst-unlockedio \
261 tst-vfprintf-mbs-prec \
262 tst-vfprintf-user-type \
c3004417 263 tst-vfprintf-width-i18n \
46c75c9a
FW
264 tst-vfprintf-width-prec \
265 tst-vfprintf-width-prec-alloc \
266 tst-wc-printf \
267 tstdiomisc \
268 tstgetln \
269 tstscanf \
270 xbug \
271 # tests
03992356 272
e7223fa1
AZ
273tests-container += \
274 tst-popen3
c3004417 275 # tests-container
e7223fa1 276
900fa257
AZ
277generated += \
278 errlist-data-aux-shared.S \
279 errlist-data-aux.S \
6fad891d
AZ
280 siglist-aux-shared.S \
281 siglist-aux.S \
900fa257 282 # generated
deab9dea 283
ffde06c9
FW
284tests-internal = \
285 tst-grouping_iterator \
286 # tests-internal
287
c3004417
CD
288test-srcs = \
289 tst-printf \
290 tst-printfsz-islongdouble \
291 tst-unbputc \
292 # test-srcs
6f98fd7e 293
f214606a 294ifeq ($(run-built-tests),yes)
46c75c9a
FW
295tests-special += \
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 \
305 # tests-special
306
307generated += \
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 \
319 # generated
320endif # $(run-built-tests)
f214606a 321
f13d2601
AZ
322tests-special += $(objpfx)tst-errno-manual.out
323
deab9dea 324include ../Rules
0793d348 325
900fa257
AZ
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
332
333$(objpfx)errlist-data-aux.S: errlist-data-gen.c
334 $(make-target-directory)
335 $(compile-command.c) $(pie-default) $(no-stack-protector) -S
336
3d7d5c10
AS
337ifndef no_deps
338-include $(objpfx)errlist-data-aux.S.d $(objpfx)errlist-data-aux-shared.S.d
339endif
340
900fa257 341$(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
a46956e6
AS
342$(addprefix $(objpfx)errlist-data, $(object-suffixes-noshared)): \
343 $(objpfx)errlist-data-aux.S
900fa257 344
6fad891d
AZ
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
348
349$(objpfx)siglist-aux.S: siglist-gen.c
350 $(make-target-directory)
351 $(compile-command.c) $(pie-default) $(no-stack-protector) -S
352
3d7d5c10
AS
353ifndef no_deps
354-include $(objpfx)siglist-aux.S.d $(objpfx)siglist-aux-shared.S.d
355endif
356
6fad891d 357$(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
a46956e6
AS
358$(addprefix $(objpfx)siglist, $(object-suffixes-noshared)): \
359 $(objpfx)siglist-aux.S
6fad891d 360
f881f6ff 361ifeq ($(run-built-tests),yes)
46c75c9a 362LOCALES := \
5176a830 363 bn_BD.UTF-8 \
46c75c9a
FW
364 de_DE.ISO-8859-1 \
365 de_DE.UTF-8 \
366 en_US.ISO-8859-1 \
320ac7ee 367 fa_IR.UTF-8 \
21bb8382 368 hi_IN.UTF-8 \
e297d33c 369 ja_JP.EUC-JP \
46c75c9a 370 ps_AF.UTF-8 \
5176a830 371 rw_RW.UTF-8 \
ffde06c9 372 tg_TJ.UTF-8 \
5176a830 373 unm_US.UTF-8 \
c3004417 374 # LOCALES
f881f6ff
AS
375include ../gen-locales.mk
376
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)
ca6466e8 381$(objpfx)tst-grouping2.out: $(gen-locales)
ffde06c9 382$(objpfx)tst-grouping_iterator.out: $(gen-locales)
f881f6ff
AS
383$(objpfx)tst-sprintf.out: $(gen-locales)
384$(objpfx)tst-sscanf.out: $(gen-locales)
385$(objpfx)tst-swprintf.out: $(gen-locales)
84d8c5bc 386$(objpfx)tst-vfprintf-mbs-prec.out: $(gen-locales)
21bb8382 387$(objpfx)tst-vfprintf-width-i18n.out: $(gen-locales)
c980549c 388$(objpfx)tst-grouping3.out: $(gen-locales)
320ac7ee 389$(objpfx)tst-scanf-to_inpunct.out: $(gen-locales)
f881f6ff
AS
390endif
391
2d2d9f2b
SP
392tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \
393 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
fdcf1c94 394tst-vfprintf-width-prec-ENV = \
2d2d9f2b
SP
395 MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \
396 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
910a835d 397tst-printf-bz25691-ENV = \
2d2d9f2b
SP
398 MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \
399 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
ede56038 400tst-printf-fp-free-ENV = \
2d2d9f2b
SP
401 MALLOC_TRACE=$(objpfx)tst-printf-fp-free.mtrace \
402 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
90663e9c 403tst-printf-fp-leak-ENV = \
2d2d9f2b
SP
404 MALLOC_TRACE=$(objpfx)tst-printf-fp-leak.mtrace \
405 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
560b0446 406
57c69bef 407$(objpfx)tst-unbputc.out: tst-unbputc.sh $(objpfx)tst-unbputc
8f8052c2 408 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
f0881698 409 $(evaluate-test)
6f98fd7e 410
57c69bef 411$(objpfx)tst-printf.out: tst-printf.sh $(objpfx)tst-printf
8f8052c2 412 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
f0881698 413 $(evaluate-test)
560b0446 414
b7b88cea
GG
415$(objpfx)tst-printfsz-islongdouble.out: \
416 tst-printfsz-islongdouble.sh $(objpfx)tst-printfsz-islongdouble
417 $(SHELL) $^ '$(test-program-prefix)' $@; \
418 $(evaluate-test)
419
560b0446
PP
420# We generate this source because it requires a printf invocation with
421# 10K arguments.
422$(objpfx)tst-printf-bz18872.c: tst-printf-bz18872.sh
423 rm -f $@ && $(BASH) $^ > $@.new && mv $@.new $@
424
fdcf1c94
FW
425$(objpfx)tst-%-mem.out: $(objpfx)tst-%.out
426 $(common-objpfx)malloc/mtrace $(objpfx)tst-$*.mtrace > $@; \
560b0446 427 $(evaluate-test)
95b04192 428
f13d2601
AZ
429errlist-h = $(firstword $(wildcard $(addsuffix /errlist.h,$(sysdirs) .)))
430
431$(objpfx)tst-errno-manual.out: tst-errno-manual.py \
432 $(errlist-h) \
433 $(..)manual/errno.texi
434 $(PYTHON) tst-errno-manual.py -m $(..)manual/errno.texi \
435 -e $(errlist-h) > $@; \
436 $(evaluate-test)
437
36975e8e
L
438CFLAGS-vfprintf.c += -Wno-uninitialized
439CFLAGS-vfwprintf.c += -Wno-uninitialized
ec4b0518 440
36975e8e
L
441CFLAGS-tmpfile.c += -fexceptions
442CFLAGS-tmpfile64.c += -fexceptions
443CFLAGS-tempname.c += -fexceptions
444CFLAGS-psignal.c += -fexceptions
445CFLAGS-vprintf.c += -fexceptions
446CFLAGS-cuserid.c += -fexceptions
874aa523 447
56ab3869
JM
448CFLAGS-vfprintf.c += -fexceptions
449CFLAGS-fprintf.c += -fexceptions
450CFLAGS-printf.c += -fexceptions
451CFLAGS-vfwprintf.c += -fexceptions
452CFLAGS-vfscanf.c += -fexceptions
453CFLAGS-vfwscanf.c += -fexceptions
454CFLAGS-fscanf.c += -fexceptions
455CFLAGS-scanf.c += -fexceptions
456CFLAGS-isoc99_vfscanf.c += -fexceptions
457CFLAGS-isoc99_vscanf.c += -fexceptions
458CFLAGS-isoc99_fscanf.c += -fexceptions
459CFLAGS-isoc99_scanf.c += -fexceptions
dee2bea0
JM
460CFLAGS-isoc23_vfscanf.c += -fexceptions
461CFLAGS-isoc23_vscanf.c += -fexceptions
462CFLAGS-isoc23_fscanf.c += -fexceptions
463CFLAGS-isoc23_scanf.c += -fexceptions
73299943 464
8d98c7c0
AZ
465CFLAGS-dprintf.c += $(config-cflags-wno-ignored-attributes)
466
434eca87
AZ
467# Called during static library initialization, so turn stack-protection
468# off for non-shared builds.
469CFLAGS-_itoa.o = $(no-stack-protector)
470CFLAGS-_itoa.op = $(no-stack-protector)
471
b9125aea 472# scanf18.c and scanf19.c test a deprecated extension which is no
03992356
ZW
473# longer visible under most conformance levels; see the source files
474# for more detail.
b9125aea
CD
475CFLAGS-scanf18.c += -std=gnu89
476CFLAGS-scanf19.c += -std=gnu89
874aa523 477
27f10a09
JM
478CFLAGS-bug3.c += -DOBJPFX=\"$(objpfx)\"
479CFLAGS-bug4.c += -DOBJPFX=\"$(objpfx)\"
480CFLAGS-bug5.c += -DOBJPFX=\"$(objpfx)\"
481CFLAGS-test-fseek.c += -DOBJPFX=\"$(objpfx)\"
482CFLAGS-test-popen.c += -DOBJPFX=\"$(objpfx)\"
483CFLAGS-test_rdwr.c += -DOBJPFX=\"$(objpfx)\"
484
7caa5054
ZW
485# tst-gets.c tests a deprecated function.
486CFLAGS-tst-gets.c += -Wno-deprecated-declarations
487
4e2f43f8
ZW
488# BZ #11319 was first fixed for regular vdprintf, then reopened because
489# the fortified version had the same bug.
20c894d2 490CFLAGS-tst-bz11319-fortify2.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2
4e2f43f8 491
0060a6de
FW
492CFLAGS-tst-memstream-string.c += -fno-builtin-fprintf
493
42cc619d
JM
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
dee2bea0
JM
497# the test as needed.
498CFLAGS-tst-scanf-binary-c11.c += -std=c11 -DOBJPFX=\"$(objpfx)\"
83d8d289 499CFLAGS-tst-scanf-binary-c23.c += -std=c11 -DOBJPFX=\"$(objpfx)\"
dee2bea0
JM
500CFLAGS-tst-scanf-binary-gnu11.c += -std=gnu11 -DOBJPFX=\"$(objpfx)\"
501CFLAGS-tst-scanf-binary-gnu89.c += -std=gnu89 -DOBJPFX=\"$(objpfx)\"
502
c75ccd4c 503CPPFLAGS += $(libio-mtsafe)
75684bd7 504
6e89caf1 505$(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
f0881698
JM
506 $(test-program-cmd) > $@ 2>&1; \
507 $(evaluate-test)
6e89caf1
JM
508
509$(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
f0881698
JM
510 cmp $^ > $@; \
511 $(evaluate-test)
784761be 512
79520f4b 513$(objpfx)tst-printf-round: $(libm)
646c2833 514$(objpfx)tst-scanf-round: $(libm)