]>
Commit | Line | Data |
---|---|---|
df4ef2ab | 1 | # Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 | # | |
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 \ |
33a934a3 | 55 | stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd \ |
b8fe19fa | 56 | posix io termios resource misc login socket sysvipc gmon gnulib \ |
c84142e8 | 57 | wctype manual shadow md5-crypt nss $(sysdep-subdirs) po argp \ |
0501d603 | 58 | $(add-ons) $(binfmt-subdir) |
28f540f4 RM |
59 | export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63. |
60 | ||
61 | # The mach and hurd subdirectories have many generated header files which | |
24906b43 | 62 | # much of the rest of the library depends on, so it is best to build them |
28f540f4 RM |
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)) | |
69 | ||
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))) | |
74 | ||
75 | ||
76 | # These are the targets that are made by making them in each subdirectory. | |
edf5b2d7 UD |
77 | +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \ |
78 | subdir_clean subdir_distclean subdir_realclean \ | |
79 | tests subdir_lint.out \ | |
6a441471 | 80 | subdir_distinfo \ |
28f540f4 | 81 | subdir_echo-headers subdir_echo-distinfo \ |
57ba7bb4 UD |
82 | subdir_install \ |
83 | $(addprefix install-, no-libc.a bin lib data headers others) | |
28f540f4 | 84 | \f |
de9ba9bd | 85 | headers := errno.h sys/errno.h errnos.h limits.h values.h \ |
2c6fe0bd | 86 | features.h gnu-versions.h libc-lock.h xopen_lim.h |
28f540f4 | 87 | aux = sysdep $(libc-init) version |
7cc27f44 | 88 | before-compile += $(objpfx)version-info.h |
28f540f4 RM |
89 | |
90 | echo-headers: subdir_echo-headers | |
91 | ||
92 | # What to install. | |
8d57beea | 93 | install-others = $(inst_includedir)/gnu/stubs.h |
56552e42 UD |
94 | install-bin = glibcbug |
95 | ||
a18f587d | 96 | ifeq (yes,$(build-shared)) |
c0e45674 | 97 | install-others += $(inst_includedir)/gnu/lib-names.h |
a18f587d | 98 | endif |
28f540f4 RM |
99 | |
100 | ifeq (yes,$(gnu-ld)) | |
101 | libc-init = set-init | |
102 | else | |
103 | libc-init = munch-init | |
104 | $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits) | |
105 | awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t | |
106 | mv -f $@-t $@ | |
107 | generated := $(generated) munch-init.c | |
108 | endif | |
109 | ||
110 | ||
111 | include Makerules | |
112 | ||
113 | # Install from subdirectories too. | |
114 | install: subdir_install | |
8d57beea UD |
115 | |
116 | # Create linkfs for shared libraries using the `ldconfig' program is possible. | |
7cc27f44 | 117 | # Ignore the error if we cannot update /etc/ld.so.cache. |
1ef32c3d UD |
118 | ifeq (no,$(cross-compiling)) |
119 | ifeq (yes,$(build-shared)) | |
8d57beea | 120 | install: |
7cc27f44 | 121 | -test ! -x $(common-objpfx)elf/ldconfig || \ |
1228ed5c | 122 | $(common-objpfx)elf/ldconfig -d $(inst_slibdir) $(inst_libdir) |
1ef32c3d UD |
123 | endif |
124 | endif | |
28f540f4 | 125 | |
01a36ad3 RM |
126 | # Build subdirectory lib objects. |
127 | lib-noranlib: subdir_lib | |
28f540f4 | 128 | |
01a36ad3 RM |
129 | ifeq (yes,$(build-shared)) |
130 | # Build the shared object from the PIC object library. | |
131 | lib: $(common-objpfx)libc.so | |
132 | endif | |
28f540f4 | 133 | |
377a515b UD |
134 | # We have a versioning file for libc.so. |
135 | #libc-map = libc.map | |
136 | ||
c4029823 UD |
137 | all-Subdirs-files = $(wildcard $(addsuffix /Subdirs, $(config-sysdirs))) |
138 | $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files) | |
139 | (echo define sysdep-subdirs; \ | |
140 | sed 's/#.*$$//' $(all-Subdirs-files) /dev/null; \ | |
28f540f4 | 141 | echo endef) > $@-tmp |
c4029823 | 142 | mv -f $@-tmp $@ |
28f540f4 | 143 | \f |
c4029823 UD |
144 | all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs))) |
145 | $(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files) | |
0d204b0a UD |
146 | (case $(config-os) in \ |
147 | linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\ | |
148 | | $(CC) -E -P - | \ | |
149 | sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\ | |
150 | if [ -z "$$version" ]; then \ | |
151 | if [ -r /proc/version ]; then \ | |
152 | version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \ | |
153 | < /proc/version`; \ | |
154 | else \ | |
155 | version=`uname -r`; \ | |
156 | fi; \ | |
157 | fi; \ | |
158 | echo -n "\"Compiled on a Linux $$version system "; \ | |
159 | echo "on `date +%Y/%m/%d`.\\n\"" ;; \ | |
160 | *) ;; \ | |
161 | esac; \ | |
162 | files="$(all-Banner-files)"; \ | |
a68b0d31 | 163 | if test -n "$$files"; then \ |
c4029823 UD |
164 | echo "\"Available extensions:"; \ |
165 | sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \ | |
166 | echo "\""; \ | |
6ed0492f UD |
167 | fi) > $@T |
168 | mv -f $@T $@ | |
169 | generated += version-info.h | |
499e7464 UD |
170 | |
171 | version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes)) | |
172 | $(version.c-objects): $(objpfx)version-info.h | |
173 | \f | |
28f540f4 RM |
174 | # Makerules creates a file `stub-$(subdir)' for each subdirectory, which |
175 | # contains `#define __stub_FUNCTION' for each function which is a stub. | |
6bc31da0 | 176 | # Here we paste all of these together into <gnu/stubs.h>. |
28f540f4 RM |
177 | |
178 | subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir)) | |
179 | ||
180 | # Since stubs.h is never needed when building the library, we simplify the | |
181 | # hairy installation process by producing it in place only as the last part | |
182 | # of the top-level `make install'. It depends on subdir_install, which | |
183 | # iterates over all the subdirs; subdir_install in each subdir depends on | |
184 | # the subdir's stubs file. Having more direct dependencies would result in | |
185 | # extra iterations over the list for subdirs and many recursive makes. | |
8d57beea | 186 | $(inst_includedir)/gnu/stubs.h: subdir_install |
28f540f4 RM |
187 | @rm -f $(objpfx)stubs.h |
188 | (echo '/* This file is automatically generated.';\ | |
189 | echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\ | |
190 | echo ' in the C library which is a stub, meaning it will fail';\ | |
191 | echo ' every time called, usually setting errno to ENOSYS. */';\ | |
192 | sort $(subdir-stubs)) > $(objpfx)stubs.h | |
13a0be88 | 193 | if test -r $@ && cmp -s $(objpfx)stubs.h $@; \ |
ba1ffaa1 | 194 | then echo 'stubs.h unchanged'; \ |
d36e7692 | 195 | else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi |
28f540f4 RM |
196 | rm -f $(objpfx)stubs.h |
197 | \f | |
8a523922 | 198 | ifeq (yes,$(build-shared)) |
afd4eb37 | 199 | |
c0e45674 | 200 | $(inst_includedir)/gnu/lib-names.h: $(common-objpfx)gnu/lib-names.h |
56552e42 UD |
201 | if test -r $@ && cmp -s $< $@; \ |
202 | then echo 'gnu/lib-names.h unchanged'; \ | |
203 | else $(INSTALL_DATA) $< $@; fi | |
afd4eb37 | 204 | endif |
ba1ffaa1 | 205 | \f |
df4ef2ab UD |
206 | # The `glibcbug' script contains the version number and it shall be rebuild |
207 | # whenever this changes or the `glibcbug.in' file. | |
5290baf0 UD |
208 | $(objpfx)glibcbug: $(common-objpfx)config.status glibcbug.in |
209 | cd $(<D); CONFIG_FILES=$(@F) CONFIG_HEADERS= $(SHELL) $(<F) | |
df4ef2ab | 210 | \f |
28f540f4 RM |
211 | # This makes the Info or DVI file of the documentation from the Texinfo source. |
212 | .PHONY: info dvi | |
213 | info dvi: | |
c0e45674 | 214 | $(MAKE) $(PARALLELMFLAGS) -C manual $@ |
28f540f4 RM |
215 | \f |
216 | # This makes all the subdirectory targets. | |
217 | ||
218 | # For each target, make it depend on DIR/target for each subdirectory DIR. | |
219 | $(+subdir_targets): %: $(addsuffix /%,$(subdirs)) | |
220 | ||
221 | # Compute a list of all those targets. | |
222 | all-subdirs-targets := $(foreach dir,$(subdirs),\ | |
223 | $(addprefix $(dir)/,$(+subdir_targets))) | |
224 | ||
225 | # The action for each of those is to cd into the directory and make the | |
226 | # target there. | |
227 | $(all-subdirs-targets): | |
c0e45674 | 228 | $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F) |
28f540f4 RM |
229 | |
230 | .PHONY: $(+subdir_targets) $(all-subdirs-targets) | |
231 | \f | |
232 | # Targets to clean things up to various degrees. | |
233 | ||
234 | .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean | |
235 | ||
236 | # Subroutines of all cleaning targets. | |
237 | parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules. | |
60092701 RM |
238 | -rm -f $(foreach o,$(object-suffixes),\ |
239 | $(common-objpfx)$(patsubst %,$(libtype$o),c)) \ | |
240 | $(addprefix $(objpfx),$(install-lib)) | |
28f540f4 RM |
241 | parent-clean: parent-mostlyclean common-clean |
242 | -rm -f $(addprefix $(common-objpfx),$(common-generated)) | |
6bf02878 | 243 | -rm -f $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules) |
28f540f4 RM |
244 | |
245 | clean: parent-clean | |
246 | # This is done this way rather than having `subdir_clean' be a | |
247 | # dependency of this target so that libc.a will be removed before the | |
248 | # subdirectories are dealt with and so they won't try to remove object | |
249 | # files from it when it's going to be removed anyway. | |
250 | @$(MAKE) subdir_clean no_deps=t | |
251 | mostlyclean: parent-mostlyclean | |
252 | @$(MAKE) subdir_mostlyclean no_deps=t | |
253 | ||
254 | # The realclean target is just like distclean for the parent, but we want | |
255 | # the subdirs to know the difference in case they care. | |
256 | realclean distclean: parent-clean | |
257 | # This is done this way rather than having `subdir_distclean' be a | |
258 | # dependency of this target so that libc.a will be removed before the | |
259 | # subdirectories are dealt with and so they won't try to remove object | |
260 | # files from it when it's going to be removed anyway. | |
261 | @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes | |
262 | ||
263 | # Subroutine of distclean and realclean. | |
264 | distclean-1: subdir_$(distclean-1) | |
265 | -rm -f $(config-generated) | |
60092701 RM |
266 | -rm -f $(addprefix $(objpfx),config.status config.cache config.log) |
267 | -rm -f $(addprefix $(objpfx),config.make config-name.h config.h) | |
28f540f4 RM |
268 | ifdef objdir |
269 | -rm -f $(objpfx)Makefile | |
270 | endif | |
271 | -rm -f $(sysdep-$(distclean-1)) | |
272 | \f | |
273 | .PHONY: echo_subdirs | |
274 | echo_subdirs:;@echo '$(subdirs)' | |
275 | ||
276 | .PHONY: echo-distinfo parent_echo-distinfo | |
277 | echo-distinfo: parent_echo-distinfo subdir_echo-distinfo | |
278 | parent_echo-distinfo: | |
279 | @echo $(addprefix +header+,$(headers)) \ | |
280 | $(addprefix +nodist+,$(generated)) | |
6a441471 | 281 | |
28f540f4 | 282 | \f |
63551311 UD |
283 | .PHONY: parent-tests |
284 | tests: parent-tests | |
285 | ||
2f6d1f1b | 286 | # Run a test on the header files we use. |
63551311 UD |
287 | parent-tests: $(objpfx)isomac |
288 | $(dir $<)$(notdir $<) '$(CC)' '$(+sysdep-includes)' > $<.out | |
2f6d1f1b UD |
289 | |
290 | $(objpfx)isomac: isomac.c | |
291 | $(native-compile) | |
292 | \f | |
28f540f4 RM |
293 | # Make the distribution tarfile. |
294 | ||
bc9f6000 | 295 | distribute := README INSTALL FAQ NOTES NEWS PROJECTS BUGS \ |
9f447fb3 | 296 | COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \ |
28f540f4 | 297 | Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \ |
2f6d1f1b | 298 | extra-lib.mk o-iterator.mk isomac.c \ |
28f540f4 RM |
299 | ansidecl.h mkinstalldirs move-if-change install-sh \ |
300 | configure configure.in aclocal.m4 config.sub config.guess\ | |
9f447fb3 | 301 | config.h.in config.make.in config-name.in Makefile.in \ |
f0e44959 | 302 | autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \ |
748050b3 | 303 | sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \ |
2f6d1f1b | 304 | rpm/Makefile rpm/template rpm/rpmrc glibcbug.in |
28f540f4 RM |
305 | |
306 | distribute := $(strip $(distribute)) | |
f0f1bf85 | 307 | generated := $(generated) stubs.h version-info.h |
28f540f4 | 308 | |
8d57beea | 309 | README: README.template version.h ; # Make-dist should update README. |
28f540f4 RM |
310 | |
311 | define format-me | |
312 | @rm -f $@ | |
313 | makeinfo --no-validate --no-warn --no-headers $< -o $@ | |
314 | -chmod a-w $@ | |
315 | endef | |
316 | INSTALL: manual/maint.texi; $(format-me) | |
317 | NOTES: manual/creature.texi; $(format-me) | |
f671aeab | 318 | manual/dir-add.texi: FORCE |
fe7bdd63 | 319 | $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F) |
f671aeab | 320 | FORCE: |
6a441471 RM |
321 | |
322 | rpm/%: subdir_distinfo | |
c0e45674 | 323 | $(MAKE) $(PARALLELMFLAGS) -C $(@D) subdirs='$(subdirs)' $(@F) |
33a934a3 UD |
324 | |
325 | # This is a special goal for people making binary distributions. Normally | |
326 | # everybody uses the DES based crypt library but for the distribution we | |
327 | # need the only-MD5 based one as well. | |
328 | md5-crypt/libmd5crypt: | |
c0e45674 | 329 | $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F) |