Update.
[glibc.git] / Makefile
blobbbece0bd0855b9c66255a2a4e4ce882a988d883f
1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 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 Library General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # 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 # Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB. If not,
16 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 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 ifeq ($(with-cvs),yes)
34 define autoconf-it
35 @-rm -f $@.new
36 autoconf $(ACFLAGS) $< > $@.new
37 chmod a-w,a+x $@.new
38 mv -f $@.new $@
39 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
40 endef
41 else
42 define autoconf-it
43 @-rm -f $@.new
44 autoconf $(ACFLAGS) $< > $@.new
45 chmod a-w,a+x $@.new
46 mv -f $@.new $@
47 endef
48 endif
50 configure: configure.in aclocal.m4; $(autoconf-it)
51 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
53 # All initialization source files.
54 +subdir_inits := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
55 # All subdirectories containing initialization source files.
56 +init_subdirs := $(patsubst %/,%,$(dir $(+subdir_inits)))
59 # These are the targets that are made by making them in each subdirectory.
60 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
61 subdir_clean subdir_distclean subdir_realclean \
62 tests subdir_lint.out \
63 subdir_distinfo \
64 subdir_echo-headers subdir_echo-distinfo \
65 subdir_install \
66 $(addprefix install-, no-libc.a bin lib data headers others)
68 headers := errno.h sys/errno.h bits/errno.h limits.h values.h \
69 features.h gnu-versions.h bits/libc-lock.h bits/xopen_lim.h \
70 gnu/libc-version.h
71 aux = sysdep $(libc-init) version
72 before-compile += $(objpfx)version-info.h
74 echo-headers: subdir_echo-headers
76 # The headers are in the include directory.
77 subdir-dirs = include
78 vpath %.h $(subdir-dirs)
80 # What to install.
81 install-others = $(inst_includedir)/gnu/stubs.h
82 install-bin = glibcbug
84 ifeq (yes,$(build-shared))
85 install-others += $(inst_includedir)/gnu/lib-names.h
86 endif
88 ifeq (yes,$(gnu-ld))
89 libc-init = set-init
90 else
91 libc-init = munch-init
92 $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
93 $(AWK) -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
94 mv -f $@-t $@
95 generated := $(generated) munch-init.c
96 endif
99 include Makerules
101 # Install from subdirectories too.
102 install: subdir_install
104 # Make sure that the dynamic linker is installed before libc.
105 $(inst_slibdir)/libc-$(version).so: elf/ldso_install
107 .PHONY: elf/ldso_install
108 elf/ldso_install:
109 $(MAKE) -C $(@D) $(@F)
111 # Create links for shared libraries using the `ldconfig' program is possible.
112 # Ignore the error if we cannot update /etc/ld.so.cache.
113 ifeq (no,$(cross-compiling))
114 ifeq (yes,$(build-shared))
115 install:
116 -test ! -x $(common-objpfx)elf/ldconfig || \
117 $(common-objpfx)elf/ldconfig -d $(inst_slibdir) $(inst_libdir)
118 ifneq (no,$(PERL))
119 ifeq (/usr,$(prefix))
120 ifeq (,$(install_root))
121 CC="$(CC)" $(PERL) test-installation.pl $(common-objpfx)
122 endif
123 endif
124 endif
125 endif
126 endif
128 # Build subdirectory lib objects.
129 lib-noranlib: subdir_lib
131 ifeq (yes,$(build-shared))
132 # Build the shared object from the PIC object library.
133 lib: $(common-objpfx)libc.so
134 endif
136 all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
137 $(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
138 (case $(config-os) in \
139 linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
140 | $(CC) -E -P - | \
141 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
142 if [ -z "$$version" ]; then \
143 if [ -r /proc/version ]; then \
144 version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
145 < /proc/version`; \
146 else \
147 version=`uname -r`; \
148 fi; \
149 fi; \
150 echo -n "\"Compiled on a Linux $$version system "; \
151 echo "on `date +%Y-%m-%d`.\\n\"" ;; \
152 *) ;; \
153 esac; \
154 files="$(all-Banner-files)"; \
155 if test -n "$$files"; then \
156 echo "\"Available extensions:"; \
157 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
158 echo "\""; \
159 fi) > $@T
160 mv -f $@T $@
162 version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes))
163 $(version.c-objects): $(objpfx)version-info.h
165 # Makerules creates a file `stubs' in each subdirectory, which
166 # contains `#define __stub_FUNCTION' for each function defined in that
167 # directory which is a stub.
168 # Here we paste all of these together into <gnu/stubs.h>.
170 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
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 $(inst_includedir)/gnu/stubs.h: subdir_install
179 $(make-target-directory)
180 @rm -f $(objpfx)stubs.h
181 (echo '/* This file is automatically generated.';\
182 echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\
183 echo ' in the C library which is a stub, meaning it will fail';\
184 echo ' every time called, usually setting errno to ENOSYS. */';\
185 sort $(subdir-stubs)) > $(objpfx)stubs.h
186 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
187 then echo 'stubs.h unchanged'; \
188 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
189 rm -f $(objpfx)stubs.h
191 ifeq (yes,$(build-shared))
193 $(inst_includedir)/gnu/lib-names.h: $(common-objpfx)gnu/lib-names.h $(+force)
194 $(make-target-directory)
195 if test -r $@ && cmp -s $< $@; \
196 then echo 'gnu/lib-names.h unchanged'; \
197 else $(INSTALL_DATA) $< $@; fi
198 endif
200 # The `glibcbug' script contains the version number and it shall be rebuild
201 # whenever this changes or the `glibcbug.in' file.
202 $(objpfx)glibcbug: $(common-objpfx)config.status glibcbug.in
203 cd $(<D) && CONFIG_FILES=$(@F) CONFIG_HEADERS= $(SHELL) $(<F)
205 # This makes the Info or DVI file of the documentation from the Texinfo source.
206 .PHONY: info dvi
207 info dvi:
208 $(MAKE) $(PARALLELMFLAGS) -C manual $@
210 # This makes all the subdirectory targets.
212 # For each target, make it depend on DIR/target for each subdirectory DIR.
213 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
215 # Compute a list of all those targets.
216 all-subdirs-targets := $(foreach dir,$(subdirs),\
217 $(addprefix $(dir)/,$(+subdir_targets)))
219 # The action for each of those is to cd into the directory and make the
220 # target there.
221 $(all-subdirs-targets):
222 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
224 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
226 # Targets to clean things up to various degrees.
228 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
230 # Subroutines of all cleaning targets.
231 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
232 -rm -f $(foreach o,$(object-suffixes-for-libc),\
233 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
234 $(addprefix $(objpfx),$(install-lib))
235 parent-clean: parent-mostlyclean common-clean
237 postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
238 $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules) \
239 $(objpfx)soversions.mk
241 clean: parent-clean
242 # This is done this way rather than having `subdir_clean' be a
243 # dependency of this target so that libc.a will be removed before the
244 # subdirectories are dealt with and so they won't try to remove object
245 # files from it when it's going to be removed anyway.
246 @$(MAKE) subdir_clean no_deps=t
247 mostlyclean: parent-mostlyclean
248 @$(MAKE) subdir_mostlyclean no_deps=t
249 -rm -f $(postclean)
251 # The realclean target is just like distclean for the parent, but we want
252 # the subdirs to know the difference in case they care.
253 realclean distclean: parent-clean
254 # This is done this way rather than having `subdir_distclean' be a
255 # dependency of this target so that libc.a will be removed before the
256 # subdirectories are dealt with and so they won't try to remove object
257 # files from it when it's going to be removed anyway.
258 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
259 sysdep-subdirs="$(sysdep-subdirs)"
260 -rm -f $(postclean)
262 # Subroutine of distclean and realclean.
263 distclean-1: subdir_$(distclean-1)
264 -rm -f $(config-generated)
265 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
266 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
267 -rm -f $(addprefix $(objpfx),glibcbug)
268 ifdef objdir
269 -rm -f $(objpfx)Makefile
270 endif
271 -rm -f $(sysdep-$(distclean-1))
273 .PHONY: echo_subdirs
274 echo_subdirs:;@echo '$(subdirs)'
276 .PHONY: echo-distinfo parent_echo-distinfo
277 echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
278 parent_echo-distinfo:
279 @echo $(addprefix +header+,$(headers)) \
280 $(addprefix +nodist+,$(generated))
283 # Make the distribution tarfile.
285 distribute := README README.libm INSTALL FAQ NOTES NEWS PROJECTS BUGS \
286 COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
287 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
288 extra-lib.mk o-iterator.mk \
289 libc.map mkinstalldirs move-if-change install-sh \
290 configure configure.in aclocal.m4 config.sub config.guess\
291 config.h.in config.make.in config-name.in Makefile.in \
292 autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \
293 sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
294 rpm/Makefile rpm/template rpm/rpmrc glibcbug.in abi-tags \
295 stub-tag.h test-installation.pl test-skeleton.c \
296 include/des.h
298 distribute := $(strip $(distribute))
299 generated := $(generated) stubs.h version-info.h
301 README: README.template version.h ; # Make-dist should update README.
303 define format-me
304 @rm -f $@
305 makeinfo --no-validate --no-warn --no-headers $< -o $@
306 -chmod a-w $@
307 endef
308 INSTALL: manual/install.texi; $(format-me)
309 NOTES: manual/creature.texi; $(format-me)
310 manual/dir-add.texi manual/dir-add.info: FORCE
311 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
312 FAQ: gen-FAQ.pl FAQ.in
313 $(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
314 ifeq ($(with-cvs),yes)
315 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: $(PERL) $^' $@
316 endif
317 FORCE:
319 rpm/%: subdir_distinfo
320 $(MAKE) $(PARALLELMFLAGS) -C $(@D) subdirs='$(subdirs)' $(@F)
322 iconvdata/%:
323 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
325 # This is a special goal for people making binary distributions. Normally
326 # everybody uses the DES based crypt library but for the distribution we
327 # need the only-MD5 based one as well.
328 md5-crypt/libmd5crypt:
329 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)