1 # Copyright (C) 1991-2013 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.in aclocal.m4
; $(autoconf-it
)
42 %/configure
: %/configure.in aclocal.m4
; $(autoconf-it
)
43 %/preconfigure
: %/preconfigure.in 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 \
54 tests xtests subdir_lint.out \
55 subdir_update-abi subdir_check-abi \
58 subdir_objs subdir_stubs subdir_testclean \
59 $(addprefix install-
, no-libc.a bin lib data headers others
)
61 headers
:= limits.h values.h features.h gnu-versions.h bits
/libc-lock.h \
62 bits
/xopen_lim.h gnu
/libc-version.h stdc-predef.h
64 echo-headers
: subdir_echo-headers
66 # The headers are in the include directory.
68 vpath
%.h
$(subdir-dirs
)
71 install-others
= $(inst_includedir
)/gnu
/stubs.h
74 ifeq (yes
,$(build-shared
))
75 headers
+= gnu
/lib-names.h
80 ifeq ($(build-programs
),yes
)
81 others
: $(addprefix $(objpfx
),$(install-bin-script
))
84 # Install from subdirectories too.
85 install: subdir_install
87 # Explicit dependency so that `make install-headers' works
88 install-headers
: install-headers-nosubdir
90 # Make sure that the dynamic linker is installed before libc.
91 $(inst_slibdir
)/libc-
$(version
).so
: elf
/ldso_install
93 .PHONY
: elf
/ldso_install
95 $(MAKE
) -C
$(@D
) $(@F
)
97 # Create links for shared libraries using the `ldconfig' program if possible.
98 # Ignore the error if we cannot update /etc/ld.so.cache.
99 ifeq (no
,$(cross-compiling
))
100 ifeq (yes
,$(build-shared
))
101 install: install-symbolic-link
102 .PHONY
: install-symbolic-link
103 install-symbolic-link
: subdir_install
104 $(symbolic-link-prog
) $(symbolic-link-list
)
105 rm -f
$(symbolic-link-list
)
108 -test ! -x
$(common-objpfx
)elf
/ldconfig || LC_ALL
=C LANGUAGE
=C \
109 $(common-objpfx
)elf
/ldconfig
$(addprefix -r
,$(install_root
)) \
112 ifeq (/usr
,$(prefix))
113 ifeq (,$(install_root
))
114 LD_SO
=$(ld.so-version
) CC
="$(CC)" $(PERL
) scripts
/test-installation.pl
$(common-objpfx
)
121 # Build subdirectory lib objects.
122 lib-noranlib
: subdir_lib
124 ifeq (yes
,$(build-shared
))
125 # Build the shared object from the PIC object library.
126 lib
: $(common-objpfx
)libc.so
128 lib
: $(common-objpfx
)linkobj
/libc.so
130 # Do not filter ld.so out of libc.so link.
131 $(common-objpfx
)linkobj
/libc.so
: link-libc-deps
= # empty
133 $(common-objpfx
)linkobj
/libc.so
: $(elfobjdir
)/soinit.os \
134 $(common-objpfx
)linkobj
/libc_pic.a \
135 $(elfobjdir
)/sofini.os \
136 $(elfobjdir
)/interp.os \
141 ifeq (,$(filter sunrpc
,$(subdirs
)))
142 $(common-objpfx
)linkobj
/libc_pic.a
: $(common-objpfx
)libc_pic.a
143 $(make-target-directory
)
146 $(common-objpfx
)linkobj
/libc_pic.a
: $(common-objpfx
)libc_pic.a \
147 $(common-objpfx
)sunrpc
/librpc_compat_pic.a
148 $(make-target-directory
)
149 (cd
$(common-objpfx
)linkobj
; \
150 $(AR
) x ..
/libc_pic.a
; \
151 rm $$($(AR
) t ..
/sunrpc
/librpc_compat_pic.a | sed
's/^compat-//'); \
152 $(AR
) x ..
/sunrpc
/librpc_compat_pic.a
; \
153 $(AR
) cr libc_pic.a
*.os
; \
155 endif # $(subdirs) contains sunrpc
156 endif # $(build-shared)
159 # This is a handy script for running any dynamically linked program against
160 # the current libc build for testing.
161 $(common-objpfx
)testrun.sh
: $(common-objpfx
)config.make \
162 $(..
)Makeconfig
$(..
)Makefile
164 echo
'builddir=`dirname "$$0"`'; \
165 echo
'GCONV_PATH="$${builddir}/iconvdata" \'; \
166 echo 'exec
$(subst $(common-objdir
),"$${builddir}",\
167 $(test-program-prefix
)) $${1+"$$@"}'; \
171 postclean-generated += testrun.sh
173 others: $(common-objpfx)testrun.sh
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.
178 # Here we paste all of these together into <gnu/stubs.h>.
180 subdir-stubs
:= $(foreach dir,$(subdirs
),$(common-objpfx
)$(dir)/stubs
)
183 installed-stubs
= $(inst_includedir
)/gnu
/stubs.h
185 installed-stubs
= $(inst_includedir
)/gnu
/stubs-
$(default-abi
).h
187 $(inst_includedir
)/gnu
/stubs.h
: $(+force)
188 $(make-target-directory
)
190 echo
'/* This file is automatically generated.';\
191 echo
" This file selects the right generated file of \`__stub_FUNCTION' macros";\
192 echo
' based on the architecture being compiled for. */'; \
194 $(foreach h
,$(abi-includes
), echo
'#include <$(h)>';) \
196 $(foreach v
,$(abi-variants
),\
197 $(if
$(abi-
$(v
)-condition
),\
198 echo
'#if $(abi-$(v)-condition)'; \
199 echo
'# include <gnu/stubs-$(v).h>'); \
200 $(if
$(abi-
$(v
)-condition
),echo
'#endif';) \
201 rm -f
$(@
:.d
=.h
).new
$(v
); \
204 mv
-f
$(@
:.d
=.h
).new
$(@
:.d
=.h
)
206 install-others-nosubdir
: $(installed-stubs
)
210 # Since stubs.h is never needed when building the library, we simplify the
211 # hairy installation process by producing it in place only as the last part
212 # of the top-level `make install'. It depends on subdir_install, which
213 # iterates over all the subdirs; subdir_install in each subdir depends on
214 # the subdir's stubs file. Having more direct dependencies would result in
215 # extra iterations over the list for subdirs and many recursive makes.
216 $(installed-stubs
): include/stubs-prologue.h subdir_install
217 $(make-target-directory
)
218 @
rm -f
$(objpfx
)stubs.h
219 (sed
'/^@/d' $<; LC_ALL
=C
sort $(subdir-stubs
)) > $(objpfx
)stubs.h
220 if
test -r
$@
&& cmp
-s
$(objpfx
)stubs.h
$@
; \
221 then echo
'stubs.h unchanged'; \
222 else $(INSTALL_DATA
) $(objpfx
)stubs.h
$@
; fi
223 rm -f
$(objpfx
)stubs.h
225 # This makes the Info or DVI file of the documentation from the Texinfo source.
226 .PHONY
: info dvi pdf html
228 $(MAKE
) $(PARALLELMFLAGS
) -C manual
$@
230 # This makes all the subdirectory targets.
232 # For each target, make it depend on DIR/target for each subdirectory DIR.
233 $(+subdir_targets
): %: $(addsuffix /%,$(subdirs
))
235 # Compute a list of all those targets.
236 all-subdirs-targets
:= $(foreach dir,$(subdirs
),\
237 $(addprefix $(dir)/,$(+subdir_targets
)))
239 # The action for each of those is to cd into the directory and make the
241 $(all-subdirs-targets
):
242 $(MAKE
) $(PARALLELMFLAGS
) $(subdir-target-args
) $(@F
)
244 define subdir-target-args
245 subdir
=$(@D
)$(if
$($(@D
)-srcdir),\
246 -C
$($(@D
)-srcdir) ..
=`pwd`/,\
250 .PHONY
: $(+subdir_targets
) $(all-subdirs-targets
)
252 # Targets to clean things up to various degrees.
254 .PHONY
: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
257 # Subroutines of all cleaning targets.
258 parent-mostlyclean
: common-mostlyclean
# common-mostlyclean is in Makerules.
259 -rm -f
$(foreach o
,$(object-suffixes-for-libc
),\
260 $(common-objpfx
)$(patsubst %,$(libtype
$o),c
)) \
261 $(addprefix $(objpfx
),$(install-lib
))
262 parent-clean
: parent-mostlyclean common-clean
264 postclean
= $(addprefix $(common-objpfx
),$(postclean-generated
)) \
265 $(addprefix $(objpfx
),sysd-dirs sysd-rules
) \
266 $(addprefix $(objpfx
),sysd-sorted soversions.mk soversions.i
)
269 # This is done this way rather than having `subdir_clean' be a
270 # dependency of this target so that libc.a will be removed before the
271 # subdirectories are dealt with and so they won't try to remove object
272 # files from it when it's going to be removed anyway.
273 @
$(MAKE
) subdir_clean no_deps
=t
275 mostlyclean: parent-mostlyclean
276 @
$(MAKE
) subdir_mostlyclean no_deps
=t
280 @
$(MAKE
) subdir_testclean no_deps
=t
282 tests
: $(objpfx
)c
++-types-check.out
$(objpfx
)check-local-headers.out
285 vpath c
++-types.data
$(+sysdep_dirs
)
287 $(objpfx
)c
++-types-check.out
: c
++-types.data scripts
/check-c
++-types.sh
288 scripts
/check-c
++-types.sh
$< $(CXX
) $(filter-out -std
=gnu99
-Wstrict-prototypes
,$(CFLAGS
)) $(CPPFLAGS
) > $@
291 $(objpfx
)check-local-headers.out
: scripts
/check-local-headers.sh
292 AWK
='$(AWK)' scripts
/check-local-headers.sh \
293 "$(includedir)" "$(objpfx)" > $@
296 installed-headers
= argp
/argp.h assert
/assert.h catgets
/nl_types.h \
297 crypt
/crypt.h ctype
/ctype.h debug
/execinfo.h \
298 dirent
/dirent.h dlfcn
/dlfcn.h elf
/elf.h elf
/link.h \
299 gmon
/sys
/gmon.h gmon
/sys
/gmon_out.h gmon
/sys
/profil.h \
300 grp
/grp.h gshadow
/gshadow.h iconv
/iconv.h iconv
/gconv.h \
301 $(wildcard inet
/netinet
/*.h
) \
302 $(wildcard inet
/arpa
/*.h inet
/protocols
/*.h
) \
303 inet
/aliases.h inet
/ifaddrs.h inet
/netinet
/ip6.h \
304 inet
/netinet
/icmp6.h intl
/libintl.h io
/sys
/stat.h \
305 io
/sys
/statfs.h io
/sys
/vfs.h io
/sys
/statvfs.h \
306 io
/fcntl.h io
/sys
/fcntl.h io
/poll.h io
/sys
/poll.h \
307 io
/utime.h io
/ftw.h io
/fts.h io
/sys
/sendfile.h \
308 libio
/stdio.h libio
/libio.h locale
/locale.h \
309 locale
/langinfo.h locale
/xlocale.h login
/utmp.h \
310 login
/lastlog.h login
/pty.h malloc
/malloc.h \
311 malloc
/obstack.h malloc
/mcheck.h math
/math.h \
312 math
/complex.h math
/fenv.h math
/tgmath.h misc
/sys
/uio.h \
313 $(wildcard nis
/rpcsvc
/*.h
) nptl_db
/thread_db.h \
314 nptl
/sysdeps
/pthread
/pthread.h nptl
/semaphore.h \
315 nss
/nss.h posix
/sys
/utsname.h posix
/sys
/times.h \
316 posix
/sys
/wait.h posix
/sys
/types.h posix
/unistd.h \
317 posix
/glob.h posix
/regex.h posix
/wordexp.h posix
/fnmatch.h\
318 posix
/getopt.h posix
/tar.h posix
/sys
/unistd.h \
319 posix
/sched.h posix
/re_comp.h posix
/wait.h \
320 posix
/cpio.h posix
/spawn.h pwd
/pwd.h resolv
/resolv.h \
321 resolv
/netdb.h
$(wildcard resolv
/arpa
/*.h
) \
322 resource
/sys
/resource.h resource
/sys
/vlimit.h \
323 resource
/sys
/vtimes.h resource
/ulimit.h rt
/aio.h \
324 rt
/mqueue.h setjmp
/setjmp.h shadow
/shadow.h \
325 signal
/signal.h signal
/sys
/signal.h socket
/sys
/socket.h \
326 socket
/sys
/un.h stdio-common
/printf.h \
327 stdio-common
/stdio_ext.h stdlib
/stdlib.h stdlib
/alloca.h \
328 stdlib
/monetary.h stdlib
/fmtmsg.h stdlib
/ucontext.h \
329 sysdeps
/generic
/inttypes.h sysdeps
/generic
/stdint.h \
330 stdlib
/errno.h stdlib
/sys
/errno.h string
/string.h \
331 string
/strings.h string
/memory.h string
/endian.h \
332 string
/argz.h string
/envz.h string
/byteswap.h \
333 $(wildcard sunrpc
/rpc
/*.h sunrpc
/rpcsvc
/*.h
) \
334 sysvipc
/sys
/ipc.h sysvipc
/sys
/msg.h sysvipc
/sys
/sem.h \
335 sysvipc
/sys
/shm.h termios
/termios.h \
336 termios
/sys
/termios.h termios
/sys
/ttychars.h time
/time.h \
337 time
/sys
/time.h time
/sys
/timeb.h wcsmbs
/wchar.h \
340 tests
: $(objpfx
)begin-end-check.out
341 $(objpfx
)begin-end-check.out
: scripts
/begin-end-check.pl
342 $(PERL
) scripts
/begin-end-check.pl
$(installed-headers
) > $@
345 # The realclean target is just like distclean for the parent, but we want
346 # the subdirs to know the difference in case they care.
347 realclean distclean: parent-clean
348 # This is done this way rather than having `subdir_distclean' be a
349 # dependency of this target so that libc.a will be removed before the
350 # subdirectories are dealt with and so they won't try to remove object
351 # files from it when it's going to be removed anyway.
352 @
$(MAKE
) distclean-1 no_deps
=t distclean-1
=$@ avoid-generated
=yes \
353 sysdep-subdirs
="$(sysdep-subdirs)"
356 # Subroutine of distclean and realclean.
357 distclean-1
: subdir_
$(distclean-1
)
358 -rm -f
$(config-generated
)
359 -rm -f
$(addprefix $(objpfx
),config.status config.cache config.log
)
360 -rm -f
$(addprefix $(objpfx
),config.make config-name.h config.h
)
362 -rm -f
$(objpfx
)Makefile
364 -rm -f
$(sysdep-
$(distclean-1
))
366 # Make the TAGS file for Emacs users.
370 scripts
/list-sources.sh | sed
-n
-e
'/Makefile/p' \
371 $(foreach S
,[chsSyl
] cxx sh bash pl
,\
372 $(subst .
,\.
,-e
'/.$S\(.in\)*$$/p')) \
375 # Make the distribution tarfile.
376 .PHONY
: dist dist-prepare
378 generated
:= $(generated
) stubs.h
380 files-for-dist
:= README INSTALL configure ChangeLog NEWS
382 # Regenerate stuff, then error if these things are not committed yet.
383 dist-prepare
: $(files-for-dist
)
384 conf
=`find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \
387 git diff
--stat HEAD
-- $^
$$conf \
388 |
$(AWK
) '{ print; rc=1 } END { exit rc }'
391 git archive
--prefix=$*/ $* > $@.new
394 # Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
396 ifneq (,$(strip $(dist-version
)))
397 dist: $(foreach Z
,.bz2 .gz .xz
,$(dist-version
).
tar$Z)
401 @if v
=`git describe`; then \
402 echo Distribution version
$$v; \
403 $(MAKE
) dist dist-version
=$$v; \
409 INSTALL
: manual
/install.texi manual
/macros.texi \
410 $(common-objpfx
)manual
/pkgvers.texi
411 makeinfo --no-validate
--plaintext
--no-number-sections \
412 -I
$(common-objpfx
)manual
$< -o
$@
-tmp
413 $(AWK
) 'NF == 0 { ++n; next } \
414 NF != 0 { while (n-- > 0) print ""; n = 0; print }' \
419 $(common-objpfx
)manual
/%: FORCE
420 $(MAKE
) $(PARALLELMFLAGS
) -C manual
$@
423 iconvdata
/% localedata
/% po
/%: FORCE
424 $(MAKE
) $(PARALLELMFLAGS
) -C
$(@D
) $(@F
)
426 # glibc 2.0 contains some header files which aren't used with glibc 2.1
428 # These rules should remove those headers
429 ifeq (,$(install_root
))
430 ifeq ($(old-glibc-headers
),yes
)
431 install: remove-old-headers
435 headers2_0
:= __math.h bytesex.h confname.h direntry.h elfclass.h \
436 errnos.h fcntlbits.h huge_val.h ioctl-types.h \
437 ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h \
438 mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h \
439 posix2_lim.h posix_opt.h resourcebits.h schedbits.h \
440 selectbits.h semaphorebits.h sigaction.h sigcontext.h \
441 signum.h sigset.h sockaddrcom.h socketbits.h stab.def \
442 statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h \
443 syscall-list.h termbits.h timebits.h ustatbits.h \
444 utmpbits.h utsnamelen.h waitflags.h waitstatus.h \
445 xopen_lim.h gnu
/types.h sys
/ipc_buf.h \
446 sys
/kernel_termios.h sys
/msq_buf.h sys
/sem_buf.h \
447 sys
/shm_buf.h sys
/socketcall.h sigstack.h
449 .PHONY
: remove-old-headers
451 rm -f
$(addprefix $(inst_includedir
)/, $(headers2_0
))