]> git.ipfire.org Git - thirdparty/glibc.git/blame - Makefile
Fix trailing space.
[thirdparty/glibc.git] / Makefile
CommitLineData
b168057a 1# Copyright (C) 1991-2015 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
PE
15# License along with the GNU C Library; if not, see
16# <http://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.
29.PHONY: all
edf5b2d7 30all: lib others
28f540f4 31\f
1400de2e
RM
32ifneq ($(AUTOCONF),no)
33
4d06461a
UD
34define autoconf-it
35@-rm -f $@.new
1400de2e 36$(AUTOCONF) $(ACFLAGS) $< > $@.new
7967983f 37chmod a-w$(patsubst %,$(comma)a+x,$(filter .,$(@D))) $@.new
4d06461a
UD
38mv -f $@.new $@
39endef
c8d32817 40
cb8a6dbd
MF
41configure: configure.ac aclocal.m4; $(autoconf-it)
42%/configure: %/configure.ac aclocal.m4; $(autoconf-it)
43%/preconfigure: %/preconfigure.ac aclocal.m4; $(autoconf-it)
28f540f4 44
1400de2e
RM
45endif # $(AUTOCONF) = no
46
47
48# We don't want to run anything here in parallel.
49.NOTPARALLEL:
50
28f540f4 51# These are the targets that are made by making them in each subdirectory.
edf5b2d7
UD
52+subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
53 subdir_clean subdir_distclean subdir_realclean \
dd7b064c 54 tests xtests \
7b57bfe5
UD
55 subdir_update-abi subdir_check-abi \
56 subdir_echo-headers \
57ba7bb4 57 subdir_install \
5d9e8991 58 subdir_objs subdir_stubs subdir_testclean \
57ba7bb4 59 $(addprefix install-, no-libc.a bin lib data headers others)
28f540f4 60\f
739d440d 61headers := limits.h values.h features.h gnu-versions.h bits/libc-lock.h \
ff3b3d82 62 bits/xopen_lim.h gnu/libc-version.h stdc-predef.h
28f540f4
RM
63
64echo-headers: subdir_echo-headers
65
762a2918
UD
66# The headers are in the include directory.
67subdir-dirs = include
68vpath %.h $(subdir-dirs)
69
28f540f4 70# What to install.
8d57beea 71install-others = $(inst_includedir)/gnu/stubs.h
fe54a69c 72install-bin-script =
56552e42 73
a18f587d 74ifeq (yes,$(build-shared))
6736e93b 75headers += gnu/lib-names.h
a18f587d 76endif
28f540f4 77
28f540f4
RM
78include Makerules
79
737547be 80ifeq ($(build-programs),yes)
6c3ebebd 81others: $(addprefix $(objpfx),$(install-bin-script))
737547be
UD
82endif
83
28f540f4
RM
84# Install from subdirectories too.
85install: subdir_install
8d57beea 86
6736e93b
UD
87# Explicit dependency so that `make install-headers' works
88install-headers: install-headers-nosubdir
89
5148d49f
UD
90# Make sure that the dynamic linker is installed before libc.
91$(inst_slibdir)/libc-$(version).so: elf/ldso_install
92
93.PHONY: elf/ldso_install
94elf/ldso_install:
95 $(MAKE) -C $(@D) $(@F)
96
b43b13ac 97# Create links for shared libraries using the `ldconfig' program if possible.
7cc27f44 98# Ignore the error if we cannot update /etc/ld.so.cache.
1ef32c3d
UD
99ifeq (no,$(cross-compiling))
100ifeq (yes,$(build-shared))
409dfcea
UD
101install: install-symbolic-link
102.PHONY: install-symbolic-link
103install-symbolic-link: subdir_install
9d141cae 104 $(symbolic-link-prog) $(symbolic-link-list)
7ef90c15 105 rm -f $(symbolic-link-list)
9d141cae 106
8d57beea 107install:
686554bf 108 -test ! -x $(elf-objpfx)ldconfig || LC_ALL=C \
4134b50d
JM
109 $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \
110 $(slibdir) $(libdir)
cc3fa755
UD
111ifneq (no,$(PERL))
112ifeq (/usr,$(prefix))
113ifeq (,$(install_root))
d22e28b0 114 LD_SO=$(ld.so-version) CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)
cc3fa755
UD
115endif
116endif
117endif
1ef32c3d
UD
118endif
119endif
28f540f4 120
01a36ad3
RM
121# Build subdirectory lib objects.
122lib-noranlib: subdir_lib
28f540f4 123
01a36ad3
RM
124ifeq (yes,$(build-shared))
125# Build the shared object from the PIC object library.
5f855e35 126lib: $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so
bd81123a 127endif # $(build-shared)
9bfce4bf
RM
128
129
130# This is a handy script for running any dynamically linked program against
131# the current libc build for testing.
132$(common-objpfx)testrun.sh: $(common-objpfx)config.make \
133 $(..)Makeconfig $(..)Makefile
134 (echo '#!/bin/sh'; \
84f9ea0f
RM
135 echo 'builddir=`dirname "$$0"`'; \
136 echo 'GCONV_PATH="$${builddir}/iconvdata" \'; \
137 echo 'exec $(subst $(common-objdir),"$${builddir}",\
740b3dbe 138 $(test-program-prefix)) $${1+"$$@"}'; \
9bfce4bf
RM
139 ) > $@T
140 chmod a+x $@T
141 mv -f $@T $@
142postclean-generated += testrun.sh
143
144others: $(common-objpfx)testrun.sh
28f540f4 145\f
97a47867
UD
146# Makerules creates a file `stubs' in each subdirectory, which
147# contains `#define __stub_FUNCTION' for each function defined in that
148# directory which is a stub.
6bc31da0 149# Here we paste all of these together into <gnu/stubs.h>.
28f540f4 150
97a47867 151subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
28f540f4 152
0ab0291b 153ifndef abi-variants
3e1e123d
RM
154installed-stubs = $(inst_includedir)/gnu/stubs.h
155else
0ab0291b 156installed-stubs = $(inst_includedir)/gnu/stubs-$(default-abi).h
3e1e123d 157
691bc9c1 158$(inst_includedir)/gnu/stubs.h: $(+force)
f0cf0902 159 $(make-target-directory)
0ab0291b
L
160 { \
161 echo '/* This file is automatically generated.';\
162 echo " This file selects the right generated file of \`__stub_FUNCTION' macros";\
163 echo ' based on the architecture being compiled for. */'; \
164 echo ''; \
165 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
166 echo ''; \
167 $(foreach v,$(abi-variants),\
168 $(if $(abi-$(v)-condition),\
169 echo '#if $(abi-$(v)-condition)'; \
170 echo '# include <gnu/stubs-$(v).h>'); \
171 $(if $(abi-$(v)-condition),echo '#endif';) \
172 rm -f $(@:.d=.h).new$(v); \
173 ) \
174 } > $(@:.d=.h).new
175 mv -f $(@:.d=.h).new $(@:.d=.h)
3e1e123d
RM
176
177install-others-nosubdir: $(installed-stubs)
178endif
179
180
28f540f4
RM
181# Since stubs.h is never needed when building the library, we simplify the
182# hairy installation process by producing it in place only as the last part
b9b49b44
UD
183# of the top-level `make install'. It depends on subdir_install, which
184# iterates over all the subdirs; subdir_install in each subdir depends on
185# the subdir's stubs file. Having more direct dependencies would result in
186# extra iterations over the list for subdirs and many recursive makes.
3e1e123d 187$(installed-stubs): include/stubs-prologue.h subdir_install
5107cf1d 188 $(make-target-directory)
28f540f4 189 @rm -f $(objpfx)stubs.h
d62507dd 190 (sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h
13a0be88 191 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
ba1ffaa1 192 then echo 'stubs.h unchanged'; \
d36e7692 193 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
28f540f4
RM
194 rm -f $(objpfx)stubs.h
195\f
196# This makes the Info or DVI file of the documentation from the Texinfo source.
fef0b717
UD
197.PHONY: info dvi pdf html
198info dvi pdf html:
c0e45674 199 $(MAKE) $(PARALLELMFLAGS) -C manual $@
28f540f4
RM
200\f
201# This makes all the subdirectory targets.
202
203# For each target, make it depend on DIR/target for each subdirectory DIR.
204$(+subdir_targets): %: $(addsuffix /%,$(subdirs))
205
206# Compute a list of all those targets.
207all-subdirs-targets := $(foreach dir,$(subdirs),\
208 $(addprefix $(dir)/,$(+subdir_targets)))
209
210# The action for each of those is to cd into the directory and make the
211# target there.
212$(all-subdirs-targets):
e0a3ed4f
RM
213 $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F)
214
215define subdir-target-args
216subdir=$(@D)$(if $($(@D)-srcdir),\
217-C $($(@D)-srcdir) ..=`pwd`/,\
218-C $(@D) ..=../)
219endef
28f540f4
RM
220
221.PHONY: $(+subdir_targets) $(all-subdirs-targets)
222\f
223# Targets to clean things up to various degrees.
224
3c5edd4d
UD
225.PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
226 tests-clean
28f540f4
RM
227
228# Subroutines of all cleaning targets.
229parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
4ddde9ee 230 -rm -f $(foreach o,$(object-suffixes-for-libc),\
60092701
RM
231 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
232 $(addprefix $(objpfx),$(install-lib))
28f540f4 233parent-clean: parent-mostlyclean common-clean
da2d1bc5
UD
234
235postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
4ae73ca0 236 $(addprefix $(objpfx),sysd-dirs sysd-rules) \
4fcddf8e 237 $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
28f540f4
RM
238
239clean: parent-clean
240# This is done this way rather than having `subdir_clean' be a
241# dependency of this target so that libc.a will be removed before the
242# subdirectories are dealt with and so they won't try to remove object
243# files from it when it's going to be removed anyway.
244 @$(MAKE) subdir_clean no_deps=t
b5c69d99 245 -rm -f $(postclean)
28f540f4
RM
246mostlyclean: parent-mostlyclean
247 @$(MAKE) subdir_mostlyclean no_deps=t
da2d1bc5 248 -rm -f $(postclean)
28f540f4 249
3c5edd4d
UD
250tests-clean:
251 @$(MAKE) subdir_testclean no_deps=t
252
f214606a 253tests-special += $(objpfx)c++-types-check.out $(objpfx)check-local-headers.out
2750c39c 254ifneq ($(CXX),no)
bd29910a
JM
255
256vpath c++-types.data $(+sysdep_dirs)
257
258$(objpfx)c++-types-check.out: c++-types.data scripts/check-c++-types.sh
f0881698
JM
259 scripts/check-c++-types.sh $< $(CXX) $(filter-out -std=gnu99 -Wstrict-prototypes,$(CFLAGS)) $(CPPFLAGS) > $@; \
260 $(evaluate-test)
2750c39c 261endif
806e4a4a 262
16feadf2 263$(objpfx)check-local-headers.out: scripts/check-local-headers.sh
ea5ee9f7 264 AWK='$(AWK)' scripts/check-local-headers.sh \
f0881698
JM
265 "$(includedir)" "$(objpfx)" > $@; \
266 $(evaluate-test)
16feadf2 267
5ef5cbb6
UD
268ifneq ($(PERL),no)
269installed-headers = argp/argp.h assert/assert.h catgets/nl_types.h \
270 crypt/crypt.h ctype/ctype.h debug/execinfo.h \
271 dirent/dirent.h dlfcn/dlfcn.h elf/elf.h elf/link.h \
272 gmon/sys/gmon.h gmon/sys/gmon_out.h gmon/sys/profil.h \
829fea46 273 grp/grp.h gshadow/gshadow.h iconv/iconv.h iconv/gconv.h \
5ef5cbb6
UD
274 $(wildcard inet/netinet/*.h) \
275 $(wildcard inet/arpa/*.h inet/protocols/*.h) \
276 inet/aliases.h inet/ifaddrs.h inet/netinet/ip6.h \
277 inet/netinet/icmp6.h intl/libintl.h io/sys/stat.h \
278 io/sys/statfs.h io/sys/vfs.h io/sys/statvfs.h \
279 io/fcntl.h io/sys/fcntl.h io/poll.h io/sys/poll.h \
280 io/utime.h io/ftw.h io/fts.h io/sys/sendfile.h \
281 libio/stdio.h libio/libio.h locale/locale.h \
282 locale/langinfo.h locale/xlocale.h login/utmp.h \
283 login/lastlog.h login/pty.h malloc/malloc.h \
284 malloc/obstack.h malloc/mcheck.h math/math.h \
285 math/complex.h math/fenv.h math/tgmath.h misc/sys/uio.h \
286 $(wildcard nis/rpcsvc/*.h) nptl_db/thread_db.h \
fc00cf7b 287 sysdeps/nptl/pthread.h sysdeps/pthread/semaphore.h \
5ef5cbb6
UD
288 nss/nss.h posix/sys/utsname.h posix/sys/times.h \
289 posix/sys/wait.h posix/sys/types.h posix/unistd.h \
290 posix/glob.h posix/regex.h posix/wordexp.h posix/fnmatch.h\
291 posix/getopt.h posix/tar.h posix/sys/unistd.h \
292 posix/sched.h posix/re_comp.h posix/wait.h \
293 posix/cpio.h posix/spawn.h pwd/pwd.h resolv/resolv.h \
294 resolv/netdb.h $(wildcard resolv/arpa/*.h) \
295 resource/sys/resource.h resource/sys/vlimit.h \
296 resource/sys/vtimes.h resource/ulimit.h rt/aio.h \
297 rt/mqueue.h setjmp/setjmp.h shadow/shadow.h \
298 signal/signal.h signal/sys/signal.h socket/sys/socket.h \
299 socket/sys/un.h stdio-common/printf.h \
300 stdio-common/stdio_ext.h stdlib/stdlib.h stdlib/alloca.h \
301 stdlib/monetary.h stdlib/fmtmsg.h stdlib/ucontext.h \
302 sysdeps/generic/inttypes.h sysdeps/generic/stdint.h \
303 stdlib/errno.h stdlib/sys/errno.h string/string.h \
304 string/strings.h string/memory.h string/endian.h \
305 string/argz.h string/envz.h string/byteswap.h \
306 $(wildcard sunrpc/rpc/*.h sunrpc/rpcsvc/*.h) \
307 sysvipc/sys/ipc.h sysvipc/sys/msg.h sysvipc/sys/sem.h \
308 sysvipc/sys/shm.h termios/termios.h \
309 termios/sys/termios.h termios/sys/ttychars.h time/time.h \
310 time/sys/time.h time/sys/timeb.h wcsmbs/wchar.h \
311 wctype/wctype.h
312
f214606a 313tests-special += $(objpfx)begin-end-check.out
5ef5cbb6 314$(objpfx)begin-end-check.out: scripts/begin-end-check.pl
f0881698
JM
315 $(PERL) scripts/begin-end-check.pl $(installed-headers) > $@; \
316 $(evaluate-test)
5ef5cbb6
UD
317endif
318
44a6213c
RM
319define summarize-tests
320@egrep -v '^(PASS|XFAIL):' $(objpfx)$1 || true
321@echo "Summary of test results$2:"
322@sed 's/:.*//' < $(objpfx)$1 | sort | uniq -c
99db95db 323@! egrep -q -v '^(X?PASS|XFAIL|UNSUPPORTED):' $(objpfx)$1
44a6213c
RM
324endef
325
265d52ab 326tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
f214606a 327tests: $(tests-special)
265d52ab
JM
328 $(..)scripts/merge-test-results.sh -s $(objpfx) "" \
329 $(sort $(tests-special-notdir:.out=)) \
330 > $(objpfx)subdir-tests.sum
331 $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-tests.sum \
332 $(sort $(subdirs) .) \
333 > $(objpfx)tests.sum
44a6213c 334 $(call summarize-tests,tests.sum)
265d52ab
JM
335xtests:
336 $(..)scripts/merge-test-results.sh -t $(objpfx) subdir-xtests.sum \
337 $(sort $(subdirs)) \
338 > $(objpfx)xtests.sum
44a6213c 339 $(call summarize-tests,xtests.sum, for extra tests)
f214606a 340
28f540f4
RM
341# The realclean target is just like distclean for the parent, but we want
342# the subdirs to know the difference in case they care.
343realclean distclean: parent-clean
344# This is done this way rather than having `subdir_distclean' be a
345# dependency of this target so that libc.a will be removed before the
346# subdirectories are dealt with and so they won't try to remove object
347# files from it when it's going to be removed anyway.
da2d1bc5
UD
348 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
349 sysdep-subdirs="$(sysdep-subdirs)"
350 -rm -f $(postclean)
28f540f4
RM
351
352# Subroutine of distclean and realclean.
353distclean-1: subdir_$(distclean-1)
354 -rm -f $(config-generated)
60092701
RM
355 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
356 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
28f540f4
RM
357ifdef objdir
358 -rm -f $(objpfx)Makefile
359endif
360 -rm -f $(sysdep-$(distclean-1))
361\f
9de06f3c
RM
362# Make the TAGS file for Emacs users.
363
364.PHONY: TAGS
365TAGS:
77c84aeb 366 scripts/list-sources.sh | sed -n -e '/Makefile/p' \
9de06f3c 367 $(foreach S,[chsSyl] cxx sh bash pl,\
77c84aeb 368 $(subst .,\.,-e '/.$S\(.in\)*$$/p')) \
9de06f3c
RM
369 | $(ETAGS) -o $@ -
370\f
28f540f4 371# Make the distribution tarfile.
6cfe8609 372.PHONY: dist dist-prepare
28f540f4 373
c7562c74 374generated := $(generated) stubs.h
28f540f4 375
7ac30cc5 376files-for-dist := README INSTALL configure ChangeLog NEWS
6cfe8609
RM
377
378# Regenerate stuff, then error if these things are not committed yet.
379dist-prepare: $(files-for-dist)
380 conf=`find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \
381 -name configure`; \
382 $(MAKE) $$conf && \
383 git diff --stat HEAD -- $^ $$conf \
384 | $(AWK) '{ print; rc=1 } END { exit rc }'
385
386%.tar: FORCE
387 git archive --prefix=$*/ $* > $@.new
388 mv -f $@.new $@
62780824 389
7c0cf356 390# Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
7c0cf356 391
6cfe8609
RM
392ifneq (,$(strip $(dist-version)))
393dist: $(foreach Z,.bz2 .gz .xz,$(dist-version).tar$Z)
62780824 394 md5sum $^
6cfe8609
RM
395else
396dist: dist-prepare
397 @if v=`git describe`; then \
398 echo Distribution version $$v; \
399 $(MAKE) dist dist-version=$$v; \
400 else \
401 false; \
402 fi
403endif
62780824 404
d136c6dc
SP
405INSTALL: manual/install-plain.texi manual/macros.texi \
406 $(common-objpfx)manual/pkgvers.texi manual/install.texi
4e87147f 407 makeinfo --no-validate --plaintext --no-number-sections \
b31469d0
JM
408 -I$(common-objpfx)manual $< -o $@-tmp
409 $(AWK) 'NF == 0 { ++n; next } \
410 NF != 0 { while (n-- > 0) print ""; n = 0; print }' \
411 < $@-tmp > $@-tmp2
412 rm -f $@-tmp
413 -chmod a-w $@-tmp2
414 mv -f $@-tmp2 $@
8b748aed
JM
415$(common-objpfx)manual/%: FORCE
416 $(MAKE) $(PARALLELMFLAGS) -C manual $@
f671aeab 417FORCE:
6a441471 418
8b748aed 419iconvdata/% localedata/% po/%: FORCE
f4017d20
UD
420 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
421
a53bad16
UD
422# glibc 2.0 contains some header files which aren't used with glibc 2.1
423# anymore.
424# These rules should remove those headers
425ifeq (,$(install_root))
426ifeq ($(old-glibc-headers),yes)
427install: remove-old-headers
428endif
429endif
430
7b57bfe5
UD
431headers2_0 := __math.h bytesex.h confname.h direntry.h elfclass.h \
432 errnos.h fcntlbits.h huge_val.h ioctl-types.h \
433 ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h \
434 mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h \
435 posix2_lim.h posix_opt.h resourcebits.h schedbits.h \
436 selectbits.h semaphorebits.h sigaction.h sigcontext.h \
437 signum.h sigset.h sockaddrcom.h socketbits.h stab.def \
438 statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h \
439 syscall-list.h termbits.h timebits.h ustatbits.h \
440 utmpbits.h utsnamelen.h waitflags.h waitstatus.h \
441 xopen_lim.h gnu/types.h sys/ipc_buf.h \
442 sys/kernel_termios.h sys/msq_buf.h sys/sem_buf.h \
a7ab2023 443 sys/shm_buf.h sys/socketcall.h sigstack.h
a53bad16 444
b195f6bc 445.PHONY: remove-old-headers
a53bad16
UD
446remove-old-headers:
447 rm -f $(addprefix $(inst_includedir)/, $(headers2_0))