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