blob: 4189bc4ad0dd670d5f0deed6da030d8c68827c21 [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001# Copyright (C) 1995-2016 Free Software Foundation, Inc.
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
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.
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
12# Lesser General Public License for more details.
13
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# <http://www.gnu.org/licenses/>.
17
18#
19# Specific makefile for libio.
20#
21subdir := libio
22
23include ../Makeconfig
24
25headers := stdio.h libio.h _G_config.h bits/stdio.h \
26 bits/sys_errlist.h bits/stdio2.h bits/stdio-ldbl.h bits/libio-ldbl.h
27
28routines := \
29 filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \
30 iofopncook iofputs iofread iofsetpos ioftell wfiledoalloc \
31 iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs \
32 ioseekoff ioseekpos iosetbuffer iosetvbuf ioungetc \
33 iovsprintf iovsscanf \
34 iofgetpos64 iofopen64 iofsetpos64 \
35 fputwc fputwc_u getwc getwc_u getwchar getwchar_u iofgetws iofgetws_u \
36 iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u \
37 putwchar putwchar_u putchar putchar_u fwprintf swprintf vwprintf \
38 wprintf wscanf fwscanf vwscanf vswprintf iovswscanf swscanf wgenops \
39 wstrops wfileops iofwide fwide wmemstream \
40 \
41 clearerr feof ferror fileno fputc freopen fseek getc getchar \
42 memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \
43 iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello \
44 freopen64 fseeko64 ftello64 \
45 \
46 __fbufsize __freading __fwriting __freadable __fwritable __flbf \
47 __fpurge __fpending __fsetlocking \
48 \
49 libc_fatal fmemopen oldfmemopen
50
51tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
52 tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 \
53 tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf \
54 tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \
55 tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
56 tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \
57 tst-mmap2-eofsync tst-mmap-offend bug-fopena+ bug-wfflush \
58 bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \
59 tst-memstream1 tst-memstream2 \
60 tst-wmemstream1 tst-wmemstream2 \
61 bug-memstream1 bug-wmemstream1 \
62 tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \
63 tst-fwrite-error tst-ftell-partial-wide tst-ftell-active-handler \
64 tst-ftell-append tst-fputws
65ifeq (yes,$(build-shared))
66# Add test-fopenloc only if shared library is enabled since it depends on
67# shared localedata objects.
68tests += tst-fopenloc
69endif
70test-srcs = test-freopen
71
72ifeq ($(build-shared),yes)
73routines += oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \
74 oldtmpfile oldiofgetpos oldiofgetpos64 oldiofsetpos \
75 oldiofsetpos64
76endif
77
78ifeq (yes,$(libc-reentrant))
79routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \
80 iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u \
81 iofputs_u
82endif
83
84CPPFLAGS += $(libio-mtsafe)
85
86# Support for exception handling.
87CFLAGS-fileops.c = -fexceptions
88CFLAGS-fputc.c = -fexceptions
89CFLAGS-fputwc.c = -fexceptions
90CFLAGS-freopen64.c = -fexceptions
91CFLAGS-freopen.c = -fexceptions
92CFLAGS-fseek.c = -fexceptions
93CFLAGS-fseeko64.c = -fexceptions
94CFLAGS-fseeko.c = -fexceptions
95CFLAGS-ftello64.c = -fexceptions
96CFLAGS-ftello.c = -fexceptions
97CFLAGS-fwide.c = -fexceptions
98CFLAGS-genops.c = -fexceptions
99CFLAGS-getc.c = -fexceptions
100CFLAGS-getchar.c = -fexceptions
101CFLAGS-getwc.c = -fexceptions
102CFLAGS-getwchar.c = -fexceptions
103CFLAGS-iofclose.c = -fexceptions
104CFLAGS-iofflush.c = -fexceptions
105CFLAGS-iofgetpos64.c = -fexceptions
106CFLAGS-iofgetpos.c = -fexceptions
107CFLAGS-iofgets.c = -fexceptions
108CFLAGS-iofgetws.c = -fexceptions
109CFLAGS-iofputs.c = -fexceptions
110CFLAGS-iofputws.c = -fexceptions
111CFLAGS-iofread.c = -fexceptions
112CFLAGS-iofsetpos64.c = -fexceptions
113CFLAGS-iofsetpos.c = -fexceptions
114CFLAGS-ioftell.c = -fexceptions
115CFLAGS-iofwrite.c = -fexceptions
116CFLAGS-iogetdelim.c = -fexceptions
117CFLAGS-iogetline.c = -fexceptions
118CFLAGS-iogets.c = -fexceptions
119CFLAGS-iogetwline.c = -fexceptions
120CFLAGS-ioputs.c = -fexceptions
121CFLAGS-ioseekoff.c = -fexceptions
122CFLAGS-ioseekpos.c = -fexceptions
123CFLAGS-iosetbuffer.c = -fexceptions
124CFLAGS-iosetvbuf.c = -fexceptions
125CFLAGS-ioungetc.c = -fexceptions
126CFLAGS-ioungetwc.c = -fexceptions
127CFLAGS-oldfileops.c = -fexceptions
128CFLAGS-oldiofclose.c = -fexceptions
129CFLAGS-oldiofgetpos64.c = -fexceptions
130CFLAGS-oldiofgetpos.c = -fexceptions
131CFLAGS-oldiofsetpos64.c = -fexceptions
132CFLAGS-oldiofsetpos.c = -fexceptions
133CFLAGS-peekc.c = -fexceptions
134CFLAGS-putc.c = -fexceptions
135CFLAGS-putchar.c = -fexceptions
136CFLAGS-putwc.c = -fexceptions
137CFLAGS-putwchar.c = -fexceptions
138CFLAGS-rewind.c = -fexceptions
139CFLAGS-wfileops.c = -fexceptions
140CFLAGS-wgenops.c = -fexceptions
141CFLAGS-oldiofopen.c = -fexceptions
142CFLAGS-iofopen.c = -fexceptions
143CFLAGS-iofopen64.c = -fexceptions
144CFLAGS-oldtmpfile.c = -fexceptions
145# XXX Do we need filedoalloc and wfiledoalloc? Others?
146
147CFLAGS-tst_putwc.c = -DOBJPFX=\"$(objpfx)\"
148
149tst_wprintf2-ARGS = "Some Text"
150
151test-fmemopen-ENV = MALLOC_TRACE=$(objpfx)test-fmemopen.mtrace
152tst-fopenloc-ENV = MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace
153
154generated += test-fmemopen.mtrace test-fmemopen.check
155generated += tst-fopenloc.mtrace tst-fopenloc.check
156
157aux := fileops genops stdfiles stdio strops
158
159ifeq ($(build-shared),yes)
160aux += oldfileops oldstdfiles
161endif
162
163shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \
164 oldstdfiles oldiopopen oldpclose oldtmpfile \
165 oldiofgetpos oldiofgetpos64 oldiofsetpos \
166 oldiofsetpos64
167
168ifeq ($(run-built-tests),yes)
169tests-special += $(objpfx)test-freopen.out $(objpfx)test-fmemopen-mem.out
170ifeq (yes,$(build-shared))
171# Run tst-fopenloc-cmp.out and tst-openloc-mem.out only if shared
172# library is enabled since they depend on tst-fopenloc.out.
173tests-special += $(objpfx)tst-fopenloc-cmp.out $(objpfx)tst-fopenloc-mem.out
174endif
175endif
176
177include ../Rules
178
179ifeq ($(run-built-tests),yes)
180LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
181 ja_JP.EUC-JP ja_JP.UTF-8
182include ../gen-locales.mk
183
184$(objpfx)bug-ftell.out: $(gen-locales)
185$(objpfx)bug-ungetwc1.out: $(gen-locales)
186$(objpfx)bug-ungetwc2.out: $(gen-locales)
187$(objpfx)tst-fgetwc.out: $(gen-locales)
188$(objpfx)tst-fgetws.out: $(gen-locales)
189$(objpfx)tst-fopenloc.out: $(gen-locales)
190$(objpfx)tst-fputws.out: $(gen-locales)
191$(objpfx)tst-fseek.out: $(gen-locales)
192$(objpfx)tst-ftell-active-handler.out: $(gen-locales)
193$(objpfx)tst-ftell-append.out: $(gen-locales)
194$(objpfx)tst-ftell-partial-wide.out: $(gen-locales)
195$(objpfx)tst-setvbuf1.out: $(gen-locales)
196$(objpfx)tst-swscanf.out: $(gen-locales)
197$(objpfx)tst-ungetwc1.out: $(gen-locales)
198$(objpfx)tst-ungetwc2.out: $(gen-locales)
199$(objpfx)tst-widetext.out: $(gen-locales)
200$(objpfx)tst_wprintf2.out: $(gen-locales)
201endif
202
203$(objpfx)test-freopen.out: test-freopen.sh $(objpfx)test-freopen
204 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' \
205 $(common-objpfx)libio/; \
206 $(evaluate-test)
207
208$(objpfx)tst-fopenloc-cmp.out: ../iconvdata/testdata/ISO-8859-1..UTF8 \
209 $(objpfx)tst-fopenloc.out
210 cmp $^ > $@; \
211 $(evaluate-test)
212
213$(objpfx)test-fmemopen-mem.out: $(objpfx)test-fmemopen.out
214 $(common-objpfx)malloc/mtrace $(objpfx)test-fmemopen.mtrace > $@; \
215 $(evaluate-test)
216
217$(objpfx)tst-fopenloc-mem.out: $(objpfx)tst-fopenloc.out
218 $(common-objpfx)malloc/mtrace $(objpfx)tst-fopenloc.mtrace > $@; \
219 $(evaluate-test)