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))" ""
39 headers := $(headers) $(sysdep_headers)
42 PATH := this definition should take precedence over $(oPATH)
43 ifeq ($(PATH),$(oPATH))
44 You must not use the -e flag when building the GNU C library.
49 ifndef +included-Makeconfig
50 include $(..)Makeconfig
53 # `configure' writes a definition of `config-sysdirs' in `config.make'.
54 sysdirs = $(config-sysdirs)
56 +sysdir_pfx = $(common-objpfx)
58 export sysdirs := $(sysdirs)
60 +sysdep_dirs := $(addprefix $(sysdep_dir)/,$(sysdirs))
62 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
65 # Add -I switches to get the right sysdep directories.
66 # `+includes' in Makeconfig references $(+sysdep-includes).
67 +sysdep-includes := $(addprefix -I,$(+sysdep_dirs))
69 # The name of the symbol table archive member. The default is suitable for
70 # BSD style archives. It can be overridden in sysdep Makefiles when SYSV
71 # style archive are used.
72 ar-symtab-name = __.SYMDEF
74 # Include any system-specific makefiles.
76 # This is here so things in sysdep Makefiles can easily depend on foo.h as
77 # appropriate and not worry about where foo.h comes from, which may be
78 # system dependent and not known by that Makefile.
79 vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) \
80 $(addprefix $(sysdep_dir)/,$(sysdirs)) \
83 # Some sysdep makefiles use this to distinguish being included here from
84 # being included individually by a subdir makefile (hurd/Makefile needs this).
87 ifndef avoid-generated
88 -include $(+sysdir_pfx)sysd-Makefile
89 ifneq ($(sysd-Makefile-sysdirs),$(sysdirs))
90 sysd-Makefile-force = FORCE
93 $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)config.make $(..)Makerules \
94 $(sysd-Makefile-force)
96 (echo 'sysd-Makefile-sysdirs := $(sysdirs)'; \
97 for dir in $(sysdirs); do \
98 file=sysdeps/$$dir/Makefile; \
99 if [ -f $(..)$$file ]; then \
100 echo include "\$$(..)$$file"; \
103 echo 'sysd-Makefile-done=t') > $@T
107 ifndef sysd-Makefile-done
108 # Don't do deps until this exists, because it might change the sources list.
113 # Reorder before-compile so that mach things come first, and hurd things
114 # second, before all else. The mach and hurd subdirectories have many
115 # generated header files which the much of rest of the library depends on,
116 # so it is best to build them first (and mach before hurd, at that).
117 before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
119 $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
122 # Remove existing files from `before-compile'. Things are added there when
123 # they must exist for dependency generation to work right, but once they
124 # exist there is no further need for every single file to depend on them,
125 # and those gratuitous dependencies result in many gratuitous
127 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
129 # Don't let any before-compile file be an intermediate and get removed.
134 # Generate an ordered list of implicit rules which find the source files in
135 # each sysdep directory. The old method was to use vpath to search all the
136 # sysdep directories. However, that had the problem that a .S file in a
137 # later directory would be chosen over a .c file in an earlier directory,
138 # which does not preserve the desired sysdeps ordering behavior.
140 # When making the list of .d files to include, we can't know which ones
141 # have source in .s files, and thus do not in fact need a .d file.
142 # So we must define rules to make .d files for .s files.
143 define make-dummy-dep
144 $(addprefix ln $(objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
147 echo '# .s files cannot contain includes, so they need no deps.' > $@
149 # It matters that this set of rules, for compiling from sources in
150 # the current directory (the $srcdir/$subdir) come before the
151 # generated sysdep rules in included from sysd-rules below. When
152 # compiling in the source tree, generated sources go into the current
153 # directory, and those should be chosen before any sources in sysdeps.
154 $(objpfx)%.o: %.S $(before-compile); $(compile-command.S)
155 $(objpfx)%.so: %.S $(before-compile); $(compile-command.S)
156 $(objpfx)%.po: %.S $(before-compile); $(compile-command.S)
157 $(objpfx)%.go: %.S $(before-compile); $(compile-command.S)
158 $(objpfx)%.d: %.S $(before-compile); $(+make-deps)
159 $(objpfx)%.o: %.s $(before-compile); $(compile-command.s)
160 $(objpfx)%.so: %.s $(before-compile); $(compile-command.s)
161 $(objpfx)%.po: %.s $(before-compile); $(compile-command.s)
162 $(objpfx)%.go: %.s $(before-compile); $(compile-command.s)
163 $(objpfx)%.d: %.s $(objpfx)dummy.d; $(make-dummy-dep)
164 $(objpfx)%.o: %.c $(before-compile); $(compile-command.c)
165 $(objpfx)%.so: %.c $(before-compile); $(compile-command.c)
166 $(objpfx)%.po: %.c $(before-compile); $(compile-command.c)
167 $(objpfx)%.go: %.c $(before-compile); $(compile-command.c)
168 $(objpfx)%.d: %.c $(before-compile); $(+make-deps)
170 # Omit the objpfx rules when building in the source tree, because
171 # objpfx is empty and so these rules just override the ones above.
173 # Define first rules to find the source files in $(objpfx).
174 # Generated source files will end up there.
175 $(objpfx)%.o: $(objpfx)%.S $(before-compile); $(compile-command.S)
176 $(objpfx)%.so: $(objpfx)%.S $(before-compile); $(compile-command.S)
177 $(objpfx)%.po: $(objpfx)%.S $(before-compile); $(compile-command.S)
178 $(objpfx)%.go: $(objpfx)%.S $(before-compile); $(compile-command.S)
179 $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps)
180 $(objpfx)%.o: $(objpfx)%.s $(before-compile); $(compile-command.s)
181 $(objpfx)%.so: $(objpfx)%.s $(before-compile); $(compile-command.s)
182 $(objpfx)%.po: $(objpfx)%.s $(before-compile); $(compile-command.s)
183 $(objpfx)%.go: $(objpfx)%.s $(before-compile); $(compile-command.s)
184 $(objpfx)%.d: $(objpfx)%.s $(objpfx)dummy.d; $(make-dummy-dep)
185 $(objpfx)%.o: $(objpfx)%.c $(before-compile); $(compile-command.c)
186 $(objpfx)%.so: $(objpfx)%.c $(before-compile); $(compile-command.c)
187 $(objpfx)%.po: $(objpfx)%.c $(before-compile); $(compile-command.c)
188 $(objpfx)%.go: $(objpfx)%.c $(before-compile); $(compile-command.c)
189 $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps)
192 # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
193 # patterns matching sysdep directories whose assembly source files should
195 ifdef inhibit-sysdep-asm
196 define open-check-inhibit-asm
197 case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
199 close-check-inhibit-asm = ;; esac ;
202 # Don't include sysd-rules until sysd-Makefile is already there and has been
203 # included. It might define inhibit-sysdep-asm, which would affect the
204 # contents of sysd-rules.
205 ifdef sysd-Makefile-done
206 -include $(+sysdir_pfx)sysd-rules
207 ifneq ($(sysd-rules-sysdirs),$(sysdirs))
208 # The value of $(sysdirs) the sysd-rules was computed for
209 # differs from the one we are using now. So force a rebuild of sysd-rules.
210 sysd-rules-force = FORCE
214 $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
215 $(wildcard $(foreach dir,$(sysdirs),\
216 $(sysdep_dir)/$(dir)/Makefile))\
219 (echo 'sysd-rules-sysdirs := $(sysdirs)'; \
220 for sysdir in $(sysdirs); do \
221 dir="\$$(sysdep_dir)/$$sysdir"; \
222 for o in $(object-suffixes); do \
223 $(open-check-inhibit-asm) \
224 echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
225 \$$(compile-command.S)"; \
226 echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
227 \$$(compile-command.s)"; \
228 $(close-check-inhibit-asm) \
229 echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
230 \$$(compile-command.c)"; \
232 $(open-check-inhibit-asm) \
233 echo "\$$(objpfx)%.d: $$dir/%.s \$$(objpfx)dummy.d; \
234 \$$(make-dummy-dep)"; \
235 echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
237 $(close-check-inhibit-asm) \
238 echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \
241 echo 'sysd-rules-done = t') > $@T
244 ifndef sysd-rules-done
245 # Don't do deps until this exists, because it provides rules to make the deps.
250 ifndef compile-command.S
251 compile-command.S = $(compile.S) $(OUTPUT_OPTION)
253 ifndef compile-command.s
254 compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION)
256 ifndef compile-command.c
257 compile-command.c = $(compile.c) $(OUTPUT_OPTION)
260 # GCC can grok options after the file name, and it looks nicer that way.
261 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
262 compile.S = $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
263 COMPILE.S = $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
264 COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
266 # We need this for the output to go in the right place. It will default to
267 # empty if make was configured to work with a cc that can't grok -c and -o
268 # together. You can't compile the C library with such a compiler.
269 OUTPUT_OPTION = -o $@
271 S-CPPFLAGS = $(asm-CPPFLAGS)
274 $(+mkdep) $< $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
275 sed -e 's,$*\.o,$(foreach o,$(object-suffixes),$(@:.d=$o)) $@,' \
276 $(sed-remove-objpfx) > $(@:.d=.T)
280 sed-remove-objpfx = -e 's@ $(subst @,\@,$(objpfx))@ $$(objpfx)@g' \
281 -e 's@^$(subst @,\@,$(objpfx))@$$(objpfx)@g'
284 # Figure out the source filenames in this directory.
286 override sources := $(addsuffix .c,$(filter-out $(elided-routines),\
289 sysdep_routines := $(sysdep_routines)
291 # This is the list of all object files, gotten by
292 # replacing every ".c" in `sources' with a ".o".
293 override objects := $(addprefix $(objpfx),$(sources:.c=.o))
296 # This variable is used in ``include $(o-iterator)'' after defining
297 # $(o-iterator-doit) to produce some desired rule using $o for the object
298 # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
299 # is produced for each object suffix in use.
300 o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes))
302 # The makefile may define $(extra-libs) with `libfoo libbar'
303 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
305 # extra-lib.mk is included once for each extra lib to define rules
306 # to build it, and to add its objects to the various variables.
307 # During its evaluation, $(lib) is set to the name of the library.
308 extra-libs-left := $(extra-libs)
309 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
312 +depfiles := $(strip $(sources:.c=.d) \
313 $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.so=.o))) \
314 $(addsuffix .d,$(others) $(tests)))
315 +depfiles := $(addprefix $(objpfx),\
316 $(filter-out $(addsuffix .d,$(omit-deps)),\
321 -include $(+depfiles)
325 # Maximize efficiency by minimizing the number of rules.
326 .SUFFIXES: # Clear the suffix list.
327 # Add the suffixes we use.
328 .SUFFIXES: .a $(object-suffixes) .S .s .c .h .d
330 # Generic rule for making directories.
332 # mkdir isn't smart enough to strip a trailing /.
335 # Make sure that object files are not removed
336 # when they are intermediates between sources and library members.
337 .PRECIOUS: $(addprefix $(objpfx)%,$(object-suffixes))
339 # Make sure that the parent library archive is never removed.
340 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
342 # Use the verbose option of ar and tar when not running silently.
343 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
349 ARFLAGS := r$(verbose)
351 # This makes all the object files in the parent library archive.
353 .PHONY: lib libobjs lib-noranlib
354 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
356 # Pattern rule for libraries: depend on the __.SYMDEF member updated by ranlib.
357 lib%.a: lib%.a($(ar-symtab-name)) ;
359 libobjs: $(foreach o,$(object-suffixes),\
360 $(common-objpfx)$(patsubst %,$(libtype$o),c)(\
361 $(notdir $(objects:.o=$o))))
362 lib-noranlib: libobjs
363 others: $(addprefix $(objpfx),$(install-lib))
367 # Define a pattern rule that will match many targets libc.a(foo.%), for
368 # each foo.o in $(objects) (% will just happen always to match `o'). This is
369 # the only way to define a rule that updates many targets at once with one
370 # sequence of commands. We in fact define the pattern rule to match
371 # targets libc.a(foo.%), libc_pic.a(foo.%), etc, to avoid repeating the rule.
372 # Each match will only ever be called upon to make member objects of
373 # the appropriate type in each library (i.e. libc_pic.a(foo.so)).
374 $(foreach l,$(libtypes),\
375 $(common-objpfx)$(patsubst %,$l,c)($(notdir $(objects:.o=.%)))): \
376 $(objpfx)stamp.%-$(subdir) ;
378 # The pattern rule tells Make to remake $(objpfx)stamp.%-$(subdir) as
379 # the way to update all the foo.% object files in $(objects).
380 # Now we define a static pattern rule to update each
381 # $(objpfx)stamp.SUFFIX-$(subdir) timestamp file;
382 # these rules (one explicit rule is generated for each object suffix)
383 # will update the parent archive with
384 $(foreach o,$(object-suffixes),$(objpfx)stamp$o-$(subdir)): \
385 $(objpfx)stamp%-$(subdir): $(objects:.o=%)
386 $(patsubst %,cd %;,$(objdir)) \
387 $(AR) cru$(verbose) ${O%-lib} \
388 $(patsubst $(objpfx)%,%,$^)
389 # `touch' won't let me touch a world-writable file I don't own. Sigh.
393 O%-lib = $(filter ../,$(firstword $(objdir) ../))$(patsubst %,$(libtype$*),c)
395 O%-lib = $(patsubst %,$(libtype$*),c)
400 # Rules to update the $(ar-symtab-name) member with ranlib,
401 # one for each object flavor.
402 define o-iterator-doit
403 $(common-objpfx)$(patsubst %,$(libtype$o),c)($(ar-symtab-name)): \
404 $(common-objpfx)$(patsubst %,$(libtype$o),c)(\
405 $(patsubst $(objpfx)%.o,%$o,$(objects))) \
406 $(filter subdir_lib,$(firstword $(subdir) subdir_lib)); \
407 $$(RANLIB) $$(common-objpfx)$$(patsubst %,$$(libtype$o),c)
409 object-suffixes-left = $(object-suffixes)
410 include $(o-iterator)
413 # This makes all the object files.
415 objects objs: $(foreach o,$(object-suffixes),$(objects:.o=$o)) \
416 $(addprefix $(objpfx),$(extra-objs))
418 # Canned sequence for building an extra library archive.
419 define build-extra-lib
420 $(patsubst %,cd %;,$(objdir)) \
421 $(AR) cru$(verbose) $(@:$(objpfx)%=%) \
422 $(patsubst $(objpfx)%,%,$^)
428 # $(install-lib) are installed from the object directory into $(libdir);
429 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
430 # unless they also appear in $(non-lib.a). $(install-data) are installed
431 # as they are into $(datadir). $(headers) are installed as they are in
432 # $(includedir). $(install-bin) and $(install-sbin) are installed from the
433 # object directory into $(bindir) and $(sbindir), respectively.
434 # $(install-others) are absolute path names of files to install; rules to
435 # install them are defined elsewhere.
437 # The simple library name to install libc.a under.
438 # This could be defined by a sysdep Makefile.
444 $(make-target-directory)
445 $(INSTALL_DATA) $< $@
448 # Make the target directory if it doesn't exist. Because of make's
449 # directory cache, this will produce the `mkdir' command when the directory
450 # already exists, if it didn't exist at the start of the `make' run. The
451 # `-' prefix ignores errors from mkdir, so there will just be some
452 # gratuitous but harmless `File exists' messages.
453 define make-target-directory
454 $(addprefix -mkdir ,$(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
457 # Any directory (parent or subdir) that has any object files to build
458 # should install libc.a; this way "make install" in a subdir is guaranteed
459 # to install everything it changes.
461 installed-libcs := $(foreach o,$(object-suffixes),\
462 $(libdir)/$(patsubst %,$(libtype$o),\
463 $(libprefix)$(libc-name)))
464 installed-libcs := $(filter-out %_pic.a,$(installed-libcs))
465 install: $(installed-libcs)
466 $(installed-libcs): $(libdir)/lib$(libprefix)%: lib
467 $(make-target-directory)
468 $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
469 # Running ranlib after installing makes the __.SYMDEF time stamp up to
470 # date, which avoids messages from some linkers.
474 define do-install-program
475 $(make-target-directory)
476 $(INSTALL_PROGRAM) $< $@.new
480 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
481 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
482 ifeq (yes,$(build-shared))
483 install-lib-nosubdir: $(foreach so,$(install-lib.so),\
484 $(libdir)/$(patsubst $(libprefix)lib%,lib$(libprefix)%,\
485 $(libprefix)$(so))$($(so)-version))
487 install: $(slibdir)/libc.so$(libc.so-version)
488 $(slibdir)/lib$(libprefix)c.so$(libc.so-version): $(common-objpfx)libc.so
492 $(do-install-program)
493 $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
494 $(filter-out %.so,$@))
497 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
498 $(foreach v,$(so-versions),\
499 $(libdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so
501 $(foreach v,$(so-versions),\
502 $(libdir)/$(libprefix)%$v): $(common-objpfx)%.so
507 $(addprefix $(bindir)/,$(install-bin)): $(bindir)/%: $(objpfx)%
508 $(do-install-program)
511 $(addprefix $(sbindir)/,$(install-sbin)): $(sbindir)/%: $(objpfx)%
512 $(do-install-program)
515 install-lib.a := $(filter lib%.a,$(install-lib))
516 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
517 ifdef install-lib-non.a
518 $(addprefix $(libdir)/$(libprefix),$(install-lib-non.a)): \
519 $(libdir)/$(libprefix)%: $(objpfx)%
523 $(install-lib.a:lib%.a=$(libdir)/lib$(libprefix)%.a): \
524 $(libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a
526 $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
530 $(addprefix $(datadir)/,$(install-data)): $(datadir)/%: %;$(do-install)
532 headers := $(strip $(headers))
534 $(addprefix $(includedir)/,$(headers)): \
535 $(includedir)/%: %;$(do-install)
538 .PHONY: install-bin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
539 install-data-nosubdir install-headers-nosubdir
540 install-bin-nosubdir: $(addprefix $(bindir)/,$(install-bin))
541 install-sbin-nosubdir: $(addprefix $(sbindir)/,$(install-sbin))
542 install-lib-nosubdir: $(addprefix $(libdir)/,\
543 $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
544 $(addprefix $(libprefix),$(install-lib-non.a)))
545 install-data-nosubdir: $(addprefix $(datadir)/,$(install-data))
546 install-headers-nosubdir: $(addprefix $(includedir)/,$(headers))
547 install-others-nosubdir: $(install-others)
549 # We need all the `-nosubdir' targets so that `install' in the parent
550 # doesn't depend on several things which each iterate over the subdirs.
551 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
552 # subroutine. Then in the parent `install-FOO' also causes subdir makes.
553 install-%:: install-%-nosubdir ;
555 .PHONY: install install-no-libc.a-nosubdir
556 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
557 install-bin-nosubdir install-lib-nosubdir \
558 install-others-nosubdir install-sbin-nosubdir
559 install: install-no-libc.a-nosubdir
561 ifeq (yes,$(build-shared))
562 # Pattern rule to build a shared object from an archive of PIC objects.
563 # This must come after the installation rules so Make doesn't try to
564 # build shared libraries in place from the installed *_pic.a files.
565 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
566 # on other shared objects.
567 lib%.so: lib%_pic.a; $(build-shlib)
570 $(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \
571 -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
572 $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
573 -Wl,-rpath-link=$(common-objdir) -Wl,-rpath=$(libdir) \
574 -Wl,--whole-archive $^ $(LDLIBS-$(@F:lib%.so=%).so)
577 # Don't try to use -lc when making libc.so itself.
578 # Also omits crti.o and crtn.o, which we do not want
579 # since we define our own `.init' section specially.
580 LDFLAGS-c.so = -nostdlib -nostartfiles
581 # Give libc.so an entry point and make it directly runnable itself.
582 LDFLAGS-c.so += -e __libc_print_version
583 # Use our own special initializer and finalizer files for libc.so.
584 elfobjdir := $(firstword $(objdir) $(..)elf)
585 $(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
586 $(common-objpfx)libc_pic.a \
587 $(elfobjdir)/sofini.so
590 ifdef libc.so-version
591 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
593 ln -s $(<F) $@ || ln $< $@
598 # Command to compile $< in $(objdir) using the native libraries.
599 define native-compile
600 cwd=`pwd`; cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) \
601 $(addprefix $$cwd/,$^) -o $(@F)
604 # Command to compile $< in $(common-objdir) using the native libraries.
605 define common-objdir-compile
606 cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) $(<:$(common-objpfx)%=%) -o $(@F)
609 # We always want to use configuration definitions.
610 BUILD_CFLAGS = -include $(common-objpfx)config.h
612 # Support the GNU standard name for this target.
617 TAGS: distinfo $(..)MakeTAGS
618 $(MAKE) $(addprefix -f ,$^) $@
625 # Common cleaning targets.
627 .PHONY: common-mostlyclean common-clean mostlyclean clean
629 mostlyclean: common-mostlyclean
631 # Remove the object files.
633 -rm -f $(addprefix $(objpfx),$(tests) $(others) \
634 $(addsuffix .o,$(tests) $(others)) \
635 $(addsuffix .out,$(tests)))
636 -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib))
637 -rm -f core $(objpfx)stub-$(subdir)
640 $(foreach o,$(object-suffixes),
641 -rm -f $(addprefix $(objpfx),stamp$o-$(subdir)) $(objects:.o=$o))
644 # Also remove the dependencies and generated source files.
645 common-clean: common-mostlyclean
646 -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles)
648 # Produce a file `stub-$(subdir)' which contains `#define __stub_FUNCTION'
649 # for each function which is a stub. We grovel over all the .d files
650 # looking for references to source files in sysdeps/stub. Then we grovel
651 # over each referenced source file to see what stub function it defines.
653 .PHONY: stubs # The parent Makefile calls this target.
654 stubs: $(common-objpfx)stub-$(subdir)
655 s = $(sysdep_dir)/stub
656 $(common-objpfx)stub-$(subdir): $(+depfiles)
657 # Use /dev/null since `...` might expand to empty.
658 s=`cd $s; /bin/pwd`; \
659 $(patsubst %,cd %;,$(objdir)) \
660 sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
661 `sed -n 's@^.*$s/\([a-z0-9_-]*\.c\).*$$@'"$$s"/'\1@p' \
662 $(patsubst $(objpfx)%,%,$^) /dev/null` \
666 # Make the distribution tar file.
669 dist: distinfo $(..)Make-dist
670 $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args)
672 # Avoid depending on source files found in sysdeps dirs,
673 # because the references affect implicit rule selection.
674 dist: $(filter-out %.c %.S %.s,$(distribute))
676 # We used to simply export all these variables, but that frequently made the
677 # environment get too large. Instead, we write all the information into
678 # a generated makefile fragment `distinfo', and then include it with -f in
679 # the sub-make that makes the distribution (above).
680 distinfo: Makefile $(..)Makerules
686 $(foreach var,subdir subdir-dirs sources elided-routines headers distribute \
687 dont_distribute generated others tests,
688 echo >> $@.new '$(var) := $($(var))')
689 echo >> $@.new 'sources := $$(sources) $$(addsuffix .c,$$(elided-routines))'
692 ifneq (,$(strip $(gpl2lgpl)))
693 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
694 # Snarf from the master source and frob the copying notice.
695 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
697 # So I don't edit them by mistake.
700 test ! -d CVS || cvs commit -m'Updated from $^' $@