1 # Copyright (C) 1991-2014 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.ac aclocal.m4
; $(autoconf-it
)
42 %/configure
: %/configure.ac aclocal.m4
; $(autoconf-it
)
43 %/preconfigure
: %/preconfigure.ac 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 \
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
$(common-objpfx
)linkobj
/libc.so
127 endif # $(build-shared)
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
135 echo
'builddir=`dirname "$$0"`'; \
136 echo
'GCONV_PATH="$${builddir}/iconvdata" \'; \
137 echo 'exec
$(subst $(common-objdir
),"$${builddir}",\
138 $(test-program-prefix
)) $${1+"$$@"}'; \
142 postclean-generated += testrun.sh
144 others: $(common-objpfx)testrun.sh
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.
149 # Here we paste all of these together into <gnu/stubs.h>.
151 subdir-stubs
:= $(foreach dir,$(subdirs
),$(common-objpfx
)$(dir)/stubs
)
154 installed-stubs
= $(inst_includedir
)/gnu
/stubs.h
156 installed-stubs
= $(inst_includedir
)/gnu
/stubs-
$(default-abi
).h
158 $(inst_includedir
)/gnu
/stubs.h
: $(+force)
159 $(make-target-directory
)
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. */'; \
165 $(foreach h
,$(abi-includes
), echo
'#include <$(h)>';) \
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
); \
175 mv
-f
$(@
:.d
=.h
).new
$(@
:.d
=.h
)
177 install-others-nosubdir
: $(installed-stubs
)
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
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.
187 $(installed-stubs
): include/stubs-prologue.h subdir_install
188 $(make-target-directory
)
189 @
rm -f
$(objpfx
)stubs.h
190 (sed
'/^@/d' $<; LC_ALL
=C
sort $(subdir-stubs
)) > $(objpfx
)stubs.h
191 if
test -r
$@
&& cmp
-s
$(objpfx
)stubs.h
$@
; \
192 then echo
'stubs.h unchanged'; \
193 else $(INSTALL_DATA
) $(objpfx
)stubs.h
$@
; fi
194 rm -f
$(objpfx
)stubs.h
196 # This makes the Info or DVI file of the documentation from the Texinfo source.
197 .PHONY
: info dvi pdf html
199 $(MAKE
) $(PARALLELMFLAGS
) -C manual
$@
201 # This makes all the subdirectory targets.
203 # For each target, make it depend on DIR/target for each subdirectory DIR.
204 $(+subdir_targets
): %: $(addsuffix /%,$(subdirs
))
206 # Compute a list of all those targets.
207 all-subdirs-targets
:= $(foreach dir,$(subdirs
),\
208 $(addprefix $(dir)/,$(+subdir_targets
)))
210 # The action for each of those is to cd into the directory and make the
212 $(all-subdirs-targets
):
213 $(MAKE
) $(PARALLELMFLAGS
) $(subdir-target-args
) $(@F
)
215 define subdir-target-args
216 subdir
=$(@D
)$(if
$($(@D
)-srcdir),\
217 -C
$($(@D
)-srcdir) ..
=`pwd`/,\
221 .PHONY
: $(+subdir_targets
) $(all-subdirs-targets
)
223 # Targets to clean things up to various degrees.
225 .PHONY
: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
228 # Subroutines of all cleaning targets.
229 parent-mostlyclean
: common-mostlyclean
# common-mostlyclean is in Makerules.
230 -rm -f
$(foreach o
,$(object-suffixes-for-libc
),\
231 $(common-objpfx
)$(patsubst %,$(libtype
$o),c
)) \
232 $(addprefix $(objpfx
),$(install-lib
))
233 parent-clean
: parent-mostlyclean common-clean
235 postclean
= $(addprefix $(common-objpfx
),$(postclean-generated
)) \
236 $(addprefix $(objpfx
),sysd-dirs sysd-rules
) \
237 $(addprefix $(objpfx
),sysd-sorted soversions.mk soversions.i
)
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
246 mostlyclean: parent-mostlyclean
247 @
$(MAKE
) subdir_mostlyclean no_deps
=t
251 @
$(MAKE
) subdir_testclean no_deps
=t
253 tests
: $(objpfx
)c
++-types-check.out
$(objpfx
)check-local-headers.out
256 vpath c
++-types.data
$(+sysdep_dirs
)
258 $(objpfx
)c
++-types-check.out
: c
++-types.data scripts
/check-c
++-types.sh
259 scripts
/check-c
++-types.sh
$< $(CXX
) $(filter-out -std
=gnu99
-Wstrict-prototypes
,$(CFLAGS
)) $(CPPFLAGS
) > $@
; \
263 $(objpfx
)check-local-headers.out
: scripts
/check-local-headers.sh
264 AWK
='$(AWK)' scripts
/check-local-headers.sh \
265 "$(includedir)" "$(objpfx)" > $@
; \
269 installed-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 \
273 grp
/grp.h gshadow
/gshadow.h iconv
/iconv.h iconv
/gconv.h \
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 \
287 nptl
/sysdeps
/pthread
/pthread.h nptl
/semaphore.h \
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 \
313 tests
: $(objpfx
)begin-end-check.out
314 $(objpfx
)begin-end-check.out
: scripts
/begin-end-check.pl
315 $(PERL
) scripts
/begin-end-check.pl
$(installed-headers
) > $@
; \
319 # The realclean target is just like distclean for the parent, but we want
320 # the subdirs to know the difference in case they care.
321 realclean distclean: parent-clean
322 # This is done this way rather than having `subdir_distclean' be a
323 # dependency of this target so that libc.a will be removed before the
324 # subdirectories are dealt with and so they won't try to remove object
325 # files from it when it's going to be removed anyway.
326 @
$(MAKE
) distclean-1 no_deps
=t distclean-1
=$@ avoid-generated
=yes \
327 sysdep-subdirs
="$(sysdep-subdirs)"
330 # Subroutine of distclean and realclean.
331 distclean-1
: subdir_
$(distclean-1
)
332 -rm -f
$(config-generated
)
333 -rm -f
$(addprefix $(objpfx
),config.status config.cache config.log
)
334 -rm -f
$(addprefix $(objpfx
),config.make config-name.h config.h
)
336 -rm -f
$(objpfx
)Makefile
338 -rm -f
$(sysdep-
$(distclean-1
))
340 # Make the TAGS file for Emacs users.
344 scripts
/list-sources.sh | sed
-n
-e
'/Makefile/p' \
345 $(foreach S
,[chsSyl
] cxx sh bash pl
,\
346 $(subst .
,\.
,-e
'/.$S\(.in\)*$$/p')) \
349 # Make the distribution tarfile.
350 .PHONY
: dist dist-prepare
352 generated
:= $(generated
) stubs.h
354 files-for-dist
:= README INSTALL configure ChangeLog NEWS
356 # Regenerate stuff, then error if these things are not committed yet.
357 dist-prepare
: $(files-for-dist
)
358 conf
=`find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \
361 git diff
--stat HEAD
-- $^
$$conf \
362 |
$(AWK
) '{ print; rc=1 } END { exit rc }'
365 git archive
--prefix=$*/ $* > $@.new
368 # Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
370 ifneq (,$(strip $(dist-version
)))
371 dist: $(foreach Z
,.bz2 .gz .xz
,$(dist-version
).
tar$Z)
375 @if v
=`git describe`; then \
376 echo Distribution version
$$v; \
377 $(MAKE
) dist dist-version
=$$v; \
383 INSTALL
: manual
/install-plain.texi manual
/macros.texi \
384 $(common-objpfx
)manual
/pkgvers.texi manual
/install.texi
385 makeinfo --no-validate
--plaintext
--no-number-sections \
386 -I
$(common-objpfx
)manual
$< -o
$@
-tmp
387 $(AWK
) 'NF == 0 { ++n; next } \
388 NF != 0 { while (n-- > 0) print ""; n = 0; print }' \
393 $(common-objpfx
)manual
/%: FORCE
394 $(MAKE
) $(PARALLELMFLAGS
) -C manual
$@
397 iconvdata
/% localedata
/% po
/%: FORCE
398 $(MAKE
) $(PARALLELMFLAGS
) -C
$(@D
) $(@F
)
400 # glibc 2.0 contains some header files which aren't used with glibc 2.1
402 # These rules should remove those headers
403 ifeq (,$(install_root
))
404 ifeq ($(old-glibc-headers
),yes
)
405 install: remove-old-headers
409 headers2_0
:= __math.h bytesex.h confname.h direntry.h elfclass.h \
410 errnos.h fcntlbits.h huge_val.h ioctl-types.h \
411 ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h \
412 mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h \
413 posix2_lim.h posix_opt.h resourcebits.h schedbits.h \
414 selectbits.h semaphorebits.h sigaction.h sigcontext.h \
415 signum.h sigset.h sockaddrcom.h socketbits.h stab.def \
416 statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h \
417 syscall-list.h termbits.h timebits.h ustatbits.h \
418 utmpbits.h utsnamelen.h waitflags.h waitstatus.h \
419 xopen_lim.h gnu
/types.h sys
/ipc_buf.h \
420 sys
/kernel_termios.h sys
/msq_buf.h sys
/sem_buf.h \
421 sys
/shm_buf.h sys
/socketcall.h sigstack.h
423 .PHONY
: remove-old-headers
425 rm -f
$(addprefix $(inst_includedir
)/, $(headers2_0
))