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