build-many-glibcs.py: Add openrisc hard float glibc variant
[glibc.git] / stdio-common / Makefile
blob6bc972af1a4c690f96b39d2d79b1e26c6a5e161f
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
23 include ../Makeconfig
25 headers := \
26 bits/printf-ldbl.h \
27 bits/stdio_lim.h \
28 printf.h \
29 stdio_ext.h \
30 # headers
32 routines := \
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 \
47 grouping_iterator \
48 iovfscanf \
49 isoc23_fscanf \
50 isoc23_scanf \
51 isoc23_sscanf \
52 isoc23_vfscanf \
53 isoc23_vscanf \
54 isoc23_vsscanf \
55 isoc99_fscanf \
56 isoc99_scanf \
57 isoc99_sscanf \
58 isoc99_vfscanf \
59 isoc99_vscanf \
60 isoc99_vsscanf \
61 itoa-digits \
62 itoa-udigits \
63 itowa-digits \
64 perror \
65 printf \
66 printf-prs \
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 \
75 printf_fp \
76 printf_fphex \
77 printf_function_invoke \
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 tmpdir \
96 tmpfile \
97 tmpfile64 \
98 tmpnam \
99 tmpnam_r \
100 translated_number_width \
101 vfprintf \
102 vfprintf-internal \
103 vfscanf \
104 vfscanf-internal \
105 vfwprintf \
106 vfwprintf-internal \
107 vfwscanf \
108 vfwscanf-internal \
109 vprintf \
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 \
119 # routines
121 # Exclude fortified routines from being built with _FORTIFY_SOURCE
122 routines_no_fortify += \
123 asprintf \
124 dprintf \
125 fprintf \
126 printf \
127 snprintf \
128 sprintf \
129 vfprintf \
130 vfwprintf \
131 vprintf \
132 # routines_no_fortify
134 aux := \
135 errlist \
136 errlist-data \
137 errname \
138 fxprintf \
139 printf-parsemb \
140 printf-parsewc \
141 siglist \
142 # aux
144 tests := \
145 bug-vfprintf-nargs \
146 bug1 \
147 bug3 \
148 bug4 \
149 bug5 \
150 bug6 \
151 bug7 \
152 bug8 \
153 bug9 \
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 \
170 bug24 \
171 bug25 \
172 bug26 \
173 bug27 \
174 bug28 \
175 bug29 \
176 errnobug \
177 scanf1 \
178 scanf2 \
179 scanf3 \
180 scanf4 \
181 scanf5 \
182 scanf7 \
183 scanf8 \
184 scanf9 \
185 scanf10 \
186 scanf11 \
187 scanf12 \
188 scanf13 \
189 scanf14 \
190 scanf15 \
191 scanf16 \
192 scanf17 \
193 scanf18 \
194 scanf19 \
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 \
208 tst-dprintf-length \
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 \
223 tst-grouping2 \
224 tst-grouping3 \
225 tst-long-dbl-fphex \
226 tst-memstream-string \
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 \
236 tst-printf-intn \
237 tst-printf-oct \
238 tst-printf-round \
239 tst-printfsz \
240 tst-put-error \
241 tst-renameat2 \
242 tst-rndseek \
243 tst-scanf-binary-c11 \
244 tst-scanf-binary-c23 \
245 tst-scanf-binary-gnu11 \
246 tst-scanf-binary-gnu89 \
247 tst-scanf-intn \
248 tst-scanf-round \
249 tst-scanf-to_inpunct \
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 \
263 tst-vfprintf-width-i18n \
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
273 tests-container += \
274 tst-popen3
275 # tests-container
277 generated += \
278 errlist-data-aux-shared.S \
279 errlist-data-aux.S \
280 siglist-aux-shared.S \
281 siglist-aux.S \
282 # generated
284 tests-internal = \
285 tst-grouping_iterator \
286 # tests-internal
288 test-srcs = \
289 tst-printf \
290 tst-printfsz-islongdouble \
291 tst-unbputc \
292 # test-srcs
294 ifeq ($(run-built-tests),yes)
295 tests-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
307 generated += \
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
320 endif # $(run-built-tests)
322 tests-special += $(objpfx)tst-errno-manual.out
324 include ../Rules
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
337 ifndef no_deps
338 -include $(objpfx)errlist-data-aux.S.d $(objpfx)errlist-data-aux-shared.S.d
339 endif
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
353 ifndef no_deps
354 -include $(objpfx)siglist-aux.S.d $(objpfx)siglist-aux-shared.S.d
355 endif
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)
362 LOCALES := \
363 bn_BD.UTF-8 \
364 de_DE.ISO-8859-1 \
365 de_DE.UTF-8 \
366 en_US.ISO-8859-1 \
367 fa_IR.UTF-8 \
368 hi_IN.UTF-8 \
369 ja_JP.EUC-JP \
370 ps_AF.UTF-8 \
371 rw_RW.UTF-8 \
372 tg_TJ.UTF-8 \
373 unm_US.UTF-8 \
374 # LOCALES
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)
390 endif
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)'; \
409 $(evaluate-test)
411 $(objpfx)tst-printf.out: tst-printf.sh $(objpfx)tst-printf
412 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
413 $(evaluate-test)
415 $(objpfx)tst-printfsz-islongdouble.out: \
416 tst-printfsz-islongdouble.sh $(objpfx)tst-printfsz-islongdouble
417 $(SHELL) $^ '$(test-program-prefix)' $@; \
418 $(evaluate-test)
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 $@
425 $(objpfx)tst-%-mem.out: $(objpfx)tst-%.out
426 $(common-objpfx)malloc/mtrace $(objpfx)tst-$*.mtrace > $@; \
427 $(evaluate-test)
429 errlist-h = $(firstword $(wildcard $(addsuffix /errlist.h,$(sysdirs) .)))
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)
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
474 # for more detail.
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; \
507 $(evaluate-test)
509 $(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
510 cmp $^ > $@; \
511 $(evaluate-test)
513 $(objpfx)tst-printf-round: $(libm)
514 $(objpfx)tst-scanf-round: $(libm)