nptl: Reformat Makefile.
[glibc.git] / support / Makefile
blob71d51485132fb0a644300b32c103db3bf25f8a3a
1 # Makefile for support library, used only at build and test time
2 # Copyright (C) 2016-2023 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 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 xfreopen \
129 xftruncate \
130 xgetline \
131 xgetsockname \
132 xlisten \
133 xlseek \
134 xlstat \
135 xlstat-time64 \
136 xmalloc \
137 xmemstream \
138 xmkdir \
139 xmkdirp \
140 xmkfifo \
141 xmmap \
142 xmprotect \
143 xmunmap \
144 xnewlocale \
145 xopen \
146 xpipe \
147 xpoll \
148 xposix_memalign \
149 xpthread_attr_destroy \
150 xpthread_attr_init \
151 xpthread_attr_setdetachstate \
152 xpthread_attr_setguardsize \
153 xpthread_attr_setaffinity_np \
154 xpthread_attr_setstack \
155 xpthread_attr_setstacksize \
156 xpthread_barrier_destroy \
157 xpthread_barrier_init \
158 xpthread_barrier_wait \
159 xpthread_barrierattr_destroy \
160 xpthread_barrierattr_init \
161 xpthread_barrierattr_setpshared \
162 xpthread_cancel \
163 xpthread_check_return \
164 xpthread_cond_wait \
165 xpthread_cond_signal \
166 xpthread_create \
167 xpthread_detach \
168 xpthread_join \
169 xpthread_key_create \
170 xpthread_key_delete \
171 xpthread_kill \
172 xpthread_mutex_consistent \
173 xpthread_mutex_destroy \
174 xpthread_mutex_init \
175 xpthread_mutex_lock \
176 xpthread_mutex_unlock \
177 xpthread_mutexattr_destroy \
178 xpthread_mutexattr_init \
179 xpthread_mutexattr_setprotocol \
180 xpthread_mutexattr_setpshared \
181 xpthread_mutexattr_setrobust \
182 xpthread_mutexattr_settype \
183 xpthread_once \
184 xpthread_rwlock_init \
185 xpthread_rwlock_destroy \
186 xpthread_rwlock_rdlock \
187 xpthread_rwlock_unlock \
188 xpthread_rwlock_wrlock \
189 xpthread_rwlockattr_init \
190 xpthread_rwlockattr_setkind_np \
191 xpthread_sigmask \
192 xpthread_spin_lock \
193 xpthread_spin_unlock \
194 xraise \
195 xreadlink \
196 xrealloc \
197 xrecvfrom \
198 xsendto \
199 xsetlocale \
200 xsetsockopt \
201 xsigaction \
202 xsignal \
203 xsigstack \
204 xsocket \
205 xposix_spawn \
206 xposix_spawn_file_actions_addclose \
207 xposix_spawn_file_actions_adddup2 \
208 xstrdup \
209 xstrndup \
210 xsymlink \
211 xsysconf \
212 xunlink \
213 xuselocale \
214 xwaitpid \
215 xwrite \
217 libsupport-static-only-routines := $(libsupport-routines)
218 # Only build one variant of the library.
219 libsupport-inhibit-o := .os
220 ifeq ($(build-shared),yes)
221 libsupport-inhibit-o += .o
222 endif
224 CFLAGS-support_paths.c = \
225 -DSRCDIR_PATH=\"`cd .. ; pwd`\" \
226 -DOBJDIR_PATH=\"`cd $(objpfx)/..; pwd`\" \
227 -DOBJDIR_ELF_LDSO_PATH=\"`cd $(objpfx)/..; pwd`/elf/$(rtld-installed-name)\" \
228 -DINSTDIR_PATH=\"$(prefix)\" \
229 -DLIBDIR_PATH=\"$(libdir)\" \
230 -DBINDIR_PATH=\"$(bindir)\" \
231 -DSBINDIR_PATH=\"$(sbindir)\" \
232 -DSLIBDIR_PATH=\"$(slibdir)\" \
233 -DROOTSBINDIR_PATH=\"$(rootsbindir)\" \
234 -DCOMPLOCALEDIR_PATH=\"$(complocaledir)\" \
235 -DSYSCONFDIR_PATH=\"$(sysconfdir)\"
237 # In support_timespec_check_in_range we may be passed a very tight
238 # range for which we should produce a correct result for expected
239 # being withing the observed range. The code uses double internally
240 # in support_timespec_check_in_range and for that computation we use
241 # -fexcess-precision=standard.
242 CFLAGS-timespec.c += -fexcess-precision=standard
243 CFLAGS-timespec-time64.c += -fexcess-precision=standard
245 # Ensure that general support files use 64-bit time_t
246 CFLAGS-delayed_exit.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
247 CFLAGS-shell-container.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
248 CFLAGS-support_can_chroot.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
249 CFLAGS-support_copy_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
250 CFLAGS-support_copy_file_range.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
251 CFLAGS-support_descriptor_supports_holes.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
252 CFLAGS-support_descriptors.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
253 CFLAGS-support_process_state.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
254 CFLAGS-support_stat_nanoseconds.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
255 CFLAGS-support_subprocess.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
256 CFLAGS-support_test_main.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
257 CFLAGS-test-container.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
258 CFLAGS-xmkdirp.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
259 # This is required to get an mkstemp which can create large files on some
260 # 32-bit platforms.
261 CFLAGS-temp_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
263 ifeq (,$(CXX))
264 LINKS_DSO_PROGRAM = links-dso-program-c
265 else
266 LINKS_DSO_PROGRAM = links-dso-program
267 LDLIBS-links-dso-program = -lstdc++ -lgcc -lgcc_s $(libunwind)
268 endif
270 ifeq (yes,$(have-selinux))
271 LDLIBS-$(LINKS_DSO_PROGRAM) += -lselinux
272 endif
275 LDLIBS-test-container = $(libsupport)
277 others += test-container
278 others-noinstall += test-container
280 others += shell-container echo-container true-container
281 others-noinstall += shell-container echo-container true-container
283 others += $(LINKS_DSO_PROGRAM)
284 others-noinstall += $(LINKS_DSO_PROGRAM)
286 others += test-run-command
287 others-static += test-run-command
288 others-noinstall += test-run-command
289 LDLIBS-test-run-command = $(libsupport)
291 $(objpfx)test-container : $(libsupport)
292 $(objpfx)shell-container : $(libsupport)
293 $(objpfx)echo-container : $(libsupport)
294 $(objpfx)true-container : $(libsupport)
295 $(objpfx)test-run-command : $(libsupport) $(common-objpfx)elf/static-stubs.o
297 tests = \
298 README-testing \
299 tst-support-namespace \
300 tst-support-open-dev-null-range \
301 tst-support-process_state \
302 tst-support_blob_repeat \
303 tst-support_capture_subprocess \
304 tst-support_descriptors \
305 tst-support_format_dns_packet \
306 tst-support_quote_blob \
307 tst-support_quote_blob_wide \
308 tst-support_quote_string \
309 tst-support_record_failure \
310 tst-test_compare \
311 tst-test_compare_blob \
312 tst-test_compare_string \
313 tst-test_compare_string_wide \
314 tst-timespec \
315 tst-xreadlink \
316 tst-xsigstack \
318 ifeq ($(run-built-tests),yes)
319 tests-special = \
320 $(objpfx)tst-support_record_failure-2.out
322 $(objpfx)tst-support_record_failure-2.out: tst-support_record_failure-2.sh \
323 $(objpfx)tst-support_record_failure
324 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
325 '$(run-program-env)' '$(test-program-prefix-after-env)' \
326 > $@; \
327 $(evaluate-test)
328 endif
330 tests-special += $(objpfx)tst-glibcpp.out
332 $(objpfx)tst-glibcpp.out: tst-glibcpp.py $(..)scripts/glibcpp.py
333 PYTHONPATH=$(..)scripts $(PYTHON) tst-glibcpp.py > $@ 2>&1; \
334 $(evaluate-test)
336 $(objpfx)tst-support_format_dns_packet: $(common-objpfx)resolv/libresolv.so
338 tst-support_capture_subprocess-ARGS = -- $(host-test-program-cmd)
340 include ../Rules