]> git.ipfire.org Git - thirdparty/glibc.git/blob - support/Makefile
elf: Testing infrastructure for ld.so DSO sorting (BZ #17645)
[thirdparty/glibc.git] / support / Makefile
1 # Makefile for support library, used only at build and test time
2 # Copyright (C) 2016-2021 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
14
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <https://www.gnu.org/licenses/>.
18
19 subdir := support
20
21 include ../Makeconfig
22
23 extra-libs := libsupport
24 extra-libs-others = $(extra-libs)
25 extra-libs-noinstall := $(extra-libs)
26
27 libsupport-routines = \
28 blob_repeat \
29 check \
30 check_addrinfo \
31 check_dns_packet \
32 check_hostent \
33 check_netent \
34 delayed_exit \
35 ignore_stderr \
36 next_to_fault \
37 oom_error \
38 resolv_response_context_duplicate \
39 resolv_response_context_free \
40 resolv_test \
41 set_fortify_handler \
42 support_stack_alloc \
43 support-xfstat \
44 support-xfstat-time64 \
45 support-xstat \
46 support-xstat-time64 \
47 support_become_root \
48 support_can_chroot \
49 support_capture_subprocess \
50 support_capture_subprocess_check \
51 support_chroot \
52 support_copy_file \
53 support_copy_file_range \
54 support_create_timer \
55 support_descriptor_supports_holes \
56 support_descriptors \
57 support_enter_mount_namespace \
58 support_enter_network_namespace \
59 support_format_address_family \
60 support_format_addrinfo \
61 support_format_dns_packet \
62 support_format_herrno \
63 support_format_hostent \
64 support_format_netent \
65 support_isolate_in_subprocess \
66 support_mutex_pi_monotonic \
67 support_path_support_time64 \
68 support_process_state \
69 support_ptrace \
70 support-open-dev-null-range \
71 support_openpty \
72 support_paths \
73 support_quote_blob \
74 support_quote_blob_wide \
75 support_quote_string \
76 support_record_failure \
77 support_run_diff \
78 support_select_modifies_timeout \
79 support_select_normalizes_timeout \
80 support_set_small_thread_stack_size \
81 support_shared_allocate \
82 support_small_stack_thread_attribute \
83 support_stat_nanoseconds \
84 support_subprocess \
85 support_test_compare_blob \
86 support_test_compare_failure \
87 support_test_compare_string \
88 support_test_compare_string_wide \
89 support_test_main \
90 support_test_verify_impl \
91 support_wait_for_thread_exit \
92 support_write_file_string \
93 temp_file \
94 timespec \
95 timespec-time64 \
96 timespec-add \
97 timespec-add-time64 \
98 timespec-sub \
99 timespec-sub-time64 \
100 write_message \
101 xaccept \
102 xaccept4 \
103 xasprintf \
104 xbind \
105 xcalloc \
106 xchdir \
107 xchroot \
108 xclock_gettime \
109 xclock_gettime_time64 \
110 xclock_settime \
111 xclock_settime_time64 \
112 xclone \
113 xclose \
114 xchmod \
115 xconnect \
116 xcopy_file_range \
117 xdlfcn \
118 xdlmopen \
119 xdup2 \
120 xfchmod \
121 xfclose \
122 xfopen \
123 xfork \
124 xftruncate \
125 xgetline \
126 xgetsockname \
127 xlisten \
128 xlseek \
129 xlstat \
130 xlstat-time64 \
131 xmalloc \
132 xmemstream \
133 xmkdir \
134 xmkdirp \
135 xmmap \
136 xmprotect \
137 xmunmap \
138 xnewlocale \
139 xopen \
140 xpipe \
141 xpoll \
142 xposix_memalign \
143 xpthread_attr_destroy \
144 xpthread_attr_init \
145 xpthread_attr_setdetachstate \
146 xpthread_attr_setguardsize \
147 xpthread_attr_setaffinity_np \
148 xpthread_attr_setstack \
149 xpthread_attr_setstacksize \
150 xpthread_barrier_destroy \
151 xpthread_barrier_init \
152 xpthread_barrier_wait \
153 xpthread_barrierattr_destroy \
154 xpthread_barrierattr_init \
155 xpthread_barrierattr_setpshared \
156 xpthread_cancel \
157 xpthread_check_return \
158 xpthread_cond_wait \
159 xpthread_create \
160 xpthread_detach \
161 xpthread_join \
162 xpthread_key_create \
163 xpthread_key_delete \
164 xpthread_kill \
165 xpthread_mutex_consistent \
166 xpthread_mutex_destroy \
167 xpthread_mutex_init \
168 xpthread_mutex_lock \
169 xpthread_mutex_unlock \
170 xpthread_mutexattr_destroy \
171 xpthread_mutexattr_init \
172 xpthread_mutexattr_setprotocol \
173 xpthread_mutexattr_setpshared \
174 xpthread_mutexattr_setrobust \
175 xpthread_mutexattr_settype \
176 xpthread_once \
177 xpthread_rwlock_init \
178 xpthread_rwlock_destroy \
179 xpthread_rwlock_rdlock \
180 xpthread_rwlock_unlock \
181 xpthread_rwlock_wrlock \
182 xpthread_rwlockattr_init \
183 xpthread_rwlockattr_setkind_np \
184 xpthread_sigmask \
185 xpthread_spin_lock \
186 xpthread_spin_unlock \
187 xraise \
188 xreadlink \
189 xrealloc \
190 xrecvfrom \
191 xsendto \
192 xsetlocale \
193 xsetsockopt \
194 xsigaction \
195 xsignal \
196 xsigstack \
197 xsocket \
198 xposix_spawn \
199 xposix_spawn_file_actions_addclose \
200 xposix_spawn_file_actions_adddup2 \
201 xstrdup \
202 xstrndup \
203 xsymlink \
204 xsysconf \
205 xunlink \
206 xuselocale \
207 xwaitpid \
208 xwrite \
209
210 libsupport-static-only-routines := $(libsupport-routines)
211 # Only build one variant of the library.
212 libsupport-inhibit-o := .os
213 ifeq ($(build-shared),yes)
214 libsupport-inhibit-o += .o
215 endif
216
217 CFLAGS-support_paths.c = \
218 -DSRCDIR_PATH=\"`cd .. ; pwd`\" \
219 -DOBJDIR_PATH=\"`cd $(objpfx)/..; pwd`\" \
220 -DOBJDIR_ELF_LDSO_PATH=\"`cd $(objpfx)/..; pwd`/elf/$(rtld-installed-name)\" \
221 -DINSTDIR_PATH=\"$(prefix)\" \
222 -DLIBDIR_PATH=\"$(libdir)\" \
223 -DBINDIR_PATH=\"$(bindir)\" \
224 -DSBINDIR_PATH=\"$(sbindir)\" \
225 -DSLIBDIR_PATH=\"$(slibdir)\" \
226 -DROOTSBINDIR_PATH=\"$(rootsbindir)\" \
227 -DCOMPLOCALEDIR_PATH=\"$(complocaledir)\"
228
229 # In support_timespec_check_in_range we may be passed a very tight
230 # range for which we should produce a correct result for expected
231 # being withing the observed range. The code uses double internally
232 # in support_timespec_check_in_range and for that computation we use
233 # -fexcess-precision=standard.
234 CFLAGS-timespec.c += -fexcess-precision=standard
235 CFLAGS-timespec-time64.c += -fexcess-precision=standard
236
237 ifeq (,$(CXX))
238 LINKS_DSO_PROGRAM = links-dso-program-c
239 else
240 LINKS_DSO_PROGRAM = links-dso-program
241 LDLIBS-links-dso-program = -lstdc++ -lgcc -lgcc_s $(libunwind)
242 endif
243
244 ifeq (yes,$(have-selinux))
245 LDLIBS-$(LINKS_DSO_PROGRAM) += -lselinux
246 endif
247
248
249 LDLIBS-test-container = $(libsupport)
250
251 others += test-container
252 others-noinstall += test-container
253
254 others += shell-container echo-container true-container
255 others-noinstall += shell-container echo-container true-container
256
257 others += $(LINKS_DSO_PROGRAM)
258 others-noinstall += $(LINKS_DSO_PROGRAM)
259
260 others += test-run-command
261 others-static += test-run-command
262 others-noinstall += test-run-command
263 LDLIBS-test-run-command = $(libsupport)
264
265 $(objpfx)test-container : $(libsupport)
266 $(objpfx)shell-container : $(libsupport)
267 $(objpfx)echo-container : $(libsupport)
268 $(objpfx)true-container : $(libsupport)
269 $(objpfx)test-run-command : $(libsupport) $(common-objpfx)elf/static-stubs.o
270
271 tests = \
272 README-testing \
273 tst-support-namespace \
274 tst-support_blob_repeat \
275 tst-support_capture_subprocess \
276 tst-support_descriptors \
277 tst-support_format_dns_packet \
278 tst-support-open-dev-null-range \
279 tst-support-process_state \
280 tst-support_quote_blob \
281 tst-support_quote_blob_wide \
282 tst-support_quote_string \
283 tst-support_record_failure \
284 tst-test_compare \
285 tst-test_compare_blob \
286 tst-test_compare_string \
287 tst-test_compare_string_wide \
288 tst-timespec \
289 tst-xreadlink \
290 tst-xsigstack \
291
292 ifeq ($(run-built-tests),yes)
293 tests-special = \
294 $(objpfx)tst-support_record_failure-2.out
295
296 $(objpfx)tst-support_record_failure-2.out: tst-support_record_failure-2.sh \
297 $(objpfx)tst-support_record_failure
298 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
299 '$(run-program-env)' '$(test-program-prefix-after-env)' \
300 > $@; \
301 $(evaluate-test)
302 endif
303
304 $(objpfx)tst-support_format_dns_packet: $(common-objpfx)resolv/libresolv.so
305
306 tst-support_capture_subprocess-ARGS = -- $(host-test-program-cmd)
307
308 include ../Rules