1 # Copyright (C) 1991-2002, 2003, 2004, 2005 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 $(@:.h.d=.h)T3 $(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' \
195 $(@:.h.d=.h)T3 > $(@:.h.d=.h)T
197 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
198 $(@:.h=.h.d)T > $(@:.h=.h.d)T2
200 mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
201 mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
202 vpath %.sym $(sysdirs)
203 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
205 # Generate an ordered list of implicit rules which find the source files in
206 # each sysdep directory. The old method was to use vpath to search all the
207 # sysdep directories. However, that had the problem that a .S file in a
208 # later directory would be chosen over a .c file in an earlier directory,
209 # which does not preserve the desired sysdeps ordering behavior.
211 # It matters that this set of rules, for compiling from sources in
212 # the current directory (the $srcdir/$subdir) come before the
213 # generated sysdep rules in included from sysd-rules below. When
214 # compiling in the source tree, generated sources go into the current
215 # directory, and those should be chosen before any sources in sysdeps.
216 define o-iterator-doit
217 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
219 object-suffixes-left := $(all-object-suffixes)
220 include $(o-iterator)
222 define o-iterator-doit
223 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
225 object-suffixes-left := $(all-object-suffixes)
226 include $(o-iterator)
228 define o-iterator-doit
229 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
231 object-suffixes-left := $(all-object-suffixes)
232 include $(o-iterator)
234 # Omit the objpfx rules when building in the source tree, because
235 # objpfx is empty and so these rules just override the ones above.
237 # Define first rules to find the source files in $(objpfx).
238 # Generated source files will end up there.
239 define o-iterator-doit
240 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
242 object-suffixes-left := $(all-object-suffixes)
243 include $(o-iterator)
245 define o-iterator-doit
246 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
248 object-suffixes-left := $(all-object-suffixes)
249 include $(o-iterator)
251 define o-iterator-doit
252 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
254 object-suffixes-left := $(all-object-suffixes)
255 include $(o-iterator)
258 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
259 # patterns matching sysdep directories whose assembly source files should
261 ifdef inhibit-sysdep-asm
262 define open-check-inhibit-asm
263 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
265 close-check-inhibit-asm = ;; esac ;
268 -include $(+sysdir_pfx)sysd-rules
269 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
270 # The value of $(+sysdep_dirs) the sysd-rules was computed for
271 # differs from the one we are using now. So force a rebuild of sysd-rules.
272 sysd-rules-force = FORCE
275 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
276 $(wildcard $(foreach dir,$(sysdirs),\
280 (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \
281 for dir in $(config-sysdirs:%='$$(..)%'); do \
282 for o in $(all-object-suffixes); do \
283 $(open-check-inhibit-asm) \
284 echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
285 \$$(compile-command.S)"; \
286 echo "\$$(objpfx)%$$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)rtld-%$$o: $$dir/%.s \$$(before-compile); \
291 \$$(compile-command.s)"; \
292 echo "\$$(objpfx)ptw-%$$o: $$dir/%.S \$$(before-compile); \
293 \$$(compile-command.S)"; \
294 echo "\$$(objpfx)ptw-%$$o: $$dir/%.s \$$(before-compile); \
295 \$$(compile-command.s)"; \
296 $(close-check-inhibit-asm) \
297 echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
298 \$$(compile-command.c)"; \
299 echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \
300 \$$(compile-command.c)"; \
301 echo "\$$(objpfx)ptw-%$$o: $$dir/%.c \$$(before-compile); \
302 \$$(compile-command.c)"; \
304 echo "\$$(objpfx)m_%.S: $$dir/s_%.S; \$$(+make-include-of-dep)"; \
305 echo "\$$(objpfx)m_%.c: $$dir/s_%.c; \$$(+make-include-of-dep)"; \
307 echo 'sysd-rules-done = t') > $@T
310 ifndef sysd-rules-done
311 # Don't do deps until this exists, because it provides rules to make the deps.
315 # This is used by the m_%.[Sc] pattern rules in sysd-rules.
316 define +make-include-of-dep
317 echo '#include <$<>' > $@T
321 # Generate version maps, but wait until sysdep-subdirs is known
322 ifeq ($(sysd-sorted-done),t)
323 ifeq ($(versioning),yes)
324 -include $(common-objpfx)sysd-versions
325 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
326 common-generated += $(version-maps)
327 postclean-generated += sysd-versions Versions.all abi-versions.h \
328 Versions.def.v.i Versions.def.v Versions.v.i Versions.v
330 ifndef avoid-generated
331 ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
332 sysd-versions-force = FORCE
335 # See %.v/%.v.i implicit rules in Makeconfig.
336 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
337 $(wildcard $(add-ons:%=$(..)%/Versions.def))
338 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
339 $(common-objpfx)soversions.i \
340 $(common-objpfx)Versions.def.v
341 { while read which lib version setname; do \
342 test x"$$which" = xDEFAULT || continue; \
343 test -z "$$setname" || echo "$$lib : $$setname"; \
344 done < $(word 2,$^); \
346 } | LC_ALL=C $(AWK) -f $< > $@T
348 # See %.v/%.v.i implicit rules in Makeconfig.
349 $(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
350 $(wildcard $(sysdirs:%=%/Versions)) \
351 $(common-objpfx)abi-versions.h \
352 $(sysd-versions-force)
353 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
354 $(common-objpfx)Versions.v \
355 $(..)scripts/versions.awk
356 ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
358 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
359 -v move_if_change='$(move-if-change)' \
363 endif # avoid-generated
364 endif # $(versioning) = yes
365 endif # sysd-sorted-done
367 # Generate .dT files as we compile.
368 compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
369 compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
370 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) $(compile-mkdep-flags)
371 compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
373 # GCC can grok options after the file name, and it looks nicer that way.
374 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
375 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
376 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
377 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
378 $(ASFLAGS) $(ASFLAGS-$(suffix $@))
379 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
381 # We need this for the output to go in the right place. It will default to
382 # empty if make was configured to work with a cc that can't grok -c and -o
383 # together. You can't compile the C library with such a compiler.
384 OUTPUT_OPTION = -o $@
386 # We need the $(CFLAGS) to be in there to have the right predefines during
387 # the dependency run for C sources. But having it for assembly sources can
388 # get the wrong predefines.
389 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
392 $(make-target-directory)
393 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
394 $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
395 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
396 $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
397 mv -f $(@:.d=.T) $@ $(generate-md5)
401 # Continuation lines here are dangerous because they introduce spaces!
402 define sed-remove-objpfx
403 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
404 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
408 # Modify the list of routines we build for different targets
410 ifeq (yesyes,$(build-shared)$(elf))
411 ifndef libc.so-version
412 # Undefine this because it can't work when we libc.so is unversioned.
413 static-only-routines =
417 # Bounded pointer thunks are only built for *.ob
418 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
420 elide-routines.oS += $(filter-out $(static-only-routines),\
421 $(routines) $(aux) $(sysdep_routines)) \
423 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
425 # If we have versioned code we don't need the old versions in any of the
427 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
428 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
429 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
430 elide-routines.ob += $(shared-only-routines)
432 # Shared library building.
434 ifeq (yes,$(build-shared))
436 # Reference map file only when versioning is selected and a map file name
438 ifeq ($(versioning),yes)
439 map-file = $(firstword $($(@F:.so=-map)) \
440 $(addprefix $(common-objpfx), \
441 $(filter $(@F:.so=.map),$(version-maps))))
442 load-map-file = $(map-file:%=-Wl,--version-script=%)
445 # Pattern rule to build a shared object from an archive of PIC objects.
446 # This must come after the installation rules so Make doesn't try to
447 # build shared libraries in place from the installed *_pic.a files.
448 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
449 # on other shared objects.
450 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
451 ifneq (,$(findstring aix,$(config-os)))
453 dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
458 define build-shlib-helper
459 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
460 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(config-LDFLAGS) \
461 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
462 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
463 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
464 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
465 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
468 ifneq (,$(findstring aix,$(config-os)))
469 define build-shlib-helper
470 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
471 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
472 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
473 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
474 -L$(subst :, -L,$(rpath-link))
481 # binutils only position loadable notes into the first page for binaries,
482 # not for shared objects
483 $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
484 $(LINK.o) -shared -Wl,-O1 \
485 -nostdlib -nostartfiles \
486 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
487 -Wl,--verbose 2>&1 | \
489 -e '/^=========/,/^=========/!d;/^=========/d' \
490 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
491 -e 's/^.*\*(\.dynbss).*$$/& \
492 PROVIDE(__start___libc_freeres_ptrs = .); \
493 *(__libc_freeres_ptrs) \
494 PROVIDE(__stop___libc_freeres_ptrs = .);/'\
495 -e 's@^.*\*(\.jcr).*$$@& \
496 PROVIDE(__start___libc_subfreeres = .);\
497 __libc_subfreeres : { *(__libc_subfreeres) }\
498 PROVIDE(__stop___libc_subfreeres = .);\
499 PROVIDE(__start___libc_atexit = .);\
500 __libc_atexit : { *(__libc_atexit) }\
501 PROVIDE(__stop___libc_atexit = .);\
502 PROVIDE(__start___libc_thread_subfreeres = .);\
503 __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
504 PROVIDE(__stop___libc_thread_subfreeres = .);\
505 /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
507 common-generated += shlib.lds
510 $(build-shlib-helper) -o $@ -T $(common-objpfx)shlib.lds \
511 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
514 ifneq (,$(findstring aix,$(config-os)))
516 $(build-shlib-helper) \
518 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
519 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
522 $(build-shlib-helper) \
523 $(build-shlib-objlist)
528 ifneq (,$(findstring aix,$(config-os)))
529 define build-module-helper
530 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
531 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
533 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
534 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
537 define build-module-helper
538 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
539 $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
540 -B$(csu-objpfx) $(load-map-file) \
541 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
542 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
546 # This macro is similar to build-shlib but it does not define a soname
547 # and it does not depend on the destination name to start with `lib'.
549 # binutils only position loadable notes into the first page for binaries,
550 # not for shared objects
552 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
553 $(csu-objpfx)abi-note.o $(build-module-objlist)
556 ifneq (,$(findstring aix,$(config-os)))
558 $(build-module-helper) \
560 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
561 $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
566 $(build-module-helper) \
568 $(build-module-objlist)
573 build-module-helper-objlist = \
574 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
575 $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^))
576 whole-archive := -Wl,--whole-archive
578 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
579 build-shlib-objlist = $(build-module-helper-objlist) \
580 $(LDLIBS-$(@F:lib%.so=%).so)
582 # Don't try to use -lc when making libc.so itself.
583 # Also omits crti.o and crtn.o, which we do not want
584 # since we define our own `.init' section specially.
585 LDFLAGS-c.so = -nostdlib -nostartfiles
586 # But we still want to link libc.so against $(libc.so-gnulib).
587 LDLIBS-c.so += $(libc.so-gnulib)
588 # Give libc.so an entry point and make it directly runnable itself.
589 LDFLAGS-c.so += -e __libc_main
590 # If lazy relocation is disabled add the -z now flag.
591 ifeq ($(bind-now),yes)
592 LDFLAGS-c.so += -Wl,-z,now
594 # Pre-link the objects of libc_pic.a so that we can locally resolve
595 # COMMON symbols before we link against ld.so. This is because ld.so
596 # contains some of libc_pic.a already, which will prevent the COMMONs
597 # from being allocated in libc.so, which introduces evil dependencies
598 # between libc.so and ld.so, which can make it impossible to upgrade.
600 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
601 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
602 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
603 # Use our own special initializer and finalizer files for libc.so.
604 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
605 $(common-objpfx)libc_pic.os \
606 $(elfobjdir)/sofini.os \
607 $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
608 $(common-objpfx)shlib.lds
610 ifeq ($(versioning),yes)
611 $(common-objpfx)libc.so: $(common-objpfx)libc.map
613 common-generated += libc.so libc_pic.os
614 ifdef libc.so-version
615 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
617 common-generated += libc.so$(libc.so-version)
621 ifneq (,$(findstring aix,$(config-os)))
622 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
625 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
626 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
627 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
628 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
629 -bE:$(common-objpfx)syscalls.exp \
630 -bI:$(common-objpfx)syscalls.exp \
631 -L$(common-objpfx) -o $@ $^
632 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
633 cp $@ $(common-objpfx)shr.o
634 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
638 # Figure out the source filenames in this directory.
640 override sources := $(addsuffix .c,\
641 $(filter-out $(elided-routines),\
644 sysdep_routines := $(sysdep_routines)
646 headers := $(headers) $(sysdep_headers)
648 # This is the list of all object files, gotten by
649 # replacing every ".c" in `sources' with a ".o".
650 # We also add bounded-pointer thunks, which are later
651 # elided for all suffixes except for `.ob'.
652 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
653 $(patsubst %,$(bppfx)%.o,\
654 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
657 # The makefile may define $(extra-libs) with `libfoo libbar'
658 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
660 # extra-lib.mk is included once for each extra lib to define rules
661 # to build it, and to add its objects to the various variables.
662 # During its evaluation, $(lib) is set to the name of the library.
663 extra-libs-left := $(extra-libs)
664 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
668 # The makefile may define $(modules-names) # to build additional
671 # extra-lib.mk is included once for each extra lib to define rules
672 # to build it, and to add its objects to the various variables.
673 # During its evaluation, $(lib) is set to the name of the library.
674 extra-modules-left := $(modules-names)
675 include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
678 +depfiles := $(sources:.c=.d) \
679 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
680 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
681 ifeq ($(build-programs),yes)
682 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
684 +depfiles := $(addprefix $(objpfx),\
685 $(filter-out $(addsuffix .d,$(omit-deps)),\
687 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
688 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
689 $(wildcard $(all-dt-files:.dt=.d))
691 # This is a funny rule in that it removes its input file.
693 @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
694 mv -f $(@:.d=.T) $@ && \
697 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
698 # They will be generated when they're needed, and trying too early won't work.
699 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
700 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
705 -include $(+depfiles)
709 # Maximize efficiency by minimizing the number of rules.
710 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
711 # Don't define any builtin rules.
712 MAKEFLAGS := $(MAKEFLAGS)r
714 # Generic rule for making directories.
716 # mkdir isn't smart enough to strip a trailing /.
719 # Make sure that object files are not removed
720 # when they are intermediates between sources and library members.
721 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
723 # Make sure that the parent library archive is never removed.
724 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
726 # Use the verbose option of ar and tar when not running silently.
727 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
733 ARFLAGS := r$(verbose)
734 CREATE_ARFLAGS := cru$(verbose)
736 # This makes all the object files in the parent library archive.
738 .PHONY: lib lib-noranlib
739 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
740 lib-noranlib: libobjs
742 # For object-suffix $o, the list of objects with that suffix.
743 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
744 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
745 $(elide-routines$o)),\
747 $(addprefix $(objpfx),$(o-objects$o))
749 others: $(addprefix $(objpfx),$(install-lib))
753 # Create the stamp$o files to keep the parent makefile happy.
754 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
755 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
756 $(make-target-directory)
760 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
761 # timestamp file; these rules (one explicit rule is generated for each
762 # object suffix) write a list of objects to update in the stamp file.
763 # The parent will then actually add them all to the archive in the
764 # archive rule, below.
765 define o-iterator-doit
766 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
769 $(make-target-directory)
770 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
773 object-suffixes-left := $(object-suffixes-for-libc)
774 include $(o-iterator)
778 # Now define explicit rules to build the library archives; these depend
779 # on the stamp files built above.
780 define o-iterator-doit
781 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
782 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
785 cd $(common-objdir) && \
786 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
789 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
790 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
792 $(subdirs-stamps): subdir_lib;
794 object-suffixes-left = $(object-suffixes-for-libc)
795 include $(o-iterator)
798 # This makes all the object files.
799 .PHONY: objects objs libobjs extra-objs
800 objects objs: libobjs extra-objs
801 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
802 extra-objs: $(addprefix $(objpfx),$(extra-objs))
804 # Canned sequence for building an extra library archive.
805 define build-extra-lib
806 $(patsubst %/,cd % &&,$(objpfx)) \
807 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
808 $(patsubst $(objpfx)%,%,$^)
814 .PHONY: force-install
817 # $(install-lib) are installed from the object directory into $(libdir);
818 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
819 # unless they also appear in $(non-lib.a). $(install-data) are installed
820 # as they are into $(datadir). $(headers) are installed as they are in
821 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
822 # are installed from the object directory into $(bindir), $(bindir) and
823 # $(sbindir), respectively. $(install-others) are absolute path names of
824 # files to install; rules to install them are defined elsewhere.
826 # The simple library name to install libc.a under.
827 # This could be defined by a sysdep Makefile.
833 $(make-target-directory)
834 $(INSTALL_DATA) $< $@
837 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
838 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
839 define make-target-directory
840 $(addprefix $(..)./scripts/mkinstalldirs ,\
841 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
844 # Any directory (parent or subdir) should install libc.a; this way
845 # "make install" in a subdir is guaranteed to install everything it changes.
846 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
847 $(inst_libdir)/$(patsubst %,$(libtype$o),\
848 $(libprefix)$(libc-name)))
849 install: $(installed-libcs)
850 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
851 $(make-target-directory)
852 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
853 # Running ranlib after installing makes the __.SYMDEF time stamp up to
854 # date, which avoids messages from some linkers.
857 define do-install-program
858 $(make-target-directory)
859 $(INSTALL_PROGRAM) $< $@.new
863 define do-install-script
864 $(make-target-directory)
865 $(INSTALL_SCRIPT) $< $@.new
869 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
870 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
872 ifeq (yes,$(build-shared))
873 # Find which .so's have versions.
874 versioned := $(strip $(foreach so,$(install-lib.so),\
875 $(patsubst %,$(so),$($(so)-version))))
877 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
878 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
880 # For versioned libraries, we install three files:
881 # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
882 # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
883 # $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
884 V := $(firstword $($(subdir)-version) $(version))
885 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
886 $(foreach L,$(install-lib.so-versioned),\
888 $(inst_slibdir)/$(L:.so=)-$V.so \
889 $(inst_slibdir)/$L$($L-version))
891 # Install all the unversioned shared libraries.
892 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
893 $(objpfx)%.so $(+force)
894 $(do-install-program)
896 ifneq ($(findstring -s,$(LN_S)),)
899 $(SHELL) $(..)scripts/rellns-sh $< $@.new
903 # If we have no symbolic links don't bother with rellns-sh.
911 ifeq (yes,$(build-shared))
912 ifeq (no,$(cross-compiling))
913 symbolic-link-prog := $(common-objpfx)elf/sln
914 symbolic-link-list := $(common-objpfx)elf/symlink.list
915 define make-shlib-link
916 echo $(<F) $@ >> $(symbolic-link-list)
918 else # cross-compiling
919 # We need a definition that can be used by elf/Makefile's install rules.
920 symbolic-link-prog = $(LN_S)
923 ifndef make-shlib-link
924 define make-shlib-link
930 ifdef libc.so-version
931 # For a library specified to be version N, install three files:
932 # libc.so -> libc.so.N (e.g. libc.so.6)
933 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
935 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
938 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
939 $(do-install-program)
940 install: $(inst_slibdir)/libc.so$(libc.so-version)
942 # This fragment of linker script gives the OUTPUT_FORMAT statement
943 # for the configuration we are building. We put this statement into
944 # the linker scripts we install for -lc et al so that they will not be
945 # used by a link for a different format on a multi-architecture system.
946 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
947 $(common-objpfx)config.make \
948 $(common-objpfx)config.h $(..)Makerules
949 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
950 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
951 | sed -n -f $< > $@.new
954 common-generated += format.lds
957 # What we install as libc.so for programs to link against is in fact a
958 # link script. It contains references for the various libraries we need.
959 # The libc.so object is not complete since some functions are only defined
960 # in libc_nonshared.a.
961 # We need to use absolute paths since otherwise local copies (if they exist)
962 # of the files are taken by the linker.
963 install: $(inst_libdir)/libc.so
964 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
965 $(common-objpfx)libc.so$(libc.so-version) \
966 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
967 $(libprefix)$(libc-name)) \
969 (echo '/* GNU ld script';\
970 echo ' Use the shared library, but some functions are only in';\
971 echo ' the static library, so try that secondarily. */';\
973 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
974 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
975 ' AS_NEEDED (' $(inst_slibdir)/$(rtld-installed-name) ') )' \
982 install: $(inst_slibdir)/libc.so
983 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
984 $(do-install-program)
987 ifneq (,$(versioned))
988 # Produce three sets of rules as above for all the smaller versioned libraries.
990 define o-iterator-doit
991 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
993 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
994 ifneq (,$(object-suffixes-left))
995 include $(o-iterator)
998 # Make symlinks in the build directory, because the versioned names might
999 # be referenced by a DT_NEEDED in another library.
1000 define o-iterator-doit
1001 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
1003 object-suffixes-left := $(versioned)
1004 include $(o-iterator)
1006 generated += $(foreach o,$(versioned),$o$($o-version))
1008 ifeq (,$($(subdir)-version))
1009 define o-iterator-doit
1010 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
1014 object-suffixes-left := $(versioned)
1015 include $(o-iterator)
1017 define o-iterator-doit
1018 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
1019 $$(do-install-program)
1021 object-suffixes-left := $(versioned)
1022 include $(o-iterator)
1024 define o-iterator-doit
1025 $(inst_slibdir)/$o$($o-version): \
1026 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1029 object-suffixes-left := $(versioned)
1030 include $(o-iterator)
1032 define o-iterator-doit
1033 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1034 $$(do-install-program)
1036 object-suffixes-left := $(versioned)
1037 include $(o-iterator)
1041 define do-install-so
1042 $(do-install-program)
1043 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1044 $(filter-out %.so,$@))
1047 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1048 $(foreach v,$(so-versions),\
1049 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1052 $(foreach v,$(so-versions),\
1053 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1058 $(addprefix $(inst_bindir)/,$(install-bin)): \
1059 $(inst_bindir)/%: $(objpfx)% $(+force)
1060 $(do-install-program)
1062 ifdef install-bin-script
1063 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1064 $(inst_bindir)/%: $(objpfx)% $(+force)
1065 $(do-install-script)
1067 ifdef install-rootsbin
1068 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1069 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1070 $(do-install-program)
1073 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1074 $(inst_sbindir)/%: $(objpfx)% $(+force)
1075 $(do-install-program)
1078 install-lib.a := $(filter lib%.a,$(install-lib))
1079 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1080 ifdef install-lib-non.a
1081 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1082 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1086 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1087 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1089 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
1093 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1096 headers := $(strip $(headers))
1098 $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
1102 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1103 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1104 install-data-nosubdir install-headers-nosubdir
1105 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1106 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1107 install-rootsbin-nosubdir: \
1108 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1109 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1110 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1111 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1112 $(addprefix $(libprefix),$(install-lib-non.a)))
1113 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1114 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1115 install-others-nosubdir: $(install-others)
1117 # We need all the `-nosubdir' targets so that `install' in the parent
1118 # doesn't depend on several things which each iterate over the subdirs.
1119 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1120 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1121 install-%:: install-%-nosubdir ;
1123 .PHONY: install install-no-libc.a-nosubdir
1124 ifeq ($(build-programs),yes)
1125 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1126 install-bin-nosubdir install-bin-script-nosubdir \
1127 install-lib-nosubdir install-others-nosubdir \
1128 install-rootsbin-nosubdir install-sbin-nosubdir
1130 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1131 install-lib-nosubdir install-others-nosubdir
1133 install: install-no-libc.a-nosubdir
1135 # Command to compile $< in $(objdir) using the native libraries.
1136 define native-compile
1137 $(make-target-directory)
1138 $(patsubst %/,cd % &&,$(objpfx)) \
1139 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1140 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1143 # Command to compile $< in $(common-objdir) using the native libraries.
1144 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1145 define common-objdir-compile
1146 $(patsubst %/,cd % &&,$(objpfx)) \
1147 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1148 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1151 # We always want to use configuration definitions.
1152 # Note that this is only used for commands running in $(objpfx).
1153 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1155 # Support the GNU standard name for this target.
1158 # Special target to run tests which cannot be run unconditionally.
1159 # Maintainers should use this target.
1163 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1164 ifneq (,$(all-nonlib))
1165 cpp-srcs-left = $(all-nonlib:=.c)
1167 include $(patsubst %,$(..)cppflags-iterator.mk,$(all-nonlib))
1170 # The include magic above causes those files to use this variable for flags.
1171 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1174 ifeq ($(versioning),yes)
1175 # Generate normalized lists of symbols, versions, and data sizes.
1176 # This is handy for checking against existing library binaries.
1178 %.symlist: $(..)scripts/abilist.awk %.dynsym
1179 LC_ALL=C $(AWK) -f $^ > $@T
1183 $(OBJDUMP) --dynamic-syms $< > $@T
1186 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1187 $(..)abilist/%.abilist $(objpfx)%.symlist
1189 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1190 $(..)abilist/%.abilist $(common-objpfx)%.symlist
1194 $(AWK) -f $< -v 'config=$(check-abi-config)' \
1195 $(patsubst %,-v 'lastversion=%',$($*-abi-frozen)) \
1196 $(filter %.abilist,$^) \
1197 | { diff -p -U 0 - $(filter %.symlist,$^) $(check-abi-warn) ; }
1199 ifeq ($(enable-check-abi),warn)
1200 check-abi-warn = || echo '*** WARNING: $*.so failed ABI check'
1203 ifeq ($(firstword $(sysd-sorted-done) f)$(firstword $(generating) f),tf)
1204 -include $(common-objpfx)tls.make
1206 ifeq ($(use-tls),yes)
1209 ifeq ($(use-thread),yes)
1210 config-tls := thread
1212 check-abi-config := \
1213 $(config-machine)-$(config-vendor)-$(config-os)/$(config-tls)
1216 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1219 update-abi-%: $(..)scripts/merge-abilist.awk $(..)abilist/%.abilist \
1220 $(common-objpfx)%.symlist
1222 ifndef update-abi-config
1224 @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2
1228 LC_ALL=C $(AWK) -v config='$(update-abi-config)' -f $^ \
1229 > $(..)abilist/$*.abilist.new
1230 @if cmp -s $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist 2> /dev/null; \
1231 then rm -f $(..)abilist/$*.abilist.new; \
1232 echo '+++ $(..)abilist/$*.abilist is unchanged'; \
1233 else mv -f $(..)abilist/$*.abilist.new $(..)abilist/$*.abilist; \
1234 echo '*** Now check $*.abilist changes for correctness ***'; \
1239 .PHONY: update-abi check-abi
1240 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1241 check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
1243 subdir_check-abi: check-abi
1244 subdir_update-abi: update-abi
1246 check-abi: subdir_check-abi
1247 update-abi: subdir_update-abi
1250 ifeq ($(subdir),elf)
1251 check-abi: check-abi-libc
1252 update-abi: update-abi-libc
1253 common-generated += libc.symlist
1256 ifeq ($(build-shared),yes)
1257 ifneq ($(enable-check-abi),no)
1266 # There's no good place to put this - here will do.
1267 ifeq ($(filter %posix, $(sysdirs)),)
1278 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1280 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1281 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1282 $(common-objpfx)config.make
1283 $(make-target-directory)
1284 { echo '#include "$(..)posix/bits/posix1_lim.h"'; \
1285 echo '#define _LIBC 1'; \
1286 echo '#include "$(..)misc/sys/uio.h"'; } | \
1287 $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \
1288 $(+includes) -xc - -o $(@:st=hT)
1289 sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
1290 $(@:st=dT) > $(@:st=dt)
1291 mv -f $(@:st=dt) $(@:st=d)
1292 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
1293 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
1294 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
1295 fopen_max=$${fopen_max:-16}; \
1296 filename_max=$${filename_max:-1024}; \
1297 if [ -z "$$iov_max" ]; then \
1298 define_iov_max="# undef IOV_MAX"; \
1300 define_iov_max="# define IOV_MAX $$iov_max"; \
1302 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
1303 -e "s/@FILENAME_MAX@/$$filename_max/" \
1304 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
1305 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
1306 -e "s/@L_ctermid@/$(L_ctermid)/" \
1307 -e "s/@L_cuserid@/$(L_cuserid)/" \
1308 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
1310 $(move-if-change) $(@:st=h.new) $(@:st=h)
1311 # Remove these last so that they can be examined if something went wrong.
1312 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1316 -include $(stdio_lim:h=d)
1318 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1321 TAGS: $(objpfx)distinfo $(..)MakeTAGS
1322 $(MAKE) $(addprefix -f ,$^) $@
1324 $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE
1325 $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
1329 .PHONY: echo-headers
1333 %.bz2: %; bzip2 -9vk $<
1334 %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
1336 # Common cleaning targets.
1338 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1340 mostlyclean: common-mostlyclean
1343 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1345 $(addsuffix -bp.out,$(tests) $(xtests) \
1348 # Remove the object files.
1350 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1351 $(others) $(sysdep-others) stubs \
1352 $(addsuffix .o,$(tests) $(xtests) \
1353 $(test-srcs) $(others) \
1355 $(addsuffix -bp,$(tests) $(xtests) \
1357 $(addsuffix .out,$(tests) $(xtests) \
1359 $(addsuffix -bp.out,$(tests) $(xtests) \
1361 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
1363 $(install-lib.so:%.so=%_pic.a))
1365 -rm -f $(objpfx)rtld-*.os
1368 $(foreach o,$(object-suffixes-for-libc),
1369 -rm -f $(objpfx)stamp$o $(o-objects))
1372 # Also remove the dependencies and generated source files.
1373 common-clean: common-mostlyclean
1374 -rm -f $(addprefix $(objpfx),$(generated))
1375 -rm -f $(objpfx)*.d $(objpfx)*.dt
1376 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1377 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1378 -rm -f $(objpfx)distinfo
1380 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1381 # for each function which is a stub. We grovel over all the .d files
1382 # looking for references to <stub-tag.h>. Then we grovel over each
1383 # referenced source file to see what stub function it defines.
1386 .PHONY: stubs # The parent Makefile calls this target.
1387 stubs: $(objpfx)stubs
1389 objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
1390 $(addprefix $(objpfx),$(extra-objs))
1391 $(objpfx)stubs: $(objs-for-stubs)
1392 ifneq (,$(strip $(objs-for-stubs)))
1393 $(OBJDUMP) -h $^ | \
1394 $(AWK) '/\.gnu\.glibc-stub\./ { \
1395 sub(/\.gnu\.glibc-stub\./, "", $$2); \
1397 END { for (s in stubs) print "#define __stub_" s }' > $@T
1403 # This information is not used for making distributions any more.
1404 # But it's used by MakeTAGS for making TAGS files and the .pot files.
1405 $(objpfx)distinfo: Makefile $(..)Makerules \
1406 $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile))
1407 $(make-target-directory)
1411 define distinfo-vars
1413 echo > $@.new 'subdir := $(subdir)'
1414 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
1415 headers sysdep_headers distribute dont_distribute generated \
1416 others tests xtests test-srcs extra-libs versioned \
1417 $(extra-libs:%=%-routines) \
1418 $(addprefix install-,lib lib.so data bin bin-script sbin others),
1419 echo >> $@.new '$(subdir)-$(var) := $($(var))'
1420 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
1423 ifneq (,$(strip $(gpl2lgpl)))
1424 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1425 # Snarf from the master source and frob the copying notice.
1426 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1428 # So I don't edit them by mistake.
1431 ifeq ($(with-cvs),yes)
1432 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@