update from main archive 961208
[glibc.git] / Makefile
blob7ebd3b7bd1cf16a8cdf828df543248e7c09d01af
1 # Copyright (C) 1991, 92, 93, 94, 95, 96 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
27 # This is the default target; it makes everything except the tests.
28 .PHONY: all
29 all: lib others
31 define autoconf-it
32 @-rm -f $@.new
33 autoconf $(ACFLAGS) $< > $@.new
34 chmod a-w,a+x $@.new
35 mv -f $@.new $@
36 test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
37 endef
39 configure: configure.in aclocal.m4; $(autoconf-it)
40 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
42 include Makeconfig
44 ifndef avoid-generated
45 -include $(objpfx)sysd-dirs
46 define \n
49 endef
50 sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
51 endif
53 # These are the subdirectories containing the library source.
54 subdirs = csu assert ctype db locale intl catgets math setjmp signal stdlib \
55 stdio-common $(stdio) $(malloc) string wcsmbs time dirent grp pwd \
56 posix io termios resource misc login socket sysvipc gmon gnulib \
57 wctype manual shadow crypt $(sysdep-subdirs) nss elf po $(add-ons)
58 export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63.
60 # The mach and hurd subdirectories have many generated header files which
61 # much of the rest of the library depends on, so it is best to build them
62 # first (and mach before hurd, at that). The before-compile additions in
63 # sysdeps/{mach,hurd}/Makefile should make it reliably work for these files
64 # not to exist when making in other directories, but it will be slower that
65 # way with more somewhat expensive `make' invocations.
66 subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
67 $(filter-out mach hurd,$(subdirs))
69 # All initialization source files.
70 +subdir_inits := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
71 # All subdirectories containing initialization source files.
72 +init_subdirs := $(patsubst %/,%,$(dir $(+subdir_inits)))
75 # These are the targets that are made by making them in each subdirectory.
76 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
77 subdir_clean subdir_distclean subdir_realclean \
78 tests subdir_lint.out \
79 subdir_distinfo \
80 subdir_echo-headers subdir_echo-distinfo \
81 subdir_install \
82 $(addprefix install-, no-libc.a bin lib data headers others)
84 headers := errno.h sys/errno.h errnos.h limits.h values.h \
85 features.h gnu-versions.h libc-lock.h xopen_lim.h
86 aux = sysdep $(libc-init) version
87 before-compile = $(objpfx)version-info.h
89 echo-headers: subdir_echo-headers
91 # What to install.
92 install-others = $(includedir)/stubs.h
93 ifeq (yes,$(build-shared))
94 install-others += $(includedir)/gnu/lib-names.h
95 endif
97 ifeq (yes,$(gnu-ld))
98 libc-init = set-init
99 else
100 libc-init = munch-init
101 $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
102 awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
103 mv -f $@-t $@
104 generated := $(generated) munch-init.c
105 endif
108 include Makerules
110 # Install from subdirectories too.
111 install: subdir_install
113 # Build subdirectory lib objects.
114 lib-noranlib: subdir_lib
116 ifeq (yes,$(build-shared))
117 # Build the shared object from the PIC object library.
118 lib: $(common-objpfx)libc.so
119 endif
121 all-Subdirs-files = $(wildcard $(addsuffix /Subdirs, $(config-sysdirs)))
122 $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files)
123 (echo define sysdep-subdirs; \
124 sed 's/#.*$$//' $(all-Subdirs-files) /dev/null; \
125 echo endef) > $@-tmp
126 mv -f $@-tmp $@
128 all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
129 $(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
130 (case $(config-os) in \
131 linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
132 | $(CC) -E -P - | \
133 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
134 if [ -z "$$version" ]; then \
135 if [ -r /proc/version ]; then \
136 version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
137 < /proc/version`; \
138 else \
139 version=`uname -r`; \
140 fi; \
141 fi; \
142 echo -n "\"Compiled on a Linux $$version system "; \
143 echo "on `date +%Y/%m/%d`.\\n\"" ;; \
144 *) ;; \
145 esac; \
146 files="$(all-Banner-files)"; \
147 if test -n "$$files"; then \
148 echo "\"Available extensions:"; \
149 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
150 echo "\""; \
151 fi) > $@T
152 mv -f $@T $@
153 generated += version-info.h
155 version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes))
156 $(version.c-objects): $(objpfx)version-info.h
158 # Makerules creates a file `stub-$(subdir)' for each subdirectory, which
159 # contains `#define __stub_FUNCTION' for each function which is a stub.
160 # Here we paste all of these together into <stubs.h>.
162 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
164 # Since stubs.h is never needed when building the library, we simplify the
165 # hairy installation process by producing it in place only as the last part
166 # of the top-level `make install'. It depends on subdir_install, which
167 # iterates over all the subdirs; subdir_install in each subdir depends on
168 # the subdir's stubs file. Having more direct dependencies would result in
169 # extra iterations over the list for subdirs and many recursive makes.
170 $(includedir)/stubs.h: subdir_install
171 @rm -f $(objpfx)stubs.h
172 (echo '/* This file is automatically generated.';\
173 echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\
174 echo ' in the C library which is a stub, meaning it will fail';\
175 echo ' every time called, usually setting errno to ENOSYS. */';\
176 sort $(subdir-stubs)) > $(objpfx)stubs.h
177 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
178 then echo 'stubs.h unchanged'; \
179 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
180 rm -f $(objpfx)stubs.h
182 ifeq (yes,$(build-shared))
184 # Like stubs.h the gnu/lib-names.h header is not used while building the
185 # libc itself. So we generate it while installing.
186 $(includedir)/gnu/lib-names.h: $(common-objpfx)soversions.mk
187 @rm -f $(objpfx)lib-names.h
188 (echo '/* This file is automatically generated.';\
189 echo ' It defines macros to allow user program to find the shared';\
190 echo ' library files which come as part of GNU libc. */';\
191 echo '#ifndef __GNU_LIB_NAMES_H'; \
192 echo '#define __GNU_LIB_NAMES_H 1'; \
193 echo; \
194 (libs='$(all-sonames)';\
195 for l in $$libs; do \
196 upname=`echo $$l | sed 's/[.]so.*//' | \
197 tr '[:lower:]-' '[:upper:]_'`; \
198 echo "#define $${upname}_SO $$l"; \
199 done;) | sort; \
200 echo; \
201 echo '#endif /* gnu/lib-names.h */';) > $(objpfx)lib-names.h
202 if test -r $@ && cmp -s $(objpfx)lib-names.h $@; \
203 then echo 'gnu/lib-names.h unchanged'; \
204 else $(INSTALL_DATA) $(objpfx)lib-names.h $@; fi
205 rm -f $(objpfx)lib-names.h
206 endif
208 # This makes the Info or DVI file of the documentation from the Texinfo source.
209 .PHONY: info dvi
210 info dvi:
211 $(MAKE) -C manual $@
213 # This makes all the subdirectory targets.
215 # For each target, make it depend on DIR/target for each subdirectory DIR.
216 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
218 # Compute a list of all those targets.
219 all-subdirs-targets := $(foreach dir,$(subdirs),\
220 $(addprefix $(dir)/,$(+subdir_targets)))
222 # The action for each of those is to cd into the directory and make the
223 # target there.
224 $(all-subdirs-targets):
225 $(MAKE) -C $(@D) $(@F)
227 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
229 # Targets to clean things up to various degrees.
231 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
233 # Subroutines of all cleaning targets.
234 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
235 -rm -f $(foreach o,$(object-suffixes),\
236 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
237 $(addprefix $(objpfx),$(install-lib))
238 parent-clean: parent-mostlyclean common-clean
239 -rm -f $(addprefix $(common-objpfx),$(common-generated))
240 -rm -f $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules)
242 clean: parent-clean
243 # This is done this way rather than having `subdir_clean' be a
244 # dependency of this target so that libc.a will be removed before the
245 # subdirectories are dealt with and so they won't try to remove object
246 # files from it when it's going to be removed anyway.
247 @$(MAKE) subdir_clean no_deps=t
248 mostlyclean: parent-mostlyclean
249 @$(MAKE) subdir_mostlyclean no_deps=t
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
260 # Subroutine of distclean and realclean.
261 distclean-1: subdir_$(distclean-1)
262 -rm -f $(config-generated)
263 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
264 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
265 ifdef objdir
266 -rm -f $(objpfx)Makefile
267 endif
268 -rm -f $(sysdep-$(distclean-1))
270 .PHONY: echo_subdirs
271 echo_subdirs:;@echo '$(subdirs)'
273 .PHONY: echo-distinfo parent_echo-distinfo
274 echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
275 parent_echo-distinfo:
276 @echo $(addprefix +header+,$(headers)) \
277 $(addprefix +nodist+,$(generated))
280 # Make the distribution tarfile.
282 distribute := README INSTALL FAQ NOTES NEWS PROJECTS \
283 COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
284 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
285 extra-lib.mk o-iterator.mk \
286 ansidecl.h mkinstalldirs move-if-change install-sh \
287 configure configure.in aclocal.m4 config.sub config.guess\
288 config.h.in config.make.in config-name.in Makefile.in \
289 autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \
290 sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
291 rpm/Makefile rpm/template rpm/rpmrc nsswitch.h netgroup.h
293 distribute := $(strip $(distribute))
294 generated := $(generated) stubs.h version-info.h
296 README: README.template version.c ; # Make-dist should update README.
298 define format-me
299 @rm -f $@
300 makeinfo --no-validate --no-warn --no-headers $< -o $@
301 -chmod a-w $@
302 endef
303 INSTALL: manual/maint.texi; $(format-me)
304 NOTES: manual/creature.texi; $(format-me)
306 rpm/%: subdir_distinfo
307 $(MAKE) -C $(@D) subdirs='$(subdirs)' $(@F)