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