* sysdeps/unix/sysv/linux/ia64/pt-initfini.c: Fix unterminated
[glibc.git] / Makerules
blob65b7f0a1bc780064a461c4521c0c0a578282378f
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
17 # 02111-1307 USA.
20 #       Common rules for making the GNU C library.  This file is included
21 #       by the top-level Makefile and by all subdirectory makefiles
22 #       (through Rules).
24 ifneq (,)
25 This makefile requires GNU Make.
26 endif
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.
34 endif
37 ifdef   subdir
38 ..      := ../
39 endif   # subdir
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))" ""
44 sources :=
45 endif
47 oPATH := $(PATH)
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.
51 else
52 PATH := $(oPATH)
53 endif
55 ifndef +included-Makeconfig
56 include $(..)Makeconfig
57 endif
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)
67 ifdef objdir
68 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
69 endif
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).
95 in-Makerules := yes
97 sysdep-makefiles := $(wildcard $(full_config_sysdirs:=/Makefile))
98 ifneq (,$(sysdep-makefiles))
99 include $(sysdep-makefiles)
100 endif
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%,\
108                            $(before-compile)) \
109                   $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
110                                $(before-compile))
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
119         mv -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
124         mv -f $@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.
130 ifdef no_deps
131 ifdef objpfx
132 before-compile += $(objpfx).
133 $(objpfx).:
134         $(make-target-directory)
135 endif
136 endif
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
142 # recompilations.
143 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
145 # Don't let any before-compile file be an intermediate and get removed.
146 ifdef before-compile
147 $(before-compile):
148 endif
150 # Generate an ordered list of implicit rules which find the source files in
151 # each sysdep directory.  The old method was to use vpath to search all the
152 # sysdep directories.  However, that had the problem that a .S file in a
153 # later directory would be chosen over a .c file in an earlier directory,
154 # which does not preserve the desired sysdeps ordering behavior.
156 # When making the list of .d files to include, we can't know which ones
157 # have source in .s files, and thus do not in fact need a .d file.
158 # So we must define rules to make .d files for .s files.
159 define make-dummy-dep
160 $(addprefix ln $(common-objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
161 endef
162 $(common-objpfx)dummy.d:
163         echo '# .s files cannot contain includes, so they need no deps.' > $@
165 # It matters that this set of rules, for compiling from sources in
166 # the current directory (the $srcdir/$subdir) come before the
167 # generated sysdep rules in included from sysd-rules below.  When
168 # compiling in the source tree, generated sources go into the current
169 # directory, and those should be chosen before any sources in sysdeps.
170 define o-iterator-doit
171 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
172 endef
173 object-suffixes-left := $(all-object-suffixes)
174 include $(o-iterator)
175 $(objpfx)%.d: %.S $(before-compile); $(+make-deps)
177 define o-iterator-doit
178 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
179 endef
180 object-suffixes-left := $(all-object-suffixes)
181 include $(o-iterator)
182 $(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep)
184 define o-iterator-doit
185 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
186 endef
187 object-suffixes-left := $(all-object-suffixes)
188 include $(o-iterator)
189 $(objpfx)%.d: %.c $(before-compile); $(+make-deps)
191 # Omit the objpfx rules when building in the source tree, because
192 # objpfx is empty and so these rules just override the ones above.
193 ifdef objpfx
194 # Define first rules to find the source files in $(objpfx).
195 # Generated source files will end up there.
196 define o-iterator-doit
197 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
198 endef
199 object-suffixes-left := $(all-object-suffixes)
200 include $(o-iterator)
201 $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps)
203 define o-iterator-doit
204 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
205 endef
206 object-suffixes-left := $(all-object-suffixes)
207 include $(o-iterator)
208 $(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep)
210 define o-iterator-doit
211 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
212 endef
213 object-suffixes-left := $(all-object-suffixes)
214 include $(o-iterator)
215 $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps)
216 endif
218 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
219 # patterns matching sysdep directories whose assembly source files should
220 # be suppressed.
221 ifdef inhibit-sysdep-asm
222 define open-check-inhibit-asm
223 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
224 endef
225 close-check-inhibit-asm = ;; esac ;
226 endif
228 -include $(+sysdir_pfx)sysd-rules
229 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
230 # The value of $(+sysdep_dirs) the sysd-rules was computed for
231 # differs from the one we are using now.  So force a rebuild of sysd-rules.
232 sysd-rules-force = FORCE
233 FORCE:
234 endif
235 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
236                           $(wildcard $(foreach dir,$(sysdirs),\
237                                                $(dir)/Makefile))\
238                           $(sysd-rules-force)
239         -@rm -f $@T
240         (echo 'sysd-rules-sysdirs := $(config-sysdirs)';                      \
241          for dir in $(config-sysdirs:%='$$(..)%'); do                         \
242            for o in $(all-object-suffixes); do \
243              $(open-check-inhibit-asm) \
244              echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
245                   \$$(compile-command.S)";                                    \
246              echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
247                   \$$(compile-command.s)";                                    \
248              echo "\$$(objpfx)rtld-%$$o: $$dir/%.S \$$(before-compile); \
249                   \$$(compile-command.S)";                                    \
250              echo "\$$(objpfx)rtld-%$$o: $$dir/%.s \$$(before-compile); \
251                   \$$(compile-command.s)";                                    \
252              $(close-check-inhibit-asm) \
253              echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
254                   \$$(compile-command.c)";                                    \
255              echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \
256                   \$$(compile-command.c)";                                    \
257            done; \
258            $(open-check-inhibit-asm) \
259            echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
260                 \$$(make-dummy-dep)";                          \
261            echo "\$$(objpfx)rtld-%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
262                 \$$(make-dummy-dep)";                          \
263            echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
264                 \$$(+make-deps)";                                             \
265            echo "\$$(objpfx)rtld-%.d: $$dir/%.S \$$(before-compile); \
266                 \$$(+make-deps)";                                             \
267            $(close-check-inhibit-asm)   \
268            echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \
269                 \$$(+make-deps)";                                             \
270            echo "\$$(objpfx)rtld-%.d: $$dir/%.c \$$(before-compile); \
271                 \$$(+make-deps)";                                             \
272          done;                                                                \
273          echo 'sysd-rules-done = t') > $@T
274         mv -f $@T $@
276 ifndef sysd-rules-done
277 # Don't do deps until this exists, because it provides rules to make the deps.
278 no_deps=t
279 endif
281 # Generate version maps, but wait until sysdep-subdirs is known
282 ifeq ($(sysd-sorted-done),t)
283 ifeq ($(versioning),yes)
284 -include $(common-objpfx)sysd-versions
285 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
286 common-generated += $(version-maps)
287 postclean-generated += sysd-versions Versions.all abi-versions.h \
288                        Versions.def.v.i Versions.def.v Versions.v.i Versions.v
290 ifndef avoid-generated
291 ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
292 sysd-versions-force = FORCE
293 FORCE:
294 endif
295 # See %.v/%.v.i implicit rules in Makeconfig.
296 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
297                                   $(wildcard $(add-ons:%=$(..)%/Versions.def))
298 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
299                               $(common-objpfx)soversions.i \
300                               $(common-objpfx)Versions.def.v
301         { while read lib version setname; do \
302             test -z "$$setname" || echo "$$lib : $$setname"; \
303           done < $(word 2,$^); \
304           cat $(word 3,$^); \
305         } | LC_ALL=C $(AWK) -f $< > $@T
306         mv -f $@T $@
307 # See %.v/%.v.i implicit rules in Makeconfig.
308 $(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
309                               $(wildcard $(sysdirs:%=%/Versions)) \
310                               $(common-objpfx)abi-versions.h \
311                               $(sysd-versions-force)
312 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
313                                $(common-objpfx)Versions.v \
314                                $(..)scripts/versions.awk
315         ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
316           cat $(word 2,$^) \
317           | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
318                             -v move_if_change='$(move-if-change)' \
319                             -f $(word 3,$^); \
320         ) > $@T
321         mv -f $@T $@
322 endif # avoid-generated
323 endif # $(versioning) = yes
324 endif # sysd-sorted-done
327 ifndef compile-command.S
328 compile-command.S = $(compile.S) $(OUTPUT_OPTION)
329 endif
330 ifndef compile-command.s
331 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION)
332 endif
333 ifndef compile-command.c
334 compile-command.c = $(compile.c) $(OUTPUT_OPTION)
335 endif
337 # GCC can grok options after the file name, and it looks nicer that way.
338 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
339 compile.S = \
340   $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
341 COMPILE.S = \
342   $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
343 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
345 # If we want to generate MD5 checksums for the sources do this now.
346 ifeq ($(md5),yes)
347 generate-md5 = ; rm -f $(@:.d=.md5); \
348 $(CC) -E $< $(CFLAGS) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
349 sed '/^\#/d;/^[[:space:]]*$$/d' | md5sum > $(@:.d=.md5)
350 else
351 generate-md5 =
352 endif
354 # We need this for the output to go in the right place.  It will default to
355 # empty if make was configured to work with a cc that can't grok -c and -o
356 # together.  You can't compile the C library with such a compiler.
357 OUTPUT_OPTION = -o $@
359 # We need the $(CFLAGS) to be in there to have the right predefines during
360 # the dependency run for C sources.  But having it for assembly sources can
361 # get the wrong predefines.
362 S-CPPFLAGS = $(asm-CPPFLAGS)
363 define +make-deps
364 $(make-target-directory)
365 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
366              $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | sed \
367 -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
368 $(sed-remove-objpfx) > $(@:.d=.T)
369 mv -f $(@:.d=.T) $@ $(generate-md5)
370 endef
371 ifneq (,$(objpfx))
372 # Continuation lines here are dangerous because they introduce spaces!
373 define sed-remove-objpfx
374 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
375 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
376 endef
377 endif
379 # Modify the list of routines we build for different targets
381 ifeq (yesyes,$(build-shared)$(elf))
382 ifndef libc.so-version
383 # Undefine this because it can't work when we libc.so is unversioned.
384 static-only-routines =
385 endif
386 endif
388 # Bounded pointer thunks are only built for *.ob
389 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
391 elide-routines.oS += $(filter-out $(static-only-routines),\
392                                   $(routines) $(aux) $(sysdep_routines)) \
393                      $(elide-bp-thunks)
394 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
396 # If we have versioned code we don't need the old versions in any of the
397 # static libraries.
398 elide-routines.o  += $(shared-only-routines) $(elide-bp-thunks)
399 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
400 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
401 elide-routines.ob += $(shared-only-routines)
403 # Shared library building.
405 ifeq (yes,$(build-shared))
407 # Reference map file only when versioning is selected and a map file name
408 # is given.
409 ifeq ($(versioning),yes)
410 map-file = $(firstword $($(@F:.so=-map)) \
411                        $(addprefix $(common-objpfx), \
412                                    $(filter $(@F:.so=.map),$(version-maps))))
413 load-map-file = $(map-file:%=-Wl,--version-script=%)
414 endif
416 # Pattern rule to build a shared object from an archive of PIC objects.
417 # This must come after the installation rules so Make doesn't try to
418 # build shared libraries in place from the installed *_pic.a files.
419 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
420 # on other shared objects.
421 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
422 ifneq (,$(findstring aix,$(config-os)))
423         (echo '#!'; \
424          dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
425 endif
426         $(build-shlib)
428 ifeq ($(elf),yes)
429 define build-shlib-helper
430 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
431           $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
432           $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
433           -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
434           $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
435           -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
436 endef
437 else
438 ifneq (,$(findstring aix,$(config-os)))
439 define build-shlib-helper
440 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
441           $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
442           $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
443           $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
444           -L$(subst :, -L,$(rpath-link))
445 endef
446 else
447 endif
448 endif
450 ifeq (yes,$(elf))
451 # binutils only position loadable notes into the first page for binaries,
452 # not for shared objects
453 define build-shlib
454 $(build-shlib-helper) \
455           -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
456           $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
457           sed -e '/^=========/,/^=========/!d;/^=========/d' \
458               -e 's/^.*\.hash[  ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
459               $(LDSEDCMD-$(@F:lib%.so=%).so) > $@.lds
460 rm -f $@.new
461 $(build-shlib-helper) -o $@ -T $@.lds \
462           $(csu-objpfx)abi-note.o $(build-shlib-objlist)
463 rm -f $@.lds
464 endef
465 else
466 ifneq (,$(findstring aix,$(config-os)))
467 define build-shlib
468 $(build-shlib-helper) \
469         -o $@ \
470         $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
471         $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
472 endef
473 define build-shlib
474 $(build-shlib-helper) \
475           $(build-shlib-objlist)
476 endef
477 endif
478 endif
480 ifneq (,$(findstring aix,$(config-os)))
481 define build-module-helper
482 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
483           $(sysdep-LDFLAGS) $(config-LDFLAGS) \
484           $(load-map-file) \
485           $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
486           -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
487 endef
488 else
489 define build-module-helper
490 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
491           -B$(csu-objpfx) $(load-map-file) \
492           $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
493           -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
494 endef
495 endif
497 # This macro is similar to build-shlib but it does not define a soname
498 # and it does not depend on the destination name to start with `lib'.
499 ifeq (yes,$(elf))
500 # binutils only position loadable notes into the first page for binaries,
501 # not for shared objects
502 define build-module
503 $(build-module-helper) \
504           -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
505           $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
506           sed -e '/^=========/,/^=========/!d;/^=========/d' \
507               -e 's/^.*\.hash[  ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
508           > $@.lds
509 rm -f $@.new
510 $(build-module-helper) -o $@ -T $@.lds \
511           $(csu-objpfx)abi-note.o $(build-module-objlist)
512 rm -f $@.lds
513 endef
514 else
515 ifneq (,$(findstring aix,$(config-os)))
516 define build-module
517 $(build-module-helper) \
518           -o $@ \
519           $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
520           $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
521 endef
522 else
523 define build-module
524 define build-module
525 $(build-module-helper) \
526           -o $@ \
527           $(build-module-objlist)
528 endef
529 endif
530 endif
532 build-module-helper-objlist = \
533         $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
534                    $(filter-out $(map-file) $(+preinit) $(+postinit),$^))
535 whole-archive := -Wl,--whole-archive
537 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
538 build-shlib-objlist = $(build-module-helper-objlist) \
539                       $(LDLIBS-$(@F:lib%.so=%).so)
541 # Don't try to use -lc when making libc.so itself.
542 # Also omits crti.o and crtn.o, which we do not want
543 # since we define our own `.init' section specially.
544 LDFLAGS-c.so = -nostdlib -nostartfiles
545 # But we still want to link libc.so against $(gnulib).
546 LDLIBS-c.so += $(gnulib)
547 # Give libc.so an entry point and make it directly runnable itself.
548 LDFLAGS-c.so += -e __libc_main
549 # Force the backward compatibility EH functions to be linked.
550 LDFLAGS-c.so += -u __register_frame
551 # Pre-link the objects of libc_pic.a so that we can locally resolve
552 # COMMON symbols before we link against ld.so.  This is because ld.so
553 # contains some of libc_pic.a already, which will prevent the COMMONs
554 # from being allocated in libc.so, which introduces evil dependencies
555 # between libc.so and ld.so, which can make it impossible to upgrade.
556 ifeq ($(elf),yes)
557 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
558         $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
559         $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
560 LDSEDCMD-c.so = -e 's/^.*\*(\.dynbss).*$$/& __start___libc_freeres_ptrs = .; *(__libc_freeres_ptrs) __stop___libc_freeres_ptrs = .;/'
561 # Use our own special initializer and finalizer files for libc.so.
562 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
563                          $(common-objpfx)libc_pic.os \
564                          $(elfobjdir)/sofini.os \
565                          $(elfobjdir)/interp.os $(elfobjdir)/ld.so
566         $(build-shlib)
567 ifeq ($(versioning),yes)
568 $(common-objpfx)libc.so: $(common-objpfx)libc.map
569 endif
570 common-generated += libc.so libc_pic.os
571 ifdef libc.so-version
572 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
573         $(make-link)
574 common-generated += libc.so$(libc.so-version)
575 endif
576 endif
577 else
578 ifneq (,$(findstring aix,$(config-os)))
579 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
580         @rm -f $@
581         (echo '#!'; \
582          dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
583         sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
584             /lib/syscalls.exp > $(common-objpfx)syscalls.exp
585         $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
586                   -bE:$(common-objpfx)syscalls.exp \
587                   -bI:$(common-objpfx)syscalls.exp \
588                   -L$(common-objpfx) -o $@ $^
589 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
590         cp $@ $(common-objpfx)shr.o
591         $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
592 endif
593 endif
595 # Figure out the source filenames in this directory.
597 override sources := $(addsuffix .c,\
598                         $(filter-out $(elided-routines),\
599                             $(routines) $(aux) \
600                             $(sysdep_routines)))
601 sysdep_routines := $(sysdep_routines)
603 headers := $(headers) $(sysdep_headers)
605 # This is the list of all object files, gotten by
606 # replacing every ".c" in `sources' with a ".o".
607 # We also add bounded-pointer thunks, which are later
608 # elided for all suffixes except for `.ob'.
609 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
610                       $(patsubst %,$(bppfx)%.o,\
611                         $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
614 # The makefile may define $(extra-libs) with `libfoo libbar'
615 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
616 ifdef extra-libs
617 # extra-lib.mk is included once for each extra lib to define rules
618 # to build it, and to add its objects to the various variables.
619 # During its evaluation, $(lib) is set to the name of the library.
620 extra-libs-left := $(extra-libs)
621 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
622 endif
624 +depfiles := $(sources:.c=.d) \
625              $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
626              $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
627 ifeq ($(build-programs),yes)
628 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
629 endif
630 +depfiles := $(addprefix $(objpfx),\
631                          $(filter-out $(addsuffix .d,$(omit-deps)),\
632                                       $(+depfiles)))
634 ifdef +depfiles
635 ifneq ($(no_deps),t)
636 -include $(+depfiles)
637 endif
638 endif
639 \f\f
640 # Maximize efficiency by minimizing the number of rules.
641 .SUFFIXES:      # Clear the suffix list.  We don't use suffix rules.
642 # Don't define any builtin rules.
643 MAKEFLAGS := $(MAKEFLAGS)r
645 # Generic rule for making directories.
647 # mkdir isn't smart enough to strip a trailing /.
648         mkdir $(@:%/=%)
650 # Make sure that object files are not removed
651 # when they are intermediates between sources and library members.
652 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
654 # Make sure that the parent library archive is never removed.
655 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
657 # Use the verbose option of ar and tar when not running silently.
658 ifeq    "$(findstring s,$(MAKEFLAGS))" ""       # if not -s
659 verbose := v
660 else                                            # -s
661 verbose :=
662 endif                                           # not -s
664 ARFLAGS := r$(verbose)
665 CREATE_ARFLAGS := cru$(verbose)
667 # This makes all the object files in the parent library archive.
669 .PHONY: lib lib-noranlib
670 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
671 lib-noranlib: libobjs
673 # For object-suffix $o, the list of objects with that suffix.
674 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
675 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
676                                                        $(elide-routines$o)),\
677                                             $(objects))) \
678             $(addprefix $(objpfx),$(o-objects$o))
680 others: $(addprefix $(objpfx),$(install-lib))
682 ifndef objects
684 # Create the stamp$o files to keep the parent makefile happy.
685 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
686 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
687         $(make-target-directory)
688         rm -f $@; > $@
689 else
691 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
692 # timestamp file; these rules (one explicit rule is generated for each
693 # object suffix) write a list of objects to update in the stamp file.
694 # The parent will then actually add them all to the archive in the
695 # archive rule, below.
696 define o-iterator-doit
697 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
698 endef
699 define do-stamp
700 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
701 mv -f $@T $@
702 endef
703 object-suffixes-left := $(object-suffixes-for-libc)
704 include $(o-iterator)
706 endif
708 # Now define explicit rules to build the library archives; these depend
709 # on the stamp files built above.
710 define o-iterator-doit
711 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
712                 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
713 endef
714 define do-makelib
715 cd $(common-objdir) && \
716 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
717 $(RANLIB) $@
718 endef
719 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
720 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
721 ifndef subdir
722 $(subdirs-stamps): subdir_lib;
723 endif
724 object-suffixes-left = $(object-suffixes-for-libc)
725 include $(o-iterator)
728 # This makes all the object files.
729 .PHONY: objects objs libobjs extra-objs
730 objects objs: libobjs extra-objs
731 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
732 extra-objs: $(addprefix $(objpfx),$(extra-objs))
734 # Canned sequence for building an extra library archive.
735 define build-extra-lib
736 $(patsubst %/,cd % &&,$(objpfx)) \
737 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
738       $(patsubst $(objpfx)%,%,$^)
739 $(RANLIB) $@
740 endef
742 # Installation.
744 .PHONY: force-install
745 force-install:
747 # $(install-lib) are installed from the object directory into $(libdir);
748 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
749 # unless they also appear in $(non-lib.a).  $(install-data) are installed
750 # as they are into $(datadir).  $(headers) are installed as they are in
751 # $(includedir).  $(install-bin), $(install-bin-script) and $(install-sbin)
752 # are installed from the object directory into $(bindir), $(bindir) and
753 # $(sbindir), respectively.  $(install-others) are absolute path names of
754 # files to install; rules to install them are defined elsewhere.
756 # The simple library name to install libc.a under.
757 # This could be defined by a sysdep Makefile.
758 ifndef libc-name
759 libc-name := c
760 endif
762 define do-install
763 $(make-target-directory)
764 $(INSTALL_DATA) $< $@
765 endef
767 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
768 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
769 define make-target-directory
770 $(addprefix $(..)./scripts/mkinstalldirs ,\
771             $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
772 endef
774 # Any directory (parent or subdir) should install libc.a; this way
775 # "make install" in a subdir is guaranteed to install everything it changes.
776 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
777                              $(inst_libdir)/$(patsubst %,$(libtype$o),\
778                                                      $(libprefix)$(libc-name)))
779 install: $(installed-libcs)
780 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
781         $(make-target-directory)
782         $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
783 # Running ranlib after installing makes the __.SYMDEF time stamp up to
784 # date, which avoids messages from some linkers.
785         $(RANLIB) $@
787 define do-install-program
788 $(make-target-directory)
789 $(INSTALL_PROGRAM) $< $@.new
790 mv -f $@.new $@
791 endef
793 define do-install-script
794 $(make-target-directory)
795 $(INSTALL_SCRIPT) $< $@.new
796 mv -f $@.new $@
797 endef
799 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
800 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
802 ifeq (yes,$(build-shared))
803 # Find which .so's have versions.
804 versioned := $(strip $(foreach so,$(install-lib.so),\
805                                $(patsubst %,$(so),$($(so)-version))))
807 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
808 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
810 install-lib-nosubdir: $(install-lib.so-versioned:%=$(inst_libdir)/%) \
811                       $(install-lib.so-unversioned:%=$(inst_slibdir)/%)
813 # Install all the unversioned shared libraries.
814 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
815     $(objpfx)%.so $(+force)
816         $(do-install-program)
818 ifneq ($(findstring -s,$(LN_S)),)
819 define make-link
820 rm -f $@.new
821 $(SHELL) $(..)scripts/rellns-sh $< $@.new
822 mv -f $@.new $@
823 endef
824 else
825 # If we have no symbolic links don't bother with rellns-sh.
826 define make-link
827 rm -f $@.new
828 $(LN_S) $< $@.new
829 mv -f $@.new $@
830 endef
831 endif
833 ifeq (yes,$(build-shared))
834 ifeq (no,$(cross-compiling))
835 symbolic-link-prog := $(common-objpfx)elf/sln
836 symbolic-link-list := $(common-objpfx)elf/symlink.list
837 define make-shlib-link
838 echo $(<F) $@ >> $(symbolic-link-list)
839 endef
840 else # cross-compiling
841 # We need a definition that can be used by elf/Makefile's install rules.
842 symbolic-link-prog = $(LN_S)
843 endif
844 endif
845 ifndef make-shlib-link
846 define make-shlib-link
847 rm -f $@
848 $(LN_S) $(<F) $@
849 endef
850 endif
852 ifdef libc.so-version
853 # For a library specified to be version N, install three files:
854 # libc.so       ->      libc.so.N       (e.g. libc.so.6)
855 # libc.so.6     ->      libc-VERSION.so (e.g. libc-1.10.so)
857 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
858                                            $(+force)
859         $(make-shlib-link)
860 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
861         $(do-install-program)
862 install: $(inst_slibdir)/libc.so$(libc.so-version)
864 ifndef subdir
865 # What we install as libc.so for programs to link against is in fact a
866 # link script.  It contains references for the various libraries we need.
867 # The libc.so object is not complete since some functions are only defined
868 # in libc_nonshared.a.
869 # We need to use absolute paths since otherwise local copies (if they exist)
870 # of the files are taken by the linker.
871 install: $(inst_libdir)/libc.so
872 $(inst_libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \
873                         $(inst_libdir)/$(patsubst %,$(libtype.oS),\
874                                                   $(libprefix)$(libc-name)) \
875                         $(+force)
876         (echo '/* GNU ld script';\
877          echo '   Use the shared library, but some functions are only in';\
878          echo '   the static library, so try that secondarily.  */';\
879          echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
880               '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
881               ')' \
882         ) > $@.new
883         mv -f $@.new $@
885 endif
887 else
888 install: $(inst_slibdir)/libc.so
889 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
890         $(do-install-program)
891 endif
893 ifneq (,$(versioned))
894 # Produce three sets of rules as above for all the smaller versioned libraries.
896 define o-iterator-doit
897 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
898 endef
899 object-suffixes-left := $(versioned)
900 include $(o-iterator)
902 # Make symlinks in the build directory, because the versioned names might
903 # be referenced by a DT_NEEDED in another library.
904 define o-iterator-doit
905 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
906 endef
907 object-suffixes-left := $(versioned)
908 include $(o-iterator)
910 generated += $(foreach o,$(versioned),$o$($o-version))
912 ifeq (,$($(subdir)-version))
913 define o-iterator-doit
914 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
915                                  $(+force);
916         $$(make-shlib-link)
917 endef
918 object-suffixes-left := $(versioned)
919 include $(o-iterator)
921 define o-iterator-doit
922 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
923         $$(do-install-program)
924 endef
925 object-suffixes-left := $(versioned)
926 include $(o-iterator)
927 else
928 define o-iterator-doit
929 $(inst_slibdir)/$o$($o-version): \
930   $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
931         $$(make-shlib-link)
932 endef
933 object-suffixes-left := $(versioned)
934 include $(o-iterator)
936 define o-iterator-doit
937 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
938         $$(do-install-program)
939 endef
940 object-suffixes-left := $(versioned)
941 include $(o-iterator)
942 endif
943 endif
945 define do-install-so
946 $(do-install-program)
947 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
948            $(filter-out %.so,$@))
949 endef
951 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
952 $(foreach v,$(so-versions),\
953           $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
954                                                $(+force)
955         $(do-install-so)
956 $(foreach v,$(so-versions),\
957           $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
958         $(do-install-so)
959 endif
961 ifdef install-bin
962 $(addprefix $(inst_bindir)/,$(install-bin)): \
963     $(inst_bindir)/%: $(objpfx)% $(+force)
964         $(do-install-program)
965 endif
966 ifdef install-bin-script
967 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
968     $(inst_bindir)/%: $(objpfx)% $(+force)
969         $(do-install-script)
970 endif
971 ifdef install-rootsbin
972 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
973    $(inst_rootsbindir)/%: $(objpfx)% $(+force)
974         $(do-install-program)
975 endif
976 ifdef install-sbin
977 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
978     $(inst_sbindir)/%: $(objpfx)% $(+force)
979         $(do-install-program)
980 endif
981 ifdef install-lib
982 install-lib.a := $(filter lib%.a,$(install-lib))
983 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
984 ifdef install-lib-non.a
985 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
986   $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
987         $(do-install)
988 endif
989 ifdef install-lib.a
990 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
991   $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
992         $(do-install)
993         $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
994 endif
995 endif
996 ifdef install-data
997 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
998         $(do-install)
999 endif
1000 headers := $(strip $(headers))
1001 ifdef headers
1002 $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
1003         $(do-install)
1004 endif   # headers
1006 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1007         install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1008         install-data-nosubdir install-headers-nosubdir
1009 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1010 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1011 install-rootsbin-nosubdir: \
1012         $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1013 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1014 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1015                        $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1016                        $(addprefix $(libprefix),$(install-lib-non.a)))
1017 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1018 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1019 install-others-nosubdir: $(install-others)
1021 # We need all the `-nosubdir' targets so that `install' in the parent
1022 # doesn't depend on several things which each iterate over the subdirs.
1023 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1024 # subroutine.  Then in the parent `install-FOO' also causes subdir makes.
1025 install-%:: install-%-nosubdir ;
1027 .PHONY: install install-no-libc.a-nosubdir
1028 ifeq ($(build-programs),yes)
1029 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1030                             install-bin-nosubdir install-bin-script-nosubdir \
1031                             install-lib-nosubdir install-others-nosubdir \
1032                             install-rootsbin-nosubdir install-sbin-nosubdir
1033 else
1034 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1035                             install-lib-nosubdir install-others-nosubdir
1036 endif
1037 install: install-no-libc.a-nosubdir
1039 # Command to compile $< in $(objdir) using the native libraries.
1040 define native-compile
1041 $(make-target-directory)
1042 $(patsubst %/,cd % &&,$(objpfx)) \
1043 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1044             $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1045 endef
1047 # Command to compile $< in $(common-objdir) using the native libraries.
1048 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1049 define common-objdir-compile
1050 $(patsubst %/,cd % &&,$(objpfx)) \
1051 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1052             $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1053 endef
1055 # We always want to use configuration definitions.
1056 # Note that this is only used for commands running in $(objpfx).
1057 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1059 # Support the GNU standard name for this target.
1060 .PHONY: check
1061 check: tests
1062 # Special target to run tests which cannot be run unconditionally.
1063 # Maintainers should use this target.
1064 .PHONY: xcheck
1065 xcheck: xtests
1067 all-nonlib = $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) $(others))
1068 ifneq (,$(all-nonlib))
1069 cpp-srcs-left = $(all-nonlib:=.c)
1070 lib := nonlib
1071 include $(patsubst %,$(..)cppflags-iterator.mk,$(all-nonlib))
1072 endif
1074 # The include magic above causes those files to use this variable for flags.
1075 CPPFLAGS-nonlib = -DNOT_IN_libc=1
1078 ifeq ($(versioning),yes)
1079 # Generate normalized lists of symbols, versions, and data sizes.
1080 # This is handy for checking against existing library binaries.
1082 $(objpfx)%.symlist: $(..)scripts/abilist.awk $(objpfx)%.dynsym
1083         $(AWK) -f $^ > $@T
1084         mv -f $@T $@
1086 $(objpfx)%.dynsym: $(objpfx)%.so
1087         $(OBJDUMP) --dynamic-syms $< > $@T
1088         mv -f $@T $@
1090 tests: $(patsubst %.so,$(objpfx)%.symlist,$(install-lib.so-versioned))
1091 generated += $(install-lib.so-versioned:.so=.symlist)
1093 ifeq ($(subdir),elf)
1094 tests: $(common-objpfx)libc.symlist
1095 common-generated += libc.symlist
1096 endif
1097 endif
1099 .PHONY: TAGS
1100 TAGS: $(objpfx)distinfo $(..)MakeTAGS
1101         $(MAKE) $(addprefix -f ,$^) $@
1103 $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE
1104         $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
1105 FORCE:
1108 .PHONY: echo-headers
1109 echo-headers:
1110         @echo $(headers)
1113 # Common cleaning targets.
1115 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1116 clean: common-clean
1117 mostlyclean: common-mostlyclean
1119 do-tests-clean:
1120         -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
1121                                                       $(test-srcs)) \
1122                                      $(addsuffix -bp.out,$(tests) $(xtests) \
1123                                                          $(test-srcs)))
1125 # Remove the object files.
1126 common-mostlyclean:
1127         -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \
1128                                      $(others) $(sysdep-others) stubs \
1129                                      $(addsuffix .o,$(tests) $(xtests) \
1130                                                     $(test-srcs) $(others) \
1131                                                     $(sysdep-others)) \
1132                                      $(addsuffix -bp,$(tests) $(xtests) \
1133                                                      $(test-srcs)) \
1134                                      $(addsuffix .out,$(tests) $(xtests) \
1135                                                       $(test-srcs)) \
1136                                      $(addsuffix -bp.out,$(tests) $(xtests) \
1137                                                          $(test-srcs)))
1138         -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
1139                                      $(install-lib.so) \
1140                                      $(install-lib.so:%.so=%_pic.a))
1141         -rm -f core
1142         -rm -f $(objpfx)rtld-*.os
1143         $(rmobjs)
1144 define rmobjs
1145 $(foreach o,$(object-suffixes-for-libc),
1146 -rm -f $(objpfx)stamp$o $(o-objects))
1147 endef
1149 # Also remove the dependencies and generated source files.
1150 common-clean: common-mostlyclean
1151         -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
1152         -rm -f $(objpfx)rtld-*.d
1153         -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1154         -rm -f $(addprefix $(common-objpfx),$(common-generated))
1155         -rm -f $(objpfx)distinfo
1157 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1158 # for each function which is a stub.  We grovel over all the .d files
1159 # looking for references to <stub-tag.h>.  Then we grovel over each
1160 # referenced source file to see what stub function it defines.
1162 ifdef objpfx
1163 .PHONY: stubs # The parent Makefile calls this target.
1164 stubs: $(objpfx)stubs
1165 endif
1166 s = $(sysdep_dir)/generic
1167 $(objpfx)stubs: $(+depfiles)
1168 # Use /dev/null since `...` might expand to empty.
1169         (s=`cd $s && $(PWD_P)`; \
1170          $(patsubst %/,cd % &&,$(objpfx)) \
1171          sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
1172           `sed -n -e '\@ $s/[^ ]*\.c@{; s@^.* $s/\([^ ]*\.c\).*$$@'"$$s"'/\1@; h; }' \
1173                 -e '/stub-tag\.h/{; g; p; }' \
1174                   $(patsubst $(objpfx)%,%,$^) /dev/null` \
1175              /dev/null) > $@T
1176         mv -f $@T $@
1178 # Make the distribution tar file.
1180 .PHONY: dist
1181 dist: $(objpfx)distinfo $(..)Make-dist
1182         $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
1184 # Avoid depending on source files found in sysdeps dirs,
1185 # because the references affect implicit rule selection.
1186 dist: $(filter-out %.c %.S %.s,$(distribute))
1188 # We used to simply export all these variables, but that frequently made the
1189 # environment get too large.  Instead, we write all the information into
1190 # a generated makefile fragment `distinfo', and then include it with -f in
1191 # the sub-make that makes the distribution (above).
1192 $(objpfx)distinfo: Makefile $(..)Makerules \
1193                    $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile))
1194         $(make-target-directory)
1195         $(distinfo-vars)
1196         mv -f $@.new $@
1197 .PHONY: subdir_distinfo
1198 subdir_distinfo: $(objpfx)distinfo
1200 define distinfo-vars
1201 rm -f $@.new
1202 echo > $@.new 'subdir := $(subdir)'
1203 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
1204               headers sysdep_headers distribute dont_distribute generated \
1205               others tests xtests test-srcs extra-libs versioned \
1206               $(extra-libs:%=%-routines) \
1207               $(addprefix install-,lib lib.so data bin bin-script sbin others),
1208 echo >> $@.new '$(subdir)-$(var) := $($(var))'
1209 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
1210 endef
1212 ifneq (,$(strip $(gpl2lgpl)))
1213 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1214 # Snarf from the master source and frob the copying notice.
1215 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1216         sed -f $^ > $@-tmp
1217 # So I don't edit them by mistake.
1218         chmod a-w $@-tmp
1219         mv -f $@-tmp $@
1220 ifeq ($(with-cvs),yes)
1221         test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@
1222 endif
1223 endif
1224 endif
1226 # Local Variables:
1227 # mode: makefile
1228 # End: