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