1 # Copyright (C) 1991-2002, 2003, 2004 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 # `configure' writes a definition of `config-sysdirs' in `config.make'.
60 sysdirs = $(strip $(full_config_sysdirs))
62 +sysdir_pfx = $(common-objpfx)
64 export sysdirs := $(sysdirs)
66 +sysdep_dirs := $(full_config_sysdirs)
68 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
71 # Add -I switches to get the right sysdep directories.
72 # `+includes' in Makeconfig references $(+sysdep-includes).
73 +sysdep-includes := $(addprefix -I,$(+sysdep_dirs))
75 # This variable is used in ``include $(o-iterator)'' after defining
76 # $(o-iterator-doit) to produce some desired rule using $o for the object
77 # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
78 # is produced for each object suffix in use.
79 o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
81 # Include any system-specific makefiles.
83 # This is here so things in sysdep Makefiles can easily depend on foo.h as
84 # appropriate and not worry about where foo.h comes from, which may be
85 # system dependent and not known by that Makefile.
86 vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
87 $(+sysdep_dirs) $(..)))
89 # The same is true for RPC source files.
90 vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
91 $(+sysdep_dirs) $(..)))
93 # Some sysdep makefiles use this to distinguish being included here from
94 # being included individually by a subdir makefile (hurd/Makefile needs this).
97 sysdep-makefiles := $(wildcard $(full_config_sysdirs:=/Makefile))
98 ifneq (,$(sysdep-makefiles))
99 include $(sysdep-makefiles)
103 # Reorder before-compile so that mach things come first, and hurd things
104 # second, before all else. The mach and hurd subdirectories have many
105 # generated header files which the much of rest of the library depends on,
106 # so it is best to build them first (and mach before hurd, at that).
107 before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
109 $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
112 # Even before that, we need abi-versions.h which is generated right here.
113 ifeq ($(versioning),yes)
114 ifndef avoid-generated
115 before-compile := $(common-objpfx)abi-versions.h $(before-compile)
116 $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
117 $(common-objpfx)Versions.all
118 LC_ALL=C $(AWK) -v oldest_abi=$(oldest-abi) -f $^ > $@T
121 $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
122 sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
123 $(common-objpfx)abi-versions.h > $@T
125 endif # avoid-generated
126 endif # $(versioning) = yes
128 # Make sure the subdirectory for object files gets created.
130 ifeq (,$(wildcard $(objpfx).))
131 before-compile += $(objpfx).
133 $(make-target-directory)
137 # Remove existing files from `before-compile'. Things are added there when
138 # they must exist for dependency generation to work right, but once they
139 # exist there is no further need for every single file to depend on them,
140 # and those gratuitous dependencies result in many gratuitous
142 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
144 # Don't let any before-compile file be an intermediate and get removed.
149 # We don't want $(common-objpfx) files to depend on miscellaneous stuff
152 common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
154 common-before-compile = $(before-compile)
158 # If a makefile needs to do something conditional on something that
159 # can only be figured out from headers, write a FOO.make.c input
160 # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
161 # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
163 # We only generate these in the top-level makefile, to avoid any weirdness
164 # from subdir-specific makefile tweaks creeping in on an update.
165 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
167 (echo '# Generated from $*.make.c by Makerules.'; \
168 $(CC) $(CFLAGS) $(CPPFLAGS) -E $< \
169 -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
170 | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \
171 echo 'common-generated += $(@F)'; \
172 sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
178 sed-remove-dotdot := -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' \
179 -e 's@^\.\.\/\([^ \]*\)@$$(..)\1@g'
181 sed-remove-dotdot := -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' \
182 -e 's@^\([^ \/$$][^ \]*\)@$$(..)\1@g'
186 # Generating headers for assembly constants.
187 # We need this defined early to get into before-compile before
188 # it's used in sysd-rules, below.
189 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
190 %.sym $(common-before-compile)
191 $(AWK) -f $< $(filter %.sym,$^) \
192 | $(CC) -S -o - $(CFLAGS) $(CPPFLAGS) -x c - \
193 -MD -MP -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)' \
194 | sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' > $(@:.h.d=.h)T
195 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
196 $(@:.h=.h.d)T > $(@:.h=.h.d)T2
198 mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
199 mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
200 vpath %.sym $(sysdirs)
201 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
203 # Generate an ordered list of implicit rules which find the source files in
204 # each sysdep directory. The old method was to use vpath to search all the
205 # sysdep directories. However, that had the problem that a .S file in a
206 # later directory would be chosen over a .c file in an earlier directory,
207 # which does not preserve the desired sysdeps ordering behavior.
209 # It matters that this set of rules, for compiling from sources in
210 # the current directory (the $srcdir/$subdir) come before the
211 # generated sysdep rules in included from sysd-rules below. When
212 # compiling in the source tree, generated sources go into the current
213 # directory, and those should be chosen before any sources in sysdeps.
214 define o-iterator-doit
215 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
217 object-suffixes-left := $(all-object-suffixes)
218 include $(o-iterator)
220 define o-iterator-doit
221 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
223 object-suffixes-left := $(all-object-suffixes)
224 include $(o-iterator)
226 define o-iterator-doit
227 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
229 object-suffixes-left := $(all-object-suffixes)
230 include $(o-iterator)
232 # Omit the objpfx rules when building in the source tree, because
233 # objpfx is empty and so these rules just override the ones above.
235 # Define first rules to find the source files in $(objpfx).
236 # Generated source files will end up there.
237 define o-iterator-doit
238 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
240 object-suffixes-left := $(all-object-suffixes)
241 include $(o-iterator)
243 define o-iterator-doit
244 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
246 object-suffixes-left := $(all-object-suffixes)
247 include $(o-iterator)
249 define o-iterator-doit
250 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
252 object-suffixes-left := $(all-object-suffixes)
253 include $(o-iterator)
256 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
257 # patterns matching sysdep directories whose assembly source files should
259 ifdef inhibit-sysdep-asm
260 define open-check-inhibit-asm
261 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
263 close-check-inhibit-asm = ;; esac ;
266 -include $(+sysdir_pfx)sysd-rules
267 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
268 # The value of $(+sysdep_dirs) the sysd-rules was computed for
269 # differs from the one we are using now. So force a rebuild of sysd-rules.
270 sysd-rules-force = FORCE
273 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
274 $(wildcard $(foreach dir,$(sysdirs),\
278 (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \
279 for dir in $(config-sysdirs:%='$$(..)%'); do \
280 for o in $(all-object-suffixes); do \
281 $(open-check-inhibit-asm) \
282 echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
283 \$$(compile-command.S)"; \
284 echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
285 \$$(compile-command.s)"; \
286 echo "\$$(objpfx)rtld-%$$o: $$dir/%.S \$$(before-compile); \
287 \$$(compile-command.S)"; \
288 echo "\$$(objpfx)rtld-%$$o: $$dir/%.s \$$(before-compile); \
289 \$$(compile-command.s)"; \
290 echo "\$$(objpfx)ptw-%$$o: $$dir/%.S \$$(before-compile); \
291 \$$(compile-command.S)"; \
292 echo "\$$(objpfx)ptw-%$$o: $$dir/%.s \$$(before-compile); \
293 \$$(compile-command.s)"; \
294 $(close-check-inhibit-asm) \
295 echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
296 \$$(compile-command.c)"; \
297 echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \
298 \$$(compile-command.c)"; \
299 echo "\$$(objpfx)ptw-%$$o: $$dir/%.c \$$(before-compile); \
300 \$$(compile-command.c)"; \
302 echo "\$$(objpfx)m_%.S: $$dir/s_%.S; \$$(+make-include-of-dep)"; \
303 echo "\$$(objpfx)m_%.c: $$dir/s_%.c; \$$(+make-include-of-dep)"; \
305 echo 'sysd-rules-done = t') > $@T
308 ifndef sysd-rules-done
309 # Don't do deps until this exists, because it provides rules to make the deps.
313 # This is used by the m_%.[Sc] pattern rules in sysd-rules.
314 define +make-include-of-dep
315 echo '#include <$<>' > $@T
319 # Generate version maps, but wait until sysdep-subdirs is known
320 ifeq ($(sysd-sorted-done),t)
321 ifeq ($(versioning),yes)
322 -include $(common-objpfx)sysd-versions
323 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
324 common-generated += $(version-maps)
325 postclean-generated += sysd-versions Versions.all abi-versions.h \
326 Versions.def.v.i Versions.def.v Versions.v.i Versions.v
328 ifndef avoid-generated
329 ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
330 sysd-versions-force = FORCE
333 # See %.v/%.v.i implicit rules in Makeconfig.
334 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
335 $(wildcard $(add-ons:%=$(..)%/Versions.def))
336 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
337 $(common-objpfx)soversions.i \
338 $(common-objpfx)Versions.def.v
339 { while read lib version setname; do \
340 test -z "$$setname" || echo "$$lib : $$setname"; \
341 done < $(word 2,$^); \
343 } | LC_ALL=C $(AWK) -f $< > $@T
345 # See %.v/%.v.i implicit rules in Makeconfig.
346 $(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
347 $(wildcard $(sysdirs:%=%/Versions)) \
348 $(common-objpfx)abi-versions.h \
349 $(sysd-versions-force)
350 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
351 $(common-objpfx)Versions.v \
352 $(..)scripts/versions.awk
353 ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
355 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
356 -v move_if_change='$(move-if-change)' \
360 endif # avoid-generated
361 endif # $(versioning) = yes
362 endif # sysd-sorted-done
364 # Generate .dT files as we compile.
365 compile-mkdep-flags = -MD -MP -MF $@.dt
366 compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
367 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) $(compile-mkdep-flags)
368 compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
370 # GCC can grok options after the file name, and it looks nicer that way.
371 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
372 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
373 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
374 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
375 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
376 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
378 # We need this for the output to go in the right place. It will default to
379 # empty if make was configured to work with a cc that can't grok -c and -o
380 # together. You can't compile the C library with such a compiler.
381 OUTPUT_OPTION = -o $@
383 # We need the $(CFLAGS) to be in there to have the right predefines during
384 # the dependency run for C sources. But having it for assembly sources can
385 # get the wrong predefines.
386 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
389 $(make-target-directory)
390 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
391 $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
392 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
393 $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
394 mv -f $(@:.d=.T) $@ $(generate-md5)
398 # Continuation lines here are dangerous because they introduce spaces!
399 define sed-remove-objpfx
400 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
401 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
405 # Modify the list of routines we build for different targets
407 ifeq (yesyes,$(build-shared)$(elf))
408 ifndef libc.so-version
409 # Undefine this because it can't work when we libc.so is unversioned.
410 static-only-routines =
414 # Bounded pointer thunks are only built for *.ob
415 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
417 elide-routines.oS += $(filter-out $(static-only-routines),\
418 $(routines) $(aux) $(sysdep_routines)) \
420 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
422 # If we have versioned code we don't need the old versions in any of the
424 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
425 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
426 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
427 elide-routines.ob += $(shared-only-routines)
429 # Shared library building.
431 ifeq (yes,$(build-shared))
433 # Reference map file only when versioning is selected and a map file name
435 ifeq ($(versioning),yes)
436 map-file = $(firstword $($(@F:.so=-map)) \
437 $(addprefix $(common-objpfx), \
438 $(filter $(@F:.so=.map),$(version-maps))))
439 load-map-file = $(map-file:%=-Wl,--version-script=%)
442 # Pattern rule to build a shared object from an archive of PIC objects.
443 # This must come after the installation rules so Make doesn't try to
444 # build shared libraries in place from the installed *_pic.a files.
445 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
446 # on other shared objects.
447 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
448 ifneq (,$(findstring aix,$(config-os)))
450 dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
455 define build-shlib-helper
456 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
457 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(config-LDFLAGS) \
458 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
459 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
460 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
461 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
462 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
465 ifneq (,$(findstring aix,$(config-os)))
466 define build-shlib-helper
467 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
468 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
469 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
470 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
471 -L$(subst :, -L,$(rpath-link))
478 # binutils only position loadable notes into the first page for binaries,
479 # not for shared objects
480 $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
481 $(LINK.o) -shared -Wl,-O1 \
482 -nostdlib -nostartfiles \
483 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
484 -Wl,--verbose 2>&1 | \
486 -e '/^=========/,/^=========/!d;/^=========/d' \
487 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
488 -e 's/^.*\*(\.dynbss).*$$/& \
489 PROVIDE(__start___libc_freeres_ptrs = .); \
490 *(__libc_freeres_ptrs) \
491 PROVIDE(__stop___libc_freeres_ptrs = .);/'\
492 -e 's/^.*\*(\.jcr).*$$/&\n\
493 PROVIDE(__start___libc_subfreeres = .);\n\
494 __libc_subfreeres : { *(__libc_subfreeres) }\n\
495 PROVIDE(__stop___libc_subfreeres = .);\n\
496 PROVIDE(__start___libc_atexit = .);\n\
497 __libc_atexit : { *(__libc_atexit) }\n\
498 PROVIDE(__stop___libc_atexit = .);\n\
499 PROVIDE(__start___libc_thread_subfreeres = .);\n\
500 __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\n\
501 PROVIDE(__stop___libc_thread_subfreeres = .);/'
503 common-generated += shlib.lds
506 $(build-shlib-helper) -o $@ -T $(common-objpfx)shlib.lds \
507 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
510 ifneq (,$(findstring aix,$(config-os)))
512 $(build-shlib-helper) \
514 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
515 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
518 $(build-shlib-helper) \
519 $(build-shlib-objlist)
524 ifneq (,$(findstring aix,$(config-os)))
525 define build-module-helper
526 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
527 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
529 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
530 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
533 define build-module-helper
534 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
535 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
536 -B$(csu-objpfx) $(load-map-file) \
537 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
538 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
542 # This macro is similar to build-shlib but it does not define a soname
543 # and it does not depend on the destination name to start with `lib'.
545 # binutils only position loadable notes into the first page for binaries,
546 # not for shared objects
548 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
549 $(csu-objpfx)abi-note.o $(build-module-objlist)
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 $(gnulib).
583 LDLIBS-c.so += $(gnulib)
584 # Give libc.so an entry point and make it directly runnable itself.
585 LDFLAGS-c.so += -e __libc_main
586 # Pre-link the objects of libc_pic.a so that we can locally resolve
587 # COMMON symbols before we link against ld.so. This is because ld.so
588 # contains some of libc_pic.a already, which will prevent the COMMONs
589 # from being allocated in libc.so, which introduces evil dependencies
590 # between libc.so and ld.so, which can make it impossible to upgrade.
592 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
593 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
594 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
595 # Use our own special initializer and finalizer files for libc.so.
596 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
597 $(common-objpfx)libc_pic.os \
598 $(elfobjdir)/sofini.os \
599 $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
600 $(common-objpfx)shlib.lds
602 ifeq ($(versioning),yes)
603 $(common-objpfx)libc.so: $(common-objpfx)libc.map
605 common-generated += libc.so libc_pic.os
606 ifdef libc.so-version
607 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
609 common-generated += libc.so$(libc.so-version)
613 ifneq (,$(findstring aix,$(config-os)))
614 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
617 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
618 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
619 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
620 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
621 -bE:$(common-objpfx)syscalls.exp \
622 -bI:$(common-objpfx)syscalls.exp \
623 -L$(common-objpfx) -o $@ $^
624 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
625 cp $@ $(common-objpfx)shr.o
626 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
630 # Figure out the source filenames in this directory.
632 override sources := $(addsuffix .c,\
633 $(filter-out $(elided-routines),\
636 sysdep_routines := $(sysdep_routines)
638 headers := $(headers) $(sysdep_headers)
640 # This is the list of all object files, gotten by
641 # replacing every ".c" in `sources' with a ".o".
642 # We also add bounded-pointer thunks, which are later
643 # elided for all suffixes except for `.ob'.
644 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
645 $(patsubst %,$(bppfx)%.o,\
646 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
649 # The makefile may define $(extra-libs) with `libfoo libbar'
650 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
652 # extra-lib.mk is included once for each extra lib to define rules
653 # to build it, and to add its objects to the various variables.
654 # During its evaluation, $(lib) is set to the name of the library.
655 extra-libs-left := $(extra-libs)
656 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
659 +depfiles := $(sources:.c=.d) \
660 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
661 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
662 ifeq ($(build-programs),yes)
663 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
665 +depfiles := $(addprefix $(objpfx),\
666 $(filter-out $(addsuffix .d,$(omit-deps)),\
668 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
669 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
670 $(wildcard $(all-dt-files:.dt=.d))
672 # This is a funny rule in that it removes its input file.
674 @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
675 mv -f $(@:.d=.T) $@ && \
678 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
679 # They will be generated when they're needed, and trying too early won't work.
680 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
681 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
686 -include $(+depfiles)
690 # Maximize efficiency by minimizing the number of rules.
691 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
692 # Don't define any builtin rules.
693 MAKEFLAGS := $(MAKEFLAGS)r
695 # Generic rule for making directories.
697 # mkdir isn't smart enough to strip a trailing /.
700 # Make sure that object files are not removed
701 # when they are intermediates between sources and library members.
702 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
704 # Make sure that the parent library archive is never removed.
705 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
707 # Use the verbose option of ar and tar when not running silently.
708 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
714 ARFLAGS := r$(verbose)
715 CREATE_ARFLAGS := cru$(verbose)
717 # This makes all the object files in the parent library archive.
719 .PHONY: lib lib-noranlib
720 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
721 lib-noranlib: libobjs
723 # For object-suffix $o, the list of objects with that suffix.
724 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
725 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
726 $(elide-routines$o)),\
728 $(addprefix $(objpfx),$(o-objects$o))
730 others: $(addprefix $(objpfx),$(install-lib))
734 # Create the stamp$o files to keep the parent makefile happy.
735 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
736 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
737 $(make-target-directory)
741 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
742 # timestamp file; these rules (one explicit rule is generated for each
743 # object suffix) write a list of objects to update in the stamp file.
744 # The parent will then actually add them all to the archive in the
745 # archive rule, below.
746 define o-iterator-doit
747 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
750 $(make-target-directory)
751 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
754 object-suffixes-left := $(object-suffixes-for-libc)
755 include $(o-iterator)
759 # Now define explicit rules to build the library archives; these depend
760 # on the stamp files built above.
761 define o-iterator-doit
762 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
763 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
766 cd $(common-objdir) && \
767 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
770 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
771 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
773 $(subdirs-stamps): subdir_lib;
775 object-suffixes-left = $(object-suffixes-for-libc)
776 include $(o-iterator)
779 # This makes all the object files.
780 .PHONY: objects objs libobjs extra-objs
781 objects objs: libobjs extra-objs
782 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
783 extra-objs: $(addprefix $(objpfx),$(extra-objs))
785 # Canned sequence for building an extra library archive.
786 define build-extra-lib
787 $(patsubst %/,cd % &&,$(objpfx)) \
788 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
789 $(patsubst $(objpfx)%,%,$^)
795 .PHONY: force-install
798 # $(install-lib) are installed from the object directory into $(libdir);
799 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
800 # unless they also appear in $(non-lib.a). $(install-data) are installed
801 # as they are into $(datadir). $(headers) are installed as they are in
802 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
803 # are installed from the object directory into $(bindir), $(bindir) and
804 # $(sbindir), respectively. $(install-others) are absolute path names of
805 # files to install; rules to install them are defined elsewhere.
807 # The simple library name to install libc.a under.
808 # This could be defined by a sysdep Makefile.
814 $(make-target-directory)
815 $(INSTALL_DATA) $< $@
818 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
819 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
820 define make-target-directory
821 $(addprefix $(..)./scripts/mkinstalldirs ,\
822 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
825 # Any directory (parent or subdir) should install libc.a; this way
826 # "make install" in a subdir is guaranteed to install everything it changes.
827 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
828 $(inst_libdir)/$(patsubst %,$(libtype$o),\
829 $(libprefix)$(libc-name)))
830 install: $(installed-libcs)
831 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
832 $(make-target-directory)
833 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
834 # Running ranlib after installing makes the __.SYMDEF time stamp up to
835 # date, which avoids messages from some linkers.
838 define do-install-program
839 $(make-target-directory)
840 $(INSTALL_PROGRAM) $< $@.new
844 define do-install-script
845 $(make-target-directory)
846 $(INSTALL_SCRIPT) $< $@.new
850 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
851 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
853 ifeq (yes,$(build-shared))
854 # Find which .so's have versions.
855 versioned := $(strip $(foreach so,$(install-lib.so),\
856 $(patsubst %,$(so),$($(so)-version))))
858 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
859 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
861 # For versioned libraries, we install three files:
862 # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
863 # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
864 # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
865 V := $(firstword $($(subdir)-version) $(version))
866 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
867 $(foreach L,$(install-lib.so-versioned),\
869 $(inst_slibdir)/$(L:.so=)-$V.so \
870 $(inst_slibdir)/$L$($L-version))
872 # Install all the unversioned shared libraries.
873 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
874 $(objpfx)%.so $(+force)
875 $(do-install-program)
877 ifneq ($(findstring -s,$(LN_S)),)
880 $(SHELL) $(..)scripts/rellns-sh $< $@.new
884 # If we have no symbolic links don't bother with rellns-sh.
892 ifeq (yes,$(build-shared))
893 ifeq (no,$(cross-compiling))
894 symbolic-link-prog := $(common-objpfx)elf/sln
895 symbolic-link-list := $(common-objpfx)elf/symlink.list
896 define make-shlib-link
897 echo $(<F) $@ >> $(symbolic-link-list)
899 else # cross-compiling
900 # We need a definition that can be used by elf/Makefile's install rules.
901 symbolic-link-prog = $(LN_S)
904 ifndef make-shlib-link
905 define make-shlib-link
911 ifdef libc.so-version
912 # For a library specified to be version N, install three files:
913 # libc.so -> libc.so.N (e.g. libc.so.6)
914 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
916 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
919 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
920 $(do-install-program)
921 install: $(inst_slibdir)/libc.so$(libc.so-version)
923 # This fragment of linker script gives the OUTPUT_FORMAT statement
924 # for the configuration we are building. We put this statement into
925 # the linker scripts we install for -lc et al so that they will not be
926 # used by a link for a different format on a multi-architecture system.
927 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
928 $(common-objpfx)config.make \
929 $(common-objpfx)config.h $(..)Makerules
930 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
931 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
932 | sed -n -f $< > $@.new
935 common-generated += format.lds
938 # What we install as libc.so for programs to link against is in fact a
939 # link script. It contains references for the various libraries we need.
940 # The libc.so object is not complete since some functions are only defined
941 # in libc_nonshared.a.
942 # We need to use absolute paths since otherwise local copies (if they exist)
943 # of the files are taken by the linker.
944 install: $(inst_libdir)/libc.so
945 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
946 $(common-objpfx)libc.so$(libc.so-version) \
947 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
948 $(libprefix)$(libc-name)) \
950 (echo '/* GNU ld script';\
951 echo ' Use the shared library, but some functions are only in';\
952 echo ' the static library, so try that secondarily. */';\
954 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
955 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
963 install: $(inst_slibdir)/libc.so
964 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
965 $(do-install-program)
968 ifneq (,$(versioned))
969 # Produce three sets of rules as above for all the smaller versioned libraries.
971 define o-iterator-doit
972 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
974 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
975 ifneq (,$(object-suffixes-left))
976 include $(o-iterator)
979 # Make symlinks in the build directory, because the versioned names might
980 # be referenced by a DT_NEEDED in another library.
981 define o-iterator-doit
982 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
984 object-suffixes-left := $(versioned)
985 include $(o-iterator)
987 generated += $(foreach o,$(versioned),$o$($o-version))
989 ifeq (,$($(subdir)-version))
990 define o-iterator-doit
991 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
995 object-suffixes-left := $(versioned)
996 include $(o-iterator)
998 define o-iterator-doit
999 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
1000 $$(do-install-program)
1002 object-suffixes-left := $(versioned)
1003 include $(o-iterator)
1005 define o-iterator-doit
1006 $(inst_slibdir)/$o$($o-version): \
1007 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1010 object-suffixes-left := $(versioned)
1011 include $(o-iterator)
1013 define o-iterator-doit
1014 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1015 $$(do-install-program)
1017 object-suffixes-left := $(versioned)
1018 include $(o-iterator)
1022 define do-install-so
1023 $(do-install-program)
1024 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1025 $(filter-out %.so,$@))
1028 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1029 $(foreach v,$(so-versions),\
1030 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1033 $(foreach v,$(so-versions),\
1034 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1039 $(addprefix $(inst_bindir)/,$(install-bin)): \
1040 $(inst_bindir)/%: $(objpfx)% $(+force)
1041 $(do-install-program)
1043 ifdef install-bin-script
1044 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1045 $(inst_bindir)/%: $(objpfx)% $(+force)
1046 $(do-install-script)
1048 ifdef install-rootsbin
1049 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1050 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1051 $(do-install-program)
1054 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1055 $(inst_sbindir)/%: $(objpfx)% $(+force)
1056 $(do-install-program)
1059 install-lib.a := $(filter lib%.a,$(install-lib))
1060 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1061 ifdef install-lib-non.a
1062 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1063 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1067 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1068 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1070 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
1074 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1077 headers := $(strip $(headers))
1079 $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
1083 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1084 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1085 install-data-nosubdir install-headers-nosubdir
1086 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1087 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1088 install-rootsbin-nosubdir: \
1089 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1090 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1091 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1092 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1093 $(addprefix $(libprefix),$(install-lib-non.a)))
1094 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1095 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1096 install-others-nosubdir: $(install-others)
1098 # We need all the `-nosubdir' targets so that `install' in the parent
1099 # doesn't depend on several things which each iterate over the subdirs.
1100 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1101 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1102 install-%:: install-%-nosubdir ;
1104 .PHONY: install install-no-libc.a-nosubdir
1105 ifeq ($(build-programs),yes)
1106 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1107 install-bin-nosubdir install-bin-script-nosubdir \
1108 install-lib-nosubdir install-others-nosubdir \
1109 install-rootsbin-nosubdir install-sbin-nosubdir
1111 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1112 install-lib-nosubdir install-others-nosubdir
1114 install: install-no-libc.a-nosubdir
1116 # Command to compile $< in $(objdir) using the native libraries.
1117 define native-compile
1118 $(make-target-directory)
1119 $(patsubst %/,cd % &&,$(objpfx)) \
1120 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1121 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1124 # Command to compile $< in $(common-objdir) using the native libraries.
1125 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1126 define common-objdir-compile
1127 $(patsubst %/,cd % &&,$(objpfx)) \
1128 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1129 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1132 # We always want to use configuration definitions.
1133 # Note that this is only used for commands running in $(objpfx).
1134 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1136 # Support the GNU standard name for this target.
1139 # Special target to run tests which cannot be run unconditionally.
1140 # Maintainers should use this target.
1144 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1145 ifneq (,$(all-nonlib))
1146 cpp-srcs-left = $(all-nonlib:=.c)
1148 include $(patsubst %,$(..)cppflags-iterator.mk,$(all-nonlib))
1151 # The include magic above causes those files to use this variable for flags.
1152 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1155 ifeq ($(versioning),yes)
1156 # Generate normalized lists of symbols, versions, and data sizes.
1157 # This is handy for checking against existing library binaries.
1159 %.symlist: $(..)scripts/abilist.awk %.dynsym
1160 LC_ALL=C $(AWK) -f $^ > $@T
1164 $(OBJDUMP) --dynamic-syms $< > $@T
1167 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1168 $(..)abilist/%.abilist $(objpfx)%.symlist
1170 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1171 $(..)abilist/%.abilist $(common-objpfx)%.symlist
1175 $(AWK) -f $< -v 'config=$(check-abi-config)' \
1176 $(filter %.abilist,$^) \
1177 | { diff -pu0 - $(filter %.symlist,$^) $(check-abi-warn) ; }
1179 ifeq ($(enable-check-abi),warn)
1180 check-abi-warn = || echo '*** WARNING: $*.so failed ABI check'
1183 ifeq ($(firstword $(sysd-sorted-done) f)$(firstword $(generating) f),tf)
1184 -include $(common-objpfx)tls.make
1186 ifeq ($(use-tls),yes)
1189 ifeq ($(use-thread),yes)
1190 config-tls := thread
1192 check-abi-config := \
1193 $(config-machine)-$(config-vendor)-$(config-os)/$(config-tls)
1196 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1199 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1200 $(common-objpfx)%.symlist
1202 ifndef update-abi-config
1204 @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2
1208 LC_ALL=C $(AWK) -v config='$(update-abi-config)' -f $^ \
1209 > $(..)abilist/$*.abilist.new
1210 @if cmp -s $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist 2> /dev/null; \
1211 then rm -f $(..)abilist/$*.abilist.new; \
1212 echo '+++ $(..)abilist/$*.abilist is unchanged'; \
1213 else mv -f $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist; \
1214 echo '*** Now check $*.abilist changes for correctness ***'; \
1219 .PHONY: update-abi check-abi
1220 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1221 check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
1223 subdir_check-abi: check-abi
1224 subdir_update-abi: update-abi
1226 check-abi: subdir_check-abi
1227 update-abi: subdir_update-abi
1230 ifeq ($(subdir),elf)
1231 check-abi: check-abi-libc
1232 update-abi: update-abi-libc
1233 common-generated += libc.symlist
1236 ifeq ($(build-shared),yes)
1237 ifneq ($(enable-check-abi),no)
1246 # There's no good place to put this - here will do.
1247 ifeq ($(filter %posix, $(sysdirs)),)
1258 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1260 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1261 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1262 $(common-objpfx)config.make
1263 $(make-target-directory)
1264 { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
1265 echo '#define _LIBC 1'; \
1266 echo '#include "$(..)misc/sys/uio.h"'; } | \
1267 $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
1268 $(+includes) -xc - -o $(@:st=hT)
1269 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
1270 $(@:st=dT) > $(@:st=dt)
1271 mv -f $(@:st=dt) $(@:st=d)
1272 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
1273 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
1274 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
1275 fopen_max=$${fopen_max:-16}; \
1276 filename_max=$${filename_max:-1024}; \
1277 if [ -z "$$iov_max" ]; then \
1278 define_iov_max="# undef IOV_MAX"; \
1280 define_iov_max="# define IOV_MAX $$iov_max"; \
1282 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
1283 -e "s/@FILENAME_MAX@/$$filename_max/" \
1284 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
1285 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
1286 -e "s/@L_ctermid@/$(L_ctermid)/" \
1287 -e "s/@L_cuserid@/$(L_cuserid)/" \
1288 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
1290 $(move-if-change) $(@:st=h.new) $(@:st=h)
1291 # Remove these last so that they can be examined if something went wrong.
1292 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1296 -include $(stdio_lim:h=d)
1298 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1301 TAGS: $(objpfx)distinfo $(..)MakeTAGS
1302 $(MAKE) $(addprefix -f ,$^) $@
1304 $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE
1305 $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
1309 .PHONY: echo-headers
1314 # Common cleaning targets.
1316 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1318 mostlyclean: common-mostlyclean
1321 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1323 $(addsuffix -bp.out,$(tests) $(xtests) \
1326 # Remove the object files.
1328 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1329 $(others) $(sysdep-others) stubs \
1330 $(addsuffix .o,$(tests) $(xtests) \
1331 $(test-srcs) $(others) \
1333 $(addsuffix -bp,$(tests) $(xtests) \
1335 $(addsuffix .out,$(tests) $(xtests) \
1337 $(addsuffix -bp.out,$(tests) $(xtests) \
1339 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
1341 $(install-lib.so:%.so=%_pic.a))
1343 -rm -f $(objpfx)rtld-*.os
1346 $(foreach o,$(object-suffixes-for-libc),
1347 -rm -f $(objpfx)stamp$o $(o-objects))
1350 # Also remove the dependencies and generated source files.
1351 common-clean: common-mostlyclean
1352 -rm -f $(addprefix $(objpfx),$(generated))
1353 -rm -f $(objpfx)*.d $(objpfx)*.dt
1354 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1355 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1356 -rm -f $(objpfx)distinfo
1358 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1359 # for each function which is a stub. We grovel over all the .d files
1360 # looking for references to <stub-tag.h>. Then we grovel over each
1361 # referenced source file to see what stub function it defines.
1364 .PHONY: stubs # The parent Makefile calls this target.
1365 stubs: $(objpfx)stubs
1367 $(objpfx)stubs: $(+depfiles)
1368 ifneq (,$(strip $(+depfiles)))
1369 # Use /dev/null since `...` might expand to empty.
1370 c=`($(patsubst %/,cd % &&,$(objpfx)) \
1371 sed -n -e 's@\$$(common-objpfx)@$(common-objpfx)@g' \
1372 -e 's@\$$(objpfx)@$(objpfx)@g' \
1373 -e '/stub-tag\.h/{; g; s/./&/p; }' \
1374 -e '/:/{x; s/^.*$$//; x; }' \
1375 -e 's/^.*://;s/\\$$//;s/^ *\([^ ][^ ]*\) .*$$/\1/' \
1376 -e '/^[^ ][^ ]*$$/{G;s/^.*\n\(..*\)/\1/;s/\n//;h; }' \
1377 $(patsubst $(objpfx)%,%,$^)) | sort | uniq`; \
1378 sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
1385 # Make the distribution tar file.
1388 dist: $(objpfx)distinfo $(..)Make-dist
1389 $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
1391 # Avoid depending on source files found in sysdeps dirs,
1392 # because the references affect implicit rule selection.
1393 dist: $(filter-out %.c %.S %.s,$(distribute))
1395 # We used to simply export all these variables, but that frequently made the
1396 # environment get too large. Instead, we write all the information into
1397 # a generated makefile fragment `distinfo', and then include it with -f in
1398 # the sub-make that makes the distribution (above).
1399 $(objpfx)distinfo: Makefile $(..)Makerules \
1400 $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile))
1401 $(make-target-directory)
1404 .PHONY: subdir_distinfo
1405 subdir_distinfo: $(objpfx)distinfo
1407 define distinfo-vars
1409 echo > $@.new 'subdir := $(subdir)'
1410 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
1411 headers sysdep_headers distribute dont_distribute generated \
1412 others tests xtests test-srcs extra-libs versioned \
1413 $(extra-libs:%=%-routines) \
1414 $(addprefix install-,lib lib.so data bin bin-script sbin others),
1415 echo >> $@.new '$(subdir)-$(var) := $($(var))'
1416 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
1419 ifneq (,$(strip $(gpl2lgpl)))
1420 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1421 # Snarf from the master source and frob the copying notice.
1422 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1424 # So I don't edit them by mistake.
1427 ifeq ($(with-cvs),yes)
1428 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@