2.3.90-5
[glibc.git] / Makefile
blob734687cf3dc88fef1cf82d5314646209ba425ec0
1 # Copyright (C) 1991-2002, 2003, 2004, 2005 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, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 # 02111-1307 USA.
20 # Master Makefile for the GNU C library
22 ifneq (,)
23 This makefile requires GNU Make.
24 endif
26 include Makeconfig
29 # This is the default target; it makes everything except the tests.
30 .PHONY: all
31 all: lib others
33 ifneq ($(AUTOCONF),no)
35 ifeq ($(with-cvs),yes)
36 define autoconf-it-cvs
37 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
38 endef
39 else
40 autoconf-it-cvs =
41 endif
43 define autoconf-it
44 @-rm -f $@.new
45 $(AUTOCONF) $(ACFLAGS) $< > $@.new
46 chmod a-w,a+x $@.new
47 mv -f $@.new $@
48 $(autoconf-it-cvs)
49 endef
51 configure: configure.in aclocal.m4; $(autoconf-it)
52 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
54 endif # $(AUTOCONF) = no
57 # We don't want to run anything here in parallel.
58 .NOTPARALLEL:
60 # These are the targets that are made by making them in each subdirectory.
61 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
62 subdir_clean subdir_distclean subdir_realclean \
63 tests xtests subdir_lint.out \
64 subdir_update-abi subdir_check-abi \
65 subdir_echo-headers \
66 subdir_install \
67 subdir_objs subdir_stubs subdir_testclean \
68 $(addprefix install-, no-libc.a bin lib data headers others)
70 headers := limits.h values.h features.h gnu-versions.h bits/libc-lock.h \
71 bits/xopen_lim.h gnu/libc-version.h
73 echo-headers: subdir_echo-headers
75 # The headers are in the include directory.
76 subdir-dirs = include
77 vpath %.h $(subdir-dirs)
79 # What to install.
80 install-others = $(inst_includedir)/gnu/stubs.h
81 install-bin-script =
83 ifeq (yes,$(build-shared))
84 headers += gnu/lib-names.h
85 endif
87 include Makerules
89 ifeq ($(build-programs),yes)
90 others: $(addprefix $(objpfx),$(install-bin-script))
91 endif
93 # Install from subdirectories too.
94 install: subdir_install
96 # Explicit dependency so that `make install-headers' works
97 install-headers: install-headers-nosubdir
99 # Make sure that the dynamic linker is installed before libc.
100 $(inst_slibdir)/libc-$(version).so: elf/ldso_install
102 .PHONY: elf/ldso_install
103 elf/ldso_install:
104 $(MAKE) -C $(@D) $(@F)
106 # Create links for shared libraries using the `ldconfig' program if possible.
107 # Ignore the error if we cannot update /etc/ld.so.cache.
108 ifeq (no,$(cross-compiling))
109 ifeq (yes,$(build-shared))
110 install: install-symbolic-link
111 .PHONY: install-symbolic-link
112 install-symbolic-link: subdir_install
113 $(symbolic-link-prog) $(symbolic-link-list)
114 rm -f $(symbolic-link-list)
116 install:
117 -test ! -x $(common-objpfx)elf/ldconfig || LC_ALL=C LANGUAGE=C \
118 $(common-objpfx)elf/ldconfig $(addprefix -r ,$(install_root)) \
119 $(slibdir) $(libdir)
120 ifneq (no,$(PERL))
121 ifeq (/usr,$(prefix))
122 ifeq (,$(install_root))
123 CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)
124 endif
125 endif
126 endif
127 endif
128 endif
130 # Build subdirectory lib objects.
131 lib-noranlib: subdir_lib
133 ifeq (yes,$(build-shared))
134 # Build the shared object from the PIC object library.
135 lib: $(common-objpfx)libc.so
136 endif
139 # This is a handy script for running any dynamically linked program against
140 # the current libc build for testing.
141 $(common-objpfx)testrun.sh: $(common-objpfx)config.make \
142 $(..)Makeconfig $(..)Makefile
143 (echo '#!/bin/sh'; \
144 echo "GCONV_PATH='$(common-objpfx)iconvdata' \\"; \
145 echo 'exec $(run-program-prefix) $${1+"$$@"}'; \
146 ) > $@T
147 chmod a+x $@T
148 mv -f $@T $@
149 postclean-generated += testrun.sh
151 others: $(common-objpfx)testrun.sh
153 # Makerules creates a file `stubs' in each subdirectory, which
154 # contains `#define __stub_FUNCTION' for each function defined in that
155 # directory which is a stub.
156 # Here we paste all of these together into <gnu/stubs.h>.
158 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
160 ifeq ($(biarch),no)
161 installed-stubs = $(inst_includedir)/gnu/stubs.h
162 else
163 installed-stubs = $(inst_includedir)/gnu/stubs-$(biarch).h
165 $(inst_includedir)/gnu/stubs.h: include/stubs-biarch.h $(+force)
166 $(INSTALL_DATA) $< $@
168 install-others-nosubdir: $(installed-stubs)
169 endif
172 # Since stubs.h is never needed when building the library, we simplify the
173 # hairy installation process by producing it in place only as the last part
174 # of the top-level `make install'. It depends on subdir_install, which
175 # iterates over all the subdirs; subdir_install in each subdir depends on
176 # the subdir's stubs file. Having more direct dependencies would result in
177 # extra iterations over the list for subdirs and many recursive makes.
178 $(installed-stubs): include/stubs-prologue.h subdir_install
179 $(make-target-directory)
180 @rm -f $(objpfx)stubs.h
181 (sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h
182 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
183 then echo 'stubs.h unchanged'; \
184 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
185 rm -f $(objpfx)stubs.h
187 # This makes the Info or DVI file of the documentation from the Texinfo source.
188 .PHONY: info dvi pdf html
189 info dvi pdf html:
190 $(MAKE) $(PARALLELMFLAGS) -C manual $@
192 # This makes all the subdirectory targets.
194 # For each target, make it depend on DIR/target for each subdirectory DIR.
195 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
197 # Compute a list of all those targets.
198 all-subdirs-targets := $(foreach dir,$(subdirs),\
199 $(addprefix $(dir)/,$(+subdir_targets)))
201 # The action for each of those is to cd into the directory and make the
202 # target there.
203 $(all-subdirs-targets):
204 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
206 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
208 # Targets to clean things up to various degrees.
210 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
211 tests-clean
213 # Subroutines of all cleaning targets.
214 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
215 -rm -f $(foreach o,$(object-suffixes-for-libc),\
216 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
217 $(addprefix $(objpfx),$(install-lib))
218 parent-clean: parent-mostlyclean common-clean
220 postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
221 $(addprefix $(objpfx),sysd-dirs sysd-rules) \
222 $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
224 clean: parent-clean
225 # This is done this way rather than having `subdir_clean' be a
226 # dependency of this target so that libc.a will be removed before the
227 # subdirectories are dealt with and so they won't try to remove object
228 # files from it when it's going to be removed anyway.
229 @$(MAKE) subdir_clean no_deps=t
230 -rm -f $(postclean)
231 mostlyclean: parent-mostlyclean
232 @$(MAKE) subdir_mostlyclean no_deps=t
233 -rm -f $(postclean)
235 tests-clean:
236 @$(MAKE) subdir_testclean no_deps=t
238 tests: $(objpfx)c++-types-check.out
239 ifneq ($(CXX),no)
240 check-data := $(firstword $(wildcard \
241 $(foreach M,$(config-machine) $(base-machine),\
242 scripts/data/c++-types-$M-$(config-os).data)))
243 ifneq (,$(check-data))
244 $(objpfx)c++-types-check.out: $(check-data)
245 scripts/check-c++-types.sh $^ $(CXX) $(filter-out -std=gnu99 -Wstrict-prototypes,$(CFLAGS)) $(CPPFLAGS) > $@
246 else
247 $(objpfx)c++-types-check.out:
248 @echo 'WARNING C++ tests not run; create a c++-types-XXX file'
249 @echo "not run" > $@
250 endif
251 endif
253 # The realclean target is just like distclean for the parent, but we want
254 # the subdirs to know the difference in case they care.
255 realclean distclean: parent-clean
256 # This is done this way rather than having `subdir_distclean' be a
257 # dependency of this target so that libc.a will be removed before the
258 # subdirectories are dealt with and so they won't try to remove object
259 # files from it when it's going to be removed anyway.
260 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
261 sysdep-subdirs="$(sysdep-subdirs)"
262 -rm -f $(postclean)
264 # Subroutine of distclean and realclean.
265 distclean-1: subdir_$(distclean-1)
266 -rm -f $(config-generated)
267 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
268 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
269 ifdef objdir
270 -rm -f $(objpfx)Makefile
271 endif
272 -rm -f $(sysdep-$(distclean-1))
274 # Make the distribution tarfile.
275 .PHONY: dist tag-for-dist
277 generated := $(generated) stubs.h
279 README: README.template version.h
280 -rm -f $@
281 sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
282 # Make it unwritable so I won't change it by mistake.
283 chmod 444 $@
284 ifeq ($(with-cvs),yes)
285 test ! -d CVS || cvs $(CVSOPTS) commit -m'Remade for $(release)-$(version)' $@
286 endif
288 files-for-dist := README FAQ INSTALL NOTES configure
290 tag-of-stem = glibc-$(subst .,_,$*)
292 # Add-ons in the main repository but distributed in their own tar files.
293 dist-separate = libidn linuxthreads
295 # Directories in each add-on.
296 dist-separate-libidn = libidn
297 dist-separate-linuxthreads = linuxthreads linuxthreads_db
299 glibc-%.tar $(dist-separate:%=glibc-%-%.tar): $(files-for-dist) \
300 $(foreach D,$(dist-separate),\
301 $D/configure)
302 @rm -fr glibc-$*
303 $(MAKE) -q `find sysdeps $(addsuffix /sysdeps,$(add-ons)) \
304 -name configure`
305 cvs $(CVSOPTS) -Q export -d glibc-$* -r $(tag-of-stem) libc
306 # Touch all the configure scripts going into the tarball since cvs export
307 # might have delivered configure.in newer than configure.
308 find glibc-$* -name configure -print | xargs touch
309 $(dist-do-separate-dirs)
310 tar cf glibc-$*.tar glibc-$*
311 rm -fr glibc-$*
312 define dist-do-separate-dirs
313 $(foreach dir,$(dist-separate),
314 tar cf glibc-$(dir)-$*.tar -C glibc-$* $(dist-separate-$(dir))
315 rm -rf $(addprefix glibc-$*/,$(dist-separate-$(dir)))
317 endef
319 # Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
320 dist-version = $(version)
322 dist: $(foreach Z,.bz2 .gz,glibc-$(dist-version).tar$Z \
323 $(foreach D,$(dist-separate),\
324 glibc-$D-$(dist-version).tar$Z))
325 md5sum $^
327 tag-for-dist: tag-$(dist-version)
328 tag-%: $(files-for-dist)
329 cvs $(CVSOPTS) -Q tag -c $(tag-of-stem)
331 define format-me
332 @rm -f $@
333 makeinfo --no-validate --no-warn --no-headers $< -o $@
334 -chmod a-w $@
335 endef
336 INSTALL: manual/install.texi; $(format-me)
337 NOTES: manual/creature.texi; $(format-me)
338 manual/dir-add.texi manual/dir-add.info: FORCE
339 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
340 FAQ: scripts/gen-FAQ.pl FAQ.in
341 $(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
342 ifeq ($(with-cvs),yes)
343 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: $(PERL) $^' $@
344 endif
345 FORCE:
347 iconvdata/% localedata/% po/% manual/%:
348 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
350 # glibc 2.0 contains some header files which aren't used with glibc 2.1
351 # anymore.
352 # These rules should remove those headers
353 ifeq (,$(install_root))
354 ifeq ($(old-glibc-headers),yes)
355 install: remove-old-headers
356 endif
357 endif
359 headers2_0 := __math.h bytesex.h confname.h direntry.h elfclass.h \
360 errnos.h fcntlbits.h huge_val.h ioctl-types.h \
361 ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h \
362 mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h \
363 posix2_lim.h posix_opt.h resourcebits.h schedbits.h \
364 selectbits.h semaphorebits.h sigaction.h sigcontext.h \
365 signum.h sigset.h sockaddrcom.h socketbits.h stab.def \
366 statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h \
367 syscall-list.h termbits.h timebits.h ustatbits.h \
368 utmpbits.h utsnamelen.h waitflags.h waitstatus.h \
369 xopen_lim.h gnu/types.h sys/ipc_buf.h \
370 sys/kernel_termios.h sys/msq_buf.h sys/sem_buf.h \
371 sys/shm_buf.h sys/socketcall.h sigstack.h
373 .PHONY: remove-old-headers
374 remove-old-headers:
375 rm -f $(addprefix $(inst_includedir)/, $(headers2_0))