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