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