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
23 This makefile requires GNU Make.
29 # This is the default target; it makes everything except the tests.
33 ifeq ($(with-cvs),yes)
36 autoconf $(ACFLAGS) $< > $@.new
39 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
44 autoconf $(ACFLAGS) $< > $@.new
50 configure: configure.in aclocal.m4; $(autoconf-it)
51 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
53 ifndef avoid-generated
54 -include $(objpfx)sysd-dirs
59 sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
62 # These are the subdirectories containing the library source.
63 subdirs = csu assert ctype db2 locale intl catgets math setjmp signal stdlib \
64 stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd \
65 posix io termios resource misc socket sysvipc gmon gnulib iconv \
66 iconvdata wctype manual shadow md5-crypt po argp $(add-ons) nss \
67 localedata timezone rt $(sysdep-subdirs) $(binfmt-subdir)
68 export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63.
70 # The mach and hurd subdirectories have many generated header files which
71 # much of the rest of the library depends on, so it is best to build them
72 # first (and mach before hurd, at that). The before-compile additions in
73 # sysdeps/{mach,hurd}/Makefile should make it reliably work for these files
74 # not to exist when making in other directories, but it will be slower that
75 # way with more somewhat expensive `make' invocations.
76 subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
77 $(filter-out mach hurd,$(subdirs))
79 # All initialization source files.
80 +subdir_inits := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
81 # All subdirectories containing initialization source files.
82 +init_subdirs := $(patsubst %/,%,$(dir $(+subdir_inits)))
85 # These are the targets that are made by making them in each subdirectory.
86 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
87 subdir_clean subdir_distclean subdir_realclean \
88 tests subdir_lint.out \
90 subdir_echo-headers subdir_echo-distinfo \
92 $(addprefix install-, no-libc.a bin lib data headers others)
94 headers := errno.h sys/errno.h bits/errno.h limits.h values.h \
95 features.h gnu-versions.h bits/libc-lock.h bits/xopen_lim.h \
97 aux = sysdep $(libc-init) version
98 before-compile += $(objpfx)version-info.h
100 echo-headers: subdir_echo-headers
102 # The headers are in the include directory.
103 subdir-dirs = include
104 vpath %.h $(subdir-dirs)
107 install-others = $(inst_includedir)/gnu/stubs.h
108 install-bin = glibcbug
110 ifeq (yes,$(build-shared))
111 install-others += $(inst_includedir)/gnu/lib-names.h
117 libc-init = munch-init
118 $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
119 $(AWK) -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
121 generated := $(generated) munch-init.c
127 # Install from subdirectories too.
128 install: subdir_install
130 # Make sure that the dynamic linker is installed before libc.
131 $(inst_slibdir)/libc-$(version).so: elf/ldso_install
133 .PHONY: elf/ldso_install
135 $(MAKE) -C $(@D) $(@F)
137 # Create links for shared libraries using the `ldconfig' program is possible.
138 # Ignore the error if we cannot update /etc/ld.so.cache.
139 ifeq (no,$(cross-compiling))
140 ifeq (yes,$(build-shared))
142 -test ! -x $(common-objpfx)elf/ldconfig || \
143 $(common-objpfx)elf/ldconfig -d $(inst_slibdir) $(inst_libdir)
145 ifeq (/usr,$(prefix))
146 ifeq (,$(install_root))
147 CC="$(CC)" $(PERL) test-installation.pl $(common-objpfx)
154 # Build subdirectory lib objects.
155 lib-noranlib: subdir_lib
157 ifeq (yes,$(build-shared))
158 # Build the shared object from the PIC object library.
159 lib: $(common-objpfx)libc.so
162 all-Subdirs-files = $(wildcard $(addsuffix /Subdirs, $(config-sysdirs)))
163 $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files)
164 (echo define sysdep-subdirs; \
165 sed 's/#.*$$//' $(all-Subdirs-files) /dev/null; \
169 all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
170 $(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
171 (case $(config-os) in \
172 linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
174 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
175 if [ -z "$$version" ]; then \
176 if [ -r /proc/version ]; then \
177 version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
180 version=`uname -r`; \
183 echo -n "\"Compiled on a Linux $$version system "; \
184 echo "on `date +%Y-%m-%d`.\\n\"" ;; \
187 files="$(all-Banner-files)"; \
188 if test -n "$$files"; then \
189 echo "\"Available extensions:"; \
190 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
195 version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes))
196 $(version.c-objects): $(objpfx)version-info.h
198 # Makerules creates a file `stubs' in each subdirectory, which
199 # contains `#define __stub_FUNCTION' for each function defined in that
200 # directory which is a stub.
201 # Here we paste all of these together into <gnu/stubs.h>.
203 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
205 # Since stubs.h is never needed when building the library, we simplify the
206 # hairy installation process by producing it in place only as the last part
207 # of the top-level `make install'. It depends on subdir_install, which
208 # iterates over all the subdirs; subdir_install in each subdir depends on
209 # the subdir's stubs file. Having more direct dependencies would result in
210 # extra iterations over the list for subdirs and many recursive makes.
211 $(inst_includedir)/gnu/stubs.h: subdir_install
212 $(make-target-directory)
213 @rm -f $(objpfx)stubs.h
214 (echo '/* This file is automatically generated.';\
215 echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\
216 echo ' in the C library which is a stub, meaning it will fail';\
217 echo ' every time called, usually setting errno to ENOSYS. */';\
218 sort $(subdir-stubs)) > $(objpfx)stubs.h
219 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
220 then echo 'stubs.h unchanged'; \
221 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
222 rm -f $(objpfx)stubs.h
224 ifeq (yes,$(build-shared))
226 $(inst_includedir)/gnu/lib-names.h: $(common-objpfx)gnu/lib-names.h $(+force)
227 $(make-target-directory)
228 if test -r $@ && cmp -s $< $@; \
229 then echo 'gnu/lib-names.h unchanged'; \
230 else $(INSTALL_DATA) $< $@; fi
233 # The `glibcbug' script contains the version number and it shall be rebuild
234 # whenever this changes or the `glibcbug.in' file.
235 $(objpfx)glibcbug: $(common-objpfx)config.status glibcbug.in
236 cd $(<D) && CONFIG_FILES=$(@F) CONFIG_HEADERS= $(SHELL) $(<F)
238 # This makes the Info or DVI file of the documentation from the Texinfo source.
241 $(MAKE) $(PARALLELMFLAGS) -C manual $@
243 # This makes all the subdirectory targets.
245 # For each target, make it depend on DIR/target for each subdirectory DIR.
246 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
248 # Compute a list of all those targets.
249 all-subdirs-targets := $(foreach dir,$(subdirs),\
250 $(addprefix $(dir)/,$(+subdir_targets)))
252 # The action for each of those is to cd into the directory and make the
254 $(all-subdirs-targets):
255 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
257 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
259 # Targets to clean things up to various degrees.
261 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
263 # Subroutines of all cleaning targets.
264 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
265 -rm -f $(foreach o,$(object-suffixes-for-libc),\
266 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
267 $(addprefix $(objpfx),$(install-lib))
268 parent-clean: parent-mostlyclean common-clean
270 postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
271 $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules) \
272 $(objpfx)soversions.mk
275 # This is done this way rather than having `subdir_clean' be a
276 # dependency of this target so that libc.a will be removed before the
277 # subdirectories are dealt with and so they won't try to remove object
278 # files from it when it's going to be removed anyway.
279 @$(MAKE) subdir_clean no_deps=t
280 mostlyclean: parent-mostlyclean
281 @$(MAKE) subdir_mostlyclean no_deps=t
284 # The realclean target is just like distclean for the parent, but we want
285 # the subdirs to know the difference in case they care.
286 realclean distclean: parent-clean
287 # This is done this way rather than having `subdir_distclean' be a
288 # dependency of this target so that libc.a will be removed before the
289 # subdirectories are dealt with and so they won't try to remove object
290 # files from it when it's going to be removed anyway.
291 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
292 sysdep-subdirs="$(sysdep-subdirs)"
295 # Subroutine of distclean and realclean.
296 distclean-1: subdir_$(distclean-1)
297 -rm -f $(config-generated)
298 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
299 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
300 -rm -f $(addprefix $(objpfx),glibcbug)
302 -rm -f $(objpfx)Makefile
304 -rm -f $(sysdep-$(distclean-1))
307 echo_subdirs:;@echo '$(subdirs)'
309 .PHONY: echo-distinfo parent_echo-distinfo
310 echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
311 parent_echo-distinfo:
312 @echo $(addprefix +header+,$(headers)) \
313 $(addprefix +nodist+,$(generated))
316 # Make the distribution tarfile.
318 distribute := README README.libm INSTALL FAQ NOTES NEWS PROJECTS BUGS \
319 COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
320 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
321 extra-lib.mk o-iterator.mk \
322 libc.map mkinstalldirs move-if-change install-sh \
323 configure configure.in aclocal.m4 config.sub config.guess\
324 config.h.in config.make.in config-name.in Makefile.in \
325 autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \
326 sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
327 rpm/Makefile rpm/template rpm/rpmrc glibcbug.in abi-tags \
328 stub-tag.h test-installation.pl test-skeleton.c \
331 distribute := $(strip $(distribute))
332 generated := $(generated) stubs.h version-info.h
334 README: README.template version.h ; # Make-dist should update README.
338 makeinfo --no-validate --no-warn --no-headers $< -o $@
341 INSTALL: manual/install.texi; $(format-me)
342 NOTES: manual/creature.texi; $(format-me)
343 manual/dir-add.texi manual/dir-add.info: FORCE
344 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
345 FAQ: gen-FAQ.pl FAQ.in
346 $(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
347 ifeq ($(with-cvs),yes)
348 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: $(PERL) $^' $@
352 rpm/%: subdir_distinfo
353 $(MAKE) $(PARALLELMFLAGS) -C $(@D) subdirs='$(subdirs)' $(@F)
356 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
358 # This is a special goal for people making binary distributions. Normally
359 # everybody uses the DES based crypt library but for the distribution we
360 # need the only-MD5 based one as well.
361 md5-crypt/libmd5crypt:
362 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)