Debian Codegraph @

support/Makefile

raw symbols SCIP
1 # Makefile for support library, used only at build and test time
2 # Copyright (C) 2016-2026 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-open-dev-null-range \
45 support_become_root \
46 support_can_chroot \
47 support_capture_subprocess \
48 support_capture_subprocess_check \
49 support_check_stat_fd \
50 support_check_stat_path \
51 support_chroot \
52 support_compare_file_bytes \
53 support_compare_file_string \
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_fuse \
68 support_isolate_in_subprocess \
69 support_mem_access \
70 support_mutex_pi_monotonic \
71 support_need_proc \
72 support_open_and_compare_file_bytes \
73 support_open_and_compare_file_string \
74 support_openpty \
75 support_path_support_time64 \
76 support_paths \
77 support_process_state \
78 support_ptrace \
79 support_quote_blob \
80 support_quote_blob_wide \
81 support_quote_string \
82 support_readdir \
83 support_readdir_check \
84 support_readdir_r_check \
85 support_record_failure \
86 support_run_diff \
87 support_select_modifies_timeout \
88 support_select_normalizes_timeout \
89 support_set_small_thread_stack_size \
90 support_set_vma_name_supported \
91 support_shared_allocate \
92 support_small_stack_thread_attribute \
93 support_socket_so_timestamp_time64 \
94 support_stack_alloc \
95 support_stat_nanoseconds \
96 support_subprocess \
97 support_test_compare_blob \
98 support_test_compare_failure \
99 support_test_compare_string \
100 support_test_compare_string_wide \
101 support_test_in_thread_wrapper \
102 support_test_main \
103 support_test_verify_impl \
104 support_wait_for_thread_exit \
105 support_write_file_string \
106 temp_file \
107 timespec \
108 timespec-add \
109 timespec-add-time64 \
110 timespec-sub \
111 timespec-sub-time64 \
112 timespec-time64 \
113 write_message \
114 xaccept \
115 xaccept4 \
116 xasprintf \
117 xbind \
118 xcalloc \
119 xchdir \
120 xchmod \
121 xchroot \
122 xclock_gettime \
123 xclock_gettime_time64 \
124 xclock_settime \
125 xclock_settime_time64 \
126 xclone \
127 xclose \
128 xclosedir \
129 xconnect \
130 xcopy_file_range \
131 xdlfcn \
132 xdlmopen \
133 xdup \
134 xdup2 \
135 xfchmod \
136 xfclose \
137 xfdopendir \
138 xfgets \
139 xfmemopen \
140 xfopen \
141 xfork \
142 xfread \
143 xfreopen \
144 xftruncate \
145 xgetline \
146 xgetpeername \
147 xgetsockname \
148 xlisten \
149 xlseek \
150 xmalloc \
151 xmemstream \
152 xmkdir \
153 xmkdirp \
154 xmkfifo \
155 xmmap \
156 xmprotect \
157 xmunmap \
158 xnewlocale \
159 xopen \
160 xopendir \
161 xpipe \
162 xpoll \
163 xposix_memalign \
164 xposix_spawn \
165 xposix_spawn_file_actions_addclose \
166 xposix_spawn_file_actions_adddup2 \
167 xpthread_attr_destroy \
168 xpthread_attr_init \
169 xpthread_attr_setaffinity_np \
170 xpthread_attr_setdetachstate \
171 xpthread_attr_setguardsize \
172 xpthread_attr_setstack \
173 xpthread_attr_setstacksize \
174 xpthread_barrier_destroy \
175 xpthread_barrier_init \
176 xpthread_barrier_wait \
177 xpthread_barrierattr_destroy \
178 xpthread_barrierattr_init \
179 xpthread_barrierattr_setpshared \
180 xpthread_cancel \
181 xpthread_check_return \
182 xpthread_cond_signal \
183 xpthread_cond_wait \
184 xpthread_create \
185 xpthread_detach \
186 xpthread_join \
187 xpthread_key_create \
188 xpthread_key_delete \
189 xpthread_kill \
190 xpthread_mutex_consistent \
191 xpthread_mutex_destroy \
192 xpthread_mutex_init \
193 xpthread_mutex_lock \
194 xpthread_mutex_unlock \
195 xpthread_mutexattr_destroy \
196 xpthread_mutexattr_init \
197 xpthread_mutexattr_setprotocol \
198 xpthread_mutexattr_setpshared \
199 xpthread_mutexattr_setrobust \
200 xpthread_mutexattr_settype \
201 xpthread_once \
202 xpthread_rwlock_destroy \
203 xpthread_rwlock_init \
204 xpthread_rwlock_rdlock \
205 xpthread_rwlock_unlock \
206 xpthread_rwlock_wrlock \
207 xpthread_rwlockattr_init \
208 xpthread_rwlockattr_setkind_np \
209 xpthread_sigmask \
210 xpthread_spin_lock \
211 xpthread_spin_unlock \
212 xraise \
213 xread \
214 xreadlink \
215 xrealloc \
216 xrecvfrom \
217 xsendto \
218 xsetlocale \
219 xsetsockopt \
220 xsigaction \
221 xsignal \
222 xsigstack \
223 xsocket \
224 xstatx \
225 xstrdup \
226 xstrndup \
227 xsymlink \
228 xsysconf \
229 xsystem \
230 xunlink \
231 xuselocale \
232 xwaitpid \
233 xwrite \
234 # libsupport-routines
235
236 libsupport-static-only-routines := $(libsupport-routines)
237 # Only build one variant of the library.
238 libsupport-inhibit-o := .os
239 ifeq ($(build-shared),yes)
240 libsupport-inhibit-o += .o
241 endif
242
243 CFLAGS-support_paths.c = \
244 -DSRCDIR_PATH=\"`cd .. ; pwd`\" \
245 -DOBJDIR_PATH=\"`cd $(objpfx)/..; pwd`\" \
246 -DOBJDIR_ELF_LDSO_PATH=\"`cd $(objpfx)/..; pwd`/elf/$(rtld-installed-name)\" \
247 -DINSTDIR_PATH=\"$(prefix)\" \
248 -DLIBDIR_PATH=\"$(libdir)\" \
249 -DBINDIR_PATH=\"$(bindir)\" \
250 -DSBINDIR_PATH=\"$(sbindir)\" \
251 -DSLIBDIR_PATH=\"$(slibdir)\" \
252 -DROOTSBINDIR_PATH=\"$(rootsbindir)\" \
253 -DCOMPLOCALEDIR_PATH=\"$(complocaledir)\" \
254 -DSYSCONFDIR_PATH=\"$(sysconfdir)\"
255
256 # Build with exception handling and asynchronous unwind table support.
257 CFLAGS-.oS += -fexceptions -fasynchronous-unwind-tables
258
259 # In support_timespec_check_in_range we may be passed a very tight
260 # range for which we should produce a correct result for expected
261 # being within the observed range. The code uses double internally
262 # in support_timespec_check_in_range and for that computation we use
263 # -fexcess-precision=standard.
264 CFLAGS-timespec.c += -fexcess-precision=standard
265 CFLAGS-timespec-time64.c += -fexcess-precision=standard
266
267 # Ensure that general support files use 64-bit time_t
268 CFLAGS-delayed_exit.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
269 CFLAGS-shell-container.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
270 CFLAGS-support_can_chroot.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
271 CFLAGS-support_copy_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
272 CFLAGS-support_copy_file_range.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
273 CFLAGS-support_descriptor_supports_holes.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
274 CFLAGS-support_descriptors.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
275 CFLAGS-support_process_state.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
276 CFLAGS-support_stat_nanoseconds.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
277 CFLAGS-support_subprocess.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
278 CFLAGS-support_test_main.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
279 CFLAGS-test-container.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
280 CFLAGS-xmkdirp.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
281 # This is required to get an mkstemp which can create large files on some
282 # 32-bit platforms.
283 CFLAGS-temp_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
284
285 ifeq (,$(CXX))
286 LINKS_DSO_PROGRAM = links-dso-program-c
287 LDLIBS-links-dso-program-c = -lgcc
288 ifeq ($(have-libgcc_s),yes)
289 CFLAGS-links-dso-program-c.c += -fexceptions
290 LDLIBS-links-dso-program-c += -lgcc_s $(libunwind)
291 endif
292 else
293 LINKS_DSO_PROGRAM = links-dso-program
294 LDLIBS-links-dso-program = -lstdc++ -lgcc -lgcc_s $(libunwind)
295 endif
296
297 ifeq (yes,$(have-selinux))
298 LDLIBS-$(LINKS_DSO_PROGRAM) += -lselinux
299 endif
300
301
302 LDLIBS-test-container = $(libsupport)
303
304 others += test-container
305 others-noinstall += test-container
306
307 others += \
308 echo-container \
309 shell-container \
310 true-container \
311 # others
312 others-noinstall += \
313 echo-container \
314 shell-container \
315 true-container \
316 # others-noinstall
317
318 others += $(LINKS_DSO_PROGRAM)
319 others-noinstall += $(LINKS_DSO_PROGRAM)
320
321 others += test-run-command
322 others-static += test-run-command
323 others-noinstall += test-run-command
324 LDLIBS-test-run-command = $(libsupport)
325
326 $(objpfx)test-container : $(libsupport)
327 $(objpfx)shell-container : $(libsupport)
328 $(objpfx)echo-container : $(libsupport)
329 $(objpfx)true-container : $(libsupport)
330 $(objpfx)test-run-command : $(libsupport) $(common-objpfx)elf/static-stubs.o
331
332 tests = \
333 README-testing \
334 tst-support-namespace \
335 tst-support-open-dev-null-range \
336 tst-support-openpty \
337 tst-support-process_state \
338 tst-support_accept_oom \
339 tst-support_blob_repeat \
340 tst-support_capture_subprocess \
341 tst-support_descriptors \
342 tst-support_format_dns_packet \
343 tst-support_fuse \
344 tst-support_quote_blob \
345 tst-support_quote_blob_wide \
346 tst-support_quote_string \
347 tst-support_readdir \
348 tst-support_record_failure \
349 tst-test_compare \
350 tst-test_compare_blob \
351 tst-test_compare_string \
352 tst-test_compare_string_wide \
353 tst-timespec \
354 tst-xdirent \
355 tst-xreadlink \
356 tst-xsigstack \
357 # tests
358
359 tests-container = \
360 tst-support-openpty-c \
361 # tests-container
362
363 ifeq ($(run-built-tests),yes)
364 tests-special = \
365 $(objpfx)tst-support_record_failure-2.out
366
367 $(objpfx)tst-support_record_failure-2.out: tst-support_record_failure-2.sh \
368 $(objpfx)tst-support_record_failure
369 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
370 '$(run-program-env)' '$(test-program-prefix-after-env)' \
371 > $@; \
372 $(evaluate-test)
373 endif
374
375 tests-special += $(objpfx)tst-glibcpp.out
376
377 $(objpfx)tst-glibcpp.out: tst-glibcpp.py $(..)scripts/glibcpp.py
378 PYTHONPATH=$(..)scripts $(PYTHON) tst-glibcpp.py > $@ 2>&1; \
379 $(evaluate-test)
380
381 $(objpfx)tst-support_format_dns_packet: $(common-objpfx)resolv/libresolv.so
382
383 tst-support_capture_subprocess-ARGS = -- $(host-test-program-cmd)
384
385 include ../Rules