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