]>
Commit | Line | Data |
---|---|---|
3c5edd4d | 1 | # Copyright (C) 1991,92,93,94,95,96,97,98,99 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 | |
54d79e99 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 | # Common rules for making the GNU C library. This file is included | |
21 | # by the top-level Makefile and by all subdirectory makefiles | |
22 | # (through Rules). | |
23 | # | |
24 | ifneq (,) | |
25 | This makefile requires GNU Make. | |
26 | endif | |
27 | ||
14bab8de | 28 | REQUIRED_MAKE_VERSION = 3.74 |
6952e59e | 29 | REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION)) |
14bab8de UD |
30 | |
31 | ifneq ($(REQUIRED_MAKE_VERSION), \ | |
54d79e99 | 32 | $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION)))) |
14bab8de UD |
33 | Wrong GNU Make version. See above for the version needed. |
34 | endif | |
35 | ||
28f540f4 RM |
36 | |
37 | ifdef subdir | |
38 | .. := ../ | |
39 | endif # subdir | |
40 | ||
41 | # If `sources' was defined by the parent makefile, undefine it so | |
42 | # we will later get it from wildcard search in this directory. | |
43 | ifneq "$(findstring env,$(origin sources))" "" | |
44 | sources := | |
45 | endif | |
46 | ||
28f540f4 RM |
47 | oPATH := $(PATH) |
48 | PATH := this definition should take precedence over $(oPATH) | |
49 | ifeq ($(PATH),$(oPATH)) | |
50 | You must not use the -e flag when building the GNU C library. | |
51 | else | |
52 | PATH := $(oPATH) | |
53 | endif | |
54 | \f | |
55 | ifndef +included-Makeconfig | |
56 | include $(..)Makeconfig | |
57 | endif | |
58 | ||
59 | # `configure' writes a definition of `config-sysdirs' in `config.make'. | |
57ba7bb4 | 60 | sysdirs = $(strip $(full-config-sysdirs)) |
28f540f4 RM |
61 | |
62 | +sysdir_pfx = $(common-objpfx) | |
63 | ||
64 | export sysdirs := $(sysdirs) | |
65 | ||
57ba7bb4 | 66 | +sysdep_dirs := $(full-config-sysdirs) |
28f540f4 RM |
67 | ifdef objdir |
68 | +sysdep_dirs := $(objdir) $(+sysdep_dirs) | |
69 | endif | |
70 | ||
71 | # Add -I switches to get the right sysdep directories. | |
72 | # `+includes' in Makeconfig references $(+sysdep-includes). | |
73 | +sysdep-includes := $(addprefix -I,$(+sysdep_dirs)) | |
dbdb6189 | 74 | |
ceb2d9aa UD |
75 | # This variable is used in ``include $(o-iterator)'' after defining |
76 | # $(o-iterator-doit) to produce some desired rule using $o for the object | |
77 | # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy | |
78 | # is produced for each object suffix in use. | |
79 | o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left)) | |
28f540f4 RM |
80 | \f |
81 | # Include any system-specific makefiles. | |
82 | ||
83 | # This is here so things in sysdep Makefiles can easily depend on foo.h as | |
84 | # appropriate and not worry about where foo.h comes from, which may be | |
85 | # system dependent and not known by that Makefile. | |
6e953631 | 86 | vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \ |
57ba7bb4 | 87 | $(+sysdep_dirs) $(..))) |
28f540f4 | 88 | |
714a562f UD |
89 | # The same is true for RPC source files. |
90 | vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \ | |
91 | $(+sysdep_dirs) $(..))) | |
92 | ||
28f540f4 RM |
93 | # Some sysdep makefiles use this to distinguish being included here from |
94 | # being included individually by a subdir makefile (hurd/Makefile needs this). | |
95 | in-Makerules := yes | |
96 | ||
555f3a39 | 97 | -include $(+sysdir_pfx)sysd-Makefile |
da2d1bc5 | 98 | ifndef avoid-generated |
57ba7bb4 | 99 | ifneq ($(sysd-Makefile-sysdirs),$(config-sysdirs)) |
273d56ce RM |
100 | sysd-Makefile-force = FORCE |
101 | FORCE: | |
102 | endif | |
103 | $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)config.make $(..)Makerules \ | |
104 | $(sysd-Makefile-force) | |
28f540f4 | 105 | -@rm -f $@T |
57ba7bb4 | 106 | (echo 'sysd-Makefile-sysdirs := $(config-sysdirs)'; \ |
9c4c0024 UD |
107 | for file in $(config-sysdirs:=/Makefile); do \ |
108 | if [ -f $(..)$$file ]; then \ | |
109 | echo include "\$$(..)$$file"; \ | |
28f540f4 | 110 | else true; fi; \ |
0d204b0a | 111 | done; \ |
28f540f4 RM |
112 | echo 'sysd-Makefile-done=t') > $@T |
113 | mv -f $@T $@ | |
114 | endif | |
115 | ||
3bbceb12 RM |
116 | ifndef sysd-Makefile-done |
117 | # Don't do deps until this exists, because it might change the sources list. | |
118 | no_deps=t | |
119 | endif | |
120 | ||
121 | ||
28f540f4 RM |
122 | # Reorder before-compile so that mach things come first, and hurd things |
123 | # second, before all else. The mach and hurd subdirectories have many | |
124 | # generated header files which the much of rest of the library depends on, | |
125 | # so it is best to build them first (and mach before hurd, at that). | |
126 | before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\ | |
127 | $(before-compile)) \ | |
128 | $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\ | |
129 | $(before-compile)) | |
130 | ||
131 | # Remove existing files from `before-compile'. Things are added there when | |
132 | # they must exist for dependency generation to work right, but once they | |
133 | # exist there is no further need for every single file to depend on them, | |
134 | # and those gratuitous dependencies result in many gratuitous | |
135 | # recompilations. | |
136 | before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile)) | |
137 | ||
138 | # Don't let any before-compile file be an intermediate and get removed. | |
139 | ifdef before-compile | |
140 | $(before-compile): | |
141 | endif | |
142 | \f | |
143 | # Generate an ordered list of implicit rules which find the source files in | |
144 | # each sysdep directory. The old method was to use vpath to search all the | |
145 | # sysdep directories. However, that had the problem that a .S file in a | |
146 | # later directory would be chosen over a .c file in an earlier directory, | |
147 | # which does not preserve the desired sysdeps ordering behavior. | |
148 | ||
149 | # When making the list of .d files to include, we can't know which ones | |
150 | # have source in .s files, and thus do not in fact need a .d file. | |
151 | # So we must define rules to make .d files for .s files. | |
152 | define make-dummy-dep | |
6e953631 | 153 | $(addprefix ln $(common-objpfx)dummy.d ,$(filter-out $(wildcard $@),$@)) |
28f540f4 | 154 | endef |
6e953631 | 155 | $(common-objpfx)dummy.d: |
28f540f4 RM |
156 | echo '# .s files cannot contain includes, so they need no deps.' > $@ |
157 | ||
158 | # It matters that this set of rules, for compiling from sources in | |
159 | # the current directory (the $srcdir/$subdir) come before the | |
160 | # generated sysdep rules in included from sysd-rules below. When | |
161 | # compiling in the source tree, generated sources go into the current | |
162 | # directory, and those should be chosen before any sources in sysdeps. | |
ceb2d9aa UD |
163 | define o-iterator-doit |
164 | $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S) | |
165 | endef | |
3f62b69a | 166 | object-suffixes-left := $(all-object-suffixes) |
ceb2d9aa | 167 | include $(o-iterator) |
28f540f4 | 168 | $(objpfx)%.d: %.S $(before-compile); $(+make-deps) |
ceb2d9aa UD |
169 | |
170 | define o-iterator-doit | |
171 | $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s) | |
172 | endef | |
3f62b69a | 173 | object-suffixes-left := $(all-object-suffixes) |
ceb2d9aa | 174 | include $(o-iterator) |
6e953631 | 175 | $(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep) |
ceb2d9aa UD |
176 | |
177 | define o-iterator-doit | |
178 | $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c) | |
179 | endef | |
3f62b69a | 180 | object-suffixes-left := $(all-object-suffixes) |
ceb2d9aa | 181 | include $(o-iterator) |
28f540f4 RM |
182 | $(objpfx)%.d: %.c $(before-compile); $(+make-deps) |
183 | ||
184 | # Omit the objpfx rules when building in the source tree, because | |
185 | # objpfx is empty and so these rules just override the ones above. | |
186 | ifdef objpfx | |
187 | # Define first rules to find the source files in $(objpfx). | |
188 | # Generated source files will end up there. | |
ceb2d9aa UD |
189 | define o-iterator-doit |
190 | $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S) | |
191 | endef | |
3f62b69a | 192 | object-suffixes-left := $(all-object-suffixes) |
ceb2d9aa | 193 | include $(o-iterator) |
28f540f4 | 194 | $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps) |
ceb2d9aa UD |
195 | |
196 | define o-iterator-doit | |
197 | $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s) | |
198 | endef | |
3f62b69a | 199 | object-suffixes-left := $(all-object-suffixes) |
ceb2d9aa | 200 | include $(o-iterator) |
6e953631 | 201 | $(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep) |
ceb2d9aa UD |
202 | |
203 | define o-iterator-doit | |
204 | $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c) | |
205 | endef | |
3f62b69a | 206 | object-suffixes-left := $(all-object-suffixes) |
ceb2d9aa | 207 | include $(o-iterator) |
28f540f4 RM |
208 | $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps) |
209 | endif | |
210 | ||
211 | # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard | |
212 | # patterns matching sysdep directories whose assembly source files should | |
213 | # be suppressed. | |
214 | ifdef inhibit-sysdep-asm | |
215 | define open-check-inhibit-asm | |
216 | case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *) | |
217 | endef | |
51f75302 | 218 | close-check-inhibit-asm = ;; esac ; |
28f540f4 RM |
219 | endif |
220 | ||
221 | # Don't include sysd-rules until sysd-Makefile is already there and has been | |
222 | # included. It might define inhibit-sysdep-asm, which would affect the | |
223 | # contents of sysd-rules. | |
224 | ifdef sysd-Makefile-done | |
555f3a39 | 225 | -include $(+sysdir_pfx)sysd-rules |
57ba7bb4 UD |
226 | ifneq ($(sysd-rules-sysdirs),$(config-sysdirs)) |
227 | # The value of $(+sysdep_dirs) the sysd-rules was computed for | |
273d56ce RM |
228 | # differs from the one we are using now. So force a rebuild of sysd-rules. |
229 | sysd-rules-force = FORCE | |
230 | FORCE: | |
231 | endif | |
28f540f4 RM |
232 | endif |
233 | $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \ | |
234 | $(wildcard $(foreach dir,$(sysdirs),\ | |
57ba7bb4 | 235 | $(dir)/Makefile))\ |
273d56ce | 236 | $(sysd-rules-force) |
28f540f4 | 237 | -@rm -f $@T |
57ba7bb4 | 238 | (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \ |
9c4c0024 | 239 | for dir in $(config-sysdirs:%='$$(..)%'); do \ |
795fbc9a | 240 | for o in $(all-object-suffixes); do \ |
51f75302 RM |
241 | $(open-check-inhibit-asm) \ |
242 | echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \ | |
243 | \$$(compile-command.S)"; \ | |
244 | echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \ | |
245 | \$$(compile-command.s)"; \ | |
246 | $(close-check-inhibit-asm) \ | |
247 | echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \ | |
248 | \$$(compile-command.c)"; \ | |
249 | done; \ | |
28f540f4 | 250 | $(open-check-inhibit-asm) \ |
6e953631 | 251 | echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \ |
51f75302 | 252 | \$$(make-dummy-dep)"; \ |
28f540f4 RM |
253 | echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \ |
254 | \$$(+make-deps)"; \ | |
51f75302 | 255 | $(close-check-inhibit-asm) \ |
28f540f4 RM |
256 | echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \ |
257 | \$$(+make-deps)"; \ | |
3bbceb12 RM |
258 | done; \ |
259 | echo 'sysd-rules-done = t') > $@T | |
28f540f4 RM |
260 | mv -f $@T $@ |
261 | ||
3bbceb12 RM |
262 | ifndef sysd-rules-done |
263 | # Don't do deps until this exists, because it provides rules to make the deps. | |
264 | no_deps=t | |
265 | endif | |
266 | ||
7a68c94a UD |
267 | # Generate version maps, but wait until sysdep-subdirs is known |
268 | ifdef sysd-dirs-done | |
8eaaffde UD |
269 | ifeq ($(versioning),yes) |
270 | -include $(common-objpfx)sysd-versions | |
4bae5567 | 271 | $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions |
7a68c94a | 272 | common-generated += $(version-maps) sysd-versions |
4bae5567 | 273 | |
7a68c94a UD |
274 | ifndef avoid-generated |
275 | ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs)) | |
276 | sysd-versions-force = FORCE | |
277 | FORCE: | |
278 | endif | |
99c9e773 UD |
279 | $(common-objpfx)Versions.all: $(..)Versions.def \ |
280 | $(wildcard $(add-ons:%=$(..)%/Versions.def)) | |
281 | cat $^ > $@T | |
282 | mv -f $@T $@ | |
283 | common-generated += $(common-objpfx)Versions.all | |
284 | $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \ | |
285 | $(..)scripts/versions.awk \ | |
8eaaffde | 286 | $(wildcard $(all-subdirs:%=$(..)%/Versions)) \ |
7a68c94a UD |
287 | $(wildcard $(sysdirs:%=%/Versions)) \ |
288 | $(sysd-versions-force) | |
289 | { echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \ | |
290 | $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \ | |
291 | -v move_if_change='$(move-if-change)' \ | |
292 | -f $(filter-out $< $(sysd-versions-force),$^); \ | |
293 | } > $@T | |
8eaaffde | 294 | mv -f $@T $@ |
7a68c94a UD |
295 | endif # avoid-generated |
296 | endif # $(versioning) = yes | |
297 | endif # sysd-dirs-done | |
3bbceb12 | 298 | |
28f540f4 RM |
299 | ifndef compile-command.S |
300 | compile-command.S = $(compile.S) $(OUTPUT_OPTION) | |
301 | endif | |
302 | ifndef compile-command.s | |
303 | compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) | |
304 | endif | |
305 | ifndef compile-command.c | |
306 | compile-command.c = $(compile.c) $(OUTPUT_OPTION) | |
307 | endif | |
308 | ||
28f540f4 | 309 | # GCC can grok options after the file name, and it looks nicer that way. |
28f540f4 | 310 | compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS) |
f166d865 UD |
311 | compile.S = \ |
312 | $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@)) | |
313 | COMPILE.S = \ | |
314 | $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@)) | |
aeb72b16 | 315 | COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS) |
28f540f4 | 316 | |
28f540f4 RM |
317 | # We need this for the output to go in the right place. It will default to |
318 | # empty if make was configured to work with a cc that can't grok -c and -o | |
319 | # together. You can't compile the C library with such a compiler. | |
320 | OUTPUT_OPTION = -o $@ | |
28f540f4 RM |
321 | |
322 | S-CPPFLAGS = $(asm-CPPFLAGS) | |
323 | define +make-deps | |
6e953631 | 324 | $(make-target-directory) |
28f540f4 | 325 | -@rm -f $@ |
60c96635 | 326 | $(+mkdep) $< $(CFLAGS) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \ |
795fbc9a UD |
327 | sed \ |
328 | -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \ | |
51f75302 | 329 | $(sed-remove-objpfx) > $(@:.d=.T) |
28f540f4 RM |
330 | mv -f $(@:.d=.T) $@ |
331 | endef | |
332 | ifneq (,$(objpfx)) | |
215dbbb1 RM |
333 | # Continuation lines here are dangerous because they introduce spaces! |
334 | define sed-remove-objpfx | |
6e953631 UD |
335 | -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \ |
336 | -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g' | |
215dbbb1 | 337 | endef |
28f540f4 RM |
338 | endif |
339 | \f | |
5f0e6fc7 RM |
340 | # Shared library building. |
341 | ||
342 | ifeq (yes,$(build-shared)) | |
343 | ||
ae1025be UD |
344 | # Reference map file only when versioning is selected and a map file name |
345 | # is given. | |
346 | ifeq ($(versioning),yes) | |
a9ddb793 UD |
347 | map-file = $(firstword $($(@F:.so=-map)) \ |
348 | $(addprefix $(common-objpfx), \ | |
349 | $(filter $(@F:.so=.map),$(version-maps)))) | |
b17277cf | 350 | load-map-file = $(map-file:%=-Wl,--version-script=%) |
ae1025be UD |
351 | endif |
352 | ||
5f0e6fc7 RM |
353 | # Pattern rule to build a shared object from an archive of PIC objects. |
354 | # This must come after the installation rules so Make doesn't try to | |
355 | # build shared libraries in place from the installed *_pic.a files. | |
356 | # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies | |
357 | # on other shared objects. | |
66715f83 | 358 | lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) |
40a55d20 | 359 | $(build-shlib) |
5f0e6fc7 | 360 | |
5f0e6fc7 | 361 | define build-shlib |
0155a773 | 362 | $(LINK.o) -shared -Wl,-O1 -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \ |
b17277cf | 363 | -B$(csu-objpfx) $(load-map-file) \ |
5f0e6fc7 RM |
364 | -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \ |
365 | $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \ | |
366 | -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \ | |
40a55d20 | 367 | -Wl,--whole-archive \ |
a9ddb793 | 368 | $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \ |
714a562f | 369 | $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so) |
5f0e6fc7 RM |
370 | endef |
371 | ||
9afc8a59 UD |
372 | ifndef libc.so-version |
373 | # Undefine this because it can't work when we libc.so is unversioned. | |
374 | static-only-routines = | |
375 | endif | |
376 | ||
b22fc5f5 UD |
377 | elide-routines.oS += $(filter-out $(static-only-routines),\ |
378 | $(routines) $(aux) $(sysdep_routines)) | |
97a47867 | 379 | elide-routines.os += $(static-only-routines) |
9afc8a59 | 380 | |
9afc8a59 UD |
381 | # If we have versioned code we don't need the old versions in any of the |
382 | # static libraries. | |
b22fc5f5 UD |
383 | elide-routines.o += $(shared-only-routines) |
384 | elide-routines.op += $(shared-only-routines) | |
385 | elide-routines.og += $(shared-only-routines) | |
386 | elide-routines.ob += $(shared-only-routines) | |
9afc8a59 | 387 | |
5f0e6fc7 RM |
388 | # Don't try to use -lc when making libc.so itself. |
389 | # Also omits crti.o and crtn.o, which we do not want | |
390 | # since we define our own `.init' section specially. | |
391 | LDFLAGS-c.so = -nostdlib -nostartfiles | |
9a0a462c | 392 | # But we still want to link libc.so against $(gnulib). |
2698e32c | 393 | LDLIBS-c.so += $(gnulib) |
5f0e6fc7 RM |
394 | # Give libc.so an entry point and make it directly runnable itself. |
395 | LDFLAGS-c.so += -e __libc_main | |
da2d1bc5 UD |
396 | # Pre-link the objects of libc_pic.a so that we can locally resolve |
397 | # COMMON symbols before we link against ld.so. This is because ld.so | |
398 | # contains some of libc_pic.a already, which will prevent the COMMONs | |
399 | # from being allocated in libc.so, which introduces evil dependencies | |
400 | # between libc.so and ld.so, which can make it impossible to upgrade. | |
401 | $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a | |
402 | $(LINK.o) -nostdlib -nostartfiles -r -o $@ \ | |
403 | -Wl,-d -Wl,--whole-archive $^ | |
5f0e6fc7 | 404 | # Use our own special initializer and finalizer files for libc.so. |
40a55d20 | 405 | $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \ |
da2d1bc5 | 406 | $(common-objpfx)libc_pic.os \ |
66715f83 | 407 | $(elfobjdir)/sofini.os \ |
a9ddb793 | 408 | $(elfobjdir)/interp.os $(elfobjdir)/ld.so |
5f0e6fc7 | 409 | $(build-shlib) |
a9ddb793 UD |
410 | ifeq ($(versioning),yes) |
411 | $(common-objpfx)libc.so: $(common-objpfx)libc.map | |
412 | endif | |
1b5fd830 | 413 | common-generated += libc.so libc_pic.os |
d705269e UD |
414 | ifdef libc.so-version |
415 | $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so | |
416 | $(make-link) | |
da2d1bc5 | 417 | common-generated += libc.so$(libc.so-version) |
d705269e | 418 | endif |
5f0e6fc7 RM |
419 | endif |
420 | \f | |
28f540f4 RM |
421 | # Figure out the source filenames in this directory. |
422 | ||
423 | override sources := $(addsuffix .c,$(filter-out $(elided-routines),\ | |
424 | $(routines) $(aux) \ | |
425 | $(sysdep_routines))) | |
426 | sysdep_routines := $(sysdep_routines) | |
427 | ||
e60062b7 RM |
428 | headers := $(headers) $(sysdep_headers) |
429 | ||
28f540f4 RM |
430 | # This is the list of all object files, gotten by |
431 | # replacing every ".c" in `sources' with a ".o". | |
432 | override objects := $(addprefix $(objpfx),$(sources:.c=.o)) | |
693e7b96 RM |
433 | |
434 | ||
693e7b96 RM |
435 | # The makefile may define $(extra-libs) with `libfoo libbar' |
436 | # to build libfoo.a et al from the modules listed in $(libfoo-routines). | |
437 | ifdef extra-libs | |
438 | # extra-lib.mk is included once for each extra lib to define rules | |
439 | # to build it, and to add its objects to the various variables. | |
440 | # During its evaluation, $(lib) is set to the name of the library. | |
441 | extra-libs-left := $(extra-libs) | |
442 | include $(patsubst %,$(..)extra-lib.mk,$(extra-libs)) | |
443 | endif | |
28f540f4 | 444 | \f |
eb406346 UD |
445 | +depfiles := $(sources:.c=.d) \ |
446 | $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \ | |
3c5edd4d | 447 | $(addsuffix .d,$(tests) $(test-srcs)) |
0413b54c | 448 | ifeq ($(build-programs),yes) |
414fd335 | 449 | +depfiles += $(addsuffix .d,$(others) $(sysdep-others)) |
0413b54c | 450 | endif |
28f540f4 RM |
451 | +depfiles := $(addprefix $(objpfx),\ |
452 | $(filter-out $(addsuffix .d,$(omit-deps)),\ | |
453 | $(+depfiles))) | |
454 | ||
28f540f4 | 455 | ifdef +depfiles |
28f540f4 | 456 | ifneq ($(no_deps),t) |
555f3a39 | 457 | -include $(+depfiles) |
deab9dea | 458 | endif |
28f540f4 RM |
459 | endif |
460 | \f\f | |
461 | # Maximize efficiency by minimizing the number of rules. | |
9756dfe1 | 462 | .SUFFIXES: # Clear the suffix list. We don't use suffix rules. |
f649c201 UD |
463 | # Don't define any builtin rules. |
464 | MAKEFLAGS := $(MAKEFLAGS)r | |
28f540f4 RM |
465 | |
466 | # Generic rule for making directories. | |
467 | %/: | |
468 | # mkdir isn't smart enough to strip a trailing /. | |
469 | mkdir $(@:%/=%) | |
470 | \f | |
471 | # Make sure that object files are not removed | |
472 | # when they are intermediates between sources and library members. | |
9afc8a59 | 473 | .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes)) |
28f540f4 RM |
474 | |
475 | # Make sure that the parent library archive is never removed. | |
51f75302 | 476 | .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c)) |
28f540f4 RM |
477 | \f |
478 | # Use the verbose option of ar and tar when not running silently. | |
479 | ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s | |
480 | verbose := v | |
481 | else # -s | |
482 | verbose := | |
483 | endif # not -s | |
484 | ||
485 | ARFLAGS := r$(verbose) | |
f38931a9 | 486 | CREATE_ARFLAGS := cru$(verbose) |
28f540f4 RM |
487 | \f |
488 | # This makes all the object files in the parent library archive. | |
489 | ||
97a47867 | 490 | .PHONY: lib lib-noranlib |
ae9b308c | 491 | lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c)) |
b22fc5f5 | 492 | lib-noranlib: libobjs |
51f75302 | 493 | |
564210fe RM |
494 | # For object-suffix $o, the list of objects with that suffix. |
495 | # Makefiles can define `elide-routines.so = foo' to leave foo.so out. | |
496 | o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\ | |
497 | $(elide-routines$o)),\ | |
498 | $(objects))) | |
3bbceb12 | 499 | others: $(addprefix $(objpfx),$(install-lib)) |
28f540f4 | 500 | |
072ebcef RM |
501 | ifndef objects |
502 | ||
503 | # Create the stamp$o files to keep the parent makefile happy. | |
9afc8a59 UD |
504 | subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o) |
505 | $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o): | |
6e953631 | 506 | $(make-target-directory) |
072ebcef RM |
507 | rm -f $@; > $@ |
508 | else | |
51f75302 | 509 | |
97a47867 | 510 | # Define explicit rules to update each $(objpfx)stamp.SUFFIX |
564210fe | 511 | # timestamp file; these rules (one explicit rule is generated for each |
97a47867 UD |
512 | # object suffix) write a list of objects to update in the stamp file. |
513 | # The parent will then actually add them all to the archive in the | |
514 | # archive rule, below. | |
564210fe | 515 | define o-iterator-doit |
97a47867 UD |
516 | $(objpfx)stamp$o: $(o-objects); $$(do-stamp) |
517 | endef | |
518 | define do-stamp | |
a709dd43 | 519 | echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T |
b22fc5f5 | 520 | mv -f $@T $@ |
564210fe | 521 | endef |
9afc8a59 | 522 | object-suffixes-left := $(object-suffixes-for-libc) |
564210fe | 523 | include $(o-iterator) |
28f540f4 | 524 | |
51f75302 | 525 | endif |
28f540f4 | 526 | |
97a47867 | 527 | # Now define explicit rules to build the library archives; these depend |
a709dd43 | 528 | # on the stamp files built above. |
dbdb6189 | 529 | define o-iterator-doit |
97a47867 UD |
530 | $(common-objpfx)$(patsubst %,$(libtype$o),c): \ |
531 | $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib) | |
532 | endef | |
533 | define do-makelib | |
b22fc5f5 | 534 | cd $(common-objdir) && \ |
a709dd43 UD |
535 | $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)` |
536 | $(RANLIB) $@ | |
dbdb6189 | 537 | endef |
97a47867 UD |
538 | subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%) |
539 | subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps)) | |
b22fc5f5 | 540 | ifndef subdir |
ae9b308c | 541 | $(subdirs-stamps): subdir_lib; |
97a47867 | 542 | endif |
9afc8a59 | 543 | object-suffixes-left = $(object-suffixes-for-libc) |
dbdb6189 RM |
544 | include $(o-iterator) |
545 | ||
28f540f4 RM |
546 | |
547 | # This makes all the object files. | |
97a47867 UD |
548 | .PHONY: objects objs libobjs extra-objs |
549 | objects objs: libobjs extra-objs | |
550 | libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o) | |
551 | extra-objs: $(addprefix $(objpfx),$(extra-objs)) | |
f0bf9cb9 RM |
552 | |
553 | # Canned sequence for building an extra library archive. | |
554 | define build-extra-lib | |
af3878df | 555 | $(patsubst %/,cd % &&,$(objpfx)) \ |
f38931a9 | 556 | $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \ |
f0bf9cb9 RM |
557 | $(patsubst $(objpfx)%,%,$^) |
558 | $(RANLIB) $@ | |
559 | endef | |
28f540f4 RM |
560 | \f |
561 | # Installation. | |
562 | ||
73237de3 UD |
563 | .PHONY: force-install |
564 | force-install: | |
565 | ||
28f540f4 RM |
566 | # $(install-lib) are installed from the object directory into $(libdir); |
567 | # files in $(install-lib) matching `lib%.a' are ranlib'd after installation | |
568 | # unless they also appear in $(non-lib.a). $(install-data) are installed | |
569 | # as they are into $(datadir). $(headers) are installed as they are in | |
570 | # $(includedir). $(install-bin) and $(install-sbin) are installed from the | |
571 | # object directory into $(bindir) and $(sbindir), respectively. | |
572 | # $(install-others) are absolute path names of files to install; rules to | |
573 | # install them are defined elsewhere. | |
574 | ||
575 | # The simple library name to install libc.a under. | |
576 | # This could be defined by a sysdep Makefile. | |
577 | ifndef libc-name | |
578 | libc-name := c | |
579 | endif | |
580 | ||
581 | define do-install | |
582 | $(make-target-directory) | |
583 | $(INSTALL_DATA) $< $@ | |
584 | endef | |
585 | ||
a182affd RM |
586 | # Make the target directory if it doesn't exist, using the `mkinstalldirs' |
587 | # script that does `mkdir -p' even if `mkdir' doesn't support that flag. | |
28f540f4 | 588 | define make-target-directory |
5bc2f642 | 589 | $(addprefix $(..)./scripts/mkinstalldirs ,\ |
a182affd | 590 | $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%))) |
28f540f4 RM |
591 | endef |
592 | ||
a709dd43 UD |
593 | # Any directory (parent or subdir) should install libc.a; this way |
594 | # "make install" in a subdir is guaranteed to install everything it changes. | |
cab24c37 | 595 | installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\ |
8d57beea UD |
596 | $(inst_libdir)/$(patsubst %,$(libtype$o),\ |
597 | $(libprefix)$(libc-name))) | |
51f75302 | 598 | install: $(installed-libcs) |
73237de3 | 599 | $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force) |
28f540f4 | 600 | $(make-target-directory) |
c316b486 | 601 | $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@ |
9f2233e8 RM |
602 | # Running ranlib after installing makes the __.SYMDEF time stamp up to |
603 | # date, which avoids messages from some linkers. | |
28f540f4 | 604 | $(RANLIB) $@ |
28f540f4 | 605 | |
273d56ce RM |
606 | define do-install-program |
607 | $(make-target-directory) | |
608 | $(INSTALL_PROGRAM) $< $@.new | |
609 | mv -f $@.new $@ | |
610 | endef | |
611 | ||
5bf62f2d | 612 | install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so)) |
0700dfa1 | 613 | install-lib := $(filter-out %.so %_pic.a,$(install-lib)) |
0e3426bb | 614 | |
a9ddb793 | 615 | ifeq (yes,$(build-shared)) |
0e3426bb | 616 | # Find which .so's have versions. |
05d4c982 RM |
617 | versioned := $(strip $(foreach so,$(install-lib.so),\ |
618 | $(patsubst %,$(so),$($(so)-version)))) | |
0e3426bb | 619 | |
a9ddb793 UD |
620 | install-lib.so-versioned := $(filter $(versioned), $(install-lib.so)) |
621 | install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so)) | |
622 | ||
623 | install-lib-nosubdir: $(install-lib.so-versioned:%=$(inst_libdir)/%) \ | |
624 | $(install-lib.so-unversioned:%=$(inst_slibdir)/%) | |
625 | ||
0e3426bb | 626 | # Install all the unversioned shared libraries. |
a9ddb793 UD |
627 | $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \ |
628 | $(objpfx)%.so $(+force) | |
629 | $(do-install-program) | |
0e3426bb | 630 | |
8a523922 | 631 | ifneq ($(findstring -s,$(LN_S)),) |
f36f8dcf | 632 | define make-link |
f8b87ef0 | 633 | rm -f $@.new |
5bc2f642 | 634 | $(SHELL) $(..)scripts/rellns-sh $< $@.new |
8a523922 UD |
635 | mv -f $@.new $@ |
636 | endef | |
637 | else | |
638 | # If we have no symbolic links don't bother with rellns-sh. | |
639 | define make-link | |
f8b87ef0 UD |
640 | rm -f $@.new |
641 | $(LN_S) $< $@.new | |
8a523922 | 642 | mv -f $@.new $@ |
f36f8dcf | 643 | endef |
8a523922 | 644 | endif |
0e3426bb | 645 | |
9d141cae UD |
646 | ifeq (no,$(cross-compiling)) |
647 | ifeq (yes,$(build-shared)) | |
9d141cae UD |
648 | symbolic-link-prog := $(common-objpfx)elf/sln |
649 | symbolic-link-list := $(common-objpfx)elf/symlink.list | |
1ef32c3d | 650 | define make-shlib-link |
9d141cae | 651 | echo $(<F) $@ >> $(symbolic-link-list) |
1ef32c3d UD |
652 | endef |
653 | endif | |
654 | endif | |
655 | ifndef make-shlib-link | |
656 | define make-shlib-link | |
9d141cae UD |
657 | rm -f $@ |
658 | $(LN_S) $(<F) $@ | |
1ef32c3d UD |
659 | endef |
660 | endif | |
661 | ||
0e3426bb RM |
662 | ifdef libc.so-version |
663 | # For a library specified to be version N, install three files: | |
664 | # libc.so -> libc.so.N (e.g. libc.so.6) | |
665 | # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so) | |
666 | ||
73237de3 UD |
667 | $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \ |
668 | $(+force) | |
1ef32c3d | 669 | $(make-shlib-link) |
73237de3 | 670 | $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force) |
8d57beea UD |
671 | $(do-install-program) |
672 | install: $(inst_slibdir)/libc.so$(libc.so-version) | |
7c713e28 | 673 | |
aa1075ea | 674 | ifndef subdir |
57ba7bb4 UD |
675 | # What we install as libc.so for programs to link against is in fact a |
676 | # link script. It contains references for the various libraries we need. | |
677 | # The libc.so object is not complete since some functions are only defined | |
71bedb76 | 678 | # in libc_nonshared.a. |
e980ca92 UD |
679 | # We need to use absolute paths since otherwise local copies (if they exist) |
680 | # of the files are taken by the linker. | |
8d57beea UD |
681 | install: $(inst_libdir)/libc.so |
682 | $(inst_libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \ | |
a44d2393 | 683 | $(inst_libdir)/$(patsubst %,$(libtype.oS),\ |
73237de3 UD |
684 | $(libprefix)$(libc-name)) \ |
685 | $(+force) | |
47707456 UD |
686 | (echo '/* GNU ld script';\ |
687 | echo ' Use the shared library, but some functions are only in';\ | |
a44d2393 | 688 | echo ' the static library, so try that secondarily. */';\ |
af6f3906 | 689 | echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \ |
a44d2393 UD |
690 | '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\ |
691 | ')' \ | |
692 | ) > $@.new | |
0f90ef96 RM |
693 | mv -f $@.new $@ |
694 | ||
aa1075ea | 695 | endif |
7c713e28 | 696 | |
0e3426bb | 697 | else |
8d57beea | 698 | install: $(inst_slibdir)/libc.so |
73237de3 | 699 | $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force) |
8d57beea | 700 | $(do-install-program) |
0e3426bb RM |
701 | endif |
702 | ||
0e3426bb RM |
703 | ifneq (,$(versioned)) |
704 | # Produce three sets of rules as above for all the smaller versioned libraries. | |
705 | ||
706 | define o-iterator-doit | |
73237de3 | 707 | $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link) |
0e3426bb RM |
708 | endef |
709 | object-suffixes-left := $(versioned) | |
dc997231 | 710 | include $(o-iterator) |
0e3426bb | 711 | |
20c81189 RM |
712 | # Make symlinks in the build directory, because the versioned names might |
713 | # be referenced by a DT_NEEDED in another library. | |
714 | define o-iterator-doit | |
715 | $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link) | |
716 | endef | |
717 | object-suffixes-left := $(versioned) | |
dc997231 | 718 | include $(o-iterator) |
20c81189 | 719 | |
da2d1bc5 | 720 | generated += $(foreach o,$(versioned),$o$($o-version)) |
20c81189 | 721 | |
499e7464 | 722 | ifeq (,$($(subdir)-version)) |
0e3426bb | 723 | define o-iterator-doit |
73237de3 UD |
724 | $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \ |
725 | $(+force); | |
1ef32c3d | 726 | $$(make-shlib-link) |
0e3426bb RM |
727 | endef |
728 | object-suffixes-left := $(versioned) | |
dc997231 | 729 | include $(o-iterator) |
0e3426bb RM |
730 | |
731 | define o-iterator-doit | |
73237de3 UD |
732 | $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force); |
733 | $$(do-install-program) | |
0e3426bb RM |
734 | endef |
735 | object-suffixes-left := $(versioned) | |
dc997231 | 736 | include $(o-iterator) |
499e7464 UD |
737 | else |
738 | define o-iterator-doit | |
8d57beea | 739 | $(inst_slibdir)/$o$($o-version): \ |
73237de3 | 740 | $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force); |
1ef32c3d | 741 | $$(make-shlib-link) |
499e7464 UD |
742 | endef |
743 | object-suffixes-left := $(versioned) | |
744 | include $(o-iterator) | |
745 | ||
746 | define o-iterator-doit | |
73237de3 | 747 | $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force); |
499e7464 UD |
748 | $$(do-install-program) |
749 | endef | |
750 | object-suffixes-left := $(versioned) | |
751 | include $(o-iterator) | |
752 | endif | |
0e3426bb | 753 | endif |
102800e0 RM |
754 | |
755 | define do-install-so | |
756 | $(do-install-program) | |
757 | $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\ | |
758 | $(filter-out %.so,$@)) | |
759 | endef | |
094bacdb | 760 | |
102800e0 RM |
761 | so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version))) |
762 | $(foreach v,$(so-versions),\ | |
73237de3 UD |
763 | $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \ |
764 | $(+force) | |
102800e0 RM |
765 | $(do-install-so) |
766 | $(foreach v,$(so-versions),\ | |
73237de3 | 767 | $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force) |
102800e0 | 768 | $(do-install-so) |
51f75302 RM |
769 | endif |
770 | ||
28f540f4 | 771 | ifdef install-bin |
73237de3 UD |
772 | $(addprefix $(inst_bindir)/,$(install-bin)): \ |
773 | $(inst_bindir)/%: $(objpfx)% $(+force) | |
273d56ce | 774 | $(do-install-program) |
28f540f4 | 775 | endif |
1ef32c3d | 776 | ifdef install-rootsbin |
73237de3 UD |
777 | $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \ |
778 | $(inst_rootsbindir)/%: $(objpfx)% $(+force) | |
1ef32c3d UD |
779 | $(do-install-program) |
780 | endif | |
28f540f4 | 781 | ifdef install-sbin |
73237de3 UD |
782 | $(addprefix $(inst_sbindir)/,$(install-sbin)): \ |
783 | $(inst_sbindir)/%: $(objpfx)% $(+force) | |
273d56ce | 784 | $(do-install-program) |
28f540f4 RM |
785 | endif |
786 | ifdef install-lib | |
787 | install-lib.a := $(filter lib%.a,$(install-lib)) | |
788 | install-lib-non.a := $(filter-out lib%.a,$(install-lib)) | |
789 | ifdef install-lib-non.a | |
9d187dd4 | 790 | $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \ |
73237de3 | 791 | $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force) |
28f540f4 RM |
792 | $(do-install) |
793 | endif | |
794 | ifdef install-lib.a | |
8d57beea | 795 | $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \ |
73237de3 | 796 | $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force) |
28f540f4 RM |
797 | $(do-install) |
798 | $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F))) | |
799 | endif | |
800 | endif | |
801 | ifdef install-data | |
73237de3 | 802 | $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force) |
8d57beea | 803 | $(do-install) |
28f540f4 RM |
804 | endif |
805 | headers := $(strip $(headers)) | |
806 | ifdef headers | |
73237de3 | 807 | $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force) |
8d57beea | 808 | $(do-install) |
28f540f4 RM |
809 | endif # headers |
810 | ||
1ef32c3d UD |
811 | .PHONY: install-bin-nosubdir install-rootsbin-nosubdir install-sbin-nosubdir \ |
812 | install-lib-nosubdir install-data-nosubdir install-headers-nosubdir | |
8d57beea UD |
813 | install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin)) |
814 | install-rootsbin-nosubdir: \ | |
815 | $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)) | |
816 | install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin)) | |
817 | install-lib-nosubdir: $(addprefix $(inst_libdir)/,\ | |
28f540f4 RM |
818 | $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \ |
819 | $(addprefix $(libprefix),$(install-lib-non.a))) | |
8d57beea UD |
820 | install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data)) |
821 | install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers)) | |
28f540f4 RM |
822 | install-others-nosubdir: $(install-others) |
823 | ||
824 | # We need all the `-nosubdir' targets so that `install' in the parent | |
825 | # doesn't depend on several things which each iterate over the subdirs. | |
826 | # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a | |
827 | # subroutine. Then in the parent `install-FOO' also causes subdir makes. | |
828 | install-%:: install-%-nosubdir ; | |
829 | ||
830 | .PHONY: install install-no-libc.a-nosubdir | |
da2d1bc5 | 831 | ifeq ($(build-programs),yes) |
28f540f4 RM |
832 | install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ |
833 | install-bin-nosubdir install-lib-nosubdir \ | |
1ef32c3d UD |
834 | install-others-nosubdir install-rootsbin-nosubdir \ |
835 | install-sbin-nosubdir | |
da2d1bc5 UD |
836 | else |
837 | install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ | |
838 | install-lib-nosubdir install-others-nosubdir | |
839 | endif | |
28f540f4 RM |
840 | install: install-no-libc.a-nosubdir |
841 | \f | |
842 | # Command to compile $< in $(objdir) using the native libraries. | |
843 | define native-compile | |
377a515b | 844 | $(make-target-directory) |
af3878df | 845 | $(patsubst %/,cd % &&,$(objpfx)) \ |
377a515b UD |
846 | $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \ |
847 | $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F) | |
28f540f4 RM |
848 | endef |
849 | ||
850 | # Command to compile $< in $(common-objdir) using the native libraries. | |
0d204b0a | 851 | # We must cd to $(objdir) anyway so that $(..)config.h is valid. |
28f540f4 | 852 | define common-objdir-compile |
af3878df | 853 | $(patsubst %/,cd % &&,$(objpfx)) \ |
377a515b UD |
854 | $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \ |
855 | $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F) | |
28f540f4 RM |
856 | endef |
857 | ||
858 | # We always want to use configuration definitions. | |
377a515b UD |
859 | # Note that this is only used for commands running in $(objpfx). |
860 | ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h | |
28f540f4 RM |
861 | |
862 | # Support the GNU standard name for this target. | |
863 | .PHONY: check | |
864 | check: tests | |
865 | \f | |
866 | .PHONY: TAGS | |
5649a1d6 | 867 | TAGS: $(objpfx)distinfo $(..)MakeTAGS |
dbdb6189 | 868 | $(MAKE) $(addprefix -f ,$^) $@ |
28f540f4 | 869 | |
5649a1d6 | 870 | $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE |
ce563359 RM |
871 | $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@ |
872 | FORCE: | |
a182affd RM |
873 | |
874 | ||
28f540f4 RM |
875 | .PHONY: echo-headers |
876 | echo-headers: | |
877 | @echo $(headers) | |
878 | ||
879 | \f | |
880 | # Common cleaning targets. | |
881 | ||
3c5edd4d | 882 | .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean |
28f540f4 RM |
883 | clean: common-clean |
884 | mostlyclean: common-mostlyclean | |
885 | ||
3c5edd4d UD |
886 | do-tests-clean: |
887 | -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(test-srcs)) \ | |
888 | $(addsuffix .sout,$(tests-static))) | |
889 | ||
28f540f4 RM |
890 | # Remove the object files. |
891 | common-mostlyclean: | |
e61abf83 | 892 | -rm -f $(addprefix $(objpfx),$(tests) $(test-srcs) $(others) \ |
3c5edd4d | 893 | $(sysdep-others) stubs \ |
e61abf83 | 894 | $(addsuffix .o,$(tests) $(test-srcs) \ |
414fd335 UD |
895 | $(others) \ |
896 | $(sysdep-others)) \ | |
1686c452 | 897 | $(addsuffix .out,$(tests) $(test-srcs))) |
da2d1bc5 UD |
898 | -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \ |
899 | $(install-lib.so) \ | |
900 | $(install-lib.so:%.so=%_pic.a)) | |
97a47867 | 901 | -rm -f core |
51f75302 RM |
902 | $(rmobjs) |
903 | define rmobjs | |
9afc8a59 | 904 | $(foreach o,$(object-suffixes-for-libc), |
51702635 | 905 | -rm -f $(objpfx)stamp$o $(o-objects)) |
51f75302 | 906 | endef |
28f540f4 RM |
907 | |
908 | # Also remove the dependencies and generated source files. | |
909 | common-clean: common-mostlyclean | |
deab9dea | 910 | -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles) |
5290baf0 | 911 | -rm -fr $(addprefix $(objpfx),$(generated-dirs)) |
924840c5 | 912 | -rm -f $(addprefix $(common-objpfx),$(common-generated)) |
5649a1d6 | 913 | -rm -f $(objpfx)distinfo |
28f540f4 | 914 | \f |
97a47867 | 915 | # Produce a file `stubs' which contains `#define __stub_FUNCTION' |
28f540f4 | 916 | # for each function which is a stub. We grovel over all the .d files |
f2ea0f5b UD |
917 | # looking for references to <stub-tag.h>. Then we grovel over each |
918 | # referenced source file to see what stub function it defines. | |
28f540f4 | 919 | |
b22fc5f5 | 920 | ifdef objpfx |
28f540f4 | 921 | .PHONY: stubs # The parent Makefile calls this target. |
97a47867 | 922 | stubs: $(objpfx)stubs |
b22fc5f5 | 923 | endif |
f2ea0f5b | 924 | s = $(sysdep_dir)/generic |
97a47867 | 925 | $(objpfx)stubs: $(+depfiles) |
28f540f4 | 926 | # Use /dev/null since `...` might expand to empty. |
af3878df UD |
927 | (s=`cd $s && /bin/pwd`; \ |
928 | $(patsubst %/,cd % &&,$(objpfx)) \ | |
c4cc693d | 929 | sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \ |
f43ce637 | 930 | `sed -n -e '\@ $s/[^ ]*\.c@{; s@^.* $s/\([^ ]*\.c\).*$$@'"$$s"'/\1@; h; }' \ |
f2ea0f5b | 931 | -e '/stub-tag\.h/{; g; p; }' \ |
c4cc693d RM |
932 | $(patsubst $(objpfx)%,%,$^) /dev/null` \ |
933 | /dev/null) > $@T | |
28f540f4 RM |
934 | mv -f $@T $@ |
935 | \f | |
936 | # Make the distribution tar file. | |
937 | ||
938 | .PHONY: dist | |
5649a1d6 | 939 | dist: $(objpfx)distinfo $(..)Make-dist |
28f540f4 RM |
940 | $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args) |
941 | ||
10ceac89 RM |
942 | # Avoid depending on source files found in sysdeps dirs, |
943 | # because the references affect implicit rule selection. | |
944 | dist: $(filter-out %.c %.S %.s,$(distribute)) | |
28f540f4 RM |
945 | |
946 | # We used to simply export all these variables, but that frequently made the | |
947 | # environment get too large. Instead, we write all the information into | |
948 | # a generated makefile fragment `distinfo', and then include it with -f in | |
949 | # the sub-make that makes the distribution (above). | |
5649a1d6 UD |
950 | $(objpfx)distinfo: Makefile $(..)Makerules \ |
951 | $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile)) | |
714a562f | 952 | $(make-target-directory) |
28f540f4 RM |
953 | $(distinfo-vars) |
954 | mv -f $@.new $@ | |
5649a1d6 UD |
955 | .PHONY: subdir_distinfo |
956 | subdir_distinfo: $(objpfx)distinfo | |
28f540f4 RM |
957 | |
958 | define distinfo-vars | |
959 | rm -f $@.new | |
a4242e25 RM |
960 | echo > $@.new 'subdir := $(subdir)' |
961 | $(foreach var,subdir-dirs sources elided-routines sysdep_routines \ | |
dfe1754a | 962 | headers sysdep_headers distribute dont_distribute generated \ |
478b92f0 | 963 | others tests test-srcs extra-libs $(extra-libs:%=%-routines) \ |
3c5edd4d | 964 | versioned \ |
6a441471 | 965 | $(addprefix install-,lib lib.so data bin sbin others), |
4d6acc61 RM |
966 | echo >> $@.new '$(subdir)-$(var) := $($(var))' |
967 | echo >> $@.new '$(var) = $$($(subdir)-$(var))') | |
28f540f4 RM |
968 | endef |
969 | \f | |
970 | ifneq (,$(strip $(gpl2lgpl))) | |
971 | ifneq (,$(wildcard $(..)gpl2lgpl.sed)) | |
972 | # Snarf from the master source and frob the copying notice. | |
973 | $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/% | |
974 | sed -f $^ > $@-tmp | |
975 | # So I don't edit them by mistake. | |
976 | chmod a-w $@-tmp | |
977 | mv -f $@-tmp $@ | |
4d06461a | 978 | ifeq ($(with-cvs),yes) |
379bb425 | 979 | test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@ |
28f540f4 RM |
980 | endif |
981 | endif | |
4d06461a | 982 | endif |