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