1 # Copyright (C) 1991-2006, 2007, 2008 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, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 # Common rules for making the GNU C library. This file is included
21 # by the top-level Makefile and by all subdirectory makefiles
25 This makefile requires GNU Make.
28 REQUIRED_MAKE_VERSION = 3.74
29 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
31 ifneq ($(REQUIRED_MAKE_VERSION), \
32 $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION))))
33 Wrong GNU Make version. See above for the version needed.
41 # If `sources' was defined by the parent makefile, undefine it so
42 # we will later get it from wildcard search in this directory.
43 ifneq "$(findstring env,$(origin sources))" ""
48 PATH := this definition should take precedence over $(oPATH)
49 ifeq ($(PATH),$(oPATH))
50 You must not use the -e flag when building the GNU C library.
55 ifndef +included-Makeconfig
56 include $(..)Makeconfig
59 # This variable is used in ``include $(o-iterator)'' after defining
60 # $(o-iterator-doit) to produce some desired rule using $o for the object
61 # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
62 # is produced for each object suffix in use.
63 o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
65 # Include any system-specific makefiles.
67 # This is here so things in sysdep Makefiles can easily depend on foo.h as
68 # appropriate and not worry about where foo.h comes from, which may be
69 # system dependent and not known by that Makefile.
70 vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
71 $(+sysdep_dirs) $(..)))
73 # The same is true for RPC source files.
74 vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
75 $(+sysdep_dirs) $(..)))
77 # Some sysdep makefiles use this to distinguish being included here from
78 # being included individually by a subdir makefile (hurd/Makefile needs this).
81 sysdep-makefiles := $(wildcard $(sysdirs:=/Makefile))
82 ifneq (,$(sysdep-makefiles))
83 include $(sysdep-makefiles)
87 # Reorder before-compile so that mach things come first, and hurd things
88 # second, before all else. The mach and hurd subdirectories have many
89 # generated header files which the much of rest of the library depends on,
90 # so it is best to build them first (and mach before hurd, at that).
91 before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
93 $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
96 # Even before that, we need abi-versions.h which is generated right here.
97 ifeq ($(versioning),yes)
98 ifndef avoid-generated
99 before-compile := $(common-objpfx)abi-versions.h $(before-compile)
100 $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
101 $(common-objpfx)Versions.all
102 LC_ALL=C $(AWK) -v oldest_abi=$(oldest-abi) -f $^ > $@T
105 $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
106 sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
107 $(common-objpfx)abi-versions.h > $@T
109 endif # avoid-generated
110 endif # $(versioning) = yes
112 # Make sure the subdirectory for object files gets created.
114 ifeq (,$(wildcard $(objpfx).))
115 before-compile += $(objpfx).
117 $(make-target-directory)
121 # Remove existing files from `before-compile'. Things are added there when
122 # they must exist for dependency generation to work right, but once they
123 # exist there is no further need for every single file to depend on them,
124 # and those gratuitous dependencies result in many gratuitous
126 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
128 # Don't let any before-compile file be an intermediate and get removed.
133 # We don't want $(common-objpfx) files to depend on miscellaneous stuff
136 common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
138 common-before-compile = $(before-compile)
142 # If a makefile needs to do something conditional on something that
143 # can only be figured out from headers, write a FOO.make.c input
144 # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
145 # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
147 # We only generate these in the top-level makefile, to avoid any weirdness
148 # from subdir-specific makefile tweaks creeping in on an update.
149 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
151 (echo '# Generated from $*.make.c by Makerules.'; \
152 $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
153 -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
154 | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \
155 echo 'common-generated += $(@F)'; \
156 sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
162 sed-remove-dotdot := -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' \
163 -e 's@^\.\.\/\([^ \]*\)@$$(..)\1@g'
165 sed-remove-dotdot := -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' \
166 -e 's@^\([^ \/$$][^ \]*\)@$$(..)\1@g'
170 ifdef gen-as-const-headers
171 # Generating headers for assembly constants.
172 # We need this defined early to get into before-compile before
173 # it's used in sysd-rules, below.
174 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
175 %.sym $(common-before-compile)
176 $(AWK) -f $< $(filter %.sym,$^) \
177 | $(CC) -S -o $(@:.h.d=.h)T3 $(CFLAGS) $(CPPFLAGS) -x c - \
178 -MD -MP -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)'
179 sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' \
180 $(@:.h.d=.h)T3 > $(@:.h.d=.h)T
182 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
183 $(@:.h=.h.d)T > $(@:.h=.h.d)T2
185 mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
186 mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
187 vpath %.sym $(sysdirs)
188 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
190 tests += $(gen-as-const-headers:%.sym=test-as-const-%)
191 generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
192 $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \
193 %.sym $(common-objpfx)%.h
194 ($(AWK) '{ sub(/^/, "asconst_", $$2); print; }' $(filter %.h,$^); \
195 $(AWK) -v test=1 -f $< $(filter %.sym,$^); \
196 echo '#include "$(..)test-skeleton.c"') > $@T
200 # Generate an ordered list of implicit rules which find the source files in
201 # each sysdep directory. The old method was to use vpath to search all the
202 # sysdep directories. However, that had the problem that a .S file in a
203 # later directory would be chosen over a .c file in an earlier directory,
204 # which does not preserve the desired sysdeps ordering behavior.
206 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
207 # patterns matching sysdep directories whose assembly source files should
209 ifdef inhibit-sysdep-asm
210 define check-inhibit-asm
211 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) asm= ;; esac;
215 -include $(common-objpfx)sysd-rules
216 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
217 # The value of $(+sysdep_dirs) the sysd-rules was computed for
218 # differs from the one we are using now. So force a rebuild of sysd-rules.
219 sysd-rules-force = FORCE
222 $(common-objpfx)sysd-rules: $(common-objpfx)config.make $(..)Makerules \
223 $(sysdep-makefiles) $(sysdep-makeconfigs) \
226 (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \
227 for dir in $(config-sysdirs); do \
230 *) dir="\$$(..)$$dir" ;; \
233 $(check-inhibit-asm) \
234 for o in $(all-object-suffixes); do \
235 set $(subst :, ,$(sysd-rules-patterns)); \
236 while [ $$# -ge 2 ]; do \
239 v=$${t%%%}; [ x"$$v" = x ] || v="\$$($${v}CPPFLAGS)"; \
240 for s in $$asm .c; do \
241 echo "\$$(objpfx)$$t$$o: $$dir/$$d$$s \$$(before-compile)"; \
242 echo " \$$(compile-command$$s) $$v"; \
246 echo "\$$(inst_includedir)/%.h: $$dir/%.h \$$(+force)"; \
247 echo " \$$(do-install)"; \
249 echo 'sysd-rules-done = t') > $@T
252 ifndef sysd-rules-done
253 # Don't do deps until this exists, because it provides rules to make the deps.
257 define o-iterator-doit
258 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
260 object-suffixes-left := $(all-object-suffixes)
261 include $(o-iterator)
263 define o-iterator-doit
264 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
266 object-suffixes-left := $(all-object-suffixes)
267 include $(o-iterator)
269 define o-iterator-doit
270 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
272 object-suffixes-left := $(all-object-suffixes)
273 include $(o-iterator)
275 define o-iterator-doit
276 $(objpfx)%$o: %.cc $(before-compile); $$(compile-command.cc)
278 object-suffixes-left := $(all-object-suffixes)
279 include $(o-iterator)
281 # Omit the objpfx rules when building in the source tree, because
282 # objpfx is empty and so these rules just override the ones above.
284 # Define first rules to find the source files in $(objpfx).
285 # Generated source files will end up there.
286 define o-iterator-doit
287 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
289 object-suffixes-left := $(all-object-suffixes)
290 include $(o-iterator)
292 define o-iterator-doit
293 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
295 object-suffixes-left := $(all-object-suffixes)
296 include $(o-iterator)
298 define o-iterator-doit
299 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
301 object-suffixes-left := $(all-object-suffixes)
302 include $(o-iterator)
305 # Generate version maps, but wait until sysdep-subdirs is known
306 ifeq ($(sysd-sorted-done),t)
307 ifeq ($(versioning),yes)
308 -include $(common-objpfx)sysd-versions
309 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
310 common-generated += $(version-maps)
311 postclean-generated += sysd-versions Versions.all abi-versions.h \
312 Versions.def.v.i Versions.def.v Versions.v.i Versions.v
314 ifndef avoid-generated
315 ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
316 sysd-versions-force = FORCE
319 # See %.v/%.v.i implicit rules in Makeconfig.
320 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
321 $(wildcard $(add-ons:%=$(..)%/Versions.def))
322 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
323 $(common-objpfx)soversions.i \
324 $(common-objpfx)Versions.def.v
325 { while read which lib version setname; do \
326 test x"$$which" = xDEFAULT || continue; \
327 test -z "$$setname" || echo "$$lib : $$setname"; \
328 done < $(word 2,$^); \
330 } | LC_ALL=C $(AWK) -f $< > $@T
332 # See %.v/%.v.i implicit rules in Makeconfig.
333 $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
334 $(wildcard $(sysdirs:%=%/Versions)) \
335 $(common-objpfx)abi-versions.h \
336 $(sysd-versions-force)
337 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
338 $(common-objpfx)Versions.v \
339 $(..)scripts/versions.awk
340 ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
342 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
343 -v move_if_change='$(move-if-change)' \
347 endif # avoid-generated
348 endif # $(versioning) = yes
349 endif # sysd-sorted-done
351 # Generate .dT files as we compile.
352 compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
353 compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
354 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) $(compile-mkdep-flags)
355 compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
356 compile-command.cc = $(compile.cc) $(OUTPUT_OPTION) $(compile-mkdep-flags)
358 # GCC can grok options after the file name, and it looks nicer that way.
359 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
360 compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
361 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
362 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
363 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
364 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
365 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
367 # We need this for the output to go in the right place. It will default to
368 # empty if make was configured to work with a cc that can't grok -c and -o
369 # together. You can't compile the C library with such a compiler.
370 OUTPUT_OPTION = -o $@
372 # We need the $(CFLAGS) to be in there to have the right predefines during
373 # the dependency run for C sources. But having it for assembly sources can
374 # get the wrong predefines.
375 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
378 $(make-target-directory)
379 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
380 $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
381 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
382 $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
383 mv -f $(@:.d=.T) $@ $(generate-md5)
387 # Continuation lines here are dangerous because they introduce spaces!
388 define sed-remove-objpfx
389 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
390 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
394 # Modify the list of routines we build for different targets
396 ifeq (yesyes,$(build-shared)$(elf))
397 ifndef libc.so-version
398 # Undefine this because it can't work when we libc.so is unversioned.
399 static-only-routines =
403 # Bounded pointer thunks are only built for *.ob
404 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
406 elide-routines.oS += $(filter-out $(static-only-routines),\
407 $(routines) $(aux) $(sysdep_routines)) \
409 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
411 # If we have versioned code we don't need the old versions in any of the
413 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
414 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
415 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
416 elide-routines.ob += $(shared-only-routines)
418 # Shared library building.
420 ifeq (yes,$(build-shared))
422 # Reference map file only when versioning is selected and a map file name
424 ifeq ($(versioning),yes)
425 map-file = $(firstword $($(@F:.so=-map)) \
426 $(addprefix $(common-objpfx), \
427 $(filter $(@F:.so=.map),$(version-maps))))
428 load-map-file = $(map-file:%=-Wl,--version-script=%)
431 # Pattern rule to build a shared object from an archive of PIC objects.
432 # This must come after the installation rules so Make doesn't try to
433 # build shared libraries in place from the installed *_pic.a files.
434 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
435 # on other shared objects.
436 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
437 ifneq (,$(findstring aix,$(config-os)))
439 dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
444 define build-shlib-helper
445 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
446 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(config-LDFLAGS) \
447 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
448 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
449 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
450 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
451 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
454 ifneq (,$(findstring aix,$(config-os)))
455 define build-shlib-helper
456 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
457 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
458 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
459 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
460 -L$(subst :, -L,$(rpath-link))
467 # binutils only position loadable notes into the first page for binaries,
468 # not for shared objects
469 $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
470 $(LINK.o) -shared -Wl,-O1 \
471 -nostdlib -nostartfiles \
472 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
473 -Wl,--verbose 2>&1 | \
475 -e '/^=========/,/^=========/!d;/^=========/d' \
476 $(if $(filter yes,$(have-hash-style)), \
477 -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
478 -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
479 -e '/DATA_SEGMENT_ALIGN/{H;g}' \
481 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
483 -e 's/^.*\*(\.dynbss).*$$/& \
484 PROVIDE(__start___libc_freeres_ptrs = .); \
485 *(__libc_freeres_ptrs) \
486 PROVIDE(__stop___libc_freeres_ptrs = .);/'\
487 -e 's@^.*\*(\.jcr).*$$@& \
488 PROVIDE(__start___libc_subfreeres = .);\
489 __libc_subfreeres : { *(__libc_subfreeres) }\
490 PROVIDE(__stop___libc_subfreeres = .);\
491 PROVIDE(__start___libc_atexit = .);\
492 __libc_atexit : { *(__libc_atexit) }\
493 PROVIDE(__stop___libc_atexit = .);\
494 PROVIDE(__start___libc_thread_subfreeres = .);\
495 __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
496 PROVIDE(__stop___libc_thread_subfreeres = .);\
497 /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
499 common-generated += shlib.lds
502 # -T $(common-objpfx)shlib.lds
503 $(build-shlib-helper) -o $@ \
504 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
507 ifneq (,$(findstring aix,$(config-os)))
509 $(build-shlib-helper) \
511 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
512 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
515 $(build-shlib-helper) \
516 $(build-shlib-objlist)
521 ifneq (,$(findstring aix,$(config-os)))
522 define build-module-helper
523 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
524 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
526 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
527 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
530 define build-module-helper
531 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
532 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
533 -B$(csu-objpfx) $(load-map-file) \
534 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
535 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
539 # This macro is similar to build-shlib but it does not define a soname
540 # and it does not depend on the destination name to start with `lib'.
542 # binutils only position loadable notes into the first page for binaries,
543 # not for shared objects
545 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
546 $(csu-objpfx)abi-note.o $(build-module-objlist)
548 define build-module-asneeded
549 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
550 $(csu-objpfx)abi-note.o \
551 -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
554 ifneq (,$(findstring aix,$(config-os)))
556 $(build-module-helper) \
558 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
559 $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
564 $(build-module-helper) \
566 $(build-module-objlist)
571 build-module-helper-objlist = \
572 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
573 $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^))
574 whole-archive := -Wl,--whole-archive
576 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
577 build-shlib-objlist = $(build-module-helper-objlist) \
578 $(LDLIBS-$(@F:lib%.so=%).so)
580 # Don't try to use -lc when making libc.so itself.
581 # Also omits crti.o and crtn.o, which we do not want
582 # since we define our own `.init' section specially.
583 LDFLAGS-c.so = -nostdlib -nostartfiles
584 # But we still want to link libc.so against $(libc.so-gnulib).
585 LDLIBS-c.so += $(libc.so-gnulib)
586 # Give libc.so an entry point and make it directly runnable itself.
587 LDFLAGS-c.so += -e __libc_main
588 # If lazy relocation is disabled add the -z now flag.
589 ifeq ($(bind-now),yes)
590 LDFLAGS-c.so += -Wl,-z,now
592 # Pre-link the objects of libc_pic.a so that we can locally resolve
593 # COMMON symbols before we link against ld.so. This is because ld.so
594 # contains some of libc_pic.a already, which will prevent the COMMONs
595 # from being allocated in libc.so, which introduces evil dependencies
596 # between libc.so and ld.so, which can make it impossible to upgrade.
598 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
599 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
600 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
601 # Use our own special initializer and finalizer files for libc.so.
602 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
603 $(common-objpfx)libc_pic.os \
604 $(elfobjdir)/sofini.os \
605 $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
606 $(common-objpfx)shlib.lds
608 ifeq ($(versioning),yes)
609 $(common-objpfx)libc.so: $(common-objpfx)libc.map
611 common-generated += libc.so libc_pic.os
612 ifdef libc.so-version
613 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
615 common-generated += libc.so$(libc.so-version)
619 ifneq (,$(findstring aix,$(config-os)))
620 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
623 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
624 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
625 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
626 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
627 -bE:$(common-objpfx)syscalls.exp \
628 -bI:$(common-objpfx)syscalls.exp \
629 -L$(common-objpfx) -o $@ $^
630 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
631 cp $@ $(common-objpfx)shr.o
632 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
636 # Figure out the source filenames in this directory.
638 override sources := $(addsuffix .c,\
639 $(filter-out $(elided-routines),\
642 sysdep_routines := $(sysdep_routines)
644 headers := $(headers) $(sysdep_headers)
646 # This is the list of all object files, gotten by
647 # replacing every ".c" in `sources' with a ".o".
648 # We also add bounded-pointer thunks, which are later
649 # elided for all suffixes except for `.ob'.
650 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
651 $(patsubst %,$(bppfx)%.o,\
652 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
655 # The makefile may define $(extra-libs) with `libfoo libbar'
656 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
658 # extra-lib.mk is included once for each extra lib to define rules
659 # to build it, and to add its objects to the various variables.
660 # During its evaluation, $(lib) is set to the name of the library.
661 extra-libs-left := $(extra-libs)
662 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
666 # The makefile may define $(modules-names) to build additional modules.
667 # These are built with $(build-module), except any in $(modules-names-nobuild).
669 # extra-lib.mk is included once for each extra lib to define rules
670 # to build it, and to add its objects to the various variables.
671 # During its evaluation, $(lib) is set to the name of the library.
672 extra-modules-left := $(modules-names)
673 include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
675 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
676 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
677 $(objpfx)%.os $(common-objpfx)shlib.lds \
678 $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
682 +depfiles := $(sources:.c=.d) \
683 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
684 $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
685 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
686 ifeq ($(build-programs),yes)
687 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
689 +depfiles := $(addprefix $(objpfx),\
690 $(filter-out $(addsuffix .d,$(omit-deps)),\
692 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
693 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
694 $(wildcard $(all-dt-files:.dt=.d))
696 # This is a funny rule in that it removes its input file.
698 @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
699 mv -f $(@:.d=.T) $@ && \
702 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
703 # They will be generated when they're needed, and trying too early won't work.
704 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
705 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
710 -include $(+depfiles)
714 # Maximize efficiency by minimizing the number of rules.
715 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
716 # Don't define any builtin rules.
717 MAKEFLAGS := $(MAKEFLAGS)r
719 # Generic rule for making directories.
721 # mkdir isn't smart enough to strip a trailing /.
722 # We always require a mkdir which supports the -p option to avoid error
723 # messages in case of races.
726 # Make sure that object files are not removed
727 # when they are intermediates between sources and library members.
728 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
730 # Make sure that the parent library archive is never removed.
731 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
733 # Use the verbose option of ar and tar when not running silently.
734 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
740 ARFLAGS := r$(verbose)
741 CREATE_ARFLAGS := cru$(verbose)
743 # This makes all the object files in the parent library archive.
745 .PHONY: lib lib-noranlib
746 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
747 lib-noranlib: libobjs
749 # For object-suffix $o, the list of objects with that suffix.
750 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
751 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
752 $(elide-routines$o)),\
754 $(addprefix $(objpfx),$(o-objects$o))
756 others: $(addprefix $(objpfx),$(install-lib))
760 # Create the stamp$o files to keep the parent makefile happy.
761 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
762 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
763 $(make-target-directory)
767 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
768 # timestamp file; these rules (one explicit rule is generated for each
769 # object suffix) write a list of objects to update in the stamp file.
770 # The parent will then actually add them all to the archive in the
771 # archive rule, below.
772 define o-iterator-doit
773 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
776 $(make-target-directory)
777 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
780 object-suffixes-left := $(object-suffixes-for-libc)
781 include $(o-iterator)
785 # Now define explicit rules to build the library archives; these depend
786 # on the stamp files built above.
787 define o-iterator-doit
788 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
789 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
792 cd $(common-objdir) && \
793 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
796 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
797 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
799 $(subdirs-stamps): subdir_lib;
801 object-suffixes-left = $(object-suffixes-for-libc)
802 include $(o-iterator)
805 # This makes all the object files.
806 .PHONY: objects objs libobjs extra-objs
807 objects objs: libobjs extra-objs
808 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
809 extra-objs: $(addprefix $(objpfx),$(extra-objs))
811 # Canned sequence for building an extra library archive.
812 define build-extra-lib
813 $(patsubst %/,cd % &&,$(objpfx)) \
814 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
815 $(patsubst $(objpfx)%,%,$^)
821 .PHONY: force-install
824 # $(install-lib) are installed from the object directory into $(libdir);
825 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
826 # unless they also appear in $(non-lib.a). $(install-data) are installed as
827 # they are into $(datadir). $(headers) are installed as they are in
828 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
829 # are installed from the object directory into $(bindir), $(bindir) and
830 # $(sbindir), respectively. $(install-others) and $(install-others-programs)
831 # are absolute path names of files to install; rules to install them are
834 # The simple library name to install libc.a under.
835 # This could be defined by a sysdep Makefile.
841 $(make-target-directory)
842 $(INSTALL_DATA) $< $@
845 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
846 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
847 define make-target-directory
848 $(addprefix $(..)./scripts/mkinstalldirs ,\
849 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
852 # Any directory (parent or subdir) should install libc.a; this way
853 # "make install" in a subdir is guaranteed to install everything it changes.
854 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
855 $(inst_libdir)/$(patsubst %,$(libtype$o),\
856 $(libprefix)$(libc-name)))
857 install: $(installed-libcs)
858 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
859 $(make-target-directory)
860 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
861 # Running ranlib after installing makes the __.SYMDEF time stamp up to
862 # date, which avoids messages from some linkers.
865 define do-install-program
866 $(make-target-directory)
867 $(INSTALL_PROGRAM) $< $@.new
871 define do-install-script
872 $(make-target-directory)
873 $(INSTALL_SCRIPT) $< $@.new
877 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
878 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
880 ifeq (yes,$(build-shared))
881 # Find which .so's have versions.
882 versioned := $(strip $(foreach so,$(install-lib.so),\
883 $(patsubst %,$(so),$($(so)-version))))
885 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
886 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
888 # For versioned libraries, we install three files:
889 # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
890 # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
891 # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
892 V := $(firstword $($(subdir)-version) $(version))
893 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
894 $(foreach L,$(install-lib.so-versioned),\
896 $(inst_slibdir)/$(L:.so=)-$V.so \
897 $(inst_slibdir)/$L$($L-version))
899 # Install all the unversioned shared libraries.
900 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
901 $(objpfx)%.so $(+force)
902 $(do-install-program)
904 ifneq ($(findstring -s,$(LN_S)),)
907 $(SHELL) $(..)scripts/rellns-sh $< $@.new
911 # If we have no symbolic links don't bother with rellns-sh.
919 ifeq (yes,$(build-shared))
920 ifeq (no,$(cross-compiling))
921 symbolic-link-prog := $(common-objpfx)elf/sln
922 symbolic-link-list := $(common-objpfx)elf/symlink.list
923 define make-shlib-link
924 echo $(<F) $@ >> $(symbolic-link-list)
926 else # cross-compiling
927 # We need a definition that can be used by elf/Makefile's install rules.
928 symbolic-link-prog = $(LN_S)
931 ifndef make-shlib-link
932 define make-shlib-link
938 ifdef libc.so-version
939 # For a library specified to be version N, install three files:
940 # libc.so -> libc.so.N (e.g. libc.so.6)
941 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
943 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
946 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
947 $(do-install-program)
948 install: $(inst_slibdir)/libc.so$(libc.so-version)
950 # This fragment of linker script gives the OUTPUT_FORMAT statement
951 # for the configuration we are building. We put this statement into
952 # the linker scripts we install for -lc et al so that they will not be
953 # used by a link for a different format on a multi-architecture system.
954 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
955 $(common-objpfx)config.make \
956 $(common-objpfx)config.h $(..)Makerules
957 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
958 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
959 | sed -n -f $< > $@.new
962 common-generated += format.lds
965 # What we install as libc.so for programs to link against is in fact a
966 # link script. It contains references for the various libraries we need.
967 # The libc.so object is not complete since some functions are only defined
968 # in libc_nonshared.a.
969 # We need to use absolute paths since otherwise local copies (if they exist)
970 # of the files are taken by the linker.
971 install: $(inst_libdir)/libc.so
972 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
973 $(common-objpfx)libc.so$(libc.so-version) \
974 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
975 $(libprefix)$(libc-name)) \
977 (echo '/* GNU ld script';\
978 echo ' Use the shared library, but some functions are only in';\
979 echo ' the static library, so try that secondarily. */';\
981 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
982 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
983 ' AS_NEEDED (' $(slibdir)/$(rtld-installed-name) ') )' \
990 install: $(inst_slibdir)/libc.so
991 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
992 $(do-install-program)
995 ifneq (,$(versioned))
996 # Produce three sets of rules as above for all the smaller versioned libraries.
998 define o-iterator-doit
999 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
1001 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
1002 ifneq (,$(object-suffixes-left))
1003 include $(o-iterator)
1006 # Make symlinks in the build directory, because the versioned names might
1007 # be referenced by a DT_NEEDED in another library.
1008 define o-iterator-doit
1009 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
1011 object-suffixes-left := $(versioned)
1012 include $(o-iterator)
1014 generated += $(foreach o,$(versioned),$o$($o-version))
1016 ifeq (,$($(subdir)-version))
1017 define o-iterator-doit
1018 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
1022 object-suffixes-left := $(versioned)
1023 include $(o-iterator)
1025 define o-iterator-doit
1026 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
1027 $$(do-install-program)
1029 object-suffixes-left := $(versioned)
1030 include $(o-iterator)
1032 define o-iterator-doit
1033 $(inst_slibdir)/$o$($o-version): \
1034 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1037 object-suffixes-left := $(versioned)
1038 include $(o-iterator)
1040 define o-iterator-doit
1041 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1042 $$(do-install-program)
1044 object-suffixes-left := $(versioned)
1045 include $(o-iterator)
1049 define do-install-so
1050 $(do-install-program)
1051 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1052 $(filter-out %.so,$@))
1055 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1056 $(foreach v,$(so-versions),\
1057 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1060 $(foreach v,$(so-versions),\
1061 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1066 $(addprefix $(inst_bindir)/,$(install-bin)): \
1067 $(inst_bindir)/%: $(objpfx)% $(+force)
1068 $(do-install-program)
1070 ifdef install-bin-script
1071 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1072 $(inst_bindir)/%: $(objpfx)% $(+force)
1073 $(do-install-script)
1075 ifdef install-rootsbin
1076 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1077 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1078 $(do-install-program)
1081 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1082 $(inst_sbindir)/%: $(objpfx)% $(+force)
1083 $(do-install-program)
1086 install-lib.a := $(filter lib%.a,$(install-lib))
1087 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1088 ifdef install-lib-non.a
1089 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1090 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1094 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1095 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1097 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
1101 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1104 headers := $(strip $(headers))
1106 # This implicit rule installs headers from the source directory.
1107 # It may be ignored in preference to rules from sysd-rules to find
1108 # headers in the sysdeps tree.
1109 $(inst_includedir)/%.h: $(objpfx)%.h $(+force)
1111 $(inst_includedir)/%.h: %.h $(+force)
1113 $(inst_includedir)/%.h: $(..)include/%.h $(+force)
1115 headers-nonh := $(filter-out %.h,$(headers))
1117 $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
1120 endif # headers-nonh
1123 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1124 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1125 install-data-nosubdir install-headers-nosubdir
1126 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1127 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1128 install-rootsbin-nosubdir: \
1129 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1130 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1131 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1132 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1133 $(addprefix $(libprefix),$(install-lib-non.a)))
1134 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1135 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1136 install-others-nosubdir: $(install-others)
1137 install-others-programs-nosubdir: $(install-others-programs)
1139 # We need all the `-nosubdir' targets so that `install' in the parent
1140 # doesn't depend on several things which each iterate over the subdirs.
1141 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1142 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1143 install-%:: install-%-nosubdir ;
1145 .PHONY: install install-no-libc.a-nosubdir
1146 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
1147 install-lib-nosubdir install-others-nosubdir
1148 ifeq ($(build-programs),yes)
1149 install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
1150 install-rootsbin-nosubdir install-sbin-nosubdir \
1151 install-others-programs-nosubdir
1153 install: install-no-libc.a-nosubdir
1155 # Command to compile $< in $(objdir) using the native libraries.
1156 define native-compile
1157 $(make-target-directory)
1158 $(patsubst %/,cd % &&,$(objpfx)) \
1159 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1160 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1163 # Command to compile $< in $(common-objdir) using the native libraries.
1164 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1165 define common-objdir-compile
1166 $(patsubst %/,cd % &&,$(objpfx)) \
1167 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1168 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1171 # We always want to use configuration definitions.
1172 # Note that this is only used for commands running in $(objpfx).
1173 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1175 # Support the GNU standard name for this target.
1178 # Special target to run tests which cannot be run unconditionally.
1179 # Maintainers should use this target.
1183 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1184 ifneq (,$(all-nonlib))
1185 cpp-srcs-left = $(all-nonlib:=.c) $(all-nonlib:=.cc)
1187 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
1190 # The include magic above causes those files to use this variable for flags.
1191 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1194 ifeq ($(versioning),yes)
1195 # Generate normalized lists of symbols, versions, and data sizes.
1196 # This is handy for checking against existing library binaries.
1198 %.symlist: $(..)scripts/abilist.awk %.dynsym
1199 LC_ALL=C $(AWK) -f $^ > $@T
1203 $(OBJDUMP) --dynamic-syms $< > $@T
1206 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1207 $(..)abilist/%.abilist $(objpfx)%.symlist
1209 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1210 $(..)abilist/%.abilist $(common-objpfx)%.symlist
1214 $(AWK) -f $< -v 'config=$(check-abi-config)' \
1215 $(patsubst %,-v 'lastversion=%',$($*-abi-frozen)) \
1216 $(filter %.abilist,$^) \
1217 | { diff -p -U 0 - $(filter %.symlist,$^) $(check-abi-warn) ; }
1219 ifeq ($(enable-check-abi),warn)
1220 check-abi-warn = || echo '*** WARNING: $*.so failed ABI check'
1223 ifeq ($(firstword $(sysd-sorted-done) f)$(firstword $(generating) f),tf)
1224 -include $(common-objpfx)tls.make
1226 ifeq ($(use-thread),yes)
1227 config-tls := thread
1229 check-abi-config := \
1230 $(config-machine)-$(config-vendor)-$(config-os)/$(config-tls)
1233 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1236 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1237 $(common-objpfx)%.symlist
1239 ifndef update-abi-config
1241 @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2
1245 LC_ALL=C $(AWK) -v config='$(update-abi-config)' -f $^ \
1246 > $(..)abilist/$*.abilist.new
1247 @if cmp -s $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist 2> /dev/null; \
1248 then rm -f $(..)abilist/$*.abilist.new; \
1249 echo '+++ $(..)abilist/$*.abilist is unchanged'; \
1250 else mv -f $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist; \
1251 echo '*** Now check $*.abilist changes for correctness ***'; \
1256 .PHONY: update-abi check-abi
1257 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1258 check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
1260 subdir_check-abi: check-abi
1261 subdir_update-abi: update-abi
1263 check-abi: subdir_check-abi
1264 update-abi: subdir_update-abi
1267 ifeq ($(subdir),elf)
1268 check-abi: check-abi-libc
1269 update-abi: update-abi-libc
1270 common-generated += libc.symlist
1273 ifeq ($(build-shared),yes)
1274 ifneq ($(enable-check-abi),no)
1283 # These will have been set by sysdeps/posix/Makefile.
1289 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1291 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1292 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1293 $(common-objpfx)config.make
1294 $(make-target-directory)
1295 { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
1296 echo '#define _LIBC 1'; \
1297 echo '#include "$(..)misc/sys/uio.h"'; } | \
1298 $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
1299 $(+includes) -xc - -o $(@:st=hT)
1300 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
1301 $(@:st=dT) > $(@:st=dt)
1302 mv -f $(@:st=dt) $(@:st=d)
1303 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
1304 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
1305 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
1306 fopen_max=$${fopen_max:-16}; \
1307 filename_max=$${filename_max:-1024}; \
1308 if [ -z "$$iov_max" ]; then \
1309 define_iov_max="# undef IOV_MAX"; \
1311 define_iov_max="# define IOV_MAX $$iov_max"; \
1313 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
1314 -e "s/@FILENAME_MAX@/$$filename_max/" \
1315 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
1316 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
1317 -e "s/@L_ctermid@/$(L_ctermid)/" \
1318 -e "s/@L_cuserid@/$(L_cuserid)/" \
1319 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
1321 $(move-if-change) $(@:st=h.new) $(@:st=h)
1322 # Remove these last so that they can be examined if something went wrong.
1323 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1327 -include $(stdio_lim:h=d)
1329 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1333 .PHONY: echo-headers
1337 %.bz2: %; bzip2 -9vk $<
1338 %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
1340 # Common cleaning targets.
1342 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1344 mostlyclean: common-mostlyclean
1347 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1349 $(addsuffix -bp.out,$(tests) $(xtests) \
1352 # Remove the object files.
1354 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1355 $(others) $(sysdep-others) stubs \
1356 $(addsuffix .o,$(tests) $(xtests) \
1357 $(test-srcs) $(others) \
1359 $(addsuffix -bp,$(tests) $(xtests) \
1361 $(addsuffix .out,$(tests) $(xtests) \
1363 $(addsuffix -bp.out,$(tests) $(xtests) \
1365 -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
1366 $(install-lib) $(install-lib.so) \
1367 $(install-lib.so:%.so=%_pic.a))
1369 -rm -f $(objpfx)rtld-*.os
1372 $(foreach o,$(object-suffixes-for-libc),
1373 -rm -f $(objpfx)stamp$o $(o-objects))
1376 # Also remove the dependencies and generated source files.
1377 common-clean: common-mostlyclean
1378 -rm -f $(addprefix $(objpfx),$(generated))
1379 -rm -f $(objpfx)*.d $(objpfx)*.dt
1380 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1381 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1383 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1384 # for each function which is a stub. We grovel over all the .d files
1385 # looking for references to <stub-tag.h>. Then we grovel over each
1386 # referenced source file to see what stub function it defines.
1389 .PHONY: stubs # The parent Makefile calls this target.
1390 stubs: $(objpfx)stubs
1392 objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
1393 $(addprefix $(objpfx),$(extra-objs))
1394 $(objpfx)stubs: $(objs-for-stubs)
1395 ifneq (,$(strip $(objs-for-stubs)))
1396 (cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
1397 $(AWK) '/\.gnu\.glibc-stub\./ { \
1398 sub(/\.gnu\.glibc-stub\./, "", $$2); \
1400 END { for (s in stubs) print "#define __stub_" s }' > $@T
1406 ifneq (,$(strip $(gpl2lgpl)))
1407 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1408 # Snarf from the master source and frob the copying notice.
1409 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1411 # So I don't edit them by mistake.
1414 ifeq ($(with-cvs),yes)
1415 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@