]>
Commit | Line | Data |
---|---|---|
a7f7b879 | 1 | # Copyright (C) 1991-2002, 2003 Free Software Foundation, Inc. |
1c68c264 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 Lesser General Public | |
6 | # License as published by the Free Software Foundation; either | |
7 | # version 2.1 of the 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 | # Lesser General Public License for more details. | |
13 | ||
14 | # You should have received a copy of the GNU Lesser General Public | |
15 | # License along with the GNU C Library; if not, write to the Free | |
16 | # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
17 | # 02111-1307 USA. | |
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 | ||
28 | REQUIRED_MAKE_VERSION = 3.74 | |
29 | REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION)) | |
30 | ||
31 | ifneq ($(REQUIRED_MAKE_VERSION), \ | |
32 | $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION)))) | |
33 | Wrong GNU Make version. See above for the version needed. | |
34 | endif | |
35 | ||
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 | ||
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'. | |
60 | sysdirs = $(strip $(full_config_sysdirs)) | |
61 | ||
62 | +sysdir_pfx = $(common-objpfx) | |
63 | ||
64 | export sysdirs := $(sysdirs) | |
65 | ||
66 | +sysdep_dirs := $(full_config_sysdirs) | |
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)) | |
74 | ||
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)) | |
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. | |
86 | vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \ | |
87 | $(+sysdep_dirs) $(..))) | |
88 | ||
89 | # The same is true for RPC source files. | |
90 | vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \ | |
91 | $(+sysdep_dirs) $(..))) | |
92 | ||
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 | ||
97 | sysdep-makefiles := $(wildcard $(full_config_sysdirs:=/Makefile)) | |
98 | ifneq (,$(sysdep-makefiles)) | |
99 | include $(sysdep-makefiles) | |
100 | endif | |
101 | ||
102 | ||
103 | # Reorder before-compile so that mach things come first, and hurd things | |
104 | # second, before all else. The mach and hurd subdirectories have many | |
105 | # generated header files which the much of rest of the library depends on, | |
106 | # so it is best to build them first (and mach before hurd, at that). | |
107 | before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\ | |
108 | $(before-compile)) \ | |
109 | $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\ | |
110 | $(before-compile)) | |
111 | ||
112 | # Even before that, we need abi-versions.h which is generated right here. | |
113 | ifeq ($(versioning),yes) | |
114 | ifndef avoid-generated | |
115 | before-compile := $(common-objpfx)abi-versions.h $(before-compile) | |
116 | $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \ | |
117 | $(common-objpfx)Versions.all | |
118 | LC_ALL=C $(AWK) -v oldest_abi=$(oldest-abi) -f $^ > $@T | |
119 | mv -f $@T $@ | |
120 | ||
121 | $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h | |
122 | sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \ | |
123 | $(common-objpfx)abi-versions.h > $@T | |
124 | mv -f $@T $@ | |
125 | endif # avoid-generated | |
126 | endif # $(versioning) = yes | |
127 | ||
0e56981e RM |
128 | |
129 | # Generating headers for assembly constants. | |
130 | # We need this defined early to get into before-compile before | |
131 | # it's used in sysd-rules, below. | |
132 | $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \ | |
133 | %.sym $(before-compile) | |
134 | $(AWK) -f $< $(filter %.sym,$^) \ | |
135 | | $(CC) -S -o - $(CFLAGS) $(CPPFLAGS) -x c - \ | |
136 | -MD -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)' \ | |
137 | | sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' > $(@:.h.d=.h)T | |
138 | sed $(sed-remove-objpfx) $(sed-remove-dotdot) \ | |
139 | $(@:.h=.h.d)T > $(@:.h=.h.d)T2 | |
140 | rm -f $(@:.h=.h.d)T | |
141 | mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d) | |
142 | mv -f $(@:.h.d=.h)T $(@:.h.d=.h) | |
143 | vpath %.sym $(sysdirs) | |
144 | before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h) | |
145 | ||
146 | ||
d73f5331 | 147 | # Make sure the subdirectory for object files gets created. |
1c68c264 | 148 | ifdef objpfx |
d73f5331 | 149 | ifeq (,$(wildcard $(objpfx).)) |
1c68c264 RM |
150 | before-compile += $(objpfx). |
151 | $(objpfx).: | |
152 | $(make-target-directory) | |
153 | endif | |
154 | endif | |
155 | ||
156 | # Remove existing files from `before-compile'. Things are added there when | |
157 | # they must exist for dependency generation to work right, but once they | |
158 | # exist there is no further need for every single file to depend on them, | |
159 | # and those gratuitous dependencies result in many gratuitous | |
160 | # recompilations. | |
161 | before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile)) | |
162 | ||
163 | # Don't let any before-compile file be an intermediate and get removed. | |
164 | ifdef before-compile | |
165 | $(before-compile): | |
166 | endif | |
167 | ||
d73f5331 | 168 | ifndef subdir |
1c68c264 RM |
169 | # If a makefile needs to do something conditional on something that |
170 | # can only be figured out from headers, write a FOO.make.c input | |
171 | # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE | |
172 | # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make. | |
d73f5331 RM |
173 | # |
174 | # We only generate these in the top-level makefile, to avoid any weirdness | |
175 | # from subdir-specific makefile tweaks creeping in on an update. | |
9ae10332 | 176 | $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(before-compile) |
1c68c264 RM |
177 | rm -f $@T $@.dT |
178 | (echo '# Generated from $*.make.c by Makerules.'; \ | |
1c68c264 | 179 | $(CC) $(CFLAGS) $(CPPFLAGS) -E $< \ |
d73f5331 | 180 | -MD -MT '$$(common-objpfx)$*.make' -MF $@.dT \ |
1c68c264 RM |
181 | | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \ |
182 | echo 'common-generated += $(@F)'; \ | |
9ae10332 RM |
183 | sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \ |
184 | rm -f $@.dT) > $@T | |
1c68c264 | 185 | mv -f $@T $@ |
d73f5331 | 186 | endif |
9ae10332 | 187 | |
0e56981e RM |
188 | ifdef subdir |
189 | sed-remove-dotdot := -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' | |
190 | else | |
191 | sed-remove-dotdot := -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' | |
192 | endif | |
1c68c264 RM |
193 | \f |
194 | # Generate an ordered list of implicit rules which find the source files in | |
195 | # each sysdep directory. The old method was to use vpath to search all the | |
196 | # sysdep directories. However, that had the problem that a .S file in a | |
197 | # later directory would be chosen over a .c file in an earlier directory, | |
198 | # which does not preserve the desired sysdeps ordering behavior. | |
199 | ||
1c68c264 RM |
200 | # It matters that this set of rules, for compiling from sources in |
201 | # the current directory (the $srcdir/$subdir) come before the | |
202 | # generated sysdep rules in included from sysd-rules below. When | |
203 | # compiling in the source tree, generated sources go into the current | |
204 | # directory, and those should be chosen before any sources in sysdeps. | |
205 | define o-iterator-doit | |
206 | $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S) | |
207 | endef | |
208 | object-suffixes-left := $(all-object-suffixes) | |
209 | include $(o-iterator) | |
1c68c264 RM |
210 | |
211 | define o-iterator-doit | |
212 | $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s) | |
213 | endef | |
214 | object-suffixes-left := $(all-object-suffixes) | |
215 | include $(o-iterator) | |
1c68c264 RM |
216 | |
217 | define o-iterator-doit | |
218 | $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c) | |
219 | endef | |
220 | object-suffixes-left := $(all-object-suffixes) | |
221 | include $(o-iterator) | |
1c68c264 RM |
222 | |
223 | # Omit the objpfx rules when building in the source tree, because | |
224 | # objpfx is empty and so these rules just override the ones above. | |
225 | ifdef objpfx | |
226 | # Define first rules to find the source files in $(objpfx). | |
227 | # Generated source files will end up there. | |
228 | define o-iterator-doit | |
229 | $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S) | |
230 | endef | |
231 | object-suffixes-left := $(all-object-suffixes) | |
232 | include $(o-iterator) | |
1c68c264 RM |
233 | |
234 | define o-iterator-doit | |
235 | $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s) | |
236 | endef | |
237 | object-suffixes-left := $(all-object-suffixes) | |
238 | include $(o-iterator) | |
1c68c264 RM |
239 | |
240 | define o-iterator-doit | |
241 | $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c) | |
242 | endef | |
243 | object-suffixes-left := $(all-object-suffixes) | |
244 | include $(o-iterator) | |
1c68c264 RM |
245 | endif |
246 | ||
247 | # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard | |
248 | # patterns matching sysdep directories whose assembly source files should | |
249 | # be suppressed. | |
250 | ifdef inhibit-sysdep-asm | |
251 | define open-check-inhibit-asm | |
252 | case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *) | |
253 | endef | |
254 | close-check-inhibit-asm = ;; esac ; | |
255 | endif | |
256 | ||
257 | -include $(+sysdir_pfx)sysd-rules | |
258 | ifneq ($(sysd-rules-sysdirs),$(config-sysdirs)) | |
259 | # The value of $(+sysdep_dirs) the sysd-rules was computed for | |
260 | # differs from the one we are using now. So force a rebuild of sysd-rules. | |
261 | sysd-rules-force = FORCE | |
262 | FORCE: | |
263 | endif | |
264 | $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \ | |
265 | $(wildcard $(foreach dir,$(sysdirs),\ | |
266 | $(dir)/Makefile))\ | |
267 | $(sysd-rules-force) | |
268 | -@rm -f $@T | |
269 | (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \ | |
270 | for dir in $(config-sysdirs:%='$$(..)%'); do \ | |
271 | for o in $(all-object-suffixes); do \ | |
272 | $(open-check-inhibit-asm) \ | |
273 | echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \ | |
274 | \$$(compile-command.S)"; \ | |
275 | echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \ | |
276 | \$$(compile-command.s)"; \ | |
277 | echo "\$$(objpfx)rtld-%$$o: $$dir/%.S \$$(before-compile); \ | |
278 | \$$(compile-command.S)"; \ | |
279 | echo "\$$(objpfx)rtld-%$$o: $$dir/%.s \$$(before-compile); \ | |
280 | \$$(compile-command.s)"; \ | |
281 | echo "\$$(objpfx)ptw-%$$o: $$dir/%.S \$$(before-compile); \ | |
282 | \$$(compile-command.S)"; \ | |
283 | echo "\$$(objpfx)ptw-%$$o: $$dir/%.s \$$(before-compile); \ | |
284 | \$$(compile-command.s)"; \ | |
285 | $(close-check-inhibit-asm) \ | |
286 | echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \ | |
287 | \$$(compile-command.c)"; \ | |
288 | echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \ | |
289 | \$$(compile-command.c)"; \ | |
290 | echo "\$$(objpfx)ptw-%$$o: $$dir/%.c \$$(before-compile); \ | |
291 | \$$(compile-command.c)"; \ | |
292 | done; \ | |
1c68c264 RM |
293 | echo "\$$(objpfx)m_%.S: $$dir/s_%.S; \$$(+make-include-of-dep)"; \ |
294 | echo "\$$(objpfx)m_%.c: $$dir/s_%.c; \$$(+make-include-of-dep)"; \ | |
295 | done; \ | |
296 | echo 'sysd-rules-done = t') > $@T | |
297 | mv -f $@T $@ | |
298 | ||
299 | ifndef sysd-rules-done | |
300 | # Don't do deps until this exists, because it provides rules to make the deps. | |
301 | no_deps=t | |
302 | endif | |
303 | ||
304 | # This is used by the m_%.[Sc] pattern rules in sysd-rules. | |
305 | define +make-include-of-dep | |
306 | echo '#include <$<>' > $@T | |
307 | mv -f $@T $@ | |
308 | endef | |
309 | ||
310 | # Generate version maps, but wait until sysdep-subdirs is known | |
311 | ifeq ($(sysd-sorted-done),t) | |
312 | ifeq ($(versioning),yes) | |
313 | -include $(common-objpfx)sysd-versions | |
314 | $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions | |
315 | common-generated += $(version-maps) | |
316 | postclean-generated += sysd-versions Versions.all abi-versions.h \ | |
317 | Versions.def.v.i Versions.def.v Versions.v.i Versions.v | |
318 | ||
319 | ifndef avoid-generated | |
320 | ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs)) | |
321 | sysd-versions-force = FORCE | |
322 | FORCE: | |
323 | endif | |
324 | # See %.v/%.v.i implicit rules in Makeconfig. | |
325 | $(common-objpfx)Versions.def.v.i: $(..)Versions.def \ | |
326 | $(wildcard $(add-ons:%=$(..)%/Versions.def)) | |
327 | $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \ | |
328 | $(common-objpfx)soversions.i \ | |
329 | $(common-objpfx)Versions.def.v | |
330 | { while read lib version setname; do \ | |
331 | test -z "$$setname" || echo "$$lib : $$setname"; \ | |
332 | done < $(word 2,$^); \ | |
333 | cat $(word 3,$^); \ | |
334 | } | LC_ALL=C $(AWK) -f $< > $@T | |
335 | mv -f $@T $@ | |
336 | # See %.v/%.v.i implicit rules in Makeconfig. | |
337 | $(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \ | |
338 | $(wildcard $(sysdirs:%=%/Versions)) \ | |
339 | $(common-objpfx)abi-versions.h \ | |
340 | $(sysd-versions-force) | |
341 | $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \ | |
342 | $(common-objpfx)Versions.v \ | |
343 | $(..)scripts/versions.awk | |
344 | ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \ | |
345 | cat $(word 2,$^) \ | |
346 | | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \ | |
347 | -v move_if_change='$(move-if-change)' \ | |
348 | -f $(word 3,$^); \ | |
349 | ) > $@T | |
350 | mv -f $@T $@ | |
351 | endif # avoid-generated | |
352 | endif # $(versioning) = yes | |
353 | endif # sysd-sorted-done | |
354 | ||
d73f5331 RM |
355 | # Generate .dT files as we compile. |
356 | compile-mkdep-flags = -MD -MP -MF $@.dt | |
357 | compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags) | |
358 | compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) $(compile-mkdep-flags) | |
359 | compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags) | |
1c68c264 RM |
360 | |
361 | # GCC can grok options after the file name, and it looks nicer that way. | |
362 | compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS) | |
073e82bf RM |
363 | compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \ |
364 | $(ASFLAGS) $(ASFLAGS-$(suffix $@)) | |
365 | COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \ | |
366 | $(ASFLAGS) $(ASFLAGS-$(suffix $@)) | |
1c68c264 RM |
367 | COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS) |
368 | ||
1c68c264 RM |
369 | # We need this for the output to go in the right place. It will default to |
370 | # empty if make was configured to work with a cc that can't grok -c and -o | |
371 | # together. You can't compile the C library with such a compiler. | |
372 | OUTPUT_OPTION = -o $@ | |
373 | ||
374 | # We need the $(CFLAGS) to be in there to have the right predefines during | |
375 | # the dependency run for C sources. But having it for assembly sources can | |
376 | # get the wrong predefines. | |
f4281cc4 | 377 | S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS) |
d73f5331 | 378 | |
1c68c264 RM |
379 | define +make-deps |
380 | $(make-target-directory) | |
381 | $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \ | |
f4281cc4 | 382 | $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed \ |
1c68c264 RM |
383 | -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \ |
384 | $(sed-remove-objpfx) > $(@:.d=.T) | |
385 | mv -f $(@:.d=.T) $@ $(generate-md5) | |
386 | endef | |
d73f5331 | 387 | |
1c68c264 RM |
388 | ifneq (,$(objpfx)) |
389 | # Continuation lines here are dangerous because they introduce spaces! | |
390 | define sed-remove-objpfx | |
391 | -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \ | |
392 | -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g' | |
393 | endef | |
394 | endif | |
395 | \f | |
396 | # Modify the list of routines we build for different targets | |
397 | ||
398 | ifeq (yesyes,$(build-shared)$(elf)) | |
399 | ifndef libc.so-version | |
400 | # Undefine this because it can't work when we libc.so is unversioned. | |
401 | static-only-routines = | |
402 | endif | |
403 | endif | |
404 | ||
405 | # Bounded pointer thunks are only built for *.ob | |
406 | elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks)) | |
407 | ||
408 | elide-routines.oS += $(filter-out $(static-only-routines),\ | |
409 | $(routines) $(aux) $(sysdep_routines)) \ | |
410 | $(elide-bp-thunks) | |
411 | elide-routines.os += $(static-only-routines) $(elide-bp-thunks) | |
412 | ||
413 | # If we have versioned code we don't need the old versions in any of the | |
414 | # static libraries. | |
415 | elide-routines.o += $(shared-only-routines) $(elide-bp-thunks) | |
416 | elide-routines.op += $(shared-only-routines) $(elide-bp-thunks) | |
417 | elide-routines.og += $(shared-only-routines) $(elide-bp-thunks) | |
418 | elide-routines.ob += $(shared-only-routines) | |
419 | \f | |
420 | # Shared library building. | |
421 | ||
422 | ifeq (yes,$(build-shared)) | |
423 | ||
424 | # Reference map file only when versioning is selected and a map file name | |
425 | # is given. | |
426 | ifeq ($(versioning),yes) | |
427 | map-file = $(firstword $($(@F:.so=-map)) \ | |
428 | $(addprefix $(common-objpfx), \ | |
429 | $(filter $(@F:.so=.map),$(version-maps)))) | |
430 | load-map-file = $(map-file:%=-Wl,--version-script=%) | |
431 | endif | |
432 | ||
433 | # Pattern rule to build a shared object from an archive of PIC objects. | |
434 | # This must come after the installation rules so Make doesn't try to | |
435 | # build shared libraries in place from the installed *_pic.a files. | |
436 | # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies | |
437 | # on other shared objects. | |
438 | lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) | |
439 | ifneq (,$(findstring aix,$(config-os))) | |
440 | (echo '#!'; \ | |
441 | dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp) | |
442 | endif | |
443 | $(build-shlib) | |
444 | ||
445 | ifeq ($(elf),yes) | |
446 | define build-shlib-helper | |
a7f7b879 | 447 | $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \ |
73398a44 | 448 | $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(config-LDFLAGS) \ |
1c68c264 RM |
449 | $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \ |
450 | $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \ | |
451 | -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \ | |
452 | $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \ | |
453 | -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) | |
454 | endef | |
455 | else | |
456 | ifneq (,$(findstring aix,$(config-os))) | |
457 | define build-shlib-helper | |
458 | $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \ | |
459 | $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \ | |
460 | $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \ | |
461 | $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \ | |
462 | -L$(subst :, -L,$(rpath-link)) | |
463 | endef | |
464 | else | |
465 | endif | |
466 | endif | |
467 | ||
468 | ifeq (yes,$(elf)) | |
469 | # binutils only position loadable notes into the first page for binaries, | |
470 | # not for shared objects | |
20792f99 | 471 | $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules |
358cad7c RM |
472 | $(LINK.o) -shared -Wl,-O1 \ |
473 | $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \ | |
474 | -Wl,--verbose 2>&1 | \ | |
475 | sed > $@T \ | |
476 | -e '/^=========/,/^=========/!d;/^=========/d' \ | |
1c68c264 | 477 | -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \ |
358cad7c | 478 | -e 's/^.*\*(\.dynbss).*$$/& \ |
20792f99 | 479 | PROVIDE(__start___libc_freeres_ptrs = .); \ |
358cad7c | 480 | *(__libc_freeres_ptrs) \ |
20792f99 | 481 | PROVIDE(__stop___libc_freeres_ptrs = .);/' |
358cad7c RM |
482 | mv -f $@T $@ |
483 | common-generated += shlib.lds | |
484 | ||
485 | define build-shlib | |
486 | $(build-shlib-helper) -o $@ -T $(common-objpfx)shlib.lds \ | |
1c68c264 | 487 | $(csu-objpfx)abi-note.o $(build-shlib-objlist) |
1c68c264 RM |
488 | endef |
489 | else | |
490 | ifneq (,$(findstring aix,$(config-os))) | |
491 | define build-shlib | |
492 | $(build-shlib-helper) \ | |
493 | -o $@ \ | |
494 | $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \ | |
495 | $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so) | |
496 | endef | |
497 | define build-shlib | |
498 | $(build-shlib-helper) \ | |
499 | $(build-shlib-objlist) | |
500 | endef | |
501 | endif | |
502 | endif | |
503 | ||
504 | ifneq (,$(findstring aix,$(config-os))) | |
505 | define build-module-helper | |
506 | $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \ | |
507 | $(sysdep-LDFLAGS) $(config-LDFLAGS) \ | |
508 | $(load-map-file) \ | |
509 | $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \ | |
510 | -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link) | |
511 | endef | |
512 | else | |
513 | define build-module-helper | |
514 | $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \ | |
515 | -B$(csu-objpfx) $(load-map-file) \ | |
516 | $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \ | |
517 | -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) | |
518 | endef | |
519 | endif | |
520 | ||
521 | # This macro is similar to build-shlib but it does not define a soname | |
522 | # and it does not depend on the destination name to start with `lib'. | |
523 | ifeq (yes,$(elf)) | |
524 | # binutils only position loadable notes into the first page for binaries, | |
525 | # not for shared objects | |
526 | define build-module | |
358cad7c | 527 | $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \ |
1c68c264 | 528 | $(csu-objpfx)abi-note.o $(build-module-objlist) |
1c68c264 RM |
529 | endef |
530 | else | |
531 | ifneq (,$(findstring aix,$(config-os))) | |
532 | define build-module | |
533 | $(build-module-helper) \ | |
534 | -o $@ \ | |
535 | $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \ | |
536 | $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so) | |
537 | endef | |
538 | else | |
539 | define build-module | |
540 | define build-module | |
541 | $(build-module-helper) \ | |
542 | -o $@ \ | |
543 | $(build-module-objlist) | |
544 | endef | |
545 | endif | |
546 | endif | |
547 | ||
548 | build-module-helper-objlist = \ | |
549 | $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\ | |
358cad7c | 550 | $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^)) |
1c68c264 RM |
551 | whole-archive := -Wl,--whole-archive |
552 | ||
553 | build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so) | |
554 | build-shlib-objlist = $(build-module-helper-objlist) \ | |
555 | $(LDLIBS-$(@F:lib%.so=%).so) | |
556 | ||
557 | # Don't try to use -lc when making libc.so itself. | |
558 | # Also omits crti.o and crtn.o, which we do not want | |
559 | # since we define our own `.init' section specially. | |
560 | LDFLAGS-c.so = -nostdlib -nostartfiles | |
561 | # But we still want to link libc.so against $(gnulib). | |
562 | LDLIBS-c.so += $(gnulib) | |
563 | # Give libc.so an entry point and make it directly runnable itself. | |
564 | LDFLAGS-c.so += -e __libc_main | |
565 | # Force the backward compatibility EH functions to be linked. | |
566 | LDFLAGS-c.so += -u __register_frame | |
567 | # Pre-link the objects of libc_pic.a so that we can locally resolve | |
568 | # COMMON symbols before we link against ld.so. This is because ld.so | |
569 | # contains some of libc_pic.a already, which will prevent the COMMONs | |
570 | # from being allocated in libc.so, which introduces evil dependencies | |
571 | # between libc.so and ld.so, which can make it impossible to upgrade. | |
572 | ifeq ($(elf),yes) | |
573 | $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a | |
574 | $(LINK.o) -nostdlib -nostartfiles -r -o $@ \ | |
575 | $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^ | |
1c68c264 RM |
576 | # Use our own special initializer and finalizer files for libc.so. |
577 | $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \ | |
578 | $(common-objpfx)libc_pic.os \ | |
579 | $(elfobjdir)/sofini.os \ | |
358cad7c RM |
580 | $(elfobjdir)/interp.os $(elfobjdir)/ld.so \ |
581 | $(common-objpfx)shlib.lds | |
1c68c264 RM |
582 | $(build-shlib) |
583 | ifeq ($(versioning),yes) | |
584 | $(common-objpfx)libc.so: $(common-objpfx)libc.map | |
585 | endif | |
586 | common-generated += libc.so libc_pic.os | |
587 | ifdef libc.so-version | |
588 | $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so | |
589 | $(make-link) | |
590 | common-generated += libc.so$(libc.so-version) | |
591 | endif | |
592 | endif | |
593 | else | |
594 | ifneq (,$(findstring aix,$(config-os))) | |
595 | $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a | |
596 | @rm -f $@ | |
597 | (echo '#!'; \ | |
598 | dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp) | |
599 | sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \ | |
600 | /lib/syscalls.exp > $(common-objpfx)syscalls.exp | |
601 | $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \ | |
602 | -bE:$(common-objpfx)syscalls.exp \ | |
603 | -bI:$(common-objpfx)syscalls.exp \ | |
604 | -L$(common-objpfx) -o $@ $^ | |
605 | # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired | |
606 | cp $@ $(common-objpfx)shr.o | |
607 | $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o | |
608 | endif | |
609 | endif | |
610 | \f | |
611 | # Figure out the source filenames in this directory. | |
612 | ||
613 | override sources := $(addsuffix .c,\ | |
614 | $(filter-out $(elided-routines),\ | |
615 | $(routines) $(aux) \ | |
616 | $(sysdep_routines))) | |
617 | sysdep_routines := $(sysdep_routines) | |
618 | ||
619 | headers := $(headers) $(sysdep_headers) | |
620 | ||
621 | # This is the list of all object files, gotten by | |
622 | # replacing every ".c" in `sources' with a ".o". | |
623 | # We also add bounded-pointer thunks, which are later | |
624 | # elided for all suffixes except for `.ob'. | |
625 | override objects := $(addprefix $(objpfx),$(sources:.c=.o) \ | |
626 | $(patsubst %,$(bppfx)%.o,\ | |
627 | $(filter $(routines) $(sysdep_routines),$(bp-thunks)))) | |
628 | ||
629 | ||
630 | # The makefile may define $(extra-libs) with `libfoo libbar' | |
631 | # to build libfoo.a et al from the modules listed in $(libfoo-routines). | |
632 | ifdef extra-libs | |
633 | # extra-lib.mk is included once for each extra lib to define rules | |
634 | # to build it, and to add its objects to the various variables. | |
635 | # During its evaluation, $(lib) is set to the name of the library. | |
636 | extra-libs-left := $(extra-libs) | |
637 | include $(patsubst %,$(..)extra-lib.mk,$(extra-libs)) | |
638 | endif | |
639 | \f | |
640 | +depfiles := $(sources:.c=.d) \ | |
641 | $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \ | |
642 | $(addsuffix .d,$(tests) $(xtests) $(test-srcs)) | |
643 | ifeq ($(build-programs),yes) | |
644 | +depfiles += $(addsuffix .d,$(others) $(sysdep-others)) | |
645 | endif | |
646 | +depfiles := $(addprefix $(objpfx),\ | |
647 | $(filter-out $(addsuffix .d,$(omit-deps)),\ | |
9ae10332 | 648 | $(+depfiles))) |
d73f5331 RM |
649 | all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt)) |
650 | +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \ | |
651 | $(wildcard $(all-dt-files:.dt=.d)) | |
652 | ||
653 | # This is a funny rule in that it removes its input file. | |
654 | %.d: %.dt | |
655 | @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \ | |
656 | mv -f $(@:.d=.T) $@ && \ | |
657 | rm -f $< | |
9ae10332 RM |
658 | |
659 | # Avoid the .h.d files for any .sym files whose .h files don't exist yet. | |
660 | # They will be generated when they're needed, and trying too early won't work. | |
661 | +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h) | |
662 | +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\ | |
663 | $(+gen-as-const))) | |
1c68c264 RM |
664 | |
665 | ifdef +depfiles | |
666 | ifneq ($(no_deps),t) | |
667 | -include $(+depfiles) | |
668 | endif | |
669 | endif | |
670 | \f\f | |
671 | # Maximize efficiency by minimizing the number of rules. | |
672 | .SUFFIXES: # Clear the suffix list. We don't use suffix rules. | |
673 | # Don't define any builtin rules. | |
674 | MAKEFLAGS := $(MAKEFLAGS)r | |
675 | ||
676 | # Generic rule for making directories. | |
677 | %/: | |
678 | # mkdir isn't smart enough to strip a trailing /. | |
679 | mkdir $(@:%/=%) | |
680 | \f | |
681 | # Make sure that object files are not removed | |
682 | # when they are intermediates between sources and library members. | |
683 | .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes)) | |
684 | ||
685 | # Make sure that the parent library archive is never removed. | |
686 | .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c)) | |
687 | \f | |
688 | # Use the verbose option of ar and tar when not running silently. | |
689 | ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s | |
690 | verbose := v | |
691 | else # -s | |
692 | verbose := | |
693 | endif # not -s | |
694 | ||
695 | ARFLAGS := r$(verbose) | |
696 | CREATE_ARFLAGS := cru$(verbose) | |
697 | \f | |
698 | # This makes all the object files in the parent library archive. | |
699 | ||
700 | .PHONY: lib lib-noranlib | |
701 | lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c)) | |
702 | lib-noranlib: libobjs | |
703 | ||
704 | # For object-suffix $o, the list of objects with that suffix. | |
705 | # Makefiles can define `elide-routines.so = foo' to leave foo.so out. | |
706 | o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\ | |
707 | $(elide-routines$o)),\ | |
708 | $(objects))) \ | |
709 | $(addprefix $(objpfx),$(o-objects$o)) | |
710 | ||
711 | others: $(addprefix $(objpfx),$(install-lib)) | |
712 | ||
713 | ifndef objects | |
714 | ||
715 | # Create the stamp$o files to keep the parent makefile happy. | |
716 | subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o) | |
717 | $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o): | |
718 | $(make-target-directory) | |
719 | rm -f $@; > $@ | |
720 | else | |
721 | ||
722 | # Define explicit rules to update each $(objpfx)stamp.SUFFIX | |
723 | # timestamp file; these rules (one explicit rule is generated for each | |
724 | # object suffix) write a list of objects to update in the stamp file. | |
725 | # The parent will then actually add them all to the archive in the | |
726 | # archive rule, below. | |
727 | define o-iterator-doit | |
728 | $(objpfx)stamp$o: $(o-objects); $$(do-stamp) | |
729 | endef | |
730 | define do-stamp | |
731 | echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T | |
732 | mv -f $@T $@ | |
733 | endef | |
734 | object-suffixes-left := $(object-suffixes-for-libc) | |
735 | include $(o-iterator) | |
736 | ||
737 | endif | |
738 | ||
739 | # Now define explicit rules to build the library archives; these depend | |
740 | # on the stamp files built above. | |
741 | define o-iterator-doit | |
742 | $(common-objpfx)$(patsubst %,$(libtype$o),c): \ | |
743 | $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib) | |
744 | endef | |
745 | define do-makelib | |
746 | cd $(common-objdir) && \ | |
747 | $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)` | |
748 | $(RANLIB) $@ | |
749 | endef | |
750 | subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%) | |
751 | subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps)) | |
752 | ifndef subdir | |
753 | $(subdirs-stamps): subdir_lib; | |
754 | endif | |
755 | object-suffixes-left = $(object-suffixes-for-libc) | |
756 | include $(o-iterator) | |
757 | ||
758 | ||
759 | # This makes all the object files. | |
760 | .PHONY: objects objs libobjs extra-objs | |
761 | objects objs: libobjs extra-objs | |
762 | libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o) | |
763 | extra-objs: $(addprefix $(objpfx),$(extra-objs)) | |
764 | ||
765 | # Canned sequence for building an extra library archive. | |
766 | define build-extra-lib | |
767 | $(patsubst %/,cd % &&,$(objpfx)) \ | |
768 | $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \ | |
769 | $(patsubst $(objpfx)%,%,$^) | |
770 | $(RANLIB) $@ | |
771 | endef | |
772 | \f | |
773 | # Installation. | |
774 | ||
775 | .PHONY: force-install | |
776 | force-install: | |
777 | ||
778 | # $(install-lib) are installed from the object directory into $(libdir); | |
779 | # files in $(install-lib) matching `lib%.a' are ranlib'd after installation | |
780 | # unless they also appear in $(non-lib.a). $(install-data) are installed | |
781 | # as they are into $(datadir). $(headers) are installed as they are in | |
782 | # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin) | |
783 | # are installed from the object directory into $(bindir), $(bindir) and | |
784 | # $(sbindir), respectively. $(install-others) are absolute path names of | |
785 | # files to install; rules to install them are defined elsewhere. | |
786 | ||
787 | # The simple library name to install libc.a under. | |
788 | # This could be defined by a sysdep Makefile. | |
789 | ifndef libc-name | |
790 | libc-name := c | |
791 | endif | |
792 | ||
793 | define do-install | |
794 | $(make-target-directory) | |
795 | $(INSTALL_DATA) $< $@ | |
796 | endef | |
797 | ||
798 | # Make the target directory if it doesn't exist, using the `mkinstalldirs' | |
799 | # script that does `mkdir -p' even if `mkdir' doesn't support that flag. | |
800 | define make-target-directory | |
801 | $(addprefix $(..)./scripts/mkinstalldirs ,\ | |
802 | $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%))) | |
803 | endef | |
804 | ||
805 | # Any directory (parent or subdir) should install libc.a; this way | |
806 | # "make install" in a subdir is guaranteed to install everything it changes. | |
807 | installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\ | |
808 | $(inst_libdir)/$(patsubst %,$(libtype$o),\ | |
809 | $(libprefix)$(libc-name))) | |
810 | install: $(installed-libcs) | |
811 | $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force) | |
812 | $(make-target-directory) | |
813 | $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@ | |
814 | # Running ranlib after installing makes the __.SYMDEF time stamp up to | |
815 | # date, which avoids messages from some linkers. | |
816 | $(RANLIB) $@ | |
817 | ||
818 | define do-install-program | |
819 | $(make-target-directory) | |
820 | $(INSTALL_PROGRAM) $< $@.new | |
821 | mv -f $@.new $@ | |
822 | endef | |
823 | ||
824 | define do-install-script | |
825 | $(make-target-directory) | |
826 | $(INSTALL_SCRIPT) $< $@.new | |
827 | mv -f $@.new $@ | |
828 | endef | |
829 | ||
830 | install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so)) | |
831 | install-lib := $(filter-out %.so %_pic.a,$(install-lib)) | |
832 | ||
833 | ifeq (yes,$(build-shared)) | |
834 | # Find which .so's have versions. | |
835 | versioned := $(strip $(foreach so,$(install-lib.so),\ | |
836 | $(patsubst %,$(so),$($(so)-version)))) | |
837 | ||
838 | install-lib.so-versioned := $(filter $(versioned), $(install-lib.so)) | |
839 | install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so)) | |
840 | ||
cc8bfce9 RM |
841 | # For versioned libraries, we install three files: |
842 | # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script | |
843 | # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink | |
844 | # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file | |
7a0c303e | 845 | V := $(firstword $($(subdir)-version) $(version)) |
cc8bfce9 RM |
846 | install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \ |
847 | $(foreach L,$(install-lib.so-versioned),\ | |
848 | $(inst_libdir)/$L \ | |
7a0c303e | 849 | $(inst_slibdir)/$(L:.so=)-$V.so \ |
cc8bfce9 | 850 | $(inst_slibdir)/$L$($L-version)) |
1c68c264 RM |
851 | |
852 | # Install all the unversioned shared libraries. | |
853 | $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \ | |
854 | $(objpfx)%.so $(+force) | |
855 | $(do-install-program) | |
856 | ||
857 | ifneq ($(findstring -s,$(LN_S)),) | |
858 | define make-link | |
859 | rm -f $@.new | |
860 | $(SHELL) $(..)scripts/rellns-sh $< $@.new | |
861 | mv -f $@.new $@ | |
862 | endef | |
863 | else | |
864 | # If we have no symbolic links don't bother with rellns-sh. | |
865 | define make-link | |
866 | rm -f $@.new | |
867 | $(LN_S) $< $@.new | |
868 | mv -f $@.new $@ | |
869 | endef | |
870 | endif | |
871 | ||
872 | ifeq (yes,$(build-shared)) | |
873 | ifeq (no,$(cross-compiling)) | |
874 | symbolic-link-prog := $(common-objpfx)elf/sln | |
875 | symbolic-link-list := $(common-objpfx)elf/symlink.list | |
876 | define make-shlib-link | |
877 | echo $(<F) $@ >> $(symbolic-link-list) | |
878 | endef | |
879 | else # cross-compiling | |
880 | # We need a definition that can be used by elf/Makefile's install rules. | |
881 | symbolic-link-prog = $(LN_S) | |
882 | endif | |
883 | endif | |
884 | ifndef make-shlib-link | |
885 | define make-shlib-link | |
886 | rm -f $@ | |
887 | $(LN_S) $(<F) $@ | |
888 | endef | |
889 | endif | |
890 | ||
891 | ifdef libc.so-version | |
892 | # For a library specified to be version N, install three files: | |
893 | # libc.so -> libc.so.N (e.g. libc.so.6) | |
894 | # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so) | |
895 | ||
896 | $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \ | |
897 | $(+force) | |
898 | $(make-shlib-link) | |
899 | $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force) | |
900 | $(do-install-program) | |
901 | install: $(inst_slibdir)/libc.so$(libc.so-version) | |
902 | ||
903 | # This fragment of linker script gives the OUTPUT_FORMAT statement | |
904 | # for the configuration we are building. We put this statement into | |
905 | # the linker scripts we install for -lc et al so that they will not be | |
906 | # used by a link for a different format on a multi-architecture system. | |
907 | $(common-objpfx)format.lds: $(..)scripts/output-format.sed \ | |
908 | $(common-objpfx)config.make \ | |
909 | $(common-objpfx)config.h $(..)Makerules | |
910 | $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \ | |
911 | -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \ | |
912 | | sed -n -f $< > $@.new | |
913 | rm -f $@.so | |
914 | mv -f $@.new $@ | |
915 | common-generated += format.lds | |
916 | ||
917 | ifndef subdir | |
918 | # What we install as libc.so for programs to link against is in fact a | |
919 | # link script. It contains references for the various libraries we need. | |
920 | # The libc.so object is not complete since some functions are only defined | |
921 | # in libc_nonshared.a. | |
922 | # We need to use absolute paths since otherwise local copies (if they exist) | |
923 | # of the files are taken by the linker. | |
924 | install: $(inst_libdir)/libc.so | |
925 | $(inst_libdir)/libc.so: $(common-objpfx)format.lds \ | |
926 | $(common-objpfx)libc.so$(libc.so-version) \ | |
927 | $(inst_libdir)/$(patsubst %,$(libtype.oS),\ | |
928 | $(libprefix)$(libc-name)) \ | |
929 | $(+force) | |
930 | (echo '/* GNU ld script';\ | |
931 | echo ' Use the shared library, but some functions are only in';\ | |
932 | echo ' the static library, so try that secondarily. */';\ | |
933 | cat $<; \ | |
934 | echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \ | |
935 | '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\ | |
936 | ')' \ | |
937 | ) > $@.new | |
938 | mv -f $@.new $@ | |
939 | ||
940 | endif | |
941 | ||
942 | else | |
943 | install: $(inst_slibdir)/libc.so | |
944 | $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force) | |
945 | $(do-install-program) | |
946 | endif | |
947 | ||
948 | ifneq (,$(versioned)) | |
949 | # Produce three sets of rules as above for all the smaller versioned libraries. | |
950 | ||
951 | define o-iterator-doit | |
952 | $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link) | |
953 | endef | |
2afbfec4 RM |
954 | object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned)) |
955 | ifneq (,$(object-suffixes-left)) | |
1c68c264 | 956 | include $(o-iterator) |
2afbfec4 | 957 | endif |
1c68c264 RM |
958 | |
959 | # Make symlinks in the build directory, because the versioned names might | |
960 | # be referenced by a DT_NEEDED in another library. | |
961 | define o-iterator-doit | |
962 | $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link) | |
963 | endef | |
964 | object-suffixes-left := $(versioned) | |
965 | include $(o-iterator) | |
966 | ||
967 | generated += $(foreach o,$(versioned),$o$($o-version)) | |
968 | ||
969 | ifeq (,$($(subdir)-version)) | |
970 | define o-iterator-doit | |
971 | $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \ | |
972 | $(+force); | |
973 | $$(make-shlib-link) | |
974 | endef | |
975 | object-suffixes-left := $(versioned) | |
976 | include $(o-iterator) | |
977 | ||
978 | define o-iterator-doit | |
979 | $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force); | |
980 | $$(do-install-program) | |
981 | endef | |
982 | object-suffixes-left := $(versioned) | |
983 | include $(o-iterator) | |
984 | else | |
985 | define o-iterator-doit | |
986 | $(inst_slibdir)/$o$($o-version): \ | |
987 | $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force); | |
988 | $$(make-shlib-link) | |
989 | endef | |
990 | object-suffixes-left := $(versioned) | |
991 | include $(o-iterator) | |
992 | ||
993 | define o-iterator-doit | |
994 | $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force); | |
995 | $$(do-install-program) | |
996 | endef | |
997 | object-suffixes-left := $(versioned) | |
998 | include $(o-iterator) | |
999 | endif | |
1000 | endif | |
1001 | ||
1002 | define do-install-so | |
1003 | $(do-install-program) | |
1004 | $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\ | |
1005 | $(filter-out %.so,$@)) | |
1006 | endef | |
1007 | ||
1008 | so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version))) | |
1009 | $(foreach v,$(so-versions),\ | |
1010 | $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \ | |
1011 | $(+force) | |
1012 | $(do-install-so) | |
1013 | $(foreach v,$(so-versions),\ | |
1014 | $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force) | |
1015 | $(do-install-so) | |
1016 | endif | |
1017 | ||
1018 | ifdef install-bin | |
1019 | $(addprefix $(inst_bindir)/,$(install-bin)): \ | |
1020 | $(inst_bindir)/%: $(objpfx)% $(+force) | |
1021 | $(do-install-program) | |
1022 | endif | |
1023 | ifdef install-bin-script | |
1024 | $(addprefix $(inst_bindir)/,$(install-bin-script)): \ | |
1025 | $(inst_bindir)/%: $(objpfx)% $(+force) | |
1026 | $(do-install-script) | |
1027 | endif | |
1028 | ifdef install-rootsbin | |
1029 | $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \ | |
1030 | $(inst_rootsbindir)/%: $(objpfx)% $(+force) | |
1031 | $(do-install-program) | |
1032 | endif | |
1033 | ifdef install-sbin | |
1034 | $(addprefix $(inst_sbindir)/,$(install-sbin)): \ | |
1035 | $(inst_sbindir)/%: $(objpfx)% $(+force) | |
1036 | $(do-install-program) | |
1037 | endif | |
1038 | ifdef install-lib | |
1039 | install-lib.a := $(filter lib%.a,$(install-lib)) | |
1040 | install-lib-non.a := $(filter-out lib%.a,$(install-lib)) | |
1041 | ifdef install-lib-non.a | |
1042 | $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \ | |
1043 | $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force) | |
1044 | $(do-install) | |
1045 | endif | |
1046 | ifdef install-lib.a | |
1047 | $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \ | |
1048 | $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force) | |
1049 | $(do-install) | |
1050 | $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F))) | |
1051 | endif | |
1052 | endif | |
1053 | ifdef install-data | |
1054 | $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force) | |
1055 | $(do-install) | |
1056 | endif | |
1057 | headers := $(strip $(headers)) | |
1058 | ifdef headers | |
1059 | $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force) | |
1060 | $(do-install) | |
1061 | endif # headers | |
1062 | ||
1063 | .PHONY: install-bin-nosubdir install-bin-script-nosubdir \ | |
1064 | install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \ | |
1065 | install-data-nosubdir install-headers-nosubdir | |
1066 | install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin)) | |
1067 | install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script)) | |
1068 | install-rootsbin-nosubdir: \ | |
1069 | $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)) | |
1070 | install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin)) | |
1071 | install-lib-nosubdir: $(addprefix $(inst_libdir)/,\ | |
1072 | $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \ | |
1073 | $(addprefix $(libprefix),$(install-lib-non.a))) | |
1074 | install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data)) | |
1075 | install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers)) | |
1076 | install-others-nosubdir: $(install-others) | |
1077 | ||
1078 | # We need all the `-nosubdir' targets so that `install' in the parent | |
1079 | # doesn't depend on several things which each iterate over the subdirs. | |
1080 | # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a | |
1081 | # subroutine. Then in the parent `install-FOO' also causes subdir makes. | |
1082 | install-%:: install-%-nosubdir ; | |
1083 | ||
1084 | .PHONY: install install-no-libc.a-nosubdir | |
1085 | ifeq ($(build-programs),yes) | |
1086 | install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ | |
1087 | install-bin-nosubdir install-bin-script-nosubdir \ | |
1088 | install-lib-nosubdir install-others-nosubdir \ | |
1089 | install-rootsbin-nosubdir install-sbin-nosubdir | |
1090 | else | |
1091 | install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ | |
1092 | install-lib-nosubdir install-others-nosubdir | |
1093 | endif | |
1094 | install: install-no-libc.a-nosubdir | |
1095 | \f | |
1096 | # Command to compile $< in $(objdir) using the native libraries. | |
1097 | define native-compile | |
1098 | $(make-target-directory) | |
1099 | $(patsubst %/,cd % &&,$(objpfx)) \ | |
1100 | $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \ | |
1101 | $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F) | |
1102 | endef | |
1103 | ||
1104 | # Command to compile $< in $(common-objdir) using the native libraries. | |
1105 | # We must cd to $(objdir) anyway so that $(..)config.h is valid. | |
1106 | define common-objdir-compile | |
1107 | $(patsubst %/,cd % &&,$(objpfx)) \ | |
1108 | $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \ | |
1109 | $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F) | |
1110 | endef | |
1111 | ||
1112 | # We always want to use configuration definitions. | |
1113 | # Note that this is only used for commands running in $(objpfx). | |
1114 | ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h | |
1115 | ||
1116 | # Support the GNU standard name for this target. | |
1117 | .PHONY: check | |
1118 | check: tests | |
1119 | # Special target to run tests which cannot be run unconditionally. | |
1120 | # Maintainers should use this target. | |
1121 | .PHONY: xcheck | |
1122 | xcheck: xtests | |
1123 | ||
1124 | all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others)) | |
1125 | ifneq (,$(all-nonlib)) | |
1126 | cpp-srcs-left = $(all-nonlib:=.c) | |
1127 | lib := nonlib | |
1128 | include $(patsubst %,$(..)cppflags-iterator.mk,$(all-nonlib)) | |
1129 | endif | |
1130 | ||
1131 | # The include magic above causes those files to use this variable for flags. | |
1132 | CPPFLAGS-nonlib = -DNOT_IN_libc=1 | |
1133 | ||
1134 | ||
1135 | ifeq ($(versioning),yes) | |
1136 | # Generate normalized lists of symbols, versions, and data sizes. | |
1137 | # This is handy for checking against existing library binaries. | |
1138 | ||
1139 | %.symlist: $(..)scripts/abilist.awk %.dynsym | |
1140 | LC_ALL=C $(AWK) -f $^ > $@T | |
1141 | mv -f $@T $@ | |
1142 | ||
1143 | %.dynsym: %.so | |
1144 | $(OBJDUMP) --dynamic-syms $< > $@T | |
1145 | mv -f $@T $@ | |
1146 | ||
1c68c264 | 1147 | check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \ |
9ae10332 RM |
1148 | $(..)abilist/%.abilist $(objpfx)%.symlist |
1149 | $(check-abi) | |
1150 | check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \ | |
1151 | $(..)abilist/%.abilist $(common-objpfx)%.symlist | |
1152 | $(check-abi) | |
1153 | define check-abi | |
1c68c264 | 1154 | LC_ALL=C \ |
9ae10332 | 1155 | $(AWK) -f $< -v 'config=$(check-abi-config)' \ |
1c68c264 | 1156 | $(filter %.abilist,$^) \ |
fd54683c | 1157 | | { diff -pu0 - $(filter %.symlist,$^) $(check-abi-warn) ; } |
9ae10332 | 1158 | endef |
fd54683c RM |
1159 | ifeq ($(enable-check-abi),warn) |
1160 | check-abi-warn = || echo '*** WARNING: $*.so failed ABI check' | |
1161 | endif | |
1c68c264 | 1162 | |
643931fb | 1163 | ifeq ($(firstword $(sysd-sorted-done) f)$(firstword $(generating) f),tf) |
0e56981e | 1164 | -include $(common-objpfx)tls.make |
fd54683c RM |
1165 | config-tls := notls |
1166 | ifeq ($(use-tls),yes) | |
1167 | config-tls := tls | |
1168 | endif | |
1169 | ifeq ($(use-thread),yes) | |
1170 | config-tls := thread | |
1171 | endif | |
9ae10332 | 1172 | check-abi-config := \ |
fd54683c | 1173 | $(config-machine)-$(config-vendor)-$(config-os)/$(config-tls) |
9ae10332 RM |
1174 | endif |
1175 | ||
1176 | update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \ | |
1177 | $(objpfx)%.symlist | |
1178 | $(update-abi) | |
1179 | update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \ | |
1180 | $(common-objpfx)%.symlist | |
1181 | $(update-abi) | |
1c68c264 | 1182 | ifndef update-abi-config |
9ae10332 | 1183 | define update-abi |
1c68c264 | 1184 | @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2 |
9ae10332 | 1185 | endef |
1c68c264 | 1186 | else |
9ae10332 | 1187 | define update-abi |
fd54683c | 1188 | LC_ALL=C $(AWK) -v config='$(update-abi-config)' -f $^ \ |
9ae10332 RM |
1189 | > $(..)abilist/$*.abilist.new |
1190 | @if cmp -s $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist 2> /dev/null; \ | |
1191 | then rm -f $(..)abilist/$*.abilist.new; \ | |
1192 | echo '+++ $(..)abilist/$*.abilist is unchanged'; \ | |
1193 | else mv -f $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist; \ | |
1194 | echo '*** Now check $*.abilist changes for correctness ***'; \ | |
1195 | fi | |
1196 | endef | |
1c68c264 RM |
1197 | endif |
1198 | ||
1199 | .PHONY: update-abi check-abi | |
1200 | update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned)) | |
1201 | check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned)) | |
1202 | ifdef subdir | |
1203 | subdir_check-abi: check-abi | |
1204 | subdir_update-abi: update-abi | |
1205 | else | |
1206 | check-abi: subdir_check-abi | |
1207 | update-abi: subdir_update-abi | |
1208 | endif | |
1209 | ||
1c68c264 RM |
1210 | ifeq ($(subdir),elf) |
1211 | check-abi: check-abi-libc | |
1212 | update-abi: update-abi-libc | |
1213 | common-generated += libc.symlist | |
1214 | endif | |
1215 | ||
fd54683c RM |
1216 | ifeq ($(build-shared),yes) |
1217 | ifneq ($(enable-check-abi),no) | |
94659495 RM |
1218 | ifdef subdir |
1219 | tests: check-abi | |
1220 | endif | |
1221 | endif | |
fd54683c | 1222 | endif |
94659495 | 1223 | |
1c68c264 | 1224 | endif |
aad08dba | 1225 | |
9ae10332 RM |
1226 | # There's no good place to put this - here will do. |
1227 | # The dependencies are wrong if it's run from the top level. | |
1228 | ifeq ($(filter %posix, $(sysdirs)),) | |
1229 | L_tmpnam = 1 | |
1230 | TMP_MAX = 0 | |
1231 | L_ctermid = 1 | |
1232 | L_cuserid = 1 | |
1233 | else | |
1234 | L_tmpnam = 20 | |
1235 | TMP_MAX = 238328 | |
1236 | L_ctermid = 9 | |
1237 | L_cuserid = 9 | |
1238 | endif | |
1239 | stdio_lim = $(common-objpfx)bits/stdio_lim.h | |
1240 | ||
1241 | $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @: | |
1242 | $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \ | |
1243 | $(common-objpfx)config.make | |
1244 | $(make-target-directory) | |
1245 | echo '#include "$(..)posix/bits/posix1_lim.h"' | \ | |
1246 | SUNPRO_DEPENDENCIES='$(@:st=dT) $@' \ | |
1247 | $(CC) $(+includes) -E -dM -xc - -o $(@:st=hT) | |
1248 | echo '#include "$(..)misc/sys/uio.h"' | \ | |
1249 | SUNPRO_DEPENDENCIES='$(@:st=dT) $@' \ | |
1250 | $(CC) -D_LIBC=1 $(+includes) -E -dM -xc - | cat - >> $(@:st=hT) | |
1251 | ifdef sed-remove-objpfx | |
1252 | sed $(sed-remove-objpfx) $(@:st=dT) > $(@:st=dt) | |
1253 | cat $(@:st=dt) >> $(@:st=d) | |
1254 | else | |
1255 | cat $(@:st=dT) >> $(@:st=d) | |
1256 | endif | |
1257 | fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \ | |
1258 | filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \ | |
1259 | iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \ | |
1260 | fopen_max=$${fopen_max:-16}; \ | |
1261 | filename_max=$${filename_max:-1024}; \ | |
1262 | if [ -z $$iov_max ]; then \ | |
1263 | define_iov_max="# undef IOV_MAX"; \ | |
1264 | else \ | |
1265 | define_iov_max="# define IOV_MAX $$iov_max"; \ | |
1266 | fi; \ | |
1267 | sed -e "s/@FOPEN_MAX@/$$fopen_max/" \ | |
1268 | -e "s/@FILENAME_MAX@/$$filename_max/" \ | |
1269 | -e "s/@L_tmpnam@/$(L_tmpnam)/" \ | |
1270 | -e "s/@TMP_MAX@/$(TMP_MAX)/" \ | |
1271 | -e "s/@L_ctermid@/$(L_ctermid)/" \ | |
1272 | -e "s/@L_cuserid@/$(L_cuserid)/" \ | |
1273 | -e "s/@define_IOV_MAX@/$$define_iov_max/" \ | |
1274 | $< > $(@:st=h.new) | |
1275 | $(move-if-change) $(@:st=h.new) $(@:st=h) | |
1276 | # Remove these last so that they can be examined if something went wrong. | |
1277 | rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt) | |
1278 | touch $@ | |
1279 | # Get dependencies. | |
1280 | ifndef no_deps | |
1281 | -include $(stdio_lim:h=d) | |
1282 | endif | |
1283 | common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st | |
1c68c264 RM |
1284 | \f |
1285 | .PHONY: TAGS | |
1286 | TAGS: $(objpfx)distinfo $(..)MakeTAGS | |
1287 | $(MAKE) $(addprefix -f ,$^) $@ | |
1288 | ||
1289 | $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE | |
1290 | $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@ | |
1291 | FORCE: | |
1292 | ||
1293 | ||
1294 | .PHONY: echo-headers | |
1295 | echo-headers: | |
1296 | @echo $(headers) | |
1297 | ||
1298 | \f | |
1299 | # Common cleaning targets. | |
1300 | ||
1301 | .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean | |
1302 | clean: common-clean | |
1303 | mostlyclean: common-mostlyclean | |
1304 | ||
1305 | do-tests-clean: | |
1306 | -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \ | |
1307 | $(test-srcs)) \ | |
1308 | $(addsuffix -bp.out,$(tests) $(xtests) \ | |
1309 | $(test-srcs))) | |
1310 | ||
1311 | # Remove the object files. | |
1312 | common-mostlyclean: | |
1313 | -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \ | |
1314 | $(others) $(sysdep-others) stubs \ | |
1315 | $(addsuffix .o,$(tests) $(xtests) \ | |
1316 | $(test-srcs) $(others) \ | |
1317 | $(sysdep-others)) \ | |
1318 | $(addsuffix -bp,$(tests) $(xtests) \ | |
1319 | $(test-srcs)) \ | |
1320 | $(addsuffix .out,$(tests) $(xtests) \ | |
1321 | $(test-srcs)) \ | |
1322 | $(addsuffix -bp.out,$(tests) $(xtests) \ | |
1323 | $(test-srcs))) | |
1324 | -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \ | |
1325 | $(install-lib.so) \ | |
1326 | $(install-lib.so:%.so=%_pic.a)) | |
1327 | -rm -f core | |
1328 | -rm -f $(objpfx)rtld-*.os | |
1329 | $(rmobjs) | |
1330 | define rmobjs | |
1331 | $(foreach o,$(object-suffixes-for-libc), | |
1332 | -rm -f $(objpfx)stamp$o $(o-objects)) | |
1333 | endef | |
1334 | ||
1335 | # Also remove the dependencies and generated source files. | |
1336 | common-clean: common-mostlyclean | |
d73f5331 RM |
1337 | -rm -f $(addprefix $(objpfx),$(generated)) |
1338 | -rm -f $(objpfx)*.d $(objpfx)*.dt | |
1c68c264 RM |
1339 | -rm -fr $(addprefix $(objpfx),$(generated-dirs)) |
1340 | -rm -f $(addprefix $(common-objpfx),$(common-generated)) | |
1341 | -rm -f $(objpfx)distinfo | |
1342 | \f | |
1343 | # Produce a file `stubs' which contains `#define __stub_FUNCTION' | |
1344 | # for each function which is a stub. We grovel over all the .d files | |
1345 | # looking for references to <stub-tag.h>. Then we grovel over each | |
1346 | # referenced source file to see what stub function it defines. | |
1347 | ||
1348 | ifdef objpfx | |
1349 | .PHONY: stubs # The parent Makefile calls this target. | |
1350 | stubs: $(objpfx)stubs | |
1351 | endif | |
1c68c264 RM |
1352 | $(objpfx)stubs: $(+depfiles) |
1353 | # Use /dev/null since `...` might expand to empty. | |
fd54683c | 1354 | (s=`cd $(sysdep_dir) && $(PWD_P)`; \ |
1c68c264 RM |
1355 | $(patsubst %/,cd % &&,$(objpfx)) \ |
1356 | sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \ | |
fd54683c RM |
1357 | `sed -n -e 's@$(sysdep_dir)/@'"$$s"'/@g' \ |
1358 | -e 's@\$$(common-objpfx)@$(..)@g' -e 's@\$$(objpfx)@@g' \ | |
1359 | -e '/: *[^ ]/{s@^.*: *\([^ ]*\) .*$$@\1@; h; }' \ | |
1360 | -e '/:$$/d' \ | |
1361 | -e '/stub-tag\.h/{; g; p; }' \ | |
1c68c264 RM |
1362 | $(patsubst $(objpfx)%,%,$^) /dev/null` \ |
1363 | /dev/null) > $@T | |
1364 | mv -f $@T $@ | |
1365 | \f | |
1366 | # Make the distribution tar file. | |
1367 | ||
1368 | .PHONY: dist | |
1369 | dist: $(objpfx)distinfo $(..)Make-dist | |
1370 | $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args) | |
1371 | ||
1372 | # Avoid depending on source files found in sysdeps dirs, | |
1373 | # because the references affect implicit rule selection. | |
1374 | dist: $(filter-out %.c %.S %.s,$(distribute)) | |
1375 | ||
1376 | # We used to simply export all these variables, but that frequently made the | |
1377 | # environment get too large. Instead, we write all the information into | |
1378 | # a generated makefile fragment `distinfo', and then include it with -f in | |
1379 | # the sub-make that makes the distribution (above). | |
1380 | $(objpfx)distinfo: Makefile $(..)Makerules \ | |
1381 | $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile)) | |
1382 | $(make-target-directory) | |
1383 | $(distinfo-vars) | |
1384 | mv -f $@.new $@ | |
1385 | .PHONY: subdir_distinfo | |
1386 | subdir_distinfo: $(objpfx)distinfo | |
1387 | ||
1388 | define distinfo-vars | |
1389 | rm -f $@.new | |
1390 | echo > $@.new 'subdir := $(subdir)' | |
1391 | $(foreach var,subdir-dirs sources elided-routines sysdep_routines \ | |
1392 | headers sysdep_headers distribute dont_distribute generated \ | |
1393 | others tests xtests test-srcs extra-libs versioned \ | |
1394 | $(extra-libs:%=%-routines) \ | |
1395 | $(addprefix install-,lib lib.so data bin bin-script sbin others), | |
1396 | echo >> $@.new '$(subdir)-$(var) := $($(var))' | |
1397 | echo >> $@.new '$(var) = $$($(subdir)-$(var))') | |
1398 | endef | |
1399 | \f | |
1400 | ifneq (,$(strip $(gpl2lgpl))) | |
1401 | ifneq (,$(wildcard $(..)gpl2lgpl.sed)) | |
1402 | # Snarf from the master source and frob the copying notice. | |
1403 | $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/% | |
1404 | sed -f $^ > $@-tmp | |
1405 | # So I don't edit them by mistake. | |
1406 | chmod a-w $@-tmp | |
1407 | mv -f $@-tmp $@ | |
1408 | ifeq ($(with-cvs),yes) | |
1409 | test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@ | |
1410 | endif | |
1411 | endif | |
1412 | endif | |
1413 | ||
1414 | # Local Variables: | |
1415 | # mode: makefile | |
1416 | # End: |