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