]> git.ipfire.org Git - thirdparty/glibc.git/blame - libio/Makefile
posix: Sync tempname with gnulib
[thirdparty/glibc.git] / libio / Makefile
CommitLineData
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#
21subdir := libio
22
a5f891ac
JM
23include ../Makeconfig
24
a4fea3f2 25headers := 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
31routines := \
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
54gen-as-const-headers += libio-macros.sym
55
20c894d2
FB
56# Exclude fortified routines from being built with _FORTIFY_SOURCE
57routines_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 71tests = 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 88tests-internal = tst-vtables tst-vtables-interposed
29055464 89
bcba7aa2
L
90ifeq (yes,$(build-shared))
91# Add test-fopenloc only if shared library is enabled since it depends on
92# shared localedata objects.
93tests += 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.
96tests += tst-bz24228
bcba7aa2 97endif
897d4284 98test-srcs = test-freopen
d64b6ad0 99
3f2e46a4 100ifeq ($(build-shared),yes)
7d6a8338 101routines += oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \
655c0697
UD
102 oldtmpfile oldiofgetpos oldiofgetpos64 oldiofsetpos \
103 oldiofsetpos64
1ea89a40
UD
104endif
105
c75ccd4c 106ifeq (yes,$(libc-reentrant))
edf5b2d7 107routines += 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
110endif
111
c75ccd4c
RM
112CPPFLAGS += $(libio-mtsafe)
113
21cea68e 114# Support for exception handling.
36975e8e
L
115CFLAGS-fileops.c += -fexceptions
116CFLAGS-fputc.c += -fexceptions
117CFLAGS-fputwc.c += -fexceptions
118CFLAGS-freopen64.c += -fexceptions
119CFLAGS-freopen.c += -fexceptions
120CFLAGS-fseek.c += -fexceptions
121CFLAGS-fseeko64.c += -fexceptions
122CFLAGS-fseeko.c += -fexceptions
123CFLAGS-ftello64.c += -fexceptions
124CFLAGS-ftello.c += -fexceptions
125CFLAGS-fwide.c += -fexceptions
126CFLAGS-genops.c += -fexceptions
127CFLAGS-getc.c += -fexceptions
128CFLAGS-getchar.c += -fexceptions
129CFLAGS-getwc.c += -fexceptions
130CFLAGS-getwchar.c += -fexceptions
131CFLAGS-iofclose.c += -fexceptions
8d98c7c0 132CFLAGS-iofflush.c += -fexceptions $(config-cflags-wno-ignored-attributes)
36975e8e
L
133CFLAGS-iofgetpos64.c += -fexceptions
134CFLAGS-iofgetpos.c += -fexceptions
135CFLAGS-iofgets.c += -fexceptions
136CFLAGS-iofgetws.c += -fexceptions
8d98c7c0 137CFLAGS-iofputs.c += -fexceptions $(config-cflags-wno-ignored-attributes)
36975e8e
L
138CFLAGS-iofputws.c += -fexceptions
139CFLAGS-iofread.c += -fexceptions
140CFLAGS-iofsetpos64.c += -fexceptions
141CFLAGS-iofsetpos.c += -fexceptions
142CFLAGS-ioftell.c += -fexceptions
8d98c7c0 143CFLAGS-iofwrite.c += -fexceptions $(config-cflags-wno-ignored-attributes)
36975e8e
L
144CFLAGS-iogetdelim.c += -fexceptions
145CFLAGS-iogetline.c += -fexceptions
146CFLAGS-iogets.c += -fexceptions
147CFLAGS-iogetwline.c += -fexceptions
148CFLAGS-ioputs.c += -fexceptions
149CFLAGS-ioseekoff.c += -fexceptions
150CFLAGS-ioseekpos.c += -fexceptions
151CFLAGS-iosetbuffer.c += -fexceptions
152CFLAGS-iosetvbuf.c += -fexceptions
153CFLAGS-ioungetc.c += -fexceptions
154CFLAGS-ioungetwc.c += -fexceptions
155CFLAGS-oldfileops.c += -fexceptions
156CFLAGS-oldiofclose.c += -fexceptions
157CFLAGS-oldiofgetpos64.c += -fexceptions
158CFLAGS-oldiofgetpos.c += -fexceptions
159CFLAGS-oldiofsetpos64.c += -fexceptions
160CFLAGS-oldiofsetpos.c += -fexceptions
161CFLAGS-peekc.c += -fexceptions
162CFLAGS-putc.c += -fexceptions
163CFLAGS-putchar.c += -fexceptions
164CFLAGS-putwc.c += -fexceptions
165CFLAGS-putwchar.c += -fexceptions
166CFLAGS-rewind.c += -fexceptions
167CFLAGS-wfileops.c += -fexceptions
168CFLAGS-wgenops.c += -fexceptions
169CFLAGS-oldiofopen.c += -fexceptions
170CFLAGS-iofopen.c += -fexceptions
171CFLAGS-iofopen64.c += -fexceptions
172CFLAGS-oldtmpfile.c += -fexceptions
8d98c7c0
AZ
173CFLAGS-fileno.c += $(config-cflags-wno-ignored-attributes)
174CFLAGS-feof_u.c += $(config-cflags-wno-ignored-attributes)
175CFLAGS-ferror_u.c += $(config-cflags-wno-ignored-attributes)
176CFLAGS-getc_u.c += $(config-cflags-wno-ignored-attributes)
177CFLAGS-iofflush_u.c += $(config-cflags-wno-ignored-attributes)
178CFLAGS-putc_u.c += $(config-cflags-wno-ignored-attributes)
179CFLAGS-iofgets_u.c += $(config-cflags-wno-ignored-attributes)
180CFLAGS-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
184CFLAGS-tst-bz24051.c += $(no-fortify-source)
185CFLAGS-tst-bz24153.c += $(no-fortify-source)
186
36975e8e 187CFLAGS-tst_putwc.c += -DOBJPFX=\"$(objpfx)\"
e8595e84 188
2d9837c1 189# These test cases intentionally use overlapping arguments
20c894d2
FB
190CFLAGS-tst-sprintf-ub.c += -Wno-restrict $(no-fortify-source)
191CFLAGS-tst-sprintf-chk-ub.c += -Wno-restrict $(no-fortify-source)
2d9837c1 192
21cc130b
DL
193LDFLAGS-tst-bz24228 = -Wl,--version-script=tst-bz24228.map
194
9c38a689
UD
195tst_wprintf2-ARGS = "Some Text"
196
2d2d9f2b
SP
197test-fmemopen-ENV = MALLOC_TRACE=$(objpfx)test-fmemopen.mtrace \
198 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
199tst-fopenloc-ENV = MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace \
200 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
201tst-bz22415-ENV = MALLOC_TRACE=$(objpfx)tst-bz22415.mtrace \
202 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
203tst-bz24228-ENV = MALLOC_TRACE=$(objpfx)tst-bz24228.mtrace \
204 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
277f8cdf 205
63e952d9 206generated += test-fmemopen.mtrace test-fmemopen.check
f08e9a26 207generated += tst-fopenloc.mtrace tst-fopenloc.check
cc683f7e 208generated += tst-bz22415.mtrace tst-bz22415.check
a3b231b7 209
414fd335 210aux := fileops genops stdfiles stdio strops
96aa2d94 211
3f2e46a4 212ifeq ($(build-shared),yes)
21cc130b 213generated += tst-bz24228.mtrace tst-bz24228.check
1ea89a40
UD
214aux += oldfileops oldstdfiles
215endif
216
bd355af0 217shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \
655c0697
UD
218 oldstdfiles oldiopopen oldpclose oldtmpfile \
219 oldiofgetpos oldiofgetpos64 oldiofsetpos \
220 oldiofsetpos64
f2ea0f5b 221
03ac099f 222ifeq ($(run-built-tests),yes)
cc683f7e 223tests-special += $(objpfx)test-freopen.out $(objpfx)test-fmemopen-mem.out \
0bfddfc9 224 $(objpfx)tst-bz22415-mem.out
bcba7aa2 225ifeq (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
228tests-special += $(objpfx)tst-fopenloc-cmp.out $(objpfx)tst-fopenloc-mem.out \
229 $(objpfx)tst-bz24228-mem.out
bcba7aa2 230endif
cd6ae7ea
FS
231
232tests += tst-cleanup-default tst-cleanup-default-static
233tests-static += tst-cleanup-default-static
234tests-special += $(objpfx)tst-cleanup-default-cmp.out $(objpfx)tst-cleanup-default-static-cmp.out
235LDFLAGS-tst-cleanup-default = -Wl,--gc-sections
236LDFLAGS-tst-cleanup-default-static = -Wl,--gc-sections
237
238ifeq ($(have-gnu-retain)$(have-z-start-stop-gc),yesyes)
239tests += tst-cleanup-start-stop-gc tst-cleanup-start-stop-gc-static \
240 tst-cleanup-nostart-stop-gc tst-cleanup-nostart-stop-gc-static
241tests-static += tst-cleanup-start-stop-gc-static tst-cleanup-nostart-stop-gc-static
242tests-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
246LDFLAGS-tst-cleanup-start-stop-gc := -Wl,--gc-sections,-z,start-stop-gc
247LDFLAGS-tst-cleanup-start-stop-gc-static := -Wl,--gc-sections,-z,start-stop-gc
248LDFLAGS-tst-cleanup-nostart-stop-gc := -Wl,--gc-sections,-z,nostart-stop-gc
249LDFLAGS-tst-cleanup-nostart-stop-gc-static := -Wl,--gc-sections,-z,nostart-stop-gc
250endif
b647f210 251endif
897d4284 252
f214606a
JM
253include ../Rules
254
f881f6ff
AS
255ifeq ($(run-built-tests),yes)
256LOCALES := 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
258include ../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
278endif
279
cd6ae7ea
FS
280define gen-tst-cleanup
281$(objpfx)tst-cleanup-$1-cmp.out: tst-cleanup.exp $(objpfx)tst-cleanup-$1.out
282 cmp $$^ > $$@; $$(evaluate-test)
283endef
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)