1 # Copyright (C) 1991-1999,2000,01,02 Free Software Foundation, Inc.
\r
2 # This file is part of the GNU C Library.
\r
4 # The GNU C Library is free software; you can redistribute it and/or
\r
5 # modify it under the terms of the GNU Lesser General Public
\r
6 # License as published by the Free Software Foundation; either
\r
7 # version 2.1 of the License, or (at your option) any later version.
\r
9 # The GNU C Library is distributed in the hope that it will be useful,
\r
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
12 # Lesser General Public License for more details.
\r
14 # You should have received a copy of the GNU Lesser General Public
\r
15 # License along with the GNU C Library; if not, write to the Free
\r
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
\r
20 # Common rules for making the GNU C library. This file is included
\r
21 # by the top-level Makefile and by all subdirectory makefiles
\r
25 This makefile requires GNU Make.
\r
28 REQUIRED_MAKE_VERSION = 3.74
\r
29 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
\r
31 ifneq ($(REQUIRED_MAKE_VERSION), \
\r
32 $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION))))
\r
33 Wrong GNU Make version. See above for the version needed.
\r
41 # If `sources' was defined by the parent makefile, undefine it so
\r
42 # we will later get it from wildcard search in this directory.
\r
43 ifneq "$(findstring env,$(origin sources))" ""
\r
48 PATH := this definition should take precedence over $(oPATH)
\r
49 ifeq ($(PATH),$(oPATH))
\r
50 You must not use the -e flag when building the GNU C library.
\r
55 ifndef +included-Makeconfig
\r
56 include $(..)Makeconfig
\r
59 # `configure' writes a definition of `config-sysdirs' in `config.make'.
\r
60 sysdirs = $(strip $(full_config_sysdirs))
\r
62 +sysdir_pfx = $(common-objpfx)
\r
64 export sysdirs := $(sysdirs)
\r
66 +sysdep_dirs := $(full_config_sysdirs)
\r
68 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
\r
71 # Add -I switches to get the right sysdep directories.
\r
72 # `+includes' in Makeconfig references $(+sysdep-includes).
\r
73 +sysdep-includes := $(addprefix -I,$(+sysdep_dirs))
\r
75 # This variable is used in ``include $(o-iterator)'' after defining
\r
76 # $(o-iterator-doit) to produce some desired rule using $o for the object
\r
77 # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
\r
78 # is produced for each object suffix in use.
\r
79 o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
\r
81 # Include any system-specific makefiles.
\r
83 # This is here so things in sysdep Makefiles can easily depend on foo.h as
\r
84 # appropriate and not worry about where foo.h comes from, which may be
\r
85 # system dependent and not known by that Makefile.
\r
86 vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
\r
87 $(+sysdep_dirs) $(..)))
\r
89 # The same is true for RPC source files.
\r
90 vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
\r
91 $(+sysdep_dirs) $(..)))
\r
93 # Some sysdep makefiles use this to distinguish being included here from
\r
94 # being included individually by a subdir makefile (hurd/Makefile needs this).
\r
97 sysdep-makefiles := $(wildcard $(full_config_sysdirs:=/Makefile))
\r
98 ifneq (,$(sysdep-makefiles))
\r
99 include $(sysdep-makefiles)
\r
103 # Reorder before-compile so that mach things come first, and hurd things
\r
104 # second, before all else. The mach and hurd subdirectories have many
\r
105 # generated header files which the much of rest of the library depends on,
\r
106 # so it is best to build them first (and mach before hurd, at that).
\r
107 before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
\r
108 $(before-compile)) \
\r
109 $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
\r
112 # Even before that, we need abi-versions.h which is generated right here.
\r
113 ifeq ($(versioning),yes)
\r
114 ifndef avoid-generated
\r
115 before-compile := $(common-objpfx)abi-versions.h $(before-compile)
\r
116 $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
\r
117 $(common-objpfx)Versions.all
\r
118 LC_ALL=C $(AWK) -v oldest_abi=$(oldest-abi) -f $^ > $@T
\r
121 $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
\r
122 sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
\r
123 $(common-objpfx)abi-versions.h > $@T
\r
125 endif # avoid-generated
\r
126 endif # $(versioning) = yes
\r
128 # When we have no deps pass doing it, then make sure the subdirectory
\r
129 # for object files gets created.
\r
132 before-compile += $(objpfx).
\r
134 $(make-target-directory)
\r
138 # Remove existing files from `before-compile'. Things are added there when
\r
139 # they must exist for dependency generation to work right, but once they
\r
140 # exist there is no further need for every single file to depend on them,
\r
141 # and those gratuitous dependencies result in many gratuitous
\r
143 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
\r
145 # Don't let any before-compile file be an intermediate and get removed.
\r
146 ifdef before-compile
\r
150 # If a makefile needs to do something conditional on something that
\r
151 # can only be figured out from headers, write a FOO.make.c input
\r
152 # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
\r
153 # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
\r
154 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules
\r
156 (echo '# Generated from $*.make.c by Makerules.'; \
\r
157 SUNPRO_DEPENDENCIES='$@.dT $$(common-objpfx)$*.make' \
\r
158 $(CC) $(CFLAGS) $(CPPFLAGS) -E $< \
\r
159 | sed -n '/@@@/{s/@@@[ ]*\(.*\)@@@/\1/;s/[ ]*$$//p;}'; \
\r
160 echo 'common-generated += $(@F)'; \
\r
161 cat $@.dT; rm -f $@.dT) > $@T
\r
164 # Generate an ordered list of implicit rules which find the source files in
\r
165 # each sysdep directory. The old method was to use vpath to search all the
\r
166 # sysdep directories. However, that had the problem that a .S file in a
\r
167 # later directory would be chosen over a .c file in an earlier directory,
\r
168 # which does not preserve the desired sysdeps ordering behavior.
\r
170 # When making the list of .d files to include, we can't know which ones
\r
171 # have source in .s files, and thus do not in fact need a .d file.
\r
172 # So we must define rules to make .d files for .s files.
\r
173 define make-dummy-dep
\r
174 $(addprefix ln $(common-objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
\r
176 $(common-objpfx)dummy.d:
\r
177 echo '# .s files cannot contain includes, so they need no deps.' > $@
\r
179 # It matters that this set of rules, for compiling from sources in
\r
180 # the current directory (the $srcdir/$subdir) come before the
\r
181 # generated sysdep rules in included from sysd-rules below. When
\r
182 # compiling in the source tree, generated sources go into the current
\r
183 # directory, and those should be chosen before any sources in sysdeps.
\r
184 define o-iterator-doit
\r
185 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
\r
187 object-suffixes-left := $(all-object-suffixes)
\r
188 include $(o-iterator)
\r
189 $(objpfx)%.d: %.S $(before-compile); $(+make-deps)
\r
191 define o-iterator-doit
\r
192 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
\r
194 object-suffixes-left := $(all-object-suffixes)
\r
195 include $(o-iterator)
\r
196 $(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep)
\r
198 define o-iterator-doit
\r
199 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
\r
201 object-suffixes-left := $(all-object-suffixes)
\r
202 include $(o-iterator)
\r
203 $(objpfx)%.d: %.c $(before-compile); $(+make-deps)
\r
205 # Omit the objpfx rules when building in the source tree, because
\r
206 # objpfx is empty and so these rules just override the ones above.
\r
208 # Define first rules to find the source files in $(objpfx).
\r
209 # Generated source files will end up there.
\r
210 define o-iterator-doit
\r
211 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
\r
213 object-suffixes-left := $(all-object-suffixes)
\r
214 include $(o-iterator)
\r
215 $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps)
\r
217 define o-iterator-doit
\r
218 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
\r
220 object-suffixes-left := $(all-object-suffixes)
\r
221 include $(o-iterator)
\r
222 $(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep)
\r
224 define o-iterator-doit
\r
225 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
\r
227 object-suffixes-left := $(all-object-suffixes)
\r
228 include $(o-iterator)
\r
229 $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps)
\r
232 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
\r
233 # patterns matching sysdep directories whose assembly source files should
\r
235 ifdef inhibit-sysdep-asm
\r
236 define open-check-inhibit-asm
\r
237 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
\r
239 close-check-inhibit-asm = ;; esac ;
\r
242 -include $(+sysdir_pfx)sysd-rules
\r
243 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
\r
244 # The value of $(+sysdep_dirs) the sysd-rules was computed for
\r
245 # differs from the one we are using now. So force a rebuild of sysd-rules.
\r
246 sysd-rules-force = FORCE
\r
249 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
\r
250 $(wildcard $(foreach dir,$(sysdirs),\
\r
252 $(sysd-rules-force)
\r
254 (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \
\r
255 for dir in $(config-sysdirs:%='$$(..)%'); do \
\r
256 for o in $(all-object-suffixes); do \
\r
257 $(open-check-inhibit-asm) \
\r
258 echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
\r
259 \$$(compile-command.S)"; \
\r
260 echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
\r
261 \$$(compile-command.s)"; \
\r
262 echo "\$$(objpfx)rtld-%$$o: $$dir/%.S \$$(before-compile); \
\r
263 \$$(compile-command.S)"; \
\r
264 echo "\$$(objpfx)rtld-%$$o: $$dir/%.s \$$(before-compile); \
\r
265 \$$(compile-command.s)"; \
\r
266 $(close-check-inhibit-asm) \
\r
267 echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
\r
268 \$$(compile-command.c)"; \
\r
269 echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \
\r
270 \$$(compile-command.c)"; \
\r
272 $(open-check-inhibit-asm) \
\r
273 echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
\r
274 \$$(make-dummy-dep)"; \
\r
275 echo "\$$(objpfx)rtld-%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
\r
276 \$$(make-dummy-dep)"; \
\r
277 echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
\r
278 \$$(+make-deps)"; \
\r
279 echo "\$$(objpfx)rtld-%.d: $$dir/%.S \$$(before-compile); \
\r
280 \$$(+make-deps)"; \
\r
281 $(close-check-inhibit-asm) \
\r
282 echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \
\r
283 \$$(+make-deps)"; \
\r
284 echo "\$$(objpfx)rtld-%.d: $$dir/%.c \$$(before-compile); \
\r
285 \$$(+make-deps)"; \
\r
286 echo "\$$(objpfx)m_%.S: $$dir/s_%.S; \$$(+make-include-of-dep)"; \
\r
287 echo "\$$(objpfx)m_%.c: $$dir/s_%.c; \$$(+make-include-of-dep)"; \
\r
289 echo 'sysd-rules-done = t') > $@T
\r
292 ifndef sysd-rules-done
\r
293 # Don't do deps until this exists, because it provides rules to make the deps.
\r
297 # This is used by the m_%.[Sc] pattern rules in sysd-rules.
\r
298 define +make-include-of-dep
\r
299 echo '#include <$<>' > $@T
\r
303 # Generate version maps, but wait until sysdep-subdirs is known
\r
304 ifeq ($(sysd-sorted-done),t)
\r
305 ifeq ($(versioning),yes)
\r
306 -include $(common-objpfx)sysd-versions
\r
307 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
\r
308 common-generated += $(version-maps)
\r
309 postclean-generated += sysd-versions Versions.all abi-versions.h \
\r
310 Versions.def.v.i Versions.def.v Versions.v.i Versions.v
\r
312 ifndef avoid-generated
\r
313 ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
\r
314 sysd-versions-force = FORCE
\r
317 # See %.v/%.v.i implicit rules in Makeconfig.
\r
318 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
\r
319 $(wildcard $(add-ons:%=$(..)%/Versions.def))
\r
320 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
\r
321 $(common-objpfx)soversions.i \
\r
322 $(common-objpfx)Versions.def.v
\r
323 { while read lib version setname; do \
\r
324 test -z "$$setname" || echo "$$lib : $$setname"; \
\r
325 done < $(word 2,$^); \
\r
326 cat $(word 3,$^); \
\r
327 } | LC_ALL=C $(AWK) -f $< > $@T
\r
329 # See %.v/%.v.i implicit rules in Makeconfig.
\r
330 $(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
\r
331 $(wildcard $(sysdirs:%=%/Versions)) \
\r
332 $(common-objpfx)abi-versions.h \
\r
333 $(sysd-versions-force)
\r
334 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
\r
335 $(common-objpfx)Versions.v \
\r
336 $(..)scripts/versions.awk
\r
337 ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
\r
339 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
\r
340 -v move_if_change='$(move-if-change)' \
\r
344 endif # avoid-generated
\r
345 endif # $(versioning) = yes
\r
346 endif # sysd-sorted-done
\r
349 ifndef compile-command.S
\r
350 compile-command.S = $(compile.S) $(OUTPUT_OPTION)
\r
352 ifndef compile-command.s
\r
353 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION)
\r
355 ifndef compile-command.c
\r
356 compile-command.c = $(compile.c) $(OUTPUT_OPTION)
\r
359 # GCC can grok options after the file name, and it looks nicer that way.
\r
360 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
\r
362 $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
\r
364 $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
\r
365 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
\r
367 # If we want to generate MD5 checksums for the sources do this now.
\r
369 generate-md5 = ; rm -f $(@:.d=.md5); \
\r
370 $(CC) -E $< $(CFLAGS) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
\r
371 sed '/^\#/d;/^[[:space:]]*$$/d' | md5sum > $(@:.d=.md5)
\r
376 # We need this for the output to go in the right place. It will default to
\r
377 # empty if make was configured to work with a cc that can't grok -c and -o
\r
378 # together. You can't compile the C library with such a compiler.
\r
379 OUTPUT_OPTION = -o $@
\r
381 # We need the $(CFLAGS) to be in there to have the right predefines during
\r
382 # the dependency run for C sources. But having it for assembly sources can
\r
383 # get the wrong predefines.
\r
384 S-CPPFLAGS = $(asm-CPPFLAGS)
\r
386 $(make-target-directory)
\r
387 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
\r
388 $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | sed \
\r
389 -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
\r
390 $(sed-remove-objpfx) > $(@:.d=.T)
\r
391 mv -f $(@:.d=.T) $@ $(generate-md5)
\r
394 # Continuation lines here are dangerous because they introduce spaces!
\r
395 define sed-remove-objpfx
\r
396 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
\r
397 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
\r
401 # Modify the list of routines we build for different targets
\r
403 ifeq (yesyes,$(build-shared)$(elf))
\r
404 ifndef libc.so-version
\r
405 # Undefine this because it can't work when we libc.so is unversioned.
\r
406 static-only-routines =
\r
410 # Bounded pointer thunks are only built for *.ob
\r
411 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
\r
413 elide-routines.oS += $(filter-out $(static-only-routines),\
\r
414 $(routines) $(aux) $(sysdep_routines)) \
\r
416 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
\r
418 # If we have versioned code we don't need the old versions in any of the
\r
419 # static libraries.
\r
420 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
\r
421 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
\r
422 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
\r
423 elide-routines.ob += $(shared-only-routines)
\r
425 # Shared library building.
\r
427 ifeq (yes,$(build-shared))
\r
429 # Reference map file only when versioning is selected and a map file name
\r
431 ifeq ($(versioning),yes)
\r
432 map-file = $(firstword $($(@F:.so=-map)) \
\r
433 $(addprefix $(common-objpfx), \
\r
434 $(filter $(@F:.so=.map),$(version-maps))))
\r
435 load-map-file = $(map-file:%=-Wl,--version-script=%)
\r
438 # Pattern rule to build a shared object from an archive of PIC objects.
\r
439 # This must come after the installation rules so Make doesn't try to
\r
440 # build shared libraries in place from the installed *_pic.a files.
\r
441 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
\r
442 # on other shared objects.
\r
443 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
\r
444 ifneq (,$(findstring aix,$(config-os)))
\r
446 dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
\r
451 define build-shlib-helper
\r
452 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
\r
453 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
\r
454 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
\r
455 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
\r
456 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
\r
457 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
\r
460 ifneq (,$(findstring aix,$(config-os)))
\r
461 define build-shlib-helper
\r
462 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
\r
463 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
\r
464 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
\r
465 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
\r
466 -L$(subst :, -L,$(rpath-link))
\r
473 # binutils only position loadable notes into the first page for binaries,
\r
474 # not for shared objects
\r
476 $(build-shlib-helper) \
\r
477 -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
\r
478 $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
\r
479 sed -e '/^=========/,/^=========/!d;/^=========/d' \
\r
480 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
\r
481 $(LDSEDCMD-$(@F:lib%.so=%).so) > $@.lds
\r
483 $(build-shlib-helper) -o $@ -T $@.lds \
\r
484 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
\r
488 ifneq (,$(findstring aix,$(config-os)))
\r
490 $(build-shlib-helper) \
\r
492 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
\r
493 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
\r
496 $(build-shlib-helper) \
\r
497 $(build-shlib-objlist)
\r
502 ifneq (,$(findstring aix,$(config-os)))
\r
503 define build-module-helper
\r
504 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
\r
505 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
\r
507 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
\r
508 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
\r
511 define build-module-helper
\r
512 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
\r
513 -B$(csu-objpfx) $(load-map-file) \
\r
514 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
\r
515 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
\r
519 # This macro is similar to build-shlib but it does not define a soname
\r
520 # and it does not depend on the destination name to start with `lib'.
\r
522 # binutils only position loadable notes into the first page for binaries,
\r
523 # not for shared objects
\r
524 define build-module
\r
525 $(build-module-helper) \
\r
526 -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
\r
527 $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
\r
528 sed -e '/^=========/,/^=========/!d;/^=========/d' \
\r
529 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
\r
532 $(build-module-helper) -o $@ -T $@.lds \
\r
533 $(csu-objpfx)abi-note.o $(build-module-objlist)
\r
537 ifneq (,$(findstring aix,$(config-os)))
\r
538 define build-module
\r
539 $(build-module-helper) \
\r
541 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
\r
542 $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
\r
545 define build-module
\r
546 define build-module
\r
547 $(build-module-helper) \
\r
549 $(build-module-objlist)
\r
554 build-module-helper-objlist = \
\r
555 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
\r
556 $(filter-out $(map-file) $(+preinit) $(+postinit),$^))
\r
557 whole-archive := -Wl,--whole-archive
\r
559 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
\r
560 build-shlib-objlist = $(build-module-helper-objlist) \
\r
561 $(LDLIBS-$(@F:lib%.so=%).so)
\r
563 # Don't try to use -lc when making libc.so itself.
\r
564 # Also omits crti.o and crtn.o, which we do not want
\r
565 # since we define our own `.init' section specially.
\r
566 LDFLAGS-c.so = -nostdlib -nostartfiles
\r
567 # But we still want to link libc.so against $(gnulib).
\r
568 LDLIBS-c.so += $(gnulib)
\r
569 # Give libc.so an entry point and make it directly runnable itself.
\r
570 LDFLAGS-c.so += -e __libc_main
\r
571 # Force the backward compatibility EH functions to be linked.
\r
572 LDFLAGS-c.so += -u __register_frame
\r
573 # Pre-link the objects of libc_pic.a so that we can locally resolve
\r
574 # COMMON symbols before we link against ld.so. This is because ld.so
\r
575 # contains some of libc_pic.a already, which will prevent the COMMONs
\r
576 # from being allocated in libc.so, which introduces evil dependencies
\r
577 # between libc.so and ld.so, which can make it impossible to upgrade.
\r
579 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
\r
580 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
\r
581 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
\r
582 LDSEDCMD-c.so = -e 's/^.*\*(\.dynbss).*$$/& __start___libc_freeres_ptrs = .; *(__libc_freeres_ptrs) __stop___libc_freeres_ptrs = .;/'
\r
583 # Use our own special initializer and finalizer files for libc.so.
\r
584 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
\r
585 $(common-objpfx)libc_pic.os \
\r
586 $(elfobjdir)/sofini.os \
\r
587 $(elfobjdir)/interp.os $(elfobjdir)/ld.so
\r
589 ifeq ($(versioning),yes)
\r
590 $(common-objpfx)libc.so: $(common-objpfx)libc.map
\r
592 common-generated += libc.so libc_pic.os
\r
593 ifdef libc.so-version
\r
594 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
\r
596 common-generated += libc.so$(libc.so-version)
\r
600 ifneq (,$(findstring aix,$(config-os)))
\r
601 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
\r
604 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
\r
605 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
\r
606 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
\r
607 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
\r
608 -bE:$(common-objpfx)syscalls.exp \
\r
609 -bI:$(common-objpfx)syscalls.exp \
\r
610 -L$(common-objpfx) -o $@ $^
\r
611 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
\r
612 cp $@ $(common-objpfx)shr.o
\r
613 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
\r
617 # Figure out the source filenames in this directory.
\r
619 override sources := $(addsuffix .c,\
\r
620 $(filter-out $(elided-routines),\
\r
621 $(routines) $(aux) \
\r
622 $(sysdep_routines)))
\r
623 sysdep_routines := $(sysdep_routines)
\r
625 headers := $(headers) $(sysdep_headers)
\r
627 # This is the list of all object files, gotten by
\r
628 # replacing every ".c" in `sources' with a ".o".
\r
629 # We also add bounded-pointer thunks, which are later
\r
630 # elided for all suffixes except for `.ob'.
\r
631 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
\r
632 $(patsubst %,$(bppfx)%.o,\
\r
633 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
\r
636 # The makefile may define $(extra-libs) with `libfoo libbar'
\r
637 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
\r
639 # extra-lib.mk is included once for each extra lib to define rules
\r
640 # to build it, and to add its objects to the various variables.
\r
641 # During its evaluation, $(lib) is set to the name of the library.
\r
642 extra-libs-left := $(extra-libs)
\r
643 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
\r
646 +depfiles := $(sources:.c=.d) \
\r
647 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
\r
648 $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
\r
649 ifeq ($(build-programs),yes)
\r
650 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
\r
652 +depfiles := $(addprefix $(objpfx),\
\r
653 $(filter-out $(addsuffix .d,$(omit-deps)),\
\r
657 ifneq ($(no_deps),t)
\r
658 -include $(+depfiles)
\r
662 # Maximize efficiency by minimizing the number of rules.
\r
663 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
\r
664 # Don't define any builtin rules.
\r
665 MAKEFLAGS := $(MAKEFLAGS)r
\r
667 # Generic rule for making directories.
\r
669 # mkdir isn't smart enough to strip a trailing /.
\r
672 # Make sure that object files are not removed
\r
673 # when they are intermediates between sources and library members.
\r
674 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
\r
676 # Make sure that the parent library archive is never removed.
\r
677 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
\r
679 # Use the verbose option of ar and tar when not running silently.
\r
680 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
\r
686 ARFLAGS := r$(verbose)
\r
687 CREATE_ARFLAGS := cru$(verbose)
\r
689 # This makes all the object files in the parent library archive.
\r
691 .PHONY: lib lib-noranlib
\r
692 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
\r
693 lib-noranlib: libobjs
\r
695 # For object-suffix $o, the list of objects with that suffix.
\r
696 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
\r
697 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
\r
698 $(elide-routines$o)),\
\r
700 $(addprefix $(objpfx),$(o-objects$o))
\r
702 others: $(addprefix $(objpfx),$(install-lib))
\r
706 # Create the stamp$o files to keep the parent makefile happy.
\r
707 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
\r
708 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
\r
709 $(make-target-directory)
\r
713 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
\r
714 # timestamp file; these rules (one explicit rule is generated for each
\r
715 # object suffix) write a list of objects to update in the stamp file.
\r
716 # The parent will then actually add them all to the archive in the
\r
717 # archive rule, below.
\r
718 define o-iterator-doit
\r
719 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
\r
722 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
\r
725 object-suffixes-left := $(object-suffixes-for-libc)
\r
726 include $(o-iterator)
\r
730 # Now define explicit rules to build the library archives; these depend
\r
731 # on the stamp files built above.
\r
732 define o-iterator-doit
\r
733 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
\r
734 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
\r
737 cd $(common-objdir) && \
\r
738 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
\r
741 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
\r
742 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
\r
744 $(subdirs-stamps): subdir_lib;
\r
746 object-suffixes-left = $(object-suffixes-for-libc)
\r
747 include $(o-iterator)
\r
750 # This makes all the object files.
\r
751 .PHONY: objects objs libobjs extra-objs
\r
752 objects objs: libobjs extra-objs
\r
753 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
\r
754 extra-objs: $(addprefix $(objpfx),$(extra-objs))
\r
756 # Canned sequence for building an extra library archive.
\r
757 define build-extra-lib
\r
758 $(patsubst %/,cd % &&,$(objpfx)) \
\r
759 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
\r
760 $(patsubst $(objpfx)%,%,$^)
\r
766 .PHONY: force-install
\r
769 # $(install-lib) are installed from the object directory into $(libdir);
\r
770 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
\r
771 # unless they also appear in $(non-lib.a). $(install-data) are installed
\r
772 # as they are into $(datadir). $(headers) are installed as they are in
\r
773 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
\r
774 # are installed from the object directory into $(bindir), $(bindir) and
\r
775 # $(sbindir), respectively. $(install-others) are absolute path names of
\r
776 # files to install; rules to install them are defined elsewhere.
\r
778 # The simple library name to install libc.a under.
\r
779 # This could be defined by a sysdep Makefile.
\r
785 $(make-target-directory)
\r
786 $(INSTALL_DATA) $< $@
\r
789 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
\r
790 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
\r
791 define make-target-directory
\r
792 $(addprefix $(..)./scripts/mkinstalldirs ,\
\r
793 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
\r
796 # Any directory (parent or subdir) should install libc.a; this way
\r
797 # "make install" in a subdir is guaranteed to install everything it changes.
\r
798 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
\r
799 $(inst_libdir)/$(patsubst %,$(libtype$o),\
\r
800 $(libprefix)$(libc-name)))
\r
801 install: $(installed-libcs)
\r
802 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
\r
803 $(make-target-directory)
\r
804 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
\r
805 # Running ranlib after installing makes the __.SYMDEF time stamp up to
\r
806 # date, which avoids messages from some linkers.
\r
809 define do-install-program
\r
810 $(make-target-directory)
\r
811 $(INSTALL_PROGRAM) $< $@.new
\r
815 define do-install-script
\r
816 $(make-target-directory)
\r
817 $(INSTALL_SCRIPT) $< $@.new
\r
821 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
\r
822 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
\r
824 ifeq (yes,$(build-shared))
\r
825 # Find which .so's have versions.
\r
826 versioned := $(strip $(foreach so,$(install-lib.so),\
\r
827 $(patsubst %,$(so),$($(so)-version))))
\r
829 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
\r
830 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
\r
832 install-lib-nosubdir: $(install-lib.so-versioned:%=$(inst_libdir)/%) \
\r
833 $(install-lib.so-unversioned:%=$(inst_slibdir)/%)
\r
835 # Install all the unversioned shared libraries.
\r
836 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
\r
837 $(objpfx)%.so $(+force)
\r
838 $(do-install-program)
\r
840 ifneq ($(findstring -s,$(LN_S)),)
\r
843 $(SHELL) $(..)scripts/rellns-sh $< $@.new
\r
847 # If we have no symbolic links don't bother with rellns-sh.
\r
855 ifeq (yes,$(build-shared))
\r
856 ifeq (no,$(cross-compiling))
\r
857 symbolic-link-prog := $(common-objpfx)elf/sln
\r
858 symbolic-link-list := $(common-objpfx)elf/symlink.list
\r
859 define make-shlib-link
\r
860 echo $(<F) $@ >> $(symbolic-link-list)
\r
862 else # cross-compiling
\r
863 # We need a definition that can be used by elf/Makefile's install rules.
\r
864 symbolic-link-prog = $(LN_S)
\r
867 ifndef make-shlib-link
\r
868 define make-shlib-link
\r
874 ifdef libc.so-version
\r
875 # For a library specified to be version N, install three files:
\r
876 # libc.so -> libc.so.N (e.g. libc.so.6)
\r
877 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
\r
879 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
\r
882 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
\r
883 $(do-install-program)
\r
884 install: $(inst_slibdir)/libc.so$(libc.so-version)
\r
886 # This fragment of linker script gives the OUTPUT_FORMAT statement
\r
887 # for the configuration we are building. We put this statement into
\r
888 # the linker scripts we install for -lc et al so that they will not be
\r
889 # used by a link for a different format on a multi-architecture system.
\r
890 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
\r
891 $(common-objpfx)config.make \
\r
892 $(common-objpfx)config.h $(..)Makerules
\r
893 $(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
\r
894 -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
\r
895 | sed -n -f $< > $@.new
\r
898 common-generated += format.lds
\r
901 # What we install as libc.so for programs to link against is in fact a
\r
902 # link script. It contains references for the various libraries we need.
\r
903 # The libc.so object is not complete since some functions are only defined
\r
904 # in libc_nonshared.a.
\r
905 # We need to use absolute paths since otherwise local copies (if they exist)
\r
906 # of the files are taken by the linker.
\r
907 install: $(inst_libdir)/libc.so
\r
908 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
\r
909 $(common-objpfx)libc.so$(libc.so-version) \
\r
910 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
\r
911 $(libprefix)$(libc-name)) \
\r
913 (echo '/* GNU ld script';\
\r
914 echo ' Use the shared library, but some functions are only in';\
\r
915 echo ' the static library, so try that secondarily. */';\
\r
917 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
\r
918 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
\r
926 install: $(inst_slibdir)/libc.so
\r
927 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
\r
928 $(do-install-program)
\r
931 ifneq (,$(versioned))
\r
932 # Produce three sets of rules as above for all the smaller versioned libraries.
\r
934 define o-iterator-doit
\r
935 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
\r
937 object-suffixes-left := $(versioned)
\r
938 include $(o-iterator)
\r
940 # Make symlinks in the build directory, because the versioned names might
\r
941 # be referenced by a DT_NEEDED in another library.
\r
942 define o-iterator-doit
\r
943 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
\r
945 object-suffixes-left := $(versioned)
\r
946 include $(o-iterator)
\r
948 generated += $(foreach o,$(versioned),$o$($o-version))
\r
950 ifeq (,$($(subdir)-version))
\r
951 define o-iterator-doit
\r
952 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
\r
954 $$(make-shlib-link)
\r
956 object-suffixes-left := $(versioned)
\r
957 include $(o-iterator)
\r
959 define o-iterator-doit
\r
960 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
\r
961 $$(do-install-program)
\r
963 object-suffixes-left := $(versioned)
\r
964 include $(o-iterator)
\r
966 define o-iterator-doit
\r
967 $(inst_slibdir)/$o$($o-version): \
\r
968 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
\r
969 $$(make-shlib-link)
\r
971 object-suffixes-left := $(versioned)
\r
972 include $(o-iterator)
\r
974 define o-iterator-doit
\r
975 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
\r
976 $$(do-install-program)
\r
978 object-suffixes-left := $(versioned)
\r
979 include $(o-iterator)
\r
983 define do-install-so
\r
984 $(do-install-program)
\r
985 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
\r
986 $(filter-out %.so,$@))
\r
989 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
\r
990 $(foreach v,$(so-versions),\
\r
991 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
\r
994 $(foreach v,$(so-versions),\
\r
995 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
\r
1000 $(addprefix $(inst_bindir)/,$(install-bin)): \
\r
1001 $(inst_bindir)/%: $(objpfx)% $(+force)
\r
1002 $(do-install-program)
\r
1004 ifdef install-bin-script
\r
1005 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
\r
1006 $(inst_bindir)/%: $(objpfx)% $(+force)
\r
1007 $(do-install-script)
\r
1009 ifdef install-rootsbin
\r
1010 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
\r
1011 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
\r
1012 $(do-install-program)
\r
1014 ifdef install-sbin
\r
1015 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
\r
1016 $(inst_sbindir)/%: $(objpfx)% $(+force)
\r
1017 $(do-install-program)
\r
1020 install-lib.a := $(filter lib%.a,$(install-lib))
\r
1021 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
\r
1022 ifdef install-lib-non.a
\r
1023 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
\r
1024 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
\r
1027 ifdef install-lib.a
\r
1028 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
\r
1029 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
\r
1031 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
\r
1034 ifdef install-data
\r
1035 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
\r
1038 headers := $(strip $(headers))
\r
1040 $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
\r
1044 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
\r
1045 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
\r
1046 install-data-nosubdir install-headers-nosubdir
\r
1047 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
\r
1048 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
\r
1049 install-rootsbin-nosubdir: \
\r
1050 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
\r
1051 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
\r
1052 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
\r
1053 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
\r
1054 $(addprefix $(libprefix),$(install-lib-non.a)))
\r
1055 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
\r
1056 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
\r
1057 install-others-nosubdir: $(install-others)
\r
1059 # We need all the `-nosubdir' targets so that `install' in the parent
\r
1060 # doesn't depend on several things which each iterate over the subdirs.
\r
1061 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
\r
1062 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
\r
1063 install-%:: install-%-nosubdir ;
\r
1065 .PHONY: install install-no-libc.a-nosubdir
\r
1066 ifeq ($(build-programs),yes)
\r
1067 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
\r
1068 install-bin-nosubdir install-bin-script-nosubdir \
\r
1069 install-lib-nosubdir install-others-nosubdir \
\r
1070 install-rootsbin-nosubdir install-sbin-nosubdir
\r
1072 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
\r
1073 install-lib-nosubdir install-others-nosubdir
\r
1075 install: install-no-libc.a-nosubdir
\r
1077 # Command to compile $< in $(objdir) using the native libraries.
\r
1078 define native-compile
\r
1079 $(make-target-directory)
\r
1080 $(patsubst %/,cd % &&,$(objpfx)) \
\r
1081 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
\r
1082 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
\r
1085 # Command to compile $< in $(common-objdir) using the native libraries.
\r
1086 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
\r
1087 define common-objdir-compile
\r
1088 $(patsubst %/,cd % &&,$(objpfx)) \
\r
1089 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
\r
1090 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
\r
1093 # We always want to use configuration definitions.
\r
1094 # Note that this is only used for commands running in $(objpfx).
\r
1095 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
\r
1097 # Support the GNU standard name for this target.
\r
1100 # Special target to run tests which cannot be run unconditionally.
\r
1101 # Maintainers should use this target.
\r
1105 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
\r
1106 ifneq (,$(all-nonlib))
\r
1107 cpp-srcs-left = $(all-nonlib:=.c)
\r
1109 include $(patsubst %,$(..)cppflags-iterator.mk,$(all-nonlib))
\r
1112 # The include magic above causes those files to use this variable for flags.
\r
1113 CPPFLAGS-nonlib = -DNOT_IN_libc=1
\r
1116 ifeq ($(versioning),yes)
\r
1117 # Generate normalized lists of symbols, versions, and data sizes.
\r
1118 # This is handy for checking against existing library binaries.
\r
1120 %.symlist: $(..)scripts/abilist.awk %.dynsym
\r
1121 $(AWK) -f $^ > $@T
\r
1125 $(OBJDUMP) --dynamic-syms $< > $@T
\r
1128 tests: $(patsubst %.so,$(objpfx)%.symlist,$(install-lib.so-versioned))
\r
1129 generated += $(install-lib.so-versioned:.so=.symlist)
\r
1131 ifeq ($(subdir),elf)
\r
1132 tests: $(common-objpfx)libc.symlist
\r
1133 common-generated += libc.symlist
\r
1138 TAGS: $(objpfx)distinfo $(..)MakeTAGS
\r
1139 $(MAKE) $(addprefix -f ,$^) $@
\r
1141 $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE
\r
1142 $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
\r
1146 .PHONY: echo-headers
\r
1151 # Common cleaning targets.
\r
1153 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
\r
1154 clean: common-clean
\r
1155 mostlyclean: common-mostlyclean
\r
1158 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
\r
1160 $(addsuffix -bp.out,$(tests) $(xtests) \
\r
1163 # Remove the object files.
\r
1164 common-mostlyclean:
\r
1165 -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
\r
1166 $(others) $(sysdep-others) stubs \
\r
1167 $(addsuffix .o,$(tests) $(xtests) \
\r
1168 $(test-srcs) $(others) \
\r
1169 $(sysdep-others)) \
\r
1170 $(addsuffix -bp,$(tests) $(xtests) \
\r
1172 $(addsuffix .out,$(tests) $(xtests) \
\r
1174 $(addsuffix -bp.out,$(tests) $(xtests) \
\r
1176 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
\r
1177 $(install-lib.so) \
\r
1178 $(install-lib.so:%.so=%_pic.a))
\r
1180 -rm -f $(objpfx)rtld-*.os
\r
1183 $(foreach o,$(object-suffixes-for-libc),
\r
1184 -rm -f $(objpfx)stamp$o $(o-objects))
\r
1187 # Also remove the dependencies and generated source files.
\r
1188 common-clean: common-mostlyclean
\r
1189 -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
\r
1190 -rm -f $(objpfx)rtld-*.d
\r
1191 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
\r
1192 -rm -f $(addprefix $(common-objpfx),$(common-generated))
\r
1193 -rm -f $(objpfx)distinfo
\r
1195 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
\r
1196 # for each function which is a stub. We grovel over all the .d files
\r
1197 # looking for references to <stub-tag.h>. Then we grovel over each
\r
1198 # referenced source file to see what stub function it defines.
\r
1201 .PHONY: stubs # The parent Makefile calls this target.
\r
1202 stubs: $(objpfx)stubs
\r
1204 s = $(sysdep_dir)/generic
\r
1205 $(objpfx)stubs: $(+depfiles)
\r
1206 # Use /dev/null since `...` might expand to empty.
\r
1207 (s=`cd $s && $(PWD_P)`; \
\r
1208 $(patsubst %/,cd % &&,$(objpfx)) \
\r
1209 sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
\r
1210 `sed -n -e '\@ $s/[^ ]*\.c@{; s@^.* $s/\([^ ]*\.c\).*$$@'"$$s"'/\1@; h; }' \
\r
1211 -e '/stub-tag\.h/{; g; p; }' \
\r
1212 $(patsubst $(objpfx)%,%,$^) /dev/null` \
\r
1216 # Make the distribution tar file.
\r
1219 dist: $(objpfx)distinfo $(..)Make-dist
\r
1220 $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
\r
1222 # Avoid depending on source files found in sysdeps dirs,
\r
1223 # because the references affect implicit rule selection.
\r
1224 dist: $(filter-out %.c %.S %.s,$(distribute))
\r
1226 # We used to simply export all these variables, but that frequently made the
\r
1227 # environment get too large. Instead, we write all the information into
\r
1228 # a generated makefile fragment `distinfo', and then include it with -f in
\r
1229 # the sub-make that makes the distribution (above).
\r
1230 $(objpfx)distinfo: Makefile $(..)Makerules \
\r
1231 $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile))
\r
1232 $(make-target-directory)
\r
1235 .PHONY: subdir_distinfo
\r
1236 subdir_distinfo: $(objpfx)distinfo
\r
1238 define distinfo-vars
\r
1240 echo > $@.new 'subdir := $(subdir)'
\r
1241 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
\r
1242 headers sysdep_headers distribute dont_distribute generated \
\r
1243 others tests xtests test-srcs extra-libs versioned \
\r
1244 $(extra-libs:%=%-routines) \
\r
1245 $(addprefix install-,lib lib.so data bin bin-script sbin others),
\r
1246 echo >> $@.new '$(subdir)-$(var) := $($(var))'
\r
1247 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
\r
1250 ifneq (,$(strip $(gpl2lgpl)))
\r
1251 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
\r
1252 # Snarf from the master source and frob the copying notice.
\r
1253 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
\r
1254 sed -f $^ > $@-tmp
\r
1255 # So I don't edit them by mistake.
\r
1258 ifeq ($(with-cvs),yes)
\r
1259 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@
\r
1264 # Local Variables:
\r