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