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 $(build-shlib-helper) -o $@ -T $(common-objpfx)shlib.lds \
503 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
506 ifneq (,$(findstring aix,$(config-os)))
508 $(build-shlib-helper) \
510 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
511 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
514 $(build-shlib-helper) \
515 $(build-shlib-objlist)
520 ifneq (,$(findstring aix,$(config-os)))
521 define build-module-helper
522 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
523 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
525 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
526 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
529 define build-module-helper
530 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
531 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
532 -B$(csu-objpfx) $(load-map-file) \
533 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
534 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
538 # This macro is similar to build-shlib but it does not define a soname
539 # and it does not depend on the destination name to start with `lib'.
541 # binutils only position loadable notes into the first page for binaries,
542 # not for shared objects
544 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
545 $(csu-objpfx)abi-note.o $(build-module-objlist)
547 define build-module-asneeded
548 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
549 $(csu-objpfx)abi-note.o \
550 -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
553 ifneq (,$(findstring aix,$(config-os)))
555 $(build-module-helper) \
557 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
558 $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
563 $(build-module-helper) \
565 $(build-module-objlist)
570 build-module-helper-objlist = \
571 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
572 $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^))
573 whole-archive := -Wl,--whole-archive
575 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
576 build-shlib-objlist = $(build-module-helper-objlist) \
577 $(LDLIBS-$(@F:lib%.so=%).so)
579 # Don't try to use -lc when making libc.so itself.
580 # Also omits crti.o and crtn.o, which we do not want
581 # since we define our own `.init' section specially.
582 LDFLAGS-c.so = -nostdlib -nostartfiles
583 # But we still want to link libc.so against $(libc.so-gnulib).
584 LDLIBS-c.so += $(libc.so-gnulib)
585 # Give libc.so an entry point and make it directly runnable itself.
586 LDFLAGS-c.so += -e __libc_main
587 # If lazy relocation is disabled add the -z now flag.
588 ifeq ($(bind-now),yes)
589 LDFLAGS-c.so += -Wl,-z,now
591 # Pre-link the objects of libc_pic.a so that we can locally resolve
592 # COMMON symbols before we link against ld.so. This is because ld.so
593 # contains some of libc_pic.a already, which will prevent the COMMONs
594 # from being allocated in libc.so, which introduces evil dependencies
595 # between libc.so and ld.so, which can make it impossible to upgrade.
597 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
598 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
599 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
600 # Use our own special initializer and finalizer files for libc.so.
601 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
602 $(common-objpfx)libc_pic.os \
603 $(elfobjdir)/sofini.os \
604 $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
605 $(common-objpfx)shlib.lds
607 ifeq ($(versioning),yes)
608 $(common-objpfx)libc.so: $(common-objpfx)libc.map
610 common-generated += libc.so libc_pic.os
611 ifdef libc.so-version
612 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
614 common-generated += libc.so$(libc.so-version)
618 ifneq (,$(findstring aix,$(config-os)))
619 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
622 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
623 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
624 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
625 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
626 -bE:$(common-objpfx)syscalls.exp \
627 -bI:$(common-objpfx)syscalls.exp \
628 -L$(common-objpfx) -o $@ $^
629 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
630 cp $@ $(common-objpfx)shr.o
631 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
635 # Figure out the source filenames in this directory.
637 override sources := $(addsuffix .c,\
638 $(filter-out $(elided-routines),\
641 sysdep_routines := $(sysdep_routines)
643 headers := $(headers) $(sysdep_headers)
645 # This is the list of all object files, gotten by
646 # replacing every ".c" in `sources' with a ".o".
647 # We also add bounded-pointer thunks, which are later
648 # elided for all suffixes except for `.ob'.
649 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
650 $(patsubst %,$(bppfx)%.o,\
651 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
654 # The makefile may define $(extra-libs) with `libfoo libbar'
655 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
657 # extra-lib.mk is included once for each extra lib to define rules
658 # to build it, and to add its objects to the various variables.
659 # During its evaluation, $(lib) is set to the name of the library.
660 extra-libs-left := $(extra-libs)
661 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
665 # The makefile may define $(modules-names) to build additional modules.
666 # These are built with $(build-module), except any in $(modules-names-nobuild).
668 # extra-lib.mk is included once for each extra lib to define rules
669 # to build it, and to add its objects to the various variables.
670 # During its evaluation, $(lib) is set to the name of the library.
671 extra-modules-left := $(modules-names)
672 include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
674 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
675 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
676 $(objpfx)%.os $(common-objpfx)shlib.lds \
677 $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
681 +depfiles := $(sources:.c=.d) \
682 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
683 $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
684 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
685 ifeq ($(build-programs),yes)
686 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
688 +depfiles := $(addprefix $(objpfx),\
689 $(filter-out $(addsuffix .d,$(omit-deps)),\
691 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
692 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
693 $(wildcard $(all-dt-files:.dt=.d))
695 # This is a funny rule in that it removes its input file.
697 @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
698 mv -f $(@:.d=.T) $@ && \
701 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
702 # They will be generated when they're needed, and trying too early won't work.
703 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
704 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
709 -include $(+depfiles)
713 # Maximize efficiency by minimizing the number of rules.
714 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
715 # Don't define any builtin rules.
716 MAKEFLAGS := $(MAKEFLAGS)r
718 # Generic rule for making directories.
720 # mkdir isn't smart enough to strip a trailing /.
721 # We always require a mkdir which supports the -p option to avoid error
722 # messages in case of races.
725 # Make sure that object files are not removed
726 # when they are intermediates between sources and library members.
727 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
729 # Make sure that the parent library archive is never removed.
730 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
732 # Use the verbose option of ar and tar when not running silently.
733 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
739 ARFLAGS := r$(verbose)
740 CREATE_ARFLAGS := cru$(verbose)
742 # This makes all the object files in the parent library archive.
744 .PHONY: lib lib-noranlib
745 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
746 lib-noranlib: libobjs
748 # For object-suffix $o, the list of objects with that suffix.
749 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
750 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
751 $(elide-routines$o)),\
753 $(addprefix $(objpfx),$(o-objects$o))
755 others: $(addprefix $(objpfx),$(install-lib))
759 # Create the stamp$o files to keep the parent makefile happy.
760 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
761 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
762 $(make-target-directory)
766 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
767 # timestamp file; these rules (one explicit rule is generated for each
768 # object suffix) write a list of objects to update in the stamp file.
769 # The parent will then actually add them all to the archive in the
770 # archive rule, below.
771 define o-iterator-doit
772 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
775 $(make-target-directory)
776 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
779 object-suffixes-left := $(object-suffixes-for-libc)
780 include $(o-iterator)
784 # Now define explicit rules to build the library archives; these depend
785 # on the stamp files built above.
786 define o-iterator-doit
787 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
788 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
791 cd $(common-objdir) && \
792 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
795 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
796 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
798 $(subdirs-stamps): subdir_lib;
800 object-suffixes-left = $(object-suffixes-for-libc)
801 include $(o-iterator)
804 # This makes all the object files.
805 .PHONY: objects objs libobjs extra-objs
806 objects objs: libobjs extra-objs
807 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
808 extra-objs: $(addprefix $(objpfx),$(extra-objs))
810 # Canned sequence for building an extra library archive.
811 define build-extra-lib
812 $(patsubst %/,cd % &&,$(objpfx)) \
813 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
814 $(patsubst $(objpfx)%,%,$^)
820 .PHONY: force-install
823 # $(install-lib) are installed from the object directory into $(libdir);
824 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
825 # unless they also appear in $(non-lib.a). $(install-data) are installed as
826 # they are into $(datadir). $(headers) are installed as they are in
827 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
828 # are installed from the object directory into $(bindir), $(bindir) and
829 # $(sbindir), respectively. $(install-others) and $(install-others-programs)
830 # are absolute path names of files to install; rules to install them are
833 # The simple library name to install libc.a under.
834 # This could be defined by a sysdep Makefile.
840 $(make-target-directory)
841 $(INSTALL_DATA) $< $@
844 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
845 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
846 define make-target-directory
847 $(addprefix $(..)./scripts/mkinstalldirs ,\
848 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
851 # Any directory (parent or subdir) should install libc.a; this way
852 # "make install" in a subdir is guaranteed to install everything it changes.
853 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
854 $(inst_libdir)/$(patsubst %,$(libtype$o),\
855 $(libprefix)$(libc-name)))
856 install: $(installed-libcs)
857 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
858 $(make-target-directory)
859 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
860 # Running ranlib after installing makes the __.SYMDEF time stamp up to
861 # date, which avoids messages from some linkers.
864 define do-install-program
865 $(make-target-directory)
866 $(INSTALL_PROGRAM) $< $@.new
870 define do-install-script
871 $(make-target-directory)
872 $(INSTALL_SCRIPT) $< $@.new
876 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
877 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
879 ifeq (yes,$(build-shared))
880 # Find which .so's have versions.
881 versioned := $(strip $(foreach so,$(install-lib.so),\
882 $(patsubst %,$(so),$($(so)-version))))
884 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
885 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
887 # For versioned libraries, we install three files:
888 # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
889 # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
890 # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
891 V := $(firstword $($(subdir)-version) $(version))
892 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
893 $(foreach L,$(install-lib.so-versioned),\
895 $(inst_slibdir)/$(L:.so=)-$V.so \
896 $(inst_slibdir)/$L$($L-version))
898 # Install all the unversioned shared libraries.
899 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
900 $(objpfx)%.so $(+force)
901 $(do-install-program)
903 ifneq ($(findstring -s,$(LN_S)),)
906 $(SHELL) $(..)scripts/rellns-sh $< $@.new
910 # If we have no symbolic links don't bother with rellns-sh.
918 ifeq (yes,$(build-shared))
919 ifeq (no,$(cross-compiling))
920 symbolic-link-prog := $(common-objpfx)elf/sln
921 symbolic-link-list := $(common-objpfx)elf/symlink.list
922 define make-shlib-link
923 echo $(<F) $@ >> $(symbolic-link-list)
925 else # cross-compiling
926 # We need a definition that can be used by elf/Makefile's install rules.
927 symbolic-link-prog = $(LN_S)
930 ifndef make-shlib-link
931 define make-shlib-link
937 ifdef libc.so-version
938 # For a library specified to be version N, install three files:
939 # libc.so -> libc.so.N (e.g. libc.so.6)
940 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
942 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
945 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
946 $(do-install-program)
947 install: $(inst_slibdir)/libc.so$(libc.so-version)
949 # This fragment of linker script gives the OUTPUT_FORMAT statement
950 # for the configuration we are building. We put this statement into
951 # the linker scripts we install for -lc et al so that they will not be
952 # used by a link for a different format on a multi-architecture system.
953 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
954 $(common-objpfx)config.make \
955 $(common-objpfx)config.h $(..)Makerules
956 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
957 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
958 | sed -n -f $< > $@.new
961 common-generated += format.lds
964 # What we install as libc.so for programs to link against is in fact a
965 # link script. It contains references for the various libraries we need.
966 # The libc.so object is not complete since some functions are only defined
967 # in libc_nonshared.a.
968 # We need to use absolute paths since otherwise local copies (if they exist)
969 # of the files are taken by the linker.
970 install: $(inst_libdir)/libc.so
971 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
972 $(common-objpfx)libc.so$(libc.so-version) \
973 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
974 $(libprefix)$(libc-name)) \
976 (echo '/* GNU ld script';\
977 echo ' Use the shared library, but some functions are only in';\
978 echo ' the static library, so try that secondarily. */';\
980 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
981 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
982 ' AS_NEEDED (' $(slibdir)/$(rtld-installed-name) ') )' \
989 install: $(inst_slibdir)/libc.so
990 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
991 $(do-install-program)
994 ifneq (,$(versioned))
995 # Produce three sets of rules as above for all the smaller versioned libraries.
997 define o-iterator-doit
998 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
1000 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
1001 ifneq (,$(object-suffixes-left))
1002 include $(o-iterator)
1005 # Make symlinks in the build directory, because the versioned names might
1006 # be referenced by a DT_NEEDED in another library.
1007 define o-iterator-doit
1008 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
1010 object-suffixes-left := $(versioned)
1011 include $(o-iterator)
1013 generated += $(foreach o,$(versioned),$o$($o-version))
1015 ifeq (,$($(subdir)-version))
1016 define o-iterator-doit
1017 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
1021 object-suffixes-left := $(versioned)
1022 include $(o-iterator)
1024 define o-iterator-doit
1025 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
1026 $$(do-install-program)
1028 object-suffixes-left := $(versioned)
1029 include $(o-iterator)
1031 define o-iterator-doit
1032 $(inst_slibdir)/$o$($o-version): \
1033 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1036 object-suffixes-left := $(versioned)
1037 include $(o-iterator)
1039 define o-iterator-doit
1040 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1041 $$(do-install-program)
1043 object-suffixes-left := $(versioned)
1044 include $(o-iterator)
1048 define do-install-so
1049 $(do-install-program)
1050 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1051 $(filter-out %.so,$@))
1054 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1055 $(foreach v,$(so-versions),\
1056 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1059 $(foreach v,$(so-versions),\
1060 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1065 $(addprefix $(inst_bindir)/,$(install-bin)): \
1066 $(inst_bindir)/%: $(objpfx)% $(+force)
1067 $(do-install-program)
1069 ifdef install-bin-script
1070 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1071 $(inst_bindir)/%: $(objpfx)% $(+force)
1072 $(do-install-script)
1074 ifdef install-rootsbin
1075 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1076 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1077 $(do-install-program)
1080 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1081 $(inst_sbindir)/%: $(objpfx)% $(+force)
1082 $(do-install-program)
1085 install-lib.a := $(filter lib%.a,$(install-lib))
1086 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1087 ifdef install-lib-non.a
1088 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1089 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1093 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1094 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1096 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
1100 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1103 headers := $(strip $(headers))
1105 # This implicit rule installs headers from the source directory.
1106 # It may be ignored in preference to rules from sysd-rules to find
1107 # headers in the sysdeps tree.
1108 $(inst_includedir)/%.h: $(objpfx)%.h $(+force)
1110 $(inst_includedir)/%.h: %.h $(+force)
1112 $(inst_includedir)/%.h: $(..)include/%.h $(+force)
1114 headers-nonh := $(filter-out %.h,$(headers))
1116 $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
1119 endif # headers-nonh
1122 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1123 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1124 install-data-nosubdir install-headers-nosubdir
1125 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1126 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1127 install-rootsbin-nosubdir: \
1128 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1129 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1130 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1131 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1132 $(addprefix $(libprefix),$(install-lib-non.a)))
1133 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1134 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1135 install-others-nosubdir: $(install-others)
1136 install-others-programs-nosubdir: $(install-others-programs)
1138 # We need all the `-nosubdir' targets so that `install' in the parent
1139 # doesn't depend on several things which each iterate over the subdirs.
1140 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1141 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1142 install-%:: install-%-nosubdir ;
1144 .PHONY: install install-no-libc.a-nosubdir
1145 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
1146 install-lib-nosubdir install-others-nosubdir
1147 ifeq ($(build-programs),yes)
1148 install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
1149 install-rootsbin-nosubdir install-sbin-nosubdir \
1150 install-others-programs-nosubdir
1152 install: install-no-libc.a-nosubdir
1154 # Command to compile $< in $(objdir) using the native libraries.
1155 define native-compile
1156 $(make-target-directory)
1157 $(patsubst %/,cd % &&,$(objpfx)) \
1158 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1159 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1162 # Command to compile $< in $(common-objdir) using the native libraries.
1163 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1164 define common-objdir-compile
1165 $(patsubst %/,cd % &&,$(objpfx)) \
1166 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1167 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1170 # We always want to use configuration definitions.
1171 # Note that this is only used for commands running in $(objpfx).
1172 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1174 # Support the GNU standard name for this target.
1177 # Special target to run tests which cannot be run unconditionally.
1178 # Maintainers should use this target.
1182 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1183 ifneq (,$(all-nonlib))
1184 cpp-srcs-left = $(all-nonlib:=.c) $(all-nonlib:=.cc)
1186 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
1189 # The include magic above causes those files to use this variable for flags.
1190 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1193 ifeq ($(versioning),yes)
1194 # Generate normalized lists of symbols, versions, and data sizes.
1195 # This is handy for checking against existing library binaries.
1197 %.symlist: $(..)scripts/abilist.awk %.dynsym
1198 LC_ALL=C $(AWK) -f $^ > $@T
1202 $(OBJDUMP) --dynamic-syms $< > $@T
1205 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1206 $(..)abilist/%.abilist $(objpfx)%.symlist
1208 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1209 $(..)abilist/%.abilist $(common-objpfx)%.symlist
1213 $(AWK) -f $< -v 'config=$(check-abi-config)' \
1214 $(patsubst %,-v 'lastversion=%',$($*-abi-frozen)) \
1215 $(filter %.abilist,$^) \
1216 | { diff -p -U 0 - $(filter %.symlist,$^) $(check-abi-warn) ; }
1218 ifeq ($(enable-check-abi),warn)
1219 check-abi-warn = || echo '*** WARNING: $*.so failed ABI check'
1222 ifeq ($(firstword $(sysd-sorted-done) f)$(firstword $(generating) f),tf)
1223 -include $(common-objpfx)tls.make
1225 ifeq ($(use-thread),yes)
1226 config-tls := thread
1228 check-abi-config := \
1229 $(config-machine)-$(config-vendor)-$(config-os)/$(config-tls)
1232 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1235 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1236 $(common-objpfx)%.symlist
1238 ifndef update-abi-config
1240 @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2
1244 LC_ALL=C $(AWK) -v config='$(update-abi-config)' -f $^ \
1245 > $(..)abilist/$*.abilist.new
1246 @if cmp -s $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist 2> /dev/null; \
1247 then rm -f $(..)abilist/$*.abilist.new; \
1248 echo '+++ $(..)abilist/$*.abilist is unchanged'; \
1249 else mv -f $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist; \
1250 echo '*** Now check $*.abilist changes for correctness ***'; \
1255 .PHONY: update-abi check-abi
1256 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1257 check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
1259 subdir_check-abi: check-abi
1260 subdir_update-abi: update-abi
1262 check-abi: subdir_check-abi
1263 update-abi: subdir_update-abi
1266 ifeq ($(subdir),elf)
1267 check-abi: check-abi-libc
1268 update-abi: update-abi-libc
1269 common-generated += libc.symlist
1272 ifeq ($(build-shared),yes)
1273 ifneq ($(enable-check-abi),no)
1282 # These will have been set by sysdeps/posix/Makefile.
1288 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1290 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1291 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1292 $(common-objpfx)config.make
1293 $(make-target-directory)
1294 { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
1295 echo '#define _LIBC 1'; \
1296 echo '#include "$(..)misc/sys/uio.h"'; } | \
1297 $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
1298 $(+includes) -xc - -o $(@:st=hT)
1299 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
1300 $(@:st=dT) > $(@:st=dt)
1301 mv -f $(@:st=dt) $(@:st=d)
1302 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
1303 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
1304 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
1305 fopen_max=$${fopen_max:-16}; \
1306 filename_max=$${filename_max:-1024}; \
1307 if [ -z "$$iov_max" ]; then \
1308 define_iov_max="# undef IOV_MAX"; \
1310 define_iov_max="# define IOV_MAX $$iov_max"; \
1312 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
1313 -e "s/@FILENAME_MAX@/$$filename_max/" \
1314 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
1315 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
1316 -e "s/@L_ctermid@/$(L_ctermid)/" \
1317 -e "s/@L_cuserid@/$(L_cuserid)/" \
1318 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
1320 $(move-if-change) $(@:st=h.new) $(@:st=h)
1321 # Remove these last so that they can be examined if something went wrong.
1322 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1326 -include $(stdio_lim:h=d)
1328 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1332 .PHONY: echo-headers
1336 %.bz2: %; bzip2 -9vk $<
1337 %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
1339 # Common cleaning targets.
1341 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1343 mostlyclean: common-mostlyclean
1346 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1348 $(addsuffix -bp.out,$(tests) $(xtests) \
1351 # Remove the object files.
1353 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1354 $(others) $(sysdep-others) stubs \
1355 $(addsuffix .o,$(tests) $(xtests) \
1356 $(test-srcs) $(others) \
1358 $(addsuffix -bp,$(tests) $(xtests) \
1360 $(addsuffix .out,$(tests) $(xtests) \
1362 $(addsuffix -bp.out,$(tests) $(xtests) \
1364 -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
1365 $(install-lib) $(install-lib.so) \
1366 $(install-lib.so:%.so=%_pic.a))
1368 -rm -f $(objpfx)rtld-*.os
1371 $(foreach o,$(object-suffixes-for-libc),
1372 -rm -f $(objpfx)stamp$o $(o-objects))
1375 # Also remove the dependencies and generated source files.
1376 common-clean: common-mostlyclean
1377 -rm -f $(addprefix $(objpfx),$(generated))
1378 -rm -f $(objpfx)*.d $(objpfx)*.dt
1379 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1380 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1382 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1383 # for each function which is a stub. We grovel over all the .d files
1384 # looking for references to <stub-tag.h>. Then we grovel over each
1385 # referenced source file to see what stub function it defines.
1388 .PHONY: stubs # The parent Makefile calls this target.
1389 stubs: $(objpfx)stubs
1391 objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
1392 $(addprefix $(objpfx),$(extra-objs))
1393 $(objpfx)stubs: $(objs-for-stubs)
1394 ifneq (,$(strip $(objs-for-stubs)))
1395 (cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
1396 $(AWK) '/\.gnu\.glibc-stub\./ { \
1397 sub(/\.gnu\.glibc-stub\./, "", $$2); \
1399 END { for (s in stubs) print "#define __stub_" s }' > $@T
1405 ifneq (,$(strip $(gpl2lgpl)))
1406 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1407 # Snarf from the master source and frob the copying notice.
1408 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1410 # So I don't edit them by mistake.
1413 ifeq ($(with-cvs),yes)
1414 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@