stdio-common: Reformat Makefile.
[glibc.git] / stdio-common / Makefile
blob1b4997afc8c0bd3a90c54bf6e5f75e1385025715
1 # Copyright (C) 1991-2023 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 tmpfile \
96 tmpfile64 \
97 tmpnam \
98 tmpnam_r \
99 translated_number_width \
100 vfprintf \
101 vfprintf-internal \
102 vfscanf \
103 vfscanf-internal \
104 vfwprintf \
105 vfwprintf-internal \
106 vfwscanf \
107 vfwscanf-internal \
108 vprintf \
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 \
118 # routines
120 aux := \
121 errlist \
122 errlist-data \
123 errname \
124 fxprintf \
125 printf-parsemb \
126 printf-parsewc \
127 siglist \
128 # aux
130 tests := \
131 bug-vfprintf-nargs \
132 bug1 \
133 bug10 \
134 bug11 \
135 bug12 \
136 bug13 \
137 bug14 \
138 bug16 \
139 bug17 \
140 bug18 \
141 bug18a \
142 bug19 \
143 bug19a \
144 bug2 \
145 bug20 \
146 bug21 \
147 bug22 \
148 bug23 \
149 bug23-2 \
150 bug23-3 \
151 bug23-4 \
152 bug24 \
153 bug25 \
154 bug26 \
155 bug3 \
156 bug4 \
157 bug5 \
158 bug6 \
159 bug7 \
160 bug8 \
161 bug9 \
162 errnobug \
163 scanf1 \
164 scanf10 \
165 scanf11 \
166 scanf12 \
167 scanf13 \
168 scanf14 \
169 scanf14a \
170 scanf15 \
171 scanf16 \
172 scanf16a \
173 scanf17 \
174 scanf2 \
175 scanf3 \
176 scanf4 \
177 scanf5 \
178 scanf7 \
179 scanf8 \
180 scanf9 \
181 temptest \
182 test-fseek \
183 test-fwrite \
184 test-popen \
185 test-strerr \
186 test-vfprintf \
187 test_rdwr \
188 tfformat \
189 tiformat \
190 tllformat \
191 tst-bz11319 \
192 tst-bz11319-fortify2 \
193 tst-cookie \
194 tst-dprintf-length \
195 tst-fdopen \
196 tst-ferror \
197 tst-fgets \
198 tst-fileno \
199 tst-fmemopen \
200 tst-fmemopen2 \
201 tst-fmemopen3 \
202 tst-fmemopen4 \
203 tst-fphex \
204 tst-fphex-wide \
205 tst-fseek \
206 tst-fwrite \
207 tst-gets \
208 tst-grouping \
209 tst-grouping2 \
210 tst-grouping3 \
211 tst-long-dbl-fphex \
212 tst-memstream-string \
213 tst-obprintf \
214 tst-perror \
215 tst-popen \
216 tst-popen2 \
217 tst-printf-binary \
218 tst-printf-bz18872 \
219 tst-printf-bz25691 \
220 tst-printf-fp-free \
221 tst-printf-fp-leak \
222 tst-printf-oct \
223 tst-printf-round \
224 tst-printfsz \
225 tst-put-error \
226 tst-renameat2 \
227 tst-rndseek \
228 tst-scanf-binary-c11 \
229 tst-scanf-binary-c2x \
230 tst-scanf-binary-gnu11 \
231 tst-scanf-binary-gnu89 \
232 tst-scanf-round \
233 tst-setvbuf1 \
234 tst-sprintf \
235 tst-sprintf-errno \
236 tst-sprintf2 \
237 tst-sprintf3 \
238 tst-sscanf \
239 tst-swprintf \
240 tst-swscanf \
241 tst-tmpnam \
242 tst-ungetc \
243 tst-unlockedio \
244 tst-vfprintf-mbs-prec \
245 tst-vfprintf-user-type \
246 tst-vfprintf-width-i18n \
247 tst-vfprintf-width-prec \
248 tst-vfprintf-width-prec-alloc \
249 tst-wc-printf \
250 tstdiomisc \
251 tstgetln \
252 tstscanf \
253 xbug \
254 # tests
256 tests-container += \
257 tst-popen3
258 # tests-container
260 generated += \
261 errlist-data-aux-shared.S \
262 errlist-data-aux.S \
263 siglist-aux-shared.S \
264 siglist-aux.S \
265 # generated
267 tests-internal = \
268 tst-grouping_iterator \
269 # tests-internal
271 test-srcs = \
272 tst-printf \
273 tst-printfsz-islongdouble \
274 tst-unbputc \
275 # test-srcs
277 ifeq ($(run-built-tests),yes)
278 tests-special += \
279 $(objpfx)tst-printf-bz18872-mem.out \
280 $(objpfx)tst-printf-bz25691-mem.out \
281 $(objpfx)tst-printf-fp-free-mem.out \
282 $(objpfx)tst-printf-fp-leak-mem.out \
283 $(objpfx)tst-printf.out \
284 $(objpfx)tst-printfsz-islongdouble.out \
285 $(objpfx)tst-setvbuf1-cmp.out \
286 $(objpfx)tst-unbputc.out \
287 $(objpfx)tst-vfprintf-width-prec-mem.out \
288 # tests-special
290 generated += \
291 tst-printf-bz18872-mem.out \
292 tst-printf-bz18872.c \
293 tst-printf-bz18872.mtrace \
294 tst-printf-bz25691-mem.out \
295 tst-printf-bz25691.mtrace \
296 tst-printf-fp-free-mem.out \
297 tst-printf-fp-free.mtrace \
298 tst-printf-fp-leak-mem.out \
299 tst-printf-fp-leak.mtrace \
300 tst-vfprintf-width-prec-mem.out \
301 tst-vfprintf-width-prec.mtrace \
302 # generated
303 endif # $(run-built-tests)
305 tests-special += $(objpfx)tst-errno-manual.out
307 include ../Rules
309 # The errlist.c is built in two phases because compiler might reorder the
310 # compat_symbol directive prior the object itself and on binutils older
311 # than 2.29 it might generate object sizes different than the expected ones.
312 $(objpfx)errlist-data-aux-shared.S: errlist-data-gen.c
313 $(make-target-directory)
314 $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
316 $(objpfx)errlist-data-aux.S: errlist-data-gen.c
317 $(make-target-directory)
318 $(compile-command.c) $(pie-default) $(no-stack-protector) -S
320 ifndef no_deps
321 -include $(objpfx)errlist-data-aux.S.d $(objpfx)errlist-data-aux-shared.S.d
322 endif
324 $(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
325 $(addprefix $(objpfx)errlist-data, $(object-suffixes-noshared)): \
326 $(objpfx)errlist-data-aux.S
328 $(objpfx)siglist-aux-shared.S: siglist-gen.c
329 $(make-target-directory)
330 $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
332 $(objpfx)siglist-aux.S: siglist-gen.c
333 $(make-target-directory)
334 $(compile-command.c) $(pie-default) $(no-stack-protector) -S
336 ifndef no_deps
337 -include $(objpfx)siglist-aux.S.d $(objpfx)siglist-aux-shared.S.d
338 endif
340 $(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
341 $(addprefix $(objpfx)siglist, $(object-suffixes-noshared)): \
342 $(objpfx)siglist-aux.S
344 ifeq ($(run-built-tests),yes)
345 LOCALES := \
346 de_DE.ISO-8859-1 \
347 de_DE.UTF-8 \
348 en_US.ISO-8859-1 \
349 hi_IN.UTF-8 \
350 ja_JP.EUC-JP \
351 ps_AF.UTF-8 \
352 tg_TJ.UTF-8 \
353 # LOCALES
354 include ../gen-locales.mk
356 $(objpfx)bug14.out: $(gen-locales)
357 $(objpfx)scanf13.out: $(gen-locales)
358 $(objpfx)test-vfprintf.out: $(gen-locales)
359 $(objpfx)tst-grouping.out: $(gen-locales)
360 $(objpfx)tst-grouping2.out: $(gen-locales)
361 $(objpfx)tst-grouping_iterator.out: $(gen-locales)
362 $(objpfx)tst-sprintf.out: $(gen-locales)
363 $(objpfx)tst-sscanf.out: $(gen-locales)
364 $(objpfx)tst-swprintf.out: $(gen-locales)
365 $(objpfx)tst-vfprintf-mbs-prec.out: $(gen-locales)
366 $(objpfx)tst-vfprintf-width-i18n.out: $(gen-locales)
367 $(objpfx)tst-grouping3.out: $(gen-locales)
368 endif
370 tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \
371 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
372 tst-vfprintf-width-prec-ENV = \
373 MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \
374 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
375 tst-printf-bz25691-ENV = \
376 MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \
377 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
378 tst-printf-fp-free-ENV = \
379 MALLOC_TRACE=$(objpfx)tst-printf-fp-free.mtrace \
380 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
381 tst-printf-fp-leak-ENV = \
382 MALLOC_TRACE=$(objpfx)tst-printf-fp-leak.mtrace \
383 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
385 $(objpfx)tst-unbputc.out: tst-unbputc.sh $(objpfx)tst-unbputc
386 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
387 $(evaluate-test)
389 $(objpfx)tst-printf.out: tst-printf.sh $(objpfx)tst-printf
390 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
391 $(evaluate-test)
393 $(objpfx)tst-printfsz-islongdouble.out: \
394 tst-printfsz-islongdouble.sh $(objpfx)tst-printfsz-islongdouble
395 $(SHELL) $^ '$(test-program-prefix)' $@; \
396 $(evaluate-test)
398 # We generate this source because it requires a printf invocation with
399 # 10K arguments.
400 $(objpfx)tst-printf-bz18872.c: tst-printf-bz18872.sh
401 rm -f $@ && $(BASH) $^ > $@.new && mv $@.new $@
403 $(objpfx)tst-%-mem.out: $(objpfx)tst-%.out
404 $(common-objpfx)malloc/mtrace $(objpfx)tst-$*.mtrace > $@; \
405 $(evaluate-test)
407 errlist-h = $(firstword $(wildcard $(addsuffix /errlist.h,$(sysdirs) .)))
409 $(objpfx)tst-errno-manual.out: tst-errno-manual.py \
410 $(errlist-h) \
411 $(..)manual/errno.texi
412 $(PYTHON) tst-errno-manual.py -m $(..)manual/errno.texi \
413 -e $(errlist-h) > $@; \
414 $(evaluate-test)
416 CFLAGS-vfprintf.c += -Wno-uninitialized
417 CFLAGS-vfwprintf.c += -Wno-uninitialized
419 CFLAGS-tmpfile.c += -fexceptions
420 CFLAGS-tmpfile64.c += -fexceptions
421 CFLAGS-tempname.c += -fexceptions
422 CFLAGS-psignal.c += -fexceptions
423 CFLAGS-vprintf.c += -fexceptions
424 CFLAGS-cuserid.c += -fexceptions
426 CFLAGS-vfprintf.c += -fexceptions
427 CFLAGS-fprintf.c += -fexceptions
428 CFLAGS-printf.c += -fexceptions
429 CFLAGS-vfwprintf.c += -fexceptions
430 CFLAGS-vfscanf.c += -fexceptions
431 CFLAGS-vfwscanf.c += -fexceptions
432 CFLAGS-fscanf.c += -fexceptions
433 CFLAGS-scanf.c += -fexceptions
434 CFLAGS-isoc99_vfscanf.c += -fexceptions
435 CFLAGS-isoc99_vscanf.c += -fexceptions
436 CFLAGS-isoc99_fscanf.c += -fexceptions
437 CFLAGS-isoc99_scanf.c += -fexceptions
438 CFLAGS-isoc23_vfscanf.c += -fexceptions
439 CFLAGS-isoc23_vscanf.c += -fexceptions
440 CFLAGS-isoc23_fscanf.c += -fexceptions
441 CFLAGS-isoc23_scanf.c += -fexceptions
443 CFLAGS-dprintf.c += $(config-cflags-wno-ignored-attributes)
445 # scanf14a.c and scanf16a.c test a deprecated extension which is no
446 # longer visible under most conformance levels; see the source files
447 # for more detail.
448 CFLAGS-scanf14a.c += -std=gnu89
449 CFLAGS-scanf16a.c += -std=gnu89
451 CFLAGS-bug3.c += -DOBJPFX=\"$(objpfx)\"
452 CFLAGS-bug4.c += -DOBJPFX=\"$(objpfx)\"
453 CFLAGS-bug5.c += -DOBJPFX=\"$(objpfx)\"
454 CFLAGS-test-fseek.c += -DOBJPFX=\"$(objpfx)\"
455 CFLAGS-test-popen.c += -DOBJPFX=\"$(objpfx)\"
456 CFLAGS-test_rdwr.c += -DOBJPFX=\"$(objpfx)\"
458 # tst-gets.c tests a deprecated function.
459 CFLAGS-tst-gets.c += -Wno-deprecated-declarations
461 # BZ #11319 was first fixed for regular vdprintf, then reopened because
462 # the fortified version had the same bug.
463 CFLAGS-tst-bz11319-fortify2.c += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
465 CFLAGS-tst-memstream-string.c += -fno-builtin-fprintf
467 # Some versions of GCC supported for building glibc do not support -std=c2x, so
468 # the test for that version uses -std=c11 and then _ISOC2X_SOURCE is defined in
469 # the test as needed.
470 CFLAGS-tst-scanf-binary-c11.c += -std=c11 -DOBJPFX=\"$(objpfx)\"
471 CFLAGS-tst-scanf-binary-c2x.c += -std=c11 -DOBJPFX=\"$(objpfx)\"
472 CFLAGS-tst-scanf-binary-gnu11.c += -std=gnu11 -DOBJPFX=\"$(objpfx)\"
473 CFLAGS-tst-scanf-binary-gnu89.c += -std=gnu89 -DOBJPFX=\"$(objpfx)\"
475 CPPFLAGS += $(libio-mtsafe)
477 $(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
478 $(test-program-cmd) > $@ 2>&1; \
479 $(evaluate-test)
481 $(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
482 cmp $^ > $@; \
483 $(evaluate-test)
485 $(objpfx)tst-printf-round: $(libm)
486 $(objpfx)tst-scanf-round: $(libm)