]>
Commit | Line | Data |
---|---|---|
dff8da6b | 1 | # Copyright (C) 1995-2024 Free Software Foundation, Inc. |
96aa2d94 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. | |
96aa2d94 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. |
96aa2d94 | 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/>. |
96aa2d94 RM |
17 | |
18 | # | |
19 | # Specific makefile for libio. | |
20 | # | |
21 | subdir := libio | |
22 | ||
a5f891ac JM |
23 | include ../Makeconfig |
24 | ||
a4fea3f2 | 25 | headers := stdio.h \ |
d0fa09a7 | 26 | bits/stdio.h bits/stdio2.h bits/stdio2-decl.h bits/stdio-ldbl.h \ |
a4fea3f2 ZW |
27 | bits/types/FILE.h bits/types/__FILE.h bits/types/struct_FILE.h \ |
28 | bits/types/__fpos_t.h bits/types/__fpos64_t.h \ | |
29 | bits/types/cookie_io_functions_t.h | |
96aa2d94 RM |
30 | |
31 | routines := \ | |
32 | filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \ | |
d64b6ad0 | 33 | iofopncook iofputs iofread iofsetpos ioftell wfiledoalloc \ |
f65fd747 | 34 | iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs \ |
77fe0b9c | 35 | ioseekoff ioseekpos iosetbuffer iosetvbuf ioungetc \ |
96aa2d94 | 36 | iovsprintf iovsscanf \ |
dfd2257a | 37 | iofgetpos64 iofopen64 iofsetpos64 \ |
d64b6ad0 UD |
38 | fputwc fputwc_u getwc getwc_u getwchar getwchar_u iofgetws iofgetws_u \ |
39 | iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u \ | |
3944f99e AS |
40 | putwchar putwchar_u putchar putchar_u fwprintf swprintf vwprintf \ |
41 | wprintf wscanf fwscanf vwscanf vswprintf iovswscanf swscanf wgenops \ | |
63f8fe54 | 42 | wstrops wfileops iofwide fwide wmemstream \ |
96aa2d94 | 43 | \ |
209caedf | 44 | clearerr feof ferror fileno fputc freopen fseek getc getchar \ |
77a58cad | 45 | memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \ |
a5a0310d | 46 | iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello \ |
77ccaba1 | 47 | freopen64 fseeko64 ftello64 \ |
96aa2d94 | 48 | \ |
a91d3cd3 UD |
49 | __fbufsize __freading __fwriting __freadable __fwritable __flbf \ |
50 | __fpurge __fpending __fsetlocking \ | |
51 | \ | |
ec2f1fdd | 52 | libc_fatal fmemopen oldfmemopen vtables |
96aa2d94 | 53 | |
3020f726 AZN |
54 | gen-as-const-headers += libio-macros.sym |
55 | ||
20c894d2 FB |
56 | # Exclude fortified routines from being built with _FORTIFY_SOURCE |
57 | routines_no_fortify += \ | |
58 | fwprintf \ | |
59 | iofgets \ | |
60 | iofgets_u \ | |
61 | iofgetws \ | |
62 | iofgetws_u \ | |
63 | swprintf \ | |
64 | vasprintf \ | |
65 | vsnprintf \ | |
66 | vswprintf \ | |
67 | vwprintf \ | |
68 | wprintf \ | |
69 | # routines_no_fortify | |
70 | ||
9c38a689 | 71 | tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ |
bcba7aa2 | 72 | tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 \ |
3384a8d6 | 73 | tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf \ |
81c64d40 | 74 | tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \ |
442685a8 | 75 | tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \ |
acbee5f6 | 76 | tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \ |
eb35b097 | 77 | tst-mmap2-eofsync tst-mmap-offend bug-fopena+ bug-wfflush \ |
01715b03 | 78 | bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \ |
0b727ed4 AZ |
79 | tst-memstream1 tst-memstream2 tst-memstream3 tst-memstream4 \ |
80 | tst-wmemstream1 tst-wmemstream2 tst-wmemstream3 tst-wmemstream4 \ | |
c1760eaf | 81 | tst-wmemstream5 bug-memstream1 bug-wmemstream1 \ |
eb6cbd24 | 82 | tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \ |
2482ae43 | 83 | tst-fwrite-error tst-ftell-partial-wide tst-ftell-active-handler \ |
2d9837c1 | 84 | tst-ftell-append tst-fputws tst-bz22415 tst-fgetc-after-eof \ |
32ff3975 | 85 | tst-sprintf-ub tst-sprintf-chk-ub tst-bz24051 tst-bz24153 \ |
a09183ae | 86 | tst-wfile-sync tst-bz28828 tst-getdelim |
2cc7bad0 | 87 | |
ec2f1fdd | 88 | tests-internal = tst-vtables tst-vtables-interposed |
29055464 | 89 | |
bcba7aa2 L |
90 | ifeq (yes,$(build-shared)) |
91 | # Add test-fopenloc only if shared library is enabled since it depends on | |
92 | # shared localedata objects. | |
93 | tests += tst-fopenloc | |
21cc130b DL |
94 | # Add tst-bz24228 only if shared library is enabled since it can never meet its |
95 | # objective with static linking because the relevant code just is not there. | |
96 | tests += tst-bz24228 | |
bcba7aa2 | 97 | endif |
897d4284 | 98 | test-srcs = test-freopen |
d64b6ad0 | 99 | |
3f2e46a4 | 100 | ifeq ($(build-shared),yes) |
7d6a8338 | 101 | routines += oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \ |
655c0697 UD |
102 | oldtmpfile oldiofgetpos oldiofgetpos64 oldiofsetpos \ |
103 | oldiofsetpos64 | |
1ea89a40 UD |
104 | endif |
105 | ||
c75ccd4c | 106 | ifeq (yes,$(libc-reentrant)) |
edf5b2d7 | 107 | routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \ |
50304ef0 UD |
108 | iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u \ |
109 | iofputs_u | |
edf5b2d7 UD |
110 | endif |
111 | ||
c75ccd4c RM |
112 | CPPFLAGS += $(libio-mtsafe) |
113 | ||
21cea68e | 114 | # Support for exception handling. |
36975e8e L |
115 | CFLAGS-fileops.c += -fexceptions |
116 | CFLAGS-fputc.c += -fexceptions | |
117 | CFLAGS-fputwc.c += -fexceptions | |
118 | CFLAGS-freopen64.c += -fexceptions | |
119 | CFLAGS-freopen.c += -fexceptions | |
120 | CFLAGS-fseek.c += -fexceptions | |
121 | CFLAGS-fseeko64.c += -fexceptions | |
122 | CFLAGS-fseeko.c += -fexceptions | |
123 | CFLAGS-ftello64.c += -fexceptions | |
124 | CFLAGS-ftello.c += -fexceptions | |
125 | CFLAGS-fwide.c += -fexceptions | |
126 | CFLAGS-genops.c += -fexceptions | |
127 | CFLAGS-getc.c += -fexceptions | |
128 | CFLAGS-getchar.c += -fexceptions | |
129 | CFLAGS-getwc.c += -fexceptions | |
130 | CFLAGS-getwchar.c += -fexceptions | |
131 | CFLAGS-iofclose.c += -fexceptions | |
8d98c7c0 | 132 | CFLAGS-iofflush.c += -fexceptions $(config-cflags-wno-ignored-attributes) |
36975e8e L |
133 | CFLAGS-iofgetpos64.c += -fexceptions |
134 | CFLAGS-iofgetpos.c += -fexceptions | |
135 | CFLAGS-iofgets.c += -fexceptions | |
136 | CFLAGS-iofgetws.c += -fexceptions | |
8d98c7c0 | 137 | CFLAGS-iofputs.c += -fexceptions $(config-cflags-wno-ignored-attributes) |
36975e8e L |
138 | CFLAGS-iofputws.c += -fexceptions |
139 | CFLAGS-iofread.c += -fexceptions | |
140 | CFLAGS-iofsetpos64.c += -fexceptions | |
141 | CFLAGS-iofsetpos.c += -fexceptions | |
142 | CFLAGS-ioftell.c += -fexceptions | |
8d98c7c0 | 143 | CFLAGS-iofwrite.c += -fexceptions $(config-cflags-wno-ignored-attributes) |
36975e8e L |
144 | CFLAGS-iogetdelim.c += -fexceptions |
145 | CFLAGS-iogetline.c += -fexceptions | |
146 | CFLAGS-iogets.c += -fexceptions | |
147 | CFLAGS-iogetwline.c += -fexceptions | |
148 | CFLAGS-ioputs.c += -fexceptions | |
149 | CFLAGS-ioseekoff.c += -fexceptions | |
150 | CFLAGS-ioseekpos.c += -fexceptions | |
151 | CFLAGS-iosetbuffer.c += -fexceptions | |
152 | CFLAGS-iosetvbuf.c += -fexceptions | |
153 | CFLAGS-ioungetc.c += -fexceptions | |
154 | CFLAGS-ioungetwc.c += -fexceptions | |
155 | CFLAGS-oldfileops.c += -fexceptions | |
156 | CFLAGS-oldiofclose.c += -fexceptions | |
157 | CFLAGS-oldiofgetpos64.c += -fexceptions | |
158 | CFLAGS-oldiofgetpos.c += -fexceptions | |
159 | CFLAGS-oldiofsetpos64.c += -fexceptions | |
160 | CFLAGS-oldiofsetpos.c += -fexceptions | |
161 | CFLAGS-peekc.c += -fexceptions | |
162 | CFLAGS-putc.c += -fexceptions | |
163 | CFLAGS-putchar.c += -fexceptions | |
164 | CFLAGS-putwc.c += -fexceptions | |
165 | CFLAGS-putwchar.c += -fexceptions | |
166 | CFLAGS-rewind.c += -fexceptions | |
167 | CFLAGS-wfileops.c += -fexceptions | |
168 | CFLAGS-wgenops.c += -fexceptions | |
169 | CFLAGS-oldiofopen.c += -fexceptions | |
170 | CFLAGS-iofopen.c += -fexceptions | |
171 | CFLAGS-iofopen64.c += -fexceptions | |
172 | CFLAGS-oldtmpfile.c += -fexceptions | |
8d98c7c0 AZ |
173 | CFLAGS-fileno.c += $(config-cflags-wno-ignored-attributes) |
174 | CFLAGS-feof_u.c += $(config-cflags-wno-ignored-attributes) | |
175 | CFLAGS-ferror_u.c += $(config-cflags-wno-ignored-attributes) | |
176 | CFLAGS-getc_u.c += $(config-cflags-wno-ignored-attributes) | |
177 | CFLAGS-iofflush_u.c += $(config-cflags-wno-ignored-attributes) | |
178 | CFLAGS-putc_u.c += $(config-cflags-wno-ignored-attributes) | |
179 | CFLAGS-iofgets_u.c += $(config-cflags-wno-ignored-attributes) | |
180 | CFLAGS-iofputs_u.c += $(config-cflags-wno-ignored-attributes) | |
21cea68e UD |
181 | # XXX Do we need filedoalloc and wfiledoalloc? Others? |
182 | ||
20c894d2 FB |
183 | # Prevent fortification as these are built with -O0 |
184 | CFLAGS-tst-bz24051.c += $(no-fortify-source) | |
185 | CFLAGS-tst-bz24153.c += $(no-fortify-source) | |
186 | ||
36975e8e | 187 | CFLAGS-tst_putwc.c += -DOBJPFX=\"$(objpfx)\" |
e8595e84 | 188 | |
2d9837c1 | 189 | # These test cases intentionally use overlapping arguments |
20c894d2 FB |
190 | CFLAGS-tst-sprintf-ub.c += -Wno-restrict $(no-fortify-source) |
191 | CFLAGS-tst-sprintf-chk-ub.c += -Wno-restrict $(no-fortify-source) | |
2d9837c1 | 192 | |
21cc130b DL |
193 | LDFLAGS-tst-bz24228 = -Wl,--version-script=tst-bz24228.map |
194 | ||
9c38a689 UD |
195 | tst_wprintf2-ARGS = "Some Text" |
196 | ||
2d2d9f2b SP |
197 | test-fmemopen-ENV = MALLOC_TRACE=$(objpfx)test-fmemopen.mtrace \ |
198 | LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so | |
199 | tst-fopenloc-ENV = MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace \ | |
200 | LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so | |
201 | tst-bz22415-ENV = MALLOC_TRACE=$(objpfx)tst-bz22415.mtrace \ | |
202 | LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so | |
203 | tst-bz24228-ENV = MALLOC_TRACE=$(objpfx)tst-bz24228.mtrace \ | |
204 | LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so | |
277f8cdf | 205 | |
63e952d9 | 206 | generated += test-fmemopen.mtrace test-fmemopen.check |
f08e9a26 | 207 | generated += tst-fopenloc.mtrace tst-fopenloc.check |
cc683f7e | 208 | generated += tst-bz22415.mtrace tst-bz22415.check |
a3b231b7 | 209 | |
414fd335 | 210 | aux := fileops genops stdfiles stdio strops |
96aa2d94 | 211 | |
3f2e46a4 | 212 | ifeq ($(build-shared),yes) |
21cc130b | 213 | generated += tst-bz24228.mtrace tst-bz24228.check |
1ea89a40 UD |
214 | aux += oldfileops oldstdfiles |
215 | endif | |
216 | ||
bd355af0 | 217 | shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \ |
655c0697 UD |
218 | oldstdfiles oldiopopen oldpclose oldtmpfile \ |
219 | oldiofgetpos oldiofgetpos64 oldiofsetpos \ | |
220 | oldiofsetpos64 | |
f2ea0f5b | 221 | |
03ac099f | 222 | ifeq ($(run-built-tests),yes) |
cc683f7e | 223 | tests-special += $(objpfx)test-freopen.out $(objpfx)test-fmemopen-mem.out \ |
0bfddfc9 | 224 | $(objpfx)tst-bz22415-mem.out |
bcba7aa2 | 225 | ifeq (yes,$(build-shared)) |
7f98f180 JM |
226 | # Run tst-fopenloc-cmp.out and tst-openloc-mem.out only if shared |
227 | # library is enabled since they depend on tst-fopenloc.out. | |
21cc130b DL |
228 | tests-special += $(objpfx)tst-fopenloc-cmp.out $(objpfx)tst-fopenloc-mem.out \ |
229 | $(objpfx)tst-bz24228-mem.out | |
bcba7aa2 | 230 | endif |
cd6ae7ea FS |
231 | |
232 | tests += tst-cleanup-default tst-cleanup-default-static | |
233 | tests-static += tst-cleanup-default-static | |
234 | tests-special += $(objpfx)tst-cleanup-default-cmp.out $(objpfx)tst-cleanup-default-static-cmp.out | |
235 | LDFLAGS-tst-cleanup-default = -Wl,--gc-sections | |
236 | LDFLAGS-tst-cleanup-default-static = -Wl,--gc-sections | |
237 | ||
238 | ifeq ($(have-gnu-retain)$(have-z-start-stop-gc),yesyes) | |
239 | tests += tst-cleanup-start-stop-gc tst-cleanup-start-stop-gc-static \ | |
240 | tst-cleanup-nostart-stop-gc tst-cleanup-nostart-stop-gc-static | |
241 | tests-static += tst-cleanup-start-stop-gc-static tst-cleanup-nostart-stop-gc-static | |
242 | tests-special += $(objpfx)tst-cleanup-start-stop-gc-cmp.out \ | |
243 | $(objpfx)tst-cleanup-start-stop-gc-static-cmp.out \ | |
244 | $(objpfx)tst-cleanup-nostart-stop-gc-cmp.out \ | |
245 | $(objpfx)tst-cleanup-nostart-stop-gc-static-cmp.out | |
246 | LDFLAGS-tst-cleanup-start-stop-gc := -Wl,--gc-sections,-z,start-stop-gc | |
247 | LDFLAGS-tst-cleanup-start-stop-gc-static := -Wl,--gc-sections,-z,start-stop-gc | |
248 | LDFLAGS-tst-cleanup-nostart-stop-gc := -Wl,--gc-sections,-z,nostart-stop-gc | |
249 | LDFLAGS-tst-cleanup-nostart-stop-gc-static := -Wl,--gc-sections,-z,nostart-stop-gc | |
250 | endif | |
b647f210 | 251 | endif |
897d4284 | 252 | |
f214606a JM |
253 | include ../Rules |
254 | ||
f881f6ff AS |
255 | ifeq ($(run-built-tests),yes) |
256 | LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \ | |
257 | ja_JP.EUC-JP ja_JP.UTF-8 | |
258 | include ../gen-locales.mk | |
259 | ||
260 | $(objpfx)bug-ftell.out: $(gen-locales) | |
261 | $(objpfx)bug-ungetwc1.out: $(gen-locales) | |
262 | $(objpfx)bug-ungetwc2.out: $(gen-locales) | |
263 | $(objpfx)tst-fgetwc.out: $(gen-locales) | |
264 | $(objpfx)tst-fgetws.out: $(gen-locales) | |
265 | $(objpfx)tst-fopenloc.out: $(gen-locales) | |
266 | $(objpfx)tst-fputws.out: $(gen-locales) | |
267 | $(objpfx)tst-fseek.out: $(gen-locales) | |
268 | $(objpfx)tst-ftell-active-handler.out: $(gen-locales) | |
269 | $(objpfx)tst-ftell-append.out: $(gen-locales) | |
270 | $(objpfx)tst-ftell-partial-wide.out: $(gen-locales) | |
271 | $(objpfx)tst-setvbuf1.out: $(gen-locales) | |
272 | $(objpfx)tst-swscanf.out: $(gen-locales) | |
273 | $(objpfx)tst-ungetwc1.out: $(gen-locales) | |
274 | $(objpfx)tst-ungetwc2.out: $(gen-locales) | |
275 | $(objpfx)tst-widetext.out: $(gen-locales) | |
276 | $(objpfx)tst_wprintf2.out: $(gen-locales) | |
32ff3975 | 277 | $(objpfx)tst-wfile-sync.out: $(gen-locales) |
f881f6ff AS |
278 | endif |
279 | ||
cd6ae7ea FS |
280 | define gen-tst-cleanup |
281 | $(objpfx)tst-cleanup-$1-cmp.out: tst-cleanup.exp $(objpfx)tst-cleanup-$1.out | |
282 | cmp $$^ > $$@; $$(evaluate-test) | |
283 | endef | |
284 | ||
285 | $(foreach t,default default-static start-stop-gc start-stop-gc-static nostart-stop-gc nostart-stop-gc-static, \ | |
286 | $(eval $(call gen-tst-cleanup,$(t)))) | |
287 | ||
897d4284 | 288 | $(objpfx)test-freopen.out: test-freopen.sh $(objpfx)test-freopen |
740b3dbe | 289 | $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' \ |
8f8052c2 | 290 | $(common-objpfx)libio/; \ |
f0881698 | 291 | $(evaluate-test) |
277f8cdf | 292 | |
7f98f180 JM |
293 | $(objpfx)tst-fopenloc-cmp.out: ../iconvdata/testdata/ISO-8859-1..UTF8 \ |
294 | $(objpfx)tst-fopenloc.out | |
f0881698 JM |
295 | cmp $^ > $@; \ |
296 | $(evaluate-test) | |
7f98f180 | 297 | |
63e952d9 PP |
298 | $(objpfx)test-fmemopen-mem.out: $(objpfx)test-fmemopen.out |
299 | $(common-objpfx)malloc/mtrace $(objpfx)test-fmemopen.mtrace > $@; \ | |
300 | $(evaluate-test) | |
301 | ||
7f98f180 | 302 | $(objpfx)tst-fopenloc-mem.out: $(objpfx)tst-fopenloc.out |
f0881698 JM |
303 | $(common-objpfx)malloc/mtrace $(objpfx)tst-fopenloc.mtrace > $@; \ |
304 | $(evaluate-test) | |
cc683f7e AZ |
305 | |
306 | $(objpfx)tst-bz22415-mem.out: $(objpfx)tst-bz22415.out | |
307 | $(common-objpfx)malloc/mtrace $(objpfx)tst-bz22415.mtrace > $@; \ | |
308 | $(evaluate-test) | |
7e740ab2 | 309 | |
21cc130b DL |
310 | $(objpfx)tst-bz24228-mem.out: $(objpfx)tst-bz24228.out |
311 | $(common-objpfx)malloc/mtrace $(objpfx)tst-bz24228.mtrace > $@; \ | |
312 | $(evaluate-test) |