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