]> git.ipfire.org Git - thirdparty/glibc.git/blob - Makerules
Add pretty printers for the NPTL lock types
[thirdparty/glibc.git] / Makerules
1 # Copyright (C) 1991-2016 Free Software Foundation, Inc.
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, see
16 # <http://www.gnu.org/licenses/>.
17
18 #
19 # Common rules for making the GNU C library. This file is included
20 # by the top-level Makefile and by all subdirectory makefiles
21 # (through Rules).
22 #
23 ifneq (,)
24 This makefile requires GNU Make.
25 endif
26
27 REQUIRED_MAKE_VERSION = 3.74
28 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
29
30 ifneq ($(REQUIRED_MAKE_VERSION), \
31 $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION))))
32 Wrong GNU Make version. See above for the version needed.
33 endif
34
35
36 ifdef subdir
37 .. := ../
38 endif # subdir
39
40 # If `sources' was defined by the parent makefile, undefine it so
41 # we will later get it from wildcard search in this directory.
42 ifneq "$(findstring env,$(origin sources))" ""
43 sources :=
44 endif
45
46 oPATH := $(PATH)
47 PATH := this definition should take precedence over $(oPATH)
48 ifeq ($(PATH),$(oPATH))
49 You must not use the -e flag when building the GNU C library.
50 else
51 PATH := $(oPATH)
52 endif
53 \f
54 ifndef +included-Makeconfig
55 include $(..)Makeconfig
56 endif
57
58 # This variable is used in ``include $(o-iterator)'' after defining
59 # $(o-iterator-doit) to produce some desired rule using $o for the object
60 # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
61 # is produced for each object suffix in use.
62 o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
63 \f
64 # Include any system-specific makefiles.
65
66 # This is here so things in sysdep Makefiles can easily depend on foo.h as
67 # appropriate and not worry about where foo.h comes from, which may be
68 # system dependent and not known by that Makefile.
69 vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
70 $(+sysdep_dirs) $(..)))
71
72 # The same is true for RPC source files.
73 vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
74 $(+sysdep_dirs) $(..)))
75
76 # Some sysdep makefiles use this to distinguish being included here from
77 # being included individually by a subdir makefile (hurd/Makefile needs this).
78 in-Makerules := yes
79
80 sysdep-makefiles := $(wildcard $(sysdirs:=/Makefile))
81 ifneq (,$(sysdep-makefiles))
82 include $(sysdep-makefiles)
83 endif
84
85
86 # Reorder before-compile so that mach things come first, and hurd things
87 # second, before all else. The mach and hurd subdirectories have many
88 # generated header files which the much of rest of the library depends on,
89 # so it is best to build them first (and mach before hurd, at that).
90 before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
91 $(before-compile)) \
92 $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
93 $(before-compile))
94
95 # Even before that, we need abi-versions.h which is generated right here.
96 ifeq ($(build-shared),yes)
97 ifndef avoid-generated
98 before-compile := $(common-objpfx)abi-versions.h $(before-compile)
99 $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
100 $(common-objpfx)Versions.all
101 LC_ALL=C $(AWK) -f $^ > $@T
102 mv -f $@T $@
103
104 $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
105 sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
106 $(common-objpfx)abi-versions.h > $@T
107 mv -f $@T $@
108 endif # avoid-generated
109 endif # $(build-shared) = yes
110
111 ifndef avoid-generated
112 ifneq (,$(CXX))
113 # If C++ headers <cstdlib> or <cmath> are used, GCC 6 will include
114 # /usr/include/stdlib.h or /usr/include/math.h from "#include_next"
115 # (instead of stdlib/stdlib.h or math/math.h in the glibc source
116 # directory), and this turns up as a make dependency. An implicit
117 # rule will kick in and make will try to install stdlib/stdlib.h or
118 # math/math.h as /usr/include/stdlib.h or /usr/include/math.h because
119 # the target is out of date. We make a copy of <cstdlib> and <cmath>
120 # in the glibc build directory so that stdlib/stdlib.h and math/math.h
121 # will be used instead of /usr/include/stdlib.h and /usr/include/math.h.
122 before-compile := $(common-objpfx)cstdlib $(common-objpfx)cmath \
123 $(before-compile)
124 cstdlib=$(shell echo "\#include <cstdlib>" | $(CXX) -M -MP -x c++ - \
125 | sed -n "/cstdlib:/{s/:$$//;p}")
126 $(common-objpfx)cstdlib: $(cstdlib)
127 $(INSTALL_DATA) $< $@T
128 $(move-if-change) $@T $@
129 cmath=$(shell echo "\#include <cmath>" | $(CXX) -M -MP -x c++ - \
130 | sed -n "/cmath:/{s/:$$//;p}")
131 $(common-objpfx)cmath: $(cmath)
132 $(INSTALL_DATA) $< $@T
133 $(move-if-change) $@T $@
134 endif
135
136 before-compile := $(common-objpfx)libc-abis.h $(before-compile)
137 $(common-objpfx)libc-abis.h: $(common-objpfx)libc-abis.stamp; @:
138 $(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \
139 $(firstword $(wildcard $(sysdirs:=/libc-abis)) \
140 $(..)libc-abis) \
141 $(..)Makerules
142 $(SHELL) $< \
143 $(base-machine)-$(config-vendor)-$(config-os) \
144 < $(word 2,$^) > $(@:.stamp=.h)T
145 $(move-if-change) $(@:.stamp=.h)T $(@:.stamp=.h)
146 touch $@
147 common-generated += $(common-objpfx)libc-abis.h
148 endif # avoid-generated
149
150 ifeq (yes,$(build-shared))
151 $(common-objpfx)runtime-linker.h: $(common-objpfx)runtime-linker.stamp; @:
152 $(common-objpfx)runtime-linker.stamp: $(common-objpfx)config.make
153 $(make-target-directory)
154 echo '#define RUNTIME_LINKER "$(rtlddir)/$(rtld-installed-name)"' \
155 > ${@:stamp=T}
156 $(move-if-change) ${@:stamp=T} ${@:stamp=h}
157 touch $@
158 endif
159
160 # Make sure the subdirectory for object files gets created.
161 ifdef objpfx
162 ifeq (,$(wildcard $(objpfx).))
163 before-compile += $(objpfx).
164 $(objpfx).:
165 $(make-target-directory)
166 endif
167 endif
168
169 # Remove existing files from `before-compile'. Things are added there when
170 # they must exist for dependency generation to work right, but once they
171 # exist there is no further need for every single file to depend on them,
172 # and those gratuitous dependencies result in many gratuitous
173 # recompilations.
174 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
175
176 # Don't let any before-compile file be an intermediate and get removed.
177 ifdef before-compile
178 $(before-compile):
179 endif
180
181 # We don't want $(common-objpfx) files to depend on miscellaneous stuff
182 # in subdirs.
183 ifdef subdir
184 common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
185 else
186 common-before-compile = $(before-compile)
187 endif
188
189 ifndef subdir
190 # If a makefile needs to do something conditional on something that
191 # can only be figured out from headers, write a FOO.make.c input
192 # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
193 # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
194 #
195 # We only generate these in the top-level makefile, to avoid any weirdness
196 # from subdir-specific makefile tweaks creeping in on an update.
197 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
198 rm -f $@T $@.dT
199 (echo '# Generated from $*.make.c by Makerules.'; \
200 $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
201 -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
202 | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \
203 echo 'common-generated += $(@F)'; \
204 sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
205 rm -f $@.dT) > $@T
206 mv -f $@T $@
207 endif
208
209 ifdef subdir
210 sed-remove-dotdot := -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' \
211 -e 's@^\.\.\/\([^ \]*\)@$$(..)\1@g'
212 else
213 sed-remove-dotdot := -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' \
214 -e 's@^\([^ \/$$][^ \]*\)@$$(..)\1@g'
215 endif
216
217 ifdef gen-py-const-headers
218 # We'll use a static pattern rule to match .pysym files with their
219 # corresponding generated .py files.
220 # The generated .py files go in the submodule's dir in the glibc source dir.
221 py-const-files := $(patsubst %.pysym,%.py,$(gen-py-const-headers))
222 py-const-dir := $(objpfx)
223 py-const := $(addprefix $(py-const-dir),$(py-const-files))
224 py-const-script := $(..)scripts/gen-py-const.awk
225
226 # This is a hack we use to generate .py files with constants for Python
227 # pretty printers. It works the same way as gen-as-const.
228 # See scripts/gen-py-const.awk for details on how the awk | gcc mechanism
229 # works.
230 #
231 # $@.tmp and $@.tmp2 are temporary files we use to store the partial contents
232 # of the target file. We do this instead of just writing on $@ because, if the
233 # build process terminates prematurely, re-running Make wouldn't run this rule
234 # since Make would see that the target file already exists (despite it being
235 # incomplete).
236 #
237 # The sed line replaces "@name@SOME_NAME@value@SOME_VALUE@" strings from the
238 # output of 'gcc -S' with "SOME_NAME = SOME_VALUE" strings.
239 # The '-n' option, combined with the '/p' command, makes sed output only the
240 # modified lines instead of the whole input file. The output is redirected
241 # to a .py file; we'll import it in the pretty printers file to read
242 # the constants generated by gen-py-const.awk.
243 # The regex has two capturing groups, for SOME_NAME and SOME_VALUE
244 # respectively. Notice SOME_VALUE may be prepended by a special character,
245 # depending on the assembly syntax (e.g. immediates are prefixed by a '$'
246 # in AT&T x86, and by a '#' in ARM). We discard it using a complemented set
247 # before the second capturing group.
248 $(py-const): $(py-const-dir)%.py: %.pysym $(py-const-script) \
249 $(common-before-compile)
250 $(make-target-directory)
251 $(AWK) -f $(py-const-script) $< \
252 | $(CC) -S -o $@.tmp $(CFLAGS) $(CPPFLAGS) -x c -
253 echo '# GENERATED FILE\n' > $@.tmp2
254 echo '# Constant definitions for pretty printers.' >> $@.tmp2
255 echo '# See gen-py-const.awk for details.\n' >> $@.tmp2
256 sed -n -r 's/^.*@name@([^@]+)@value@[^[:xdigit:]Xx-]*([[:xdigit:]Xx-]+)@.*/\1 = \2/p' \
257 $@.tmp >> $@.tmp2
258 mv -f $@.tmp2 $@
259 rm -f $@.tmp
260
261 generated += $(py-const)
262 endif # gen-py-const-headers
263
264 ifdef gen-as-const-headers
265 # Generating headers for assembly constants.
266 # We need this defined early to get into before-compile before
267 # it's used in sysd-rules, below.
268 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
269 %.sym $(common-before-compile)
270 $(AWK) -f $< $(filter %.sym,$^) \
271 | $(CC) -S -o $(@:.h.d=.h)T3 $(CFLAGS) $(CPPFLAGS) -x c - \
272 -MD -MP -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)'
273 sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' \
274 $(@:.h.d=.h)T3 > $(@:.h.d=.h)T
275 rm -f $(@:.h.d=.h)T3
276 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
277 $(@:.h=.h.d)T > $(@:.h=.h.d)T2
278 rm -f $(@:.h=.h.d)T
279 mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
280 mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
281 vpath %.sym $(sysdirs)
282 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
283
284 tests += $(gen-as-const-headers:%.sym=test-as-const-%)
285 generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
286 $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \
287 %.sym $(common-objpfx)%.h
288 ($(AWK) '{ sub(/^/, "asconst_", $$2); print; }' $(filter %.h,$^); \
289 $(AWK) -v test=1 -f $< $(filter %.sym,$^); \
290 echo '#include "$(..)test-skeleton.c"') > $@T
291 mv -f $@T $@
292 endif
293 \f
294 ifeq (yes,$(build-shared))
295 # Generate the header containing the names of all shared libraries.
296 # We use a stamp file to avoid unnecessary recompilations.
297 before-compile += $(common-objpfx)gnu/lib-names.h
298 ifeq ($(soversions.mk-done),t)
299 ifndef abi-variants
300 lib-names-h-abi = gnu/lib-names.h
301 lib-names-stmp-abi = gnu/lib-names.stmp
302 else
303 lib-names-h-abi = gnu/lib-names-$(default-abi).h
304 lib-names-stmp-abi = gnu/lib-names-$(default-abi).stmp
305 before-compile += $(common-objpfx)$(lib-names-h-abi)
306 common-generated += gnu/lib-names.h
307 install-others-nosubdir: $(inst_includedir)/$(lib-names-h-abi)
308 $(common-objpfx)gnu/lib-names.h:
309 $(make-target-directory)
310 { \
311 echo '/* This file is automatically generated.';\
312 echo ' It defines macros to allow user program to find the shared'; \
313 echo ' library files which come as part of GNU libc. */'; \
314 echo '#ifndef __GNU_LIB_NAMES_H'; \
315 echo '#define __GNU_LIB_NAMES_H 1'; \
316 echo ''; \
317 $(if $(abi-includes), \
318 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
319 echo '';) \
320 $(foreach v,$(abi-variants),\
321 $(if $(abi-$(v)-condition),\
322 echo '#if $(abi-$(v)-condition)'; \
323 echo '# include <gnu/lib-names-$(v).h>'); \
324 $(if $(abi-$(v)-condition),echo '#endif';)) \
325 echo ''; \
326 echo '#endif /* gnu/lib-names.h */'; \
327 } > $@
328 endif
329 $(common-objpfx)$(lib-names-h-abi): $(common-objpfx)$(lib-names-stmp-abi); @:
330 $(common-objpfx)$(lib-names-stmp-abi): $(..)scripts/lib-names.awk \
331 $(common-objpfx)soversions.i
332 $(make-target-directory)
333 { \
334 $(if $(abi-variants), \
335 echo '/* This file is automatically generated. */';\
336 echo '#ifndef __GNU_LIB_NAMES_H'; \
337 echo '# error "Never use <$(lib-names-h-abi)> directly; include <gnu/lib-names.h> instead."'; \
338 echo '#endif';, \
339 echo '/* This file is automatically generated.';\
340 echo ' It defines macros to allow user program to find the shared'; \
341 echo ' library files which come as part of GNU libc. */'; \
342 echo '#ifndef __GNU_LIB_NAMES_H'; \
343 echo '#define __GNU_LIB_NAMES_H 1';) \
344 echo ''; \
345 ($(foreach s,$(all-sonames), echo $(s);)) \
346 | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort; \
347 $(if $(abi-variants),, \
348 echo ''; \
349 echo '#endif /* gnu/lib-names.h */';) \
350 } > ${@:stmp=T}
351 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
352 touch $@
353 endif
354 common-generated += $(lib-names-h-abi) $(lib-names-stmp-abi)
355 endif
356 \f
357 ###############################################################################
358 # NOTE! Everything adding to before-compile needs to come before this point! #
359 ###############################################################################
360
361 # Generate an ordered list of implicit rules which find the source files in
362 # each sysdep directory. The old method was to use vpath to search all the
363 # sysdep directories. However, that had the problem that a .S file in a
364 # later directory would be chosen over a .c file in an earlier directory,
365 # which does not preserve the desired sysdeps ordering behavior.
366
367 # System-dependent makefiles can put in `inhibit-sysdep-asm' regexps
368 # matching sysdep directories whose assembly source files should be
369 # suppressed.
370
371 -include $(common-objpfx)sysd-rules
372 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
373 # The value of $(+sysdep_dirs) the sysd-rules was computed for
374 # differs from the one we are using now. So force a rebuild of sysd-rules.
375 sysd-rules-force = FORCE
376 FORCE:
377 endif
378 $(common-objpfx)sysd-rules: $(..)scripts/sysd-rules.awk \
379 $(common-objpfx)config.make $(..)Makerules \
380 $(sysdep-makefiles) $(sysdep-makeconfigs) \
381 $(sysd-rules-force)
382 -@rm -f $@T
383 LC_ALL=C $(AWK) -f $< > $@T \
384 -v all_object_suffixes='$(all-object-suffixes)' \
385 -v inhibit_sysdep_asm='$(inhibit-sysdep-asm)' \
386 -v sysd_rules_patterns='$(sysd-rules-patterns)' \
387 -v config_sysdirs='$(config-sysdirs)'
388 mv -f $@T $@
389
390 ifndef sysd-rules-done
391 # Don't do deps until this exists, because it provides rules to make the deps.
392 no_deps=t
393 endif
394
395 define o-iterator-doit
396 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
397 endef
398 object-suffixes-left := $(all-object-suffixes)
399 include $(o-iterator)
400
401 define o-iterator-doit
402 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
403 endef
404 object-suffixes-left := $(all-object-suffixes)
405 include $(o-iterator)
406
407 define o-iterator-doit
408 $(objpfx)%$o: %.cc $(before-compile); $$(compile-command.cc)
409 endef
410 object-suffixes-left := $(all-object-suffixes)
411 include $(o-iterator)
412
413 # Omit the objpfx rules when building in the source tree, because
414 # objpfx is empty and so these rules just override the ones above.
415 ifdef objpfx
416 # Define first rules to find the source files in $(objpfx).
417 # Generated source files will end up there.
418 define o-iterator-doit
419 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
420 endef
421 object-suffixes-left := $(all-object-suffixes)
422 include $(o-iterator)
423
424 define o-iterator-doit
425 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
426 endef
427 object-suffixes-left := $(all-object-suffixes)
428 include $(o-iterator)
429 endif
430
431 # Generate version maps, but wait until sysdep-subdirs is known
432 ifeq ($(sysd-sorted-done),t)
433 ifeq ($(build-shared),yes)
434 -include $(common-objpfx)sysd-versions
435 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
436 common-generated += $(version-maps)
437 postclean-generated += sysd-versions Versions.all abi-versions.h \
438 Versions.def Versions.v.i Versions.v
439
440 ifndef avoid-generated
441 ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
442 sysd-versions-force = FORCE
443 FORCE:
444 endif
445
446 $(common-objpfx)Versions.def: $(..)scripts/versionlist.awk \
447 $(common-objpfx)Versions.v
448 LC_ALL=C $(AWK) -f $^ > $@T
449 mv -f $@T $@
450
451 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
452 $(common-objpfx)soversions.i \
453 $(common-objpfx)Versions.def
454 { while read which lib version setname; do \
455 test x"$$which" = xDEFAULT || continue; \
456 test -z "$$setname" || echo "$$lib : $$setname"; \
457 done < $(word 2,$^); \
458 cat $(word 3,$^); \
459 } | LC_ALL=C $(AWK) -f $< > $@T
460 mv -f $@T $@
461 # See %.v/%.v.i implicit rules in Makeconfig.
462 $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
463 $(wildcard $(sysdirs:%=%/Versions)) \
464 $(sysd-versions-force)
465 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
466 $(common-objpfx)Versions.v \
467 $(..)scripts/versions.awk
468 ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
469 cat $(word 2,$^) \
470 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
471 -v move_if_change='$(move-if-change)' \
472 -f $(word 3,$^); \
473 ) > $@T
474 mv -f $@T $@
475 endif # avoid-generated
476 endif # $(build-shared) = yes
477 endif # sysd-sorted-done
478
479 # Generate .dT files as we compile.
480 compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
481 compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
482 compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
483 compile-command.cc = $(compile.cc) $(OUTPUT_OPTION) $(compile-mkdep-flags)
484
485 # Like compile-mkdep-flags, but for use with $(BUILD_CC). We don't want to
486 # track system includes here, they may spuriously trigger an install rule,
487 # and would cause the check-local-headers test to fail.
488 native-compile-mkdep-flags = -MMD -MP -MF $@.dt -MT $@
489
490 # GCC can grok options after the file name, and it looks nicer that way.
491 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
492 compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
493 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
494 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
495 COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS)
496 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
497 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
498
499 # We need this for the output to go in the right place. It will default to
500 # empty if make was configured to work with a cc that can't grok -c and -o
501 # together. You can't compile the C library with such a compiler.
502 OUTPUT_OPTION = -o $@
503
504 # This is the end of the pipeline for compiling generated C code.
505 compile-stdin.c = $(COMPILE.c) -o $@ -x c - $(compile-mkdep-flags)
506
507 # We need the $(CFLAGS) to be in there to have the right predefines during
508 # the dependency run for C sources. But having it for assembly sources can
509 # get the wrong predefines.
510 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
511
512 define +make-deps
513 $(make-target-directory)
514 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
515 $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
516 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
517 $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
518 mv -f $(@:.d=.T) $@ $(generate-md5)
519 endef
520
521 ifneq (,$(objpfx))
522 # Continuation lines here are dangerous because they introduce spaces!
523 define sed-remove-objpfx
524 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
525 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
526 endef
527 endif
528 \f
529 # Modify the list of routines we build for different targets
530
531 ifeq (yes,$(build-shared))
532 ifndef libc.so-version
533 # Undefine this because it can't work when we libc.so is unversioned.
534 static-only-routines =
535 endif
536 endif
537
538 elide-routines.oS += $(filter-out $(static-only-routines),\
539 $(routines) $(aux) $(sysdep_routines))
540 elide-routines.os += $(static-only-routines)
541
542 # If we have versioned code we don't need the old versions in any of the
543 # static libraries.
544 elide-routines.o += $(shared-only-routines)
545 elide-routines.op += $(shared-only-routines)
546 elide-routines.og += $(shared-only-routines)
547 \f
548 # Shared library building.
549
550 ifeq (yes,$(build-shared))
551
552 # Reference map file only when shared libraries are built and a map file name
553 # is given.
554 ifeq ($(build-shared),yes)
555 map-file = $(firstword $($(@F:.so=-map)) \
556 $(addprefix $(common-objpfx), \
557 $(filter $(@F:.so=.map),$(version-maps))))
558 load-map-file = $(map-file:%=-Wl,--version-script=%)
559 endif
560
561 # Compiler arguments to use to link a shared object with libc and
562 # ld.so. This is intended to be as similar as possible to a default
563 # link with an installed libc.
564 link-libc-args = -Wl,--start-group \
565 $(libc-for-link) \
566 $(common-objpfx)libc_nonshared.a \
567 $(as-needed) $(elf-objpfx)ld.so $(no-as-needed) \
568 -Wl,--end-group
569
570 # The corresponding shared libc to use. This may be modified for a
571 # particular target.
572 libc-for-link = $(common-objpfx)libc.so
573
574 # The corresponding dependencies. As these are used in dependencies,
575 # not just commands, they cannot use target-specific variables so need
576 # to name both possible libc.so objects.
577 link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
578 $(common-objpfx)libc_nonshared.a $(elf-objpfx)ld.so
579
580 # Pattern rule to build a shared object from an archive of PIC objects.
581 # This must come after the installation rules so Make doesn't try to
582 # build shared libraries in place from the installed *_pic.a files.
583 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
584 # on other shared objects. The linking with libc and ld.so is intended
585 # to be as similar as possible to a default link with an installed libc.
586 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(link-libc-deps)
587 $(build-shlib) $(link-libc-args)
588 $(call after-link,$@)
589
590 define build-shlib-helper
591 $(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \
592 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(rtld-LDFLAGS) \
593 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
594 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
595 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
596 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
597 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
598 endef
599
600 ifeq (yes,$(use-default-link))
601 # If the linker is good enough, we can let it use its default linker script.
602 shlib-lds =
603 shlib-lds-flags =
604 else
605 # binutils only position loadable notes into the first page for binaries,
606 # not for shared objects
607 $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
608 $(LINK.o) -shared -Wl,-O1 \
609 -nostdlib -nostartfiles \
610 $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
611 -Wl,--verbose 2>&1 | \
612 sed > $@T \
613 -e '/^=========/,/^=========/!d;/^=========/d' \
614 $(if $(filter yes,$(have-hash-style)), \
615 -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
616 -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
617 -e '/DATA_SEGMENT_ALIGN/{H;g}' \
618 , \
619 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
620 ) \
621 -e 's/^.*\*(\.dynbss).*$$/& \
622 PROVIDE(__start___libc_freeres_ptrs = .); \
623 *(__libc_freeres_ptrs) \
624 PROVIDE(__stop___libc_freeres_ptrs = .);/'\
625 -e 's@^.*\*(\.jcr).*$$@& \
626 PROVIDE(__start___libc_subfreeres = .);\
627 __libc_subfreeres : { *(__libc_subfreeres) }\
628 PROVIDE(__stop___libc_subfreeres = .);\
629 PROVIDE(__start___libc_atexit = .);\
630 __libc_atexit : { *(__libc_atexit) }\
631 PROVIDE(__stop___libc_atexit = .);\
632 PROVIDE(__start___libc_thread_subfreeres = .);\
633 __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
634 PROVIDE(__stop___libc_thread_subfreeres = .);\
635 PROVIDE(__start___libc_IO_vtables = .);\
636 __libc_IO_vtables : { *(__libc_IO_vtables) }\
637 PROVIDE(__stop___libc_IO_vtables = .);\
638 /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
639 test -s $@T
640 mv -f $@T $@
641 common-generated += shlib.lds
642
643 shlib-lds = $(common-objpfx)shlib.lds
644 shlib-lds-flags = -T $(shlib-lds)
645 endif
646
647 define build-shlib
648 $(build-shlib-helper) -o $@ $(shlib-lds-flags) \
649 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
650 endef
651
652 define build-module-helper
653 $(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
654 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
655 -B$(csu-objpfx) $(load-map-file) \
656 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
657 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
658 endef
659
660 # This macro is similar to build-shlib but it does not define a soname
661 # and it does not depend on the destination name to start with `lib'.
662 # binutils only position loadable notes into the first page for binaries,
663 # not for shared objects
664 define build-module
665 $(build-module-helper) -o $@ $(shlib-lds-flags) \
666 $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
667 $(call after-link,$@)
668 endef
669 define build-module-asneeded
670 $(build-module-helper) -o $@ $(shlib-lds-flags) \
671 $(csu-objpfx)abi-note.o \
672 -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
673 $(link-libc-args)
674 $(call after-link,$@)
675 endef
676
677 build-module-helper-objlist = \
678 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
679 $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \
680 $(link-libc-deps),$^))
681
682 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
683 build-shlib-objlist = $(build-module-helper-objlist) \
684 $(LDLIBS-$(@F:lib%.so=%).so)
685
686 # Don't try to use -lc when making libc.so itself.
687 # Also omits crti.o and crtn.o, which we do not want
688 # since we define our own `.init' section specially.
689 LDFLAGS-c.so = -nostdlib -nostartfiles
690 # But we still want to link libc.so against $(libc.so-gnulib).
691 LDLIBS-c.so += $(libc.so-gnulib)
692 # Give libc.so an entry point and make it directly runnable itself.
693 LDFLAGS-c.so += -e __libc_main
694 # If lazy relocation is disabled add the -z now flag.
695 ifeq ($(bind-now),yes)
696 LDFLAGS-c.so += -Wl,-z,now
697 endif
698 # Pre-link the objects of libc_pic.a so that we can locally resolve
699 # COMMON symbols before we link against ld.so. This is because ld.so
700 # contains some of libc_pic.a already, which will prevent the COMMONs
701 # from being allocated in libc.so, which introduces evil dependencies
702 # between libc.so and ld.so, which can make it impossible to upgrade.
703 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
704 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
705 $(LDFLAGS-c_pic.os) -Wl,-d $(whole-archive) $^ -o $@
706
707 ifeq (,$(strip $(shlib-lds-flags)))
708 # Generate a list of -R options to excise .gnu.glibc-stub.* sections.
709 $(common-objpfx)libc_pic.opts: $(common-objpfx)libc_pic.os
710 $(OBJDUMP) -h $< | \
711 $(AWK) '$$2 ~ /\.gnu\.glibc-stub\./ { print "-R", $$2 }' \
712 > $@T
713 mv -f $@T $@
714 # Apply those -R options.
715 $(common-objpfx)libc_pic.os.clean: $(common-objpfx)libc_pic.opts \
716 $(common-objpfx)libc_pic.os
717 $(OBJCOPY) @$^ $@
718 generated += libc_pic.opts libc_pic.os.clean
719
720 libc_pic_clean := .clean
721 endif
722
723 # Build a possibly-modified version of libc_pic.a for use in building
724 # linkobj/libc.so.
725 ifeq (,$(filter sunrpc,$(subdirs)))
726 $(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a
727 $(make-target-directory)
728 ln -f $< $@
729 else
730 $(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a \
731 $(common-objpfx)sunrpc/librpc_compat_pic.a
732 $(make-target-directory)
733 (cd $(common-objpfx)linkobj; \
734 $(AR) x ../libc_pic.a; \
735 rm $$($(AR) t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//'); \
736 $(AR) x ../sunrpc/librpc_compat_pic.a; \
737 $(AR) cr libc_pic.a *.os; \
738 rm *.os)
739 endif # $(subdirs) contains sunrpc
740
741 # Clear link-libc-deps for the libc.so libraries so build-shlibs does not
742 # filter ld.so out of the list of linked objects.
743 $(common-objpfx)libc.so: link-libc-deps = # empty
744 $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty
745
746 # Use our own special initializer and finalizer files for the libc.so
747 # libraries.
748 $(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
749 $(common-objpfx)libc_pic.os$(libc_pic_clean) \
750 $(elf-objpfx)sofini.os \
751 $(elf-objpfx)interp.os \
752 $(elf-objpfx)ld.so \
753 $(shlib-lds)
754 $(build-shlib)
755 $(call after-link,$@)
756
757 $(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \
758 $(common-objpfx)linkobj/libc_pic.a \
759 $(elf-objpfx)sofini.os \
760 $(elf-objpfx)interp.os \
761 $(elf-objpfx)ld.so \
762 $(shlib-lds)
763 $(build-shlib)
764 $(call after-link,$@)
765
766 ifeq ($(build-shared),yes)
767 $(common-objpfx)libc.so: $(common-objpfx)libc.map
768 endif
769 common-generated += libc.so libc_pic.os
770 ifdef libc.so-version
771 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
772 $(make-link)
773 common-generated += libc.so$(libc.so-version)
774 endif
775 endif
776 \f
777 # Figure out the source filenames in this directory.
778
779 override sources := $(addsuffix .c,\
780 $(filter-out $(elided-routines),\
781 $(routines) $(aux) \
782 $(sysdep_routines)))
783 sysdep_routines := $(sysdep_routines)
784
785 headers := $(headers) $(sysdep_headers)
786
787 # This is the list of all object files, gotten by
788 # replacing every ".c" in `sources' with a ".o".
789 override objects := $(addprefix $(objpfx),$(sources:.c=.o))
790
791
792 # The makefile may define $(extra-libs) with `libfoo libbar'
793 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
794 ifdef extra-libs
795 # extra-lib.mk is included once for each extra lib to define rules
796 # to build it, and to add its objects to the various variables.
797 # During its evaluation, $(lib) is set to the name of the library.
798 extra-libs-left := $(extra-libs)
799 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
800 endif
801
802
803 # The makefile may define $(modules-names) to build additional modules.
804 # These are built with $(build-module), except any in $(modules-names-nobuild).
805 ifdef modules-names
806 # extra-lib.mk is included once for each extra lib to define rules
807 # to build it, and to add its objects to the various variables.
808 # During its evaluation, $(lib) is set to the name of the library.
809 extra-modules-left := $(modules-names)
810 include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
811
812 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
813 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
814 $(objpfx)%.os $(shlib-lds) $(link-libs-deps)
815 $(build-module)
816 endif
817 \f
818 +depfiles := $(sources:.c=.d) \
819 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
820 $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
821 $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
822 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
823 ifeq ($(build-programs),yes)
824 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
825 endif
826 +depfiles := $(addprefix $(objpfx),\
827 $(filter-out $(addsuffix .d,$(omit-deps)),\
828 $(+depfiles)))
829 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
830 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
831 $(wildcard $(all-dt-files:.dt=.d))
832
833 # This is a funny rule in that it removes its input file.
834 %.d: %.dt
835 @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
836 mv -f $(@:.d=.T) $@ && \
837 rm -f $<
838
839 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
840 # They will be generated when they're needed, and trying too early won't work.
841 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
842 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
843 $(+gen-as-const)))
844
845 ifdef +depfiles
846 ifneq ($(no_deps),t)
847 -include $(+depfiles)
848 endif
849 endif
850 \f\f
851 # Maximize efficiency by minimizing the number of rules.
852 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
853 # Don't define any builtin rules.
854 MAKEFLAGS := $(MAKEFLAGS)r
855
856 # Generic rule for making directories.
857 %/:
858 # mkdir isn't smart enough to strip a trailing /.
859 # We always require a mkdir which supports the -p option to avoid error
860 # messages in case of races.
861 mkdir -p $(@:%/=%)
862 \f
863 # Make sure that object files are not removed
864 # when they are intermediates between sources and library members.
865 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
866
867 # Make sure that the parent library archive is never removed.
868 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
869 \f
870 # Use the verbose option of ar and tar when not running silently.
871 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
872 verbose := v
873 else # -s
874 verbose :=
875 endif # not -s
876
877 ARFLAGS := r$(verbose)
878 CREATE_ARFLAGS := cru$(verbose)
879 \f
880 # This makes all the object files in the parent library archive.
881
882 .PHONY: lib lib-noranlib
883 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
884 lib-noranlib: libobjs
885
886 # For object-suffix $o, the list of objects with that suffix.
887 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
888 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
889 $(elide-routines$o)),\
890 $(objects))) \
891 $(addprefix $(objpfx),$(o-objects$o))
892
893 others: $(addprefix $(objpfx),$(install-lib))
894
895 ifndef objects
896
897 # Create the stamp$o files to keep the parent makefile happy.
898 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
899 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
900 $(make-target-directory)
901 rm -f $@; > $@
902 else
903
904 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
905 # timestamp file; these rules (one explicit rule is generated for each
906 # object suffix) write a list of objects to update in the stamp file.
907 # The parent will then actually add them all to the archive in the
908 # archive rule, below.
909 define o-iterator-doit
910 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
911 endef
912 define do-stamp
913 $(make-target-directory)
914 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
915 mv -f $@T $@
916 endef
917 object-suffixes-left := $(object-suffixes-for-libc)
918 include $(o-iterator)
919
920 endif
921
922 # Now define explicit rules to build the library archives; these depend
923 # on the stamp files built above.
924 define o-iterator-doit
925 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
926 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
927 endef
928 define do-makelib
929 cd $(common-objdir) && \
930 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
931 endef
932 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
933 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
934 ifndef subdir
935 $(subdirs-stamps): subdir_lib;
936 endif
937 object-suffixes-left = $(object-suffixes-for-libc)
938 include $(o-iterator)
939
940
941 # This makes all the object files.
942 .PHONY: objects objs libobjs extra-objs
943 objects objs: libobjs extra-objs
944 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
945 extra-objs: $(addprefix $(objpfx),$(extra-objs))
946
947 # Canned sequence for building an extra library archive.
948 define build-extra-lib
949 $(patsubst %/,cd % &&,$(objpfx)) \
950 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
951 $(patsubst $(objpfx)%,%,$^)
952 endef
953 \f
954 # Installation.
955
956 .PHONY: force-install
957 force-install:
958
959 # $(install-lib) are installed from the object directory into $(libdir);
960 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
961 # unless they also appear in $(non-lib.a). $(install-data) are installed as
962 # they are into $(datadir). $(headers) are installed as they are in
963 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
964 # are installed from the object directory into $(bindir), $(bindir) and
965 # $(sbindir), respectively. $(install-others) and $(install-others-programs)
966 # are absolute path names of files to install; rules to install them are
967 # defined elsewhere.
968
969 # The simple library name to install libc.a under.
970 # This could be defined by a sysdep Makefile.
971 ifndef libc-name
972 libc-name := c
973 endif
974
975 define do-install
976 $(make-target-directory)
977 $(INSTALL_DATA) $< $@
978 endef
979
980 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
981 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
982 define make-target-directory
983 $(addprefix $(..)./scripts/mkinstalldirs ,\
984 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
985 endef
986
987 # Any directory (parent or subdir) should install libc.a; this way
988 # "make install" in a subdir is guaranteed to install everything it changes.
989 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
990 $(inst_libdir)/$(patsubst %,$(libtype$o),\
991 $(libprefix)$(libc-name)))
992
993 .PHONY: check-install-supported
994 check-install-supported:
995
996 # Check to see if the prefix or exec_prefix GNU standard variable
997 # has been overridden on the command line and, if so, fail with
998 # an error message since doing so is not supported (set DESTDIR
999 # instead).
1000 ifeq ($(origin prefix),command line)
1001 check-install-supported:
1002 $(error Overriding prefix is not supported. Set DESTDIR instead.)
1003 endif
1004
1005 ifeq ($(origin exec_prefix),command line)
1006 check-install-supported:
1007 $(error Overriding exec_prefix is not supported. Set DESTDIR instead.)
1008 endif
1009
1010 install: check-install-supported
1011
1012 install: $(installed-libcs)
1013 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
1014 $(make-target-directory)
1015 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
1016
1017 define do-install-program
1018 $(make-target-directory)
1019 $(INSTALL_PROGRAM) $< $@.new
1020 mv -f $@.new $@
1021 endef
1022
1023 define do-install-script
1024 $(make-target-directory)
1025 $(INSTALL_SCRIPT) $< $@.new
1026 mv -f $@.new $@
1027 endef
1028
1029 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
1030 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
1031
1032 ifeq (yes,$(build-shared))
1033 # Find which .so's have versions.
1034 versioned := $(strip $(foreach so,$(install-lib.so),\
1035 $(patsubst %,$(so),$($(so)-version))))
1036
1037 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
1038 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
1039
1040 # For versioned libraries, we install three files:
1041 # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
1042 # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
1043 # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
1044 lib-version := $(firstword $($(subdir)-version) $(version))
1045 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
1046 $(foreach L,$(install-lib.so-versioned),\
1047 $(inst_libdir)/$L \
1048 $(inst_slibdir)/$(L:.so=)-$(lib-version).so \
1049 $(inst_slibdir)/$L$($L-version))
1050
1051 # Install all the unversioned shared libraries.
1052 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
1053 $(objpfx)%.so $(+force)
1054 $(do-install-program)
1055
1056 ifneq ($(findstring -s,$(LN_S)),)
1057 define make-link
1058 rm -f $@.new
1059 $(SHELL) $(..)scripts/rellns-sh $< $@.new
1060 mv -f $@.new $@
1061 endef
1062 else
1063 # If we have no symbolic links don't bother with rellns-sh.
1064 define make-link
1065 rm -f $@.new
1066 $(LN_S) $< $@.new
1067 mv -f $@.new $@
1068 endef
1069 endif
1070
1071 ifeq (yes,$(build-shared))
1072 ifeq (no,$(cross-compiling))
1073 symbolic-link-prog := $(elf-objpfx)sln
1074 symbolic-link-list := $(elf-objpfx)symlink.list
1075 define make-shlib-link
1076 echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
1077 endef
1078 else # cross-compiling
1079 # We need a definition that can be used by elf/Makefile's install rules.
1080 symbolic-link-prog = $(LN_S)
1081 endif
1082 endif
1083 ifndef make-shlib-link
1084 define make-shlib-link
1085 rm -f $@
1086 $(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
1087 endef
1088 endif
1089
1090 ifdef libc.so-version
1091 # For a library specified to be version N, install three files:
1092 # libc.so -> libc.so.N (e.g. libc.so.6)
1093 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
1094
1095 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
1096 $(+force)
1097 $(make-shlib-link)
1098 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
1099 $(do-install-program)
1100 install: $(inst_slibdir)/libc.so$(libc.so-version)
1101
1102 # This fragment of linker script gives the OUTPUT_FORMAT statement
1103 # for the configuration we are building. We put this statement into
1104 # the linker scripts we install for -lc et al so that they will not be
1105 # used by a link for a different format on a multi-architecture system.
1106 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
1107 $(common-objpfx)config.make \
1108 $(common-objpfx)config.h $(..)Makerules
1109 ifneq (unknown,$(output-format))
1110 echo > $@.new 'OUTPUT_FORMAT($(output-format))'
1111 else
1112 $(LINK.o) -shared $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
1113 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
1114 | sed -n -f $< > $@.new
1115 test -s $@.new
1116 rm -f $@.so
1117 endif
1118 mv -f $@.new $@
1119 common-generated += format.lds
1120
1121 ifndef subdir
1122 # What we install as libc.so for programs to link against is in fact a
1123 # link script. It contains references for the various libraries we need.
1124 # The libc.so object is not complete since some functions are only defined
1125 # in libc_nonshared.a.
1126 # We need to use absolute paths since otherwise local copies (if they exist)
1127 # of the files are taken by the linker.
1128 install: $(inst_libdir)/libc.so
1129 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
1130 $(common-objpfx)libc.so$(libc.so-version) \
1131 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
1132 $(libprefix)$(libc-name)) \
1133 $(+force)
1134 (echo '/* GNU ld script';\
1135 echo ' Use the shared library, but some functions are only in';\
1136 echo ' the static library, so try that secondarily. */';\
1137 cat $<; \
1138 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
1139 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
1140 ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \
1141 ) > $@.new
1142 mv -f $@.new $@
1143
1144 endif
1145
1146 else
1147 install: $(inst_slibdir)/libc.so
1148 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
1149 $(do-install-program)
1150 endif
1151
1152 ifneq (,$(versioned))
1153 # Produce three sets of rules as above for all the smaller versioned libraries.
1154
1155 define o-iterator-doit
1156 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
1157 endef
1158 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
1159 ifneq (,$(object-suffixes-left))
1160 include $(o-iterator)
1161 endif
1162
1163 # Make symlinks in the build directory, because the versioned names might
1164 # be referenced by a DT_NEEDED in another library.
1165 define o-iterator-doit
1166 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
1167 endef
1168 object-suffixes-left := $(versioned)
1169 include $(o-iterator)
1170
1171 generated += $(foreach o,$(versioned),$o$($o-version))
1172
1173 ifeq (,$($(subdir)-version))
1174 define o-iterator-doit
1175 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
1176 $(+force);
1177 $$(make-shlib-link)
1178 endef
1179 object-suffixes-left := $(versioned)
1180 include $(o-iterator)
1181
1182 define o-iterator-doit
1183 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
1184 $$(do-install-program)
1185 endef
1186 object-suffixes-left := $(versioned)
1187 include $(o-iterator)
1188 else
1189 define o-iterator-doit
1190 $(inst_slibdir)/$o$($o-version): \
1191 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1192 $$(make-shlib-link)
1193 endef
1194 object-suffixes-left := $(versioned)
1195 include $(o-iterator)
1196
1197 define o-iterator-doit
1198 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1199 $$(do-install-program)
1200 endef
1201 object-suffixes-left := $(versioned)
1202 include $(o-iterator)
1203 endif
1204 endif
1205
1206 define do-install-so
1207 $(do-install-program)
1208 $(patsubst %,$(LN_S) -f $(@F) \
1209 $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1210 $(filter-out %.so,$@))
1211 endef
1212
1213 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1214 $(foreach v,$(so-versions),\
1215 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1216 $(+force)
1217 $(do-install-so)
1218 $(foreach v,$(so-versions),\
1219 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1220 $(do-install-so)
1221 endif
1222
1223 ifdef install-bin
1224 $(addprefix $(inst_bindir)/,$(install-bin)): \
1225 $(inst_bindir)/%: $(objpfx)% $(+force)
1226 $(do-install-program)
1227 endif
1228 ifdef install-bin-script
1229 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1230 $(inst_bindir)/%: $(objpfx)% $(+force)
1231 $(do-install-script)
1232 endif
1233 ifdef install-rootsbin
1234 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1235 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1236 $(do-install-program)
1237 endif
1238 ifdef install-sbin
1239 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1240 $(inst_sbindir)/%: $(objpfx)% $(+force)
1241 $(do-install-program)
1242 endif
1243 ifdef install-lib
1244 install-lib.a := $(filter lib%.a,$(install-lib))
1245 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1246 ifdef install-lib-non.a
1247 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1248 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1249 $(do-install)
1250 endif
1251 ifdef install-lib.a
1252 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1253 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1254 $(do-install)
1255 endif
1256 endif
1257 ifdef install-data
1258 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1259 $(do-install)
1260 endif
1261 headers := $(strip $(headers))
1262 ifdef headers
1263 # This implicit rule installs headers from the source directory.
1264 # It may be ignored in preference to rules from sysd-rules to find
1265 # headers in the sysdeps tree.
1266 $(inst_includedir)/%.h: $(objpfx)%.h $(+force)
1267 $(do-install)
1268 $(inst_includedir)/%.h: $(common-objpfx)%.h $(+force)
1269 $(do-install)
1270 $(inst_includedir)/%.h: %.h $(+force)
1271 $(do-install)
1272 $(inst_includedir)/%.h: $(..)include/%.h $(+force)
1273 $(do-install)
1274 headers-nonh := $(filter-out %.h,$(headers))
1275 ifdef headers-nonh
1276 $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
1277 % $(+force)
1278 $(do-install)
1279 endif # headers-nonh
1280 endif # headers
1281
1282 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1283 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1284 install-data-nosubdir install-headers-nosubdir
1285 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1286 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1287 install-rootsbin-nosubdir: \
1288 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1289 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1290 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1291 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1292 $(addprefix $(libprefix),$(install-lib-non.a)))
1293 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1294 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1295 install-others-nosubdir: $(install-others)
1296 install-others-programs-nosubdir: $(install-others-programs)
1297
1298 # We need all the `-nosubdir' targets so that `install' in the parent
1299 # doesn't depend on several things which each iterate over the subdirs.
1300 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1301 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1302 install-%:: install-%-nosubdir ;
1303
1304 .PHONY: install install-no-libc.a-nosubdir
1305 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
1306 install-lib-nosubdir install-others-nosubdir
1307 ifeq ($(build-programs),yes)
1308 install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
1309 install-rootsbin-nosubdir install-sbin-nosubdir \
1310 install-others-programs-nosubdir
1311 endif
1312 install: install-no-libc.a-nosubdir
1313 \f
1314 # Command to compile $< using the native libraries.
1315 define native-compile
1316 $(make-target-directory)
1317 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1318 $< $(OUTPUT_OPTION) $(BUILD_LDFLAGS)
1319 endef
1320
1321 # We always want to use configuration definitions.
1322 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -D_GNU_SOURCE \
1323 -DIS_IN_build -include $(common-objpfx)config.h
1324
1325 # Support the GNU standard name for this target.
1326 .PHONY: check
1327 check: tests
1328 # Special target to run tests which cannot be run unconditionally.
1329 # Maintainers should use this target.
1330 .PHONY: xcheck
1331 xcheck: xtests
1332
1333 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1334 ifneq (,$(all-nonlib))
1335 cpp-srcs-left = $(all-nonlib)
1336 lib := nonlib
1337 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
1338 endif
1339
1340
1341 ifeq ($(build-shared),yes)
1342 # Generate normalized lists of symbols, versions, and data sizes.
1343 # This is handy for checking against existing library binaries.
1344
1345 %.symlist: $(..)scripts/abilist.awk %.dynsym
1346 LC_ALL=C $(AWK) -f $^ > $@T
1347 mv -f $@T $@
1348
1349 %.dynsym: %.so
1350 LC_ALL=C $(OBJDUMP) --dynamic-syms $< > $@T
1351 mv -f $@T $@
1352
1353 # A sysdeps/.../Makefile can set abilist-pattern to something like
1354 # %-foo.abilist to look for libc-foo.abilist instead of libc.abilist.
1355 # This makes sense if multiple ABIs can be most cleanly supported by a
1356 # configuration without using separate sysdeps directories for each.
1357 ifdef abilist-pattern
1358 vpath $(abilist-pattern) $(+sysdep_dirs)
1359 endif
1360
1361 vpath %.abilist $(+sysdep_dirs)
1362
1363 # The .PRECIOUS rule prevents the files built by an implicit rule whose
1364 # target pattern is %.symlist from being considered "intermediate files"
1365 # and automatically removed. We only want these files to be removed by
1366 # 'make clean', which is handled by the 'generated' variable.
1367 .PRECIOUS: %.symlist
1368 generated += $(extra-libs:=.symlist)
1369
1370 ifdef abilist-pattern
1371 $(objpfx)check-abi-%.out: $(common-objpfx)config.make $(abilist-pattern) \
1372 $(objpfx)%.symlist
1373 $(check-abi-pattern); \
1374 $(evaluate-test)
1375 $(objpfx)check-abi-%.out: $(common-objpfx)config.make $(abilist-pattern) \
1376 $(common-objpfx)%.symlist
1377 $(check-abi-pattern); \
1378 $(evaluate-test)
1379 endif
1380 $(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
1381 $(objpfx)%.symlist
1382 $(check-abi); \
1383 $(evaluate-test)
1384 $(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
1385 $(common-objpfx)%.symlist
1386 $(check-abi); \
1387 $(evaluate-test)
1388 define check-abi-pattern
1389 diff -p -U 0 $(filter $(abilist-pattern),$^) $(filter %.symlist,$^) \
1390 > $@
1391 endef
1392 define check-abi
1393 diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^) > $@
1394 endef
1395
1396 ifdef abilist-pattern
1397 update-abi-%: $(objpfx)%.symlist $(abilist-pattern)
1398 $(update-abi-pattern)
1399 update-abi-%: $(common-objpfx)%.symlist $(abilist-pattern)
1400 $(update-abi-pattern)
1401 endif
1402 update-abi-%: $(objpfx)%.symlist %.abilist
1403 $(update-abi)
1404 update-abi-%: $(common-objpfx)%.symlist %.abilist
1405 $(update-abi)
1406 define update-abi-pattern
1407 @if cmp -s $^ 2> /dev/null; \
1408 then \
1409 echo '+++ $(filter $(abilist-pattern),$^) is unchanged'; \
1410 else cp -f $^; \
1411 echo '*** Now check $(filter $(abilist-pattern),$^) changes for correctness ***'; \
1412 fi
1413 endef
1414 define update-abi
1415 @if cmp -s $^ 2> /dev/null; \
1416 then \
1417 echo '+++ $(filter %.abilist,$^) is unchanged'; \
1418 else cp -f $^; \
1419 echo '*** Now check $(filter %.abilist,$^) changes for correctness ***'; \
1420 fi
1421 endef
1422
1423 # Patch all .abilist files for one DSO. The find command locates
1424 # abilist files for all architectures. The regular expression in the
1425 # find invocation is needed to separate libc.abilist and
1426 # libcrypt.abilist, for example. It assumes that abilist-pattern, if
1427 # set, is of the form "%-SUFFIX", and not "%SUFFIX", that is, there is
1428 # a non-alphanumeric seperator between the pattern and the suffix
1429 # added. The abilist files in /generic/ are filtered out because
1430 # these are expected to remain empty.
1431 define update-all-abi
1432 $(SHELL) $(..)scripts/update-abilist.sh $^ \
1433 $$(find $(..)sysdeps \
1434 -regextype posix-egrep -regex '.*/$*([^a-z0-9].*)?\.abilist$$' \
1435 \! -regex '.*/generic/.*')
1436 endef
1437 ifdef abilist-pattern
1438 update-all-abi-%: $(abilist-pattern) $(objpfx)%.symlist
1439 $(update-all-abi)
1440 update-all-abi-%: $(abilist-pattern) $(common-objpfx)%.symlist
1441 $(update-all-abi)
1442 endif
1443 update-all-abi-%: %.abilist $(objpfx)%.symlist
1444 $(update-all-abi)
1445 update-all-abi-%: %.abilist $(common-objpfx)%.symlist
1446 $(update-all-abi)
1447
1448 .PHONY: update-abi update-all-abi check-abi
1449 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1450 update-all-abi: $(patsubst %.so,update-all-abi-%,$(install-lib.so-versioned))
1451 check-abi-list = $(patsubst %.so,$(objpfx)check-abi-%.out, \
1452 $(install-lib.so-versioned))
1453 check-abi: $(check-abi-list)
1454 ifdef subdir
1455 subdir_check-abi: check-abi
1456 subdir_update-abi: update-abi
1457 subdir_update-all-abi: update-all-abi
1458 else
1459 check-abi: subdir_check-abi
1460 if grep -q '^FAIL:' $(objpfx)*/check-abi*.test-result; then \
1461 cat $(objpfx)*/check-abi*.out && exit 1; fi
1462 update-abi: subdir_update-abi
1463 update-all-abi: subdir_update-all-abi
1464 endif
1465
1466 ifeq ($(subdir),elf)
1467 check-abi: $(objpfx)check-abi-libc.out
1468 tests-special += $(objpfx)check-abi-libc.out
1469 update-abi: update-abi-libc
1470 update-all-abi: update-all-abi-libc
1471 common-generated += libc.symlist
1472 endif
1473
1474 ifeq ($(build-shared),yes)
1475 ifdef subdir
1476 tests-special += $(check-abi-list)
1477 endif
1478 endif
1479
1480 endif
1481 \f
1482 # These will have been set by sysdeps/posix/Makefile.
1483 L_tmpnam ?= 1
1484 TMP_MAX ?= 0
1485 L_ctermid ?= 1
1486 L_cuserid ?= 1
1487
1488 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1489
1490 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1491 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1492 $(common-objpfx)config.make
1493 $(make-target-directory)
1494 { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
1495 echo '#define _LIBC 1'; \
1496 echo '#include "$(..)misc/sys/uio.h"'; } | \
1497 $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
1498 $(CPPUNDEFS) $(+includes) -xc - -o $(@:st=hT)
1499 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
1500 $(@:st=dT) > $(@:st=dt)
1501 mv -f $(@:st=dt) $(@:st=d)
1502 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
1503 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
1504 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
1505 fopen_max=$${fopen_max:-16}; \
1506 filename_max=$${filename_max:-1024}; \
1507 if [ -z "$$iov_max" ]; then \
1508 define_iov_max="# undef IOV_MAX"; \
1509 else \
1510 define_iov_max="# define IOV_MAX $$iov_max"; \
1511 fi; \
1512 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
1513 -e "s/@FILENAME_MAX@/$$filename_max/" \
1514 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
1515 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
1516 -e "s/@L_ctermid@/$(L_ctermid)/" \
1517 -e "s/@L_cuserid@/$(L_cuserid)/" \
1518 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
1519 $< > $(@:st=h.new)
1520 $(move-if-change) $(@:st=h.new) $(@:st=h)
1521 # Remove these last so that they can be examined if something went wrong.
1522 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1523 touch $@
1524 # Get dependencies.
1525 ifndef no_deps
1526 -include $(stdio_lim:h=d)
1527 endif
1528 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1529 \f
1530 FORCE:
1531
1532 .PHONY: echo-headers
1533 echo-headers:
1534 @echo $(headers)
1535
1536 %.bz2: %; bzip2 -9vk $<
1537 %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
1538 %.xz: %; xz -9evk $<
1539 \f
1540 # Common cleaning targets.
1541
1542 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1543 clean: common-clean
1544 mostlyclean: common-mostlyclean
1545
1546 do-tests-clean:
1547 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1548 $(test-srcs)) \
1549 $(addsuffix .test-result,$(tests) \
1550 $(xtests) \
1551 $(test-srcs)))
1552
1553 # Remove the object files.
1554 common-mostlyclean:
1555 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1556 $(others) $(sysdep-others) stubs \
1557 $(addsuffix .o,$(tests) $(xtests) \
1558 $(test-srcs) $(others) \
1559 $(sysdep-others)) \
1560 $(addsuffix .out,$(tests) $(xtests) \
1561 $(test-srcs)) \
1562 $(addsuffix .test-result,$(tests) \
1563 $(xtests) \
1564 $(test-srcs)))
1565 -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
1566 $(install-lib) $(install-lib.so) \
1567 $(install-lib.so:%.so=%_pic.a))
1568 -rm -f core
1569 -rm -f $(objpfx)rtld-*.os
1570 $(rmobjs)
1571 define rmobjs
1572 $(foreach o,$(object-suffixes-for-libc),
1573 -rm -f $(objpfx)stamp$o $(o-objects))
1574 endef
1575
1576 # Also remove the dependencies and generated source files.
1577 common-clean: common-mostlyclean
1578 -rm -f $(addprefix $(objpfx),$(generated))
1579 -rm -f $(objpfx)*.d $(objpfx)*.dt
1580 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1581 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1582 -rm -f $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
1583 \f
1584 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1585 # for each function which is a stub.
1586
1587 ifdef objpfx
1588 .PHONY: stubs # The parent Makefile calls this target.
1589 stubs: $(objpfx)stubs
1590 endif
1591 objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
1592 $(addprefix $(objpfx),$(extra-objs))
1593 $(objpfx)stubs: $(objs-for-stubs)
1594 ifneq (,$(strip $(objs-for-stubs)))
1595 (cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
1596 $(AWK) '/\.gnu\.glibc-stub\./ { \
1597 sub(/\.gnu\.glibc-stub\./, "", $$2); \
1598 stubs[$$2] = 1; } \
1599 END { for (s in stubs) print "#define __stub_" s }' > $@T
1600 mv -f $@T $@
1601 else
1602 > $@
1603 endif
1604 \f
1605 ifneq (,$(strip $(gpl2lgpl)))
1606 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1607 # Snarf from the master source and frob the copying notice.
1608 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1609 sed -f $^ > $@-tmp
1610 # So I don't edit them by mistake.
1611 chmod a-w $@-tmp
1612 mv -f $@-tmp $@
1613 endif
1614 endif
1615
1616 # Local Variables:
1617 # mode: makefile
1618 # End: