1 # Copyright (C) 1991-2015 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 ($(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
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 # $(build-shared) = 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 ifeq (yes,$(build-shared))
127 $(common-objpfx)runtime-linker.h: $(common-objpfx)runtime-linker.stamp; @:
128 $(common-objpfx)runtime-linker.stamp: $(common-objpfx)config.make
129 $(make-target-directory)
130 echo '#define RUNTIME_LINKER "$(rtlddir)/$(rtld-installed-name)"' \
132 $(move-if-change) ${@:stamp=T} ${@:stamp=h}
136 # Make sure the subdirectory for object files gets created.
138 ifeq (,$(wildcard $(objpfx).))
139 before-compile += $(objpfx).
141 $(make-target-directory)
145 # Remove existing files from `before-compile'. Things are added there when
146 # they must exist for dependency generation to work right, but once they
147 # exist there is no further need for every single file to depend on them,
148 # and those gratuitous dependencies result in many gratuitous
150 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
152 # Don't let any before-compile file be an intermediate and get removed.
157 # We don't want $(common-objpfx) files to depend on miscellaneous stuff
160 common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
162 common-before-compile = $(before-compile)
166 # If a makefile needs to do something conditional on something that
167 # can only be figured out from headers, write a FOO.make.c input
168 # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
169 # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
171 # We only generate these in the top-level makefile, to avoid any weirdness
172 # from subdir-specific makefile tweaks creeping in on an update.
173 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
175 (echo '# Generated from $*.make.c by Makerules.'; \
176 $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
177 -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
178 | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \
179 echo 'common-generated += $(@F)'; \
180 sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
186 sed-remove-dotdot := -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' \
187 -e 's@^\.\.\/\([^ \]*\)@$$(..)\1@g'
189 sed-remove-dotdot := -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' \
190 -e 's@^\([^ \/$$][^ \]*\)@$$(..)\1@g'
194 ifdef gen-as-const-headers
195 # Generating headers for assembly constants.
196 # We need this defined early to get into before-compile before
197 # it's used in sysd-rules, below.
198 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
199 %.sym $(common-before-compile)
200 $(AWK) -f $< $(filter %.sym,$^) \
201 | $(CC) -S -o $(@:.h.d=.h)T3 $(CFLAGS) $(CPPFLAGS) -x c - \
202 -MD -MP -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)'
203 sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' \
204 $(@:.h.d=.h)T3 > $(@:.h.d=.h)T
206 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
207 $(@:.h=.h.d)T > $(@:.h=.h.d)T2
209 mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
210 mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
211 vpath %.sym $(sysdirs)
212 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
214 tests += $(gen-as-const-headers:%.sym=test-as-const-%)
215 generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
216 $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \
217 %.sym $(common-objpfx)%.h
218 ($(AWK) '{ sub(/^/, "asconst_", $$2); print; }' $(filter %.h,$^); \
219 $(AWK) -v test=1 -f $< $(filter %.sym,$^); \
220 echo '#include "$(..)test-skeleton.c"') > $@T
224 ifeq (yes,$(build-shared))
225 # Generate the header containing the names of all shared libraries.
226 # We use a stamp file to avoid unnecessary recompilations.
227 before-compile += $(common-objpfx)gnu/lib-names.h
228 ifeq ($(soversions.mk-done),t)
230 lib-names-h-abi = gnu/lib-names.h
231 lib-names-stmp-abi = gnu/lib-names.stmp
233 lib-names-h-abi = gnu/lib-names-$(default-abi).h
234 lib-names-stmp-abi = gnu/lib-names-$(default-abi).stmp
235 before-compile += $(common-objpfx)$(lib-names-h-abi)
236 common-generated += gnu/lib-names.h
237 install-others-nosubdir: $(inst_includedir)/$(lib-names-h-abi)
238 $(common-objpfx)gnu/lib-names.h:
239 $(make-target-directory)
241 echo '/* This file is automatically generated.';\
242 echo ' It defines macros to allow user program to find the shared'; \
243 echo ' library files which come as part of GNU libc. */'; \
244 echo '#ifndef __GNU_LIB_NAMES_H'; \
245 echo '#define __GNU_LIB_NAMES_H 1'; \
247 $(if $(abi-includes), \
248 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
250 $(foreach v,$(abi-variants),\
251 $(if $(abi-$(v)-condition),\
252 echo '#if $(abi-$(v)-condition)'; \
253 echo '# include <gnu/lib-names-$(v).h>'); \
254 $(if $(abi-$(v)-condition),echo '#endif';)) \
256 echo '#endif /* gnu/lib-names.h */'; \
259 $(common-objpfx)$(lib-names-h-abi): $(common-objpfx)$(lib-names-stmp-abi); @:
260 $(common-objpfx)$(lib-names-stmp-abi): $(..)scripts/lib-names.awk \
261 $(common-objpfx)soversions.i
262 $(make-target-directory)
264 $(if $(abi-variants), \
265 echo '/* This file is automatically generated. */';\
266 echo '#ifndef __GNU_LIB_NAMES_H'; \
267 echo '# error "Never use <$(lib-names-h-abi)> directly; include <gnu/lib-names.h> instead."'; \
269 echo '/* This file is automatically generated.';\
270 echo ' It defines macros to allow user program to find the shared'; \
271 echo ' library files which come as part of GNU libc. */'; \
272 echo '#ifndef __GNU_LIB_NAMES_H'; \
273 echo '#define __GNU_LIB_NAMES_H 1';) \
275 ($(foreach s,$(all-sonames), echo $(s);)) \
276 | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort; \
277 $(if $(abi-variants),, \
279 echo '#endif /* gnu/lib-names.h */';) \
281 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
284 common-generated += $(lib-names-h-abi) $(lib-names-stmp-abi)
287 ###############################################################################
288 # NOTE! Everything adding to before-compile needs to come before this point! #
289 ###############################################################################
291 # Generate an ordered list of implicit rules which find the source files in
292 # each sysdep directory. The old method was to use vpath to search all the
293 # sysdep directories. However, that had the problem that a .S file in a
294 # later directory would be chosen over a .c file in an earlier directory,
295 # which does not preserve the desired sysdeps ordering behavior.
297 # System-dependent makefiles can put in `inhibit-sysdep-asm' regexps
298 # matching sysdep directories whose assembly source files should be
301 -include $(common-objpfx)sysd-rules
302 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
303 # The value of $(+sysdep_dirs) the sysd-rules was computed for
304 # differs from the one we are using now. So force a rebuild of sysd-rules.
305 sysd-rules-force = FORCE
308 $(common-objpfx)sysd-rules: $(..)scripts/sysd-rules.awk \
309 $(common-objpfx)config.make $(..)Makerules \
310 $(sysdep-makefiles) $(sysdep-makeconfigs) \
313 LC_ALL=C $(AWK) -f $< > $@T \
314 -v all_object_suffixes='$(all-object-suffixes)' \
315 -v inhibit_sysdep_asm='$(inhibit-sysdep-asm)' \
316 -v sysd_rules_patterns='$(sysd-rules-patterns)' \
317 -v config_sysdirs='$(config-sysdirs)'
320 ifndef sysd-rules-done
321 # Don't do deps until this exists, because it provides rules to make the deps.
325 define o-iterator-doit
326 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
328 object-suffixes-left := $(all-object-suffixes)
329 include $(o-iterator)
331 define o-iterator-doit
332 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
334 object-suffixes-left := $(all-object-suffixes)
335 include $(o-iterator)
337 define o-iterator-doit
338 $(objpfx)%$o: %.cc $(before-compile); $$(compile-command.cc)
340 object-suffixes-left := $(all-object-suffixes)
341 include $(o-iterator)
343 # Omit the objpfx rules when building in the source tree, because
344 # objpfx is empty and so these rules just override the ones above.
346 # Define first rules to find the source files in $(objpfx).
347 # Generated source files will end up there.
348 define o-iterator-doit
349 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
351 object-suffixes-left := $(all-object-suffixes)
352 include $(o-iterator)
354 define o-iterator-doit
355 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
357 object-suffixes-left := $(all-object-suffixes)
358 include $(o-iterator)
361 # Generate version maps, but wait until sysdep-subdirs is known
362 ifeq ($(sysd-sorted-done),t)
363 ifeq ($(build-shared),yes)
364 -include $(common-objpfx)sysd-versions
365 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
366 common-generated += $(version-maps)
367 postclean-generated += sysd-versions Versions.all abi-versions.h \
368 Versions.def Versions.v.i Versions.v
370 ifndef avoid-generated
371 ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
372 sysd-versions-force = FORCE
376 $(common-objpfx)Versions.def: $(..)scripts/versionlist.awk \
377 $(common-objpfx)Versions.v
378 LC_ALL=C $(AWK) -f $^ > $@T
381 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
382 $(common-objpfx)soversions.i \
383 $(common-objpfx)Versions.def
384 { while read which lib version setname; do \
385 test x"$$which" = xDEFAULT || continue; \
386 test -z "$$setname" || echo "$$lib : $$setname"; \
387 done < $(word 2,$^); \
389 } | LC_ALL=C $(AWK) -f $< > $@T
391 # See %.v/%.v.i implicit rules in Makeconfig.
392 $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
393 $(wildcard $(sysdirs:%=%/Versions)) \
394 $(sysd-versions-force)
395 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
396 $(common-objpfx)Versions.v \
397 $(..)scripts/versions.awk
398 ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
400 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
401 -v move_if_change='$(move-if-change)' \
405 endif # avoid-generated
406 endif # $(build-shared) = yes
407 endif # sysd-sorted-done
409 # Generate .dT files as we compile.
410 compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
411 compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
412 compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
413 compile-command.cc = $(compile.cc) $(OUTPUT_OPTION) $(compile-mkdep-flags)
415 # Like compile-mkdep-flags, but for use with $(BUILD_CC). We don't want to
416 # track system includes here, they may spuriously trigger an install rule,
417 # and would cause the check-local-headers test to fail.
418 native-compile-mkdep-flags = -MMD -MP -MF $@.dt -MT $@
420 # GCC can grok options after the file name, and it looks nicer that way.
421 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
422 compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
423 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
424 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
425 COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS)
426 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
427 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
429 # We need this for the output to go in the right place. It will default to
430 # empty if make was configured to work with a cc that can't grok -c and -o
431 # together. You can't compile the C library with such a compiler.
432 OUTPUT_OPTION = -o $@
434 # This is the end of the pipeline for compiling generated C code.
435 compile-stdin.c = $(COMPILE.c) -o $@ -x c - $(compile-mkdep-flags)
437 # We need the $(CFLAGS) to be in there to have the right predefines during
438 # the dependency run for C sources. But having it for assembly sources can
439 # get the wrong predefines.
440 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
443 $(make-target-directory)
444 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
445 $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
446 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
447 $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
448 mv -f $(@:.d=.T) $@ $(generate-md5)
452 # Continuation lines here are dangerous because they introduce spaces!
453 define sed-remove-objpfx
454 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
455 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
459 # Modify the list of routines we build for different targets
461 ifeq (yes,$(build-shared))
462 ifndef libc.so-version
463 # Undefine this because it can't work when we libc.so is unversioned.
464 static-only-routines =
468 elide-routines.oS += $(filter-out $(static-only-routines),\
469 $(routines) $(aux) $(sysdep_routines))
470 elide-routines.os += $(static-only-routines)
472 # If we have versioned code we don't need the old versions in any of the
474 elide-routines.o += $(shared-only-routines)
475 elide-routines.op += $(shared-only-routines)
476 elide-routines.og += $(shared-only-routines)
478 # Shared library building.
480 ifeq (yes,$(build-shared))
482 # Reference map file only when shared libraries are built and a map file name
484 ifeq ($(build-shared),yes)
485 map-file = $(firstword $($(@F:.so=-map)) \
486 $(addprefix $(common-objpfx), \
487 $(filter $(@F:.so=.map),$(version-maps))))
488 load-map-file = $(map-file:%=-Wl,--version-script=%)
491 # Compiler arguments to use to link a shared object with libc and
492 # ld.so. This is intended to be as similar as possible to a default
493 # link with an installed libc.
494 link-libc-args = -Wl,--start-group \
496 $(common-objpfx)libc_nonshared.a \
497 $(as-needed) $(elf-objpfx)ld.so $(no-as-needed) \
500 # The corresponding shared libc to use. This may be modified for a
502 libc-for-link = $(common-objpfx)libc.so
504 # The corresponding dependencies. As these are used in dependencies,
505 # not just commands, they cannot use target-specific variables so need
506 # to name both possible libc.so objects.
507 link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
508 $(common-objpfx)libc_nonshared.a $(elf-objpfx)ld.so
510 # Pattern rule to build a shared object from an archive of PIC objects.
511 # This must come after the installation rules so Make doesn't try to
512 # build shared libraries in place from the installed *_pic.a files.
513 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
514 # on other shared objects. The linking with libc and ld.so is intended
515 # to be as similar as possible to a default link with an installed libc.
516 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(link-libc-deps)
517 $(build-shlib) $(link-libc-args)
518 $(call after-link,$@)
520 define build-shlib-helper
521 $(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \
522 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(rtld-LDFLAGS) \
523 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
524 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
525 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
526 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
527 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
530 ifeq (yes,$(use-default-link))
531 # If the linker is good enough, we can let it use its default linker script.
535 # binutils only position loadable notes into the first page for binaries,
536 # not for shared objects
537 $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
538 $(LINK.o) -shared -Wl,-O1 \
539 -nostdlib -nostartfiles \
540 $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
541 -Wl,--verbose 2>&1 | \
543 -e '/^=========/,/^=========/!d;/^=========/d' \
544 $(if $(filter yes,$(have-hash-style)), \
545 -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
546 -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
547 -e '/DATA_SEGMENT_ALIGN/{H;g}' \
549 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
551 -e 's/^.*\*(\.dynbss).*$$/& \
552 PROVIDE(__start___libc_freeres_ptrs = .); \
553 *(__libc_freeres_ptrs) \
554 PROVIDE(__stop___libc_freeres_ptrs = .);/'\
555 -e 's@^.*\*(\.jcr).*$$@& \
556 PROVIDE(__start___libc_subfreeres = .);\
557 __libc_subfreeres : { *(__libc_subfreeres) }\
558 PROVIDE(__stop___libc_subfreeres = .);\
559 PROVIDE(__start___libc_atexit = .);\
560 __libc_atexit : { *(__libc_atexit) }\
561 PROVIDE(__stop___libc_atexit = .);\
562 PROVIDE(__start___libc_thread_subfreeres = .);\
563 __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
564 PROVIDE(__stop___libc_thread_subfreeres = .);\
565 /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
568 common-generated += shlib.lds
570 shlib-lds = $(common-objpfx)shlib.lds
571 shlib-lds-flags = -T $(shlib-lds)
575 $(build-shlib-helper) -o $@ $(shlib-lds-flags) \
576 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
579 define build-module-helper
580 $(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
581 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
582 -B$(csu-objpfx) $(load-map-file) \
583 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
584 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
587 # This macro is similar to build-shlib but it does not define a soname
588 # and it does not depend on the destination name to start with `lib'.
589 # binutils only position loadable notes into the first page for binaries,
590 # not for shared objects
592 $(build-module-helper) -o $@ $(shlib-lds-flags) \
593 $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
594 $(call after-link,$@)
596 define build-module-asneeded
597 $(build-module-helper) -o $@ $(shlib-lds-flags) \
598 $(csu-objpfx)abi-note.o \
599 -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
601 $(call after-link,$@)
604 build-module-helper-objlist = \
605 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
606 $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \
607 $(link-libc-deps),$^))
609 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
610 build-shlib-objlist = $(build-module-helper-objlist) \
611 $(LDLIBS-$(@F:lib%.so=%).so)
613 # Don't try to use -lc when making libc.so itself.
614 # Also omits crti.o and crtn.o, which we do not want
615 # since we define our own `.init' section specially.
616 LDFLAGS-c.so = -nostdlib -nostartfiles
617 # But we still want to link libc.so against $(libc.so-gnulib).
618 LDLIBS-c.so += $(libc.so-gnulib)
619 # Give libc.so an entry point and make it directly runnable itself.
620 LDFLAGS-c.so += -e __libc_main
621 # If lazy relocation is disabled add the -z now flag.
622 ifeq ($(bind-now),yes)
623 LDFLAGS-c.so += -Wl,-z,now
625 # Pre-link the objects of libc_pic.a so that we can locally resolve
626 # COMMON symbols before we link against ld.so. This is because ld.so
627 # contains some of libc_pic.a already, which will prevent the COMMONs
628 # from being allocated in libc.so, which introduces evil dependencies
629 # between libc.so and ld.so, which can make it impossible to upgrade.
630 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
631 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
632 $(LDFLAGS-c_pic.os) -Wl,-d $(whole-archive) $^ -o $@
634 ifeq (,$(strip $(shlib-lds-flags)))
635 # Generate a list of -R options to excise .gnu.glibc-stub.* sections.
636 $(common-objpfx)libc_pic.opts: $(common-objpfx)libc_pic.os
638 $(AWK) '$$2 ~ /\.gnu\.glibc-stub\./ { print "-R", $$2 }' \
641 # Apply those -R options.
642 $(common-objpfx)libc_pic.os.clean: $(common-objpfx)libc_pic.opts \
643 $(common-objpfx)libc_pic.os
645 generated += libc_pic.opts libc_pic.os.clean
647 libc_pic_clean := .clean
650 # Build a possibly-modified version of libc_pic.a for use in building
652 ifeq (,$(filter sunrpc,$(subdirs)))
653 $(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a
654 $(make-target-directory)
657 $(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a \
658 $(common-objpfx)sunrpc/librpc_compat_pic.a
659 $(make-target-directory)
660 (cd $(common-objpfx)linkobj; \
661 $(AR) x ../libc_pic.a; \
662 rm $$($(AR) t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//'); \
663 $(AR) x ../sunrpc/librpc_compat_pic.a; \
664 $(AR) cr libc_pic.a *.os; \
666 endif # $(subdirs) contains sunrpc
668 # Clear link-libc-deps for the libc.so libraries so build-shlibs does not
669 # filter ld.so out of the list of linked objects.
670 $(common-objpfx)libc.so: link-libc-deps = # empty
671 $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty
673 # Use our own special initializer and finalizer files for the libc.so
675 $(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
676 $(common-objpfx)libc_pic.os$(libc_pic_clean) \
677 $(elf-objpfx)sofini.os \
678 $(elf-objpfx)interp.os \
682 $(call after-link,$@)
684 $(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \
685 $(common-objpfx)linkobj/libc_pic.a \
686 $(elf-objpfx)sofini.os \
687 $(elf-objpfx)interp.os \
691 $(call after-link,$@)
693 ifeq ($(build-shared),yes)
694 $(common-objpfx)libc.so: $(common-objpfx)libc.map
696 common-generated += libc.so libc_pic.os
697 ifdef libc.so-version
698 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
700 common-generated += libc.so$(libc.so-version)
704 # Figure out the source filenames in this directory.
706 override sources := $(addsuffix .c,\
707 $(filter-out $(elided-routines),\
710 sysdep_routines := $(sysdep_routines)
712 headers := $(headers) $(sysdep_headers)
714 # This is the list of all object files, gotten by
715 # replacing every ".c" in `sources' with a ".o".
716 override objects := $(addprefix $(objpfx),$(sources:.c=.o))
719 # The makefile may define $(extra-libs) with `libfoo libbar'
720 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
722 # extra-lib.mk is included once for each extra lib to define rules
723 # to build it, and to add its objects to the various variables.
724 # During its evaluation, $(lib) is set to the name of the library.
725 extra-libs-left := $(extra-libs)
726 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
730 # The makefile may define $(modules-names) to build additional modules.
731 # These are built with $(build-module), except any in $(modules-names-nobuild).
733 # extra-lib.mk is included once for each extra lib to define rules
734 # to build it, and to add its objects to the various variables.
735 # During its evaluation, $(lib) is set to the name of the library.
736 extra-modules-left := $(modules-names)
737 include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
739 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
740 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
741 $(objpfx)%.os $(shlib-lds) $(link-libs-deps)
745 +depfiles := $(sources:.c=.d) \
746 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
747 $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
748 $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
749 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
750 ifeq ($(build-programs),yes)
751 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
753 +depfiles := $(addprefix $(objpfx),\
754 $(filter-out $(addsuffix .d,$(omit-deps)),\
756 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
757 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
758 $(wildcard $(all-dt-files:.dt=.d))
760 # This is a funny rule in that it removes its input file.
762 @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
763 mv -f $(@:.d=.T) $@ && \
766 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
767 # They will be generated when they're needed, and trying too early won't work.
768 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
769 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
774 -include $(+depfiles)
778 # Maximize efficiency by minimizing the number of rules.
779 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
780 # Don't define any builtin rules.
781 MAKEFLAGS := $(MAKEFLAGS)r
783 # Generic rule for making directories.
785 # mkdir isn't smart enough to strip a trailing /.
786 # We always require a mkdir which supports the -p option to avoid error
787 # messages in case of races.
790 # Make sure that object files are not removed
791 # when they are intermediates between sources and library members.
792 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
794 # Make sure that the parent library archive is never removed.
795 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
797 # Use the verbose option of ar and tar when not running silently.
798 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
804 ARFLAGS := r$(verbose)
805 CREATE_ARFLAGS := cru$(verbose)
807 # This makes all the object files in the parent library archive.
809 .PHONY: lib lib-noranlib
810 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
811 lib-noranlib: libobjs
813 # For object-suffix $o, the list of objects with that suffix.
814 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
815 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
816 $(elide-routines$o)),\
818 $(addprefix $(objpfx),$(o-objects$o))
820 others: $(addprefix $(objpfx),$(install-lib))
824 # Create the stamp$o files to keep the parent makefile happy.
825 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
826 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
827 $(make-target-directory)
831 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
832 # timestamp file; these rules (one explicit rule is generated for each
833 # object suffix) write a list of objects to update in the stamp file.
834 # The parent will then actually add them all to the archive in the
835 # archive rule, below.
836 define o-iterator-doit
837 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
840 $(make-target-directory)
841 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
844 object-suffixes-left := $(object-suffixes-for-libc)
845 include $(o-iterator)
849 # Now define explicit rules to build the library archives; these depend
850 # on the stamp files built above.
851 define o-iterator-doit
852 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
853 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
856 cd $(common-objdir) && \
857 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
859 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
860 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
862 $(subdirs-stamps): subdir_lib;
864 object-suffixes-left = $(object-suffixes-for-libc)
865 include $(o-iterator)
868 # This makes all the object files.
869 .PHONY: objects objs libobjs extra-objs
870 objects objs: libobjs extra-objs
871 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
872 extra-objs: $(addprefix $(objpfx),$(extra-objs))
874 # Canned sequence for building an extra library archive.
875 define build-extra-lib
876 $(patsubst %/,cd % &&,$(objpfx)) \
877 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
878 $(patsubst $(objpfx)%,%,$^)
883 .PHONY: force-install
886 # $(install-lib) are installed from the object directory into $(libdir);
887 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
888 # unless they also appear in $(non-lib.a). $(install-data) are installed as
889 # they are into $(datadir). $(headers) are installed as they are in
890 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
891 # are installed from the object directory into $(bindir), $(bindir) and
892 # $(sbindir), respectively. $(install-others) and $(install-others-programs)
893 # are absolute path names of files to install; rules to install them are
896 # The simple library name to install libc.a under.
897 # This could be defined by a sysdep Makefile.
903 $(make-target-directory)
904 $(INSTALL_DATA) $< $@
907 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
908 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
909 define make-target-directory
910 $(addprefix $(..)./scripts/mkinstalldirs ,\
911 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
914 # Any directory (parent or subdir) should install libc.a; this way
915 # "make install" in a subdir is guaranteed to install everything it changes.
916 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
917 $(inst_libdir)/$(patsubst %,$(libtype$o),\
918 $(libprefix)$(libc-name)))
920 .PHONY: check-install-supported
921 check-install-supported:
923 # Check to see if the prefix or exec_prefix GNU standard variable
924 # has been overridden on the command line and, if so, fail with
925 # an error message since doing so is not supported (set DESTDIR
927 ifeq ($(origin prefix),command line)
928 check-install-supported:
929 $(error Overriding prefix is not supported. Set DESTDIR instead.)
932 ifeq ($(origin exec_prefix),command line)
933 check-install-supported:
934 $(error Overriding exec_prefix is not supported. Set DESTDIR instead.)
937 install: check-install-supported
939 install: $(installed-libcs)
940 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
941 $(make-target-directory)
942 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
944 define do-install-program
945 $(make-target-directory)
946 $(INSTALL_PROGRAM) $< $@.new
950 define do-install-script
951 $(make-target-directory)
952 $(INSTALL_SCRIPT) $< $@.new
956 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
957 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
959 ifeq (yes,$(build-shared))
960 # Find which .so's have versions.
961 versioned := $(strip $(foreach so,$(install-lib.so),\
962 $(patsubst %,$(so),$($(so)-version))))
964 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
965 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
967 # For versioned libraries, we install three files:
968 # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
969 # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
970 # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
971 lib-version := $(firstword $($(subdir)-version) $(version))
972 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
973 $(foreach L,$(install-lib.so-versioned),\
975 $(inst_slibdir)/$(L:.so=)-$(lib-version).so \
976 $(inst_slibdir)/$L$($L-version))
978 # Install all the unversioned shared libraries.
979 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
980 $(objpfx)%.so $(+force)
981 $(do-install-program)
983 ifneq ($(findstring -s,$(LN_S)),)
986 $(SHELL) $(..)scripts/rellns-sh $< $@.new
990 # If we have no symbolic links don't bother with rellns-sh.
998 ifeq (yes,$(build-shared))
999 ifeq (no,$(cross-compiling))
1000 symbolic-link-prog := $(elf-objpfx)sln
1001 symbolic-link-list := $(elf-objpfx)symlink.list
1002 define make-shlib-link
1003 echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
1005 else # cross-compiling
1006 # We need a definition that can be used by elf/Makefile's install rules.
1007 symbolic-link-prog = $(LN_S)
1010 ifndef make-shlib-link
1011 define make-shlib-link
1013 $(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
1017 ifdef libc.so-version
1018 # For a library specified to be version N, install three files:
1019 # libc.so -> libc.so.N (e.g. libc.so.6)
1020 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
1022 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
1025 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
1026 $(do-install-program)
1027 install: $(inst_slibdir)/libc.so$(libc.so-version)
1029 # This fragment of linker script gives the OUTPUT_FORMAT statement
1030 # for the configuration we are building. We put this statement into
1031 # the linker scripts we install for -lc et al so that they will not be
1032 # used by a link for a different format on a multi-architecture system.
1033 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
1034 $(common-objpfx)config.make \
1035 $(common-objpfx)config.h $(..)Makerules
1036 ifneq (unknown,$(output-format))
1037 echo > $@.new 'OUTPUT_FORMAT($(output-format))'
1039 $(LINK.o) -shared $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
1040 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
1041 | sed -n -f $< > $@.new
1046 common-generated += format.lds
1049 # What we install as libc.so for programs to link against is in fact a
1050 # link script. It contains references for the various libraries we need.
1051 # The libc.so object is not complete since some functions are only defined
1052 # in libc_nonshared.a.
1053 # We need to use absolute paths since otherwise local copies (if they exist)
1054 # of the files are taken by the linker.
1055 install: $(inst_libdir)/libc.so
1056 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
1057 $(common-objpfx)libc.so$(libc.so-version) \
1058 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
1059 $(libprefix)$(libc-name)) \
1061 (echo '/* GNU ld script';\
1062 echo ' Use the shared library, but some functions are only in';\
1063 echo ' the static library, so try that secondarily. */';\
1065 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
1066 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
1067 ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \
1074 install: $(inst_slibdir)/libc.so
1075 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
1076 $(do-install-program)
1079 ifneq (,$(versioned))
1080 # Produce three sets of rules as above for all the smaller versioned libraries.
1082 define o-iterator-doit
1083 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
1085 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
1086 ifneq (,$(object-suffixes-left))
1087 include $(o-iterator)
1090 # Make symlinks in the build directory, because the versioned names might
1091 # be referenced by a DT_NEEDED in another library.
1092 define o-iterator-doit
1093 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
1095 object-suffixes-left := $(versioned)
1096 include $(o-iterator)
1098 generated += $(foreach o,$(versioned),$o$($o-version))
1100 ifeq (,$($(subdir)-version))
1101 define o-iterator-doit
1102 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
1106 object-suffixes-left := $(versioned)
1107 include $(o-iterator)
1109 define o-iterator-doit
1110 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
1111 $$(do-install-program)
1113 object-suffixes-left := $(versioned)
1114 include $(o-iterator)
1116 define o-iterator-doit
1117 $(inst_slibdir)/$o$($o-version): \
1118 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1121 object-suffixes-left := $(versioned)
1122 include $(o-iterator)
1124 define o-iterator-doit
1125 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1126 $$(do-install-program)
1128 object-suffixes-left := $(versioned)
1129 include $(o-iterator)
1133 define do-install-so
1134 $(do-install-program)
1135 $(patsubst %,$(LN_S) -f $(@F) \
1136 $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1137 $(filter-out %.so,$@))
1140 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1141 $(foreach v,$(so-versions),\
1142 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1145 $(foreach v,$(so-versions),\
1146 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1151 $(addprefix $(inst_bindir)/,$(install-bin)): \
1152 $(inst_bindir)/%: $(objpfx)% $(+force)
1153 $(do-install-program)
1155 ifdef install-bin-script
1156 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1157 $(inst_bindir)/%: $(objpfx)% $(+force)
1158 $(do-install-script)
1160 ifdef install-rootsbin
1161 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1162 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1163 $(do-install-program)
1166 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1167 $(inst_sbindir)/%: $(objpfx)% $(+force)
1168 $(do-install-program)
1171 install-lib.a := $(filter lib%.a,$(install-lib))
1172 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1173 ifdef install-lib-non.a
1174 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1175 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1179 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1180 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1185 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1188 headers := $(strip $(headers))
1190 # This implicit rule installs headers from the source directory.
1191 # It may be ignored in preference to rules from sysd-rules to find
1192 # headers in the sysdeps tree.
1193 $(inst_includedir)/%.h: $(objpfx)%.h $(+force)
1195 $(inst_includedir)/%.h: $(common-objpfx)%.h $(+force)
1197 $(inst_includedir)/%.h: %.h $(+force)
1199 $(inst_includedir)/%.h: $(..)include/%.h $(+force)
1201 headers-nonh := $(filter-out %.h,$(headers))
1203 $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
1206 endif # headers-nonh
1209 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1210 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1211 install-data-nosubdir install-headers-nosubdir
1212 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1213 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1214 install-rootsbin-nosubdir: \
1215 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1216 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1217 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1218 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1219 $(addprefix $(libprefix),$(install-lib-non.a)))
1220 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1221 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1222 install-others-nosubdir: $(install-others)
1223 install-others-programs-nosubdir: $(install-others-programs)
1225 # We need all the `-nosubdir' targets so that `install' in the parent
1226 # doesn't depend on several things which each iterate over the subdirs.
1227 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1228 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1229 install-%:: install-%-nosubdir ;
1231 .PHONY: install install-no-libc.a-nosubdir
1232 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
1233 install-lib-nosubdir install-others-nosubdir
1234 ifeq ($(build-programs),yes)
1235 install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
1236 install-rootsbin-nosubdir install-sbin-nosubdir \
1237 install-others-programs-nosubdir
1239 install: install-no-libc.a-nosubdir
1241 # Command to compile $< using the native libraries.
1242 define native-compile
1243 $(make-target-directory)
1244 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1245 $< $(OUTPUT_OPTION) $(BUILD_LDFLAGS)
1248 # We always want to use configuration definitions.
1249 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -D_GNU_SOURCE \
1250 -DIS_IN_build -include $(common-objpfx)config.h
1252 # Support the GNU standard name for this target.
1255 # Special target to run tests which cannot be run unconditionally.
1256 # Maintainers should use this target.
1260 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1261 ifneq (,$(all-nonlib))
1262 cpp-srcs-left = $(all-nonlib)
1264 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
1268 ifeq ($(build-shared),yes)
1269 # Generate normalized lists of symbols, versions, and data sizes.
1270 # This is handy for checking against existing library binaries.
1272 %.symlist: $(..)scripts/abilist.awk %.dynsym
1273 LC_ALL=C $(AWK) -f $^ > $@T
1277 LC_ALL=C $(OBJDUMP) --dynamic-syms $< > $@T
1280 # A sysdeps/.../Makefile can set abilist-pattern to something like
1281 # %-foo.abilist to look for libc-foo.abilist instead of libc.abilist.
1282 # This makes sense if multiple ABIs can be most cleanly supported by a
1283 # configuration without using separate sysdeps directories for each.
1284 ifdef abilist-pattern
1285 vpath $(abilist-pattern) $(+sysdep_dirs)
1288 vpath %.abilist $(+sysdep_dirs)
1290 # The .PRECIOUS rule prevents the files built by an implicit rule whose
1291 # target pattern is %.symlist from being considered "intermediate files"
1292 # and automatically removed. We only want these files to be removed by
1293 # 'make clean', which is handled by the 'generated' variable.
1294 .PRECIOUS: %.symlist
1295 generated += $(extra-libs:=.symlist)
1297 ifdef abilist-pattern
1298 $(objpfx)check-abi-%.out: $(common-objpfx)config.make $(abilist-pattern) \
1300 $(check-abi-pattern); \
1302 $(objpfx)check-abi-%.out: $(common-objpfx)config.make $(abilist-pattern) \
1303 $(common-objpfx)%.symlist
1304 $(check-abi-pattern); \
1307 $(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
1311 $(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
1312 $(common-objpfx)%.symlist
1315 define check-abi-pattern
1316 diff -p -U 0 $(filter $(abilist-pattern),$^) $(filter %.symlist,$^) \
1320 diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^) > $@
1323 ifdef abilist-pattern
1324 update-abi-%: $(objpfx)%.symlist $(abilist-pattern)
1325 $(update-abi-pattern)
1326 update-abi-%: $(common-objpfx)%.symlist $(abilist-pattern)
1327 $(update-abi-pattern)
1329 update-abi-%: $(objpfx)%.symlist %.abilist
1331 update-abi-%: $(common-objpfx)%.symlist %.abilist
1333 define update-abi-pattern
1334 @if cmp -s $^ 2> /dev/null; \
1336 echo '+++ $(filter $(abilist-pattern),$^) is unchanged'; \
1338 echo '*** Now check $(filter $(abilist-pattern),$^) changes for correctness ***'; \
1342 @if cmp -s $^ 2> /dev/null; \
1344 echo '+++ $(filter %.abilist,$^) is unchanged'; \
1346 echo '*** Now check $(filter %.abilist,$^) changes for correctness ***'; \
1350 .PHONY: update-abi check-abi
1351 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1352 check-abi-list = $(patsubst %.so,$(objpfx)check-abi-%.out, \
1353 $(install-lib.so-versioned))
1354 check-abi: $(check-abi-list)
1356 subdir_check-abi: check-abi
1357 subdir_update-abi: update-abi
1359 check-abi: subdir_check-abi
1360 if grep -q '^FAIL:' $(objpfx)*/check-abi*.test-result; then \
1361 cat $(objpfx)*/check-abi*.out && exit 1; fi
1362 update-abi: subdir_update-abi
1365 ifeq ($(subdir),elf)
1366 check-abi: $(objpfx)check-abi-libc.out
1367 tests-special += $(objpfx)check-abi-libc.out
1368 update-abi: update-abi-libc
1369 common-generated += libc.symlist
1372 ifeq ($(build-shared),yes)
1374 tests-special += $(check-abi-list)
1380 # These will have been set by sysdeps/posix/Makefile.
1386 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1388 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1389 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1390 $(common-objpfx)config.make
1391 $(make-target-directory)
1392 { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
1393 echo '#define _LIBC 1'; \
1394 echo '#include "$(..)misc/sys/uio.h"'; } | \
1395 $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
1396 $(CPPUNDEFS) $(+includes) -xc - -o $(@:st=hT)
1397 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
1398 $(@:st=dT) > $(@:st=dt)
1399 mv -f $(@:st=dt) $(@:st=d)
1400 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
1401 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
1402 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
1403 fopen_max=$${fopen_max:-16}; \
1404 filename_max=$${filename_max:-1024}; \
1405 if [ -z "$$iov_max" ]; then \
1406 define_iov_max="# undef IOV_MAX"; \
1408 define_iov_max="# define IOV_MAX $$iov_max"; \
1410 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
1411 -e "s/@FILENAME_MAX@/$$filename_max/" \
1412 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
1413 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
1414 -e "s/@L_ctermid@/$(L_ctermid)/" \
1415 -e "s/@L_cuserid@/$(L_cuserid)/" \
1416 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
1418 $(move-if-change) $(@:st=h.new) $(@:st=h)
1419 # Remove these last so that they can be examined if something went wrong.
1420 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1424 -include $(stdio_lim:h=d)
1426 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1430 .PHONY: echo-headers
1434 %.bz2: %; bzip2 -9vk $<
1435 %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
1436 %.xz: %; xz -9evk $<
1438 # Common cleaning targets.
1440 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1442 mostlyclean: common-mostlyclean
1445 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1447 $(addsuffix .test-result,$(tests) \
1451 # Remove the object files.
1453 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1454 $(others) $(sysdep-others) stubs \
1455 $(addsuffix .o,$(tests) $(xtests) \
1456 $(test-srcs) $(others) \
1458 $(addsuffix .out,$(tests) $(xtests) \
1460 $(addsuffix .test-result,$(tests) \
1463 -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
1464 $(install-lib) $(install-lib.so) \
1465 $(install-lib.so:%.so=%_pic.a))
1467 -rm -f $(objpfx)rtld-*.os
1470 $(foreach o,$(object-suffixes-for-libc),
1471 -rm -f $(objpfx)stamp$o $(o-objects))
1474 # Also remove the dependencies and generated source files.
1475 common-clean: common-mostlyclean
1476 -rm -f $(addprefix $(objpfx),$(generated))
1477 -rm -f $(objpfx)*.d $(objpfx)*.dt
1478 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1479 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1480 -rm -f $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
1482 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1483 # for each function which is a stub.
1486 .PHONY: stubs # The parent Makefile calls this target.
1487 stubs: $(objpfx)stubs
1489 objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
1490 $(addprefix $(objpfx),$(extra-objs))
1491 $(objpfx)stubs: $(objs-for-stubs)
1492 ifneq (,$(strip $(objs-for-stubs)))
1493 (cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
1494 $(AWK) '/\.gnu\.glibc-stub\./ { \
1495 sub(/\.gnu\.glibc-stub\./, "", $$2); \
1497 END { for (s in stubs) print "#define __stub_" s }' > $@T
1503 ifneq (,$(strip $(gpl2lgpl)))
1504 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1505 # Snarf from the master source and frob the copying notice.
1506 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1508 # So I don't edit them by mistake.