1 # Copyright (C) 1991-2012 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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/>.
19 # Common rules for making the GNU C library. This file is included
20 # by the top-level Makefile and by all subdirectory makefiles
24 This makefile requires GNU Make.
27 REQUIRED_MAKE_VERSION = 3.74
28 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
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.
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))" ""
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.
54 ifndef +included-Makeconfig
55 include $(..)Makeconfig
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))
64 # Include any system-specific makefiles.
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) $(..)))
72 # The same is true for RPC source files.
73 vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
74 $(+sysdep_dirs) $(..)))
76 # Some sysdep makefiles use this to distinguish being included here from
77 # being included individually by a subdir makefile (hurd/Makefile needs this).
80 sysdep-makefiles := $(wildcard $(sysdirs:=/Makefile))
81 ifneq (,$(sysdep-makefiles))
82 include $(sysdep-makefiles)
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%,\
92 $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
95 # Even before that, we need abi-versions.h which is generated right here.
96 ifeq ($(versioning),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) -v oldest_abi=$(oldest-abi) -f $^ > $@T
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
108 endif # avoid-generated
109 endif # $(versioning) = yes
111 ifndef avoid-generated
112 before-compile := $(common-objpfx)libc-abis.h $(before-compile)
113 $(common-objpfx)libc-abis.h: $(common-objpfx)libc-abis.stamp; @:
114 $(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \
115 $(firstword $(wildcard $(sysdirs:=/libc-abis)) \
119 $(base-machine)-$(config-vendor)-$(config-os) \
120 < $(word 2,$^) > $(@:.stamp=.h)T
121 $(move-if-change) $(@:.stamp=.h)T $(@:.stamp=.h)
123 common-generated += $(common-objpfx)libc-abis.h
124 endif # avoid-generated
126 # Make sure the subdirectory for object files gets created.
128 ifeq (,$(wildcard $(objpfx).))
129 before-compile += $(objpfx).
131 $(make-target-directory)
135 # Remove existing files from `before-compile'. Things are added there when
136 # they must exist for dependency generation to work right, but once they
137 # exist there is no further need for every single file to depend on them,
138 # and those gratuitous dependencies result in many gratuitous
140 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
142 # Don't let any before-compile file be an intermediate and get removed.
147 # We don't want $(common-objpfx) files to depend on miscellaneous stuff
150 common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
152 common-before-compile = $(before-compile)
156 # If a makefile needs to do something conditional on something that
157 # can only be figured out from headers, write a FOO.make.c input
158 # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
159 # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
161 # We only generate these in the top-level makefile, to avoid any weirdness
162 # from subdir-specific makefile tweaks creeping in on an update.
163 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
165 (echo '# Generated from $*.make.c by Makerules.'; \
166 $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
167 -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
168 | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \
169 echo 'common-generated += $(@F)'; \
170 sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
176 sed-remove-dotdot := -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' \
177 -e 's@^\.\.\/\([^ \]*\)@$$(..)\1@g'
179 sed-remove-dotdot := -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' \
180 -e 's@^\([^ \/$$][^ \]*\)@$$(..)\1@g'
184 ifdef gen-as-const-headers
185 # Generating headers for assembly constants.
186 # We need this defined early to get into before-compile before
187 # it's used in sysd-rules, below.
188 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
189 %.sym $(common-before-compile)
190 $(AWK) -f $< $(filter %.sym,$^) \
191 | $(CC) -S -o $(@:.h.d=.h)T3 $(CFLAGS) $(CPPFLAGS) -x c - \
192 -MD -MP -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)'
193 sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' \
194 $(@:.h.d=.h)T3 > $(@:.h.d=.h)T
196 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
197 $(@:.h=.h.d)T > $(@:.h=.h.d)T2
199 mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
200 mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
201 vpath %.sym $(sysdirs)
202 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
204 tests += $(gen-as-const-headers:%.sym=test-as-const-%)
205 generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
206 $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \
207 %.sym $(common-objpfx)%.h
208 ($(AWK) '{ sub(/^/, "asconst_", $$2); print; }' $(filter %.h,$^); \
209 $(AWK) -v test=1 -f $< $(filter %.sym,$^); \
210 echo '#include "$(..)test-skeleton.c"') > $@T
214 # Generate an ordered list of implicit rules which find the source files in
215 # each sysdep directory. The old method was to use vpath to search all the
216 # sysdep directories. However, that had the problem that a .S file in a
217 # later directory would be chosen over a .c file in an earlier directory,
218 # which does not preserve the desired sysdeps ordering behavior.
220 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
221 # patterns matching sysdep directories whose assembly source files should
223 ifdef inhibit-sysdep-asm
224 define check-inhibit-asm
225 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) asm= ;; esac;
229 -include $(common-objpfx)sysd-rules
230 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
231 # The value of $(+sysdep_dirs) the sysd-rules was computed for
232 # differs from the one we are using now. So force a rebuild of sysd-rules.
233 sysd-rules-force = FORCE
236 $(common-objpfx)sysd-rules: $(common-objpfx)config.make $(..)Makerules \
237 $(sysdep-makefiles) $(sysdep-makeconfigs) \
240 (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \
241 for dir in $(config-sysdirs); do \
244 *) dir="\$$(..)$$dir" ;; \
247 $(check-inhibit-asm) \
248 for o in $(all-object-suffixes); do \
249 set $(subst :, ,$(sysd-rules-patterns)); \
250 while [ $$# -ge 2 ]; do \
253 v=$${t%%%}; [ x"$$v" = x ] || v="\$$($${v}CPPFLAGS)"; \
254 for s in $$asm .c; do \
255 echo "\$$(objpfx)$$t$$o: $$dir/$$d$$s \$$(before-compile)"; \
256 echo " \$$(compile-command$$s) $$v"; \
260 echo "\$$(inst_includedir)/%.h: $$dir/%.h \$$(+force)"; \
261 echo " \$$(do-install)"; \
263 echo 'sysd-rules-done = t') > $@T
266 ifndef sysd-rules-done
267 # Don't do deps until this exists, because it provides rules to make the deps.
271 define o-iterator-doit
272 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
274 object-suffixes-left := $(all-object-suffixes)
275 include $(o-iterator)
277 define o-iterator-doit
278 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
280 object-suffixes-left := $(all-object-suffixes)
281 include $(o-iterator)
283 define o-iterator-doit
284 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
286 object-suffixes-left := $(all-object-suffixes)
287 include $(o-iterator)
289 define o-iterator-doit
290 $(objpfx)%$o: %.cc $(before-compile); $$(compile-command.cc)
292 object-suffixes-left := $(all-object-suffixes)
293 include $(o-iterator)
295 # Omit the objpfx rules when building in the source tree, because
296 # objpfx is empty and so these rules just override the ones above.
298 # Define first rules to find the source files in $(objpfx).
299 # Generated source files will end up there.
300 define o-iterator-doit
301 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
303 object-suffixes-left := $(all-object-suffixes)
304 include $(o-iterator)
306 define o-iterator-doit
307 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
309 object-suffixes-left := $(all-object-suffixes)
310 include $(o-iterator)
312 define o-iterator-doit
313 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
315 object-suffixes-left := $(all-object-suffixes)
316 include $(o-iterator)
319 # Generate version maps, but wait until sysdep-subdirs is known
320 ifeq ($(sysd-sorted-done),t)
321 ifeq ($(versioning),yes)
322 -include $(common-objpfx)sysd-versions
323 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
324 common-generated += $(version-maps)
325 postclean-generated += sysd-versions Versions.all abi-versions.h \
326 Versions.def.v.i Versions.def.v Versions.v.i Versions.v
328 ifndef avoid-generated
329 ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
330 sysd-versions-force = FORCE
333 # See %.v/%.v.i implicit rules in Makeconfig.
334 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
335 $(wildcard $(add-ons:%=$(..)%/Versions.def))
336 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
337 $(common-objpfx)soversions.i \
338 $(common-objpfx)Versions.def.v
339 { while read which lib version setname; do \
340 test x"$$which" = xDEFAULT || continue; \
341 test -z "$$setname" || echo "$$lib : $$setname"; \
342 done < $(word 2,$^); \
344 } | LC_ALL=C $(AWK) -f $< > $@T
346 # See %.v/%.v.i implicit rules in Makeconfig.
347 $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
348 $(wildcard $(sysdirs:%=%/Versions)) \
349 $(common-objpfx)abi-versions.h \
350 $(sysd-versions-force)
351 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
352 $(common-objpfx)Versions.v \
353 $(..)scripts/versions.awk
354 ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
356 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
357 -v move_if_change='$(move-if-change)' \
361 endif # avoid-generated
362 endif # $(versioning) = yes
363 endif # sysd-sorted-done
365 # Generate .dT files as we compile.
366 compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
367 compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
368 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) $(compile-mkdep-flags)
369 compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
370 compile-command.cc = $(compile.cc) $(OUTPUT_OPTION) $(compile-mkdep-flags)
372 # Like compile-mkdep-flags, but for use with $(BUILD_CC). We don't want to
373 # track system includes here, they may spuriously trigger an install rule,
374 # and would cause the check-local-headers test to fail.
375 native-compile-mkdep-flags = -MMD -MP -MF $@.dt -MT $@
377 # GCC can grok options after the file name, and it looks nicer that way.
378 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
379 compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
380 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
381 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
382 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
383 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
384 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
386 # We need this for the output to go in the right place. It will default to
387 # empty if make was configured to work with a cc that can't grok -c and -o
388 # together. You can't compile the C library with such a compiler.
389 OUTPUT_OPTION = -o $@
391 # We need the $(CFLAGS) to be in there to have the right predefines during
392 # the dependency run for C sources. But having it for assembly sources can
393 # get the wrong predefines.
394 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
397 $(make-target-directory)
398 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
399 $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
400 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
401 $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
402 mv -f $(@:.d=.T) $@ $(generate-md5)
406 # Continuation lines here are dangerous because they introduce spaces!
407 define sed-remove-objpfx
408 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
409 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
413 # Modify the list of routines we build for different targets
415 ifeq (yes,$(build-shared))
416 ifndef libc.so-version
417 # Undefine this because it can't work when we libc.so is unversioned.
418 static-only-routines =
422 # Bounded pointer thunks are only built for *.ob
423 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
425 elide-routines.oS += $(filter-out $(static-only-routines),\
426 $(routines) $(aux) $(sysdep_routines)) \
428 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
430 # If we have versioned code we don't need the old versions in any of the
432 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
433 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
434 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
435 elide-routines.ob += $(shared-only-routines)
437 # Shared library building.
439 ifeq (yes,$(build-shared))
441 # Reference map file only when versioning is selected and a map file name
443 ifeq ($(versioning),yes)
444 map-file = $(firstword $($(@F:.so=-map)) \
445 $(addprefix $(common-objpfx), \
446 $(filter $(@F:.so=.map),$(version-maps))))
447 load-map-file = $(map-file:%=-Wl,--version-script=%)
450 # Pattern rule to build a shared object from an archive of PIC objects.
451 # This must come after the installation rules so Make doesn't try to
452 # build shared libraries in place from the installed *_pic.a files.
453 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
454 # on other shared objects.
455 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
458 define build-shlib-helper
459 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
460 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(config-LDFLAGS) \
461 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
462 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
463 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
464 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
465 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
468 ifeq (yes,$(use-default-link))
469 # If the linker is good enough, we can let it use its default linker script.
473 # binutils only position loadable notes into the first page for binaries,
474 # not for shared objects
475 $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
476 $(LINK.o) -shared -Wl,-O1 \
477 -nostdlib -nostartfiles \
478 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
479 -Wl,--verbose 2>&1 | \
481 -e '/^=========/,/^=========/!d;/^=========/d' \
482 $(if $(filter yes,$(have-hash-style)), \
483 -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
484 -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
485 -e '/DATA_SEGMENT_ALIGN/{H;g}' \
487 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
489 -e 's/^.*\*(\.dynbss).*$$/& \
490 PROVIDE(__start___libc_freeres_ptrs = .); \
491 *(__libc_freeres_ptrs) \
492 PROVIDE(__stop___libc_freeres_ptrs = .);/'\
493 -e 's@^.*\*(\.jcr).*$$@& \
494 PROVIDE(__start___libc_subfreeres = .);\
495 __libc_subfreeres : { *(__libc_subfreeres) }\
496 PROVIDE(__stop___libc_subfreeres = .);\
497 PROVIDE(__start___libc_atexit = .);\
498 __libc_atexit : { *(__libc_atexit) }\
499 PROVIDE(__stop___libc_atexit = .);\
500 PROVIDE(__start___libc_thread_subfreeres = .);\
501 __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
502 PROVIDE(__stop___libc_thread_subfreeres = .);\
503 /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
506 common-generated += shlib.lds
508 shlib-lds = $(common-objpfx)shlib.lds
509 shlib-lds-flags = -T $(shlib-lds)
513 $(build-shlib-helper) -o $@ $(shlib-lds-flags) \
514 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
517 define build-module-helper
518 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
519 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
520 -B$(csu-objpfx) $(load-map-file) \
521 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
522 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
525 # This macro is similar to build-shlib but it does not define a soname
526 # and it does not depend on the destination name to start with `lib'.
527 # binutils only position loadable notes into the first page for binaries,
528 # not for shared objects
530 $(build-module-helper) -o $@ $(shlib-lds-flags) \
531 $(csu-objpfx)abi-note.o $(build-module-objlist)
533 define build-module-asneeded
534 $(build-module-helper) -o $@ $(shlib-lds-flags) \
535 $(csu-objpfx)abi-note.o \
536 -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
539 build-module-helper-objlist = \
540 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
541 $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^))
543 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
544 build-shlib-objlist = $(build-module-helper-objlist) \
545 $(LDLIBS-$(@F:lib%.so=%).so)
547 # Don't try to use -lc when making libc.so itself.
548 # Also omits crti.o and crtn.o, which we do not want
549 # since we define our own `.init' section specially.
550 LDFLAGS-c.so = -nostdlib -nostartfiles
551 # But we still want to link libc.so against $(libc.so-gnulib).
552 LDLIBS-c.so += $(libc.so-gnulib)
553 # Give libc.so an entry point and make it directly runnable itself.
554 LDFLAGS-c.so += -e __libc_main
555 # If lazy relocation is disabled add the -z now flag.
556 ifeq ($(bind-now),yes)
557 LDFLAGS-c.so += -Wl,-z,now
559 # Pre-link the objects of libc_pic.a so that we can locally resolve
560 # COMMON symbols before we link against ld.so. This is because ld.so
561 # contains some of libc_pic.a already, which will prevent the COMMONs
562 # from being allocated in libc.so, which introduces evil dependencies
563 # between libc.so and ld.so, which can make it impossible to upgrade.
564 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
565 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
566 $(LDFLAGS-c_pic.os) -Wl,-d $(whole-archive) $^ -o $@
568 ifeq (,$(strip $(shlib-lds-flags)))
569 # Generate a list of -R options to excise .gnu.glibc-stub.* sections.
570 $(common-objpfx)libc_pic.opts: $(common-objpfx)libc_pic.os
572 $(AWK) '$$2 ~ /\.gnu\.glibc-stub\./ { print "-R", $$2 }' \
575 # Apply those -R options.
576 $(common-objpfx)libc_pic.os.clean: $(common-objpfx)libc_pic.opts \
577 $(common-objpfx)libc_pic.os
579 generated += libc_pic.opts libc_pic.os.clean
581 libc_pic_clean := .clean
584 # Use our own special initializer and finalizer files for libc.so.
585 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
586 $(common-objpfx)libc_pic.os$(libc_pic_clean) \
587 $(elfobjdir)/sofini.os \
588 $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
591 ifeq ($(versioning),yes)
592 $(common-objpfx)libc.so: $(common-objpfx)libc.map
594 common-generated += libc.so libc_pic.os
595 ifdef libc.so-version
596 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
598 common-generated += libc.so$(libc.so-version)
602 # Figure out the source filenames in this directory.
604 override sources := $(addsuffix .c,\
605 $(filter-out $(elided-routines),\
608 sysdep_routines := $(sysdep_routines)
610 headers := $(headers) $(sysdep_headers)
612 # This is the list of all object files, gotten by
613 # replacing every ".c" in `sources' with a ".o".
614 # We also add bounded-pointer thunks, which are later
615 # elided for all suffixes except for `.ob'.
616 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
617 $(patsubst %,$(bppfx)%.o,\
618 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
621 # The makefile may define $(extra-libs) with `libfoo libbar'
622 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
624 # extra-lib.mk is included once for each extra lib to define rules
625 # to build it, and to add its objects to the various variables.
626 # During its evaluation, $(lib) is set to the name of the library.
627 extra-libs-left := $(extra-libs)
628 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
632 # The makefile may define $(modules-names) to build additional modules.
633 # These are built with $(build-module), except any in $(modules-names-nobuild).
635 # extra-lib.mk is included once for each extra lib to define rules
636 # to build it, and to add its objects to the various variables.
637 # During its evaluation, $(lib) is set to the name of the library.
638 extra-modules-left := $(modules-names)
639 include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
641 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
642 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
643 $(objpfx)%.os $(shlib-lds) \
644 $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
648 +depfiles := $(sources:.c=.d) \
649 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
650 $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
651 $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
652 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
653 ifeq ($(build-programs),yes)
654 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
656 +depfiles := $(addprefix $(objpfx),\
657 $(filter-out $(addsuffix .d,$(omit-deps)),\
659 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
660 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
661 $(wildcard $(all-dt-files:.dt=.d))
663 # This is a funny rule in that it removes its input file.
665 @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
666 mv -f $(@:.d=.T) $@ && \
669 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
670 # They will be generated when they're needed, and trying too early won't work.
671 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
672 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
677 -include $(+depfiles)
681 # Maximize efficiency by minimizing the number of rules.
682 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
683 # Don't define any builtin rules.
684 MAKEFLAGS := $(MAKEFLAGS)r
686 # Generic rule for making directories.
688 # mkdir isn't smart enough to strip a trailing /.
689 # We always require a mkdir which supports the -p option to avoid error
690 # messages in case of races.
693 # Make sure that object files are not removed
694 # when they are intermediates between sources and library members.
695 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
697 # Make sure that the parent library archive is never removed.
698 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
700 # Use the verbose option of ar and tar when not running silently.
701 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
707 ARFLAGS := r$(verbose)
708 CREATE_ARFLAGS := cru$(verbose)
710 # This makes all the object files in the parent library archive.
712 .PHONY: lib lib-noranlib
713 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
714 lib-noranlib: libobjs
716 # For object-suffix $o, the list of objects with that suffix.
717 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
718 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
719 $(elide-routines$o)),\
721 $(addprefix $(objpfx),$(o-objects$o))
723 others: $(addprefix $(objpfx),$(install-lib))
727 # Create the stamp$o files to keep the parent makefile happy.
728 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
729 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
730 $(make-target-directory)
734 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
735 # timestamp file; these rules (one explicit rule is generated for each
736 # object suffix) write a list of objects to update in the stamp file.
737 # The parent will then actually add them all to the archive in the
738 # archive rule, below.
739 define o-iterator-doit
740 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
743 $(make-target-directory)
744 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
747 object-suffixes-left := $(object-suffixes-for-libc)
748 include $(o-iterator)
752 # Now define explicit rules to build the library archives; these depend
753 # on the stamp files built above.
754 define o-iterator-doit
755 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
756 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
759 cd $(common-objdir) && \
760 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
762 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
763 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
765 $(subdirs-stamps): subdir_lib;
767 object-suffixes-left = $(object-suffixes-for-libc)
768 include $(o-iterator)
771 # This makes all the object files.
772 .PHONY: objects objs libobjs extra-objs
773 objects objs: libobjs extra-objs
774 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
775 extra-objs: $(addprefix $(objpfx),$(extra-objs))
777 # Canned sequence for building an extra library archive.
778 define build-extra-lib
779 $(patsubst %/,cd % &&,$(objpfx)) \
780 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
781 $(patsubst $(objpfx)%,%,$^)
786 .PHONY: force-install
789 # $(install-lib) are installed from the object directory into $(libdir);
790 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
791 # unless they also appear in $(non-lib.a). $(install-data) are installed as
792 # they are into $(datadir). $(headers) are installed as they are in
793 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
794 # are installed from the object directory into $(bindir), $(bindir) and
795 # $(sbindir), respectively. $(install-others) and $(install-others-programs)
796 # are absolute path names of files to install; rules to install them are
799 # The simple library name to install libc.a under.
800 # This could be defined by a sysdep Makefile.
806 $(make-target-directory)
807 $(INSTALL_DATA) $< $@
810 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
811 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
812 define make-target-directory
813 $(addprefix $(..)./scripts/mkinstalldirs ,\
814 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
817 # Any directory (parent or subdir) should install libc.a; this way
818 # "make install" in a subdir is guaranteed to install everything it changes.
819 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
820 $(inst_libdir)/$(patsubst %,$(libtype$o),\
821 $(libprefix)$(libc-name)))
822 install: $(installed-libcs)
823 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
824 $(make-target-directory)
825 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
827 define do-install-program
828 $(make-target-directory)
829 $(INSTALL_PROGRAM) $< $@.new
833 define do-install-script
834 $(make-target-directory)
835 $(INSTALL_SCRIPT) $< $@.new
839 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
840 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
842 ifeq (yes,$(build-shared))
843 # Find which .so's have versions.
844 versioned := $(strip $(foreach so,$(install-lib.so),\
845 $(patsubst %,$(so),$($(so)-version))))
847 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
848 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
850 # For versioned libraries, we install three files:
851 # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
852 # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
853 # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
854 V := $(firstword $($(subdir)-version) $(version))
855 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
856 $(foreach L,$(install-lib.so-versioned),\
858 $(inst_slibdir)/$(L:.so=)-$V.so \
859 $(inst_slibdir)/$L$($L-version))
861 # Install all the unversioned shared libraries.
862 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
863 $(objpfx)%.so $(+force)
864 $(do-install-program)
866 ifneq ($(findstring -s,$(LN_S)),)
869 $(SHELL) $(..)scripts/rellns-sh $< $@.new
873 # If we have no symbolic links don't bother with rellns-sh.
881 ifeq (yes,$(build-shared))
882 ifeq (no,$(cross-compiling))
883 symbolic-link-prog := $(common-objpfx)elf/sln
884 symbolic-link-list := $(common-objpfx)elf/symlink.list
885 define make-shlib-link
886 echo $(<F) $@ >> $(symbolic-link-list)
888 else # cross-compiling
889 # We need a definition that can be used by elf/Makefile's install rules.
890 symbolic-link-prog = $(LN_S)
893 ifndef make-shlib-link
894 define make-shlib-link
900 ifdef libc.so-version
901 # For a library specified to be version N, install three files:
902 # libc.so -> libc.so.N (e.g. libc.so.6)
903 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
905 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
908 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
909 $(do-install-program)
910 install: $(inst_slibdir)/libc.so$(libc.so-version)
912 # This fragment of linker script gives the OUTPUT_FORMAT statement
913 # for the configuration we are building. We put this statement into
914 # the linker scripts we install for -lc et al so that they will not be
915 # used by a link for a different format on a multi-architecture system.
916 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
917 $(common-objpfx)config.make \
918 $(common-objpfx)config.h $(..)Makerules
919 ifneq (unknown,$(output-format))
920 echo > $@.new 'OUTPUT_FORMAT($(output-format))'
922 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
923 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
924 | sed -n -f $< > $@.new
929 common-generated += format.lds
932 # What we install as libc.so for programs to link against is in fact a
933 # link script. It contains references for the various libraries we need.
934 # The libc.so object is not complete since some functions are only defined
935 # in libc_nonshared.a.
936 # We need to use absolute paths since otherwise local copies (if they exist)
937 # of the files are taken by the linker.
938 install: $(inst_libdir)/libc.so
939 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
940 $(common-objpfx)libc.so$(libc.so-version) \
941 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
942 $(libprefix)$(libc-name)) \
944 (echo '/* GNU ld script';\
945 echo ' Use the shared library, but some functions are only in';\
946 echo ' the static library, so try that secondarily. */';\
948 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
949 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
950 ' AS_NEEDED (' $(slibdir)/$(rtld-installed-name) ') )' \
957 install: $(inst_slibdir)/libc.so
958 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
959 $(do-install-program)
962 ifneq (,$(versioned))
963 # Produce three sets of rules as above for all the smaller versioned libraries.
965 define o-iterator-doit
966 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
968 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
969 ifneq (,$(object-suffixes-left))
970 include $(o-iterator)
973 # Make symlinks in the build directory, because the versioned names might
974 # be referenced by a DT_NEEDED in another library.
975 define o-iterator-doit
976 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
978 object-suffixes-left := $(versioned)
979 include $(o-iterator)
981 generated += $(foreach o,$(versioned),$o$($o-version))
983 ifeq (,$($(subdir)-version))
984 define o-iterator-doit
985 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
989 object-suffixes-left := $(versioned)
990 include $(o-iterator)
992 define o-iterator-doit
993 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
994 $$(do-install-program)
996 object-suffixes-left := $(versioned)
997 include $(o-iterator)
999 define o-iterator-doit
1000 $(inst_slibdir)/$o$($o-version): \
1001 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1004 object-suffixes-left := $(versioned)
1005 include $(o-iterator)
1007 define o-iterator-doit
1008 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1009 $$(do-install-program)
1011 object-suffixes-left := $(versioned)
1012 include $(o-iterator)
1016 define do-install-so
1017 $(do-install-program)
1018 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1019 $(filter-out %.so,$@))
1022 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1023 $(foreach v,$(so-versions),\
1024 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1027 $(foreach v,$(so-versions),\
1028 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1033 $(addprefix $(inst_bindir)/,$(install-bin)): \
1034 $(inst_bindir)/%: $(objpfx)% $(+force)
1035 $(do-install-program)
1037 ifdef install-bin-script
1038 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1039 $(inst_bindir)/%: $(objpfx)% $(+force)
1040 $(do-install-script)
1042 ifdef install-rootsbin
1043 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1044 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1045 $(do-install-program)
1048 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1049 $(inst_sbindir)/%: $(objpfx)% $(+force)
1050 $(do-install-program)
1053 install-lib.a := $(filter lib%.a,$(install-lib))
1054 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1055 ifdef install-lib-non.a
1056 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1057 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1061 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1062 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1067 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1070 headers := $(strip $(headers))
1072 # This implicit rule installs headers from the source directory.
1073 # It may be ignored in preference to rules from sysd-rules to find
1074 # headers in the sysdeps tree.
1075 $(inst_includedir)/%.h: $(objpfx)%.h $(+force)
1077 $(inst_includedir)/%.h: $(common-objpfx)%.h $(+force)
1079 $(inst_includedir)/%.h: %.h $(+force)
1081 $(inst_includedir)/%.h: $(..)include/%.h $(+force)
1083 headers-nonh := $(filter-out %.h,$(headers))
1085 $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
1088 endif # headers-nonh
1091 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1092 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1093 install-data-nosubdir install-headers-nosubdir
1094 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1095 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1096 install-rootsbin-nosubdir: \
1097 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1098 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1099 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1100 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1101 $(addprefix $(libprefix),$(install-lib-non.a)))
1102 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1103 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1104 install-others-nosubdir: $(install-others)
1105 install-others-programs-nosubdir: $(install-others-programs)
1107 # We need all the `-nosubdir' targets so that `install' in the parent
1108 # doesn't depend on several things which each iterate over the subdirs.
1109 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1110 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1111 install-%:: install-%-nosubdir ;
1113 .PHONY: install install-no-libc.a-nosubdir
1114 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
1115 install-lib-nosubdir install-others-nosubdir
1116 ifeq ($(build-programs),yes)
1117 install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
1118 install-rootsbin-nosubdir install-sbin-nosubdir \
1119 install-others-programs-nosubdir
1121 install: install-no-libc.a-nosubdir
1123 # Command to compile $< using the native libraries.
1124 define native-compile
1125 $(make-target-directory)
1126 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1127 $< $(OUTPUT_OPTION) $(BUILD_LDFLAGS)
1130 # We always want to use configuration definitions.
1131 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -D_GNU_SOURCE \
1132 -DIS_IN_build -include $(common-objpfx)config.h
1134 # Support the GNU standard name for this target.
1137 # Special target to run tests which cannot be run unconditionally.
1138 # Maintainers should use this target.
1142 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1143 ifneq (,$(all-nonlib))
1144 cpp-srcs-left = $(all-nonlib:=.c) $(all-nonlib:=.cc)
1146 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
1149 # The include magic above causes those files to use this variable for flags.
1150 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1153 ifeq ($(versioning),yes)
1154 # Generate normalized lists of symbols, versions, and data sizes.
1155 # This is handy for checking against existing library binaries.
1157 %.symlist: $(..)scripts/abilist.awk %.dynsym
1158 LC_ALL=C $(AWK) -f $^ > $@T
1162 $(OBJDUMP) --dynamic-syms $< > $@T
1165 vpath %.abilist $(+sysdep_dirs)
1167 # The .PRECIOUS rule prevents the files built by an implicit rule whose
1168 # target pattern is %.symlist from being considered "intermediate files"
1169 # and automatically removed. We only want these files to be removed by
1170 # 'make clean', which is handled by the 'generated' variable.
1171 .PRECIOUS: %.symlist
1172 generated += $(extra-libs:=.symlist)
1174 check-abi-%: $(common-objpfx)config.make %.abilist $(objpfx)%.symlist
1176 check-abi-%: $(common-objpfx)config.make %.abilist $(common-objpfx)%.symlist
1179 diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^)
1182 update-abi-%: $(objpfx)%.symlist %.abilist
1184 update-abi-%: $(common-objpfx)%.symlist %.abilist
1187 @if cmp -s $^ 2> /dev/null; \
1189 echo '+++ $(filter %.abilist,$^) is unchanged'; \
1191 echo '*** Now check $(filter %.abilist,$^) changes for correctness ***'; \
1195 .PHONY: update-abi check-abi
1196 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1197 check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
1199 subdir_check-abi: check-abi
1200 subdir_update-abi: update-abi
1202 check-abi: subdir_check-abi
1203 update-abi: subdir_update-abi
1206 ifeq ($(subdir),elf)
1207 check-abi: check-abi-libc
1208 update-abi: update-abi-libc
1209 common-generated += libc.symlist
1212 ifeq ($(build-shared),yes)
1220 # These will have been set by sysdeps/posix/Makefile.
1226 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1228 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1229 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1230 $(common-objpfx)config.make
1231 $(make-target-directory)
1232 { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
1233 echo '#define _LIBC 1'; \
1234 echo '#include "$(..)misc/sys/uio.h"'; } | \
1235 $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
1236 $(+includes) -xc - -o $(@:st=hT)
1237 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
1238 $(@:st=dT) > $(@:st=dt)
1239 mv -f $(@:st=dt) $(@:st=d)
1240 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
1241 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
1242 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
1243 fopen_max=$${fopen_max:-16}; \
1244 filename_max=$${filename_max:-1024}; \
1245 if [ -z "$$iov_max" ]; then \
1246 define_iov_max="# undef IOV_MAX"; \
1248 define_iov_max="# define IOV_MAX $$iov_max"; \
1250 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
1251 -e "s/@FILENAME_MAX@/$$filename_max/" \
1252 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
1253 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
1254 -e "s/@L_ctermid@/$(L_ctermid)/" \
1255 -e "s/@L_cuserid@/$(L_cuserid)/" \
1256 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
1258 $(move-if-change) $(@:st=h.new) $(@:st=h)
1259 # Remove these last so that they can be examined if something went wrong.
1260 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1264 -include $(stdio_lim:h=d)
1266 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1270 .PHONY: echo-headers
1274 %.bz2: %; bzip2 -9vk $<
1275 %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
1276 %.xz: %; xz -9evk $<
1278 # Common cleaning targets.
1280 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1282 mostlyclean: common-mostlyclean
1285 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1287 $(addsuffix -bp.out,$(tests) $(xtests) \
1290 # Remove the object files.
1292 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1293 $(others) $(sysdep-others) stubs \
1294 $(addsuffix .o,$(tests) $(xtests) \
1295 $(test-srcs) $(others) \
1297 $(addsuffix -bp,$(tests) $(xtests) \
1299 $(addsuffix .out,$(tests) $(xtests) \
1301 $(addsuffix -bp.out,$(tests) $(xtests) \
1303 -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
1304 $(install-lib) $(install-lib.so) \
1305 $(install-lib.so:%.so=%_pic.a))
1307 -rm -f $(objpfx)rtld-*.os
1310 $(foreach o,$(object-suffixes-for-libc),
1311 -rm -f $(objpfx)stamp$o $(o-objects))
1314 # Also remove the dependencies and generated source files.
1315 common-clean: common-mostlyclean
1316 -rm -f $(addprefix $(objpfx),$(generated))
1317 -rm -f $(objpfx)*.d $(objpfx)*.dt
1318 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1319 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1320 -rm -f $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
1322 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1323 # for each function which is a stub. We grovel over all the .d files
1324 # looking for references to <stub-tag.h>. Then we grovel over each
1325 # referenced source file to see what stub function it defines.
1328 .PHONY: stubs # The parent Makefile calls this target.
1329 stubs: $(objpfx)stubs
1331 objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
1332 $(addprefix $(objpfx),$(extra-objs))
1333 $(objpfx)stubs: $(objs-for-stubs)
1334 ifneq (,$(strip $(objs-for-stubs)))
1335 (cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
1336 $(AWK) '/\.gnu\.glibc-stub\./ { \
1337 sub(/\.gnu\.glibc-stub\./, "", $$2); \
1339 END { for (s in stubs) print "#define __stub_" s }' > $@T
1345 ifneq (,$(strip $(gpl2lgpl)))
1346 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1347 # Snarf from the master source and frob the copying notice.
1348 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1350 # So I don't edit them by mistake.