]>
Commit | Line | Data |
---|---|---|
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 | |
15 | # License along with the GNU C Library; see the file COPYING.LIB. If | |
16 | # not, write to the Free Software Foundation, Inc., 675 Mass Ave, | |
17 | # Cambridge, MA 02139, USA. | |
18 | ||
19 | # | |
20 | # Master Makefile for the GNU C library | |
21 | # | |
22 | ifneq (,) | |
23 | This makefile requires GNU Make. | |
24 | endif | |
25 | ||
26 | ||
27 | # This is the default target; it makes everything except the tests. | |
28 | .PHONY: all | |
edf5b2d7 | 29 | all: lib others |
28f540f4 RM |
30 | \f |
31 | define autoconf-it | |
587dbc6f | 32 | @-rm -f $@.new |
28f540f4 | 33 | autoconf $(ACFLAGS) $< > $@.new |
587dbc6f | 34 | chmod a-w,a+x $@.new |
28f540f4 | 35 | mv -f $@.new $@ |
a2fe9c76 | 36 | test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@ |
28f540f4 RM |
37 | endef |
38 | ||
dbdb6189 RM |
39 | configure: configure.in aclocal.m4; $(autoconf-it) |
40 | %/configure: %/configure.in aclocal.m4; $(autoconf-it) | |
28f540f4 RM |
41 | |
42 | include Makeconfig | |
43 | ||
44 | ifndef avoid-generated | |
b86199fb | 45 | -include $(objpfx)sysd-dirs |
28f540f4 RM |
46 | define \n |
47 | ||
48 | ||
49 | endef | |
50 | sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs)) | |
51 | endif | |
52 | ||
53 | # These are the subdirectories containing the library source. | |
a641835a | 54 | subdirs = 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 \ |
a8922de8 | 57 | wctype manual shadow $(sysdep-subdirs) nss elf po $(add-ons) |
28f540f4 RM |
58 | export 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. | |
66 | subdirs := $(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 | 84 | headers := errno.h sys/errno.h errnos.h limits.h values.h \ |
3d3ac840 | 85 | features.h gnu-versions.h libc-lock.h |
28f540f4 | 86 | aux = sysdep $(libc-init) version |
f0f1bf85 | 87 | before-compile = $(objpfx)version-info.h |
28f540f4 RM |
88 | |
89 | echo-headers: subdir_echo-headers | |
90 | ||
91 | # What to install. | |
92 | install-others = $(includedir)/stubs.h | |
93 | ||
94 | ifeq (yes,$(gnu-ld)) | |
95 | libc-init = set-init | |
96 | else | |
97 | libc-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 $@ | |
101 | generated := $(generated) munch-init.c | |
102 | endif | |
103 | ||
104 | ||
105 | include Makerules | |
106 | ||
107 | # Install from subdirectories too. | |
108 | install: subdir_install | |
109 | ||
01a36ad3 RM |
110 | # Build subdirectory lib objects. |
111 | lib-noranlib: subdir_lib | |
28f540f4 | 112 | |
01a36ad3 RM |
113 | ifeq (yes,$(build-shared)) |
114 | # Build the shared object from the PIC object library. | |
115 | lib: $(common-objpfx)libc.so | |
116 | endif | |
28f540f4 RM |
117 | |
118 | $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make | |
119 | (echo define sysdep-subdirs; \ | |
57ba7bb4 UD |
120 | for sysdir in $(config-sysdirs); do \ |
121 | case $$sysdir in \ | |
122 | /*) dir=$$sysdir ;; \ | |
123 | *) dir=$(..)$$sysdir ;; \ | |
124 | esac; \ | |
125 | if [ -r $$dir/Subdirs ]; then \ | |
126 | sed 's/#.*$$//' $$dir/Subdirs; \ | |
28f540f4 RM |
127 | else true; \ |
128 | fi; \ | |
129 | done; \ | |
130 | echo endef) > $@-tmp | |
131 | mv -f $@-tmp $@ | |
132 | \f | |
499e7464 UD |
133 | $(objpfx)version-info.h: $(..)Makefile $(+sysdir_pfx)config.make |
134 | (first=yes; \ | |
135 | for dir in $(subdirs); do \ | |
136 | if [ -r $$dir/Banner ]; then \ | |
137 | if [ $$first = yes ]; then \ | |
138 | echo "\"Available extensions:"; \ | |
139 | first=no; \ | |
140 | fi; \ | |
141 | sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$dir/Banner; \ | |
142 | fi; \ | |
143 | done; \ | |
da74e902 | 144 | [ $$first = yes ] || echo "\"") > $@-tmp |
499e7464 UD |
145 | mv -f $@-tmp $@ |
146 | ||
147 | version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes)) | |
148 | $(version.c-objects): $(objpfx)version-info.h | |
149 | \f | |
28f540f4 RM |
150 | # Makerules creates a file `stub-$(subdir)' for each subdirectory, which |
151 | # contains `#define __stub_FUNCTION' for each function which is a stub. | |
152 | # Here we paste all of these together into <stubs.h>. | |
153 | ||
154 | subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir)) | |
155 | ||
156 | # Since stubs.h is never needed when building the library, we simplify the | |
157 | # hairy installation process by producing it in place only as the last part | |
158 | # of the top-level `make install'. It depends on subdir_install, which | |
159 | # iterates over all the subdirs; subdir_install in each subdir depends on | |
160 | # the subdir's stubs file. Having more direct dependencies would result in | |
161 | # extra iterations over the list for subdirs and many recursive makes. | |
162 | $(includedir)/stubs.h: subdir_install | |
163 | @rm -f $(objpfx)stubs.h | |
164 | (echo '/* This file is automatically generated.';\ | |
165 | echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\ | |
166 | echo ' in the C library which is a stub, meaning it will fail';\ | |
167 | echo ' every time called, usually setting errno to ENOSYS. */';\ | |
168 | sort $(subdir-stubs)) > $(objpfx)stubs.h | |
13a0be88 | 169 | if test -r $@ && cmp -s $(objpfx)stubs.h $@; \ |
80791291 | 170 | then echo stubs.h unchanged ; \ |
d36e7692 | 171 | else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi |
28f540f4 RM |
172 | rm -f $(objpfx)stubs.h |
173 | \f | |
174 | # This makes the Info or DVI file of the documentation from the Texinfo source. | |
175 | .PHONY: info dvi | |
176 | info dvi: | |
177 | $(MAKE) -C manual $@ | |
178 | \f | |
179 | # This makes all the subdirectory targets. | |
180 | ||
181 | # For each target, make it depend on DIR/target for each subdirectory DIR. | |
182 | $(+subdir_targets): %: $(addsuffix /%,$(subdirs)) | |
183 | ||
184 | # Compute a list of all those targets. | |
185 | all-subdirs-targets := $(foreach dir,$(subdirs),\ | |
186 | $(addprefix $(dir)/,$(+subdir_targets))) | |
187 | ||
188 | # The action for each of those is to cd into the directory and make the | |
189 | # target there. | |
190 | $(all-subdirs-targets): | |
191 | $(MAKE) -C $(@D) $(@F) | |
192 | ||
193 | .PHONY: $(+subdir_targets) $(all-subdirs-targets) | |
194 | \f | |
195 | # Targets to clean things up to various degrees. | |
196 | ||
197 | .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean | |
198 | ||
199 | # Subroutines of all cleaning targets. | |
200 | parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules. | |
60092701 RM |
201 | -rm -f $(foreach o,$(object-suffixes),\ |
202 | $(common-objpfx)$(patsubst %,$(libtype$o),c)) \ | |
203 | $(addprefix $(objpfx),$(install-lib)) | |
28f540f4 RM |
204 | parent-clean: parent-mostlyclean common-clean |
205 | -rm -f $(addprefix $(common-objpfx),$(common-generated)) | |
6bf02878 | 206 | -rm -f $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules) |
28f540f4 RM |
207 | |
208 | clean: parent-clean | |
209 | # This is done this way rather than having `subdir_clean' be a | |
210 | # dependency of this target so that libc.a will be removed before the | |
211 | # subdirectories are dealt with and so they won't try to remove object | |
212 | # files from it when it's going to be removed anyway. | |
213 | @$(MAKE) subdir_clean no_deps=t | |
214 | mostlyclean: parent-mostlyclean | |
215 | @$(MAKE) subdir_mostlyclean no_deps=t | |
216 | ||
217 | # The realclean target is just like distclean for the parent, but we want | |
218 | # the subdirs to know the difference in case they care. | |
219 | realclean distclean: parent-clean | |
220 | # This is done this way rather than having `subdir_distclean' be a | |
221 | # dependency of this target so that libc.a will be removed before the | |
222 | # subdirectories are dealt with and so they won't try to remove object | |
223 | # files from it when it's going to be removed anyway. | |
224 | @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes | |
225 | ||
226 | # Subroutine of distclean and realclean. | |
227 | distclean-1: subdir_$(distclean-1) | |
228 | -rm -f $(config-generated) | |
60092701 RM |
229 | -rm -f $(addprefix $(objpfx),config.status config.cache config.log) |
230 | -rm -f $(addprefix $(objpfx),config.make config-name.h config.h) | |
28f540f4 RM |
231 | ifdef objdir |
232 | -rm -f $(objpfx)Makefile | |
233 | endif | |
234 | -rm -f $(sysdep-$(distclean-1)) | |
235 | \f | |
236 | .PHONY: echo_subdirs | |
237 | echo_subdirs:;@echo '$(subdirs)' | |
238 | ||
239 | .PHONY: echo-distinfo parent_echo-distinfo | |
240 | echo-distinfo: parent_echo-distinfo subdir_echo-distinfo | |
241 | parent_echo-distinfo: | |
242 | @echo $(addprefix +header+,$(headers)) \ | |
243 | $(addprefix +nodist+,$(generated)) | |
6a441471 | 244 | |
28f540f4 RM |
245 | \f |
246 | # Make the distribution tarfile. | |
247 | ||
0200214b | 248 | distribute := README INSTALL FAQ NOTES NEWS PROJECTS \ |
9f447fb3 | 249 | COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \ |
28f540f4 | 250 | Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \ |
693e7b96 | 251 | extra-lib.mk o-iterator.mk \ |
28f540f4 RM |
252 | ansidecl.h mkinstalldirs move-if-change install-sh \ |
253 | configure configure.in aclocal.m4 config.sub config.guess\ | |
9f447fb3 | 254 | config.h.in config.make.in config-name.in Makefile.in \ |
f0f1bf85 | 255 | autolock.sh munch-tmpl.c munch.awk interp.c \ |
748050b3 RM |
256 | sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \ |
257 | rpm/Makefile rpm/template rpm/rpmrc | |
28f540f4 RM |
258 | |
259 | distribute := $(strip $(distribute)) | |
f0f1bf85 | 260 | generated := $(generated) stubs.h version-info.h |
28f540f4 RM |
261 | |
262 | README: README.template version.c ; # Make-dist should update README. | |
263 | ||
264 | define format-me | |
265 | @rm -f $@ | |
266 | makeinfo --no-validate --no-warn --no-headers $< -o $@ | |
267 | -chmod a-w $@ | |
268 | endef | |
269 | INSTALL: manual/maint.texi; $(format-me) | |
270 | NOTES: manual/creature.texi; $(format-me) | |
6a441471 RM |
271 | |
272 | rpm/%: subdir_distinfo | |
273 | $(MAKE) -C $(@D) subdirs='$(subdirs)' $(@F) |