1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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.
27 # This is the default target; it makes everything except the tests.
33 autoconf $(ACFLAGS) $< > $@.new
36 test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
39 configure: configure.in aclocal.m4; $(autoconf-it)
40 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
44 ifndef avoid-generated
45 -include $(objpfx)sysd-dirs
50 sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
53 # These are the subdirectories containing the library source.
54 subdirs = csu assert ctype db2 locale intl catgets math setjmp signal stdlib \
55 stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd \
56 posix io termios resource misc socket sysvipc gmon gnulib iconv \
57 wctype manual shadow md5-crypt po argp $(add-ons) nss \
58 $(sysdep-subdirs) $(binfmt-subdir)
59 export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63.
61 # The mach and hurd subdirectories have many generated header files which
62 # much of the rest of the library depends on, so it is best to build them
63 # first (and mach before hurd, at that). The before-compile additions in
64 # sysdeps/{mach,hurd}/Makefile should make it reliably work for these files
65 # not to exist when making in other directories, but it will be slower that
66 # way with more somewhat expensive `make' invocations.
67 subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
68 $(filter-out mach hurd,$(subdirs))
70 # All initialization source files.
71 +subdir_inits := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
72 # All subdirectories containing initialization source files.
73 +init_subdirs := $(patsubst %/,%,$(dir $(+subdir_inits)))
76 # These are the targets that are made by making them in each subdirectory.
77 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
78 subdir_clean subdir_distclean subdir_realclean \
79 tests subdir_lint.out \
81 subdir_echo-headers subdir_echo-distinfo \
83 $(addprefix install-, no-libc.a bin lib data headers others)
85 headers := errno.h sys/errno.h bits/errno.h limits.h values.h \
86 features.h gnu-versions.h bits/libc-lock.h bits/xopen_lim.h
87 aux = sysdep $(libc-init) version
88 before-compile += $(objpfx)version-info.h
90 echo-headers: subdir_echo-headers
92 # The headers are in the include directory.
94 vpath %.h $(subdir-dirs)
97 install-others = $(inst_includedir)/gnu/stubs.h
98 install-bin = glibcbug
100 ifeq (yes,$(build-shared))
101 install-others += $(inst_includedir)/gnu/lib-names.h
107 libc-init = munch-init
108 $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
109 awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
111 generated := $(generated) munch-init.c
117 # Install from subdirectories too.
118 install: subdir_install
120 # Create links for shared libraries using the `ldconfig' program is possible.
121 # Ignore the error if we cannot update /etc/ld.so.cache.
122 ifeq (no,$(cross-compiling))
123 ifeq (yes,$(build-shared))
125 -test ! -x $(common-objpfx)elf/ldconfig || \
126 $(common-objpfx)elf/ldconfig -d $(inst_slibdir) $(inst_libdir)
128 ifeq (/usr,$(prefix))
129 ifeq (,$(install_root))
130 CC="$(CC)" $(PERL) test-installation.pl $(common-objpfx)
137 # Build subdirectory lib objects.
138 lib-noranlib: subdir_lib
140 ifeq (yes,$(build-shared))
141 # Build the shared object from the PIC object library.
142 lib: $(common-objpfx)libc.so
145 all-Subdirs-files = $(wildcard $(addsuffix /Subdirs, $(config-sysdirs)))
146 $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files)
147 (echo define sysdep-subdirs; \
148 sed 's/#.*$$//' $(all-Subdirs-files) /dev/null; \
152 all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
153 $(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
154 (case $(config-os) in \
155 linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
157 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
158 if [ -z "$$version" ]; then \
159 if [ -r /proc/version ]; then \
160 version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
163 version=`uname -r`; \
166 echo -n "\"Compiled on a Linux $$version system "; \
167 echo "on `date +%Y-%m-%d`.\\n\"" ;; \
170 files="$(all-Banner-files)"; \
171 if test -n "$$files"; then \
172 echo "\"Available extensions:"; \
173 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
177 generated += version-info.h
179 version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes))
180 $(version.c-objects): $(objpfx)version-info.h
182 # Makerules creates a file `stub-$(subdir)' for each subdirectory, which
183 # contains `#define __stub_FUNCTION' for each function which is a stub.
184 # Here we paste all of these together into <gnu/stubs.h>.
186 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
188 # Since stubs.h is never needed when building the library, we simplify the
189 # hairy installation process by producing it in place only as the last part
190 # of the top-level `make install'. It depends on subdir_install, which
191 # iterates over all the subdirs; subdir_install in each subdir depends on
192 # the subdir's stubs file. Having more direct dependencies would result in
193 # extra iterations over the list for subdirs and many recursive makes.
194 $(inst_includedir)/gnu/stubs.h: subdir_install
195 $(make-target-directory)
196 @rm -f $(objpfx)stubs.h
197 (echo '/* This file is automatically generated.';\
198 echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\
199 echo ' in the C library which is a stub, meaning it will fail';\
200 echo ' every time called, usually setting errno to ENOSYS. */';\
201 sort $(subdir-stubs)) > $(objpfx)stubs.h
202 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
203 then echo 'stubs.h unchanged'; \
204 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
205 rm -f $(objpfx)stubs.h
207 ifeq (yes,$(build-shared))
209 $(inst_includedir)/gnu/lib-names.h: $(common-objpfx)gnu/lib-names.h
210 $(make-target-directory)
211 if test -r $@ && cmp -s $< $@; \
212 then echo 'gnu/lib-names.h unchanged'; \
213 else $(INSTALL_DATA) $< $@; fi
216 # The `glibcbug' script contains the version number and it shall be rebuild
217 # whenever this changes or the `glibcbug.in' file.
218 $(objpfx)glibcbug: $(common-objpfx)config.status glibcbug.in
219 cd $(<D); CONFIG_FILES=$(@F) CONFIG_HEADERS= $(SHELL) $(<F)
221 # This makes the Info or DVI file of the documentation from the Texinfo source.
224 $(MAKE) $(PARALLELMFLAGS) -C manual $@
226 # This makes all the subdirectory targets.
228 # For each target, make it depend on DIR/target for each subdirectory DIR.
229 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
231 # Compute a list of all those targets.
232 all-subdirs-targets := $(foreach dir,$(subdirs),\
233 $(addprefix $(dir)/,$(+subdir_targets)))
235 # The action for each of those is to cd into the directory and make the
237 $(all-subdirs-targets):
238 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
240 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
242 # Targets to clean things up to various degrees.
244 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
246 # Subroutines of all cleaning targets.
247 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
248 -rm -f $(foreach o,$(object-suffixes),\
249 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
250 $(addprefix $(objpfx),$(install-lib))
251 parent-clean: parent-mostlyclean common-clean
252 -rm -f $(addprefix $(common-objpfx),$(common-generated))
253 -rm -f $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules)
256 # This is done this way rather than having `subdir_clean' 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) subdir_clean no_deps=t
261 mostlyclean: parent-mostlyclean
262 @$(MAKE) subdir_mostlyclean no_deps=t
264 # The realclean target is just like distclean for the parent, but we want
265 # the subdirs to know the difference in case they care.
266 realclean distclean: parent-clean
267 # This is done this way rather than having `subdir_distclean' be a
268 # dependency of this target so that libc.a will be removed before the
269 # subdirectories are dealt with and so they won't try to remove object
270 # files from it when it's going to be removed anyway.
271 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes
273 # Subroutine of distclean and realclean.
274 distclean-1: subdir_$(distclean-1)
275 -rm -f $(config-generated)
276 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
277 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
278 -rm -f $(addprefix $(objpfx),glibcbug)
280 -rm -f $(objpfx)Makefile
282 -rm -f $(sysdep-$(distclean-1))
285 echo_subdirs:;@echo '$(subdirs)'
287 .PHONY: echo-distinfo parent_echo-distinfo
288 echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
289 parent_echo-distinfo:
290 @echo $(addprefix +header+,$(headers)) \
291 $(addprefix +nodist+,$(generated))
297 # Run a test on the header files we use.
298 parent-tests: $(objpfx)isomac
299 $(dir $<)$(notdir $<) '$(CC)' '-Iinclude $(+sysdep-includes)' > $<.out
301 $(objpfx)isomac: isomac.c
304 # Make the distribution tarfile.
306 distribute := README INSTALL FAQ NOTES NEWS PROJECTS BUGS \
307 COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
308 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
309 extra-lib.mk o-iterator.mk isomac.c \
310 libc.map mkinstalldirs move-if-change install-sh \
311 configure configure.in aclocal.m4 config.sub config.guess\
312 config.h.in config.make.in config-name.in Makefile.in \
313 autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \
314 sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
315 rpm/Makefile rpm/template rpm/rpmrc glibcbug.in abi-tags \
318 distribute := $(strip $(distribute))
319 generated := $(generated) stubs.h version-info.h
321 README: README.template version.h ; # Make-dist should update README.
325 makeinfo --no-validate --no-warn --no-headers $< -o $@
328 INSTALL: manual/maint.texi; $(format-me)
329 NOTES: manual/creature.texi; $(format-me)
330 manual/dir-add.texi manual/dir-add.info: FORCE
331 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
334 rpm/%: subdir_distinfo
335 $(MAKE) $(PARALLELMFLAGS) -C $(@D) subdirs='$(subdirs)' $(@F)
337 # This is a special goal for people making binary distributions. Normally
338 # everybody uses the DES based crypt library but for the distribution we
339 # need the only-MD5 based one as well.
340 md5-crypt/libmd5crypt:
341 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)