]> sourceware.org Git - glibc.git/blame - Makefile
Rewrite local headers check to be more robust and informative.
[glibc.git] / Makefile
CommitLineData
7b57bfe5 1# Copyright (C) 1991-2002,2003,2004,2005,2006,2008,2009,2011
e85f1d6a 2# Free Software Foundation, Inc.
28f540f4
RM
3# This file is part of the GNU C Library.
4
5# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
28f540f4
RM
9
10# The GNU C Library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13# Lesser General Public License for more details.
28f540f4 14
41bdb6e2
AJ
15# You should have received a copy of the GNU Lesser General Public
16# License along with the GNU C Library; if not, write to the Free
17# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18# 02111-1307 USA.
28f540f4
RM
19
20#
21# Master Makefile for the GNU C library
22#
23ifneq (,)
24This makefile requires GNU Make.
25endif
26
aa802e96
UD
27include Makeconfig
28
28f540f4
RM
29
30# This is the default target; it makes everything except the tests.
31.PHONY: all
edf5b2d7 32all: lib others
28f540f4 33\f
1400de2e
RM
34ifneq ($(AUTOCONF),no)
35
4d06461a 36ifeq ($(with-cvs),yes)
1400de2e 37define autoconf-it-cvs
379bb425 38test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
28f540f4 39endef
4d06461a 40else
1400de2e
RM
41autoconf-it-cvs =
42endif
43
4d06461a
UD
44define autoconf-it
45@-rm -f $@.new
1400de2e 46$(AUTOCONF) $(ACFLAGS) $< > $@.new
7967983f 47chmod a-w$(patsubst %,$(comma)a+x,$(filter .,$(@D))) $@.new
4d06461a 48mv -f $@.new $@
1400de2e 49$(autoconf-it-cvs)
4d06461a 50endef
c8d32817 51
dbdb6189
RM
52configure: configure.in aclocal.m4; $(autoconf-it)
53%/configure: %/configure.in aclocal.m4; $(autoconf-it)
e0a3ed4f 54%/preconfigure: %/preconfigure.in aclocal.m4; $(autoconf-it)
28f540f4 55
1400de2e
RM
56endif # $(AUTOCONF) = no
57
58
59# We don't want to run anything here in parallel.
60.NOTPARALLEL:
61
28f540f4 62# These are the targets that are made by making them in each subdirectory.
edf5b2d7
UD
63+subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
64 subdir_clean subdir_distclean subdir_realclean \
c238ecf7 65 tests xtests subdir_lint.out \
7b57bfe5
UD
66 subdir_update-abi subdir_check-abi \
67 subdir_echo-headers \
57ba7bb4 68 subdir_install \
5d9e8991 69 subdir_objs subdir_stubs subdir_testclean \
57ba7bb4 70 $(addprefix install-, no-libc.a bin lib data headers others)
28f540f4 71\f
739d440d
UD
72headers := limits.h values.h features.h gnu-versions.h bits/libc-lock.h \
73 bits/xopen_lim.h gnu/libc-version.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:
b4a555d6 119 -test ! -x $(common-objpfx)elf/ldconfig || LC_ALL=C LANGUAGE=C \
03c0d6ef 120 $(common-objpfx)elf/ldconfig $(addprefix -r ,$(install_root)) \
5732c4df 121 $(slibdir) $(libdir)
cc3fa755
UD
122ifneq (no,$(PERL))
123ifeq (/usr,$(prefix))
124ifeq (,$(install_root))
5bc2f642 125 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.
137lib: $(common-objpfx)libc.so
7b57bfe5
UD
138
139lib: $(common-objpfx)linkobj/libc.so
140
5615eaf2
RM
141$(common-objpfx)linkobj/libc.so: $(elfobjdir)/soinit.os \
142 $(common-objpfx)linkobj/libc_pic.a \
143 $(elfobjdir)/sofini.os \
144 $(elfobjdir)/interp.os \
145 $(elfobjdir)/ld.so \
146 $(common-objpfx)shlib.lds
7b57bfe5
UD
147 $(build-shlib)
148
5615eaf2
RM
149$(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a \
150 $(common-objpfx)sunrpc/librpc_compat_pic.a
7b57bfe5
UD
151 $(..)./scripts/mkinstalldirs $(common-objpfx)linkobj
152 (cd $(common-objpfx)linkobj; \
153 $(AR) x ../libc_pic.a; \
154 rm $$($(AR) t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//'); \
155 $(AR) x ../sunrpc/librpc_compat_pic.a; \
156 $(AR) cr libc_pic.a *.os; \
157 rm *.os)
01a36ad3 158endif
9bfce4bf
RM
159
160
161# This is a handy script for running any dynamically linked program against
162# the current libc build for testing.
163$(common-objpfx)testrun.sh: $(common-objpfx)config.make \
164 $(..)Makeconfig $(..)Makefile
165 (echo '#!/bin/sh'; \
166 echo "GCONV_PATH='$(common-objpfx)iconvdata' \\"; \
167 echo 'exec $(run-program-prefix) $${1+"$$@"}'; \
168 ) > $@T
169 chmod a+x $@T
170 mv -f $@T $@
171postclean-generated += testrun.sh
172
173others: $(common-objpfx)testrun.sh
28f540f4 174\f
97a47867
UD
175# Makerules creates a file `stubs' in each subdirectory, which
176# contains `#define __stub_FUNCTION' for each function defined in that
177# directory which is a stub.
6bc31da0 178# Here we paste all of these together into <gnu/stubs.h>.
28f540f4 179
97a47867 180subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
28f540f4 181
3e1e123d
RM
182ifeq ($(biarch),no)
183installed-stubs = $(inst_includedir)/gnu/stubs.h
184else
185installed-stubs = $(inst_includedir)/gnu/stubs-$(biarch).h
186
187$(inst_includedir)/gnu/stubs.h: include/stubs-biarch.h $(+force)
f0cf0902 188 $(make-target-directory)
3e1e123d
RM
189 $(INSTALL_DATA) $< $@
190
191install-others-nosubdir: $(installed-stubs)
192endif
193
194
28f540f4
RM
195# Since stubs.h is never needed when building the library, we simplify the
196# hairy installation process by producing it in place only as the last part
b9b49b44
UD
197# of the top-level `make install'. It depends on subdir_install, which
198# iterates over all the subdirs; subdir_install in each subdir depends on
199# the subdir's stubs file. Having more direct dependencies would result in
200# extra iterations over the list for subdirs and many recursive makes.
3e1e123d 201$(installed-stubs): include/stubs-prologue.h subdir_install
5107cf1d 202 $(make-target-directory)
28f540f4 203 @rm -f $(objpfx)stubs.h
d62507dd 204 (sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h
13a0be88 205 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
ba1ffaa1 206 then echo 'stubs.h unchanged'; \
d36e7692 207 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
28f540f4
RM
208 rm -f $(objpfx)stubs.h
209\f
210# This makes the Info or DVI file of the documentation from the Texinfo source.
fef0b717
UD
211.PHONY: info dvi pdf html
212info dvi pdf html:
c0e45674 213 $(MAKE) $(PARALLELMFLAGS) -C manual $@
28f540f4
RM
214\f
215# This makes all the subdirectory targets.
216
217# For each target, make it depend on DIR/target for each subdirectory DIR.
218$(+subdir_targets): %: $(addsuffix /%,$(subdirs))
219
220# Compute a list of all those targets.
221all-subdirs-targets := $(foreach dir,$(subdirs),\
222 $(addprefix $(dir)/,$(+subdir_targets)))
223
224# The action for each of those is to cd into the directory and make the
225# target there.
226$(all-subdirs-targets):
e0a3ed4f
RM
227 $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F)
228
229define subdir-target-args
230subdir=$(@D)$(if $($(@D)-srcdir),\
231-C $($(@D)-srcdir) ..=`pwd`/,\
232-C $(@D) ..=../)
233endef
28f540f4
RM
234
235.PHONY: $(+subdir_targets) $(all-subdirs-targets)
236\f
237# Targets to clean things up to various degrees.
238
3c5edd4d
UD
239.PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
240 tests-clean
28f540f4
RM
241
242# Subroutines of all cleaning targets.
243parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
4ddde9ee 244 -rm -f $(foreach o,$(object-suffixes-for-libc),\
60092701
RM
245 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
246 $(addprefix $(objpfx),$(install-lib))
28f540f4 247parent-clean: parent-mostlyclean common-clean
da2d1bc5
UD
248
249postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
4ae73ca0 250 $(addprefix $(objpfx),sysd-dirs sysd-rules) \
4fcddf8e 251 $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
28f540f4
RM
252
253clean: parent-clean
254# This is done this way rather than having `subdir_clean' be a
255# dependency of this target so that libc.a will be removed before the
256# subdirectories are dealt with and so they won't try to remove object
257# files from it when it's going to be removed anyway.
258 @$(MAKE) subdir_clean no_deps=t
b5c69d99 259 -rm -f $(postclean)
28f540f4
RM
260mostlyclean: parent-mostlyclean
261 @$(MAKE) subdir_mostlyclean no_deps=t
da2d1bc5 262 -rm -f $(postclean)
28f540f4 263
3c5edd4d
UD
264tests-clean:
265 @$(MAKE) subdir_testclean no_deps=t
266
16feadf2 267tests: $(objpfx)c++-types-check.out $(objpfx)check-local-headers.out
2750c39c 268ifneq ($(CXX),no)
ad243052 269check-data := $(firstword $(wildcard \
7b57bfe5
UD
270 $(foreach D,$(add-ons) scripts,\
271 $(patsubst %,$D/data/c++-types-%.data,\
272 $(abi-name) \
273 $(addsuffix -$(config-os),\
274 $(config-machine) \
e85f1d6a 275 $(base-machine))))))
ad243052 276ifneq (,$(check-data))
5ef5cbb6 277$(objpfx)c++-types-check.out: $(check-data) scripts/check-c++-types.sh
f7ffeb91 278 scripts/check-c++-types.sh $< $(CXX) $(filter-out -std=gnu99 -Wstrict-prototypes,$(CFLAGS)) $(CPPFLAGS) > $@
806e4a4a
UD
279else
280$(objpfx)c++-types-check.out:
281 @echo 'WARNING C++ tests not run; create a c++-types-XXX file'
282 @echo "not run" > $@
283endif
2750c39c 284endif
806e4a4a 285
16feadf2 286$(objpfx)check-local-headers.out: scripts/check-local-headers.sh
ea5ee9f7
RM
287 AWK='$(AWK)' scripts/check-local-headers.sh \
288 "$(includedir)" "$(objpfx)" > $@
16feadf2 289
5ef5cbb6
UD
290ifneq ($(PERL),no)
291installed-headers = argp/argp.h assert/assert.h catgets/nl_types.h \
292 crypt/crypt.h ctype/ctype.h debug/execinfo.h \
293 dirent/dirent.h dlfcn/dlfcn.h elf/elf.h elf/link.h \
294 gmon/sys/gmon.h gmon/sys/gmon_out.h gmon/sys/profil.h \
829fea46 295 grp/grp.h gshadow/gshadow.h iconv/iconv.h iconv/gconv.h \
5ef5cbb6
UD
296 $(wildcard inet/netinet/*.h) \
297 $(wildcard inet/arpa/*.h inet/protocols/*.h) \
298 inet/aliases.h inet/ifaddrs.h inet/netinet/ip6.h \
299 inet/netinet/icmp6.h intl/libintl.h io/sys/stat.h \
300 io/sys/statfs.h io/sys/vfs.h io/sys/statvfs.h \
301 io/fcntl.h io/sys/fcntl.h io/poll.h io/sys/poll.h \
302 io/utime.h io/ftw.h io/fts.h io/sys/sendfile.h \
303 libio/stdio.h libio/libio.h locale/locale.h \
304 locale/langinfo.h locale/xlocale.h login/utmp.h \
305 login/lastlog.h login/pty.h malloc/malloc.h \
306 malloc/obstack.h malloc/mcheck.h math/math.h \
307 math/complex.h math/fenv.h math/tgmath.h misc/sys/uio.h \
308 $(wildcard nis/rpcsvc/*.h) nptl_db/thread_db.h \
309 nptl/sysdeps/pthread/pthread.h nptl/semaphore.h \
310 nss/nss.h posix/sys/utsname.h posix/sys/times.h \
311 posix/sys/wait.h posix/sys/types.h posix/unistd.h \
312 posix/glob.h posix/regex.h posix/wordexp.h posix/fnmatch.h\
313 posix/getopt.h posix/tar.h posix/sys/unistd.h \
314 posix/sched.h posix/re_comp.h posix/wait.h \
315 posix/cpio.h posix/spawn.h pwd/pwd.h resolv/resolv.h \
316 resolv/netdb.h $(wildcard resolv/arpa/*.h) \
317 resource/sys/resource.h resource/sys/vlimit.h \
318 resource/sys/vtimes.h resource/ulimit.h rt/aio.h \
319 rt/mqueue.h setjmp/setjmp.h shadow/shadow.h \
320 signal/signal.h signal/sys/signal.h socket/sys/socket.h \
321 socket/sys/un.h stdio-common/printf.h \
322 stdio-common/stdio_ext.h stdlib/stdlib.h stdlib/alloca.h \
323 stdlib/monetary.h stdlib/fmtmsg.h stdlib/ucontext.h \
324 sysdeps/generic/inttypes.h sysdeps/generic/stdint.h \
325 stdlib/errno.h stdlib/sys/errno.h string/string.h \
326 string/strings.h string/memory.h string/endian.h \
327 string/argz.h string/envz.h string/byteswap.h \
328 $(wildcard sunrpc/rpc/*.h sunrpc/rpcsvc/*.h) \
329 sysvipc/sys/ipc.h sysvipc/sys/msg.h sysvipc/sys/sem.h \
330 sysvipc/sys/shm.h termios/termios.h \
331 termios/sys/termios.h termios/sys/ttychars.h time/time.h \
332 time/sys/time.h time/sys/timeb.h wcsmbs/wchar.h \
333 wctype/wctype.h
334
335tests: $(objpfx)begin-end-check.out
336$(objpfx)begin-end-check.out: scripts/begin-end-check.pl
337 $(PERL) scripts/begin-end-check.pl $(installed-headers) > $@
338endif
339
28f540f4
RM
340# The realclean target is just like distclean for the parent, but we want
341# the subdirs to know the difference in case they care.
342realclean distclean: parent-clean
343# This is done this way rather than having `subdir_distclean' be a
344# dependency of this target so that libc.a will be removed before the
345# subdirectories are dealt with and so they won't try to remove object
346# files from it when it's going to be removed anyway.
da2d1bc5
UD
347 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
348 sysdep-subdirs="$(sysdep-subdirs)"
349 -rm -f $(postclean)
28f540f4
RM
350
351# Subroutine of distclean and realclean.
352distclean-1: subdir_$(distclean-1)
353 -rm -f $(config-generated)
60092701
RM
354 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
355 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
28f540f4
RM
356ifdef objdir
357 -rm -f $(objpfx)Makefile
358endif
359 -rm -f $(sysdep-$(distclean-1))
360\f
9de06f3c
RM
361# Make the TAGS file for Emacs users.
362
363.PHONY: TAGS
364TAGS:
77c84aeb 365 scripts/list-sources.sh | sed -n -e '/Makefile/p' \
9de06f3c 366 $(foreach S,[chsSyl] cxx sh bash pl,\
77c84aeb 367 $(subst .,\.,-e '/.$S\(.in\)*$$/p')) \
9de06f3c
RM
368 | $(ETAGS) -o $@ -
369\f
28f540f4 370# Make the distribution tarfile.
6cfe8609 371.PHONY: dist dist-prepare
28f540f4 372
c7562c74 373generated := $(generated) stubs.h
28f540f4 374
6cfe8609
RM
375files-for-dist := README FAQ INSTALL NOTES configure ChangeLog NEWS
376
377# Regenerate stuff, then error if these things are not committed yet.
378dist-prepare: $(files-for-dist)
379 conf=`find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \
380 -name configure`; \
381 $(MAKE) $$conf && \
382 git diff --stat HEAD -- $^ $$conf \
383 | $(AWK) '{ print; rc=1 } END { exit rc }'
384
385%.tar: FORCE
386 git archive --prefix=$*/ $* > $@.new
387 mv -f $@.new $@
62780824 388
7c0cf356 389# Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
7c0cf356 390
6cfe8609
RM
391ifneq (,$(strip $(dist-version)))
392dist: $(foreach Z,.bz2 .gz .xz,$(dist-version).tar$Z)
62780824 393 md5sum $^
6cfe8609
RM
394else
395dist: dist-prepare
396 @if v=`git describe`; then \
397 echo Distribution version $$v; \
398 $(MAKE) dist dist-version=$$v; \
399 else \
400 false; \
401 fi
402endif
62780824 403
28f540f4
RM
404define format-me
405@rm -f $@
c9dc3f62 406makeinfo --no-validate --plaintext --no-number-sections $< -o $@
28f540f4
RM
407-chmod a-w $@
408endef
a35cb74d 409INSTALL: manual/install.texi; $(format-me)
28f540f4 410NOTES: manual/creature.texi; $(format-me)
714a562f 411manual/dir-add.texi manual/dir-add.info: FORCE
fe7bdd63 412 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
5bc2f642 413FAQ: scripts/gen-FAQ.pl FAQ.in
61952351 414 $(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
a35cb74d
UD
415ifeq ($(with-cvs),yes)
416 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: $(PERL) $^' $@
417endif
f671aeab 418FORCE:
6a441471 419
9de06f3c 420iconvdata/% localedata/% po/% manual/%: FORCE
f4017d20
UD
421 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
422
a53bad16
UD
423# glibc 2.0 contains some header files which aren't used with glibc 2.1
424# anymore.
425# These rules should remove those headers
426ifeq (,$(install_root))
427ifeq ($(old-glibc-headers),yes)
428install: remove-old-headers
429endif
430endif
431
7b57bfe5
UD
432headers2_0 := __math.h bytesex.h confname.h direntry.h elfclass.h \
433 errnos.h fcntlbits.h huge_val.h ioctl-types.h \
434 ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h \
435 mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h \
436 posix2_lim.h posix_opt.h resourcebits.h schedbits.h \
437 selectbits.h semaphorebits.h sigaction.h sigcontext.h \
438 signum.h sigset.h sockaddrcom.h socketbits.h stab.def \
439 statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h \
440 syscall-list.h termbits.h timebits.h ustatbits.h \
441 utmpbits.h utsnamelen.h waitflags.h waitstatus.h \
442 xopen_lim.h gnu/types.h sys/ipc_buf.h \
443 sys/kernel_termios.h sys/msq_buf.h sys/sem_buf.h \
a7ab2023 444 sys/shm_buf.h sys/socketcall.h sigstack.h
a53bad16 445
b195f6bc 446.PHONY: remove-old-headers
a53bad16
UD
447remove-old-headers:
448 rm -f $(addprefix $(inst_includedir)/, $(headers2_0))
This page took 0.293452 seconds and 5 git commands to generate.