blob: 7b3bcf90fe359ba03520c7a6337ec1f94d8ce2c7 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# Copyright (C) 1995-2015 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 bits/stdio-lock.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 = $(exceptions)
88CFLAGS-fputc.c = $(exceptions)
89CFLAGS-fputwc.c = $(exceptions)
90CFLAGS-freopen64.c = $(exceptions)
91CFLAGS-freopen.c = $(exceptions)
92CFLAGS-fseek.c = $(exceptions)
93CFLAGS-fseeko64.c = $(exceptions)
94CFLAGS-fseeko.c = $(exceptions)
95CFLAGS-ftello64.c = $(exceptions)
96CFLAGS-ftello.c = $(exceptions)
97CFLAGS-fwide.c = $(exceptions)
98CFLAGS-genops.c = $(exceptions)
99CFLAGS-getc.c = $(exceptions)
100CFLAGS-getchar.c = $(exceptions)
101CFLAGS-getwc.c = $(exceptions)
102CFLAGS-getwchar.c = $(exceptions)
103CFLAGS-iofclose.c = $(exceptions)
104CFLAGS-iofflush.c = $(exceptions)
105CFLAGS-iofgetpos64.c = $(exceptions)
106CFLAGS-iofgetpos.c = $(exceptions)
107CFLAGS-iofgets.c = $(exceptions)
108CFLAGS-iofgetws.c = $(exceptions)
109CFLAGS-iofputs.c = $(exceptions)
110CFLAGS-iofputws.c = $(exceptions)
111CFLAGS-iofread.c = $(exceptions)
112CFLAGS-iofsetpos64.c = $(exceptions)
113CFLAGS-iofsetpos.c = $(exceptions)
114CFLAGS-ioftell.c = $(exceptions)
115CFLAGS-iofwrite.c = $(exceptions)
116CFLAGS-iogetdelim.c = $(exceptions)
117CFLAGS-iogetline.c = $(exceptions)
118CFLAGS-iogets.c = $(exceptions)
119CFLAGS-iogetwline.c = $(exceptions)
120CFLAGS-ioputs.c = $(exceptions)
121CFLAGS-ioseekoff.c = $(exceptions)
122CFLAGS-ioseekpos.c = $(exceptions)
123CFLAGS-iosetbuffer.c = $(exceptions)
124CFLAGS-iosetvbuf.c = $(exceptions)
125CFLAGS-ioungetc.c = $(exceptions)
126CFLAGS-ioungetwc.c = $(exceptions)
127CFLAGS-oldfileops.c = $(exceptions)
128CFLAGS-oldiofclose.c = $(exceptions)
129CFLAGS-oldiofgetpos64.c = $(exceptions)
130CFLAGS-oldiofgetpos.c = $(exceptions)
131CFLAGS-oldiofsetpos64.c = $(exceptions)
132CFLAGS-oldiofsetpos.c = $(exceptions)
133CFLAGS-peekc.c = $(exceptions)
134CFLAGS-putc.c = $(exceptions)
135CFLAGS-putchar.c = $(exceptions)
136CFLAGS-putwc.c = $(exceptions)
137CFLAGS-putwchar.c = $(exceptions)
138CFLAGS-rewind.c = $(exceptions)
139CFLAGS-wfileops.c = $(exceptions)
140CFLAGS-wgenops.c = $(exceptions)
141CFLAGS-oldiofopen.c = $(exceptions)
142CFLAGS-iofopen.c = $(exceptions)
143CFLAGS-iofopen64.c = $(exceptions)
144CFLAGS-oldtmpfile.c = $(exceptions)
145# XXX Do we need filedoalloc and wfiledoalloc? Others?
146
147CFLAGS-tst_putwc.c = -DOBJPFX=\"$(objpfx)\"
148
149tst_wprintf2-ARGS = "Some Text"
150
151tst-fopenloc-ENV = MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace
152
153generated += tst-fopenloc.mtrace tst-fopenloc.check
154
155aux := fileops genops stdfiles stdio strops
156
157ifeq ($(build-shared),yes)
158aux += oldfileops oldstdfiles
159endif
160
161shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \
162 oldstdfiles oldiopopen oldpclose oldtmpfile \
163 oldiofgetpos oldiofgetpos64 oldiofsetpos \
164 oldiofsetpos64
165
166ifeq ($(run-built-tests),yes)
167tests-special += $(objpfx)test-freopen.out
168ifeq (yes,$(build-shared))
169# Run tst-fopenloc-cmp.out and tst-openloc-mem.out only if shared
170# library is enabled since they depend on tst-fopenloc.out.
171tests-special += $(objpfx)tst-fopenloc-cmp.out $(objpfx)tst-fopenloc-mem.out
172endif
173endif
174
175include ../Rules
176
177$(objpfx)test-freopen.out: test-freopen.sh $(objpfx)test-freopen
178 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' \
179 $(common-objpfx)libio/; \
180 $(evaluate-test)
181
182$(objpfx)tst-fopenloc-cmp.out: ../iconvdata/testdata/ISO-8859-1..UTF8 \
183 $(objpfx)tst-fopenloc.out
184 cmp $^ > $@; \
185 $(evaluate-test)
186
187$(objpfx)tst-fopenloc-mem.out: $(objpfx)tst-fopenloc.out
188 $(common-objpfx)malloc/mtrace $(objpfx)tst-fopenloc.mtrace > $@; \
189 $(evaluate-test)