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)
373 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) $(ASFLAGS-$(suffix $@))
374 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) $(ASFLAGS-$(suffix $@))
375 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
377 # If we want to generate MD5 checksums for the sources do this now.
379 generate-md5 = ; rm -f $(@:.d=.md5); \
380 $(CC) -E $< $(CFLAGS) $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | \
381 sed '/^\#/d;/^[[:space:]]*$$/d' | md5sum > $(@:.d=.md5)
386 # We need this for the output to go in the right place. It will default to
387 # empty if make was configured to work with a cc that can't grok -c and -o
388 # together. You can't compile the C library with such a compiler.
389 OUTPUT_OPTION = -o $@
391 # We need the $(CFLAGS) to be in there to have the right predefines during
392 # the dependency run for C sources. But having it for assembly sources can
393 # get the wrong predefines.
394 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
396 $(make-target-directory)
397 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
398 $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed \
399 -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
400 $(sed-remove-objpfx) > $(@:.d=.T)
401 mv -f $(@:.d=.T) $@ $(generate-md5)
404 # Continuation lines here are dangerous because they introduce spaces!
405 define sed-remove-objpfx
406 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
407 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
411 # Modify the list of routines we build for different targets
413 ifeq (yesyes,$(build-shared)$(elf))
414 ifndef libc.so-version
415 # Undefine this because it can't work when we libc.so is unversioned.
416 static-only-routines =
420 # Bounded pointer thunks are only built for *.ob
421 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
423 elide-routines.oS += $(filter-out $(static-only-routines),\
424 $(routines) $(aux) $(sysdep_routines)) \
426 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
428 # If we have versioned code we don't need the old versions in any of the
430 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
431 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
432 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
433 elide-routines.ob += $(shared-only-routines)
435 # Shared library building.
437 ifeq (yes,$(build-shared))
439 # Reference map file only when versioning is selected and a map file name
441 ifeq ($(versioning),yes)
442 map-file = $(firstword $($(@F:.so=-map)) \
443 $(addprefix $(common-objpfx), \
444 $(filter $(@F:.so=.map),$(version-maps))))
445 load-map-file = $(map-file:%=-Wl,--version-script=%)
448 # Pattern rule to build a shared object from an archive of PIC objects.
449 # This must come after the installation rules so Make doesn't try to
450 # build shared libraries in place from the installed *_pic.a files.
451 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
452 # on other shared objects.
453 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
454 ifneq (,$(findstring aix,$(config-os)))
456 dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
461 define build-shlib-helper
462 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
463 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
464 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
465 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
466 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
467 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
470 ifneq (,$(findstring aix,$(config-os)))
471 define build-shlib-helper
472 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
473 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
474 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
475 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
476 -L$(subst :, -L,$(rpath-link))
483 # binutils only position loadable notes into the first page for binaries,
484 # not for shared objects
486 $(build-shlib-helper) \
487 -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
488 $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
489 sed -e '/^=========/,/^=========/!d;/^=========/d' \
490 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
491 $(LDSEDCMD-$(@F:lib%.so=%).so) > $@.lds
493 $(build-shlib-helper) -o $@ -T $@.lds \
494 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
498 ifneq (,$(findstring aix,$(config-os)))
500 $(build-shlib-helper) \
502 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
503 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
506 $(build-shlib-helper) \
507 $(build-shlib-objlist)
512 ifneq (,$(findstring aix,$(config-os)))
513 define build-module-helper
514 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
515 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
517 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
518 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
521 define build-module-helper
522 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
523 -B$(csu-objpfx) $(load-map-file) \
524 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
525 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
529 # This macro is similar to build-shlib but it does not define a soname
530 # and it does not depend on the destination name to start with `lib'.
532 # binutils only position loadable notes into the first page for binaries,
533 # not for shared objects
535 $(build-module-helper) \
536 -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
537 $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
538 sed -e '/^=========/,/^=========/!d;/^=========/d' \
539 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
542 $(build-module-helper) -o $@ -T $@.lds \
543 $(csu-objpfx)abi-note.o $(build-module-objlist)
547 ifneq (,$(findstring aix,$(config-os)))
549 $(build-module-helper) \
551 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
552 $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
557 $(build-module-helper) \
559 $(build-module-objlist)
564 build-module-helper-objlist = \
565 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
566 $(filter-out $(map-file) $(+preinit) $(+postinit),$^))
567 whole-archive := -Wl,--whole-archive
569 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
570 build-shlib-objlist = $(build-module-helper-objlist) \
571 $(LDLIBS-$(@F:lib%.so=%).so)
573 # Don't try to use -lc when making libc.so itself.
574 # Also omits crti.o and crtn.o, which we do not want
575 # since we define our own `.init' section specially.
576 LDFLAGS-c.so = -nostdlib -nostartfiles
577 # But we still want to link libc.so against $(gnulib).
578 LDLIBS-c.so += $(gnulib)
579 # Give libc.so an entry point and make it directly runnable itself.
580 LDFLAGS-c.so += -e __libc_main
581 # Force the backward compatibility EH functions to be linked.
582 LDFLAGS-c.so += -u __register_frame
583 # Pre-link the objects of libc_pic.a so that we can locally resolve
584 # COMMON symbols before we link against ld.so. This is because ld.so
585 # contains some of libc_pic.a already, which will prevent the COMMONs
586 # from being allocated in libc.so, which introduces evil dependencies
587 # between libc.so and ld.so, which can make it impossible to upgrade.
589 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
590 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
591 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
592 LDSEDCMD-c.so = -e 's/^.*\*(\.dynbss).*$$/& __start___libc_freeres_ptrs = .; *(__libc_freeres_ptrs) __stop___libc_freeres_ptrs = .;/'
593 # Use our own special initializer and finalizer files for libc.so.
594 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
595 $(common-objpfx)libc_pic.os \
596 $(elfobjdir)/sofini.os \
597 $(elfobjdir)/interp.os $(elfobjdir)/ld.so
599 ifeq ($(versioning),yes)
600 $(common-objpfx)libc.so: $(common-objpfx)libc.map
602 common-generated += libc.so libc_pic.os
603 ifdef libc.so-version
604 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
606 common-generated += libc.so$(libc.so-version)
610 ifneq (,$(findstring aix,$(config-os)))
611 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
614 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
615 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
616 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
617 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
618 -bE:$(common-objpfx)syscalls.exp \
619 -bI:$(common-objpfx)syscalls.exp \
620 -L$(common-objpfx) -o $@ $^
621 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
622 cp $@ $(common-objpfx)shr.o
623 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
627 # Figure out the source filenames in this directory.
629 override sources := $(addsuffix .c,\
630 $(filter-out $(elided-routines),\
633 sysdep_routines := $(sysdep_routines)
635 headers := $(headers) $(sysdep_headers)
637 # This is the list of all object files, gotten by
638 # replacing every ".c" in `sources' with a ".o".
639 # We also add bounded-pointer thunks, which are later
640 # elided for all suffixes except for `.ob'.
641 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
642 $(patsubst %,$(bppfx)%.o,\
643 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
646 # The makefile may define $(extra-libs) with `libfoo libbar'
647 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
649 # extra-lib.mk is included once for each extra lib to define rules
650 # to build it, and to add its objects to the various variables.
651 # During its evaluation, $(lib) is set to the name of the library.
652 extra-libs-left := $(extra-libs)
653 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
656 +depfiles := $(sources:.c=.d) \
657 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
658 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
659 ifeq ($(build-programs),yes)
660 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
662 +depfiles := $(addprefix $(objpfx),\
663 $(filter-out $(addsuffix .d,$(omit-deps)),\
665 $(addprefix $(common-objpfx),$(gen-as-const-headers:.sym=.h.d))
669 -include $(+depfiles)
673 # Maximize efficiency by minimizing the number of rules.
674 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
675 # Don't define any builtin rules.
676 MAKEFLAGS := $(MAKEFLAGS)r
678 # Generic rule for making directories.
680 # mkdir isn't smart enough to strip a trailing /.
683 # Make sure that object files are not removed
684 # when they are intermediates between sources and library members.
685 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
687 # Make sure that the parent library archive is never removed.
688 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
690 # Use the verbose option of ar and tar when not running silently.
691 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
697 ARFLAGS := r$(verbose)
698 CREATE_ARFLAGS := cru$(verbose)
700 # This makes all the object files in the parent library archive.
702 .PHONY: lib lib-noranlib
703 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
704 lib-noranlib: libobjs
706 # For object-suffix $o, the list of objects with that suffix.
707 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
708 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
709 $(elide-routines$o)),\
711 $(addprefix $(objpfx),$(o-objects$o))
713 others: $(addprefix $(objpfx),$(install-lib))
717 # Create the stamp$o files to keep the parent makefile happy.
718 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
719 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
720 $(make-target-directory)
724 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
725 # timestamp file; these rules (one explicit rule is generated for each
726 # object suffix) write a list of objects to update in the stamp file.
727 # The parent will then actually add them all to the archive in the
728 # archive rule, below.
729 define o-iterator-doit
730 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
733 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
736 object-suffixes-left := $(object-suffixes-for-libc)
737 include $(o-iterator)
741 # Now define explicit rules to build the library archives; these depend
742 # on the stamp files built above.
743 define o-iterator-doit
744 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
745 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
748 cd $(common-objdir) && \
749 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
752 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
753 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
755 $(subdirs-stamps): subdir_lib;
757 object-suffixes-left = $(object-suffixes-for-libc)
758 include $(o-iterator)
761 # This makes all the object files.
762 .PHONY: objects objs libobjs extra-objs
763 objects objs: libobjs extra-objs
764 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
765 extra-objs: $(addprefix $(objpfx),$(extra-objs))
767 # Canned sequence for building an extra library archive.
768 define build-extra-lib
769 $(patsubst %/,cd % &&,$(objpfx)) \
770 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
771 $(patsubst $(objpfx)%,%,$^)
777 .PHONY: force-install
780 # $(install-lib) are installed from the object directory into $(libdir);
781 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
782 # unless they also appear in $(non-lib.a). $(install-data) are installed
783 # as they are into $(datadir). $(headers) are installed as they are in
784 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
785 # are installed from the object directory into $(bindir), $(bindir) and
786 # $(sbindir), respectively. $(install-others) are absolute path names of
787 # files to install; rules to install them are defined elsewhere.
789 # The simple library name to install libc.a under.
790 # This could be defined by a sysdep Makefile.
796 $(make-target-directory)
797 $(INSTALL_DATA) $< $@
800 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
801 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
802 define make-target-directory
803 $(addprefix $(..)./scripts/mkinstalldirs ,\
804 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
807 # Any directory (parent or subdir) should install libc.a; this way
808 # "make install" in a subdir is guaranteed to install everything it changes.
809 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
810 $(inst_libdir)/$(patsubst %,$(libtype$o),\
811 $(libprefix)$(libc-name)))
812 install: $(installed-libcs)
813 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
814 $(make-target-directory)
815 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
816 # Running ranlib after installing makes the __.SYMDEF time stamp up to
817 # date, which avoids messages from some linkers.
820 define do-install-program
821 $(make-target-directory)
822 $(INSTALL_PROGRAM) $< $@.new
826 define do-install-script
827 $(make-target-directory)
828 $(INSTALL_SCRIPT) $< $@.new
832 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
833 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
835 ifeq (yes,$(build-shared))
836 # Find which .so's have versions.
837 versioned := $(strip $(foreach so,$(install-lib.so),\
838 $(patsubst %,$(so),$($(so)-version))))
840 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
841 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
843 install-lib-nosubdir: $(install-lib.so-versioned:%=$(inst_libdir)/%) \
844 $(install-lib.so-unversioned:%=$(inst_slibdir)/%)
846 # Install all the unversioned shared libraries.
847 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
848 $(objpfx)%.so $(+force)
849 $(do-install-program)
851 ifneq ($(findstring -s,$(LN_S)),)
854 $(SHELL) $(..)scripts/rellns-sh $< $@.new
858 # If we have no symbolic links don't bother with rellns-sh.
866 ifeq (yes,$(build-shared))
867 ifeq (no,$(cross-compiling))
868 symbolic-link-prog := $(common-objpfx)elf/sln
869 symbolic-link-list := $(common-objpfx)elf/symlink.list
870 define make-shlib-link
871 echo $(<F) $@ >> $(symbolic-link-list)
873 else # cross-compiling
874 # We need a definition that can be used by elf/Makefile's install rules.
875 symbolic-link-prog = $(LN_S)
878 ifndef make-shlib-link
879 define make-shlib-link
885 ifdef libc.so-version
886 # For a library specified to be version N, install three files:
887 # libc.so -> libc.so.N (e.g. libc.so.6)
888 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
890 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
893 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
894 $(do-install-program)
895 install: $(inst_slibdir)/libc.so$(libc.so-version)
897 # This fragment of linker script gives the OUTPUT_FORMAT statement
898 # for the configuration we are building. We put this statement into
899 # the linker scripts we install for -lc et al so that they will not be
900 # used by a link for a different format on a multi-architecture system.
901 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
902 $(common-objpfx)config.make \
903 $(common-objpfx)config.h $(..)Makerules
904 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
905 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
906 | sed -n -f $< > $@.new
909 common-generated += format.lds
912 # What we install as libc.so for programs to link against is in fact a
913 # link script. It contains references for the various libraries we need.
914 # The libc.so object is not complete since some functions are only defined
915 # in libc_nonshared.a.
916 # We need to use absolute paths since otherwise local copies (if they exist)
917 # of the files are taken by the linker.
918 install: $(inst_libdir)/libc.so
919 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
920 $(common-objpfx)libc.so$(libc.so-version) \
921 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
922 $(libprefix)$(libc-name)) \
924 (echo '/* GNU ld script';\
925 echo ' Use the shared library, but some functions are only in';\
926 echo ' the static library, so try that secondarily. */';\
928 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
929 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
937 install: $(inst_slibdir)/libc.so
938 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
939 $(do-install-program)
942 ifneq (,$(versioned))
943 # Produce three sets of rules as above for all the smaller versioned libraries.
945 define o-iterator-doit
946 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
948 object-suffixes-left := $(versioned)
949 include $(o-iterator)
951 # Make symlinks in the build directory, because the versioned names might
952 # be referenced by a DT_NEEDED in another library.
953 define o-iterator-doit
954 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
956 object-suffixes-left := $(versioned)
957 include $(o-iterator)
959 generated += $(foreach o,$(versioned),$o$($o-version))
961 ifeq (,$($(subdir)-version))
962 define o-iterator-doit
963 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
967 object-suffixes-left := $(versioned)
968 include $(o-iterator)
970 define o-iterator-doit
971 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
972 $$(do-install-program)
974 object-suffixes-left := $(versioned)
975 include $(o-iterator)
977 define o-iterator-doit
978 $(inst_slibdir)/$o$($o-version): \
979 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
982 object-suffixes-left := $(versioned)
983 include $(o-iterator)
985 define o-iterator-doit
986 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
987 $$(do-install-program)
989 object-suffixes-left := $(versioned)
990 include $(o-iterator)
995 $(do-install-program)
996 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
997 $(filter-out %.so,$@))
1000 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1001 $(foreach v,$(so-versions),\
1002 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1005 $(foreach v,$(so-versions),\
1006 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1011 $(addprefix $(inst_bindir)/,$(install-bin)): \
1012 $(inst_bindir)/%: $(objpfx)% $(+force)
1013 $(do-install-program)
1015 ifdef install-bin-script
1016 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1017 $(inst_bindir)/%: $(objpfx)% $(+force)
1018 $(do-install-script)
1020 ifdef install-rootsbin
1021 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1022 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1023 $(do-install-program)
1026 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1027 $(inst_sbindir)/%: $(objpfx)% $(+force)
1028 $(do-install-program)
1031 install-lib.a := $(filter lib%.a,$(install-lib))
1032 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1033 ifdef install-lib-non.a
1034 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1035 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1039 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1040 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1042 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
1046 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1049 headers := $(strip $(headers))
1051 $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
1055 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1056 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1057 install-data-nosubdir install-headers-nosubdir
1058 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1059 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1060 install-rootsbin-nosubdir: \
1061 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1062 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1063 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1064 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1065 $(addprefix $(libprefix),$(install-lib-non.a)))
1066 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1067 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1068 install-others-nosubdir: $(install-others)
1070 # We need all the `-nosubdir' targets so that `install' in the parent
1071 # doesn't depend on several things which each iterate over the subdirs.
1072 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1073 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1074 install-%:: install-%-nosubdir ;
1076 .PHONY: install install-no-libc.a-nosubdir
1077 ifeq ($(build-programs),yes)
1078 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1079 install-bin-nosubdir install-bin-script-nosubdir \
1080 install-lib-nosubdir install-others-nosubdir \
1081 install-rootsbin-nosubdir install-sbin-nosubdir
1083 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1084 install-lib-nosubdir install-others-nosubdir
1086 install: install-no-libc.a-nosubdir
1088 # Command to compile $< in $(objdir) using the native libraries.
1089 define native-compile
1090 $(make-target-directory)
1091 $(patsubst %/,cd % &&,$(objpfx)) \
1092 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1093 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1096 # Command to compile $< in $(common-objdir) using the native libraries.
1097 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1098 define common-objdir-compile
1099 $(patsubst %/,cd % &&,$(objpfx)) \
1100 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1101 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1104 # We always want to use configuration definitions.
1105 # Note that this is only used for commands running in $(objpfx).
1106 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1108 # Support the GNU standard name for this target.
1111 # Special target to run tests which cannot be run unconditionally.
1112 # Maintainers should use this target.
1116 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1117 ifneq (,$(all-nonlib))
1118 cpp-srcs-left = $(all-nonlib:=.c)
1120 include $(patsubst %,$(..)cppflags-iterator.mk,$(all-nonlib))
1123 # The include magic above causes those files to use this variable for flags.
1124 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1127 ifeq ($(versioning),yes)
1128 # Generate normalized lists of symbols, versions, and data sizes.
1129 # This is handy for checking against existing library binaries.
1131 %.symlist: $(..)scripts/abilist.awk %.dynsym
1132 LC_ALL=C $(AWK) -f $^ > $@T
1136 $(OBJDUMP) --dynamic-syms $< > $@T
1139 vpath %.symlist $(objpfx) $(common-objpfx)
1140 check-abi-%: $(..)scripts/extract-abilist.awk $(common-objpfx)config.make \
1144 -v 'config=$(config-machine)-$(config-vendor)-$(config-os)' \
1145 $(filter %.abilist,$^) \
1146 | diff -pu0 - $(filter %.symlist,$^)
1148 update-abi-%: $(..)scripts/merge-abilist.awk %.abilist %.symlist
1149 ifndef update-abi-config
1150 @echo 'Run $(MAKE) $@ update-abi-config=REGEXP'; exit 2
1152 LC_ALL=C $(AWK) -v config=$(update-abi-config) -f $^ > $*.abilist.new
1153 mv -f $*.abilist.new $*.abilist
1154 @echo '*** Now check $*.abilist changes for correctness ***'
1157 .PHONY: update-abi check-abi
1158 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1159 check-abi: $(patsubst %.so,check-abi-%,$(install-lib.so-versioned))
1161 subdir_check-abi: check-abi
1162 subdir_update-abi: update-abi
1164 check-abi: subdir_check-abi
1165 update-abi: subdir_update-abi
1168 # Enable this well all the .abilist files are in place.
1170 generated += $(install-lib.so-versioned:.so=.symlist)
1172 ifeq ($(subdir),elf)
1173 check-abi: check-abi-libc
1174 update-abi: update-abi-libc
1175 common-generated += libc.symlist
1180 # Generating headers for assembly constants.
1181 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk %.sym
1182 $(AWK) -f $< $(filter %.sym,$^) \
1183 | $(CC) -S -o - $(CFLAGS) $(CPPFLAGS) -x c - \
1184 -MD -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)' \
1185 | 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
1186 sed $(sed-remove-objpfx) \
1187 -e 's@ *\([^ \/$$][^ \]*\)@ $$(..)\1@g' \
1188 -e 's@ *\.\.\/\([^ \]*\)@ $$(..)\1@g' \
1189 $(@:.h=.h.d)T > $(@:.h=.h.d)T2
1191 mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
1192 mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
1193 vpath %.sym $(sysdirs)
1195 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
1198 TAGS: $(objpfx)distinfo $(..)MakeTAGS
1199 $(MAKE) $(addprefix -f ,$^) $@
1201 $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE
1202 $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
1206 .PHONY: echo-headers
1211 # Common cleaning targets.
1213 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1215 mostlyclean: common-mostlyclean
1218 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1220 $(addsuffix -bp.out,$(tests) $(xtests) \
1223 # Remove the object files.
1225 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1226 $(others) $(sysdep-others) stubs \
1227 $(addsuffix .o,$(tests) $(xtests) \
1228 $(test-srcs) $(others) \
1230 $(addsuffix -bp,$(tests) $(xtests) \
1232 $(addsuffix .out,$(tests) $(xtests) \
1234 $(addsuffix -bp.out,$(tests) $(xtests) \
1236 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
1238 $(install-lib.so:%.so=%_pic.a))
1240 -rm -f $(objpfx)rtld-*.os
1243 $(foreach o,$(object-suffixes-for-libc),
1244 -rm -f $(objpfx)stamp$o $(o-objects))
1247 # Also remove the dependencies and generated source files.
1248 common-clean: common-mostlyclean
1249 -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
1250 -rm -f $(objpfx)rtld-*.d
1251 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1252 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1253 -rm -f $(objpfx)distinfo
1255 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1256 # for each function which is a stub. We grovel over all the .d files
1257 # looking for references to <stub-tag.h>. Then we grovel over each
1258 # referenced source file to see what stub function it defines.
1261 .PHONY: stubs # The parent Makefile calls this target.
1262 stubs: $(objpfx)stubs
1264 s = $(sysdep_dir)/generic
1265 $(objpfx)stubs: $(+depfiles)
1266 # Use /dev/null since `...` might expand to empty.
1267 (s=`cd $s && $(PWD_P)`; \
1268 $(patsubst %/,cd % &&,$(objpfx)) \
1269 sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
1270 `sed -n -e '\@ $s/[^ ]*\.c@{; s@^.* $s/\([^ ]*\.c\).*$$@'"$$s"'/\1@; h; }' \
1271 -e '/stub-tag\.h/{; g; p; }' \
1272 $(patsubst $(objpfx)%,%,$^) /dev/null` \
1276 # Make the distribution tar file.
1279 dist: $(objpfx)distinfo $(..)Make-dist
1280 $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
1282 # Avoid depending on source files found in sysdeps dirs,
1283 # because the references affect implicit rule selection.
1284 dist: $(filter-out %.c %.S %.s,$(distribute))
1286 # We used to simply export all these variables, but that frequently made the
1287 # environment get too large. Instead, we write all the information into
1288 # a generated makefile fragment `distinfo', and then include it with -f in
1289 # the sub-make that makes the distribution (above).
1290 $(objpfx)distinfo: Makefile $(..)Makerules \
1291 $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile))
1292 $(make-target-directory)
1295 .PHONY: subdir_distinfo
1296 subdir_distinfo: $(objpfx)distinfo
1298 define distinfo-vars
1300 echo > $@.new 'subdir := $(subdir)'
1301 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
1302 headers sysdep_headers distribute dont_distribute generated \
1303 others tests xtests test-srcs extra-libs versioned \
1304 $(extra-libs:%=%-routines) \
1305 $(addprefix install-,lib lib.so data bin bin-script sbin others),
1306 echo >> $@.new '$(subdir)-$(var) := $($(var))'
1307 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
1310 ifneq (,$(strip $(gpl2lgpl)))
1311 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1312 # Snarf from the master source and frob the copying notice.
1313 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1315 # So I don't edit them by mistake.
1318 ifeq ($(with-cvs),yes)
1319 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@