1 # Copyright (C) 1995-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 libio.
26 bits
/stdio.h bits
/stdio2.h bits
/stdio2-decl.h bits
/stdio-ldbl.h \
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
32 filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \
33 iofopncook iofputs iofread iofsetpos ioftell wfiledoalloc \
34 iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs \
35 ioseekoff ioseekpos iosetbuffer iosetvbuf ioungetc \
36 iovsprintf iovsscanf \
37 iofgetpos64 iofopen64 iofsetpos64 \
38 fputwc fputwc_u getwc getwc_u getwchar getwchar_u iofgetws iofgetws_u \
39 iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u \
40 putwchar putwchar_u putchar putchar_u fwprintf swprintf vwprintf \
41 wprintf wscanf fwscanf vwscanf vswprintf iovswscanf swscanf wgenops \
42 wstrops wfileops iofwide fwide wmemstream \
44 clearerr feof ferror fileno fputc freopen fseek getc getchar \
45 memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \
46 iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello \
47 freopen64 fseeko64 ftello64 \
49 __fbufsize __freading __fwriting __freadable __fwritable __flbf \
50 __fpurge __fpending __fsetlocking \
52 libc_fatal fmemopen oldfmemopen vtables
54 gen-as-const-headers
+= libio-macros.sym
56 tests
= tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
57 tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 \
58 tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf \
59 tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \
60 tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
61 tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \
62 tst-mmap2-eofsync tst-mmap-offend bug-fopena
+ bug-wfflush \
63 bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \
64 tst-memstream1 tst-memstream2 tst-memstream3 tst-memstream4 \
65 tst-wmemstream1 tst-wmemstream2 tst-wmemstream3 tst-wmemstream4 \
66 tst-wmemstream5 bug-memstream1 bug-wmemstream1 \
67 tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \
68 tst-fwrite-error tst-ftell-partial-wide tst-ftell-active-handler \
69 tst-ftell-append tst-fputws tst-bz22415 tst-fgetc-after-eof \
70 tst-sprintf-ub tst-sprintf-chk-ub tst-bz24051 tst-bz24153 \
71 tst-wfile-sync tst-bz28828 tst-getdelim
73 tests-internal
= tst-vtables tst-vtables-interposed
75 ifeq (yes
,$(build-shared
))
76 # Add test-fopenloc only if shared library is enabled since it depends on
77 # shared localedata objects.
79 # Add tst-bz24228 only if shared library is enabled since it can never meet its
80 # objective with static linking because the relevant code just is not there.
83 test-srcs
= test-freopen
85 ifeq ($(build-shared
),yes
)
86 routines
+= oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \
87 oldtmpfile oldiofgetpos oldiofgetpos64 oldiofsetpos \
91 ifeq (yes
,$(libc-reentrant
))
92 routines
+= clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \
93 iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u \
97 CPPFLAGS
+= $(libio-mtsafe
)
99 # Support for exception handling.
100 CFLAGS-fileops.c
+= -fexceptions
101 CFLAGS-fputc.c
+= -fexceptions
102 CFLAGS-fputwc.c
+= -fexceptions
103 CFLAGS-freopen64.c
+= -fexceptions
104 CFLAGS-freopen.c
+= -fexceptions
105 CFLAGS-fseek.c
+= -fexceptions
106 CFLAGS-fseeko64.c
+= -fexceptions
107 CFLAGS-fseeko.c
+= -fexceptions
108 CFLAGS-ftello64.c
+= -fexceptions
109 CFLAGS-ftello.c
+= -fexceptions
110 CFLAGS-fwide.c
+= -fexceptions
111 CFLAGS-genops.c
+= -fexceptions
112 CFLAGS-getc.c
+= -fexceptions
113 CFLAGS-getchar.c
+= -fexceptions
114 CFLAGS-getwc.c
+= -fexceptions
115 CFLAGS-getwchar.c
+= -fexceptions
116 CFLAGS-iofclose.c
+= -fexceptions
117 CFLAGS-iofflush.c
+= -fexceptions
$(config-cflags-wno-ignored-attributes
)
118 CFLAGS-iofgetpos64.c
+= -fexceptions
119 CFLAGS-iofgetpos.c
+= -fexceptions
120 CFLAGS-iofgets.c
+= -fexceptions
121 CFLAGS-iofgetws.c
+= -fexceptions
122 CFLAGS-iofputs.c
+= -fexceptions
$(config-cflags-wno-ignored-attributes
)
123 CFLAGS-iofputws.c
+= -fexceptions
124 CFLAGS-iofread.c
+= -fexceptions
125 CFLAGS-iofsetpos64.c
+= -fexceptions
126 CFLAGS-iofsetpos.c
+= -fexceptions
127 CFLAGS-ioftell.c
+= -fexceptions
128 CFLAGS-iofwrite.c
+= -fexceptions
$(config-cflags-wno-ignored-attributes
)
129 CFLAGS-iogetdelim.c
+= -fexceptions
130 CFLAGS-iogetline.c
+= -fexceptions
131 CFLAGS-iogets.c
+= -fexceptions
132 CFLAGS-iogetwline.c
+= -fexceptions
133 CFLAGS-ioputs.c
+= -fexceptions
134 CFLAGS-ioseekoff.c
+= -fexceptions
135 CFLAGS-ioseekpos.c
+= -fexceptions
136 CFLAGS-iosetbuffer.c
+= -fexceptions
137 CFLAGS-iosetvbuf.c
+= -fexceptions
138 CFLAGS-ioungetc.c
+= -fexceptions
139 CFLAGS-ioungetwc.c
+= -fexceptions
140 CFLAGS-oldfileops.c
+= -fexceptions
141 CFLAGS-oldiofclose.c
+= -fexceptions
142 CFLAGS-oldiofgetpos64.c
+= -fexceptions
143 CFLAGS-oldiofgetpos.c
+= -fexceptions
144 CFLAGS-oldiofsetpos64.c
+= -fexceptions
145 CFLAGS-oldiofsetpos.c
+= -fexceptions
146 CFLAGS-peekc.c
+= -fexceptions
147 CFLAGS-putc.c
+= -fexceptions
148 CFLAGS-putchar.c
+= -fexceptions
149 CFLAGS-putwc.c
+= -fexceptions
150 CFLAGS-putwchar.c
+= -fexceptions
151 CFLAGS-rewind.c
+= -fexceptions
152 CFLAGS-wfileops.c
+= -fexceptions
153 CFLAGS-wgenops.c
+= -fexceptions
154 CFLAGS-oldiofopen.c
+= -fexceptions
155 CFLAGS-iofopen.c
+= -fexceptions
156 CFLAGS-iofopen64.c
+= -fexceptions
157 CFLAGS-oldtmpfile.c
+= -fexceptions
158 CFLAGS-fileno.c
+= $(config-cflags-wno-ignored-attributes
)
159 CFLAGS-feof_u.c
+= $(config-cflags-wno-ignored-attributes
)
160 CFLAGS-ferror_u.c
+= $(config-cflags-wno-ignored-attributes
)
161 CFLAGS-getc_u.c
+= $(config-cflags-wno-ignored-attributes
)
162 CFLAGS-iofflush_u.c
+= $(config-cflags-wno-ignored-attributes
)
163 CFLAGS-putc_u.c
+= $(config-cflags-wno-ignored-attributes
)
164 CFLAGS-iofgets_u.c
+= $(config-cflags-wno-ignored-attributes
)
165 CFLAGS-iofputs_u.c
+= $(config-cflags-wno-ignored-attributes
)
166 # XXX Do we need filedoalloc and wfiledoalloc? Others?
168 CFLAGS-tst_putwc.c
+= -DOBJPFX
=\"$(objpfx
)\"
170 # These test cases intentionally use overlapping arguments
171 CFLAGS-tst-sprintf-ub.c
+= -Wno-restrict
172 CFLAGS-tst-sprintf-chk-ub.c
+= -Wno-restrict
174 LDFLAGS-tst-bz24228
= -Wl
,--version-script
=tst-bz24228.map
176 tst_wprintf2-ARGS
= "Some Text"
178 test-fmemopen-ENV
= MALLOC_TRACE
=$(objpfx
)test-fmemopen.mtrace \
179 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
180 tst-fopenloc-ENV
= MALLOC_TRACE
=$(objpfx
)tst-fopenloc.mtrace \
181 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
182 tst-bz22415-ENV
= MALLOC_TRACE
=$(objpfx
)tst-bz22415.mtrace \
183 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
184 tst-bz24228-ENV
= MALLOC_TRACE
=$(objpfx
)tst-bz24228.mtrace \
185 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
187 generated
+= test-fmemopen.mtrace test-fmemopen.
check
188 generated
+= tst-fopenloc.mtrace tst-fopenloc.
check
189 generated
+= tst-bz22415.mtrace tst-bz22415.
check
191 aux
:= fileops genops stdfiles stdio strops
193 ifeq ($(build-shared
),yes
)
194 generated
+= tst-bz24228.mtrace tst-bz24228.
check
195 aux
+= oldfileops oldstdfiles
198 shared-only-routines
= oldiofopen oldiofdopen oldiofclose oldfileops \
199 oldstdfiles oldiopopen oldpclose oldtmpfile \
200 oldiofgetpos oldiofgetpos64 oldiofsetpos \
203 ifeq ($(run-built-tests
),yes
)
204 tests-special
+= $(objpfx
)test-freopen.out
$(objpfx
)test-fmemopen-mem.out \
205 $(objpfx
)tst-bz22415-mem.out
206 ifeq (yes
,$(build-shared
))
207 # Run tst-fopenloc-cmp.out and tst-openloc-mem.out only if shared
208 # library is enabled since they depend on tst-fopenloc.out.
209 tests-special
+= $(objpfx
)tst-fopenloc-cmp.out
$(objpfx
)tst-fopenloc-mem.out \
210 $(objpfx
)tst-bz24228-mem.out
213 tests
+= tst-cleanup-default tst-cleanup-default-static
214 tests-static
+= tst-cleanup-default-static
215 tests-special
+= $(objpfx
)tst-cleanup-default-cmp.out
$(objpfx
)tst-cleanup-default-static-cmp.out
216 LDFLAGS-tst-cleanup-default
= -Wl
,--gc-sections
217 LDFLAGS-tst-cleanup-default-static
= -Wl
,--gc-sections
219 ifeq ($(have-gnu-retain
)$(have-z-start-stop-gc
),yesyes
)
220 tests
+= tst-cleanup-start-stop-gc tst-cleanup-start-stop-gc-static \
221 tst-cleanup-nostart-stop-gc tst-cleanup-nostart-stop-gc-static
222 tests-static
+= tst-cleanup-start-stop-gc-static tst-cleanup-nostart-stop-gc-static
223 tests-special
+= $(objpfx
)tst-cleanup-start-stop-gc-cmp.out \
224 $(objpfx
)tst-cleanup-start-stop-gc-static-cmp.out \
225 $(objpfx
)tst-cleanup-nostart-stop-gc-cmp.out \
226 $(objpfx
)tst-cleanup-nostart-stop-gc-static-cmp.out
227 LDFLAGS-tst-cleanup-start-stop-gc
:= -Wl
,--gc-sections
,-z
,start-stop-gc
228 LDFLAGS-tst-cleanup-start-stop-gc-static
:= -Wl
,--gc-sections
,-z
,start-stop-gc
229 LDFLAGS-tst-cleanup-nostart-stop-gc
:= -Wl
,--gc-sections
,-z
,nostart-stop-gc
230 LDFLAGS-tst-cleanup-nostart-stop-gc-static
:= -Wl
,--gc-sections
,-z
,nostart-stop-gc
236 ifeq ($(run-built-tests
),yes
)
237 LOCALES
:= de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
238 ja_JP.EUC-JP ja_JP.UTF-8
239 include ..
/gen-locales.mk
241 $(objpfx
)bug-ftell.out
: $(gen-locales
)
242 $(objpfx
)bug-ungetwc1.out
: $(gen-locales
)
243 $(objpfx
)bug-ungetwc2.out
: $(gen-locales
)
244 $(objpfx
)tst-fgetwc.out
: $(gen-locales
)
245 $(objpfx
)tst-fgetws.out
: $(gen-locales
)
246 $(objpfx
)tst-fopenloc.out
: $(gen-locales
)
247 $(objpfx
)tst-fputws.out
: $(gen-locales
)
248 $(objpfx
)tst-fseek.out
: $(gen-locales
)
249 $(objpfx
)tst-ftell-active-handler.out
: $(gen-locales
)
250 $(objpfx
)tst-ftell-append.out
: $(gen-locales
)
251 $(objpfx
)tst-ftell-partial-wide.out
: $(gen-locales
)
252 $(objpfx
)tst-setvbuf1.out
: $(gen-locales
)
253 $(objpfx
)tst-swscanf.out
: $(gen-locales
)
254 $(objpfx
)tst-ungetwc1.out
: $(gen-locales
)
255 $(objpfx
)tst-ungetwc2.out
: $(gen-locales
)
256 $(objpfx
)tst-widetext.out
: $(gen-locales
)
257 $(objpfx
)tst_wprintf2.out
: $(gen-locales
)
258 $(objpfx
)tst-wfile-sync.out
: $(gen-locales
)
261 define gen-tst-cleanup
262 $(objpfx
)tst-cleanup-
$1-cmp.out
: tst-cleanup.exp
$(objpfx
)tst-cleanup-
$1.out
263 cmp
$$^
> $$@
; $$(evaluate-test
)
266 $(foreach t
,default default-static start-stop-gc start-stop-gc-static nostart-stop-gc nostart-stop-gc-static
, \
267 $(eval
$(call gen-tst-cleanup
,$(t
))))
269 $(objpfx
)test-freopen.out
: test-freopen.sh
$(objpfx
)test-freopen
270 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix)' \
271 $(common-objpfx
)libio
/; \
274 $(objpfx
)tst-fopenloc-cmp.out
: ..
/iconvdata
/testdata
/ISO-8859-1..UTF8 \
275 $(objpfx
)tst-fopenloc.out
279 $(objpfx
)test-fmemopen-mem.out
: $(objpfx
)test-fmemopen.out
280 $(common-objpfx
)malloc
/mtrace
$(objpfx
)test-fmemopen.mtrace
> $@
; \
283 $(objpfx
)tst-fopenloc-mem.out
: $(objpfx
)tst-fopenloc.out
284 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-fopenloc.mtrace
> $@
; \
287 $(objpfx
)tst-bz22415-mem.out
: $(objpfx
)tst-bz22415.out
288 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-bz22415.mtrace
> $@
; \
291 $(objpfx
)tst-bz24228-mem.out
: $(objpfx
)tst-bz24228.out
292 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-bz24228.mtrace
> $@
; \