1 # Copyright (C) 1991, 92, 93, 94, 95, 96 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
16 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 # Cambridge, MA 02139, 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.
33 # If `sources' was defined by the parent makefile, undefine it so
34 # we will later get it from wildcard search in this directory.
35 ifneq "$(findstring env,$(origin sources))" ""
40 PATH := this definition should take precedence over $(oPATH)
41 ifeq ($(PATH),$(oPATH))
42 You must not use the -e flag when building the GNU C library.
47 ifndef +included-Makeconfig
48 include $(..)Makeconfig
51 # `configure' writes a definition of `config-sysdirs' in `config.make'.
52 sysdirs = $(config-sysdirs)
54 +sysdir_pfx = $(common-objpfx)
56 export sysdirs := $(sysdirs)
58 +sysdep_dirs := $(addprefix $(sysdep_dir)/,$(sysdirs))
60 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
63 # Add -I switches to get the right sysdep directories.
64 # `+includes' in Makeconfig references $(+sysdep-includes).
65 +sysdep-includes := $(addprefix -I,$(+sysdep_dirs))
67 # The name of the symbol table archive member. The default is suitable for
68 # BSD style archives. It can be overridden in sysdep Makefiles when SYSV
69 # style archive are used.
71 ar-symtab-name = __.SYMDEF
73 ar-symtab-name = # The null name is used in ELF archives.
76 # Include any system-specific makefiles.
78 # This is here so things in sysdep Makefiles can easily depend on foo.h as
79 # appropriate and not worry about where foo.h comes from, which may be
80 # system dependent and not known by that Makefile.
81 vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) \
82 $(addprefix $(sysdep_dir)/,$(sysdirs)) \
85 # Some sysdep makefiles use this to distinguish being included here from
86 # being included individually by a subdir makefile (hurd/Makefile needs this).
89 ifndef avoid-generated
90 -include $(+sysdir_pfx)sysd-Makefile
91 ifneq ($(sysd-Makefile-sysdirs),$(sysdirs))
92 sysd-Makefile-force = FORCE
95 $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)config.make $(..)Makerules \
96 $(sysd-Makefile-force)
98 (echo 'sysd-Makefile-sysdirs := $(sysdirs)'; \
99 for dir in $(sysdirs); do \
100 file=sysdeps/$$dir/Makefile; \
101 if [ -f $(..)$$file ]; then \
102 echo include "\$$(..)$$file"; \
105 echo 'sysd-Makefile-done=t') > $@T
109 ifndef sysd-Makefile-done
110 # Don't do deps until this exists, because it might change the sources list.
115 # Reorder before-compile so that mach things come first, and hurd things
116 # second, before all else. The mach and hurd subdirectories have many
117 # generated header files which the much of rest of the library depends on,
118 # so it is best to build them first (and mach before hurd, at that).
119 before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
121 $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
124 # Remove existing files from `before-compile'. Things are added there when
125 # they must exist for dependency generation to work right, but once they
126 # exist there is no further need for every single file to depend on them,
127 # and those gratuitous dependencies result in many gratuitous
129 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
131 # Don't let any before-compile file be an intermediate and get removed.
136 # Generate an ordered list of implicit rules which find the source files in
137 # each sysdep directory. The old method was to use vpath to search all the
138 # sysdep directories. However, that had the problem that a .S file in a
139 # later directory would be chosen over a .c file in an earlier directory,
140 # which does not preserve the desired sysdeps ordering behavior.
142 # When making the list of .d files to include, we can't know which ones
143 # have source in .s files, and thus do not in fact need a .d file.
144 # So we must define rules to make .d files for .s files.
145 define make-dummy-dep
146 $(addprefix ln $(objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
149 echo '# .s files cannot contain includes, so they need no deps.' > $@
151 # It matters that this set of rules, for compiling from sources in
152 # the current directory (the $srcdir/$subdir) come before the
153 # generated sysdep rules in included from sysd-rules below. When
154 # compiling in the source tree, generated sources go into the current
155 # directory, and those should be chosen before any sources in sysdeps.
156 $(objpfx)%.o: %.S $(before-compile); $(compile-command.S)
157 $(objpfx)%.so: %.S $(before-compile); $(compile-command.S)
158 $(objpfx)%.po: %.S $(before-compile); $(compile-command.S)
159 $(objpfx)%.go: %.S $(before-compile); $(compile-command.S)
160 $(objpfx)%.d: %.S $(before-compile); $(+make-deps)
161 $(objpfx)%.o: %.s $(before-compile); $(compile-command.s)
162 $(objpfx)%.so: %.s $(before-compile); $(compile-command.s)
163 $(objpfx)%.po: %.s $(before-compile); $(compile-command.s)
164 $(objpfx)%.go: %.s $(before-compile); $(compile-command.s)
165 $(objpfx)%.d: %.s $(objpfx)dummy.d; $(make-dummy-dep)
166 $(objpfx)%.o: %.c $(before-compile); $(compile-command.c)
167 $(objpfx)%.so: %.c $(before-compile); $(compile-command.c)
168 $(objpfx)%.po: %.c $(before-compile); $(compile-command.c)
169 $(objpfx)%.go: %.c $(before-compile); $(compile-command.c)
170 $(objpfx)%.d: %.c $(before-compile); $(+make-deps)
172 # Omit the objpfx rules when building in the source tree, because
173 # objpfx is empty and so these rules just override the ones above.
175 # Define first rules to find the source files in $(objpfx).
176 # Generated source files will end up there.
177 $(objpfx)%.o: $(objpfx)%.S $(before-compile); $(compile-command.S)
178 $(objpfx)%.so: $(objpfx)%.S $(before-compile); $(compile-command.S)
179 $(objpfx)%.po: $(objpfx)%.S $(before-compile); $(compile-command.S)
180 $(objpfx)%.go: $(objpfx)%.S $(before-compile); $(compile-command.S)
181 $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps)
182 $(objpfx)%.o: $(objpfx)%.s $(before-compile); $(compile-command.s)
183 $(objpfx)%.so: $(objpfx)%.s $(before-compile); $(compile-command.s)
184 $(objpfx)%.po: $(objpfx)%.s $(before-compile); $(compile-command.s)
185 $(objpfx)%.go: $(objpfx)%.s $(before-compile); $(compile-command.s)
186 $(objpfx)%.d: $(objpfx)%.s $(objpfx)dummy.d; $(make-dummy-dep)
187 $(objpfx)%.o: $(objpfx)%.c $(before-compile); $(compile-command.c)
188 $(objpfx)%.so: $(objpfx)%.c $(before-compile); $(compile-command.c)
189 $(objpfx)%.po: $(objpfx)%.c $(before-compile); $(compile-command.c)
190 $(objpfx)%.go: $(objpfx)%.c $(before-compile); $(compile-command.c)
191 $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps)
194 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
195 # patterns matching sysdep directories whose assembly source files should
197 ifdef inhibit-sysdep-asm
198 define open-check-inhibit-asm
199 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
201 close-check-inhibit-asm = ;; esac ;
204 # Don't include sysd-rules until sysd-Makefile is already there and has been
205 # included. It might define inhibit-sysdep-asm, which would affect the
206 # contents of sysd-rules.
207 ifdef sysd-Makefile-done
208 -include $(+sysdir_pfx)sysd-rules
209 ifneq ($(sysd-rules-sysdirs),$(sysdirs))
210 # The value of $(sysdirs) the sysd-rules was computed for
211 # differs from the one we are using now. So force a rebuild of sysd-rules.
212 sysd-rules-force = FORCE
216 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
217 $(wildcard $(foreach dir,$(sysdirs),\
218 $(sysdep_dir)/$(dir)/Makefile))\
221 (echo 'sysd-rules-sysdirs := $(sysdirs)'; \
222 for sysdir in $(sysdirs); do \
223 dir="\$$(sysdep_dir)/$$sysdir"; \
224 for o in $(object-suffixes); do \
225 $(open-check-inhibit-asm) \
226 echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
227 \$$(compile-command.S)"; \
228 echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
229 \$$(compile-command.s)"; \
230 $(close-check-inhibit-asm) \
231 echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
232 \$$(compile-command.c)"; \
234 $(open-check-inhibit-asm) \
235 echo "\$$(objpfx)%.d: $$dir/%.s \$$(objpfx)dummy.d; \
236 \$$(make-dummy-dep)"; \
237 echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
239 $(close-check-inhibit-asm) \
240 echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \
243 echo 'sysd-rules-done = t') > $@T
246 ifndef sysd-rules-done
247 # Don't do deps until this exists, because it provides rules to make the deps.
252 ifndef compile-command.S
253 compile-command.S = $(compile.S) $(OUTPUT_OPTION)
255 ifndef compile-command.s
256 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION)
258 ifndef compile-command.c
259 compile-command.c = $(compile.c) $(OUTPUT_OPTION)
262 # GCC can grok options after the file name, and it looks nicer that way.
263 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
264 compile.S = $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
265 COMPILE.S = $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
266 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
268 # We need this for the output to go in the right place. It will default to
269 # empty if make was configured to work with a cc that can't grok -c and -o
270 # together. You can't compile the C library with such a compiler.
271 OUTPUT_OPTION = -o $@
273 S-CPPFLAGS = $(asm-CPPFLAGS)
276 $(+mkdep) $< $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
277 sed -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(object-suffixes),$(@:.d=$o)) $@,' \
278 $(sed-remove-objpfx) > $(@:.d=.T)
282 # Continuation lines here are dangerous because they introduce spaces!
283 define sed-remove-objpfx
284 -e 's@ $(subst .,\.,$(subst @,\@,$(objpfx)))@ $$(objpfx)@g' \
285 -e 's@^$(subst .,\.,$(subst @,\@,$(objpfx)))@$$(objpfx)@g'
289 # Shared library building.
291 ifeq (yes,$(build-shared))
293 # Pattern rule to build a shared object from an archive of PIC objects.
294 # This must come after the installation rules so Make doesn't try to
295 # build shared libraries in place from the installed *_pic.a files.
296 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
297 # on other shared objects.
298 lib%.so: lib%_pic.a; $(build-shlib)
300 ifeq ($(have-no-whole-archive),yes)
301 no-whole-archive = -Wl,--no-whole-archive
307 $(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \
309 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
310 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
311 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
312 -Wl,--whole-archive $^ $(no-whole-archive) \
313 $(LDLIBS-$(@F:lib%.so=%).so)
316 # Don't try to use -lc when making libc.so itself.
317 # Also omits crti.o and crtn.o, which we do not want
318 # since we define our own `.init' section specially.
319 LDFLAGS-c.so = -nostdlib -nostartfiles
320 # Give libc.so an entry point and make it directly runnable itself.
321 LDFLAGS-c.so += -e __libc_main
322 # Use our own special initializer and finalizer files for libc.so.
323 elfobjdir := $(firstword $(objdir) $(patsubst ../$(subdir),.,$(..)elf))
324 $(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
325 $(common-objpfx)libc_pic.a \
326 $(elfobjdir)/sofini.so $(elfobjdir)/ld.so
329 ifdef libc.so-version
330 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
332 ln -s $(<F) $@ || ln $< $@
336 # Some files must not be compiled with the exception handler mechanism
337 # enabled (introduced in gcc-2.8). Use $(no-exceptions) in the
338 # appropriate CFLAGS definition.
339 ifeq ($(have-no-exceptions),yes)
340 no-exceptions = -fno-exceptions
345 # Figure out the source filenames in this directory.
347 override sources := $(addsuffix .c,$(filter-out $(elided-routines),\
350 sysdep_routines := $(sysdep_routines)
352 headers := $(headers) $(sysdep_headers)
354 # This is the list of all object files, gotten by
355 # replacing every ".c" in `sources' with a ".o".
356 override objects := $(addprefix $(objpfx),$(sources:.c=.o))
359 # This variable is used in ``include $(o-iterator)'' after defining
360 # $(o-iterator-doit) to produce some desired rule using $o for the object
361 # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
362 # is produced for each object suffix in use.
363 o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
365 # The makefile may define $(extra-libs) with `libfoo libbar'
366 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
368 # extra-lib.mk is included once for each extra lib to define rules
369 # to build it, and to add its objects to the various variables.
370 # During its evaluation, $(lib) is set to the name of the library.
371 extra-libs-left := $(extra-libs)
372 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
375 +depfiles := $(strip $(sources:.c=.d) \
376 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.so=.o))) \
377 $(addsuffix .d,$(others) $(tests)))
378 +depfiles := $(addprefix $(objpfx),\
379 $(filter-out $(addsuffix .d,$(omit-deps)),\
384 -include $(+depfiles)
388 # Maximize efficiency by minimizing the number of rules.
389 .SUFFIXES: # Clear the suffix list.
390 # Add the suffixes we use.
391 .SUFFIXES: .a $(object-suffixes) .S .s .c .h .d
393 # Generic rule for making directories.
395 # mkdir isn't smart enough to strip a trailing /.
398 # Make sure that object files are not removed
399 # when they are intermediates between sources and library members.
400 .PRECIOUS: $(addprefix $(objpfx)%,$(object-suffixes))
402 # Make sure that the parent library archive is never removed.
403 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
405 # Use the verbose option of ar and tar when not running silently.
406 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
412 ARFLAGS := r$(verbose)
414 # This makes all the object files in the parent library archive.
416 .PHONY: lib libobjs lib-noranlib
417 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
419 # Pattern rule for libraries: depend on the __.SYMDEF member updated by ranlib.
420 lib%.a: lib%.a($(ar-symtab-name)) ;
422 # For object-suffix $o, the list of objects with that suffix.
423 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
424 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
425 $(elide-routines$o)),\
428 libobjs: $(foreach o,$(object-suffixes),\
429 $(common-objpfx)$(patsubst %,$(libtype$o),c)(\
430 $(notdir $(o-objects))))
431 lib-noranlib: libobjs
432 others: $(addprefix $(objpfx),$(install-lib))
436 # Create the stamp$o files to keep the parent makefile happy.
437 subdir_lib: $(foreach o,$(object-suffixes),$(objpfx)stamp$o-$(subdir))
438 $(foreach o,$(object-suffixes),$(objpfx)stamp$o-$(subdir)):
442 # Define a pattern rule that will match many targets libc.a(foo.%), for
443 # each foo.o in $(objects) (% will just happen always to match `o'). This is
444 # the only way to define a rule that updates many targets at once with one
445 # sequence of commands.
446 define o-iterator-doit
447 $(common-objpfx)$(patsubst %,$(libtype$o),c)(\
448 $(addsuffix .%,$(filter-out $(elide-routines$o),$(notdir $(objects:.o=))))): \
449 $(objpfx)stamp.%-$(subdir) ;
451 object-suffixes-left := $(object-suffixes)
452 include $(o-iterator)
454 # The pattern rule tells Make to remake $(objpfx)stamp.%-$(subdir) as
455 # the way to update all the foo.% object files in $(objects). Now we
456 # define explicit rules to update each $(objpfx)stamp.SUFFIX-$(subdir)
457 # timestamp file; these rules (one explicit rule is generated for each
458 # object suffix) will update the parent archive with ar. Use a static
459 # pattern rule so $* is set to the object type during the commands.
460 define o-iterator-doit
461 $(objpfx)stamp$o-$(subdir): $(objpfx)stamp%-$(subdir): $(o-objects); $$(do-ar)
463 object-suffixes-left := $(object-suffixes)
464 include $(o-iterator)
466 topdir=`cd $(..).; pwd`; \
467 $(patsubst %,cd %;,$(objdir)) \
468 $$topdir/autolock.sh ${O%-lib}.lck $(AR) cru$(verbose) ${O%-lib} \
469 $(patsubst $(objpfx)%,%,$^)
474 O%-lib = $(filter ../,$(firstword $(objdir) ../))$(patsubst %,$(libtype$*),c)
476 O%-lib = $(patsubst %,$(libtype$*),c)
481 # Rules to update the $(ar-symtab-name) member with ranlib,
482 # one for each object flavor.
483 define o-iterator-doit
484 $(common-objpfx)$(patsubst %,$(libtype$o),c)($(ar-symtab-name)): \
485 $(common-objpfx)$(patsubst %,$(libtype$o),c)(\
486 $(patsubst $(objpfx)%,%,$(o-objects))) $(subdirs-stamp-o); \
487 $$(..)./autolock.sh \
488 $$(common-objpfx)$$(patsubst %,$$(libtype$o),c).lck \
489 $$(RANLIB) $$(common-objpfx)$$(patsubst %,$$(libtype$o),c)
492 subdirs-stamps := $(foreach d,$(subdirs),\
493 $(firstword $(objdir) $(subdir))/stamp%-$d)
494 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
495 $(subdirs-stamps): subdir_lib;
497 object-suffixes-left = $(object-suffixes)
498 include $(o-iterator)
501 # This makes all the object files.
503 objects objs: $(foreach o,$(object-suffixes),$(o-objects)) \
504 $(addprefix $(objpfx),$(extra-objs))
506 # Canned sequence for building an extra library archive.
507 define build-extra-lib
508 $(patsubst %,cd %;,$(objdir)) \
509 $(AR) cru$(verbose) $(@:$(objpfx)%=%) \
510 $(patsubst $(objpfx)%,%,$^)
516 # $(install-lib) are installed from the object directory into $(libdir);
517 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
518 # unless they also appear in $(non-lib.a). $(install-data) are installed
519 # as they are into $(datadir). $(headers) are installed as they are in
520 # $(includedir). $(install-bin) and $(install-sbin) are installed from the
521 # object directory into $(bindir) and $(sbindir), respectively.
522 # $(install-others) are absolute path names of files to install; rules to
523 # install them are defined elsewhere.
525 # The simple library name to install libc.a under.
526 # This could be defined by a sysdep Makefile.
532 $(make-target-directory)
533 $(INSTALL_DATA) $< $@
536 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
537 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
538 define make-target-directory
539 $(addprefix $(..)./mkinstalldirs ,\
540 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
543 # Any directory (parent or subdir) that has any object files to build
544 # should install libc.a; this way "make install" in a subdir is guaranteed
545 # to install everything it changes.
547 installed-libcs := $(foreach o,$(object-suffixes),\
548 $(libdir)/$(patsubst %,$(libtype$o),\
549 $(libprefix)$(libc-name)))
550 installed-libcs := $(filter-out %_pic.a,$(installed-libcs))
551 install: $(installed-libcs)
552 $(installed-libcs): $(libdir)/lib$(libprefix)%: lib
553 $(make-target-directory)
554 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
555 # Running ranlib after installing makes the __.SYMDEF time stamp up to
556 # date, which avoids messages from some linkers.
560 define do-install-program
561 $(make-target-directory)
562 $(INSTALL_PROGRAM) $< $@.new
566 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
567 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
568 ifeq (yes,$(build-shared))
570 install-lib-nosubdir: $(install-lib.so:%=$(libdir)/%)
572 # Find which .so's have versions.
573 versioned := $(strip $(foreach so,$(install-lib.so),\
574 $(patsubst %,$(so),$($(so)-version))))
576 # Install all the unversioned shared libraries.
577 $(addprefix $(libdir)/,$(filter-out $(versioned),$(install-lib.so))): \
578 $(libdir)/%.so: $(objpfx)%.so; $(do-install-program)
581 cd $(@D); rm -f $(@F).new; $(LN_S) $(<F) $(@F).new; mv -f $(@F).new $(@F)
584 ifdef libc.so-version
585 # For a library specified to be version N, install three files:
586 # libc.so -> libc.so.N (e.g. libc.so.6)
587 # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
589 $(slibdir)/libc.so$(libc.so-version): $(slibdir)/libc-$(version).so
591 $(slibdir)/libc-$(version).so: $(common-objpfx)libc.so; $(do-install-program)
592 install: $(slibdir)/libc.so$(libc.so-version)
595 # What we install as libc.so for programs to link against is in fact an
596 # archive. It contains the various $(static-only-routines) objects, and
597 # the special object libc-syms.so that contains just the dynamic symbol
598 # table of the shared libc object.
599 install: $(libdir)/libc.so
600 $(libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \
601 $(elfobjdir)/$(rtld-installed-name) \
602 $(common-objpfx)libc.a
603 (echo '/* Use the shared library, but some functions are only in';\
604 echo ' the static library, so try that secondarily.'; \
605 echo ' The dynamic linker defines some functions used by $(<F),';\
606 echo ' but ld uses definitions from libc.a before examining the';\
607 echo ' dependencies of $(<F) to find $(rtld-installed-name). */';\
608 echo 'GROUP ( $(^F) )') > $@.new
614 install: $(slibdir)/libc.so
615 $(slibdir)/libc.so: $(common-objpfx)libc.so; $(do-install-program)
619 ifneq (,$(versioned))
620 # Produce three sets of rules as above for all the smaller versioned libraries.
622 define o-iterator-doit
623 $(libdir)/$o: $(libdir)/$o$($o-version); $$(make-link)
625 object-suffixes-left := $(versioned)
626 include $(o-iterator)
628 # Make symlinks in the build directory, because the versioned names might
629 # be referenced by a DT_NEEDED in another library.
630 define o-iterator-doit
631 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
633 object-suffixes-left := $(versioned)
634 include $(o-iterator)
637 define o-iterator-doit
638 $(libdir)/$o$($o-version): $(libdir)/$(o:.so=)-$(version).so; $$(make-link)
640 object-suffixes-left := $(versioned)
641 include $(o-iterator)
643 define o-iterator-doit
644 $(libdir)/$(o:.so=)-$(version).so: $(objpfx)$o; $$(do-install-program)
646 object-suffixes-left := $(versioned)
647 include $(o-iterator)
651 $(do-install-program)
652 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
653 $(filter-out %.so,$@))
656 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
657 $(foreach v,$(so-versions),\
658 $(libdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so
660 $(foreach v,$(so-versions),\
661 $(libdir)/$(libprefix)%$v): $(common-objpfx)%.so
666 $(addprefix $(bindir)/,$(install-bin)): $(bindir)/%: $(objpfx)%
667 $(do-install-program)
670 $(addprefix $(sbindir)/,$(install-sbin)): $(sbindir)/%: $(objpfx)%
671 $(do-install-program)
674 install-lib.a := $(filter lib%.a,$(install-lib))
675 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
676 ifdef install-lib-non.a
677 $(addprefix $(libdir)/$(libprefix),$(install-lib-non.a)): \
678 $(libdir)/$(libprefix)%: $(objpfx)%
682 $(install-lib.a:lib%.a=$(libdir)/lib$(libprefix)%.a): \
683 $(libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a
685 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
689 $(addprefix $(datadir)/,$(install-data)): $(datadir)/%: %;$(do-install)
691 headers := $(strip $(headers))
693 $(addprefix $(includedir)/,$(headers)): \
694 $(includedir)/%: %;$(do-install)
697 .PHONY: install-bin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
698 install-data-nosubdir install-headers-nosubdir
699 install-bin-nosubdir: $(addprefix $(bindir)/,$(install-bin))
700 install-sbin-nosubdir: $(addprefix $(sbindir)/,$(install-sbin))
701 install-lib-nosubdir: $(addprefix $(libdir)/,\
702 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
703 $(addprefix $(libprefix),$(install-lib-non.a)))
704 install-data-nosubdir: $(addprefix $(datadir)/,$(install-data))
705 install-headers-nosubdir: $(addprefix $(includedir)/,$(headers))
706 install-others-nosubdir: $(install-others)
708 # We need all the `-nosubdir' targets so that `install' in the parent
709 # doesn't depend on several things which each iterate over the subdirs.
710 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
711 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
712 install-%:: install-%-nosubdir ;
714 .PHONY: install install-no-libc.a-nosubdir
715 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
716 install-bin-nosubdir install-lib-nosubdir \
717 install-others-nosubdir install-sbin-nosubdir
718 install: install-no-libc.a-nosubdir
720 # Command to compile $< in $(objdir) using the native libraries.
721 define native-compile
722 cwd=`pwd`; cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) \
723 $(addprefix $$cwd/,$^) -o $(@F)
726 # Command to compile $< in $(common-objdir) using the native libraries.
727 define common-objdir-compile
728 cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) $(<:$(common-objpfx)%=%) -o $(@F)
731 # We always want to use configuration definitions.
733 # This is always used in $(common-objdir), so we use no directory name.
734 BUILD_CFLAGS = -include config.h
736 BUILD_CFLAGS = -include $(..)config.h
739 # Support the GNU standard name for this target.
744 TAGS: $(common-objpfx)distinfo-$(subdir) $(..)MakeTAGS
745 $(MAKE) $(addprefix -f ,$^) $@
747 $(..)po/%.pot: $(common-objpfx)distinfo-$(subdir) $(..)MakeTAGS FORCE
748 $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
757 # Common cleaning targets.
759 .PHONY: common-mostlyclean common-clean mostlyclean clean
761 mostlyclean: common-mostlyclean
763 # Remove the object files.
765 -rm -f $(addprefix $(objpfx),$(tests) $(others) \
766 $(addsuffix .o,$(tests) $(others)) \
767 $(addsuffix .out,$(tests)))
768 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib))
769 -rm -f core $(objpfx)stub-$(subdir)
772 $(foreach o,$(object-suffixes),
773 -rm -f $(addprefix $(objpfx),stamp$o-$(subdir)) $(o-objects))
776 # Also remove the dependencies and generated source files.
777 common-clean: common-mostlyclean
778 -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
779 -rm -f $(common-objpfx)distinfo-$(subdir)
781 # Produce a file `stub-$(subdir)' which contains `#define __stub_FUNCTION'
782 # for each function which is a stub. We grovel over all the .d files
783 # looking for references to source files in sysdeps/stub. Then we grovel
784 # over each referenced source file to see what stub function it defines.
786 .PHONY: stubs # The parent Makefile calls this target.
787 stubs: $(common-objpfx)stub-$(subdir)
788 s = $(sysdep_dir)/stub
789 $(common-objpfx)stub-$(subdir): $(+depfiles)
790 # Use /dev/null since `...` might expand to empty.
791 (s=`cd $s; /bin/pwd`; \
792 $(patsubst %,cd %;,$(objdir)) \
793 sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
794 `sed -n 's@^.*$s/\([a-z0-9_-]*\.c\).*$$@'"$$s"/'\1@p' \
795 $(patsubst $(objpfx)%,%,$^) /dev/null` \
799 # Make the distribution tar file.
802 dist: $(common-objpfx)distinfo-$(subdir) $(..)Make-dist
803 $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
805 # Avoid depending on source files found in sysdeps dirs,
806 # because the references affect implicit rule selection.
807 dist: $(filter-out %.c %.S %.s,$(distribute))
809 # We used to simply export all these variables, but that frequently made the
810 # environment get too large. Instead, we write all the information into
811 # a generated makefile fragment `distinfo', and then include it with -f in
812 # the sub-make that makes the distribution (above).
813 $(common-objpfx)distinfo-$(subdir): Makefile $(..)Makerules
816 .PHONY: subdir_distinfo distinfo
817 subdir_distinfo: distinfo
818 distinfo: $(common-objpfx)distinfo-$(subdir)
822 echo > $@.new 'subdir := $(subdir)'
823 $(foreach var,subdir-dirs sources elided-routines sysdep_routines \
824 headers sysdep_headers distribute dont_distribute generated \
825 others tests extra-libs $(extra-libs:%=%-routines) \
827 $(addprefix install-,lib lib.so data bin sbin others),
828 echo >> $@.new '$(subdir)-$(var) := $($(var))'
829 echo >> $@.new '$(var) = $$($(subdir)-$(var))')
832 ifneq (,$(strip $(gpl2lgpl)))
833 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
834 # Snarf from the master source and frob the copying notice.
835 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
837 # So I don't edit them by mistake.
840 test ! -d CVS || cvs commit -m'Updated from $^' $@