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