1 # Copyright (C) 1991-1999,2000,01,02 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 # When we have no deps pass doing it, then make sure the subdirectory
129 # for object files gets created.
132 before-compile += $(objpfx).
134 $(make-target-directory)
138 # Remove existing files from `before-compile'. Things are added there when
139 # they must exist for dependency generation to work right, but once they
140 # exist there is no further need for every single file to depend on them,
141 # and those gratuitous dependencies result in many gratuitous
143 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
145 # Don't let any before-compile file be an intermediate and get removed.
150 # If a makefile needs to do something conditional on something that
151 # can only be figured out from headers, write a FOO.make.c input
152 # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
153 # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
154 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules
156 (echo '# Generated from $*.make.c by Makerules.'; \
157 SUNPRO_DEPENDENCIES='$@.dT $$(common-objpfx)$*.make' \
158 $(CC) $(CFLAGS) $(CPPFLAGS) -E $< \
159 | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \
160 echo 'common-generated += $(@F)'; \
161 sed $(sed-remove-objpfx) $@.dT; rm -f $@.dT) > $@T
164 # Generate an ordered list of implicit rules which find the source files in
165 # each sysdep directory. The old method was to use vpath to search all the
166 # sysdep directories. However, that had the problem that a .S file in a
167 # later directory would be chosen over a .c file in an earlier directory,
168 # which does not preserve the desired sysdeps ordering behavior.
170 # When making the list of .d files to include, we can't know which ones
171 # have source in .s files, and thus do not in fact need a .d file.
172 # So we must define rules to make .d files for .s files.
173 define make-dummy-dep
174 $(addprefix ln $(common-objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
176 $(common-objpfx)dummy.d:
177 echo '# .s files cannot contain includes, so they need no deps.' > $@
179 # It matters that this set of rules, for compiling from sources in
180 # the current directory (the $srcdir/$subdir) come before the
181 # generated sysdep rules in included from sysd-rules below. When
182 # compiling in the source tree, generated sources go into the current
183 # directory, and those should be chosen before any sources in sysdeps.
184 define o-iterator-doit
185 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
187 object-suffixes-left := $(all-object-suffixes)
188 include $(o-iterator)
189 $(objpfx)%.d: %.S $(before-compile); $(+make-deps)
191 define o-iterator-doit
192 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
194 object-suffixes-left := $(all-object-suffixes)
195 include $(o-iterator)
196 $(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep)
198 define o-iterator-doit
199 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
201 object-suffixes-left := $(all-object-suffixes)
202 include $(o-iterator)
203 $(objpfx)%.d: %.c $(before-compile); $(+make-deps)
205 # Omit the objpfx rules when building in the source tree, because
206 # objpfx is empty and so these rules just override the ones above.
208 # Define first rules to find the source files in $(objpfx).
209 # Generated source files will end up there.
210 define o-iterator-doit
211 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
213 object-suffixes-left := $(all-object-suffixes)
214 include $(o-iterator)
215 $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps)
217 define o-iterator-doit
218 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
220 object-suffixes-left := $(all-object-suffixes)
221 include $(o-iterator)
222 $(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep)
224 define o-iterator-doit
225 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
227 object-suffixes-left := $(all-object-suffixes)
228 include $(o-iterator)
229 $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps)
232 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
233 # patterns matching sysdep directories whose assembly source files should
235 ifdef inhibit-sysdep-asm
236 define open-check-inhibit-asm
237 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
239 close-check-inhibit-asm = ;; esac ;
242 -include $(+sysdir_pfx)sysd-rules
243 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
244 # The value of $(+sysdep_dirs) the sysd-rules was computed for
245 # differs from the one we are using now. So force a rebuild of sysd-rules.
246 sysd-rules-force = FORCE
249 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
250 $(wildcard $(foreach dir,$(sysdirs),\
254 (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \
255 for dir in $(config-sysdirs:%='$$(..)%'); do \
256 for o in $(all-object-suffixes); do \
257 $(open-check-inhibit-asm) \
258 echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
259 \$$(compile-command.S)"; \
260 echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
261 \$$(compile-command.s)"; \
262 echo "\$$(objpfx)rtld-%$$o: $$dir/%.S \$$(before-compile); \
263 \$$(compile-command.S)"; \
264 echo "\$$(objpfx)rtld-%$$o: $$dir/%.s \$$(before-compile); \
265 \$$(compile-command.s)"; \
266 echo "\$$(objpfx)ptw-%$$o: $$dir/%.S \$$(before-compile); \
267 \$$(compile-command.S)"; \
268 echo "\$$(objpfx)ptw-%$$o: $$dir/%.s \$$(before-compile); \
269 \$$(compile-command.s)"; \
270 $(close-check-inhibit-asm) \
271 echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
272 \$$(compile-command.c)"; \
273 echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \
274 \$$(compile-command.c)"; \
275 echo "\$$(objpfx)ptw-%$$o: $$dir/%.c \$$(before-compile); \
276 \$$(compile-command.c)"; \
278 $(open-check-inhibit-asm) \
279 echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
280 \$$(make-dummy-dep)"; \
281 echo "\$$(objpfx)rtld-%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
282 \$$(make-dummy-dep)"; \
283 echo "\$$(objpfx)ptw-%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
284 \$$(make-dummy-dep)"; \
285 echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
287 echo "\$$(objpfx)rtld-%.d: $$dir/%.S \$$(before-compile); \
289 echo "\$$(objpfx)ptw-%.d: $$dir/%.S \$$(before-compile); \
291 $(close-check-inhibit-asm) \
292 echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \
294 echo "\$$(objpfx)rtld-%.d: $$dir/%.c \$$(before-compile); \
296 echo "\$$(objpfx)ptw-%.d: $$dir/%.c \$$(before-compile); \
298 echo "\$$(objpfx)m_%.S: $$dir/s_%.S; \$$(+make-include-of-dep)"; \
299 echo "\$$(objpfx)m_%.c: $$dir/s_%.c; \$$(+make-include-of-dep)"; \
301 echo 'sysd-rules-done = t') > $@T
304 ifndef sysd-rules-done
305 # Don't do deps until this exists, because it provides rules to make the deps.
309 # This is used by the m_%.[Sc] pattern rules in sysd-rules.
310 define +make-include-of-dep
311 echo '#include <$<>' > $@T
315 # Generate version maps, but wait until sysdep-subdirs is known
316 ifeq ($(sysd-sorted-done),t)
317 ifeq ($(versioning),yes)
318 -include $(common-objpfx)sysd-versions
319 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
320 common-generated += $(version-maps)
321 postclean-generated += sysd-versions Versions.all abi-versions.h \
322 Versions.def.v.i Versions.def.v Versions.v.i Versions.v
324 ifndef avoid-generated
325 ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
326 sysd-versions-force = FORCE
329 # See %.v/%.v.i implicit rules in Makeconfig.
330 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
331 $(wildcard $(add-ons:%=$(..)%/Versions.def))
332 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
333 $(common-objpfx)soversions.i \
334 $(common-objpfx)Versions.def.v
335 { while read lib version setname; do \
336 test -z "$$setname" || echo "$$lib : $$setname"; \
337 done < $(word 2,$^); \
339 } | LC_ALL=C $(AWK) -f $< > $@T
341 # See %.v/%.v.i implicit rules in Makeconfig.
342 $(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
343 $(wildcard $(sysdirs:%=%/Versions)) \
344 $(common-objpfx)abi-versions.h \
345 $(sysd-versions-force)
346 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
347 $(common-objpfx)Versions.v \
348 $(..)scripts/versions.awk
349 ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
351 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
352 -v move_if_change='$(move-if-change)' \
356 endif # avoid-generated
357 endif # $(versioning) = yes
358 endif # sysd-sorted-done
361 ifndef compile-command.S
362 compile-command.S = $(compile.S) $(OUTPUT_OPTION)
364 ifndef compile-command.s
365 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION)
367 ifndef compile-command.c
368 compile-command.c = $(compile.c) $(OUTPUT_OPTION)
371 # GCC can grok options after the file name, and it looks nicer that way.
372 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
374 $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
376 $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
377 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
379 # If we want to generate MD5 checksums for the sources do this now.
381 generate-md5 = ; rm -f $(@:.d=.md5); \
382 $(CC) -E $< $(CFLAGS) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
383 sed '/^\#/d;/^[[:space:]]*$$/d' | md5sum > $(@:.d=.md5)
388 # We need this for the output to go in the right place. It will default to
389 # empty if make was configured to work with a cc that can't grok -c and -o
390 # together. You can't compile the C library with such a compiler.
391 OUTPUT_OPTION = -o $@
393 # We need the $(CFLAGS) to be in there to have the right predefines during
394 # the dependency run for C sources. But having it for assembly sources can
395 # get the wrong predefines.
396 S-CPPFLAGS = $(asm-CPPFLAGS)
398 $(make-target-directory)
399 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
400 $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | sed \
401 -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
402 $(sed-remove-objpfx) > $(@:.d=.T)
403 mv -f $(@:.d=.T) $@ $(generate-md5)
406 # Continuation lines here are dangerous because they introduce spaces!
407 define sed-remove-objpfx
408 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
409 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
413 # Modify the list of routines we build for different targets
415 ifeq (yesyes,$(build-shared)$(elf))
416 ifndef libc.so-version
417 # Undefine this because it can't work when we libc.so is unversioned.
418 static-only-routines =
422 # Bounded pointer thunks are only built for *.ob
423 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
425 elide-routines.oS += $(filter-out $(static-only-routines),\
426 $(routines) $(aux) $(sysdep_routines)) \
428 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
430 # If we have versioned code we don't need the old versions in any of the
432 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
433 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
434 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
435 elide-routines.ob += $(shared-only-routines)
437 # Shared library building.
439 ifeq (yes,$(build-shared))
441 # Reference map file only when versioning is selected and a map file name
443 ifeq ($(versioning),yes)
444 map-file = $(firstword $($(@F:.so=-map)) \
445 $(addprefix $(common-objpfx), \
446 $(filter $(@F:.so=.map),$(version-maps))))
447 load-map-file = $(map-file:%=-Wl,--version-script=%)
450 # Pattern rule to build a shared object from an archive of PIC objects.
451 # This must come after the installation rules so Make doesn't try to
452 # build shared libraries in place from the installed *_pic.a files.
453 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
454 # on other shared objects.
455 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
456 ifneq (,$(findstring aix,$(config-os)))
458 dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
463 define build-shlib-helper
464 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
465 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
466 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
467 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
468 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
469 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
472 ifneq (,$(findstring aix,$(config-os)))
473 define build-shlib-helper
474 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
475 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
476 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
477 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
478 -L$(subst :, -L,$(rpath-link))
485 # binutils only position loadable notes into the first page for binaries,
486 # not for shared objects
488 $(build-shlib-helper) \
489 -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
490 $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
491 sed -e '/^=========/,/^=========/!d;/^=========/d' \
492 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
493 $(LDSEDCMD-$(@F:lib%.so=%).so) > $@.lds
495 $(build-shlib-helper) -o $@ -T $@.lds \
496 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
500 ifneq (,$(findstring aix,$(config-os)))
502 $(build-shlib-helper) \
504 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
505 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
508 $(build-shlib-helper) \
509 $(build-shlib-objlist)
514 ifneq (,$(findstring aix,$(config-os)))
515 define build-module-helper
516 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
517 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
519 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
520 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
523 define build-module-helper
524 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
525 -B$(csu-objpfx) $(load-map-file) \
526 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
527 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
531 # This macro is similar to build-shlib but it does not define a soname
532 # and it does not depend on the destination name to start with `lib'.
534 # binutils only position loadable notes into the first page for binaries,
535 # not for shared objects
537 $(build-module-helper) \
538 -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
539 $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
540 sed -e '/^=========/,/^=========/!d;/^=========/d' \
541 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
544 $(build-module-helper) -o $@ -T $@.lds \
545 $(csu-objpfx)abi-note.o $(build-module-objlist)
549 ifneq (,$(findstring aix,$(config-os)))
551 $(build-module-helper) \
553 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
554 $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
559 $(build-module-helper) \
561 $(build-module-objlist)
566 build-module-helper-objlist = \
567 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
568 $(filter-out $(map-file) $(+preinit) $(+postinit),$^))
569 whole-archive := -Wl,--whole-archive
571 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
572 build-shlib-objlist = $(build-module-helper-objlist) \
573 $(LDLIBS-$(@F:lib%.so=%).so)
575 # Don't try to use -lc when making libc.so itself.
576 # Also omits crti.o and crtn.o, which we do not want
577 # since we define our own `.init' section specially.
578 LDFLAGS-c.so = -nostdlib -nostartfiles
579 # But we still want to link libc.so against $(gnulib).
580 LDLIBS-c.so += $(gnulib)
581 # Give libc.so an entry point and make it directly runnable itself.
582 LDFLAGS-c.so += -e __libc_main
583 # Force the backward compatibility EH functions to be linked.
584 LDFLAGS-c.so += -u __register_frame
585 # Pre-link the objects of libc_pic.a so that we can locally resolve
586 # COMMON symbols before we link against ld.so. This is because ld.so
587 # contains some of libc_pic.a already, which will prevent the COMMONs
588 # from being allocated in libc.so, which introduces evil dependencies
589 # between libc.so and ld.so, which can make it impossible to upgrade.
591 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
592 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
593 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
594 LDSEDCMD-c.so = -e 's/^.*\*(\.dynbss).*$$/& __start___libc_freeres_ptrs = .; *(__libc_freeres_ptrs) __stop___libc_freeres_ptrs = .;/'
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
601 ifeq ($(versioning),yes)
602 $(common-objpfx)libc.so: $(common-objpfx)libc.map
604 common-generated += libc.so libc_pic.os
605 ifdef libc.so-version
606 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
608 common-generated += libc.so$(libc.so-version)
612 ifneq (,$(findstring aix,$(config-os)))
613 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
616 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
617 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
618 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
619 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
620 -bE:$(common-objpfx)syscalls.exp \
621 -bI:$(common-objpfx)syscalls.exp \
622 -L$(common-objpfx) -o $@ $^
623 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
624 cp $@ $(common-objpfx)shr.o
625 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
629 # Figure out the source filenames in this directory.
631 override sources := $(addsuffix .c,\
632 $(filter-out $(elided-routines),\
635 sysdep_routines := $(sysdep_routines)
637 headers := $(headers) $(sysdep_headers)
639 # This is the list of all object files, gotten by
640 # replacing every ".c" in `sources' with a ".o".
641 # We also add bounded-pointer thunks, which are later
642 # elided for all suffixes except for `.ob'.
643 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
644 $(patsubst %,$(bppfx)%.o,\
645 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
648 # The makefile may define $(extra-libs) with `libfoo libbar'
649 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
651 # extra-lib.mk is included once for each extra lib to define rules
652 # to build it, and to add its objects to the various variables.
653 # During its evaluation, $(lib) is set to the name of the library.
654 extra-libs-left := $(extra-libs)
655 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
658 +depfiles := $(sources:.c=.d) \
659 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
660 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
661 ifeq ($(build-programs),yes)
662 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
664 +depfiles := $(addprefix $(objpfx),\
665 $(filter-out $(addsuffix .d,$(omit-deps)),\
667 $(addprefix $(common-objpfx),$(gen-as-const-headers:.sym=.h.d))
671 -include $(+depfiles)
675 # Maximize efficiency by minimizing the number of rules.
676 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
677 # Don't define any builtin rules.
678 MAKEFLAGS := $(MAKEFLAGS)r
680 # Generic rule for making directories.
682 # mkdir isn't smart enough to strip a trailing /.
685 # Make sure that object files are not removed
686 # when they are intermediates between sources and library members.
687 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
689 # Make sure that the parent library archive is never removed.
690 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
692 # Use the verbose option of ar and tar when not running silently.
693 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
699 ARFLAGS := r$(verbose)
700 CREATE_ARFLAGS := cru$(verbose)
702 # This makes all the object files in the parent library archive.
704 .PHONY: lib lib-noranlib
705 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
706 lib-noranlib: libobjs
708 # For object-suffix $o, the list of objects with that suffix.
709 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
710 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
711 $(elide-routines$o)),\
713 $(addprefix $(objpfx),$(o-objects$o))
715 others: $(addprefix $(objpfx),$(install-lib))
719 # Create the stamp$o files to keep the parent makefile happy.
720 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
721 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
722 $(make-target-directory)
726 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
727 # timestamp file; these rules (one explicit rule is generated for each
728 # object suffix) write a list of objects to update in the stamp file.
729 # The parent will then actually add them all to the archive in the
730 # archive rule, below.
731 define o-iterator-doit
732 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
735 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
738 object-suffixes-left := $(object-suffixes-for-libc)
739 include $(o-iterator)
743 # Now define explicit rules to build the library archives; these depend
744 # on the stamp files built above.
745 define o-iterator-doit
746 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
747 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
750 cd $(common-objdir) && \
751 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
754 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
755 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
757 $(subdirs-stamps): subdir_lib;
759 object-suffixes-left = $(object-suffixes-for-libc)
760 include $(o-iterator)
763 # This makes all the object files.
764 .PHONY: objects objs libobjs extra-objs
765 objects objs: libobjs extra-objs
766 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
767 extra-objs: $(addprefix $(objpfx),$(extra-objs))
769 # Canned sequence for building an extra library archive.
770 define build-extra-lib
771 $(patsubst %/,cd % &&,$(objpfx)) \
772 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
773 $(patsubst $(objpfx)%,%,$^)
779 .PHONY: force-install
782 # $(install-lib) are installed from the object directory into $(libdir);
783 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
784 # unless they also appear in $(non-lib.a). $(install-data) are installed
785 # as they are into $(datadir). $(headers) are installed as they are in
786 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
787 # are installed from the object directory into $(bindir), $(bindir) and
788 # $(sbindir), respectively. $(install-others) are absolute path names of
789 # files to install; rules to install them are defined elsewhere.
791 # The simple library name to install libc.a under.
792 # This could be defined by a sysdep Makefile.
798 $(make-target-directory)
799 $(INSTALL_DATA) $< $@
802 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
803 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
804 define make-target-directory
805 $(addprefix $(..)./scripts/mkinstalldirs ,\
806 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
809 # Any directory (parent or subdir) should install libc.a; this way
810 # "make install" in a subdir is guaranteed to install everything it changes.
811 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
812 $(inst_libdir)/$(patsubst %,$(libtype$o),\
813 $(libprefix)$(libc-name)))
814 install: $(installed-libcs)
815 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
816 $(make-target-directory)
817 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
818 # Running ranlib after installing makes the __.SYMDEF time stamp up to
819 # date, which avoids messages from some linkers.
822 define do-install-program
823 $(make-target-directory)
824 $(INSTALL_PROGRAM) $< $@.new
828 define do-install-script
829 $(make-target-directory)
830 $(INSTALL_SCRIPT) $< $@.new
834 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
835 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
837 ifeq (yes,$(build-shared))
838 # Find which .so's have versions.
839 versioned := $(strip $(foreach so,$(install-lib.so),\
840 $(patsubst %,$(so),$($(so)-version))))
842 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
843 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
845 install-lib-nosubdir: $(install-lib.so-versioned:%=$(inst_libdir)/%) \
846 $(install-lib.so-unversioned:%=$(inst_slibdir)/%)
848 # Install all the unversioned shared libraries.
849 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
850 $(objpfx)%.so $(+force)
851 $(do-install-program)
853 ifneq ($(findstring -s,$(LN_S)),)
856 $(SHELL) $(..)scripts/rellns-sh $< $@.new
860 # If we have no symbolic links don't bother with rellns-sh.
868 ifeq (yes,$(build-shared))
869 ifeq (no,$(cross-compiling))
870 symbolic-link-prog := $(common-objpfx)elf/sln
871 symbolic-link-list := $(common-objpfx)elf/symlink.list
872 define make-shlib-link
873 echo $(<F) $@ >> $(symbolic-link-list)
875 else # cross-compiling
876 # We need a definition that can be used by elf/Makefile's install rules.
877 symbolic-link-prog = $(LN_S)
880 ifndef make-shlib-link
881 define make-shlib-link
887 ifdef libc.so-version
888 # For a library specified to be version N, install three files:
889 # libc.so -> libc.so.N (e.g. libc.so.6)
890 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
892 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
895 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
896 $(do-install-program)
897 install: $(inst_slibdir)/libc.so$(libc.so-version)
899 # This fragment of linker script gives the OUTPUT_FORMAT statement
900 # for the configuration we are building. We put this statement into
901 # the linker scripts we install for -lc et al so that they will not be
902 # used by a link for a different format on a multi-architecture system.
903 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
904 $(common-objpfx)config.make \
905 $(common-objpfx)config.h $(..)Makerules
906 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
907 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
908 | sed -n -f $< > $@.new
911 common-generated += format.lds
914 # What we install as libc.so for programs to link against is in fact a
915 # link script. It contains references for the various libraries we need.
916 # The libc.so object is not complete since some functions are only defined
917 # in libc_nonshared.a.
918 # We need to use absolute paths since otherwise local copies (if they exist)
919 # of the files are taken by the linker.
920 install: $(inst_libdir)/libc.so
921 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
922 $(common-objpfx)libc.so$(libc.so-version) \
923 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
924 $(libprefix)$(libc-name)) \
926 (echo '/* GNU ld script';\
927 echo ' Use the shared library, but some functions are only in';\
928 echo ' the static library, so try that secondarily. */';\
930 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
931 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
939 install: $(inst_slibdir)/libc.so
940 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
941 $(do-install-program)
944 ifneq (,$(versioned))
945 # Produce three sets of rules as above for all the smaller versioned libraries.
947 define o-iterator-doit
948 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
950 object-suffixes-left := $(versioned)
951 include $(o-iterator)
953 # Make symlinks in the build directory, because the versioned names might
954 # be referenced by a DT_NEEDED in another library.
955 define o-iterator-doit
956 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
958 object-suffixes-left := $(versioned)
959 include $(o-iterator)
961 generated += $(foreach o,$(versioned),$o$($o-version))
963 ifeq (,$($(subdir)-version))
964 define o-iterator-doit
965 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
969 object-suffixes-left := $(versioned)
970 include $(o-iterator)
972 define o-iterator-doit
973 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
974 $$(do-install-program)
976 object-suffixes-left := $(versioned)
977 include $(o-iterator)
979 define o-iterator-doit
980 $(inst_slibdir)/$o$($o-version): \
981 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
984 object-suffixes-left := $(versioned)
985 include $(o-iterator)
987 define o-iterator-doit
988 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
989 $$(do-install-program)
991 object-suffixes-left := $(versioned)
992 include $(o-iterator)
997 $(do-install-program)
998 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
999 $(filter-out %.so,$@))
1002 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1003 $(foreach v,$(so-versions),\
1004 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1007 $(foreach v,$(so-versions),\
1008 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1013 $(addprefix $(inst_bindir)/,$(install-bin)): \
1014 $(inst_bindir)/%: $(objpfx)% $(+force)
1015 $(do-install-program)
1017 ifdef install-bin-script
1018 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1019 $(inst_bindir)/%: $(objpfx)% $(+force)
1020 $(do-install-script)
1022 ifdef install-rootsbin
1023 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1024 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1025 $(do-install-program)
1028 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1029 $(inst_sbindir)/%: $(objpfx)% $(+force)
1030 $(do-install-program)
1033 install-lib.a := $(filter lib%.a,$(install-lib))
1034 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1035 ifdef install-lib-non.a
1036 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1037 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1041 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1042 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1044 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
1048 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1051 headers := $(strip $(headers))
1053 $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
1057 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1058 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1059 install-data-nosubdir install-headers-nosubdir
1060 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1061 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1062 install-rootsbin-nosubdir: \
1063 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1064 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1065 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1066 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1067 $(addprefix $(libprefix),$(install-lib-non.a)))
1068 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1069 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1070 install-others-nosubdir: $(install-others)
1072 # We need all the `-nosubdir' targets so that `install' in the parent
1073 # doesn't depend on several things which each iterate over the subdirs.
1074 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1075 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1076 install-%:: install-%-nosubdir ;
1078 .PHONY: install install-no-libc.a-nosubdir
1079 ifeq ($(build-programs),yes)
1080 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1081 install-bin-nosubdir install-bin-script-nosubdir \
1082 install-lib-nosubdir install-others-nosubdir \
1083 install-rootsbin-nosubdir install-sbin-nosubdir
1085 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1086 install-lib-nosubdir install-others-nosubdir
1088 install: install-no-libc.a-nosubdir
1090 # Command to compile $< in $(objdir) using the native libraries.
1091 define native-compile
1092 $(make-target-directory)
1093 $(patsubst %/,cd % &&,$(objpfx)) \
1094 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1095 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1098 # Command to compile $< in $(common-objdir) using the native libraries.
1099 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1100 define common-objdir-compile
1101 $(patsubst %/,cd % &&,$(objpfx)) \
1102 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1103 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1106 # We always want to use configuration definitions.
1107 # Note that this is only used for commands running in $(objpfx).
1108 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1110 # Support the GNU standard name for this target.
1113 # Special target to run tests which cannot be run unconditionally.
1114 # Maintainers should use this target.
1118 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1119 ifneq (,$(all-nonlib))
1120 cpp-srcs-left = $(all-nonlib:=.c)
1122 include $(patsubst %,$(..)cppflags-iterator.mk,$(all-nonlib))
1125 # The include magic above causes those files to use this variable for flags.
1126 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1129 ifeq ($(versioning),yes)
1130 # Generate normalized lists of symbols, versions, and data sizes.
1131 # This is handy for checking against existing library binaries.
1133 %.symlist: $(..)scripts/abilist.awk %.dynsym
1134 LC_ALL=C $(AWK) -f $^ > $@T
1138 $(OBJDUMP) --dynamic-syms $< > $@T
1141 vpath %.symlist $(objpfx) $(common-objpfx)
1142 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1146 -v 'config=$(config-machine)-$(config-vendor)-$(config-os)' \
1147 $(filter %.abilist,$^) \
1148 | diff -pu0 - $(filter %.symlist,$^)
1150 update-abi-%: $(..)scripts/merge-abilist.awk %.abilist %.symlist
1151 ifndef update-abi-config
1152 @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2
1154 LC_ALL=C $(AWK) -v config=$(update-abi-config) -f $^ > $*.abilist.new
1155 mv -f $*.abilist.new $*.abilist
1156 @echo '*** Now check $*.abilist changes for correctness ***'
1159 .PHONY: update-abi check-abi
1160 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1161 check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
1163 subdir_check-abi: check-abi
1164 subdir_update-abi: update-abi
1166 check-abi: subdir_check-abi
1167 update-abi: subdir_update-abi
1170 # Enable this well all the .abilist files are in place.
1172 generated += $(install-lib.so-versioned:.so=.symlist)
1174 ifeq ($(subdir),elf)
1175 check-abi: check-abi-libc
1176 update-abi: update-abi-libc
1177 common-generated += libc.symlist
1182 # Generating headers for assembly constants.
1183 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk %.sym
1184 $(AWK) -f $< $(filter %.sym,$^) \
1185 | $(CC) -S -o - $(CFLAGS) $(CPPFLAGS) -x c - \
1186 -MD -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)' \
1187 | 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
1188 sed $(sed-remove-objpfx) \
1189 -e 's@ *\([^ \/][^ \]*\)@ $$(..)\1@g' \
1190 -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' \
1191 $(@:.h=.h.d)T > $(@:.h=.h.d)T2
1193 mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
1194 mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
1195 vpath %.sym $(sysdirs)
1197 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
1200 TAGS: $(objpfx)distinfo $(..)MakeTAGS
1201 $(MAKE) $(addprefix -f ,$^) $@
1203 $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE
1204 $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
1208 .PHONY: echo-headers
1213 # Common cleaning targets.
1215 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1217 mostlyclean: common-mostlyclean
1220 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1222 $(addsuffix -bp.out,$(tests) $(xtests) \
1225 # Remove the object files.
1227 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1228 $(others) $(sysdep-others) stubs \
1229 $(addsuffix .o,$(tests) $(xtests) \
1230 $(test-srcs) $(others) \
1232 $(addsuffix -bp,$(tests) $(xtests) \
1234 $(addsuffix .out,$(tests) $(xtests) \
1236 $(addsuffix -bp.out,$(tests) $(xtests) \
1238 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
1240 $(install-lib.so:%.so=%_pic.a))
1242 -rm -f $(objpfx)rtld-*.os
1245 $(foreach o,$(object-suffixes-for-libc),
1246 -rm -f $(objpfx)stamp$o $(o-objects))
1249 # Also remove the dependencies and generated source files.
1250 common-clean: common-mostlyclean
1251 -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
1252 -rm -f $(objpfx)rtld-*.d
1253 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1254 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1255 -rm -f $(objpfx)distinfo
1257 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1258 # for each function which is a stub. We grovel over all the .d files
1259 # looking for references to <stub-tag.h>. Then we grovel over each
1260 # referenced source file to see what stub function it defines.
1263 .PHONY: stubs # The parent Makefile calls this target.
1264 stubs: $(objpfx)stubs
1266 s = $(sysdep_dir)/generic
1267 $(objpfx)stubs: $(+depfiles)
1268 # Use /dev/null since `...` might expand to empty.
1269 (s=`cd $s && $(PWD_P)`; \
1270 $(patsubst %/,cd % &&,$(objpfx)) \
1271 sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
1272 `sed -n -e '\@ $s/[^ ]*\.c@{; s@^.* $s/\([^ ]*\.c\).*$$@'"$$s"'/\1@; h; }' \
1273 -e '/stub-tag\.h/{; g; p; }' \
1274 $(patsubst $(objpfx)%,%,$^) /dev/null` \
1278 # Make the distribution tar file.
1281 dist: $(objpfx)distinfo $(..)Make-dist
1282 $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
1284 # Avoid depending on source files found in sysdeps dirs,
1285 # because the references affect implicit rule selection.
1286 dist: $(filter-out %.c %.S %.s,$(distribute))
1288 # We used to simply export all these variables, but that frequently made the
1289 # environment get too large. Instead, we write all the information into
1290 # a generated makefile fragment `distinfo', and then include it with -f in
1291 # the sub-make that makes the distribution (above).
1292 $(objpfx)distinfo: Makefile $(..)Makerules \
1293 $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile))
1294 $(make-target-directory)
1297 .PHONY: subdir_distinfo
1298 subdir_distinfo: $(objpfx)distinfo
1300 define distinfo-vars
1302 echo > $@.new 'subdir := $(subdir)'
1303 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
1304 headers sysdep_headers distribute dont_distribute generated \
1305 others tests xtests test-srcs extra-libs versioned \
1306 $(extra-libs:%=%-routines) \
1307 $(addprefix install-,lib lib.so data bin bin-script sbin others),
1308 echo >> $@.new '$(subdir)-$(var) := $($(var))'
1309 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
1312 ifneq (,$(strip $(gpl2lgpl)))
1313 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1314 # Snarf from the master source and frob the copying notice.
1315 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1317 # So I don't edit them by mistake.
1320 ifeq ($(with-cvs),yes)
1321 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@