1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 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 Library General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # 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 # Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB. If not,
16 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 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
25 This makefile requires GNU Make.
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.
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))" ""
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.
55 ifndef +included-Makeconfig
56 include $(..)Makeconfig
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)
68 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
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).
97 -include $(+sysdir_pfx)sysd-Makefile
98 ifndef avoid-generated
99 ifneq ($(sysd-Makefile-sysdirs),$(config-sysdirs))
100 sysd-Makefile-force = FORCE
103 $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)config.make $(..)Makerules \
104 $(sysd-Makefile-force)
106 (echo 'sysd-Makefile-sysdirs := $(config-sysdirs)'; \
107 for dir in $(config-sysdirs); do \
108 file=$$dir/Makefile; \
113 if [ -f $$rel$$file ]; then \
115 /*) echo include "$$file" ;; \
116 *) echo include "\$$(..)$$file" ;; \
120 echo 'sysd-Makefile-done=t') > $@T
124 ifndef sysd-Makefile-done
125 # Don't do deps until this exists, because it might change the sources list.
130 # Reorder before-compile so that mach things come first, and hurd things
131 # second, before all else. The mach and hurd subdirectories have many
132 # generated header files which the much of rest of the library depends on,
133 # so it is best to build them first (and mach before hurd, at that).
134 before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
136 $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
139 # Remove existing files from `before-compile'. Things are added there when
140 # they must exist for dependency generation to work right, but once they
141 # exist there is no further need for every single file to depend on them,
142 # and those gratuitous dependencies result in many gratuitous
144 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
146 # Don't let any before-compile file be an intermediate and get removed.
151 # Generate an ordered list of implicit rules which find the source files in
152 # each sysdep directory. The old method was to use vpath to search all the
153 # sysdep directories. However, that had the problem that a .S file in a
154 # later directory would be chosen over a .c file in an earlier directory,
155 # which does not preserve the desired sysdeps ordering behavior.
157 # When making the list of .d files to include, we can't know which ones
158 # have source in .s files, and thus do not in fact need a .d file.
159 # So we must define rules to make .d files for .s files.
160 define make-dummy-dep
161 $(addprefix ln $(common-objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
163 $(common-objpfx)dummy.d:
164 echo '# .s files cannot contain includes, so they need no deps.' > $@
166 # It matters that this set of rules, for compiling from sources in
167 # the current directory (the $srcdir/$subdir) come before the
168 # generated sysdep rules in included from sysd-rules below. When
169 # compiling in the source tree, generated sources go into the current
170 # directory, and those should be chosen before any sources in sysdeps.
171 define o-iterator-doit
172 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
174 object-suffixes-left := $(object-suffixes-for-libc)
175 include $(o-iterator)
176 $(objpfx)%.d: %.S $(before-compile); $(+make-deps)
178 define o-iterator-doit
179 $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
181 object-suffixes-left := $(object-suffixes-for-libc)
182 include $(o-iterator)
183 $(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep)
185 define o-iterator-doit
186 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
188 object-suffixes-left := $(object-suffixes-for-libc)
189 include $(o-iterator)
190 $(objpfx)%.d: %.c $(before-compile); $(+make-deps)
192 # Omit the objpfx rules when building in the source tree, because
193 # objpfx is empty and so these rules just override the ones above.
195 # Define first rules to find the source files in $(objpfx).
196 # Generated source files will end up there.
197 define o-iterator-doit
198 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
200 object-suffixes-left := $(object-suffixes-for-libc)
201 include $(o-iterator)
202 $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps)
204 define o-iterator-doit
205 $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
207 object-suffixes-left := $(object-suffixes-for-libc)
208 include $(o-iterator)
209 $(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep)
211 define o-iterator-doit
212 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
214 object-suffixes-left := $(object-suffixes-for-libc)
215 include $(o-iterator)
216 $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps)
219 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
220 # patterns matching sysdep directories whose assembly source files should
222 ifdef inhibit-sysdep-asm
223 define open-check-inhibit-asm
224 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
226 close-check-inhibit-asm = ;; esac ;
229 # Don't include sysd-rules until sysd-Makefile is already there and has been
230 # included. It might define inhibit-sysdep-asm, which would affect the
231 # contents of sysd-rules.
232 ifdef sysd-Makefile-done
233 -include $(+sysdir_pfx)sysd-rules
234 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
235 # The value of $(+sysdep_dirs) the sysd-rules was computed for
236 # differs from the one we are using now. So force a rebuild of sysd-rules.
237 sysd-rules-force = FORCE
241 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
242 $(wildcard $(foreach dir,$(sysdirs),\
246 (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \
247 for sysdir in $(config-sysdirs); do \
249 /*) dir=$$sysdir ;; \
250 *) dir="\$$(..)$$sysdir" ;; \
252 for o in $(all-object-suffixes); do \
253 $(open-check-inhibit-asm) \
254 echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
255 \$$(compile-command.S)"; \
256 echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
257 \$$(compile-command.s)"; \
258 $(close-check-inhibit-asm) \
259 echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
260 \$$(compile-command.c)"; \
262 $(open-check-inhibit-asm) \
263 echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
264 \$$(make-dummy-dep)"; \
265 echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
267 $(close-check-inhibit-asm) \
268 echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \
271 echo 'sysd-rules-done = t') > $@T
274 ifndef sysd-rules-done
275 # Don't do deps until this exists, because it provides rules to make the deps.
279 # Generate version maps.
280 ifeq ($(versioning),yes)
281 -include $(common-objpfx)sysd-versions
282 $(common-objpfx)sysd-versions: $(..)Versions.def $(..)versions.awk \
283 $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
284 $(wildcard $(+sysdep_dirs:%=%/Versions))
285 $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
286 -f $(filter-out $<,$^) > $@T
288 $(all-version-maps): $(common-objpfx)sysd-versions
291 ifndef compile-command.S
292 compile-command.S = $(compile.S) $(OUTPUT_OPTION)
294 ifndef compile-command.s
295 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION)
297 ifndef compile-command.c
298 compile-command.c = $(compile.c) $(OUTPUT_OPTION)
301 # GCC can grok options after the file name, and it looks nicer that way.
302 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
304 $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
306 $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) $(ASFLAGS-$(suffix $@))
307 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
309 # We need this for the output to go in the right place. It will default to
310 # empty if make was configured to work with a cc that can't grok -c and -o
311 # together. You can't compile the C library with such a compiler.
312 OUTPUT_OPTION = -o $@
314 S-CPPFLAGS = $(asm-CPPFLAGS)
316 $(make-target-directory)
318 $(+mkdep) $< $(CFLAGS) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
320 -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
321 $(sed-remove-objpfx) > $(@:.d=.T)
325 # Continuation lines here are dangerous because they introduce spaces!
326 define sed-remove-objpfx
327 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
328 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
332 # Shared library building.
334 ifeq (yes,$(build-shared))
336 # Reference map file only when versioning is selected and a map file name
338 ifeq ($(versioning),yes)
339 map-file = $(firstword $(wildcard $($(@F:.so=-map)) \
340 $(common-objpfx)$(@F:.so=.map)))
341 load-map-file = $(map-file:%=-Wl,--version-script=%)
344 # Pattern rule to build a shared object from an archive of PIC objects.
345 # This must come after the installation rules so Make doesn't try to
346 # build shared libraries in place from the installed *_pic.a files.
347 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
348 # on other shared objects.
349 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
353 $(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \
354 -B$(csu-objpfx) $(load-map-file) \
355 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
356 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
357 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
358 -Wl,--whole-archive \
359 $(filter-out $(map-file) $(common-objpfx)$(@F:.so=.map) \
360 $(+preinit) $(+postinit),$^) \
361 $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
364 ifndef libc.so-version
365 # Undefine this because it can't work when we libc.so is unversioned.
366 static-only-routines =
369 elide-routines.oS += $(filter-out $(static-only-routines),\
370 $(routines) $(aux) $(sysdep_routines))
371 elide-routines.os += $(static-only-routines)
373 # If we have versioned code we don't need the old versions in any of the
375 elide-routines.o += $(shared-only-routines)
376 elide-routines.op += $(shared-only-routines)
377 elide-routines.og += $(shared-only-routines)
378 elide-routines.ob += $(shared-only-routines)
380 # Don't try to use -lc when making libc.so itself.
381 # Also omits crti.o and crtn.o, which we do not want
382 # since we define our own `.init' section specially.
383 LDFLAGS-c.so = -nostdlib -nostartfiles
384 # But we still want to link libc.so against $(gnulib).
385 LDLIBS-c.so = $(gnulib)
386 # Give libc.so an entry point and make it directly runnable itself.
387 LDFLAGS-c.so += -e __libc_main
388 # Pre-link the objects of libc_pic.a so that we can locally resolve
389 # COMMON symbols before we link against ld.so. This is because ld.so
390 # contains some of libc_pic.a already, which will prevent the COMMONs
391 # from being allocated in libc.so, which introduces evil dependencies
392 # between libc.so and ld.so, which can make it impossible to upgrade.
393 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
394 $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
395 -Wl,-d -Wl,--whole-archive $^
396 # Use our own special initializer and finalizer files for libc.so.
397 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
398 $(common-objpfx)libc_pic.os \
399 $(elfobjdir)/sofini.os \
400 $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
401 $(common-objpfx)libc.map
403 common-generated += libc.so libc_pic.os
404 ifdef libc.so-version
405 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
407 common-generated += libc.so$(libc.so-version)
411 # Figure out the source filenames in this directory.
413 override sources := $(addsuffix .c,$(filter-out $(elided-routines),\
416 sysdep_routines := $(sysdep_routines)
418 headers := $(headers) $(sysdep_headers)
420 # This is the list of all object files, gotten by
421 # replacing every ".c" in `sources' with a ".o".
422 override objects := $(addprefix $(objpfx),$(sources:.c=.o))
425 # The makefile may define $(extra-libs) with `libfoo libbar'
426 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
428 # extra-lib.mk is included once for each extra lib to define rules
429 # to build it, and to add its objects to the various variables.
430 # During its evaluation, $(lib) is set to the name of the library.
431 extra-libs-left := $(extra-libs)
432 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
435 +depfiles := $(sources:.c=.d) \
436 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
437 $(addsuffix .d,$(tests) $(test-srcs) $(tests-static))
438 ifeq ($(build-programs),yes)
439 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
441 +depfiles := $(addprefix $(objpfx),\
442 $(filter-out $(addsuffix .d,$(omit-deps)),\
447 -include $(+depfiles)
451 # Maximize efficiency by minimizing the number of rules.
452 .SUFFIXES: # Clear the suffix list. We don't use suffix rules.
453 # Don't define any builtin rules.
454 MAKEFLAGS := $(MAKEFLAGS)r
456 # Generic rule for making directories.
458 # mkdir isn't smart enough to strip a trailing /.
461 # Make sure that object files are not removed
462 # when they are intermediates between sources and library members.
463 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
465 # Make sure that the parent library archive is never removed.
466 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
468 # Use the verbose option of ar and tar when not running silently.
469 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
475 ARFLAGS := r$(verbose)
476 CREATE_ARFLAGS := cru$(verbose)
478 # This makes all the object files in the parent library archive.
480 .PHONY: lib lib-noranlib
481 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
482 lib-noranlib: libobjs
484 # For object-suffix $o, the list of objects with that suffix.
485 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
486 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
487 $(elide-routines$o)),\
489 others: $(addprefix $(objpfx),$(install-lib))
493 # Create the stamp$o files to keep the parent makefile happy.
494 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
495 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
496 $(make-target-directory)
500 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
501 # timestamp file; these rules (one explicit rule is generated for each
502 # object suffix) write a list of objects to update in the stamp file.
503 # The parent will then actually add them all to the archive in the
504 # archive rule, below.
505 define o-iterator-doit
506 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
509 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
512 object-suffixes-left := $(object-suffixes-for-libc)
513 include $(o-iterator)
517 # Now define explicit rules to build the library archives; these depend
518 # on the stamp files built above.
519 define o-iterator-doit
520 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
521 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
524 cd $(common-objdir) && \
525 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
528 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
529 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
531 $(subdirs-stamps): subdir_lib;
533 object-suffixes-left = $(object-suffixes-for-libc)
534 include $(o-iterator)
537 # This makes all the object files.
538 .PHONY: objects objs libobjs extra-objs
539 objects objs: libobjs extra-objs
540 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
541 extra-objs: $(addprefix $(objpfx),$(extra-objs))
543 # Canned sequence for building an extra library archive.
544 define build-extra-lib
545 $(patsubst %/,cd % &&,$(objpfx)) \
546 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
547 $(patsubst $(objpfx)%,%,$^)
553 .PHONY: force-install
556 # $(install-lib) are installed from the object directory into $(libdir);
557 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
558 # unless they also appear in $(non-lib.a). $(install-data) are installed
559 # as they are into $(datadir). $(headers) are installed as they are in
560 # $(includedir). $(install-bin) and $(install-sbin) are installed from the
561 # object directory into $(bindir) and $(sbindir), respectively.
562 # $(install-others) are absolute path names of files to install; rules to
563 # install them are defined elsewhere.
565 # The simple library name to install libc.a under.
566 # This could be defined by a sysdep Makefile.
572 $(make-target-directory)
573 $(INSTALL_DATA) $< $@
576 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
577 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
578 define make-target-directory
579 $(addprefix $(..)./scripts/mkinstalldirs ,\
580 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
583 # Any directory (parent or subdir) should install libc.a; this way
584 # "make install" in a subdir is guaranteed to install everything it changes.
585 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
586 $(inst_libdir)/$(patsubst %,$(libtype$o),\
587 $(libprefix)$(libc-name)))
588 install: $(installed-libcs)
589 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
590 $(make-target-directory)
591 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
592 # Running ranlib after installing makes the __.SYMDEF time stamp up to
593 # date, which avoids messages from some linkers.
596 define do-install-program
597 $(make-target-directory)
598 $(INSTALL_PROGRAM) $< $@.new
602 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
603 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
604 ifeq (yes,$(build-shared))
606 install-lib-nosubdir: $(install-lib.so:%=$(inst_libdir)/%)
608 # Find which .so's have versions.
609 versioned := $(strip $(foreach so,$(install-lib.so),\
610 $(patsubst %,$(so),$($(so)-version))))
612 # Install all the unversioned shared libraries.
613 $(addprefix $(inst_slibdir)/, $(filter-out $(versioned),$(install-lib.so))): \
614 $(inst_slibdir)/%.so: $(objpfx)%.so $(+force); $(do-install-program)
616 ifneq ($(findstring -s,$(LN_S)),)
619 $(SHELL) $(..)scripts/rellns-sh $< $@.new
623 # If we have no symbolic links don't bother with rellns-sh.
631 # XXX The following will have to be changed when `ldconfig' is available.
632 ifneq (yes,$(cross-compiling))
633 ifeq (yes,$(has-ldconfig))
634 define make-shlib-link
639 ifndef make-shlib-link
640 define make-shlib-link
645 ifdef libc.so-version
646 # For a library specified to be version N, install three files:
647 # libc.so -> libc.so.N (e.g. libc.so.6)
648 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
650 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
653 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
654 $(do-install-program)
655 install: $(inst_slibdir)/libc.so$(libc.so-version)
658 # What we install as libc.so for programs to link against is in fact a
659 # link script. It contains references for the various libraries we need.
660 # The libc.so object is not complete since some functions are only defined
661 # in libc_nonshared.a.
662 install: $(inst_libdir)/libc.so
663 $(inst_libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \
664 $(inst_libdir)/$(patsubst %,$(libtype.oS),\
665 $(libprefix)$(libc-name)) \
667 (echo '/* GNU ld script';\
668 echo ' Use the shared library, but some functions are only in';\
669 echo ' the static library, so try that secondarily. */';\
670 echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
671 '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
679 install: $(inst_slibdir)/libc.so
680 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
681 $(do-install-program)
684 ifneq (,$(versioned))
685 # Produce three sets of rules as above for all the smaller versioned libraries.
687 define o-iterator-doit
688 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
690 object-suffixes-left := $(versioned)
691 include $(o-iterator)
693 # Make symlinks in the build directory, because the versioned names might
694 # be referenced by a DT_NEEDED in another library.
695 define o-iterator-doit
696 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
698 object-suffixes-left := $(versioned)
699 include $(o-iterator)
701 generated += $(foreach o,$(versioned),$o$($o-version))
703 ifeq (,$($(subdir)-version))
704 define o-iterator-doit
705 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
709 object-suffixes-left := $(versioned)
710 include $(o-iterator)
712 define o-iterator-doit
713 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
714 $$(do-install-program)
716 object-suffixes-left := $(versioned)
717 include $(o-iterator)
719 define o-iterator-doit
720 $(inst_slibdir)/$o$($o-version): \
721 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
724 object-suffixes-left := $(versioned)
725 include $(o-iterator)
727 define o-iterator-doit
728 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
729 $$(do-install-program)
731 object-suffixes-left := $(versioned)
732 include $(o-iterator)
737 $(do-install-program)
738 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
739 $(filter-out %.so,$@))
742 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
743 $(foreach v,$(so-versions),\
744 $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
747 $(foreach v,$(so-versions),\
748 $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
753 $(addprefix $(inst_bindir)/,$(install-bin)): \
754 $(inst_bindir)/%: $(objpfx)% $(+force)
755 $(do-install-program)
757 ifdef install-rootsbin
758 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
759 $(inst_rootsbindir)/%: $(objpfx)% $(+force)
760 $(do-install-program)
763 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
764 $(inst_sbindir)/%: $(objpfx)% $(+force)
765 $(do-install-program)
768 install-lib.a := $(filter lib%.a,$(install-lib))
769 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
770 ifdef install-lib-non.a
771 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
772 $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
776 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
777 $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
779 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
783 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
786 headers := $(strip $(headers))
788 $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
792 .PHONY: install-bin-nosubdir install-rootsbin-nosubdir install-sbin-nosubdir \
793 install-lib-nosubdir install-data-nosubdir install-headers-nosubdir
794 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
795 install-rootsbin-nosubdir: \
796 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
797 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
798 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
799 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
800 $(addprefix $(libprefix),$(install-lib-non.a)))
801 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
802 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
803 install-others-nosubdir: $(install-others)
805 # We need all the `-nosubdir' targets so that `install' in the parent
806 # doesn't depend on several things which each iterate over the subdirs.
807 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
808 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
809 install-%:: install-%-nosubdir ;
811 .PHONY: install install-no-libc.a-nosubdir
812 ifeq ($(build-programs),yes)
813 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
814 install-bin-nosubdir install-lib-nosubdir \
815 install-others-nosubdir install-rootsbin-nosubdir \
816 install-sbin-nosubdir
818 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
819 install-lib-nosubdir install-others-nosubdir
821 install: install-no-libc.a-nosubdir
823 # Command to compile $< in $(objdir) using the native libraries.
824 define native-compile
825 $(make-target-directory)
826 $(patsubst %/,cd % &&,$(objpfx)) \
827 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
828 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
831 # Command to compile $< in $(common-objdir) using the native libraries.
832 # We must cd to $(objdir) anyway so that $(..)config.h is valid.
833 define common-objdir-compile
834 $(patsubst %/,cd % &&,$(objpfx)) \
835 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
836 $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(..)$(@F)
839 # We always want to use configuration definitions.
840 # Note that this is only used for commands running in $(objpfx).
841 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h
843 # Support the GNU standard name for this target.
848 TAGS: $(objpfx)distinfo $(..)MakeTAGS
849 $(MAKE) $(addprefix -f ,$^) $@
851 $(..)po/%.pot: $(objpfx)distinfo $(..)MakeTAGS FORCE
852 $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
861 # Common cleaning targets.
863 .PHONY: common-mostlyclean common-clean mostlyclean clean
865 mostlyclean: common-mostlyclean
867 # Remove the object files.
869 -rm -f $(addprefix $(objpfx),$(tests) $(test-srcs) $(others) \
870 $(sysdep-others) $(tests-static) stubs \
871 $(addsuffix .o,$(tests) $(test-srcs) \
875 $(addsuffix .out,$(tests) $(test-srcs)) \
876 $(addsuffix .sout,$(tests-static)))
877 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
879 $(install-lib.so:%.so=%_pic.a))
883 $(foreach o,$(object-suffixes-for-libc),
884 -rm -f $(objpfx)stamp$o $(o-objects))
887 # Also remove the dependencies and generated source files.
888 common-clean: common-mostlyclean
889 -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
890 -rm -fr $(addprefix $(objpfx),$(generated-dirs))
891 -rm -f $(addprefix $(common-objpfx),$(common-generated))
892 -rm -f $(objpfx)distinfo
894 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
895 # for each function which is a stub. We grovel over all the .d files
896 # looking for references to <stub-tag.h>. Then we grovel over each
897 # referenced source file to see what stub function it defines.
900 .PHONY: stubs # The parent Makefile calls this target.
901 stubs: $(objpfx)stubs
903 s = $(sysdep_dir)/generic
904 $(objpfx)stubs: $(+depfiles)
905 # Use /dev/null since `...` might expand to empty.
906 (s=`cd $s && /bin/pwd`; \
907 $(patsubst %/,cd % &&,$(objpfx)) \
908 sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
909 `sed -n -e '\@ $s/[^ ]*\.c@{; s@^.* $s/\([^ ]*\.c\).*$$@'"$$s"'/\1@; h; }' \
910 -e '/stub-tag\.h/{; g; p; }' \
911 $(patsubst $(objpfx)%,%,$^) /dev/null` \
915 # Make the distribution tar file.
918 dist: $(objpfx)distinfo $(..)Make-dist
919 $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
921 # Avoid depending on source files found in sysdeps dirs,
922 # because the references affect implicit rule selection.
923 dist: $(filter-out %.c %.S %.s,$(distribute))
925 # We used to simply export all these variables, but that frequently made the
926 # environment get too large. Instead, we write all the information into
927 # a generated makefile fragment `distinfo', and then include it with -f in
928 # the sub-make that makes the distribution (above).
929 $(objpfx)distinfo: Makefile $(..)Makerules \
930 $(wildcard $(foreach dir,$(sysdirs),$(dir)/Makefile))
931 $(make-target-directory)
934 .PHONY: subdir_distinfo
935 subdir_distinfo: $(objpfx)distinfo
939 echo > $@.new 'subdir := $(subdir)'
940 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
941 headers sysdep_headers distribute dont_distribute generated \
942 others tests test-srcs extra-libs $(extra-libs:%=%-routines) \
943 tests-static $(extra-libs:%=%-map) versioned \
944 $(addprefix install-,lib lib.so data bin sbin others),
945 echo >> $@.new '$(subdir)-$(var) := $($(var))'
946 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
949 ifneq (,$(strip $(gpl2lgpl)))
950 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
951 # Snarf from the master source and frob the copying notice.
952 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
954 # So I don't edit them by mistake.
957 ifeq ($(with-cvs),yes)
958 test ! -d CVS || cvs $(CVSOPTS) commit -m'Updated from $^' $@