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) $(sysd-rules-force)
225 (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \
226 for dir in $(config-sysdirs); do \
229 *) dir="\$$(..)$$dir" ;; \
232 $(check-inhibit-asm) \
233 for o in $(all-object-suffixes); do \
234 set $(subst :, ,$(sysd-rules-patterns)); \
235 while [ $$# -ge 2 ]; do \
238 v=$${t%%%}; [ x"$$v" = x ] || v="\$$($${v}CPPFLAGS)"; \
239 for s in $$asm .c; do \
240 echo "\$$(objpfx)$$t$$o: $$dir/$$d$$s \$$(before-compile)"; \
241 echo " \$$(compile-command$$s) $$v"; \
245 echo "\$$(inst_includedir)/%.h: $$dir/%.h \$$(+force)"; \
246 echo " \$$(do-install)"; \
248 echo 'sysd-rules-done = t') > $@T
251 ifndef sysd-rules-done
252 # Don't do deps until this exists, because it provides rules to make the deps.
256 define o-iterator-doit
257 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
259 object-suffixes-left := $(all-object-suffixes)
260 include $(o-iterator)
262 define o-iterator-doit
263 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
265 object-suffixes-left := $(all-object-suffixes)
266 include $(o-iterator)
268 define o-iterator-doit
269 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
271 object-suffixes-left := $(all-object-suffixes)
272 include $(o-iterator)
274 define o-iterator-doit
275 $(objpfx)%$o: %.cc $(before-compile); $$(compile-command.cc)
277 object-suffixes-left := $(all-object-suffixes)
278 include $(o-iterator)
280 # Omit the objpfx rules when building in the source tree, because
281 # objpfx is empty and so these rules just override the ones above.
283 # Define first rules to find the source files in $(objpfx).
284 # Generated source files will end up there.
285 define o-iterator-doit
286 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
288 object-suffixes-left := $(all-object-suffixes)
289 include $(o-iterator)
291 define o-iterator-doit
292 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
294 object-suffixes-left := $(all-object-suffixes)
295 include $(o-iterator)
297 define o-iterator-doit
298 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
300 object-suffixes-left := $(all-object-suffixes)
301 include $(o-iterator)
304 # Generate version maps, but wait until sysdep-subdirs is known
305 ifeq ($(sysd-sorted-done),t)
306 ifeq ($(versioning),yes)
307 -include $(common-objpfx)sysd-versions
308 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
309 common-generated += $(version-maps)
310 postclean-generated += sysd-versions Versions.all abi-versions.h \
311 Versions.def.v.i Versions.def.v Versions.v.i Versions.v
313 ifndef avoid-generated
314 ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
315 sysd-versions-force = FORCE
318 # See %.v/%.v.i implicit rules in Makeconfig.
319 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
320 $(wildcard $(add-ons:%=$(..)%/Versions.def))
321 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
322 $(common-objpfx)soversions.i \
323 $(common-objpfx)Versions.def.v
324 { while read which lib version setname; do \
325 test x"$$which" = xDEFAULT || continue; \
326 test -z "$$setname" || echo "$$lib : $$setname"; \
327 done < $(word 2,$^); \
329 } | LC_ALL=C $(AWK) -f $< > $@T
331 # See %.v/%.v.i implicit rules in Makeconfig.
332 $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
333 $(wildcard $(sysdirs:%=%/Versions)) \
334 $(common-objpfx)abi-versions.h \
335 $(sysd-versions-force)
336 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
337 $(common-objpfx)Versions.v \
338 $(..)scripts/versions.awk
339 ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
341 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
342 -v move_if_change='$(move-if-change)' \
346 endif # avoid-generated
347 endif # $(versioning) = yes
348 endif # sysd-sorted-done
350 # Generate .dT files as we compile.
351 compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
352 compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
353 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) $(compile-mkdep-flags)
354 compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
355 compile-command.cc = $(compile.cc) $(OUTPUT_OPTION) $(compile-mkdep-flags)
357 # GCC can grok options after the file name, and it looks nicer that way.
358 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
359 compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
360 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
361 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
362 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
363 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
364 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
366 # We need this for the output to go in the right place. It will default to
367 # empty if make was configured to work with a cc that can't grok -c and -o
368 # together. You can't compile the C library with such a compiler.
369 OUTPUT_OPTION = -o $@
371 # We need the $(CFLAGS) to be in there to have the right predefines during
372 # the dependency run for C sources. But having it for assembly sources can
373 # get the wrong predefines.
374 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
377 $(make-target-directory)
378 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
379 $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
380 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
381 $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
382 mv -f $(@:.d=.T) $@ $(generate-md5)
386 # Continuation lines here are dangerous because they introduce spaces!
387 define sed-remove-objpfx
388 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
389 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
393 # Modify the list of routines we build for different targets
395 ifeq (yesyes,$(build-shared)$(elf))
396 ifndef libc.so-version
397 # Undefine this because it can't work when we libc.so is unversioned.
398 static-only-routines =
402 # Bounded pointer thunks are only built for *.ob
403 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
405 elide-routines.oS += $(filter-out $(static-only-routines),\
406 $(routines) $(aux) $(sysdep_routines)) \
408 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
410 # If we have versioned code we don't need the old versions in any of the
412 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
413 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
414 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
415 elide-routines.ob += $(shared-only-routines)
417 # Shared library building.
419 ifeq (yes,$(build-shared))
421 # Reference map file only when versioning is selected and a map file name
423 ifeq ($(versioning),yes)
424 map-file = $(firstword $($(@F:.so=-map)) \
425 $(addprefix $(common-objpfx), \
426 $(filter $(@F:.so=.map),$(version-maps))))
427 load-map-file = $(map-file:%=-Wl,--version-script=%)
430 # Pattern rule to build a shared object from an archive of PIC objects.
431 # This must come after the installation rules so Make doesn't try to
432 # build shared libraries in place from the installed *_pic.a files.
433 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
434 # on other shared objects.
435 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
436 ifneq (,$(findstring aix,$(config-os)))
438 dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
443 define build-shlib-helper
444 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
445 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(config-LDFLAGS) \
446 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
447 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
448 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
449 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
450 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
453 ifneq (,$(findstring aix,$(config-os)))
454 define build-shlib-helper
455 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
456 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
457 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
458 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
459 -L$(subst :, -L,$(rpath-link))
466 # binutils only position loadable notes into the first page for binaries,
467 # not for shared objects
468 $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
469 $(LINK.o) -shared -Wl,-O1 \
470 -nostdlib -nostartfiles \
471 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
472 -Wl,--verbose 2>&1 | \
474 -e '/^=========/,/^=========/!d;/^=========/d' \
475 $(if $(filter yes,$(have-hash-style)), \
476 -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
477 -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
478 -e '/DATA_SEGMENT_ALIGN/{H;g}' \
480 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
482 -e 's/^.*\*(\.dynbss).*$$/& \
483 PROVIDE(__start___libc_freeres_ptrs = .); \
484 *(__libc_freeres_ptrs) \
485 PROVIDE(__stop___libc_freeres_ptrs = .);/'\
486 -e 's@^.*\*(\.jcr).*$$@& \
487 PROVIDE(__start___libc_subfreeres = .);\
488 __libc_subfreeres : { *(__libc_subfreeres) }\
489 PROVIDE(__stop___libc_subfreeres = .);\
490 PROVIDE(__start___libc_atexit = .);\
491 __libc_atexit : { *(__libc_atexit) }\
492 PROVIDE(__stop___libc_atexit = .);\
493 PROVIDE(__start___libc_thread_subfreeres = .);\
494 __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
495 PROVIDE(__stop___libc_thread_subfreeres = .);\
496 /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
498 common-generated += shlib.lds
501 $(build-shlib-helper) -o $@ -T $(common-objpfx)shlib.lds \
502 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
505 ifneq (,$(findstring aix,$(config-os)))
507 $(build-shlib-helper) \
509 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
510 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
513 $(build-shlib-helper) \
514 $(build-shlib-objlist)
519 ifneq (,$(findstring aix,$(config-os)))
520 define build-module-helper
521 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
522 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
524 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
525 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
528 define build-module-helper
529 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
530 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
531 -B$(csu-objpfx) $(load-map-file) \
532 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
533 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
537 # This macro is similar to build-shlib but it does not define a soname
538 # and it does not depend on the destination name to start with `lib'.
540 # binutils only position loadable notes into the first page for binaries,
541 # not for shared objects
543 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
544 $(csu-objpfx)abi-note.o $(build-module-objlist)
546 define build-module-asneeded
547 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
548 $(csu-objpfx)abi-note.o \
549 -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
552 ifneq (,$(findstring aix,$(config-os)))
554 $(build-module-helper) \
556 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
557 $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
562 $(build-module-helper) \
564 $(build-module-objlist)
569 build-module-helper-objlist = \
570 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
571 $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^))
572 whole-archive := -Wl,--whole-archive
574 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
575 build-shlib-objlist = $(build-module-helper-objlist) \
576 $(LDLIBS-$(@F:lib%.so=%).so)
578 # Don't try to use -lc when making libc.so itself.
579 # Also omits crti.o and crtn.o, which we do not want
580 # since we define our own `.init' section specially.
581 LDFLAGS-c.so = -nostdlib -nostartfiles
582 # But we still want to link libc.so against $(libc.so-gnulib).
583 LDLIBS-c.so += $(libc.so-gnulib)
584 # Give libc.so an entry point and make it directly runnable itself.
585 LDFLAGS-c.so += -e __libc_main
586 # If lazy relocation is disabled add the -z now flag.
587 ifeq ($(bind-now),yes)
588 LDFLAGS-c.so += -Wl,-z,now
590 # Pre-link the objects of libc_pic.a so that we can locally resolve
591 # COMMON symbols before we link against ld.so. This is because ld.so
592 # contains some of libc_pic.a already, which will prevent the COMMONs
593 # from being allocated in libc.so, which introduces evil dependencies
594 # between libc.so and ld.so, which can make it impossible to upgrade.
596 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
597 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
598 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
599 # Use our own special initializer and finalizer files for libc.so.
600 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
601 $(common-objpfx)libc_pic.os \
602 $(elfobjdir)/sofini.os \
603 $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
604 $(common-objpfx)shlib.lds
606 ifeq ($(versioning),yes)
607 $(common-objpfx)libc.so: $(common-objpfx)libc.map
609 common-generated += libc.so libc_pic.os
610 ifdef libc.so-version
611 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
613 common-generated += libc.so$(libc.so-version)
617 ifneq (,$(findstring aix,$(config-os)))
618 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
621 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
622 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
623 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
624 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
625 -bE:$(common-objpfx)syscalls.exp \
626 -bI:$(common-objpfx)syscalls.exp \
627 -L$(common-objpfx) -o $@ $^
628 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
629 cp $@ $(common-objpfx)shr.o
630 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
634 # Figure out the source filenames in this directory.
636 override sources := $(addsuffix .c,\
637 $(filter-out $(elided-routines),\
640 sysdep_routines := $(sysdep_routines)
642 headers := $(headers) $(sysdep_headers)
644 # This is the list of all object files, gotten by
645 # replacing every ".c" in `sources' with a ".o".
646 # We also add bounded-pointer thunks, which are later
647 # elided for all suffixes except for `.ob'.
648 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
649 $(patsubst %,$(bppfx)%.o,\
650 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
653 # The makefile may define $(extra-libs) with `libfoo libbar'
654 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
656 # extra-lib.mk is included once for each extra lib to define rules
657 # to build it, and to add its objects to the various variables.
658 # During its evaluation, $(lib) is set to the name of the library.
659 extra-libs-left := $(extra-libs)
660 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
664 # The makefile may define $(modules-names) to build additional modules.
665 # These are built with $(build-module), except any in $(modules-names-nobuild).
667 # extra-lib.mk is included once for each extra lib to define rules
668 # to build it, and to add its objects to the various variables.
669 # During its evaluation, $(lib) is set to the name of the library.
670 extra-modules-left := $(modules-names)
671 include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
673 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
674 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
675 $(objpfx)%.os $(common-objpfx)shlib.lds \
676 $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
680 +depfiles := $(sources:.c=.d) \
681 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
682 $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
683 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
684 ifeq ($(build-programs),yes)
685 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
687 +depfiles := $(addprefix $(objpfx),\
688 $(filter-out $(addsuffix .d,$(omit-deps)),\
690 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
691 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
692 $(wildcard $(all-dt-files:.dt=.d))
694 # This is a funny rule in that it removes its input file.
696 @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
697 mv -f $(@:.d=.T) $@ && \
700 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
701 # They will be generated when they're needed, and trying too early won't work.
702 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
703 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
708 -include $(+depfiles)
712 # Maximize efficiency by minimizing the number of rules.
713 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
714 # Don't define any builtin rules.
715 MAKEFLAGS := $(MAKEFLAGS)r
717 # Generic rule for making directories.
719 # mkdir isn't smart enough to strip a trailing /.
720 # We always require a mkdir which supports the -p option to avoid error
721 # messages in case of races.
724 # Make sure that object files are not removed
725 # when they are intermediates between sources and library members.
726 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
728 # Make sure that the parent library archive is never removed.
729 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
731 # Use the verbose option of ar and tar when not running silently.
732 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
738 ARFLAGS := r$(verbose)
739 CREATE_ARFLAGS := cru$(verbose)
741 # This makes all the object files in the parent library archive.
743 .PHONY: lib lib-noranlib
744 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
745 lib-noranlib: libobjs
747 # For object-suffix $o, the list of objects with that suffix.
748 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
749 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
750 $(elide-routines$o)),\
752 $(addprefix $(objpfx),$(o-objects$o))
754 others: $(addprefix $(objpfx),$(install-lib))
758 # Create the stamp$o files to keep the parent makefile happy.
759 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
760 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
761 $(make-target-directory)
765 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
766 # timestamp file; these rules (one explicit rule is generated for each
767 # object suffix) write a list of objects to update in the stamp file.
768 # The parent will then actually add them all to the archive in the
769 # archive rule, below.
770 define o-iterator-doit
771 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
774 $(make-target-directory)
775 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
778 object-suffixes-left := $(object-suffixes-for-libc)
779 include $(o-iterator)
783 # Now define explicit rules to build the library archives; these depend
784 # on the stamp files built above.
785 define o-iterator-doit
786 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
787 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
790 cd $(common-objdir) && \
791 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
794 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
795 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
797 $(subdirs-stamps): subdir_lib;
799 object-suffixes-left = $(object-suffixes-for-libc)
800 include $(o-iterator)
803 # This makes all the object files.
804 .PHONY: objects objs libobjs extra-objs
805 objects objs: libobjs extra-objs
806 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
807 extra-objs: $(addprefix $(objpfx),$(extra-objs))
809 # Canned sequence for building an extra library archive.
810 define build-extra-lib
811 $(patsubst %/,cd % &&,$(objpfx)) \
812 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
813 $(patsubst $(objpfx)%,%,$^)
819 .PHONY: force-install
822 # $(install-lib) are installed from the object directory into $(libdir);
823 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
824 # unless they also appear in $(non-lib.a). $(install-data) are installed as
825 # they are into $(datadir). $(headers) are installed as they are in
826 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
827 # are installed from the object directory into $(bindir), $(bindir) and
828 # $(sbindir), respectively. $(install-others) and $(install-others-programs)
829 # are absolute path names of files to install; rules to install them are
832 # The simple library name to install libc.a under.
833 # This could be defined by a sysdep Makefile.
839 $(make-target-directory)
840 $(INSTALL_DATA) $< $@
843 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
844 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
845 define make-target-directory
846 $(addprefix $(..)./scripts/mkinstalldirs ,\
847 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
850 # Any directory (parent or subdir) should install libc.a; this way
851 # "make install" in a subdir is guaranteed to install everything it changes.
852 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
853 $(inst_libdir)/$(patsubst %,$(libtype$o),\
854 $(libprefix)$(libc-name)))
855 install: $(installed-libcs)
856 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
857 $(make-target-directory)
858 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
859 # Running ranlib after installing makes the __.SYMDEF time stamp up to
860 # date, which avoids messages from some linkers.
863 define do-install-program
864 $(make-target-directory)
865 $(INSTALL_PROGRAM) $< $@.new
869 define do-install-script
870 $(make-target-directory)
871 $(INSTALL_SCRIPT) $< $@.new
875 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
876 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
878 ifeq (yes,$(build-shared))
879 # Find which .so's have versions.
880 versioned := $(strip $(foreach so,$(install-lib.so),\
881 $(patsubst %,$(so),$($(so)-version))))
883 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
884 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
886 # For versioned libraries, we install three files:
887 # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
888 # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
889 # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
890 V := $(firstword $($(subdir)-version) $(version))
891 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
892 $(foreach L,$(install-lib.so-versioned),\
894 $(inst_slibdir)/$(L:.so=)-$V.so \
895 $(inst_slibdir)/$L$($L-version))
897 # Install all the unversioned shared libraries.
898 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
899 $(objpfx)%.so $(+force)
900 $(do-install-program)
902 ifneq ($(findstring -s,$(LN_S)),)
905 $(SHELL) $(..)scripts/rellns-sh $< $@.new
909 # If we have no symbolic links don't bother with rellns-sh.
917 ifeq (yes,$(build-shared))
918 ifeq (no,$(cross-compiling))
919 symbolic-link-prog := $(common-objpfx)elf/sln
920 symbolic-link-list := $(common-objpfx)elf/symlink.list
921 define make-shlib-link
922 echo $(<F) $@ >> $(symbolic-link-list)
924 else # cross-compiling
925 # We need a definition that can be used by elf/Makefile's install rules.
926 symbolic-link-prog = $(LN_S)
929 ifndef make-shlib-link
930 define make-shlib-link
936 ifdef libc.so-version
937 # For a library specified to be version N, install three files:
938 # libc.so -> libc.so.N (e.g. libc.so.6)
939 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
941 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
944 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
945 $(do-install-program)
946 install: $(inst_slibdir)/libc.so$(libc.so-version)
948 # This fragment of linker script gives the OUTPUT_FORMAT statement
949 # for the configuration we are building. We put this statement into
950 # the linker scripts we install for -lc et al so that they will not be
951 # used by a link for a different format on a multi-architecture system.
952 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
953 $(common-objpfx)config.make \
954 $(common-objpfx)config.h $(..)Makerules
955 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
956 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
957 | sed -n -f $< > $@.new
960 common-generated += format.lds
963 # What we install as libc.so for programs to link against is in fact a
964 # link script. It contains references for the various libraries we need.
965 # The libc.so object is not complete since some functions are only defined
966 # in libc_nonshared.a.
967 # We need to use absolute paths since otherwise local copies (if they exist)
968 # of the files are taken by the linker.
969 install: $(inst_libdir)/libc.so
970 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
971 $(common-objpfx)libc.so$(libc.so-version) \
972 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
973 $(libprefix)$(libc-name)) \
975 (echo '/* GNU ld script';\
976 echo ' Use the shared library, but some functions are only in';\
977 echo ' the static library, so try that secondarily. */';\
979 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
980 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
981 ' AS_NEEDED (' $(slibdir)/$(rtld-installed-name) ') )' \
988 install: $(inst_slibdir)/libc.so
989 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
990 $(do-install-program)
993 ifneq (,$(versioned))
994 # Produce three sets of rules as above for all the smaller versioned libraries.
996 define o-iterator-doit
997 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
999 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
1000 ifneq (,$(object-suffixes-left))
1001 include $(o-iterator)
1004 # Make symlinks in the build directory, because the versioned names might
1005 # be referenced by a DT_NEEDED in another library.
1006 define o-iterator-doit
1007 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
1009 object-suffixes-left := $(versioned)
1010 include $(o-iterator)
1012 generated += $(foreach o,$(versioned),$o$($o-version))
1014 ifeq (,$($(subdir)-version))
1015 define o-iterator-doit
1016 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
1020 object-suffixes-left := $(versioned)
1021 include $(o-iterator)
1023 define o-iterator-doit
1024 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
1025 $$(do-install-program)
1027 object-suffixes-left := $(versioned)
1028 include $(o-iterator)
1030 define o-iterator-doit
1031 $(inst_slibdir)/$o$($o-version): \
1032 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1035 object-suffixes-left := $(versioned)
1036 include $(o-iterator)
1038 define o-iterator-doit
1039 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1040 $$(do-install-program)
1042 object-suffixes-left := $(versioned)
1043 include $(o-iterator)
1047 define do-install-so
1048 $(do-install-program)
1049 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1050 $(filter-out %.so,$@))
1053 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1054 $(foreach v,$(so-versions),\
1055 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1058 $(foreach v,$(so-versions),\
1059 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1064 $(addprefix $(inst_bindir)/,$(install-bin)): \
1065 $(inst_bindir)/%: $(objpfx)% $(+force)
1066 $(do-install-program)
1068 ifdef install-bin-script
1069 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1070 $(inst_bindir)/%: $(objpfx)% $(+force)
1071 $(do-install-script)
1073 ifdef install-rootsbin
1074 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1075 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1076 $(do-install-program)
1079 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1080 $(inst_sbindir)/%: $(objpfx)% $(+force)
1081 $(do-install-program)
1084 install-lib.a := $(filter lib%.a,$(install-lib))
1085 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1086 ifdef install-lib-non.a
1087 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1088 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1092 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1093 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1095 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
1099 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1102 headers := $(strip $(headers))
1104 # This implicit rule installs headers from the source directory.
1105 # It may be ignored in preference to rules from sysd-rules to find
1106 # headers in the sysdeps tree.
1107 $(inst_includedir)/%.h: $(objpfx)%.h $(+force)
1109 $(inst_includedir)/%.h: %.h $(+force)
1111 $(inst_includedir)/%.h: $(..)include/%.h $(+force)
1113 headers-nonh := $(filter-out %.h,$(headers))
1115 $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
1118 endif # headers-nonh
1121 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1122 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1123 install-data-nosubdir install-headers-nosubdir
1124 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1125 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1126 install-rootsbin-nosubdir: \
1127 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1128 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1129 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1130 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1131 $(addprefix $(libprefix),$(install-lib-non.a)))
1132 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1133 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1134 install-others-nosubdir: $(install-others)
1135 install-others-programs-nosubdir: $(install-others-programs)
1137 # We need all the `-nosubdir' targets so that `install' in the parent
1138 # doesn't depend on several things which each iterate over the subdirs.
1139 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1140 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1141 install-%:: install-%-nosubdir ;
1143 .PHONY: install install-no-libc.a-nosubdir
1144 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
1145 install-lib-nosubdir install-others-nosubdir
1146 ifeq ($(build-programs),yes)
1147 install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
1148 install-rootsbin-nosubdir install-sbin-nosubdir \
1149 install-others-programs-nosubdir
1151 install: install-no-libc.a-nosubdir
1153 # Command to compile $< in $(objdir) using the native libraries.
1154 define native-compile
1155 $(make-target-directory)
1156 $(patsubst %/,cd % &&,$(objpfx)) \
1157 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1158 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1161 # Command to compile $< in $(common-objdir) using the native libraries.
1162 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1163 define common-objdir-compile
1164 $(patsubst %/,cd % &&,$(objpfx)) \
1165 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1166 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1169 # We always want to use configuration definitions.
1170 # Note that this is only used for commands running in $(objpfx).
1171 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1173 # Support the GNU standard name for this target.
1176 # Special target to run tests which cannot be run unconditionally.
1177 # Maintainers should use this target.
1181 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1182 ifneq (,$(all-nonlib))
1183 cpp-srcs-left = $(all-nonlib:=.c) $(all-nonlib:=.cc)
1185 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
1188 # The include magic above causes those files to use this variable for flags.
1189 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1192 ifeq ($(versioning),yes)
1193 # Generate normalized lists of symbols, versions, and data sizes.
1194 # This is handy for checking against existing library binaries.
1196 %.symlist: $(..)scripts/abilist.awk %.dynsym
1197 LC_ALL=C $(AWK) -f $^ > $@T
1201 $(OBJDUMP) --dynamic-syms $< > $@T
1204 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1205 $(..)abilist/%.abilist $(objpfx)%.symlist
1207 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1208 $(..)abilist/%.abilist $(common-objpfx)%.symlist
1212 $(AWK) -f $< -v 'config=$(check-abi-config)' \
1213 $(patsubst %,-v 'lastversion=%',$($*-abi-frozen)) \
1214 $(filter %.abilist,$^) \
1215 | { diff -p -U 0 - $(filter %.symlist,$^) $(check-abi-warn) ; }
1217 ifeq ($(enable-check-abi),warn)
1218 check-abi-warn = || echo '*** WARNING: $*.so failed ABI check'
1221 ifeq ($(firstword $(sysd-sorted-done) f)$(firstword $(generating) f),tf)
1222 -include $(common-objpfx)tls.make
1224 ifeq ($(use-thread),yes)
1225 config-tls := thread
1227 check-abi-config := \
1228 $(config-machine)-$(config-vendor)-$(config-os)/$(config-tls)
1231 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1234 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1235 $(common-objpfx)%.symlist
1237 ifndef update-abi-config
1239 @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2
1243 LC_ALL=C $(AWK) -v config='$(update-abi-config)' -f $^ \
1244 > $(..)abilist/$*.abilist.new
1245 @if cmp -s $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist 2> /dev/null; \
1246 then rm -f $(..)abilist/$*.abilist.new; \
1247 echo '+++ $(..)abilist/$*.abilist is unchanged'; \
1248 else mv -f $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist; \
1249 echo '*** Now check $*.abilist changes for correctness ***'; \
1254 .PHONY: update-abi check-abi
1255 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1256 check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
1258 subdir_check-abi: check-abi
1259 subdir_update-abi: update-abi
1261 check-abi: subdir_check-abi
1262 update-abi: subdir_update-abi
1265 ifeq ($(subdir),elf)
1266 check-abi: check-abi-libc
1267 update-abi: update-abi-libc
1268 common-generated += libc.symlist
1271 ifeq ($(build-shared),yes)
1272 ifneq ($(enable-check-abi),no)
1281 # These will have been set by sysdeps/posix/Makefile.
1287 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1289 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1290 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1291 $(common-objpfx)config.make
1292 $(make-target-directory)
1293 { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
1294 echo '#define _LIBC 1'; \
1295 echo '#include "$(..)misc/sys/uio.h"'; } | \
1296 $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
1297 $(+includes) -xc - -o $(@:st=hT)
1298 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
1299 $(@:st=dT) > $(@:st=dt)
1300 mv -f $(@:st=dt) $(@:st=d)
1301 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
1302 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
1303 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
1304 fopen_max=$${fopen_max:-16}; \
1305 filename_max=$${filename_max:-1024}; \
1306 if [ -z "$$iov_max" ]; then \
1307 define_iov_max="# undef IOV_MAX"; \
1309 define_iov_max="# define IOV_MAX $$iov_max"; \
1311 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
1312 -e "s/@FILENAME_MAX@/$$filename_max/" \
1313 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
1314 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
1315 -e "s/@L_ctermid@/$(L_ctermid)/" \
1316 -e "s/@L_cuserid@/$(L_cuserid)/" \
1317 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
1319 $(move-if-change) $(@:st=h.new) $(@:st=h)
1320 # Remove these last so that they can be examined if something went wrong.
1321 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1325 -include $(stdio_lim:h=d)
1327 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1331 .PHONY: echo-headers
1335 %.bz2: %; bzip2 -9vk $<
1336 %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
1338 # Common cleaning targets.
1340 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1342 mostlyclean: common-mostlyclean
1345 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1347 $(addsuffix -bp.out,$(tests) $(xtests) \
1350 # Remove the object files.
1352 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1353 $(others) $(sysdep-others) stubs \
1354 $(addsuffix .o,$(tests) $(xtests) \
1355 $(test-srcs) $(others) \
1357 $(addsuffix -bp,$(tests) $(xtests) \
1359 $(addsuffix .out,$(tests) $(xtests) \
1361 $(addsuffix -bp.out,$(tests) $(xtests) \
1363 -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
1364 $(install-lib) $(install-lib.so) \
1365 $(install-lib.so:%.so=%_pic.a))
1367 -rm -f $(objpfx)rtld-*.os
1370 $(foreach o,$(object-suffixes-for-libc),
1371 -rm -f $(objpfx)stamp$o $(o-objects))
1374 # Also remove the dependencies and generated source files.
1375 common-clean: common-mostlyclean
1376 -rm -f $(addprefix $(objpfx),$(generated))
1377 -rm -f $(objpfx)*.d $(objpfx)*.dt
1378 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1379 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1381 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1382 # for each function which is a stub. We grovel over all the .d files
1383 # looking for references to <stub-tag.h>. Then we grovel over each
1384 # referenced source file to see what stub function it defines.
1387 .PHONY: stubs # The parent Makefile calls this target.
1388 stubs: $(objpfx)stubs
1390 objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
1391 $(addprefix $(objpfx),$(extra-objs))
1392 $(objpfx)stubs: $(objs-for-stubs)
1393 ifneq (,$(strip $(objs-for-stubs)))
1394 (cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
1395 $(AWK) '/\.gnu\.glibc-stub\./ { \
1396 sub(/\.gnu\.glibc-stub\./, "", $$2); \
1398 END { for (s in stubs) print "#define __stub_" s }' > $@T
1404 ifneq (,$(strip $(gpl2lgpl)))
1405 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1406 # Snarf from the master source and frob the copying notice.
1407 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1409 # So I don't edit them by mistake.
1412 ifeq ($(with-cvs),yes)
1413 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@