aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/Makefile
blob: fe57dbdf568999576eb778238d553ec3eed379e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# Copyright (C) 1991-2022 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <https://www.gnu.org/licenses/>.

#
#	Specific makefile for stdio-common.
#
subdir	:= stdio-common

include ../Makeconfig

headers	:= stdio_ext.h printf.h bits/printf-ldbl.h bits/stdio_lim.h

routines := \
  _itoa \
  _itowa \
  asprintf \
  ctermid \
  cuserid \
  dprintf \
  flockfile \
  fprintf \
  fscanf \
  ftrylockfile \
  funlockfile \
  gentempfd \
  getline \
  getw \
  iovfscanf \
  isoc99_fscanf \
  isoc99_scanf \
  isoc99_sscanf \
  isoc99_vfscanf \
  isoc99_vscanf \
  isoc99_vsscanf \
  itoa-digits \
  itoa-udigits \
  itowa-digits \
  perror \
  printf \
  printf-prs \
  printf_fp \
  printf_fphex \
  printf_size \
  psiginfo \
  psignal \
  putw \
  reg-modifier \
  reg-printf \
  reg-type \
  remove \
  rename \
  renameat \
  renameat2 \
  scanf \
  snprintf \
  sprintf \
  sscanf \
  tempnam \
  tempname \
  tmpfile \
  tmpfile64 \
  tmpnam \
  tmpnam_r \
  vfprintf \
  vfprintf-internal \
  vfscanf \
  vfscanf-internal \
  vfwprintf \
  vfwprintf-internal \
  vfwscanf \
  vfwscanf-internal \
  vprintf \
  # routines

aux := \
  errlist \
  errlist-data \
  errname \
  fxprintf \
  printf-parsemb \
  printf-parsewc \
  siglist \
  # aux

tests := \
  bug-vfprintf-nargs \
  bug1 \
  bug10 \
  bug11 \
  bug12 \
  bug13 \
  bug14 \
  bug16 \
  bug17 \
  bug18 \
  bug18a \
  bug19 \
  bug19a \
  bug2 \
  bug20 \
  bug21 \
  bug22 \
  bug23 \
  bug23-2 \
  bug23-3 \
  bug23-4 \
  bug24 \
  bug25 \
  bug26 \
  bug3 \
  bug4 \
  bug5 \
  bug6 \
  bug7 \
  bug8 \
  bug9 \
  errnobug \
  scanf1 \
  scanf10 \
  scanf11 \
  scanf12 \
  scanf13 \
  scanf14 \
  scanf14a \
  scanf15 \
  scanf16 \
  scanf16a \
  scanf17 \
  scanf2 \
  scanf3 \
  scanf4 \
  scanf5 \
  scanf7 \
  scanf8 \
  scanf9 \
  temptest \
  test-fseek \
  test-fwrite \
  test-popen \
  test-strerr \
  test-vfprintf \
  test_rdwr \
  tfformat \
  tiformat \
  tllformat \
  tst-bz11319 \
  tst-bz11319-fortify2 \
  tst-cookie \
  tst-fdopen \
  tst-ferror \
  tst-fgets \
  tst-fileno \
  tst-fmemopen \
  tst-fmemopen2 \
  tst-fmemopen3 \
  tst-fmemopen4 \
  tst-fphex \
  tst-fphex-wide \
  tst-fseek \
  tst-fwrite \
  tst-gets \
  tst-grouping \
  tst-grouping2 \
  tst-long-dbl-fphex \
  tst-memstream-string \
  tst-obprintf \
  tst-perror \
  tst-popen \
  tst-popen2 \
  tst-printf-binary \
  tst-printf-bz18872 \
  tst-printf-bz25691 \
  tst-printf-fp-free \
  tst-printf-fp-leak \
  tst-printf-round \
  tst-printfsz \
  tst-put-error \
  tst-renameat2 \
  tst-rndseek \
  tst-scanf-round \
  tst-setvbuf1 \
  tst-sprintf \
  tst-sprintf-errno \
  tst-sprintf2 \
  tst-sprintf3 \
  tst-sscanf \
  tst-swprintf \
  tst-swscanf \
  tst-tmpnam \
  tst-ungetc \
  tst-unlockedio \
  tst-vfprintf-mbs-prec \
  tst-vfprintf-user-type \
  tst-vfprintf-width-prec \
  tst-vfprintf-width-prec-alloc \
  tst-vfprintf-width-i18n \
  tst-wc-printf \
  tstdiomisc \
  tstgetln \
  tstscanf \
  xbug \
  # tests

generated += \
  errlist-data-aux-shared.S \
  errlist-data-aux.S \
  siglist-aux-shared.S \
  siglist-aux.S \
  # generated

test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble

ifeq ($(run-built-tests),yes)
tests-special += \
  $(objpfx)tst-printf-bz18872-mem.out \
  $(objpfx)tst-printf-bz25691-mem.out \
  $(objpfx)tst-printf-fp-free-mem.out \
  $(objpfx)tst-printf-fp-leak-mem.out \
  $(objpfx)tst-printf.out \
  $(objpfx)tst-printfsz-islongdouble.out \
  $(objpfx)tst-setvbuf1-cmp.out \
  $(objpfx)tst-unbputc.out \
  $(objpfx)tst-vfprintf-width-prec-mem.out \
  # tests-special

generated += \
  tst-printf-bz18872-mem.out \
  tst-printf-bz18872.c \
  tst-printf-bz18872.mtrace \
  tst-printf-bz25691-mem.out \
  tst-printf-bz25691.mtrace \
  tst-printf-fp-free-mem.out \
  tst-printf-fp-free.mtrace \
  tst-printf-fp-leak-mem.out \
  tst-printf-fp-leak.mtrace \
  tst-vfprintf-width-prec-mem.out \
  tst-vfprintf-width-prec.mtrace \
  # generated
endif # $(run-built-tests)

tests-special += $(objpfx)tst-errno-manual.out

include ../Rules

# The errlist.c is built in two phases because compiler might reorder the
# compat_symbol directive prior the object itself and on binutils older
# than 2.29 it might generate object sizes different than the expected ones.
$(objpfx)errlist-data-aux-shared.S: errlist-data-gen.c
	$(make-target-directory)
	$(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S

$(objpfx)errlist-data-aux.S: errlist-data-gen.c
	$(make-target-directory)
	$(compile-command.c) $(pie-default) $(no-stack-protector) -S

ifndef no_deps
-include $(objpfx)errlist-data-aux.S.d $(objpfx)errlist-data-aux-shared.S.d
endif

$(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
$(addprefix $(objpfx)errlist-data, $(object-suffixes-noshared)): \
  $(objpfx)errlist-data-aux.S

$(objpfx)siglist-aux-shared.S: siglist-gen.c
	$(make-target-directory)
	$(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S

$(objpfx)siglist-aux.S: siglist-gen.c
	$(make-target-directory)
	$(compile-command.c) $(pie-default) $(no-stack-protector) -S

ifndef no_deps
-include $(objpfx)siglist-aux.S.d $(objpfx)siglist-aux-shared.S.d
endif

$(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
$(addprefix $(objpfx)siglist, $(object-suffixes-noshared)): \
  $(objpfx)siglist-aux.S

ifeq ($(run-built-tests),yes)
LOCALES := \
  de_DE.ISO-8859-1 \
  de_DE.UTF-8 \
  en_US.ISO-8859-1 \
  hi_IN.UTF-8 \
  ja_JP.EUC-JP \
  ps_AF.UTF-8 \
  # LOCALES
include ../gen-locales.mk

$(objpfx)bug14.out: $(gen-locales)
$(objpfx)scanf13.out: $(gen-locales)
$(objpfx)test-vfprintf.out: $(gen-locales)
$(objpfx)tst-grouping.out: $(gen-locales)
$(objpfx)tst-grouping2.out: $(gen-locales)
$(objpfx)tst-sprintf.out: $(gen-locales)
$(objpfx)tst-sscanf.out: $(gen-locales)
$(objpfx)tst-swprintf.out: $(gen-locales)
$(objpfx)tst-vfprintf-mbs-prec.out: $(gen-locales)
$(objpfx)tst-vfprintf-width-i18n.out: $(gen-locales)
endif

tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \
			LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
tst-vfprintf-width-prec-ENV = \
  MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \
  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
tst-printf-bz25691-ENV = \
  MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \
  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
tst-printf-fp-free-ENV = \
  MALLOC_TRACE=$(objpfx)tst-printf-fp-free.mtrace \
  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
tst-printf-fp-leak-ENV = \
  MALLOC_TRACE=$(objpfx)tst-printf-fp-leak.mtrace \
  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so

$(objpfx)tst-unbputc.out: tst-unbputc.sh $(objpfx)tst-unbputc
	$(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
	$(evaluate-test)

$(objpfx)tst-printf.out: tst-printf.sh $(objpfx)tst-printf
	$(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
	$(evaluate-test)

$(objpfx)tst-printfsz-islongdouble.out: \
  tst-printfsz-islongdouble.sh $(objpfx)tst-printfsz-islongdouble
	$(SHELL) $^ '$(test-program-prefix)' $@; \
	$(evaluate-test)

# We generate this source because it requires a printf invocation with
# 10K arguments.
$(objpfx)tst-printf-bz18872.c: tst-printf-bz18872.sh
	rm -f $@ && $(BASH) $^ > $@.new && mv $@.new $@

$(objpfx)tst-%-mem.out: $(objpfx)tst-%.out
	$(common-objpfx)malloc/mtrace $(objpfx)tst-$*.mtrace > $@; \
	$(evaluate-test)

errlist-h = $(firstword $(wildcard $(addsuffix /errlist.h,$(sysdirs) .)))

$(objpfx)tst-errno-manual.out: tst-errno-manual.py \
			       $(errlist-h) \
			       $(..)manual/errno.texi
	$(PYTHON) tst-errno-manual.py -m $(..)manual/errno.texi \
				      -e $(errlist-h) > $@; \
	$(evaluate-test)

CFLAGS-vfprintf.c += -Wno-uninitialized
CFLAGS-vfwprintf.c += -Wno-uninitialized

CFLAGS-tmpfile.c += -fexceptions
CFLAGS-tmpfile64.c += -fexceptions
CFLAGS-tempname.c += -fexceptions
CFLAGS-psignal.c += -fexceptions
CFLAGS-vprintf.c += -fexceptions
CFLAGS-cuserid.c += -fexceptions

CFLAGS-vfprintf.c += -fexceptions
CFLAGS-fprintf.c += -fexceptions
CFLAGS-printf.c += -fexceptions
CFLAGS-vfwprintf.c += -fexceptions
CFLAGS-vfscanf.c += -fexceptions
CFLAGS-vfwscanf.c += -fexceptions
CFLAGS-fscanf.c += -fexceptions
CFLAGS-scanf.c += -fexceptions
CFLAGS-isoc99_vfscanf.c += -fexceptions
CFLAGS-isoc99_vscanf.c += -fexceptions
CFLAGS-isoc99_fscanf.c += -fexceptions
CFLAGS-isoc99_scanf.c += -fexceptions

CFLAGS-dprintf.c += $(config-cflags-wno-ignored-attributes)

# scanf14a.c and scanf16a.c test a deprecated extension which is no
# longer visible under most conformance levels; see the source files
# for more detail.
CFLAGS-scanf14a.c += -std=gnu89
CFLAGS-scanf16a.c += -std=gnu89

CFLAGS-bug3.c += -DOBJPFX=\"$(objpfx)\"
CFLAGS-bug4.c += -DOBJPFX=\"$(objpfx)\"
CFLAGS-bug5.c += -DOBJPFX=\"$(objpfx)\"
CFLAGS-test-fseek.c += -DOBJPFX=\"$(objpfx)\"
CFLAGS-test-popen.c += -DOBJPFX=\"$(objpfx)\"
CFLAGS-test_rdwr.c += -DOBJPFX=\"$(objpfx)\"

# tst-gets.c tests a deprecated function.
CFLAGS-tst-gets.c += -Wno-deprecated-declarations

# BZ #11319 was first fixed for regular vdprintf, then reopened because
# the fortified version had the same bug.
CFLAGS-tst-bz11319-fortify2.c += -D_FORTIFY_SOURCE=2

CFLAGS-tst-memstream-string.c += -fno-builtin-fprintf

CPPFLAGS += $(libio-mtsafe)

$(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
	$(test-program-cmd) > $@ 2>&1; \
	$(evaluate-test)

$(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
	cmp $^ > $@; \
	$(evaluate-test)

$(objpfx)tst-printf-round: $(libm)
$(objpfx)tst-scanf-round: $(libm)