]> git.ipfire.org Git - thirdparty/glibc.git/blame - Makefile
Revert last change.
[thirdparty/glibc.git] / Makefile
CommitLineData
a2e1b046 1# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
28f540f4
RM
2# This file is part of the GNU C Library.
3
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.
8
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.
13
14# You should have received a copy of the GNU Library General Public
2c6fe0bd
UD
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.
28f540f4
RM
18
19#
20# Master Makefile for the GNU C library
21#
22ifneq (,)
23This makefile requires GNU Make.
24endif
25
26
27# This is the default target; it makes everything except the tests.
28.PHONY: all
edf5b2d7 29all: lib others
28f540f4
RM
30\f
31define autoconf-it
587dbc6f 32@-rm -f $@.new
28f540f4 33autoconf $(ACFLAGS) $< > $@.new
587dbc6f 34chmod a-w,a+x $@.new
28f540f4 35mv -f $@.new $@
a2fe9c76 36test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
28f540f4
RM
37endef
38
dbdb6189
RM
39configure: configure.in aclocal.m4; $(autoconf-it)
40%/configure: %/configure.in aclocal.m4; $(autoconf-it)
28f540f4
RM
41
42include Makeconfig
43
44ifndef avoid-generated
b86199fb 45-include $(objpfx)sysd-dirs
28f540f4
RM
46define \n
47
48
49endef
50sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
51endif
52
53# These are the subdirectories containing the library source.
a641835a 54subdirs = csu assert ctype db locale intl catgets math setjmp signal stdlib \
a482b5a5 55 stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd\
b8fe19fa 56 posix io termios resource misc login socket sysvipc gmon gnulib \
cccda09f 57 wctype manual shadow crypt $(sysdep-subdirs) nss elf po $(add-ons)
28f540f4
RM
58export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63.
59
60# The mach and hurd subdirectories have many generated header files which
24906b43 61# much of the rest of the library depends on, so it is best to build them
28f540f4
RM
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.
66subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
67 $(filter-out mach hurd,$(subdirs))
68
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)))
73
74
75# These are the targets that are made by making them in each subdirectory.
edf5b2d7
UD
76+subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
77 subdir_clean subdir_distclean subdir_realclean \
78 tests subdir_lint.out \
6a441471 79 subdir_distinfo \
28f540f4 80 subdir_echo-headers subdir_echo-distinfo \
57ba7bb4
UD
81 subdir_install \
82 $(addprefix install-, no-libc.a bin lib data headers others)
28f540f4 83\f
de9ba9bd 84headers := errno.h sys/errno.h errnos.h limits.h values.h \
2c6fe0bd 85 features.h gnu-versions.h libc-lock.h xopen_lim.h
28f540f4 86aux = sysdep $(libc-init) version
ba1ffaa1 87before-compile = $(objpfx)version-info.h
28f540f4
RM
88
89echo-headers: subdir_echo-headers
90
91# What to install.
afd4eb37 92install-others = $(includedir)/stubs.h
28f540f4
RM
93
94ifeq (yes,$(gnu-ld))
95libc-init = set-init
96else
97libc-init = munch-init
98$(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
99 awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
100 mv -f $@-t $@
101generated := $(generated) munch-init.c
102endif
103
104
105include Makerules
106
107# Install from subdirectories too.
108install: subdir_install
109
01a36ad3
RM
110# Build subdirectory lib objects.
111lib-noranlib: subdir_lib
28f540f4 112
01a36ad3
RM
113ifeq (yes,$(build-shared))
114# Build the shared object from the PIC object library.
115lib: $(common-objpfx)libc.so
116endif
28f540f4 117
c4029823
UD
118all-Subdirs-files = $(wildcard $(addsuffix /Subdirs, $(config-sysdirs)))
119$(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files)
120 (echo define sysdep-subdirs; \
121 sed 's/#.*$$//' $(all-Subdirs-files) /dev/null; \
28f540f4 122 echo endef) > $@-tmp
c4029823 123 mv -f $@-tmp $@
28f540f4 124\f
c4029823
UD
125all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
126$(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
0d204b0a
UD
127 (case $(config-os) in \
128 linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
129 | $(CC) -E -P - | \
130 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
131 if [ -z "$$version" ]; then \
132 if [ -r /proc/version ]; then \
133 version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
134 < /proc/version`; \
135 else \
136 version=`uname -r`; \
137 fi; \
138 fi; \
139 echo -n "\"Compiled on a Linux $$version system "; \
140 echo "on `date +%Y/%m/%d`.\\n\"" ;; \
141 *) ;; \
142 esac; \
143 files="$(all-Banner-files)"; \
a68b0d31 144 if test -n "$$files"; then \
c4029823
UD
145 echo "\"Available extensions:"; \
146 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
147 echo "\""; \
6ed0492f
UD
148 fi) > $@T
149 mv -f $@T $@
150generated += version-info.h
499e7464
UD
151
152version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes))
153$(version.c-objects): $(objpfx)version-info.h
154\f
28f540f4
RM
155# Makerules creates a file `stub-$(subdir)' for each subdirectory, which
156# contains `#define __stub_FUNCTION' for each function which is a stub.
157# Here we paste all of these together into <stubs.h>.
158
159subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
160
161# Since stubs.h is never needed when building the library, we simplify the
162# hairy installation process by producing it in place only as the last part
163# of the top-level `make install'. It depends on subdir_install, which
164# iterates over all the subdirs; subdir_install in each subdir depends on
165# the subdir's stubs file. Having more direct dependencies would result in
166# extra iterations over the list for subdirs and many recursive makes.
167$(includedir)/stubs.h: subdir_install
168 @rm -f $(objpfx)stubs.h
169 (echo '/* This file is automatically generated.';\
170 echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\
171 echo ' in the C library which is a stub, meaning it will fail';\
172 echo ' every time called, usually setting errno to ENOSYS. */';\
173 sort $(subdir-stubs)) > $(objpfx)stubs.h
13a0be88 174 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
ba1ffaa1 175 then echo 'stubs.h unchanged'; \
d36e7692 176 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
28f540f4
RM
177 rm -f $(objpfx)stubs.h
178\f
afd4eb37
UD
179ifeq (yes, $(build-shared))
180
ba1ffaa1
UD
181# Like stubs.h the gnu/lib-names.h header is not used while building the
182# libc itself. So we generate it while installing.
183$(includedir)/gnu/lib-names.h: $(common-objpfx)soversions.mk
184 @rm -f $(objpfx)lib-names.h
185 (echo '/* This file is automatically generated.';\
186 echo ' It defines macros to allow user program to find the shared';\
187 echo ' library files which come as part of GNU libc. */';\
188 echo '#ifndef __GNU_LIB_NAMES_H'; \
189 echo '#define __GNU_LIB_NAMES_H 1'; \
190 echo; \
191 (libs='$(all-sonames)';\
192 for l in $$libs; do \
26761c28
UD
193 upname=`echo $$l | sed 's/[.]so.*//' | \
194 tr '[:lower:]-' '[:upper:]_'`; \
ba1ffaa1
UD
195 echo "#define $${upname}_SO $$l"; \
196 done;) | sort; \
197 echo; \
198 echo '#endif /* gnu/lib-names.h */';) > $(objpfx)lib-names.h
199 if test -r $@ && cmp -s $(objpfx)lib-names.h $@; \
200 then echo 'gnu/lib-names.h unchanged'; \
201 else $(INSTALL_DATA) $(objpfx)lib-names.h $@; fi
202 rm -f $(objpfx)lib-names.h
afd4eb37
UD
203
204install-others += $(includedir)/gnu/lib-names.h
205endif
ba1ffaa1 206\f
28f540f4
RM
207# This makes the Info or DVI file of the documentation from the Texinfo source.
208.PHONY: info dvi
209info dvi:
210 $(MAKE) -C manual $@
211\f
212# This makes all the subdirectory targets.
213
214# For each target, make it depend on DIR/target for each subdirectory DIR.
215$(+subdir_targets): %: $(addsuffix /%,$(subdirs))
216
217# Compute a list of all those targets.
218all-subdirs-targets := $(foreach dir,$(subdirs),\
219 $(addprefix $(dir)/,$(+subdir_targets)))
220
221# The action for each of those is to cd into the directory and make the
222# target there.
223$(all-subdirs-targets):
224 $(MAKE) -C $(@D) $(@F)
225
226.PHONY: $(+subdir_targets) $(all-subdirs-targets)
227\f
228# Targets to clean things up to various degrees.
229
230.PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
231
232# Subroutines of all cleaning targets.
233parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
60092701
RM
234 -rm -f $(foreach o,$(object-suffixes),\
235 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
236 $(addprefix $(objpfx),$(install-lib))
28f540f4
RM
237parent-clean: parent-mostlyclean common-clean
238 -rm -f $(addprefix $(common-objpfx),$(common-generated))
6bf02878 239 -rm -f $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules)
28f540f4
RM
240
241clean: 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
247mostlyclean: parent-mostlyclean
248 @$(MAKE) subdir_mostlyclean no_deps=t
249
250# The realclean target is just like distclean for the parent, but we want
251# the subdirs to know the difference in case they care.
252realclean distclean: parent-clean
253# This is done this way rather than having `subdir_distclean' be a
254# dependency of this target so that libc.a will be removed before the
255# subdirectories are dealt with and so they won't try to remove object
256# files from it when it's going to be removed anyway.
257 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes
258
259# Subroutine of distclean and realclean.
260distclean-1: subdir_$(distclean-1)
261 -rm -f $(config-generated)
60092701
RM
262 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
263 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
28f540f4
RM
264ifdef objdir
265 -rm -f $(objpfx)Makefile
266endif
267 -rm -f $(sysdep-$(distclean-1))
268\f
269.PHONY: echo_subdirs
270echo_subdirs:;@echo '$(subdirs)'
271
272.PHONY: echo-distinfo parent_echo-distinfo
273echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
274parent_echo-distinfo:
275 @echo $(addprefix +header+,$(headers)) \
276 $(addprefix +nodist+,$(generated))
6a441471 277
28f540f4
RM
278\f
279# Make the distribution tarfile.
280
0200214b 281distribute := README INSTALL FAQ NOTES NEWS PROJECTS \
9f447fb3 282 COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
28f540f4 283 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
693e7b96 284 extra-lib.mk o-iterator.mk \
28f540f4
RM
285 ansidecl.h mkinstalldirs move-if-change install-sh \
286 configure configure.in aclocal.m4 config.sub config.guess\
9f447fb3 287 config.h.in config.make.in config-name.in Makefile.in \
f0e44959 288 autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \
748050b3 289 sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
1f64ac13 290 rpm/Makefile rpm/template rpm/rpmrc nsswitch.h netgroup.h
28f540f4
RM
291
292distribute := $(strip $(distribute))
f0f1bf85 293generated := $(generated) stubs.h version-info.h
28f540f4
RM
294
295README: README.template version.c ; # Make-dist should update README.
296
297define format-me
298@rm -f $@
299makeinfo --no-validate --no-warn --no-headers $< -o $@
300-chmod a-w $@
301endef
302INSTALL: manual/maint.texi; $(format-me)
303NOTES: manual/creature.texi; $(format-me)
6a441471
RM
304
305rpm/%: subdir_distinfo
306 $(MAKE) -C $(@D) subdirs='$(subdirs)' $(@F)