Add a test to check for duplicate definitions in the static library
[glibc.git] / misc / Makefile
blobc273ec6974a96c3f75dcb880921d01e68ae17e03
1 # Copyright (C) 1991-2024 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 := \
293 tst-syslog \
294 tst-syslog-long-progname \
295 # tests-container
297 CFLAGS-select.c += -fexceptions -fasynchronous-unwind-tables
298 CFLAGS-tsearch.c += $(uses-callbacks)
299 CFLAGS-lsearch.c += $(uses-callbacks)
300 CFLAGS-pselect.c += -fexceptions
301 CFLAGS-readv.c += -fexceptions -fasynchronous-unwind-tables
302 CFLAGS-writev.c += -fexceptions -fasynchronous-unwind-tables
303 CFLAGS-preadv.c += -fexceptions -fasynchronous-unwind-tables
304 CFLAGS-preadv64.c += -fexceptions -fasynchronous-unwind-tables
305 CFLAGS-pwritev.c += -fexceptions -fasynchronous-unwind-tables
306 CFLAGS-pwritev64.c += -fexceptions -fasynchronous-unwind-tables
307 CFLAGS-preadv2.c += -fexceptions -fasynchronous-unwind-tables
308 CFLAGS-preadv64v2.c += -fexceptions -fasynchronous-unwind-tables
309 CFLAGS-pwritev2.c += -fexceptions -fasynchronous-unwind-tables
310 CFLAGS-pwritev64v2.c += -fexceptions -fasynchronous-unwind-tables
311 CFLAGS-usleep.c += -fexceptions
312 CFLAGS-syslog.c += -fexceptions
313 CFLAGS-error.c += -fexceptions
314 CFLAGS-getpass.c += -fexceptions
315 CFLAGS-mkstemp.c += -fexceptions
316 CFLAGS-mkstemp64.c += -fexceptions
317 CFLAGS-getsysstats.c += -fexceptions
318 CFLAGS-getusershell.c += -fexceptions
319 CFLAGS-err.c += -fexceptions
320 CFLAGS-tst-tsearch.c += $(stack-align-test-flags)
321 CFLAGS-msync.c += -fexceptions -fasynchronous-unwind-tables
322 CFLAGS-fdatasync.c += -fexceptions -fasynchronous-unwind-tables
323 CFLAGS-fsync.c += -fexceptions -fasynchronous-unwind-tables
324 CFLAGS-makedev.c += $(config-cflags-wno-ignored-attributes)
325 CFLAGS-mmap64.c += $(config-cflags-wno-ignored-attributes)
327 # Called during static library initialization, so turn stack-protection
328 # off for non-shared builds.
329 CFLAGS-sbrk.o = $(no-stack-protector)
330 CFLAGS-sbrk.op = $(no-stack-protector)
331 CFLAGS-brk.o = $(no-stack-protector)
332 CFLAGS-brk.op = $(no-stack-protector)
333 CFLAGS-mmap.o = $(no-stack-protector)
334 CFLAGS-mmap.op = $(no-stack-protector)
335 CFLAGS-mmap64.o = $(no-stack-protector)
336 CFLAGS-mmap64.op = $(no-stack-protector)
338 include ../Rules
340 $(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib)
342 $(objpfx)tst-tsearch: $(libm)
344 tst-error1-ENV = MALLOC_TRACE=$(objpfx)tst-error1.mtrace \
345 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
346 tst-error1-ARGS = $(objpfx)tst-error1.out
347 $(objpfx)tst-error1-mem.out: $(objpfx)tst-error1.out
348 $(common-objpfx)malloc/mtrace $(objpfx)tst-error1.mtrace > $@; \
349 $(evaluate-test)
351 tst-allocate_once-ENV = MALLOC_TRACE=$(objpfx)tst-allocate_once.mtrace \
352 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
353 $(objpfx)tst-allocate_once-mem.out: $(objpfx)tst-allocate_once.out
354 $(common-objpfx)malloc/mtrace $(objpfx)tst-allocate_once.mtrace > $@; \
355 $(evaluate-test)
357 tst-syslog-long-progname-ENV = GLIBC_TUNABLES=glibc.malloc.check=3 \
358 LD_PRELOAD=libc_malloc_debug.so.0
360 $(objpfx)tst-select: $(librt)
361 $(objpfx)tst-select-time64: $(librt)
362 $(objpfx)tst-pselect: $(librt)
363 $(objpfx)tst-pselect-time64: $(librt)