]> git.ipfire.org Git - thirdparty/glibc.git/blob - Makerules
Update.
[thirdparty/glibc.git] / Makerules
1 # Copyright (C) 1991-1999,2000,01,02 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
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.
8
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.
13
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.
18
19 #
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).
23 #
24 ifneq (,)
25 This makefile requires GNU Make.
26 endif
27
28 REQUIRED_MAKE_VERSION = 3.74
29 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
30
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
35
36
37 ifdef subdir
38 .. := ../
39 endif # subdir
40
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
46
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
54 \f
55 ifndef +included-Makeconfig
56 include $(..)Makeconfig
57 endif
58
59 # `configure' writes a definition of `config-sysdirs' in `config.make'.
60 sysdirs = $(strip $(full_config_sysdirs))
61
62 +sysdir_pfx = $(common-objpfx)
63
64 export sysdirs := $(sysdirs)
65
66 +sysdep_dirs := $(full_config_sysdirs)
67 ifdef objdir
68 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
69 endif
70
71 # Add -I switches to get the right sysdep directories.
72 # `+includes' in Makeconfig references $(+sysdep-includes).
73 +sysdep-includes := $(addprefix -I,$(+sysdep_dirs))
74
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))
80 \f
81 # Include any system-specific makefiles.
82
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) $(..)))
88
89 # The same is true for RPC source files.
90 vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
91 $(+sysdep_dirs) $(..)))
92
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
96
97 sysdep-makefiles := $(wildcard $(full_config_sysdirs:=/Makefile))
98 ifneq (,$(sysdep-makefiles))
99 include $(sysdep-makefiles)
100 endif
101
102
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))
111
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 $@
120
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
127
128
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))
135
136 # Don't let any before-compile file be an intermediate and get removed.
137 ifdef before-compile
138 $(before-compile):
139 endif
140 \f
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.
146
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.' > $@
155
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)
167
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)
174
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)
181
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)
193
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)
200
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
208
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
218
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 $(close-check-inhibit-asm) \
240 echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
241 \$$(compile-command.c)"; \
242 done; \
243 $(open-check-inhibit-asm) \
244 echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
245 \$$(make-dummy-dep)"; \
246 echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
247 \$$(+make-deps)"; \
248 $(close-check-inhibit-asm) \
249 echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \
250 \$$(+make-deps)"; \
251 done; \
252 echo 'sysd-rules-done = t') > $@T
253 mv -f $@T $@
254
255 ifndef sysd-rules-done
256 # Don't do deps until this exists, because it provides rules to make the deps.
257 no_deps=t
258 endif
259
260 # Generate version maps, but wait until sysdep-subdirs is known
261 ifeq ($(sysd-sorted-done),t)
262 ifeq ($(versioning),yes)
263 -include $(common-objpfx)sysd-versions
264 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
265 common-generated += $(version-maps)
266 postclean-generated += sysd-versions Versions.all abi-versions.h \
267 Versions.def.v.i Versions.def.v Versions.v.i Versions.v
268
269 ifndef avoid-generated
270 ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
271 sysd-versions-force = FORCE
272 FORCE:
273 endif
274 # See %.v/%.v.i implicit rules in Makeconfig.
275 $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
276 $(wildcard $(add-ons:%=$(..)%/Versions.def))
277 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
278 $(common-objpfx)soversions.i \
279 $(common-objpfx)Versions.def.v
280 { while read lib version setname; do \
281 test -z "$$setname" || echo "$$lib : $$setname"; \
282 done < $(word 2,$^); \
283 cat $(word 3,$^); \
284 } | LC_ALL=C $(AWK) -f $< > $@T
285 mv -f $@T $@
286 # See %.v/%.v.i implicit rules in Makeconfig.
287 $(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
288 $(wildcard $(sysdirs:%=%/Versions)) \
289 $(common-objpfx)abi-versions.h \
290 $(sysd-versions-force)
291 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
292 $(common-objpfx)Versions.v \
293 $(..)scripts/versions.awk
294 ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
295 cat $(word 2,$^) \
296 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
297 -v move_if_change='$(move-if-change)' \
298 -f $(word 3,$^); \
299 ) > $@T
300 mv -f $@T $@
301 endif # avoid-generated
302 endif # $(versioning) = yes
303 endif # sysd-sorted-done
304
305
306 ifndef compile-command.S
307 compile-command.S = $(compile.S) $(OUTPUT_OPTION)
308 endif
309 ifndef compile-command.s
310 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION)
311 endif
312 ifndef compile-command.c
313 compile-command.c = $(compile.c) $(OUTPUT_OPTION)
314 endif
315
316 # GCC can grok options after the file name, and it looks nicer that way.
317 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
318 compile.S = \
319 $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
320 COMPILE.S = \
321 $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
322 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
323
324 # If we want to generate MD5 checksums for the sources do this now.
325 ifeq ($(md5),yes)
326 generate-md5 = ; rm -f $(@:.d=.md5); \
327 $(CC) -E $< $(CFLAGS) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
328 sed '/^\#/d;/^[[:space:]]*$$/d' | md5sum > $(@:.d=.md5)
329 else
330 generate-md5 =
331 endif
332
333 # We need this for the output to go in the right place. It will default to
334 # empty if make was configured to work with a cc that can't grok -c and -o
335 # together. You can't compile the C library with such a compiler.
336 OUTPUT_OPTION = -o $@
337
338 S-CPPFLAGS = $(asm-CPPFLAGS)
339 define +make-deps
340 $(make-target-directory)
341 -@rm -f $@
342 $(+mkdep) $< $(CFLAGS) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
343 sed \
344 -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
345 $(sed-remove-objpfx) > $(@:.d=.T)
346 mv -f $(@:.d=.T) $@ $(generate-md5)
347 endef
348 ifneq (,$(objpfx))
349 # Continuation lines here are dangerous because they introduce spaces!
350 define sed-remove-objpfx
351 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
352 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
353 endef
354 endif
355 \f
356 # Modify the list of routines we build for different targets
357
358 ifeq (yesyes,$(build-shared)$(elf))
359 ifndef libc.so-version
360 # Undefine this because it can't work when we libc.so is unversioned.
361 static-only-routines =
362 endif
363 endif
364
365 # Bounded pointer thunks are only built for *.ob
366 elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
367
368 elide-routines.oS += $(filter-out $(static-only-routines),\
369 $(routines) $(aux) $(sysdep_routines)) \
370 $(elide-bp-thunks)
371 elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
372
373 # If we have versioned code we don't need the old versions in any of the
374 # static libraries.
375 elide-routines.o += $(shared-only-routines) $(elide-bp-thunks)
376 elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
377 elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
378 elide-routines.ob += $(shared-only-routines)
379 \f
380 # Shared library building.
381
382 ifeq (yes,$(build-shared))
383
384 # Reference map file only when versioning is selected and a map file name
385 # is given.
386 ifeq ($(versioning),yes)
387 map-file = $(firstword $($(@F:.so=-map)) \
388 $(addprefix $(common-objpfx), \
389 $(filter $(@F:.so=.map),$(version-maps))))
390 load-map-file = $(map-file:%=-Wl,--version-script=%)
391 endif
392
393 # Pattern rule to build a shared object from an archive of PIC objects.
394 # This must come after the installation rules so Make doesn't try to
395 # build shared libraries in place from the installed *_pic.a files.
396 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
397 # on other shared objects.
398 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
399 ifneq (,$(findstring aix,$(config-os)))
400 (echo '#!'; \
401 dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
402 endif
403 $(build-shlib)
404
405 ifeq ($(elf),yes)
406 define build-shlib-helper
407 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
408 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
409 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
410 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
411 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
412 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
413 endef
414 else
415 ifneq (,$(findstring aix,$(config-os)))
416 define build-shlib-helper
417 $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
418 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
419 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
420 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
421 -L$(subst :, -L,$(rpath-link))
422 endef
423 else
424 endif
425 endif
426
427 ifeq (yes,$(elf))
428 # binutils only position loadable notes into the first page for binaries,
429 # not for shared objects
430 define build-shlib
431 $(build-shlib-helper) \
432 -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
433 $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
434 sed -e '/^=========/,/^=========/!d;/^=========/d' \
435 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
436 > $@.lds
437 rm -f $@.new
438 $(build-shlib-helper) -o $@ -T $@.lds \
439 $(csu-objpfx)abi-note.o $(build-shlib-objlist)
440 rm -f $@.lds
441 endef
442 else
443 ifneq (,$(findstring aix,$(config-os)))
444 define build-shlib
445 $(build-shlib-helper) \
446 -o $@ \
447 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
448 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
449 endef
450 define build-shlib
451 $(build-shlib-helper) \
452 $(build-shlib-objlist)
453 endef
454 endif
455 endif
456
457 ifneq (,$(findstring aix,$(config-os)))
458 define build-module-helper
459 $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
460 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
461 $(load-map-file) \
462 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
463 -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
464 endef
465 else
466 define build-module-helper
467 $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
468 -B$(csu-objpfx) $(load-map-file) \
469 $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
470 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
471 endef
472 endif
473
474 # This macro is similar to build-shlib but it does not define a soname
475 # and it does not depend on the destination name to start with `lib'.
476 ifeq (yes,$(elf))
477 # binutils only position loadable notes into the first page for binaries,
478 # not for shared objects
479 define build-module
480 $(build-module-helper) \
481 -o $@.new $(csu-objpfx)abi-note.o -Wl,--verbose \
482 $(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
483 sed -e '/^=========/,/^=========/!d;/^=========/d' \
484 -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
485 > $@.lds
486 rm -f $@.new
487 $(build-module-helper) -o $@ -T $@.lds \
488 $(csu-objpfx)abi-note.o $(build-module-objlist)
489 rm -f $@.lds
490 endef
491 else
492 ifneq (,$(findstring aix,$(config-os)))
493 define build-module
494 $(build-module-helper) \
495 -o $@ \
496 $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
497 $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
498 endef
499 else
500 define build-module
501 define build-module
502 $(build-module-helper) \
503 -o $@ \
504 $(build-module-objlist)
505 endef
506 endif
507 endif
508
509 build-module-helper-objlist = \
510 $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
511 $(filter-out $(map-file) $(+preinit) $(+postinit),$^))
512 whole-archive := -Wl,--whole-archive
513
514 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
515 build-shlib-objlist = $(build-module-helper-objlist) \
516 $(LDLIBS-$(@F:lib%.so=%).so)
517
518 # Don't try to use -lc when making libc.so itself.
519 # Also omits crti.o and crtn.o, which we do not want
520 # since we define our own `.init' section specially.
521 LDFLAGS-c.so = -nostdlib -nostartfiles
522 # But we still want to link libc.so against $(gnulib).
523 LDLIBS-c.so += $(gnulib)
524 # Give libc.so an entry point and make it directly runnable itself.
525 LDFLAGS-c.so += -e __libc_main
526 # Force the backward compatibility EH functions to be linked.
527 LDFLAGS-c.so += -u __register_frame
528 # Pre-link the objects of libc_pic.a so that we can locally resolve
529 # COMMON symbols before we link against ld.so. This is because ld.so
530 # contains some of libc_pic.a already, which will prevent the COMMONs
531 # from being allocated in libc.so, which introduces evil dependencies
532 # between libc.so and ld.so, which can make it impossible to upgrade.
533 ifeq ($(elf),yes)
534 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
535 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
536 $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
537 # Use our own special initializer and finalizer files for libc.so.
538 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
539 $(common-objpfx)libc_pic.os \
540 $(elfobjdir)/sofini.os \
541 $(elfobjdir)/interp.os $(elfobjdir)/ld.so
542 $(build-shlib)
543 ifeq ($(versioning),yes)
544 $(common-objpfx)libc.so: $(common-objpfx)libc.map
545 endif
546 common-generated += libc.so libc_pic.os
547 ifdef libc.so-version
548 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
549 $(make-link)
550 common-generated += libc.so$(libc.so-version)
551 endif
552 endif
553 else
554 ifneq (,$(findstring aix,$(config-os)))
555 $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
556 @rm -f $@
557 (echo '#!'; \
558 dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
559 sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
560 /lib/syscalls.exp > $(common-objpfx)syscalls.exp
561 $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
562 -bE:$(common-objpfx)syscalls.exp \
563 -bI:$(common-objpfx)syscalls.exp \
564 -L$(common-objpfx) -o $@ $^
565 # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
566 cp $@ $(common-objpfx)shr.o
567 $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
568 endif
569 endif
570 \f
571 # Figure out the source filenames in this directory.
572
573 override sources := $(addsuffix .c,\
574 $(filter-out $(elided-routines),\
575 $(routines) $(aux) \
576 $(sysdep_routines)))
577 sysdep_routines := $(sysdep_routines)
578
579 headers := $(headers) $(sysdep_headers)
580
581 # This is the list of all object files, gotten by
582 # replacing every ".c" in `sources' with a ".o".
583 # We also add bounded-pointer thunks, which are later
584 # elided for all suffixes except for `.ob'.
585 override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
586 $(patsubst %,$(bppfx)%.o,\
587 $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
588
589
590 # The makefile may define $(extra-libs) with `libfoo libbar'
591 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
592 ifdef extra-libs
593 # extra-lib.mk is included once for each extra lib to define rules
594 # to build it, and to add its objects to the various variables.
595 # During its evaluation, $(lib) is set to the name of the library.
596 extra-libs-left := $(extra-libs)
597 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
598 endif
599 \f
600 +depfiles := $(sources:.c=.d) \
601 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
602 $(addsuffix .d,$(tests) $(test-srcs))
603 ifeq ($(build-programs),yes)
604 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
605 endif
606 +depfiles := $(addprefix $(objpfx),\
607 $(filter-out $(addsuffix .d,$(omit-deps)),\
608 $(+depfiles)))
609
610 ifdef +depfiles
611 ifneq ($(no_deps),t)
612 -include $(+depfiles)
613 endif
614 endif
615 \f\f
616 # Maximize efficiency by minimizing the number of rules.
617 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
618 # Don't define any builtin rules.
619 MAKEFLAGS := $(MAKEFLAGS)r
620
621 # Generic rule for making directories.
622 %/:
623 # mkdir isn't smart enough to strip a trailing /.
624 mkdir $(@:%/=%)
625 \f
626 # Make sure that object files are not removed
627 # when they are intermediates between sources and library members.
628 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
629
630 # Make sure that the parent library archive is never removed.
631 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
632 \f
633 # Use the verbose option of ar and tar when not running silently.
634 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
635 verbose := v
636 else # -s
637 verbose :=
638 endif # not -s
639
640 ARFLAGS := r$(verbose)
641 CREATE_ARFLAGS := cru$(verbose)
642 \f
643 # This makes all the object files in the parent library archive.
644
645 .PHONY: lib lib-noranlib
646 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
647 lib-noranlib: libobjs
648
649 # For object-suffix $o, the list of objects with that suffix.
650 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
651 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
652 $(elide-routines$o)),\
653 $(objects))) \
654 $(addprefix $(objpfx),$(o-objects$o))
655
656 others: $(addprefix $(objpfx),$(install-lib))
657
658 ifndef objects
659
660 # Create the stamp$o files to keep the parent makefile happy.
661 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
662 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
663 $(make-target-directory)
664 rm -f $@; > $@
665 else
666
667 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
668 # timestamp file; these rules (one explicit rule is generated for each
669 # object suffix) write a list of objects to update in the stamp file.
670 # The parent will then actually add them all to the archive in the
671 # archive rule, below.
672 define o-iterator-doit
673 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
674 endef
675 define do-stamp
676 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
677 mv -f $@T $@
678 endef
679 object-suffixes-left := $(object-suffixes-for-libc)
680 include $(o-iterator)
681
682 endif
683
684 # Now define explicit rules to build the library archives; these depend
685 # on the stamp files built above.
686 define o-iterator-doit
687 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
688 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
689 endef
690 define do-makelib
691 cd $(common-objdir) && \
692 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
693 $(RANLIB) $@
694 endef
695 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
696 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
697 ifndef subdir
698 $(subdirs-stamps): subdir_lib;
699 endif
700 object-suffixes-left = $(object-suffixes-for-libc)
701 include $(o-iterator)
702
703
704 # This makes all the object files.
705 .PHONY: objects objs libobjs extra-objs
706 objects objs: libobjs extra-objs
707 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
708 extra-objs: $(addprefix $(objpfx),$(extra-objs))
709
710 # Canned sequence for building an extra library archive.
711 define build-extra-lib
712 $(patsubst %/,cd % &&,$(objpfx)) \
713 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
714 $(patsubst $(objpfx)%,%,$^)
715 $(RANLIB) $@
716 endef
717 \f
718 # Installation.
719
720 .PHONY: force-install
721 force-install:
722
723 # $(install-lib) are installed from the object directory into $(libdir);
724 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
725 # unless they also appear in $(non-lib.a). $(install-data) are installed
726 # as they are into $(datadir). $(headers) are installed as they are in
727 # $(includedir). $(install-bin), $(install-bin-script) and $(install-sbin)
728 # are installed from the object directory into $(bindir), $(bindir) and
729 # $(sbindir), respectively. $(install-others) are absolute path names of
730 # files to install; rules to install them are defined elsewhere.
731
732 # The simple library name to install libc.a under.
733 # This could be defined by a sysdep Makefile.
734 ifndef libc-name
735 libc-name := c
736 endif
737
738 define do-install
739 $(make-target-directory)
740 $(INSTALL_DATA) $< $@
741 endef
742
743 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
744 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
745 define make-target-directory
746 $(addprefix $(..)./scripts/mkinstalldirs ,\
747 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
748 endef
749
750 # Any directory (parent or subdir) should install libc.a; this way
751 # "make install" in a subdir is guaranteed to install everything it changes.
752 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
753 $(inst_libdir)/$(patsubst %,$(libtype$o),\
754 $(libprefix)$(libc-name)))
755 install: $(installed-libcs)
756 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
757 $(make-target-directory)
758 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
759 # Running ranlib after installing makes the __.SYMDEF time stamp up to
760 # date, which avoids messages from some linkers.
761 $(RANLIB) $@
762
763 define do-install-program
764 $(make-target-directory)
765 $(INSTALL_PROGRAM) $< $@.new
766 mv -f $@.new $@
767 endef
768
769 define do-install-script
770 $(make-target-directory)
771 $(INSTALL_SCRIPT) $< $@.new
772 mv -f $@.new $@
773 endef
774
775 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
776 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
777
778 ifeq (yes,$(build-shared))
779 # Find which .so's have versions.
780 versioned := $(strip $(foreach so,$(install-lib.so),\
781 $(patsubst %,$(so),$($(so)-version))))
782
783 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
784 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
785
786 install-lib-nosubdir: $(install-lib.so-versioned:%=$(inst_libdir)/%) \
787 $(install-lib.so-unversioned:%=$(inst_slibdir)/%)
788
789 # Install all the unversioned shared libraries.
790 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
791 $(objpfx)%.so $(+force)
792 $(do-install-program)
793
794 ifneq ($(findstring -s,$(LN_S)),)
795 define make-link
796 rm -f $@.new
797 $(SHELL) $(..)scripts/rellns-sh $< $@.new
798 mv -f $@.new $@
799 endef
800 else
801 # If we have no symbolic links don't bother with rellns-sh.
802 define make-link
803 rm -f $@.new
804 $(LN_S) $< $@.new
805 mv -f $@.new $@
806 endef
807 endif
808
809 ifeq (yes,$(build-shared))
810 ifeq (no,$(cross-compiling))
811 symbolic-link-prog := $(common-objpfx)elf/sln
812 symbolic-link-list := $(common-objpfx)elf/symlink.list
813 define make-shlib-link
814 echo $(<F) $@ >> $(symbolic-link-list)
815 endef
816 else # cross-compiling
817 # We need a definition that can be used by elf/Makefile's install rules.
818 symbolic-link-prog = $(LN_S)
819 endif
820 endif
821 ifndef make-shlib-link
822 define make-shlib-link
823 rm -f $@
824 $(LN_S) $(<F) $@
825 endef
826 endif
827
828 ifdef libc.so-version
829 # For a library specified to be version N, install three files:
830 # libc.so -> libc.so.N (e.g. libc.so.6)
831 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
832
833 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
834 $(+force)
835 $(make-shlib-link)
836 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
837 $(do-install-program)
838 install: $(inst_slibdir)/libc.so$(libc.so-version)
839
840 ifndef subdir
841 # What we install as libc.so for programs to link against is in fact a
842 # link script. It contains references for the various libraries we need.
843 # The libc.so object is not complete since some functions are only defined
844 # in libc_nonshared.a.
845 # We need to use absolute paths since otherwise local copies (if they exist)
846 # of the files are taken by the linker.
847 install: $(inst_libdir)/libc.so
848 $(inst_libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \
849 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
850 $(libprefix)$(libc-name)) \
851 $(+force)
852 (echo '/* GNU ld script';\
853 echo ' Use the shared library, but some functions are only in';\
854 echo ' the static library, so try that secondarily. */';\
855 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
856 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
857 ')' \
858 ) > $@.new
859 mv -f $@.new $@
860
861 endif
862
863 else
864 install: $(inst_slibdir)/libc.so
865 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
866 $(do-install-program)
867 endif
868
869 ifneq (,$(versioned))
870 # Produce three sets of rules as above for all the smaller versioned libraries.
871
872 define o-iterator-doit
873 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
874 endef
875 object-suffixes-left := $(versioned)
876 include $(o-iterator)
877
878 # Make symlinks in the build directory, because the versioned names might
879 # be referenced by a DT_NEEDED in another library.
880 define o-iterator-doit
881 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
882 endef
883 object-suffixes-left := $(versioned)
884 include $(o-iterator)
885
886 generated += $(foreach o,$(versioned),$o$($o-version))
887
888 ifeq (,$($(subdir)-version))
889 define o-iterator-doit
890 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
891 $(+force);
892 $$(make-shlib-link)
893 endef
894 object-suffixes-left := $(versioned)
895 include $(o-iterator)
896
897 define o-iterator-doit
898 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
899 $$(do-install-program)
900 endef
901 object-suffixes-left := $(versioned)
902 include $(o-iterator)
903 else
904 define o-iterator-doit
905 $(inst_slibdir)/$o$($o-version): \
906 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
907 $$(make-shlib-link)
908 endef
909 object-suffixes-left := $(versioned)
910 include $(o-iterator)
911
912 define o-iterator-doit
913 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
914 $$(do-install-program)
915 endef
916 object-suffixes-left := $(versioned)
917 include $(o-iterator)
918 endif
919 endif
920
921 define do-install-so
922 $(do-install-program)
923 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
924 $(filter-out %.so,$@))
925 endef
926
927 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
928 $(foreach v,$(so-versions),\
929 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
930 $(+force)
931 $(do-install-so)
932 $(foreach v,$(so-versions),\
933 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
934 $(do-install-so)
935 endif
936
937 ifdef install-bin
938 $(addprefix $(inst_bindir)/,$(install-bin)): \
939 $(inst_bindir)/%: $(objpfx)% $(+force)
940 $(do-install-program)
941 endif
942 ifdef install-bin-script
943 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
944 $(inst_bindir)/%: $(objpfx)% $(+force)
945 $(do-install-script)
946 endif
947 ifdef install-rootsbin
948 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
949 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
950 $(do-install-program)
951 endif
952 ifdef install-sbin
953 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
954 $(inst_sbindir)/%: $(objpfx)% $(+force)
955 $(do-install-program)
956 endif
957 ifdef install-lib
958 install-lib.a := $(filter lib%.a,$(install-lib))
959 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
960 ifdef install-lib-non.a
961 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
962 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
963 $(do-install)
964 endif
965 ifdef install-lib.a
966 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
967 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
968 $(do-install)
969 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
970 endif
971 endif
972 ifdef install-data
973 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
974 $(do-install)
975 endif
976 headers := $(strip $(headers))
977 ifdef headers
978 $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
979 $(do-install)
980 endif # headers
981
982 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
983 install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
984 install-data-nosubdir install-headers-nosubdir
985 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
986 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
987 install-rootsbin-nosubdir: \
988 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
989 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
990 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
991 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
992 $(addprefix $(libprefix),$(install-lib-non.a)))
993 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
994 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
995 install-others-nosubdir: $(install-others)
996
997 # We need all the `-nosubdir' targets so that `install' in the parent
998 # doesn't depend on several things which each iterate over the subdirs.
999 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1000 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
1001 install-%:: install-%-nosubdir ;
1002
1003 .PHONY: install install-no-libc.a-nosubdir
1004 ifeq ($(build-programs),yes)
1005 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1006 install-bin-nosubdir install-bin-script-nosubdir \
1007 install-lib-nosubdir install-others-nosubdir \
1008 install-rootsbin-nosubdir install-sbin-nosubdir
1009 else
1010 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
1011 install-lib-nosubdir install-others-nosubdir
1012 endif
1013 install: install-no-libc.a-nosubdir
1014 \f
1015 # Command to compile $< in $(objdir) using the native libraries.
1016 define native-compile
1017 $(make-target-directory)
1018 $(patsubst %/,cd % &&,$(objpfx)) \
1019 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1020 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
1021 endef
1022
1023 # Command to compile $< in $(common-objdir) using the native libraries.
1024 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
1025 define common-objdir-compile
1026 $(patsubst %/,cd % &&,$(objpfx)) \
1027 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1028 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
1029 endef
1030
1031 # We always want to use configuration definitions.
1032 # Note that this is only used for commands running in $(objpfx).
1033 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
1034
1035 # Support the GNU standard name for this target.
1036 .PHONY: check
1037 check: tests
1038
1039 ifneq (,$(tests))
1040 cpp-srcs-left = $(tests)
1041 lib := tests
1042 include $(patsubst %,$(..)cppflags-iterator.mk,$(tests))
1043 endif
1044 \f
1045 .PHONY: TAGS
1046 TAGS: $(objpfx)distinfo $(..)MakeTAGS
1047 $(MAKE) $(addprefix -f ,$^) $@
1048
1049 $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE
1050 $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
1051 FORCE:
1052
1053
1054 .PHONY: echo-headers
1055 echo-headers:
1056 @echo $(headers)
1057
1058 \f
1059 # Common cleaning targets.
1060
1061 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1062 clean: common-clean
1063 mostlyclean: common-mostlyclean
1064
1065 do-tests-clean:
1066 -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(test-srcs)) \
1067 $(addsuffix -bp.out,$(tests) $(test-srcs)))
1068
1069 # Remove the object files.
1070 common-mostlyclean:
1071 -rm -f $(addprefix $(objpfx),$(tests) $(test-srcs) $(others) \
1072 $(sysdep-others) stubs \
1073 $(addsuffix .o,$(tests) $(test-srcs) \
1074 $(others) \
1075 $(sysdep-others)) \
1076 $(addsuffix -bp,$(tests) $(test-srcs)) \
1077 $(addsuffix .out,$(tests) $(test-srcs)) \
1078 $(addsuffix -bp.out,$(tests) $(test-srcs)))
1079 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
1080 $(install-lib.so) \
1081 $(install-lib.so:%.so=%_pic.a))
1082 -rm -f core
1083 $(rmobjs)
1084 define rmobjs
1085 $(foreach o,$(object-suffixes-for-libc),
1086 -rm -f $(objpfx)stamp$o $(o-objects))
1087 endef
1088
1089 # Also remove the dependencies and generated source files.
1090 common-clean: common-mostlyclean
1091 -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
1092 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1093 -rm -f $(addprefix $(common-objpfx),$(common-generated))
1094 -rm -f $(objpfx)distinfo
1095 \f
1096 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1097 # for each function which is a stub. We grovel over all the .d files
1098 # looking for references to <stub-tag.h>. Then we grovel over each
1099 # referenced source file to see what stub function it defines.
1100
1101 ifdef objpfx
1102 .PHONY: stubs # The parent Makefile calls this target.
1103 stubs: $(objpfx)stubs
1104 endif
1105 s = $(sysdep_dir)/generic
1106 $(objpfx)stubs: $(+depfiles)
1107 # Use /dev/null since `...` might expand to empty.
1108 (s=`cd $s && $(PWD_P)`; \
1109 $(patsubst %/,cd % &&,$(objpfx)) \
1110 sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
1111 `sed -n -e '\@ $s/[^ ]*\.c@{; s@^.* $s/\([^ ]*\.c\).*$$@'"$$s"'/\1@; h; }' \
1112 -e '/stub-tag\.h/{; g; p; }' \
1113 $(patsubst $(objpfx)%,%,$^) /dev/null` \
1114 /dev/null) > $@T
1115 mv -f $@T $@
1116 \f
1117 # Make the distribution tar file.
1118
1119 .PHONY: dist
1120 dist: $(objpfx)distinfo $(..)Make-dist
1121 $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
1122
1123 # Avoid depending on source files found in sysdeps dirs,
1124 # because the references affect implicit rule selection.
1125 dist: $(filter-out %.c %.S %.s,$(distribute))
1126
1127 # We used to simply export all these variables, but that frequently made the
1128 # environment get too large. Instead, we write all the information into
1129 # a generated makefile fragment `distinfo', and then include it with -f in
1130 # the sub-make that makes the distribution (above).
1131 $(objpfx)distinfo: Makefile $(..)Makerules \
1132 $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile))
1133 $(make-target-directory)
1134 $(distinfo-vars)
1135 mv -f $@.new $@
1136 .PHONY: subdir_distinfo
1137 subdir_distinfo: $(objpfx)distinfo
1138
1139 define distinfo-vars
1140 rm -f $@.new
1141 echo > $@.new 'subdir := $(subdir)'
1142 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
1143 headers sysdep_headers distribute dont_distribute generated \
1144 others tests test-srcs extra-libs $(extra-libs:%=%-routines) \
1145 versioned \
1146 $(addprefix install-,lib lib.so data bin bin-script sbin others),
1147 echo >> $@.new '$(subdir)-$(var) := $($(var))'
1148 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
1149 endef
1150 \f
1151 ifneq (,$(strip $(gpl2lgpl)))
1152 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1153 # Snarf from the master source and frob the copying notice.
1154 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1155 sed -f $^ > $@-tmp
1156 # So I don't edit them by mistake.
1157 chmod a-w $@-tmp
1158 mv -f $@-tmp $@
1159 ifeq ($(with-cvs),yes)
1160 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@
1161 endif
1162 endif
1163 endif