1 # Copyright (C) 1991-2018 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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 # <http://www.gnu.org/licenses/>.
19 # Master Makefile for the GNU C library
22 This makefile requires GNU Make.
28 # This is the default target; it makes everything except the tests.
32 ifneq ($(AUTOCONF
),no
)
36 $(AUTOCONF
) $(ACFLAGS
) $< > $@.new
37 chmod a-w
$(patsubst %,$(comma
)a
+x
,$(filter .
,$(@D
))) $@.new
41 configure
: configure.ac aclocal.m4
; $(autoconf-it
)
42 %/configure
: %/configure.ac aclocal.m4
; $(autoconf-it
)
43 %/preconfigure
: %/preconfigure.ac aclocal.m4
; $(autoconf-it
)
45 endif # $(AUTOCONF) = no
48 # We don't want to run anything here in parallel.
51 # These are the targets that are made by making them in each subdirectory.
52 +subdir_targets
:= subdir_lib objects objs others subdir_mostlyclean \
53 subdir_clean subdir_distclean subdir_realclean \
55 subdir_update-abi subdir_check-abi \
56 subdir_update-all-abi \
59 subdir_objs subdir_stubs subdir_testclean \
60 $(addprefix install-
, no-libc.a bin lib data headers others
)
62 headers
:= limits.h values.h features.h gnu-versions.h \
63 bits
/xopen_lim.h gnu
/libc-version.h stdc-predef.h \
64 bits
/libc-header-start.h
66 echo-headers
: subdir_echo-headers
68 # The headers are in the include directory.
70 vpath
%.h
$(subdir-dirs
)
73 install-others
= $(inst_includedir
)/gnu
/stubs.h
76 ifeq (yes
,$(build-shared
))
77 headers
+= gnu
/lib-names.h
82 ifeq ($(build-programs
),yes
)
83 others
: $(addprefix $(objpfx
),$(install-bin-script
))
86 # Install from subdirectories too.
87 install: subdir_install
89 # Explicit dependency so that `make install-headers' works
90 install-headers
: install-headers-nosubdir
92 # Make sure that the dynamic linker is installed before libc.
93 $(inst_slibdir
)/libc-
$(version
).so
: elf
/ldso_install
95 .PHONY
: elf
/ldso_install
97 $(MAKE
) -C
$(@D
) $(@F
)
99 # Create links for shared libraries using the `ldconfig' program if possible.
100 # Ignore the error if we cannot update /etc/ld.so.cache.
101 ifeq (no
,$(cross-compiling
))
102 ifeq (yes
,$(build-shared
))
103 install: install-symbolic-link
104 .PHONY
: install-symbolic-link
105 install-symbolic-link
: subdir_install
106 $(symbolic-link-prog
) $(symbolic-link-list
)
107 rm -f
$(symbolic-link-list
)
110 -test ! -x
$(elf-objpfx
)ldconfig || LC_ALL
=C \
111 $(elf-objpfx
)ldconfig
$(addprefix -r
,$(install_root
)) \
114 ifeq (/usr
,$(prefix))
115 ifeq (,$(install_root
))
116 LD_SO
=$(ld.so-version
) CC
="$(CC)" $(PERL
) scripts
/test-installation.pl
$(common-objpfx
)
123 # Build subdirectory lib objects.
124 lib-noranlib
: subdir_lib
126 ifeq (yes
,$(build-shared
))
127 # Build the shared object from the PIC object library.
128 lib
: $(common-objpfx
)libc.so
$(common-objpfx
)linkobj
/libc.so
129 endif # $(build-shared)
131 # Used to build testrun.sh.
132 define testrun-script
134 builddir
=`dirname "$$0"`
135 GCONV_PATH
="$${builddir}/iconvdata"
138 echo
"usage: $$0 [--tool=strace] PROGRAM [ARGUMENTS...]" 2>&1
139 echo
" $$0 --tool=valgrind PROGRAM [ARGUMENTS...]" 2>&1
143 while
test $$# -gt 0 ; do
158 if
test $$# -eq 0 ; then
164 exec
$(subst $(common-objdir
),"$${builddir}", $(test-program-prefix
)) \
168 exec strace
$(patsubst %, -E
%, $(run-program-env
)) \
169 $(test-via-rtld-prefix
) $${1+"$$@"}
172 exec env
$(run-program-env
) valgrind
$(test-via-rtld-prefix
) $${1+"$$@"}
180 # This is a handy script for running any dynamically linked program against
181 # the current libc build for testing.
182 $(common-objpfx
)testrun.sh
: $(common-objpfx
)config.make \
183 $(..
)Makeconfig
$(..
)Makefile
184 $(file
>$@T
, $(testrun-script
))
187 postclean-generated
+= testrun.sh
189 others
: $(common-objpfx
)testrun.sh
191 # Makerules creates a file `stubs' in each subdirectory, which
192 # contains `#define __stub_FUNCTION' for each function defined in that
193 # directory which is a stub.
194 # Here we paste all of these together into <gnu/stubs.h>.
196 subdir-stubs
:= $(foreach dir,$(subdirs
),$(common-objpfx
)$(dir)/stubs
)
199 installed-stubs
= $(inst_includedir
)/gnu
/stubs.h
201 installed-stubs
= $(inst_includedir
)/gnu
/stubs-
$(default-abi
).h
203 $(inst_includedir
)/gnu
/stubs.h
: $(+force)
204 $(make-target-directory
)
206 echo
'/* This file is automatically generated.';\
207 echo
" This file selects the right generated file of \`__stub_FUNCTION' macros";\
208 echo
' based on the architecture being compiled for. */'; \
210 $(foreach h
,$(abi-includes
), echo
'#include <$(h)>';) \
212 $(foreach v
,$(abi-variants
),\
213 $(if
$(abi-
$(v
)-condition
),\
214 echo
'#if $(abi-$(v)-condition)'; \
215 echo
'# include <gnu/stubs-$(v).h>'); \
216 $(if
$(abi-
$(v
)-condition
),echo
'#endif';) \
217 rm -f
$(@
:.d
=.h
).new
$(v
); \
220 mv
-f
$(@
:.d
=.h
).new
$(@
:.d
=.h
)
222 install-others-nosubdir
: $(installed-stubs
)
226 # Since stubs.h is never needed when building the library, we simplify the
227 # hairy installation process by producing it in place only as the last part
228 # of the top-level `make install'. It depends on subdir_install, which
229 # iterates over all the subdirs; subdir_install in each subdir depends on
230 # the subdir's stubs file. Having more direct dependencies would result in
231 # extra iterations over the list for subdirs and many recursive makes.
232 $(installed-stubs
): include/stubs-prologue.h subdir_install
233 $(make-target-directory
)
234 @
rm -f
$(objpfx
)stubs.h
235 (sed
'/^@/d' $<; LC_ALL
=C
sort $(subdir-stubs
)) > $(objpfx
)stubs.h
236 if
test -r
$@
&& cmp
-s
$(objpfx
)stubs.h
$@
; \
237 then echo
'stubs.h unchanged'; \
238 else $(INSTALL_DATA
) $(objpfx
)stubs.h
$@
; fi
239 rm -f
$(objpfx
)stubs.h
241 # This makes the Info or DVI file of the documentation from the Texinfo source.
242 .PHONY
: info dvi pdf html
244 $(MAKE
) $(PARALLELMFLAGS
) -C manual
$@
246 # This makes all the subdirectory targets.
248 # For each target, make it depend on DIR/target for each subdirectory DIR.
249 $(+subdir_targets
): %: $(addsuffix /%,$(subdirs
))
251 # Compute a list of all those targets.
252 all-subdirs-targets
:= $(foreach dir,$(subdirs
),\
253 $(addprefix $(dir)/,$(+subdir_targets
)))
255 # The action for each of those is to cd into the directory and make the
257 $(all-subdirs-targets
):
258 $(MAKE
) $(PARALLELMFLAGS
) $(subdir-target-args
) $(@F
)
260 define subdir-target-args
261 subdir
=$(@D
)$(if
$($(@D
)-srcdir),\
262 -C
$($(@D
)-srcdir) ..
=`pwd`/,\
266 .PHONY
: $(+subdir_targets
) $(all-subdirs-targets
)
268 # Targets to clean things up to various degrees.
270 .PHONY
: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
273 # Subroutines of all cleaning targets.
274 parent-mostlyclean
: common-mostlyclean
# common-mostlyclean is in Makerules.
275 -rm -f
$(foreach o
,$(object-suffixes-for-libc
),\
276 $(common-objpfx
)$(patsubst %,$(libtype
$o),c
)) \
277 $(addprefix $(objpfx
),$(install-lib
))
278 parent-clean
: parent-mostlyclean common-clean
280 postclean
= $(addprefix $(common-objpfx
),$(postclean-generated
)) \
281 $(addprefix $(objpfx
),sysd-dirs sysd-rules
) \
282 $(addprefix $(objpfx
),sysd-sorted soversions.mk soversions.i
)
285 # This is done this way rather than having `subdir_clean' be a
286 # dependency of this target so that libc.a will be removed before the
287 # subdirectories are dealt with and so they won't try to remove object
288 # files from it when it's going to be removed anyway.
289 @
$(MAKE
) subdir_clean no_deps
=t
291 mostlyclean: parent-mostlyclean
292 @
$(MAKE
) subdir_mostlyclean no_deps
=t
296 @
$(MAKE
) subdir_testclean no_deps
=t
299 vpath c
++-types.data
$(+sysdep_dirs
)
301 tests-special
+= $(objpfx
)c
++-types-check.out
302 $(objpfx
)c
++-types-check.out
: c
++-types.data scripts
/check-c
++-types.sh
303 scripts
/check-c
++-types.sh
$< $(CXX
) $(filter-out -std
=gnu11
$(+gccwarn-c
),$(CFLAGS
)) $(CPPFLAGS
) > $@
; \
307 tests-special
+= $(objpfx
)check-local-headers.out
308 $(objpfx
)check-local-headers.out
: scripts
/check-local-headers.sh
309 AWK
='$(AWK)' scripts
/check-local-headers.sh \
310 "$(includedir)" "$(objpfx)" < /dev
/null
> $@
; \
313 ifneq "$(headers)" ""
314 # Special test of all the installed headers in this directory.
315 tests-special
+= $(objpfx
)check-installed-headers-c.out
316 libof-check-installed-headers-c
:= testsuite
317 $(objpfx
)check-installed-headers-c.out
: \
318 scripts
/check-installed-headers.sh
$(headers
)
319 $(SHELL
) $(..
)scripts
/check-installed-headers.sh c \
320 "$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
325 tests-special
+= $(objpfx
)check-installed-headers-cxx.out
326 libof-check-installed-headers-cxx
:= testsuite
327 $(objpfx
)check-installed-headers-cxx.out
: \
328 scripts
/check-installed-headers.sh
$(headers
)
329 $(SHELL
) $(..
)scripts
/check-installed-headers.sh c
++ \
330 "$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
336 define summarize-tests
337 @egrep
-v
'^(PASS|XFAIL):' $(objpfx
)$1 || true
338 @echo
"Summary of test results$2:"
339 @sed
's/:.*//' < $(objpfx
)$1 |
sort | uniq
-c
340 @
! egrep
-q
-v
'^(X?PASS|XFAIL|UNSUPPORTED):' $(objpfx
)$1
343 tests-special-notdir
= $(patsubst $(objpfx
)%, %, $(tests-special
))
344 tests
: $(tests-special
)
345 $(..
)scripts
/merge-test-results.sh
-s
$(objpfx
) "" \
346 $(sort $(tests-special-notdir
:.out
=)) \
347 > $(objpfx
)subdir-tests.sum
348 $(..
)scripts
/merge-test-results.sh
-t
$(objpfx
) subdir-tests.sum \
349 $(sort $(subdirs
) .
) \
351 $(call summarize-tests
,tests.sum
)
353 $(..
)scripts
/merge-test-results.sh
-t
$(objpfx
) subdir-xtests.sum \
355 > $(objpfx
)xtests.sum
356 $(call summarize-tests
,xtests.sum
, for extra tests
)
358 # The realclean target is just like distclean for the parent, but we want
359 # the subdirs to know the difference in case they care.
360 realclean distclean: parent-clean
361 # This is done this way rather than having `subdir_distclean' be a
362 # dependency of this target so that libc.a will be removed before the
363 # subdirectories are dealt with and so they won't try to remove object
364 # files from it when it's going to be removed anyway.
365 @
$(MAKE
) distclean-1 no_deps
=t distclean-1
=$@ avoid-generated
=yes \
366 sysdep-subdirs
="$(sysdep-subdirs)"
369 # Subroutine of distclean and realclean.
370 distclean-1
: subdir_
$(distclean-1
)
371 -rm -f
$(config-generated
)
372 -rm -f
$(addprefix $(objpfx
),config.status config.cache config.log
)
373 -rm -f
$(addprefix $(objpfx
),config.make config-name.h config.h
)
375 -rm -f
$(objpfx
)Makefile
377 -rm -f
$(sysdep-
$(distclean-1
))
379 # Make the TAGS file for Emacs users.
383 scripts
/list-sources.sh | sed
-n
-e
'/Makefile/p' \
384 $(foreach S
,[chsSyl
] cxx sh bash pl
,\
385 $(subst .
,\.
,-e
'/.$S\(.in\)*$$/p')) \
388 # Make the distribution tarfile.
389 .PHONY
: dist dist-prepare
391 generated
:= $(generated
) stubs.h
393 files-for-dist
:= README INSTALL configure ChangeLog NEWS
395 # Regenerate stuff, then error if these things are not committed yet.
396 dist-prepare
: $(files-for-dist
)
397 conf
=`find sysdeps -name configure`; \
399 git diff
--stat HEAD
-- $^
$$conf \
400 |
$(AWK
) '{ print; rc=1 } END { exit rc }'
403 git archive
--prefix=$*/ $* > $@.new
406 # Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
408 ifneq (,$(strip $(dist-version
)))
409 dist: $(foreach Z
,.bz2 .gz .xz
,$(dist-version
).
tar$Z)
413 @if v
=`git describe`; then \
414 echo Distribution version
$$v; \
415 $(MAKE
) dist dist-version
=$$v; \
421 INSTALL
: manual
/install-plain.texi manual
/macros.texi \
422 $(common-objpfx
)manual
/pkgvers.texi manual
/install.texi
423 makeinfo --no-validate
--plaintext
--no-number-sections \
424 -I
$(common-objpfx
)manual
$< -o
$@
-tmp
425 $(AWK
) 'NF == 0 { ++n; next } \
426 NF != 0 { while (n-- > 0) print ""; n = 0; print }' \
431 $(common-objpfx
)manual
/%: FORCE
432 $(MAKE
) $(PARALLELMFLAGS
) -C manual
$@
435 iconvdata
/% localedata
/% po
/%: FORCE
436 $(MAKE
) $(PARALLELMFLAGS
) -C
$(@D
) $(@F
)