aboutsummaryrefslogtreecommitdiff
path: root/support/Makefile
blob: 05b31159ea53ca0dbd4b04051e252bc25dbcf6ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# Makefile for support library, used only at build and test time
# Copyright (C) 2016-2023 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <https://www.gnu.org/licenses/>.

subdir := support

include ../Makeconfig

extra-libs := libsupport
extra-libs-others = $(extra-libs)
extra-libs-noinstall := $(extra-libs)

libsupport-routines = \
  blob_repeat \
  check \
  check_addrinfo \
  check_dns_packet \
  check_hostent \
  check_netent \
  delayed_exit \
  dtotimespec \
  dtotimespec-time64 \
  ignore_stderr \
  next_to_fault \
  oom_error \
  resolv_response_context_duplicate \
  resolv_response_context_free \
  resolv_test \
  set_fortify_handler \
  support_stack_alloc \
  support-xfstat \
  support-xfstat-time64 \
  support-xstat \
  support-xstat-time64 \
  support_become_root \
  support_can_chroot \
  support_capture_subprocess \
  support_capture_subprocess_check \
  support_chroot \
  support_copy_file \
  support_copy_file_range \
  support_create_timer \
  support_descriptor_supports_holes \
  support_descriptors \
  support_enter_mount_namespace \
  support_enter_network_namespace \
  support_format_address_family \
  support_format_addrinfo \
  support_format_dns_packet \
  support_format_herrno \
  support_format_hostent \
  support_format_netent \
  support_isolate_in_subprocess \
  support_mutex_pi_monotonic \
  support_need_proc \
  support_path_support_time64 \
  support_process_state \
  support_ptrace \
  support-open-dev-null-range \
  support_openpty \
  support_paths \
  support_quote_blob \
  support_quote_blob_wide \
  support_quote_string \
  support_record_failure \
  support_run_diff \
  support_select_modifies_timeout \
  support_select_normalizes_timeout \
  support_set_small_thread_stack_size \
  support_shared_allocate \
  support_small_stack_thread_attribute \
  support_socket_so_timestamp_time64 \
  support_stat_nanoseconds \
  support_subprocess \
  support_test_compare_blob \
  support_test_compare_failure \
  support_test_compare_string \
  support_test_compare_string_wide \
  support_test_main \
  support_test_verify_impl \
  support_wait_for_thread_exit \
  support_write_file_string \
  temp_file \
  timespec \
  timespec-time64 \
  timespec-add \
  timespec-add-time64 \
  timespec-sub \
  timespec-sub-time64 \
  write_message \
  xaccept \
  xaccept4 \
  xasprintf \
  xbind \
  xcalloc \
  xchdir \
  xchroot \
  xclock_gettime \
  xclock_gettime_time64 \
  xclock_settime \
  xclock_settime_time64 \
  xclone \
  xclose \
  xchmod \
  xconnect \
  xcopy_file_range \
  xdlfcn \
  xdlmopen \
  xdup2 \
  xfchmod \
  xfclose \
  xfopen \
  xfork \
  xfreopen \
  xftruncate \
  xgetline \
  xgetsockname \
  xlisten \
  xlseek \
  xlstat \
  xlstat-time64 \
  xmalloc \
  xmemstream \
  xmkdir \
  xmkdirp \
  xmkfifo \
  xmmap \
  xmprotect \
  xmunmap \
  xnewlocale \
  xopen \
  xpipe \
  xpoll \
  xposix_memalign \
  xpthread_attr_destroy \
  xpthread_attr_init \
  xpthread_attr_setdetachstate \
  xpthread_attr_setguardsize \
  xpthread_attr_setaffinity_np \
  xpthread_attr_setstack \
  xpthread_attr_setstacksize \
  xpthread_barrier_destroy \
  xpthread_barrier_init \
  xpthread_barrier_wait \
  xpthread_barrierattr_destroy \
  xpthread_barrierattr_init \
  xpthread_barrierattr_setpshared \
  xpthread_cancel \
  xpthread_check_return \
  xpthread_cond_wait \
  xpthread_cond_signal \
  xpthread_create \
  xpthread_detach \
  xpthread_join \
  xpthread_key_create \
  xpthread_key_delete \
  xpthread_kill \
  xpthread_mutex_consistent \
  xpthread_mutex_destroy \
  xpthread_mutex_init \
  xpthread_mutex_lock \
  xpthread_mutex_unlock \
  xpthread_mutexattr_destroy \
  xpthread_mutexattr_init \
  xpthread_mutexattr_setprotocol \
  xpthread_mutexattr_setpshared \
  xpthread_mutexattr_setrobust \
  xpthread_mutexattr_settype \
  xpthread_once \
  xpthread_rwlock_init \
  xpthread_rwlock_destroy \
  xpthread_rwlock_rdlock \
  xpthread_rwlock_unlock \
  xpthread_rwlock_wrlock \
  xpthread_rwlockattr_init \
  xpthread_rwlockattr_setkind_np \
  xpthread_sigmask \
  xpthread_spin_lock \
  xpthread_spin_unlock \
  xraise \
  xreadlink \
  xrealloc \
  xrecvfrom \
  xsendto \
  xsetlocale \
  xsetsockopt \
  xsigaction \
  xsignal \
  xsigstack \
  xsocket \
  xposix_spawn \
  xposix_spawn_file_actions_addclose \
  xposix_spawn_file_actions_adddup2 \
  xstrdup \
  xstrndup \
  xsymlink \
  xsysconf \
  xunlink \
  xuselocale \
  xwaitpid \
  xwrite \

libsupport-static-only-routines := $(libsupport-routines)
# Only build one variant of the library.
libsupport-inhibit-o := .os
ifeq ($(build-shared),yes)
libsupport-inhibit-o += .o
endif

CFLAGS-support_paths.c = \
		-DSRCDIR_PATH=\"`cd .. ; pwd`\" \
		-DOBJDIR_PATH=\"`cd $(objpfx)/..; pwd`\" \
		-DOBJDIR_ELF_LDSO_PATH=\"`cd $(objpfx)/..; pwd`/elf/$(rtld-installed-name)\" \
		-DINSTDIR_PATH=\"$(prefix)\" \
		-DLIBDIR_PATH=\"$(libdir)\" \
		-DBINDIR_PATH=\"$(bindir)\" \
		-DSBINDIR_PATH=\"$(sbindir)\" \
		-DSLIBDIR_PATH=\"$(slibdir)\" \
		-DROOTSBINDIR_PATH=\"$(rootsbindir)\" \
		-DCOMPLOCALEDIR_PATH=\"$(complocaledir)\"

# In support_timespec_check_in_range we may be passed a very tight
# range for which we should produce a correct result for expected
# being withing the observed range.  The code uses double internally
# in support_timespec_check_in_range and for that computation we use
# -fexcess-precision=standard.
CFLAGS-timespec.c += -fexcess-precision=standard
CFLAGS-timespec-time64.c += -fexcess-precision=standard

# Ensure that general support files use 64-bit time_t
CFLAGS-delayed_exit.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-shell-container.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_can_chroot.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_copy_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_copy_file_range.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_descriptor_supports_holes.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_descriptors.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_process_state.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_stat_nanoseconds.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_subprocess.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-support_test_main.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-test-container.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
CFLAGS-xmkdirp.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
# This is required to get an mkstemp which can create large files on some
# 32-bit platforms.
CFLAGS-temp_file.c += -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64

ifeq (,$(CXX))
LINKS_DSO_PROGRAM = links-dso-program-c
else
LINKS_DSO_PROGRAM = links-dso-program
LDLIBS-links-dso-program = -lstdc++ -lgcc -lgcc_s $(libunwind)
endif

ifeq (yes,$(have-selinux))
LDLIBS-$(LINKS_DSO_PROGRAM) += -lselinux
endif


LDLIBS-test-container = $(libsupport)

others += test-container
others-noinstall += test-container

others += shell-container echo-container true-container
others-noinstall += shell-container echo-container true-container

others += $(LINKS_DSO_PROGRAM)
others-noinstall += $(LINKS_DSO_PROGRAM)

others += test-run-command
others-static += test-run-command
others-noinstall += test-run-command
LDLIBS-test-run-command = $(libsupport)

$(objpfx)test-container : $(libsupport)
$(objpfx)shell-container : $(libsupport)
$(objpfx)echo-container : $(libsupport)
$(objpfx)true-container : $(libsupport)
$(objpfx)test-run-command : $(libsupport) $(common-objpfx)elf/static-stubs.o

tests = \
  README-testing \
  tst-support-namespace \
  tst-support-open-dev-null-range \
  tst-support-process_state \
  tst-support_blob_repeat \
  tst-support_capture_subprocess \
  tst-support_descriptors \
  tst-support_format_dns_packet \
  tst-support_quote_blob \
  tst-support_quote_blob_wide \
  tst-support_quote_string \
  tst-support_record_failure \
  tst-test_compare \
  tst-test_compare_blob \
  tst-test_compare_string \
  tst-test_compare_string_wide \
  tst-timespec \
  tst-xreadlink \
  tst-xsigstack \

ifeq ($(run-built-tests),yes)
tests-special = \
  $(objpfx)tst-support_record_failure-2.out

$(objpfx)tst-support_record_failure-2.out: tst-support_record_failure-2.sh \
  $(objpfx)tst-support_record_failure
	$(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
	  '$(run-program-env)' '$(test-program-prefix-after-env)' \
	  > $@; \
	$(evaluate-test)
endif

tests-special += $(objpfx)tst-glibcpp.out

$(objpfx)tst-glibcpp.out: tst-glibcpp.py $(..)scripts/glibcpp.py
	PYTHONPATH=$(..)scripts $(PYTHON) tst-glibcpp.py > $@ 2>&1; \
	$(evaluate-test)

$(objpfx)tst-support_format_dns_packet: $(common-objpfx)resolv/libresolv.so

tst-support_capture_subprocess-ARGS = -- $(host-test-program-cmd)

include ../Rules