]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | # Copyright (C) 1991-2019 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 |
625cd00f | 71 | headers := limits.h values.h features.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)) | |
409dfcea UD |
112 | install: install-symbolic-link |
113 | .PHONY: install-symbolic-link | |
114 | install-symbolic-link: subdir_install | |
9d141cae | 115 | $(symbolic-link-prog) $(symbolic-link-list) |
7ef90c15 | 116 | rm -f $(symbolic-link-list) |
9d141cae | 117 | |
8d57beea | 118 | install: |
686554bf | 119 | -test ! -x $(elf-objpfx)ldconfig || LC_ALL=C \ |
4134b50d JM |
120 | $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \ |
121 | $(slibdir) $(libdir) | |
cc3fa755 UD |
122 | ifneq (no,$(PERL)) |
123 | ifeq (/usr,$(prefix)) | |
124 | ifeq (,$(install_root)) | |
d22e28b0 | 125 | LD_SO=$(ld.so-version) CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx) |
cc3fa755 UD |
126 | endif |
127 | endif | |
128 | endif | |
1ef32c3d UD |
129 | endif |
130 | endif | |
28f540f4 | 131 | |
01a36ad3 RM |
132 | # Build subdirectory lib objects. |
133 | lib-noranlib: subdir_lib | |
28f540f4 | 134 | |
01a36ad3 RM |
135 | ifeq (yes,$(build-shared)) |
136 | # Build the shared object from the PIC object library. | |
5f855e35 | 137 | lib: $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so |
bd81123a | 138 | endif # $(build-shared) |
9bfce4bf | 139 | |
f2873d2d FW |
140 | # Used to build testrun.sh. |
141 | define testrun-script | |
142 | #!/bin/bash | |
143 | builddir=`dirname "$$0"` | |
144 | GCONV_PATH="$${builddir}/iconvdata" | |
145 | ||
146 | usage () { | |
147 | echo "usage: $$0 [--tool=strace] PROGRAM [ARGUMENTS...]" 2>&1 | |
148 | echo " $$0 --tool=valgrind PROGRAM [ARGUMENTS...]" 2>&1 | |
5e10136b | 149 | exit 1 |
f2873d2d FW |
150 | } |
151 | ||
152 | toolname=default | |
153 | while test $$# -gt 0 ; do | |
154 | case "$$1" in | |
155 | --tool=*) | |
156 | toolname="$${1:7}" | |
157 | shift | |
158 | ;; | |
159 | --*) | |
160 | usage | |
161 | ;; | |
162 | *) | |
163 | break | |
164 | ;; | |
165 | esac | |
166 | done | |
167 | ||
168 | if test $$# -eq 0 ; then | |
169 | usage | |
170 | fi | |
171 | ||
172 | case "$$toolname" in | |
173 | default) | |
174 | exec $(subst $(common-objdir),"$${builddir}", $(test-program-prefix)) \ | |
175 | $${1+"$$@"} | |
176 | ;; | |
177 | strace) | |
178 | exec strace $(patsubst %, -E%, $(run-program-env)) \ | |
179 | $(test-via-rtld-prefix) $${1+"$$@"} | |
180 | ;; | |
181 | valgrind) | |
182 | exec env $(run-program-env) valgrind $(test-via-rtld-prefix) $${1+"$$@"} | |
183 | ;; | |
184 | *) | |
185 | usage | |
186 | ;; | |
187 | esac | |
188 | endef | |
9bfce4bf RM |
189 | |
190 | # This is a handy script for running any dynamically linked program against | |
191 | # the current libc build for testing. | |
192 | $(common-objpfx)testrun.sh: $(common-objpfx)config.make \ | |
193 | $(..)Makeconfig $(..)Makefile | |
46341286 | 194 | $(file >$@T,$(testrun-script)) |
9bfce4bf RM |
195 | chmod a+x $@T |
196 | mv -f $@T $@ | |
197 | postclean-generated += testrun.sh | |
198 | ||
79ced5a8 GG |
199 | define debugglibc |
200 | #!/bin/bash | |
201 | ||
202 | SOURCE_DIR="$(CURDIR)" | |
203 | BUILD_DIR="$(common-objpfx)" | |
204 | CMD_FILE="$(common-objpfx)debugglibc.gdb" | |
205 | DIRECT=true | |
206 | SYMBOLSFILE=true | |
207 | unset TESTCASE | |
208 | unset BREAKPOINTS | |
209 | unset ENVVARS | |
210 | ||
211 | usage() | |
212 | { | |
213 | cat << EOF | |
21417aaa | 214 | Usage: $$0 [OPTIONS] <program> |
79ced5a8 | 215 | |
21417aaa AS |
216 | Or: $$0 [OPTIONS] -- <program> [<args>]... |
217 | ||
218 | where <program> is the path to the program being tested, | |
219 | and <args> are the arguments to be passed to it. | |
79ced5a8 GG |
220 | |
221 | Options: | |
222 | ||
223 | -h, --help | |
224 | Prints this message and leaves. | |
225 | ||
226 | The following options require one argument: | |
227 | ||
228 | -b, --breakpoint | |
229 | Breakpoints to set at the beginning of the execution | |
230 | (each breakpoint demands its own -b option, e.g. -b foo -b bar) | |
231 | -e, --environment-variable | |
232 | Environment variables to be set with 'exec-wrapper env' in GDB | |
233 | (each environment variable demands its own -e option, e.g. | |
234 | -e FOO=foo -e BAR=bar) | |
235 | ||
236 | The following options do not take arguments: | |
237 | ||
238 | -i, --no-direct | |
21417aaa AS |
239 | Selects whether to pass the --direct flag to the program. |
240 | --direct is useful when debugging glibc test cases. It inhibits the | |
241 | tests from forking and executing in a subprocess. | |
242 | Default behaviour is to pass the --direct flag, except when the | |
243 | program is run with user specified arguments using the "--" separator. | |
79ced5a8 | 244 | -s, --no-symbols-file |
21417aaa | 245 | Do not tell GDB to load debug symbols from the program. |
79ced5a8 GG |
246 | EOF |
247 | } | |
248 | ||
249 | # Parse input options | |
250 | while [[ $$# > 0 ]] | |
251 | do | |
252 | key="$$1" | |
253 | case $$key in | |
254 | -h|--help) | |
255 | usage | |
256 | exit 0 | |
257 | ;; | |
258 | -b|--breakpoint) | |
259 | BREAKPOINTS="break $$2\n$$BREAKPOINTS" | |
260 | shift | |
261 | ;; | |
262 | -e|--environment-variable) | |
263 | ENVVARS="$$2 $$ENVVARS" | |
264 | shift | |
265 | ;; | |
266 | -i|--no-direct) | |
267 | DIRECT=false | |
268 | ;; | |
269 | -s|--no-symbols-file) | |
270 | SYMBOLSFILE=false | |
271 | ;; | |
21417aaa AS |
272 | --) |
273 | shift | |
274 | TESTCASE=$$1 | |
275 | COMMANDLINE="$$@" | |
276 | # Don't add --direct when user specifies program arguments | |
277 | DIRECT=false | |
278 | break | |
279 | ;; | |
79ced5a8 GG |
280 | *) |
281 | TESTCASE=$$1 | |
21417aaa | 282 | COMMANDLINE=$$TESTCASE |
79ced5a8 GG |
283 | ;; |
284 | esac | |
285 | shift | |
286 | done | |
287 | ||
288 | # Check for required argument | |
289 | if [ ! -v TESTCASE ] | |
290 | then | |
291 | usage | |
292 | exit 1 | |
293 | fi | |
294 | ||
295 | # Expand environment setup command | |
296 | if [ -v ENVVARS ] | |
297 | then | |
298 | ENVVARSCMD="set exec-wrapper env $$ENVVARS" | |
299 | fi | |
300 | ||
301 | # Expand direct argument | |
302 | if [ "$$DIRECT" == true ] | |
303 | then | |
304 | DIRECT="--direct" | |
305 | else | |
306 | DIRECT="" | |
307 | fi | |
308 | ||
309 | # Expand symbols loading command | |
310 | if [ "$$SYMBOLSFILE" == true ] | |
311 | then | |
312 | SYMBOLSFILE="add-symbol-file $${TESTCASE}" | |
313 | else | |
314 | SYMBOLSFILE="" | |
315 | fi | |
316 | ||
317 | # GDB commands template | |
318 | template () | |
319 | { | |
320 | cat <<EOF | |
321 | set environment C -E -x c-header | |
322 | set auto-load safe-path $${BUILD_DIR}/nptl_db:\$$debugdir:\$$datadir/auto-load | |
323 | set libthread-db-search-path $${BUILD_DIR}/nptl_db | |
324 | __ENVVARS__ | |
325 | __SYMBOLSFILE__ | |
326 | break _dl_start_user | |
327 | run --library-path $(rpath-link):$${BUILD_DIR}/nptl_db \ | |
21417aaa | 328 | __COMMANDLINE__ __DIRECT__ |
79ced5a8 GG |
329 | __BREAKPOINTS__ |
330 | EOF | |
331 | } | |
332 | ||
333 | # Generate the commands file for gdb initialization | |
334 | template | sed \ | |
335 | -e "s|__ENVVARS__|$$ENVVARSCMD|" \ | |
336 | -e "s|__SYMBOLSFILE__|$$SYMBOLSFILE|" \ | |
21417aaa | 337 | -e "s|__COMMANDLINE__|$$COMMANDLINE|" \ |
79ced5a8 GG |
338 | -e "s|__DIRECT__|$$DIRECT|" \ |
339 | -e "s|__BREAKPOINTS__|$$BREAKPOINTS|" \ | |
340 | > $$CMD_FILE | |
341 | ||
342 | echo | |
343 | echo "Debugging glibc..." | |
344 | echo "Build directory : $$BUILD_DIR" | |
345 | echo "Source directory : $$SOURCE_DIR" | |
346 | echo "GLIBC Testcase : $$TESTCASE" | |
347 | echo "GDB Commands : $$CMD_FILE" | |
348 | echo "Env vars : $$ENVVARS" | |
349 | echo | |
350 | ||
351 | # Start the test case debugging in two steps: | |
352 | # 1. the following command invokes gdb to run the loader; | |
353 | # 2. the commands file tells the loader to run the test case. | |
354 | gdb -q \ | |
355 | -x $${CMD_FILE} \ | |
356 | -d $${SOURCE_DIR} \ | |
357 | $${BUILD_DIR}/elf/ld.so | |
358 | endef | |
359 | ||
360 | # This is another handy script for debugging dynamically linked program | |
361 | # against the current libc build for testing. | |
362 | $(common-objpfx)debugglibc.sh: $(common-objpfx)config.make \ | |
363 | $(..)Makeconfig $(..)Makefile | |
364 | $(file >$@T,$(debugglibc)) | |
365 | chmod a+x $@T | |
366 | mv -f $@T $@ | |
367 | postclean-generated += debugglibc.sh debugglibc.gdb | |
368 | ||
369 | others: $(common-objpfx)testrun.sh $(common-objpfx)debugglibc.sh | |
28f540f4 | 370 | \f |
97a47867 UD |
371 | # Makerules creates a file `stubs' in each subdirectory, which |
372 | # contains `#define __stub_FUNCTION' for each function defined in that | |
373 | # directory which is a stub. | |
6bc31da0 | 374 | # Here we paste all of these together into <gnu/stubs.h>. |
28f540f4 | 375 | |
97a47867 | 376 | subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs) |
28f540f4 | 377 | |
0ab0291b | 378 | ifndef abi-variants |
3e1e123d RM |
379 | installed-stubs = $(inst_includedir)/gnu/stubs.h |
380 | else | |
0ab0291b | 381 | installed-stubs = $(inst_includedir)/gnu/stubs-$(default-abi).h |
3e1e123d | 382 | |
691bc9c1 | 383 | $(inst_includedir)/gnu/stubs.h: $(+force) |
f0cf0902 | 384 | $(make-target-directory) |
0ab0291b L |
385 | { \ |
386 | echo '/* This file is automatically generated.';\ | |
387 | echo " This file selects the right generated file of \`__stub_FUNCTION' macros";\ | |
388 | echo ' based on the architecture being compiled for. */'; \ | |
389 | echo ''; \ | |
390 | $(foreach h,$(abi-includes), echo '#include <$(h)>';) \ | |
391 | echo ''; \ | |
392 | $(foreach v,$(abi-variants),\ | |
393 | $(if $(abi-$(v)-condition),\ | |
394 | echo '#if $(abi-$(v)-condition)'; \ | |
395 | echo '# include <gnu/stubs-$(v).h>'); \ | |
396 | $(if $(abi-$(v)-condition),echo '#endif';) \ | |
397 | rm -f $(@:.d=.h).new$(v); \ | |
398 | ) \ | |
399 | } > $(@:.d=.h).new | |
400 | mv -f $(@:.d=.h).new $(@:.d=.h) | |
3e1e123d RM |
401 | |
402 | install-others-nosubdir: $(installed-stubs) | |
403 | endif | |
404 | ||
405 | ||
28f540f4 RM |
406 | # Since stubs.h is never needed when building the library, we simplify the |
407 | # hairy installation process by producing it in place only as the last part | |
b9b49b44 UD |
408 | # of the top-level `make install'. It depends on subdir_install, which |
409 | # iterates over all the subdirs; subdir_install in each subdir depends on | |
410 | # the subdir's stubs file. Having more direct dependencies would result in | |
411 | # extra iterations over the list for subdirs and many recursive makes. | |
3e1e123d | 412 | $(installed-stubs): include/stubs-prologue.h subdir_install |
5107cf1d | 413 | $(make-target-directory) |
28f540f4 | 414 | @rm -f $(objpfx)stubs.h |
d62507dd | 415 | (sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h |
13a0be88 | 416 | if test -r $@ && cmp -s $(objpfx)stubs.h $@; \ |
ba1ffaa1 | 417 | then echo 'stubs.h unchanged'; \ |
d36e7692 | 418 | else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi |
28f540f4 RM |
419 | rm -f $(objpfx)stubs.h |
420 | \f | |
421 | # This makes the Info or DVI file of the documentation from the Texinfo source. | |
fef0b717 UD |
422 | .PHONY: info dvi pdf html |
423 | info dvi pdf html: | |
c0e45674 | 424 | $(MAKE) $(PARALLELMFLAGS) -C manual $@ |
28f540f4 RM |
425 | \f |
426 | # This makes all the subdirectory targets. | |
427 | ||
428 | # For each target, make it depend on DIR/target for each subdirectory DIR. | |
429 | $(+subdir_targets): %: $(addsuffix /%,$(subdirs)) | |
430 | ||
431 | # Compute a list of all those targets. | |
432 | all-subdirs-targets := $(foreach dir,$(subdirs),\ | |
433 | $(addprefix $(dir)/,$(+subdir_targets))) | |
434 | ||
435 | # The action for each of those is to cd into the directory and make the | |
436 | # target there. | |
437 | $(all-subdirs-targets): | |
e0a3ed4f RM |
438 | $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F) |
439 | ||
440 | define subdir-target-args | |
441 | subdir=$(@D)$(if $($(@D)-srcdir),\ | |
442 | -C $($(@D)-srcdir) ..=`pwd`/,\ | |
443 | -C $(@D) ..=../) | |
444 | endef | |
28f540f4 RM |
445 | |
446 | .PHONY: $(+subdir_targets) $(all-subdirs-targets) | |
447 | \f | |
448 | # Targets to clean things up to various degrees. | |
449 | ||
3c5edd4d UD |
450 | .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \ |
451 | tests-clean | |
28f540f4 RM |
452 | |
453 | # Subroutines of all cleaning targets. | |
454 | parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules. | |
4ddde9ee | 455 | -rm -f $(foreach o,$(object-suffixes-for-libc),\ |
60092701 RM |
456 | $(common-objpfx)$(patsubst %,$(libtype$o),c)) \ |
457 | $(addprefix $(objpfx),$(install-lib)) | |
28f540f4 | 458 | parent-clean: parent-mostlyclean common-clean |
da2d1bc5 UD |
459 | |
460 | postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \ | |
4ae73ca0 | 461 | $(addprefix $(objpfx),sysd-dirs sysd-rules) \ |
4fcddf8e | 462 | $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i) |
28f540f4 RM |
463 | |
464 | clean: parent-clean | |
465 | # This is done this way rather than having `subdir_clean' be a | |
466 | # dependency of this target so that libc.a will be removed before the | |
467 | # subdirectories are dealt with and so they won't try to remove object | |
468 | # files from it when it's going to be removed anyway. | |
469 | @$(MAKE) subdir_clean no_deps=t | |
b5c69d99 | 470 | -rm -f $(postclean) |
28f540f4 RM |
471 | mostlyclean: parent-mostlyclean |
472 | @$(MAKE) subdir_mostlyclean no_deps=t | |
da2d1bc5 | 473 | -rm -f $(postclean) |
28f540f4 | 474 | |
3c5edd4d UD |
475 | tests-clean: |
476 | @$(MAKE) subdir_testclean no_deps=t | |
477 | ||
00db8bf4 | 478 | ifneq (,$(CXX)) |
bd29910a JM |
479 | vpath c++-types.data $(+sysdep_dirs) |
480 | ||
684ce7e0 | 481 | tests-special += $(objpfx)c++-types-check.out |
bd29910a | 482 | $(objpfx)c++-types-check.out: c++-types.data scripts/check-c++-types.sh |
783dd2d3 | 483 | scripts/check-c++-types.sh $< $(CXX) $(filter-out -std=gnu11 $(+gccwarn-c),$(CFLAGS)) $(CPPFLAGS) > $@; \ |
f0881698 | 484 | $(evaluate-test) |
2750c39c | 485 | endif |
806e4a4a | 486 | |
1241b50b | 487 | tests-special += $(objpfx)check-local-headers.out |
16feadf2 | 488 | $(objpfx)check-local-headers.out: scripts/check-local-headers.sh |
ea5ee9f7 | 489 | AWK='$(AWK)' scripts/check-local-headers.sh \ |
3b2cc56d | 490 | "$(includedir)" "$(objpfx)" < /dev/null > $@; \ |
f0881698 | 491 | $(evaluate-test) |
16feadf2 | 492 | |
47755784 ZW |
493 | ifneq "$(headers)" "" |
494 | # Special test of all the installed headers in this directory. | |
495 | tests-special += $(objpfx)check-installed-headers-c.out | |
7c3018f9 | 496 | libof-check-installed-headers-c := testsuite |
47755784 ZW |
497 | $(objpfx)check-installed-headers-c.out: \ |
498 | scripts/check-installed-headers.sh $(headers) | |
499 | $(SHELL) $(..)scripts/check-installed-headers.sh c \ | |
500 | "$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \ | |
501 | $(headers) > $@; \ | |
502 | $(evaluate-test) | |
503 | ||
504 | ifneq "$(CXX)" "" | |
505 | tests-special += $(objpfx)check-installed-headers-cxx.out | |
7c3018f9 | 506 | libof-check-installed-headers-cxx := testsuite |
47755784 ZW |
507 | $(objpfx)check-installed-headers-cxx.out: \ |
508 | scripts/check-installed-headers.sh $(headers) | |
509 | $(SHELL) $(..)scripts/check-installed-headers.sh c++ \ | |
510 | "$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \ | |
511 | $(headers) > $@; \ | |
512 | $(evaluate-test) | |
ad18dade FW |
513 | endif # $(CXX) |
514 | ||
515 | tests-special += $(objpfx)check-wrapper-headers.out | |
516 | $(objpfx)check-wrapper-headers.out: scripts/check-wrapper-headers.py $(headers) | |
517 | $(PYTHON) $< --root=. --subdir=. $(headers) \ | |
518 | --generated $(common-generated) > $@; $(evaluate-test) | |
519 | endif # $(headers) | |
47755784 | 520 | |
44a6213c RM |
521 | define summarize-tests |
522 | @egrep -v '^(PASS|XFAIL):' $(objpfx)$1 || true | |
523 | @echo "Summary of test results$2:" | |
524 | @sed 's/:.*//' < $(objpfx)$1 | sort | uniq -c | |
99db95db | 525 | @! egrep -q -v '^(X?PASS|XFAIL|UNSUPPORTED):' $(objpfx)$1 |
44a6213c RM |
526 | endef |
527 | ||
561b0bec DD |
528 | # The intention here is to do ONE install of our build into the |
529 | # testroot.pristine/ directory, then rsync (internal to | |
530 | # support/test-container) that to testroot.root/ at the start of each | |
531 | # test. That way we can promise each test a "clean" install, without | |
532 | # having to do the install for each test. | |
533 | # | |
534 | # In addition, we have to copy some files (which we build) into this | |
535 | # root in addition to what glibc installs. For example, many tests | |
536 | # require additional programs including /bin/sh, /bin/true, and | |
537 | # /bin/echo, all of which we build below to limit library dependencies | |
538 | # to just those things in glibc and language support libraries which | |
539 | # we also copy into the into the rootfs. To determine what language | |
540 | # support libraries we need we build a "test" program in either C or | |
541 | # (if available) C++ just so we can copy in any shared objects | |
542 | # (which we do not build) that GCC-compiled programs depend on. | |
543 | ||
544 | ||
545 | ifeq (,$(CXX)) | |
546 | LINKS_DSO_PROGRAM = links-dso-program-c | |
547 | else | |
548 | LINKS_DSO_PROGRAM = links-dso-program | |
549 | endif | |
550 | ||
551 | $(tests-container) $(addsuffix /tests,$(subdirs)) : \ | |
552 | $(objpfx)testroot.pristine/install.stamp | |
553 | $(objpfx)testroot.pristine/install.stamp : | |
554 | test -d $(objpfx)testroot.pristine || \ | |
555 | mkdir $(objpfx)testroot.pristine | |
556 | # We need a working /bin/sh for some of the tests. | |
557 | test -d $(objpfx)testroot.pristine/bin || \ | |
558 | mkdir $(objpfx)testroot.pristine/bin | |
559 | cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/bin/sh | |
560 | cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/bin/echo | |
561 | cp $(objpfx)support/true-container $(objpfx)testroot.pristine/bin/true | |
bd598da9 | 562 | ifeq ($(run-built-tests),yes) |
561b0bec DD |
563 | # Copy these DSOs first so we can overwrite them with our own. |
564 | for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \ | |
95da14da | 565 | $(rtld-prefix) \ |
561b0bec DD |
566 | $(objpfx)testroot.pristine/bin/sh \ |
567 | | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\ | |
568 | do \ | |
569 | test -d `dirname $(objpfx)testroot.pristine$$dso` || \ | |
570 | mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\ | |
571 | $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\ | |
572 | done | |
573 | for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \ | |
95da14da | 574 | $(rtld-prefix) \ |
561b0bec DD |
575 | $(objpfx)support/$(LINKS_DSO_PROGRAM) \ |
576 | | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\ | |
577 | do \ | |
578 | test -d `dirname $(objpfx)testroot.pristine$$dso` || \ | |
579 | mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\ | |
580 | $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\ | |
581 | done | |
bd598da9 | 582 | endif |
35e038c1 | 583 | $(MAKE) install DESTDIR=$(objpfx)testroot.pristine \ |
354e4c1a | 584 | subdirs='$(sorted-subdirs)' |
561b0bec DD |
585 | touch $(objpfx)testroot.pristine/install.stamp |
586 | ||
265d52ab | 587 | tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special)) |
f214606a | 588 | tests: $(tests-special) |
265d52ab JM |
589 | $(..)scripts/merge-test-results.sh -s $(objpfx) "" \ |
590 | $(sort $(tests-special-notdir:.out=)) \ | |
591 | > $(objpfx)subdir-tests.sum | |
592 | $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-tests.sum \ | |
593 | $(sort $(subdirs) .) \ | |
594 | > $(objpfx)tests.sum | |
44a6213c | 595 | $(call summarize-tests,tests.sum) |
265d52ab JM |
596 | xtests: |
597 | $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-xtests.sum \ | |
598 | $(sort $(subdirs)) \ | |
599 | > $(objpfx)xtests.sum | |
44a6213c | 600 | $(call summarize-tests,xtests.sum, for extra tests) |
f214606a | 601 | |
28f540f4 RM |
602 | # The realclean target is just like distclean for the parent, but we want |
603 | # the subdirs to know the difference in case they care. | |
604 | realclean distclean: parent-clean | |
605 | # This is done this way rather than having `subdir_distclean' be a | |
606 | # dependency of this target so that libc.a will be removed before the | |
607 | # subdirectories are dealt with and so they won't try to remove object | |
608 | # files from it when it's going to be removed anyway. | |
da2d1bc5 UD |
609 | @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \ |
610 | sysdep-subdirs="$(sysdep-subdirs)" | |
611 | -rm -f $(postclean) | |
28f540f4 RM |
612 | |
613 | # Subroutine of distclean and realclean. | |
614 | distclean-1: subdir_$(distclean-1) | |
615 | -rm -f $(config-generated) | |
60092701 RM |
616 | -rm -f $(addprefix $(objpfx),config.status config.cache config.log) |
617 | -rm -f $(addprefix $(objpfx),config.make config-name.h config.h) | |
28f540f4 RM |
618 | ifdef objdir |
619 | -rm -f $(objpfx)Makefile | |
620 | endif | |
621 | -rm -f $(sysdep-$(distclean-1)) | |
622 | \f | |
9de06f3c RM |
623 | # Make the TAGS file for Emacs users. |
624 | ||
625 | .PHONY: TAGS | |
626 | TAGS: | |
77c84aeb | 627 | scripts/list-sources.sh | sed -n -e '/Makefile/p' \ |
9de06f3c | 628 | $(foreach S,[chsSyl] cxx sh bash pl,\ |
77c84aeb | 629 | $(subst .,\.,-e '/.$S\(.in\)*$$/p')) \ |
9de06f3c RM |
630 | | $(ETAGS) -o $@ - |
631 | \f | |
28f540f4 | 632 | # Make the distribution tarfile. |
6cfe8609 | 633 | .PHONY: dist dist-prepare |
28f540f4 | 634 | |
c7562c74 | 635 | generated := $(generated) stubs.h |
28f540f4 | 636 | |
7ac30cc5 | 637 | files-for-dist := README INSTALL configure ChangeLog NEWS |
6cfe8609 RM |
638 | |
639 | # Regenerate stuff, then error if these things are not committed yet. | |
640 | dist-prepare: $(files-for-dist) | |
644d3857 | 641 | conf=`find sysdeps -name configure`; \ |
6cfe8609 RM |
642 | $(MAKE) $$conf && \ |
643 | git diff --stat HEAD -- $^ $$conf \ | |
644 | | $(AWK) '{ print; rc=1 } END { exit rc }' | |
645 | ||
646 | %.tar: FORCE | |
647 | git archive --prefix=$*/ $* > $@.new | |
648 | mv -f $@.new $@ | |
62780824 | 649 | |
7c0cf356 | 650 | # Do `make dist dist-version=X.Y.Z' to make tar files of an older version. |
7c0cf356 | 651 | |
6cfe8609 RM |
652 | ifneq (,$(strip $(dist-version))) |
653 | dist: $(foreach Z,.bz2 .gz .xz,$(dist-version).tar$Z) | |
62780824 | 654 | md5sum $^ |
6cfe8609 RM |
655 | else |
656 | dist: dist-prepare | |
657 | @if v=`git describe`; then \ | |
658 | echo Distribution version $$v; \ | |
659 | $(MAKE) dist dist-version=$$v; \ | |
660 | else \ | |
661 | false; \ | |
662 | fi | |
663 | endif | |
62780824 | 664 | |
d136c6dc SP |
665 | INSTALL: manual/install-plain.texi manual/macros.texi \ |
666 | $(common-objpfx)manual/pkgvers.texi manual/install.texi | |
4e87147f | 667 | makeinfo --no-validate --plaintext --no-number-sections \ |
b31469d0 JM |
668 | -I$(common-objpfx)manual $< -o $@-tmp |
669 | $(AWK) 'NF == 0 { ++n; next } \ | |
670 | NF != 0 { while (n-- > 0) print ""; n = 0; print }' \ | |
671 | < $@-tmp > $@-tmp2 | |
672 | rm -f $@-tmp | |
673 | -chmod a-w $@-tmp2 | |
674 | mv -f $@-tmp2 $@ | |
8b748aed JM |
675 | $(common-objpfx)manual/%: FORCE |
676 | $(MAKE) $(PARALLELMFLAGS) -C manual $@ | |
f671aeab | 677 | FORCE: |
6a441471 | 678 | |
8b748aed | 679 | iconvdata/% localedata/% po/%: FORCE |
f4017d20 | 680 | $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F) |
2ac579f9 DD |
681 | |
682 | # Convenience target to rerun one test, from the top of the build tree | |
683 | # Example: make test t=wcsmbs/test-wcsnlen | |
684 | .PHONY: test | |
685 | test : | |
686 | @-rm -f $(objpfx)$t.out | |
687 | $(MAKE) subdir=$(dir $t) -C $(dir $t) ..=../ $(objpfx)$t.out | |
688 | @cat $(objpfx)$t.test-result | |
689 | @cat $(objpfx)$t.out |