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