]> git.ipfire.org Git - thirdparty/glibc.git/blob - Makefile
nss: Re-enable NSS module loading after chroot [BZ #27389]
[thirdparty/glibc.git] / Makefile
1 # Copyright (C) 1991-2021 Free Software Foundation, Inc.
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
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.
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
12 # Lesser General Public License for more details.
13
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
17
18 #
19 # Master Makefile for the GNU C library
20 #
21 ifneq (,)
22 This makefile requires GNU Make.
23 endif
24
25 include Makeconfig
26
27
28 # This is the default target; it makes everything except the tests.
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
40 \f
41 ifneq ($(AUTOCONF),no)
42
43 define autoconf-it
44 @-rm -f $@.new
45 $(AUTOCONF) $(ACFLAGS) $< > $@.new
46 chmod a-w$(patsubst %,$(comma)a+x,$(filter .,$(@D))) $@.new
47 mv -f $@.new $@
48 endef
49
50 configure: configure.ac aclocal.m4; $(autoconf-it)
51 %/configure: %/configure.ac aclocal.m4; $(autoconf-it)
52 %/preconfigure: %/preconfigure.ac aclocal.m4; $(autoconf-it)
53
54 endif # $(AUTOCONF) = no
55
56
57 # We don't want to run anything here in parallel.
58 .NOTPARALLEL:
59
60 # These are the targets that are made by making them in each subdirectory.
61 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
62 subdir_clean subdir_distclean subdir_realclean \
63 tests xtests \
64 subdir_update-abi subdir_check-abi \
65 subdir_update-all-abi \
66 subdir_echo-headers \
67 subdir_install \
68 subdir_objs subdir_stubs subdir_testclean \
69 $(addprefix install-, no-libc.a bin lib data headers others)
70 \f
71 headers := limits.h values.h features.h gnu-versions.h \
72 bits/xopen_lim.h gnu/libc-version.h stdc-predef.h \
73 bits/libc-header-start.h
74
75 echo-headers: subdir_echo-headers
76
77 # The headers are in the include directory.
78 subdir-dirs = include
79 vpath %.h $(subdir-dirs)
80
81 # What to install.
82 install-others = $(inst_includedir)/gnu/stubs.h
83 install-bin-script =
84
85 ifeq (yes,$(build-shared))
86 headers += gnu/lib-names.h
87 endif
88
89 include Makerules
90
91 ifeq ($(build-programs),yes)
92 others: $(addprefix $(objpfx),$(install-bin-script))
93 endif
94
95 # Install from subdirectories too.
96 install: subdir_install
97
98 # Explicit dependency so that `make install-headers' works
99 install-headers: install-headers-nosubdir
100
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
108 # Create links for shared libraries using the `ldconfig' program if possible.
109 # Ignore the error if we cannot update /etc/ld.so.cache.
110 ifeq (no,$(cross-compiling))
111 ifeq (yes,$(build-shared))
112 install: install-symbolic-link
113 .PHONY: install-symbolic-link
114 install-symbolic-link: subdir_install
115 $(symbolic-link-prog) $(symbolic-link-list)
116 rm -f $(symbolic-link-list)
117
118 install:
119 -test ! -x $(elf-objpfx)ldconfig || LC_ALL=C \
120 $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \
121 $(slibdir) $(libdir)
122 ifneq (no,$(PERL))
123 ifeq (/usr,$(prefix))
124 ifeq (,$(install_root))
125 LD_SO=$(ld.so-version) CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)
126 endif
127 endif
128 endif
129 endif
130 endif
131
132 # Build subdirectory lib objects.
133 lib-noranlib: subdir_lib
134
135 ifeq (yes,$(build-shared))
136 # Build the shared object from the PIC object library.
137 lib: $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so
138 endif # $(build-shared)
139
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
149 exit 1
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 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 ;;
189 *)
190 usage
191 ;;
192 esac
193 endef
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
199 $(file >$@T,$(testrun-script))
200 chmod a+x $@T
201 mv -f $@T $@
202 postclean-generated += testrun.sh
203
204 define debugglibc
205 #!/bin/bash
206
207 SOURCE_DIR="$(CURDIR)"
208 BUILD_DIR="$(common-objpfx)"
209 CMD_FILE="$(common-objpfx)debugglibc.gdb"
210 CONTAINER=false
211 DIRECT=true
212 STATIC=false
213 SYMBOLSFILE=true
214 unset TESTCASE
215 unset BREAKPOINTS
216 unset ENVVARS
217
218 usage()
219 {
220 cat << EOF
221 Usage: $$0 [OPTIONS] <program>
222
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.
227
228 Options:
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
245 -c, --in-container
246 Run the test case inside a container and automatically attach
247 GDB to it.
248 -i, --no-direct
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.
254 -s, --no-symbols-file
255 Do not tell GDB to load debug symbols from the program.
256 EOF
257 }
258
259 # Parse input options
260 while [[ $$# > 0 ]]
261 do
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 ;;
276 -c|--in-container)
277 CONTAINER=true
278 ;;
279 -i|--no-direct)
280 DIRECT=false
281 ;;
282 -s|--no-symbols-file)
283 SYMBOLSFILE=false
284 ;;
285 --)
286 shift
287 TESTCASE=$$1
288 COMMANDLINE="$$@"
289 # Don't add --direct when user specifies program arguments
290 DIRECT=false
291 break
292 ;;
293 *)
294 TESTCASE=$$1
295 COMMANDLINE=$$TESTCASE
296 ;;
297 esac
298 shift
299 done
300
301 # Check for required argument and if the testcase exists
302 if [ ! -v TESTCASE ] || [ ! -f $${TESTCASE} ]
303 then
304 usage
305 exit 1
306 fi
307
308 # Container tests needing locale data should install them in-container.
309 # Other tests/binaries need to use locale data from the build tree.
310 if [ "$$CONTAINER" = false ]
311 then
312 ENVVARS="GCONV_PATH=$${BUILD_DIR}/iconvdata $$ENVVARS"
313 ENVVARS="LOCPATH=$${BUILD_DIR}/localedata $$ENVVARS"
314 ENVVARS="LC_ALL=C $$ENVVARS"
315 fi
316
317 # Expand environment setup command
318 if [ -v ENVVARS ]
319 then
320 ENVVARSCMD="set exec-wrapper env $$ENVVARS"
321 fi
322
323 # Expand direct argument
324 if [ "$$DIRECT" == true ]
325 then
326 DIRECT="--direct"
327 else
328 DIRECT=""
329 fi
330
331 # Check if the test case is static
332 if file $${TESTCASE} | grep "statically linked" >/dev/null
333 then
334 STATIC=true
335 else
336 STATIC=false
337 fi
338
339 # Expand symbols loading command
340 if [ "$$SYMBOLSFILE" == true ]
341 then
342 SYMBOLSFILE="add-symbol-file $${TESTCASE}"
343 else
344 SYMBOLSFILE=""
345 fi
346
347 # GDB commands template
348 template ()
349 {
350 cat <<EOF
351 set environment C -E -x c-header
352 set auto-load safe-path $${BUILD_DIR}/nptl_db:\$$debugdir:\$$datadir/auto-load
353 set libthread-db-search-path $${BUILD_DIR}/nptl_db
354 __ENVVARS__
355 __SYMBOLSFILE__
356 break _dl_start_user
357 run --library-path $(rpath-link):$${BUILD_DIR}/nptl_db \
358 __COMMANDLINE__ __DIRECT__
359 __BREAKPOINTS__
360 EOF
361 }
362
363 # Generate the commands file for gdb initialization
364 template | sed \
365 -e "s|__ENVVARS__|$$ENVVARSCMD|" \
366 -e "s|__SYMBOLSFILE__|$$SYMBOLSFILE|" \
367 -e "s|__COMMANDLINE__|$$COMMANDLINE|" \
368 -e "s|__DIRECT__|$$DIRECT|" \
369 -e "s|__BREAKPOINTS__|$$BREAKPOINTS|" \
370 > $$CMD_FILE
371
372 echo
373 echo "Debugging glibc..."
374 echo "Build directory : $$BUILD_DIR"
375 echo "Source directory : $$SOURCE_DIR"
376 echo "GLIBC Testcase : $$TESTCASE"
377 echo "GDB Commands : $$CMD_FILE"
378 echo "Env vars : $$ENVVARS"
379 echo
380
381 if [ "$$CONTAINER" == true ]
382 then
383 # Use testrun.sh to start the test case with WAIT_FOR_DEBUGGER=1, then
384 # automatically attach GDB to it.
385 WAIT_FOR_DEBUGGER=1 $(common-objpfx)testrun.sh --tool=container $${TESTCASE} &
386 gdb -x $${TESTCASE}.gdb
387 elif [ "$$STATIC" == true ]
388 then
389 gdb $${TESTCASE}
390 else
391 # Start the test case debugging in two steps:
392 # 1. the following command invokes gdb to run the loader;
393 # 2. the commands file tells the loader to run the test case.
394 gdb -q \
395 -x $${CMD_FILE} \
396 -d $${SOURCE_DIR} \
397 $${BUILD_DIR}/elf/ld.so
398 fi
399 endef
400
401 # This is another handy script for debugging dynamically linked program
402 # against the current libc build for testing.
403 $(common-objpfx)debugglibc.sh: $(common-objpfx)config.make \
404 $(..)Makeconfig $(..)Makefile
405 $(file >$@T,$(debugglibc))
406 chmod a+x $@T
407 mv -f $@T $@
408 postclean-generated += debugglibc.sh debugglibc.gdb
409
410 others: $(common-objpfx)testrun.sh $(common-objpfx)debugglibc.sh
411 \f
412 # Makerules creates a file `stubs' in each subdirectory, which
413 # contains `#define __stub_FUNCTION' for each function defined in that
414 # directory which is a stub.
415 # Here we paste all of these together into <gnu/stubs.h>.
416
417 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
418
419 ifndef abi-variants
420 installed-stubs = $(inst_includedir)/gnu/stubs.h
421 else
422 installed-stubs = $(inst_includedir)/gnu/stubs-$(default-abi).h
423
424 $(inst_includedir)/gnu/stubs.h: $(+force)
425 $(make-target-directory)
426 { \
427 echo '/* This file is automatically generated.';\
428 echo " This file selects the right generated file of \`__stub_FUNCTION' macros";\
429 echo ' based on the architecture being compiled for. */'; \
430 echo ''; \
431 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
432 echo ''; \
433 $(foreach v,$(abi-variants),\
434 $(if $(abi-$(v)-condition),\
435 echo '#if $(abi-$(v)-condition)'; \
436 echo '# include <gnu/stubs-$(v).h>'); \
437 $(if $(abi-$(v)-condition),echo '#endif';) \
438 rm -f $(@:.d=.h).new$(v); \
439 ) \
440 } > $(@:.d=.h).new
441 mv -f $(@:.d=.h).new $(@:.d=.h)
442
443 install-others-nosubdir: $(installed-stubs)
444 endif
445
446
447 # Since stubs.h is never needed when building the library, we simplify the
448 # hairy installation process by producing it in place only as the last part
449 # of the top-level `make install'. It depends on subdir_install, which
450 # iterates over all the subdirs; subdir_install in each subdir depends on
451 # the subdir's stubs file. Having more direct dependencies would result in
452 # extra iterations over the list for subdirs and many recursive makes.
453 $(installed-stubs): include/stubs-prologue.h subdir_install
454 $(make-target-directory)
455 @rm -f $(objpfx)stubs.h
456 (sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h
457 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
458 then echo 'stubs.h unchanged'; \
459 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
460 rm -f $(objpfx)stubs.h
461 \f
462 # This makes the Info or DVI file of the documentation from the Texinfo source.
463 .PHONY: info dvi pdf html
464 info dvi pdf html:
465 $(MAKE) $(PARALLELMFLAGS) -C manual $@
466 \f
467 # This makes all the subdirectory targets.
468
469 # For each target, make it depend on DIR/target for each subdirectory DIR.
470 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
471
472 # Compute a list of all those targets.
473 all-subdirs-targets := $(foreach dir,$(subdirs),\
474 $(addprefix $(dir)/,$(+subdir_targets)))
475
476 # The action for each of those is to cd into the directory and make the
477 # target there.
478 $(all-subdirs-targets):
479 $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F)
480
481 define subdir-target-args
482 subdir=$(@D)$(if $($(@D)-srcdir),\
483 -C $($(@D)-srcdir) ..=`pwd`/,\
484 -C $(@D) ..=../)
485 endef
486
487 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
488 \f
489 # Targets to clean things up to various degrees.
490
491 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
492 tests-clean
493
494 # Subroutines of all cleaning targets.
495 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
496 -rm -f $(foreach o,$(object-suffixes-for-libc),\
497 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
498 $(addprefix $(objpfx),$(install-lib))
499 parent-clean: parent-mostlyclean common-clean
500
501 postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
502 $(addprefix $(objpfx),sysd-dirs sysd-rules) \
503 $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
504
505 clean: parent-clean
506 # This is done this way rather than having `subdir_clean' be a
507 # dependency of this target so that libc.a will be removed before the
508 # subdirectories are dealt with and so they won't try to remove object
509 # files from it when it's going to be removed anyway.
510 @$(MAKE) subdir_clean no_deps=t
511 -rm -f $(postclean)
512 mostlyclean: parent-mostlyclean
513 @$(MAKE) subdir_mostlyclean no_deps=t
514 -rm -f $(postclean)
515
516 tests-clean:
517 @$(MAKE) subdir_testclean no_deps=t
518
519 ifneq (,$(CXX))
520 vpath c++-types.data $(+sysdep_dirs)
521
522 tests-special += $(objpfx)c++-types-check.out
523 $(objpfx)c++-types-check.out: c++-types.data scripts/check-c++-types.sh
524 scripts/check-c++-types.sh $< $(CXX) $(filter-out -std=gnu11 $(+gccwarn-c),$(CFLAGS)) $(CPPFLAGS) > $@; \
525 $(evaluate-test)
526 endif
527
528 tests-special += $(objpfx)check-local-headers.out
529 $(objpfx)check-local-headers.out: scripts/check-local-headers.sh
530 AWK='$(AWK)' scripts/check-local-headers.sh \
531 "$(includedir)" "$(objpfx)" < /dev/null > $@; \
532 $(evaluate-test)
533
534 ifneq "$(headers)" ""
535 # Special test of all the installed headers in this directory.
536 tests-special += $(objpfx)check-installed-headers-c.out
537 libof-check-installed-headers-c := testsuite
538 $(objpfx)check-installed-headers-c.out: \
539 scripts/check-installed-headers.sh $(headers)
540 $(SHELL) $(..)scripts/check-installed-headers.sh c \
541 "$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
542 $(headers) > $@; \
543 $(evaluate-test)
544
545 ifneq "$(CXX)" ""
546 tests-special += $(objpfx)check-installed-headers-cxx.out
547 libof-check-installed-headers-cxx := testsuite
548 $(objpfx)check-installed-headers-cxx.out: \
549 scripts/check-installed-headers.sh $(headers)
550 $(SHELL) $(..)scripts/check-installed-headers.sh c++ \
551 "$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
552 $(headers) > $@; \
553 $(evaluate-test)
554 endif # $(CXX)
555
556 tests-special += $(objpfx)check-wrapper-headers.out
557 $(objpfx)check-wrapper-headers.out: scripts/check-wrapper-headers.py $(headers)
558 $(PYTHON) $< --root=. --subdir=. $(headers) \
559 --generated $(common-generated) > $@; $(evaluate-test)
560 endif # $(headers)
561
562 define summarize-tests
563 @egrep -v '^(PASS|XFAIL):' $(objpfx)$1 || true
564 @echo "Summary of test results$2:"
565 @sed 's/:.*//' < $(objpfx)$1 | sort | uniq -c
566 @! egrep -q -v '^(X?PASS|XFAIL|UNSUPPORTED):' $(objpfx)$1
567 endef
568
569 # The intention here is to do ONE install of our build into the
570 # testroot.pristine/ directory, then rsync (internal to
571 # support/test-container) that to testroot.root/ at the start of each
572 # test. That way we can promise each test a "clean" install, without
573 # having to do the install for each test.
574 #
575 # In addition, we have to copy some files (which we build) into this
576 # root in addition to what glibc installs. For example, many tests
577 # require additional programs including /bin/sh, /bin/true, and
578 # /bin/echo, all of which we build below to limit library dependencies
579 # to just those things in glibc and language support libraries which
580 # we also copy into the into the rootfs. To determine what language
581 # support libraries we need we build a "test" program in either C or
582 # (if available) C++ just so we can copy in any shared objects
583 # (which we do not build) that GCC-compiled programs depend on.
584
585
586 ifeq (,$(CXX))
587 LINKS_DSO_PROGRAM = links-dso-program-c
588 else
589 LINKS_DSO_PROGRAM = links-dso-program
590 endif
591
592 $(tests-container) $(addsuffix /tests,$(subdirs)) : \
593 $(objpfx)testroot.pristine/install.stamp
594 $(objpfx)testroot.pristine/install.stamp :
595 test -d $(objpfx)testroot.pristine || \
596 mkdir $(objpfx)testroot.pristine
597 # We need a working /bin/sh for some of the tests.
598 test -d $(objpfx)testroot.pristine/bin || \
599 mkdir $(objpfx)testroot.pristine/bin
600 # We need the compiled locale dir for localedef tests.
601 test -d $(objpfx)testroot.pristine/$(complocaledir) || \
602 mkdir -p $(objpfx)testroot.pristine/$(complocaledir)
603 cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/bin/sh
604 cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/bin/echo
605 cp $(objpfx)support/true-container $(objpfx)testroot.pristine/bin/true
606 ifeq ($(run-built-tests),yes)
607 # Copy these DSOs first so we can overwrite them with our own.
608 for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \
609 $(rtld-prefix) \
610 $(objpfx)testroot.pristine/bin/sh \
611 | sed -n '/\//{s@.*=> /@/@;s/^[^/]*//;s/ .*//p;}'` ;\
612 do \
613 test -d `dirname $(objpfx)testroot.pristine$$dso` || \
614 mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\
615 $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\
616 done
617 for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \
618 $(rtld-prefix) \
619 $(objpfx)support/$(LINKS_DSO_PROGRAM) \
620 | sed -n '/\//{s@.*=> /@/@;s/^[^/]*//;s/ .*//p;}'` ;\
621 do \
622 test -d `dirname $(objpfx)testroot.pristine$$dso` || \
623 mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\
624 $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\
625 done
626 endif
627 # $(symbolic-link-list) is a file that encodes $(DESTDIR) so we
628 # have to purge it
629 rm -f $(symbolic-link-list)
630 # Setting INSTALL_UNCOMPRESSED causes localedata/Makefile to
631 # install the charmaps uncompressed, as the testroot does not
632 # provide a gunzip program.
633 $(MAKE) install DESTDIR=$(objpfx)testroot.pristine \
634 INSTALL_UNCOMPRESSED=yes subdirs='$(sorted-subdirs)'
635 rm -f $(symbolic-link-list)
636 touch $(objpfx)testroot.pristine/install.stamp
637
638 tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
639 tests: $(tests-special)
640 $(..)scripts/merge-test-results.sh -s $(objpfx) "" \
641 $(sort $(tests-special-notdir:.out=)) \
642 > $(objpfx)subdir-tests.sum
643 $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-tests.sum \
644 $(sort $(subdirs) .) \
645 > $(objpfx)tests.sum
646 $(call summarize-tests,tests.sum)
647 xtests:
648 $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-xtests.sum \
649 $(sort $(subdirs)) \
650 > $(objpfx)xtests.sum
651 $(call summarize-tests,xtests.sum, for extra tests)
652
653 # The realclean target is just like distclean for the parent, but we want
654 # the subdirs to know the difference in case they care.
655 realclean distclean: parent-clean
656 # This is done this way rather than having `subdir_distclean' be a
657 # dependency of this target so that libc.a will be removed before the
658 # subdirectories are dealt with and so they won't try to remove object
659 # files from it when it's going to be removed anyway.
660 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
661 sysdep-subdirs="$(sysdep-subdirs)"
662 -rm -f $(postclean)
663
664 # Subroutine of distclean and realclean.
665 distclean-1: subdir_$(distclean-1)
666 -rm -f $(config-generated)
667 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
668 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
669 ifdef objdir
670 -rm -f $(objpfx)Makefile
671 endif
672 -rm -f $(sysdep-$(distclean-1))
673 \f
674 # Make the TAGS file for Emacs users.
675
676 .PHONY: TAGS
677 TAGS:
678 scripts/list-sources.sh | sed -n -e '/Makefile/p' \
679 $(foreach S,[chsSyl] cxx sh bash pl,\
680 $(subst .,\.,-e '/.$S\(.in\)*$$/p')) \
681 | $(ETAGS) -o $@ -
682 \f
683 # Make the distribution tarfile.
684 .PHONY: dist dist-prepare
685
686 generated := $(generated) stubs.h
687
688 files-for-dist := README INSTALL configure NEWS
689
690 # Regenerate stuff, then error if these things are not committed yet.
691 dist-prepare: $(files-for-dist)
692 conf=`find sysdeps -name configure`; \
693 $(MAKE) $$conf && \
694 git diff --stat HEAD -- $^ $$conf \
695 | $(AWK) '{ print; rc=1 } END { exit rc }'
696
697 %.tar: FORCE
698 git archive --prefix=$*/ $* > $@.new
699 mv -f $@.new $@
700
701 # Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
702
703 ifneq (,$(strip $(dist-version)))
704 dist: $(foreach Z,.bz2 .gz .xz,$(dist-version).tar$Z)
705 md5sum $^
706 else
707 dist: dist-prepare
708 @if v=`git describe`; then \
709 echo Distribution version $$v; \
710 $(MAKE) dist dist-version=$$v; \
711 else \
712 false; \
713 fi
714 endif
715
716 INSTALL: manual/install-plain.texi manual/macros.texi \
717 $(common-objpfx)manual/pkgvers.texi manual/install.texi
718 makeinfo --no-validate --plaintext --no-number-sections \
719 -I$(common-objpfx)manual $< -o $@-tmp
720 $(AWK) 'NF == 0 { ++n; next } \
721 NF != 0 { while (n-- > 0) print ""; n = 0; print }' \
722 < $@-tmp > $@-tmp2
723 rm -f $@-tmp
724 -chmod a-w $@-tmp2
725 mv -f $@-tmp2 $@
726 $(common-objpfx)manual/%: FORCE
727 $(MAKE) $(PARALLELMFLAGS) -C manual $@
728 FORCE:
729
730 iconvdata/% localedata/% po/%: FORCE
731 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
732
733 # Convenience target to rerun one test, from the top of the build tree
734 # Example: make test t=wcsmbs/test-wcsnlen
735 .PHONY: test
736 test :
737 @-rm -f $(objpfx)$t.out
738 $(MAKE) subdir=$(patsubst %/,%,$(dir $t)) -C $(dir $t) ..=../ $(objpfx)$t.out
739 @cat $(objpfx)$t.test-result
740 @cat $(objpfx)$t.out