]>
Commit | Line | Data |
---|---|---|
dff8da6b | 1 | # Copyright (C) 1991-2024 Free Software Foundation, Inc. |
28f540f4 RM |
2 | # This file is part of the GNU C Library. |
3 | ||
4 | # The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | # modify it under the terms of the GNU Lesser General Public |
6 | # License as published by the Free Software Foundation; either | |
7 | # version 2.1 of the License, or (at your option) any later version. | |
28f540f4 RM |
8 | |
9 | # The GNU C Library is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | # Lesser General Public License for more details. |
28f540f4 | 13 | |
41bdb6e2 | 14 | # You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | # License along with the GNU C Library; if not, see |
5a82c748 | 16 | # <https://www.gnu.org/licenses/>. |
28f540f4 RM |
17 | |
18 | # | |
19 | # Master Makefile for the GNU C library | |
20 | # | |
21 | ifneq (,) | |
22 | This makefile requires GNU Make. | |
23 | endif | |
24 | ||
aa802e96 UD |
25 | include Makeconfig |
26 | ||
28f540f4 RM |
27 | |
28 | # This is the default target; it makes everything except the tests. | |
2ac579f9 DD |
29 | .PHONY: all help minihelp |
30 | all: minihelp lib others | |
31 | ||
32 | help: | |
33 | @sed '0,/^help-starts-here$$/d' Makefile.help | |
34 | ||
35 | minihelp: | |
36 | @echo | |
37 | @echo type \"make help\" for help with common glibc makefile targets | |
38 | @echo | |
39 | ||
28f540f4 | 40 | \f |
1400de2e RM |
41 | ifneq ($(AUTOCONF),no) |
42 | ||
4d06461a UD |
43 | define autoconf-it |
44 | @-rm -f $@.new | |
1400de2e | 45 | $(AUTOCONF) $(ACFLAGS) $< > $@.new |
7967983f | 46 | chmod a-w$(patsubst %,$(comma)a+x,$(filter .,$(@D))) $@.new |
4d06461a UD |
47 | mv -f $@.new $@ |
48 | endef | |
c8d32817 | 49 | |
cb8a6dbd MF |
50 | configure: configure.ac aclocal.m4; $(autoconf-it) |
51 | %/configure: %/configure.ac aclocal.m4; $(autoconf-it) | |
52 | %/preconfigure: %/preconfigure.ac aclocal.m4; $(autoconf-it) | |
28f540f4 | 53 | |
1400de2e RM |
54 | endif # $(AUTOCONF) = no |
55 | ||
56 | ||
57 | # We don't want to run anything here in parallel. | |
58 | .NOTPARALLEL: | |
59 | ||
28f540f4 | 60 | # These are the targets that are made by making them in each subdirectory. |
edf5b2d7 UD |
61 | +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \ |
62 | subdir_clean subdir_distclean subdir_realclean \ | |
dd7b064c | 63 | tests xtests \ |
7b57bfe5 | 64 | subdir_update-abi subdir_check-abi \ |
c100dca3 | 65 | subdir_update-all-abi \ |
7b57bfe5 | 66 | subdir_echo-headers \ |
57ba7bb4 | 67 | subdir_install \ |
5d9e8991 | 68 | subdir_objs subdir_stubs subdir_testclean \ |
57ba7bb4 | 69 | $(addprefix install-, no-libc.a bin lib data headers others) |
28f540f4 | 70 | \f |
47f24c21 | 71 | headers := limits.h values.h features.h features-time64.h gnu-versions.h \ |
48789000 JM |
72 | bits/xopen_lim.h gnu/libc-version.h stdc-predef.h \ |
73 | bits/libc-header-start.h | |
28f540f4 RM |
74 | |
75 | echo-headers: subdir_echo-headers | |
76 | ||
762a2918 UD |
77 | # The headers are in the include directory. |
78 | subdir-dirs = include | |
79 | vpath %.h $(subdir-dirs) | |
80 | ||
28f540f4 | 81 | # What to install. |
8d57beea | 82 | install-others = $(inst_includedir)/gnu/stubs.h |
fe54a69c | 83 | install-bin-script = |
56552e42 | 84 | |
a18f587d | 85 | ifeq (yes,$(build-shared)) |
6736e93b | 86 | headers += gnu/lib-names.h |
a18f587d | 87 | endif |
28f540f4 | 88 | |
28f540f4 RM |
89 | include Makerules |
90 | ||
737547be | 91 | ifeq ($(build-programs),yes) |
6c3ebebd | 92 | others: $(addprefix $(objpfx),$(install-bin-script)) |
737547be UD |
93 | endif |
94 | ||
28f540f4 RM |
95 | # Install from subdirectories too. |
96 | install: subdir_install | |
8d57beea | 97 | |
6736e93b UD |
98 | # Explicit dependency so that `make install-headers' works |
99 | install-headers: install-headers-nosubdir | |
100 | ||
5148d49f UD |
101 | # Make sure that the dynamic linker is installed before libc. |
102 | $(inst_slibdir)/libc-$(version).so: elf/ldso_install | |
103 | ||
104 | .PHONY: elf/ldso_install | |
105 | elf/ldso_install: | |
106 | $(MAKE) -C $(@D) $(@F) | |
107 | ||
b43b13ac | 108 | # Create links for shared libraries using the `ldconfig' program if possible. |
7cc27f44 | 109 | # Ignore the error if we cannot update /etc/ld.so.cache. |
1ef32c3d UD |
110 | ifeq (no,$(cross-compiling)) |
111 | ifeq (yes,$(build-shared)) | |
8d57beea | 112 | install: |
686554bf | 113 | -test ! -x $(elf-objpfx)ldconfig || LC_ALL=C \ |
4134b50d JM |
114 | $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \ |
115 | $(slibdir) $(libdir) | |
cc3fa755 UD |
116 | ifneq (no,$(PERL)) |
117 | ifeq (/usr,$(prefix)) | |
118 | ifeq (,$(install_root)) | |
d22e28b0 | 119 | LD_SO=$(ld.so-version) CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx) |
cc3fa755 UD |
120 | endif |
121 | endif | |
122 | endif | |
1ef32c3d UD |
123 | endif |
124 | endif | |
28f540f4 | 125 | |
01a36ad3 RM |
126 | # Build subdirectory lib objects. |
127 | lib-noranlib: subdir_lib | |
28f540f4 | 128 | |
01a36ad3 RM |
129 | ifeq (yes,$(build-shared)) |
130 | # Build the shared object from the PIC object library. | |
5f855e35 | 131 | lib: $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so |
bd81123a | 132 | endif # $(build-shared) |
9bfce4bf | 133 | |
f2873d2d FW |
134 | # Used to build testrun.sh. |
135 | define testrun-script | |
136 | #!/bin/bash | |
137 | builddir=`dirname "$$0"` | |
138 | GCONV_PATH="$${builddir}/iconvdata" | |
139 | ||
140 | usage () { | |
709e3709 LM |
141 | cat << EOF |
142 | Usage: $$0 [OPTIONS] <program> [ARGUMENTS...] | |
143 | ||
27ae52e4 SB |
144 | --tool=TOOL Run with the specified TOOL. It can be strace, rpctrace, |
145 | valgrind or container. The container will run within | |
bb888737 FW |
146 | support/test-container. For strace and valgrind, |
147 | additional arguments can be passed after the tool name. | |
709e3709 LM |
148 | EOF |
149 | ||
5e10136b | 150 | exit 1 |
f2873d2d FW |
151 | } |
152 | ||
153 | toolname=default | |
154 | while test $$# -gt 0 ; do | |
155 | case "$$1" in | |
156 | --tool=*) | |
157 | toolname="$${1:7}" | |
158 | shift | |
159 | ;; | |
160 | --*) | |
161 | usage | |
162 | ;; | |
163 | *) | |
164 | break | |
165 | ;; | |
166 | esac | |
167 | done | |
168 | ||
169 | if test $$# -eq 0 ; then | |
170 | usage | |
171 | fi | |
172 | ||
173 | case "$$toolname" in | |
174 | default) | |
175 | exec $(subst $(common-objdir),"$${builddir}", $(test-program-prefix)) \ | |
176 | $${1+"$$@"} | |
177 | ;; | |
bb888737 FW |
178 | strace*) |
179 | exec $$toolname $(patsubst %, -E%, $(run-program-env)) \ | |
f2873d2d FW |
180 | $(test-via-rtld-prefix) $${1+"$$@"} |
181 | ;; | |
27ae52e4 SB |
182 | rpctrace) |
183 | exec rpctrace $(patsubst %, -E%, $(run-program-env)) \ | |
184 | $(test-via-rtld-prefix) $${1+"$$@"} | |
185 | ;; | |
bb888737 FW |
186 | valgrind*) |
187 | exec env $(run-program-env) $$toolname $(test-via-rtld-prefix) $${1+"$$@"} | |
f2873d2d | 188 | ;; |
6ef1bab6 GG |
189 | container) |
190 | exec env $(run-program-env) $(test-via-rtld-prefix) \ | |
191 | $(common-objdir)/support/test-container \ | |
192 | env $(run-program-env) $(test-via-rtld-prefix) $${1+"$$@"} | |
193 | ;; | |
f2873d2d FW |
194 | *) |
195 | usage | |
196 | ;; | |
197 | esac | |
198 | endef | |
9bfce4bf RM |
199 | |
200 | # This is a handy script for running any dynamically linked program against | |
201 | # the current libc build for testing. | |
202 | $(common-objpfx)testrun.sh: $(common-objpfx)config.make \ | |
203 | $(..)Makeconfig $(..)Makefile | |
46341286 | 204 | $(file >$@T,$(testrun-script)) |
9bfce4bf RM |
205 | chmod a+x $@T |
206 | mv -f $@T $@ | |
207 | postclean-generated += testrun.sh | |
208 | ||
79ced5a8 GG |
209 | define debugglibc |
210 | #!/bin/bash | |
211 | ||
212 | SOURCE_DIR="$(CURDIR)" | |
213 | BUILD_DIR="$(common-objpfx)" | |
214 | CMD_FILE="$(common-objpfx)debugglibc.gdb" | |
6ef1bab6 | 215 | CONTAINER=false |
79ced5a8 | 216 | DIRECT=true |
d0bc5b72 | 217 | STATIC=false |
79ced5a8 GG |
218 | SYMBOLSFILE=true |
219 | unset TESTCASE | |
220 | unset BREAKPOINTS | |
221 | unset ENVVARS | |
222 | ||
223 | usage() | |
224 | { | |
225 | cat << EOF | |
21417aaa | 226 | Usage: $$0 [OPTIONS] <program> |
79ced5a8 | 227 | |
21417aaa AS |
228 | Or: $$0 [OPTIONS] -- <program> [<args>]... |
229 | ||
230 | where <program> is the path to the program being tested, | |
231 | and <args> are the arguments to be passed to it. | |
79ced5a8 GG |
232 | |
233 | Options: | |
234 | ||
235 | -h, --help | |
236 | Prints this message and leaves. | |
237 | ||
238 | The following options require one argument: | |
239 | ||
240 | -b, --breakpoint | |
241 | Breakpoints to set at the beginning of the execution | |
242 | (each breakpoint demands its own -b option, e.g. -b foo -b bar) | |
243 | -e, --environment-variable | |
244 | Environment variables to be set with 'exec-wrapper env' in GDB | |
245 | (each environment variable demands its own -e option, e.g. | |
246 | -e FOO=foo -e BAR=bar) | |
247 | ||
248 | The following options do not take arguments: | |
249 | ||
6ef1bab6 GG |
250 | -c, --in-container |
251 | Run the test case inside a container and automatically attach | |
252 | GDB to it. | |
79ced5a8 | 253 | -i, --no-direct |
21417aaa AS |
254 | Selects whether to pass the --direct flag to the program. |
255 | --direct is useful when debugging glibc test cases. It inhibits the | |
256 | tests from forking and executing in a subprocess. | |
257 | Default behaviour is to pass the --direct flag, except when the | |
258 | program is run with user specified arguments using the "--" separator. | |
79ced5a8 | 259 | -s, --no-symbols-file |
21417aaa | 260 | Do not tell GDB to load debug symbols from the program. |
79ced5a8 GG |
261 | EOF |
262 | } | |
263 | ||
264 | # Parse input options | |
265 | while [[ $$# > 0 ]] | |
266 | do | |
267 | key="$$1" | |
268 | case $$key in | |
269 | -h|--help) | |
270 | usage | |
271 | exit 0 | |
272 | ;; | |
273 | -b|--breakpoint) | |
274 | BREAKPOINTS="break $$2\n$$BREAKPOINTS" | |
275 | shift | |
276 | ;; | |
277 | -e|--environment-variable) | |
278 | ENVVARS="$$2 $$ENVVARS" | |
279 | shift | |
280 | ;; | |
6ef1bab6 GG |
281 | -c|--in-container) |
282 | CONTAINER=true | |
283 | ;; | |
79ced5a8 GG |
284 | -i|--no-direct) |
285 | DIRECT=false | |
286 | ;; | |
287 | -s|--no-symbols-file) | |
288 | SYMBOLSFILE=false | |
289 | ;; | |
21417aaa AS |
290 | --) |
291 | shift | |
292 | TESTCASE=$$1 | |
293 | COMMANDLINE="$$@" | |
294 | # Don't add --direct when user specifies program arguments | |
295 | DIRECT=false | |
296 | break | |
297 | ;; | |
79ced5a8 GG |
298 | *) |
299 | TESTCASE=$$1 | |
21417aaa | 300 | COMMANDLINE=$$TESTCASE |
79ced5a8 GG |
301 | ;; |
302 | esac | |
303 | shift | |
304 | done | |
305 | ||
d0bc5b72 GG |
306 | # Check for required argument and if the testcase exists |
307 | if [ ! -v TESTCASE ] || [ ! -f $${TESTCASE} ] | |
79ced5a8 GG |
308 | then |
309 | usage | |
310 | exit 1 | |
311 | fi | |
312 | ||
b3b0b691 AS |
313 | # Container tests needing locale data should install them in-container. |
314 | # Other tests/binaries need to use locale data from the build tree. | |
315 | if [ "$$CONTAINER" = false ] | |
316 | then | |
317 | ENVVARS="GCONV_PATH=$${BUILD_DIR}/iconvdata $$ENVVARS" | |
318 | ENVVARS="LOCPATH=$${BUILD_DIR}/localedata $$ENVVARS" | |
319 | ENVVARS="LC_ALL=C $$ENVVARS" | |
320 | fi | |
321 | ||
79ced5a8 GG |
322 | # Expand environment setup command |
323 | if [ -v ENVVARS ] | |
324 | then | |
325 | ENVVARSCMD="set exec-wrapper env $$ENVVARS" | |
326 | fi | |
327 | ||
328 | # Expand direct argument | |
329 | if [ "$$DIRECT" == true ] | |
330 | then | |
331 | DIRECT="--direct" | |
332 | else | |
333 | DIRECT="" | |
334 | fi | |
335 | ||
d0bc5b72 GG |
336 | # Check if the test case is static |
337 | if file $${TESTCASE} | grep "statically linked" >/dev/null | |
338 | then | |
339 | STATIC=true | |
340 | else | |
341 | STATIC=false | |
342 | fi | |
343 | ||
79ced5a8 GG |
344 | # Expand symbols loading command |
345 | if [ "$$SYMBOLSFILE" == true ] | |
346 | then | |
347 | SYMBOLSFILE="add-symbol-file $${TESTCASE}" | |
348 | else | |
349 | SYMBOLSFILE="" | |
350 | fi | |
351 | ||
352 | # GDB commands template | |
353 | template () | |
354 | { | |
355 | cat <<EOF | |
356 | set environment C -E -x c-header | |
357 | set auto-load safe-path $${BUILD_DIR}/nptl_db:\$$debugdir:\$$datadir/auto-load | |
358 | set libthread-db-search-path $${BUILD_DIR}/nptl_db | |
359 | __ENVVARS__ | |
360 | __SYMBOLSFILE__ | |
361 | break _dl_start_user | |
362 | run --library-path $(rpath-link):$${BUILD_DIR}/nptl_db \ | |
21417aaa | 363 | __COMMANDLINE__ __DIRECT__ |
79ced5a8 GG |
364 | __BREAKPOINTS__ |
365 | EOF | |
366 | } | |
367 | ||
368 | # Generate the commands file for gdb initialization | |
369 | template | sed \ | |
370 | -e "s|__ENVVARS__|$$ENVVARSCMD|" \ | |
371 | -e "s|__SYMBOLSFILE__|$$SYMBOLSFILE|" \ | |
21417aaa | 372 | -e "s|__COMMANDLINE__|$$COMMANDLINE|" \ |
79ced5a8 GG |
373 | -e "s|__DIRECT__|$$DIRECT|" \ |
374 | -e "s|__BREAKPOINTS__|$$BREAKPOINTS|" \ | |
375 | > $$CMD_FILE | |
376 | ||
377 | echo | |
378 | echo "Debugging glibc..." | |
379 | echo "Build directory : $$BUILD_DIR" | |
380 | echo "Source directory : $$SOURCE_DIR" | |
381 | echo "GLIBC Testcase : $$TESTCASE" | |
382 | echo "GDB Commands : $$CMD_FILE" | |
383 | echo "Env vars : $$ENVVARS" | |
384 | echo | |
385 | ||
6ef1bab6 GG |
386 | if [ "$$CONTAINER" == true ] |
387 | then | |
388 | # Use testrun.sh to start the test case with WAIT_FOR_DEBUGGER=1, then | |
389 | # automatically attach GDB to it. | |
390 | WAIT_FOR_DEBUGGER=1 $(common-objpfx)testrun.sh --tool=container $${TESTCASE} & | |
391 | gdb -x $${TESTCASE}.gdb | |
d0bc5b72 GG |
392 | elif [ "$$STATIC" == true ] |
393 | then | |
394 | gdb $${TESTCASE} | |
6ef1bab6 | 395 | else |
79ced5a8 GG |
396 | # Start the test case debugging in two steps: |
397 | # 1. the following command invokes gdb to run the loader; | |
398 | # 2. the commands file tells the loader to run the test case. | |
399 | gdb -q \ | |
400 | -x $${CMD_FILE} \ | |
401 | -d $${SOURCE_DIR} \ | |
402 | $${BUILD_DIR}/elf/ld.so | |
6ef1bab6 | 403 | fi |
79ced5a8 GG |
404 | endef |
405 | ||
406 | # This is another handy script for debugging dynamically linked program | |
407 | # against the current libc build for testing. | |
408 | $(common-objpfx)debugglibc.sh: $(common-objpfx)config.make \ | |
409 | $(..)Makeconfig $(..)Makefile | |
410 | $(file >$@T,$(debugglibc)) | |
411 | chmod a+x $@T | |
412 | mv -f $@T $@ | |
413 | postclean-generated += debugglibc.sh debugglibc.gdb | |
414 | ||
415 | others: $(common-objpfx)testrun.sh $(common-objpfx)debugglibc.sh | |
28f540f4 | 416 | \f |
97a47867 UD |
417 | # Makerules creates a file `stubs' in each subdirectory, which |
418 | # contains `#define __stub_FUNCTION' for each function defined in that | |
419 | # directory which is a stub. | |
6bc31da0 | 420 | # Here we paste all of these together into <gnu/stubs.h>. |
28f540f4 | 421 | |
97a47867 | 422 | subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs) |
28f540f4 | 423 | |
0ab0291b | 424 | ifndef abi-variants |
3e1e123d RM |
425 | installed-stubs = $(inst_includedir)/gnu/stubs.h |
426 | else | |
0ab0291b | 427 | installed-stubs = $(inst_includedir)/gnu/stubs-$(default-abi).h |
3e1e123d | 428 | |
691bc9c1 | 429 | $(inst_includedir)/gnu/stubs.h: $(+force) |
f0cf0902 | 430 | $(make-target-directory) |
0ab0291b L |
431 | { \ |
432 | echo '/* This file is automatically generated.';\ | |
433 | echo " This file selects the right generated file of \`__stub_FUNCTION' macros";\ | |
434 | echo ' based on the architecture being compiled for. */'; \ | |
435 | echo ''; \ | |
436 | $(foreach h,$(abi-includes), echo '#include <$(h)>';) \ | |
437 | echo ''; \ | |
438 | $(foreach v,$(abi-variants),\ | |
439 | $(if $(abi-$(v)-condition),\ | |
440 | echo '#if $(abi-$(v)-condition)'; \ | |
441 | echo '# include <gnu/stubs-$(v).h>'); \ | |
442 | $(if $(abi-$(v)-condition),echo '#endif';) \ | |
443 | rm -f $(@:.d=.h).new$(v); \ | |
444 | ) \ | |
445 | } > $(@:.d=.h).new | |
446 | mv -f $(@:.d=.h).new $(@:.d=.h) | |
3e1e123d RM |
447 | |
448 | install-others-nosubdir: $(installed-stubs) | |
449 | endif | |
450 | ||
451 | ||
28f540f4 RM |
452 | # Since stubs.h is never needed when building the library, we simplify the |
453 | # hairy installation process by producing it in place only as the last part | |
b9b49b44 UD |
454 | # of the top-level `make install'. It depends on subdir_install, which |
455 | # iterates over all the subdirs; subdir_install in each subdir depends on | |
456 | # the subdir's stubs file. Having more direct dependencies would result in | |
457 | # extra iterations over the list for subdirs and many recursive makes. | |
3e1e123d | 458 | $(installed-stubs): include/stubs-prologue.h subdir_install |
5107cf1d | 459 | $(make-target-directory) |
28f540f4 | 460 | @rm -f $(objpfx)stubs.h |
d62507dd | 461 | (sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h |
13a0be88 | 462 | if test -r $@ && cmp -s $(objpfx)stubs.h $@; \ |
ba1ffaa1 | 463 | then echo 'stubs.h unchanged'; \ |
d36e7692 | 464 | else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi |
28f540f4 RM |
465 | rm -f $(objpfx)stubs.h |
466 | \f | |
467 | # This makes the Info or DVI file of the documentation from the Texinfo source. | |
fef0b717 UD |
468 | .PHONY: info dvi pdf html |
469 | info dvi pdf html: | |
c0e45674 | 470 | $(MAKE) $(PARALLELMFLAGS) -C manual $@ |
28f540f4 RM |
471 | \f |
472 | # This makes all the subdirectory targets. | |
473 | ||
474 | # For each target, make it depend on DIR/target for each subdirectory DIR. | |
475 | $(+subdir_targets): %: $(addsuffix /%,$(subdirs)) | |
476 | ||
477 | # Compute a list of all those targets. | |
478 | all-subdirs-targets := $(foreach dir,$(subdirs),\ | |
479 | $(addprefix $(dir)/,$(+subdir_targets))) | |
480 | ||
481 | # The action for each of those is to cd into the directory and make the | |
482 | # target there. | |
483 | $(all-subdirs-targets): | |
e0a3ed4f RM |
484 | $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F) |
485 | ||
486 | define subdir-target-args | |
487 | subdir=$(@D)$(if $($(@D)-srcdir),\ | |
488 | -C $($(@D)-srcdir) ..=`pwd`/,\ | |
489 | -C $(@D) ..=../) | |
490 | endef | |
28f540f4 RM |
491 | |
492 | .PHONY: $(+subdir_targets) $(all-subdirs-targets) | |
493 | \f | |
494 | # Targets to clean things up to various degrees. | |
495 | ||
3c5edd4d UD |
496 | .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \ |
497 | tests-clean | |
28f540f4 RM |
498 | |
499 | # Subroutines of all cleaning targets. | |
500 | parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules. | |
4ddde9ee | 501 | -rm -f $(foreach o,$(object-suffixes-for-libc),\ |
60092701 RM |
502 | $(common-objpfx)$(patsubst %,$(libtype$o),c)) \ |
503 | $(addprefix $(objpfx),$(install-lib)) | |
28f540f4 | 504 | parent-clean: parent-mostlyclean common-clean |
da2d1bc5 UD |
505 | |
506 | postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \ | |
4ae73ca0 | 507 | $(addprefix $(objpfx),sysd-dirs sysd-rules) \ |
4fcddf8e | 508 | $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i) |
28f540f4 RM |
509 | |
510 | clean: parent-clean | |
511 | # This is done this way rather than having `subdir_clean' be a | |
512 | # dependency of this target so that libc.a will be removed before the | |
513 | # subdirectories are dealt with and so they won't try to remove object | |
514 | # files from it when it's going to be removed anyway. | |
515 | @$(MAKE) subdir_clean no_deps=t | |
b5c69d99 | 516 | -rm -f $(postclean) |
28f540f4 RM |
517 | mostlyclean: parent-mostlyclean |
518 | @$(MAKE) subdir_mostlyclean no_deps=t | |
da2d1bc5 | 519 | -rm -f $(postclean) |
28f540f4 | 520 | |
7c507f44 MK |
521 | # Remove test artifacts from the whole glibc build. |
522 | # do-tests-clean removes test artifacts from top-level directory, and | |
523 | # subdir_testclean removes them from individual sub-directories. | |
524 | tests-clean: do-tests-clean | |
3c5edd4d UD |
525 | @$(MAKE) subdir_testclean no_deps=t |
526 | ||
00db8bf4 | 527 | ifneq (,$(CXX)) |
bd29910a JM |
528 | vpath c++-types.data $(+sysdep_dirs) |
529 | ||
684ce7e0 | 530 | tests-special += $(objpfx)c++-types-check.out |
bd29910a | 531 | $(objpfx)c++-types-check.out: c++-types.data scripts/check-c++-types.sh |
783dd2d3 | 532 | scripts/check-c++-types.sh $< $(CXX) $(filter-out -std=gnu11 $(+gccwarn-c),$(CFLAGS)) $(CPPFLAGS) > $@; \ |
f0881698 | 533 | $(evaluate-test) |
2750c39c | 534 | endif |
806e4a4a | 535 | |
1241b50b | 536 | tests-special += $(objpfx)check-local-headers.out |
16feadf2 | 537 | $(objpfx)check-local-headers.out: scripts/check-local-headers.sh |
ea5ee9f7 | 538 | AWK='$(AWK)' scripts/check-local-headers.sh \ |
3b2cc56d | 539 | "$(includedir)" "$(objpfx)" < /dev/null > $@; \ |
f0881698 | 540 | $(evaluate-test) |
16feadf2 | 541 | |
47755784 ZW |
542 | ifneq "$(headers)" "" |
543 | # Special test of all the installed headers in this directory. | |
544 | tests-special += $(objpfx)check-installed-headers-c.out | |
7c3018f9 | 545 | libof-check-installed-headers-c := testsuite |
47755784 ZW |
546 | $(objpfx)check-installed-headers-c.out: \ |
547 | scripts/check-installed-headers.sh $(headers) | |
a3090c2c | 548 | $(SHELL) $(..)scripts/check-installed-headers.sh c $(supported-fortify) \ |
47755784 ZW |
549 | "$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \ |
550 | $(headers) > $@; \ | |
551 | $(evaluate-test) | |
552 | ||
553 | ifneq "$(CXX)" "" | |
554 | tests-special += $(objpfx)check-installed-headers-cxx.out | |
7c3018f9 | 555 | libof-check-installed-headers-cxx := testsuite |
47755784 ZW |
556 | $(objpfx)check-installed-headers-cxx.out: \ |
557 | scripts/check-installed-headers.sh $(headers) | |
a3090c2c | 558 | $(SHELL) $(..)scripts/check-installed-headers.sh c++ $(supported-fortify) \ |
47755784 ZW |
559 | "$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \ |
560 | $(headers) > $@; \ | |
561 | $(evaluate-test) | |
ad18dade FW |
562 | endif # $(CXX) |
563 | ||
564 | tests-special += $(objpfx)check-wrapper-headers.out | |
565 | $(objpfx)check-wrapper-headers.out: scripts/check-wrapper-headers.py $(headers) | |
566 | $(PYTHON) $< --root=. --subdir=. $(headers) \ | |
567 | --generated $(common-generated) > $@; $(evaluate-test) | |
568 | endif # $(headers) | |
47755784 | 569 | |
547de57e CD |
570 | # Lint all Makefiles; including this one. Pass `pwd` as the source |
571 | # directory since the top-level Makefile is in the root of the source | |
572 | # tree and these tests are run from there. We add light-weight linting | |
573 | # to the 'check' target to support the existing developer workflow of: | |
574 | # edit -> make -> make check; without needing an additional step. | |
575 | tests-special += $(objpfx)lint-makefiles.out | |
576 | $(objpfx)lint-makefiles.out: scripts/lint-makefiles.sh | |
577 | $(SHELL) $< "$(PYTHON)" `pwd` > $@ ; \ | |
578 | $(evaluate-test) | |
579 | ||
02976a4a MK |
580 | # Print test summary for tests in $1 .sum file; |
581 | # $2 is optional test identifier. | |
582 | # Fail if there are unexpected failures in the test results. | |
44a6213c | 583 | define summarize-tests |
02976a4a MK |
584 | @grep -E '^[A-Z]+:' $(objpfx)$1 | grep -E -v '^(PASS|XFAIL):' || true |
585 | @echo " === Summary of results$2 ===" | |
586 | @sed -e '/:.*/!d' -e 's/:.*//' < $(objpfx)$1 | sort | uniq -c | |
587 | @! grep -E '^[A-Z]+:' $(objpfx)$1 | grep -E -q -v '^(X?PASS|XFAIL|UNSUPPORTED):' | |
44a6213c RM |
588 | endef |
589 | ||
561b0bec DD |
590 | # The intention here is to do ONE install of our build into the |
591 | # testroot.pristine/ directory, then rsync (internal to | |
592 | # support/test-container) that to testroot.root/ at the start of each | |
593 | # test. That way we can promise each test a "clean" install, without | |
594 | # having to do the install for each test. | |
595 | # | |
596 | # In addition, we have to copy some files (which we build) into this | |
597 | # root in addition to what glibc installs. For example, many tests | |
598 | # require additional programs including /bin/sh, /bin/true, and | |
599 | # /bin/echo, all of which we build below to limit library dependencies | |
600 | # to just those things in glibc and language support libraries which | |
601 | # we also copy into the into the rootfs. To determine what language | |
602 | # support libraries we need we build a "test" program in either C or | |
603 | # (if available) C++ just so we can copy in any shared objects | |
604 | # (which we do not build) that GCC-compiled programs depend on. | |
605 | ||
606 | ||
607 | ifeq (,$(CXX)) | |
608 | LINKS_DSO_PROGRAM = links-dso-program-c | |
609 | else | |
610 | LINKS_DSO_PROGRAM = links-dso-program | |
611 | endif | |
612 | ||
613 | $(tests-container) $(addsuffix /tests,$(subdirs)) : \ | |
614 | $(objpfx)testroot.pristine/install.stamp | |
615 | $(objpfx)testroot.pristine/install.stamp : | |
616 | test -d $(objpfx)testroot.pristine || \ | |
617 | mkdir $(objpfx)testroot.pristine | |
618 | # We need a working /bin/sh for some of the tests. | |
619 | test -d $(objpfx)testroot.pristine/bin || \ | |
620 | mkdir $(objpfx)testroot.pristine/bin | |
033362cf CD |
621 | # We need the compiled locale dir for localedef tests. |
622 | test -d $(objpfx)testroot.pristine/$(complocaledir) || \ | |
623 | mkdir -p $(objpfx)testroot.pristine/$(complocaledir) | |
561b0bec DD |
624 | cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/bin/sh |
625 | cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/bin/echo | |
626 | cp $(objpfx)support/true-container $(objpfx)testroot.pristine/bin/true | |
bd598da9 | 627 | ifeq ($(run-built-tests),yes) |
561b0bec DD |
628 | # Copy these DSOs first so we can overwrite them with our own. |
629 | for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \ | |
97290559 | 630 | $(rtld-prefix) --inhibit-cache \ |
561b0bec | 631 | $(objpfx)testroot.pristine/bin/sh \ |
7db1fe38 | 632 | | sed -n '/\//{s@.*=> /@/@;s/^[^/]*//;s/ .*//p;}'` ;\ |
561b0bec DD |
633 | do \ |
634 | test -d `dirname $(objpfx)testroot.pristine$$dso` || \ | |
635 | mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\ | |
636 | $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\ | |
637 | done | |
638 | for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \ | |
97290559 | 639 | $(rtld-prefix) --inhibit-cache \ |
561b0bec | 640 | $(objpfx)support/$(LINKS_DSO_PROGRAM) \ |
7db1fe38 | 641 | | sed -n '/\//{s@.*=> /@/@;s/^[^/]*//;s/ .*//p;}'` ;\ |
561b0bec DD |
642 | do \ |
643 | test -d `dirname $(objpfx)testroot.pristine$$dso` || \ | |
644 | mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\ | |
645 | $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\ | |
646 | done | |
bd598da9 | 647 | endif |
97476447 DD |
648 | # $(symbolic-link-list) is a file that encodes $(DESTDIR) so we |
649 | # have to purge it | |
650 | rm -f $(symbolic-link-list) | |
651 | # Setting INSTALL_UNCOMPRESSED causes localedata/Makefile to | |
652 | # install the charmaps uncompressed, as the testroot does not | |
653 | # provide a gunzip program. | |
35e038c1 | 654 | $(MAKE) install DESTDIR=$(objpfx)testroot.pristine \ |
97476447 DD |
655 | INSTALL_UNCOMPRESSED=yes subdirs='$(sorted-subdirs)' |
656 | rm -f $(symbolic-link-list) | |
561b0bec DD |
657 | touch $(objpfx)testroot.pristine/install.stamp |
658 | ||
265d52ab | 659 | tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special)) |
f214606a | 660 | tests: $(tests-special) |
265d52ab JM |
661 | $(..)scripts/merge-test-results.sh -s $(objpfx) "" \ |
662 | $(sort $(tests-special-notdir:.out=)) \ | |
663 | > $(objpfx)subdir-tests.sum | |
664 | $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-tests.sum \ | |
665 | $(sort $(subdirs) .) \ | |
666 | > $(objpfx)tests.sum | |
44a6213c | 667 | $(call summarize-tests,tests.sum) |
265d52ab JM |
668 | xtests: |
669 | $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-xtests.sum \ | |
670 | $(sort $(subdirs)) \ | |
671 | > $(objpfx)xtests.sum | |
44a6213c | 672 | $(call summarize-tests,xtests.sum, for extra tests) |
f214606a | 673 | |
28f540f4 RM |
674 | # The realclean target is just like distclean for the parent, but we want |
675 | # the subdirs to know the difference in case they care. | |
676 | realclean distclean: parent-clean | |
677 | # This is done this way rather than having `subdir_distclean' be a | |
678 | # dependency of this target so that libc.a will be removed before the | |
679 | # subdirectories are dealt with and so they won't try to remove object | |
680 | # files from it when it's going to be removed anyway. | |
da2d1bc5 UD |
681 | @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \ |
682 | sysdep-subdirs="$(sysdep-subdirs)" | |
683 | -rm -f $(postclean) | |
28f540f4 RM |
684 | |
685 | # Subroutine of distclean and realclean. | |
686 | distclean-1: subdir_$(distclean-1) | |
687 | -rm -f $(config-generated) | |
60092701 RM |
688 | -rm -f $(addprefix $(objpfx),config.status config.cache config.log) |
689 | -rm -f $(addprefix $(objpfx),config.make config-name.h config.h) | |
28f540f4 RM |
690 | ifdef objdir |
691 | -rm -f $(objpfx)Makefile | |
692 | endif | |
693 | -rm -f $(sysdep-$(distclean-1)) | |
694 | \f | |
9de06f3c RM |
695 | # Make the TAGS file for Emacs users. |
696 | ||
697 | .PHONY: TAGS | |
698 | TAGS: | |
77c84aeb | 699 | scripts/list-sources.sh | sed -n -e '/Makefile/p' \ |
9de06f3c | 700 | $(foreach S,[chsSyl] cxx sh bash pl,\ |
77c84aeb | 701 | $(subst .,\.,-e '/.$S\(.in\)*$$/p')) \ |
9de06f3c RM |
702 | | $(ETAGS) -o $@ - |
703 | \f | |
28f540f4 | 704 | # Make the distribution tarfile. |
6cfe8609 | 705 | .PHONY: dist dist-prepare |
28f540f4 | 706 | |
c7562c74 | 707 | generated := $(generated) stubs.h |
28f540f4 | 708 | |
97ff54d2 | 709 | files-for-dist := README INSTALL configure NEWS |
6cfe8609 RM |
710 | |
711 | # Regenerate stuff, then error if these things are not committed yet. | |
712 | dist-prepare: $(files-for-dist) | |
644d3857 | 713 | conf=`find sysdeps -name configure`; \ |
6cfe8609 RM |
714 | $(MAKE) $$conf && \ |
715 | git diff --stat HEAD -- $^ $$conf \ | |
716 | | $(AWK) '{ print; rc=1 } END { exit rc }' | |
717 | ||
718 | %.tar: FORCE | |
719 | git archive --prefix=$*/ $* > $@.new | |
720 | mv -f $@.new $@ | |
62780824 | 721 | |
7c0cf356 | 722 | # Do `make dist dist-version=X.Y.Z' to make tar files of an older version. |
7c0cf356 | 723 | |
6cfe8609 RM |
724 | ifneq (,$(strip $(dist-version))) |
725 | dist: $(foreach Z,.bz2 .gz .xz,$(dist-version).tar$Z) | |
62780824 | 726 | md5sum $^ |
6cfe8609 RM |
727 | else |
728 | dist: dist-prepare | |
729 | @if v=`git describe`; then \ | |
730 | echo Distribution version $$v; \ | |
731 | $(MAKE) dist dist-version=$$v; \ | |
732 | else \ | |
733 | false; \ | |
734 | fi | |
735 | endif | |
62780824 | 736 | |
d136c6dc SP |
737 | INSTALL: manual/install-plain.texi manual/macros.texi \ |
738 | $(common-objpfx)manual/pkgvers.texi manual/install.texi | |
4e87147f | 739 | makeinfo --no-validate --plaintext --no-number-sections \ |
84e93afc | 740 | -I$(common-objpfx)manual $< -o $@-tmp |
b31469d0 JM |
741 | $(AWK) 'NF == 0 { ++n; next } \ |
742 | NF != 0 { while (n-- > 0) print ""; n = 0; print }' \ | |
743 | < $@-tmp > $@-tmp2 | |
744 | rm -f $@-tmp | |
745 | -chmod a-w $@-tmp2 | |
746 | mv -f $@-tmp2 $@ | |
8b748aed JM |
747 | $(common-objpfx)manual/%: FORCE |
748 | $(MAKE) $(PARALLELMFLAGS) -C manual $@ | |
f671aeab | 749 | FORCE: |
6a441471 | 750 | |
8b748aed | 751 | iconvdata/% localedata/% po/%: FORCE |
f4017d20 | 752 | $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F) |
2ac579f9 DD |
753 | |
754 | # Convenience target to rerun one test, from the top of the build tree | |
755 | # Example: make test t=wcsmbs/test-wcsnlen | |
756 | .PHONY: test | |
757 | test : | |
758 | @-rm -f $(objpfx)$t.out | |
81a1fa6c | 759 | $(MAKE) subdir=$(patsubst %/,%,$(dir $t)) -C $(dir $t) ..=../ $(objpfx)$t.out |
2ac579f9 DD |
760 | @cat $(objpfx)$t.test-result |
761 | @cat $(objpfx)$t.out |