scripts: Fix fortify checks if compiler does not support _FORTIFY_SOURCE=3
[glibc.git] / misc / Makefile
blobfe0d49c1de5c8a0cf51d84ce4455bd87587b8046
1 # Copyright (C) 1991-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 # Sub-makefile for misc portion of the library.
22 subdir := misc
24 include ../Makeconfig
26 headers := \
27 sys/uio.h \
28 bits/uio-ext.h \
29 bits/uio_lim.h \
30 sys/ioctl.h \
31 bits/ioctls.h \
32 bits/ioctl-types.h \
33 sys/ptrace.h \
34 sys/file.h \
35 sys/dir.h \
36 sys/cdefs.h \
37 ar.h \
38 a.out.h \
39 libgen.h \
40 stab.h \
41 bits/stab.def \
42 sgtty.h \
43 ttyent.h \
44 paths.h \
45 sys/reboot.h \
46 sys/mman.h \
47 sys/param.h \
48 bits/param.h \
49 fstab.h \
50 mntent.h \
51 search.h \
52 err.h \
53 error.h \
54 sys/queue.h \
55 sysexits.h \
56 syscall.h \
57 sys/syscall.h \
58 sys/swap.h \
59 sys/select.h \
60 sys/sysinfo.h \
61 regexp.h \
62 bits/select.h \
63 bits/mman.h \
64 sys/xattr.h \
65 syslog.h \
66 sys/syslog.h \
67 bits/syslog-decl.h \
68 bits/syslog.h \
69 bits/syslog-ldbl.h \
70 bits/syslog-path.h \
71 bits/error.h \
72 bits/select-decl.h \
73 bits/select2.h \
74 bits/hwcap.h \
75 sys/auxv.h \
76 sys/sysmacros.h \
77 bits/sysmacros.h \
78 bits/types/struct_iovec.h \
79 bits/err-ldbl.h \
80 bits/error-ldbl.h \
81 sys/single_threaded.h \
82 # headers
84 routines := \
85 acct \
86 allocate_once \
87 atomic_wide_counter \
88 brk \
89 chflags \
90 chroot \
91 daemon \
92 dirname \
93 efgcvt \
94 efgcvt_r \
95 err \
96 error \
97 fchflags \
98 fd_to_filename \
99 fdatasync \
100 fgetxattr \
101 flistxattr \
102 fremovexattr \
103 fsetxattr \
104 fstab \
105 fsync \
106 ftruncate \
107 ftruncate64 \
108 futimes \
109 futimesat \
110 getauxval \
111 getclktck \
112 getdomain \
113 getdtsz \
114 gethostid \
115 gethostname \
116 getloadavg \
117 getpagesize \
118 getpass \
119 getsysstats \
120 getttyent \
121 getusershell \
122 getxattr \
123 gtty \
124 hsearch \
125 hsearch_r \
126 ifunc-impl-list \
127 insremque \
128 ioctl \
129 lgetxattr \
130 listxattr \
131 llistxattr \
132 lremovexattr \
133 lsearch \
134 lsetxattr \
135 lutimes \
136 madvise \
137 makedev \
138 mincore \
139 mkdtemp \
140 mkostemp \
141 mkostemp64 \
142 mkostemps \
143 mkostemps64 \
144 mkstemp \
145 mkstemp64 \
146 mkstemps \
147 mkstemps64 \
148 mktemp \
149 mlock \
150 mlockall \
151 mmap \
152 mmap64 \
153 mntent \
154 mntent_r \
155 mprotect \
156 msync \
157 munlock \
158 munlockall \
159 munmap \
160 preadv \
161 preadv2 \
162 preadv64 \
163 preadv64v2 \
164 pselect \
165 ptrace \
166 pwritev \
167 pwritev2 \
168 pwritev64 \
169 pwritev64v2 \
170 qefgcvt \
171 qefgcvt_r \
172 readv \
173 reboot \
174 regexp \
175 remap_file_pages \
176 removexattr \
177 revoke \
178 sbrk \
179 select \
180 setdomain \
181 setegid \
182 seteuid \
183 sethostid \
184 sethostname \
185 setregid \
186 setreuid \
187 setxattr \
188 single_threaded \
189 sstk \
190 stty \
191 swapoff \
192 swapon \
193 sync \
194 syncfs \
195 syscall \
196 syslog \
197 truncate \
198 truncate64 \
199 tsearch \
200 ttyslot \
201 ualarm \
202 unwind-link \
203 usleep \
204 ustat \
205 utimes \
206 vhangup \
207 writev \
208 # routines
210 # Exclude fortified routines from being built with _FORTIFY_SOURCE
211 routines_no_fortify += \
212 getdomain \
213 gethostname \
214 syslog \
215 # routines_no_fortify
217 generated += \
218 tst-allocate_once-mem.out \
219 tst-allocate_once.mtrace \
220 tst-error1-mem.out \
221 tst-error1.mtrace \
222 # generated
224 aux := init-misc
225 install-lib := libg.a
227 gpl2lgpl := \
228 error.c \
229 error.h \
230 # gpl2lgpl
232 tests := \
233 bug-hsearch1 \
234 bug18240 \
235 tst-dbl-efgcvt \
236 tst-dirname \
237 tst-empty \
238 tst-error1 \
239 tst-fdset \
240 tst-hsearch \
241 tst-insremque \
242 tst-ioctl \
243 tst-ldbl-efgcvt \
244 tst-ldbl-error \
245 tst-ldbl-errorfptr \
246 tst-ldbl-warn \
247 tst-makedev \
248 tst-mntent \
249 tst-mntent-autofs \
250 tst-mntent-blank-corrupt \
251 tst-mntent-blank-passno \
252 tst-mntent-escape \
253 tst-mntent2 \
254 tst-preadvwritev \
255 tst-preadvwritev2 \
256 tst-preadvwritev64 \
257 tst-preadvwritev64v2 \
258 tst-pselect \
259 tst-select \
260 tst-syscalls \
261 tst-tsearch \
262 tst-warn-wide \
263 # tests
265 tests-time64 := \
266 tst-ioctl-time64 \
267 tst-pselect-time64 \
268 tst-select-time64 \
269 # tests-time64
271 # Tests which need libdl.
272 ifeq (yes,$(build-shared))
273 tests += tst-gethostid
274 endif
276 tests-internal := \
277 tst-allocate_once \
278 tst-atomic \
279 tst-atomic-long \
280 # tests-internal
281 tests-static := tst-empty
283 # Test for the internal, non-exported __fd_to_filename function.
284 tests-internal += tst-fd_to_filename
285 tests-static += tst-fd_to_filename
287 ifeq ($(run-built-tests),yes)
288 tests-special += $(objpfx)tst-error1-mem.out \
289 $(objpfx)tst-allocate_once-mem.out
290 endif
292 tests-container := tst-syslog
294 CFLAGS-select.c += -fexceptions -fasynchronous-unwind-tables
295 CFLAGS-tsearch.c += $(uses-callbacks)
296 CFLAGS-lsearch.c += $(uses-callbacks)
297 CFLAGS-pselect.c += -fexceptions
298 CFLAGS-readv.c += -fexceptions -fasynchronous-unwind-tables
299 CFLAGS-writev.c += -fexceptions -fasynchronous-unwind-tables
300 CFLAGS-preadv.c += -fexceptions -fasynchronous-unwind-tables
301 CFLAGS-preadv64.c += -fexceptions -fasynchronous-unwind-tables
302 CFLAGS-pwritev.c += -fexceptions -fasynchronous-unwind-tables
303 CFLAGS-pwritev64.c += -fexceptions -fasynchronous-unwind-tables
304 CFLAGS-preadv2.c += -fexceptions -fasynchronous-unwind-tables
305 CFLAGS-preadv64v2.c += -fexceptions -fasynchronous-unwind-tables
306 CFLAGS-pwritev2.c += -fexceptions -fasynchronous-unwind-tables
307 CFLAGS-pwritev64v2.c += -fexceptions -fasynchronous-unwind-tables
308 CFLAGS-usleep.c += -fexceptions
309 CFLAGS-syslog.c += -fexceptions
310 CFLAGS-error.c += -fexceptions
311 CFLAGS-getpass.c += -fexceptions
312 CFLAGS-mkstemp.c += -fexceptions
313 CFLAGS-mkstemp64.c += -fexceptions
314 CFLAGS-getsysstats.c += -fexceptions
315 CFLAGS-getusershell.c += -fexceptions
316 CFLAGS-err.c += -fexceptions
317 CFLAGS-tst-tsearch.c += $(stack-align-test-flags)
318 CFLAGS-msync.c += -fexceptions -fasynchronous-unwind-tables
319 CFLAGS-fdatasync.c += -fexceptions -fasynchronous-unwind-tables
320 CFLAGS-fsync.c += -fexceptions -fasynchronous-unwind-tables
321 CFLAGS-makedev.c += $(config-cflags-wno-ignored-attributes)
322 CFLAGS-mmap64.c += $(config-cflags-wno-ignored-attributes)
324 # Called during static library initialization, so turn stack-protection
325 # off for non-shared builds.
326 CFLAGS-sbrk.o = $(no-stack-protector)
327 CFLAGS-sbrk.op = $(no-stack-protector)
328 CFLAGS-brk.o = $(no-stack-protector)
329 CFLAGS-brk.op = $(no-stack-protector)
330 CFLAGS-mmap.o = $(no-stack-protector)
331 CFLAGS-mmap.op = $(no-stack-protector)
332 CFLAGS-mmap64.o = $(no-stack-protector)
333 CFLAGS-mmap64.op = $(no-stack-protector)
335 include ../Rules
337 $(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib)
339 $(objpfx)tst-tsearch: $(libm)
341 tst-error1-ENV = MALLOC_TRACE=$(objpfx)tst-error1.mtrace \
342 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
343 tst-error1-ARGS = $(objpfx)tst-error1.out
344 $(objpfx)tst-error1-mem.out: $(objpfx)tst-error1.out
345 $(common-objpfx)malloc/mtrace $(objpfx)tst-error1.mtrace > $@; \
346 $(evaluate-test)
348 tst-allocate_once-ENV = MALLOC_TRACE=$(objpfx)tst-allocate_once.mtrace \
349 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
350 $(objpfx)tst-allocate_once-mem.out: $(objpfx)tst-allocate_once.out
351 $(common-objpfx)malloc/mtrace $(objpfx)tst-allocate_once.mtrace > $@; \
352 $(evaluate-test)
354 $(objpfx)tst-select: $(librt)
355 $(objpfx)tst-select-time64: $(librt)
356 $(objpfx)tst-pselect: $(librt)
357 $(objpfx)tst-pselect-time64: $(librt)