-# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# Add -I switches to get the right sysdep directories.
# `+includes' in Makeconfig references $(+sysdep-includes).
+sysdep-includes := $(addprefix -I,$(+sysdep_dirs))
+
+# The name of the symbol table archive member. The default is suitable for
+# BSD style archives. It can be overridden in sysdep Makefiles when SYSV
+# style archive are used.
+ifeq (no,$(elf))
+ar-symtab-name = __.SYMDEF
+else
+ar-symtab-name = # The null name is used in ELF archives.
+endif
\f
# Include any system-specific makefiles.
in-Makerules := yes
ifndef avoid-generated
-include $(+sysdir_pfx)sysd-Makefile
+-include $(+sysdir_pfx)sysd-Makefile
ifneq ($(sysd-Makefile-sysdirs),$(sysdirs))
sysd-Makefile-force = FORCE
FORCE:
# included. It might define inhibit-sysdep-asm, which would affect the
# contents of sysd-rules.
ifdef sysd-Makefile-done
-include $(+sysdir_pfx)sysd-rules
+-include $(+sysdir_pfx)sysd-rules
ifneq ($(sysd-rules-sysdirs),$(sysdirs))
# The value of $(sysdirs) the sysd-rules was computed for
# differs from the one we are using now. So force a rebuild of sysd-rules.
endif
# GCC can grok options after the file name, and it looks nicer that way.
-compile.S = $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
+compile.S = $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
+COMPILE.S = $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS)
+COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
# We need this for the output to go in the right place. It will default to
# empty if make was configured to work with a cc that can't grok -c and -o
define +make-deps
-@rm -f $@
$(+mkdep) $< $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
-sed -e 's,$*\.o,$(foreach o,$(object-suffixes),$(@:.d=$o)) $@,' \
+sed -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(object-suffixes),$(@:.d=$o)) $@,' \
$(sed-remove-objpfx) > $(@:.d=.T)
mv -f $(@:.d=.T) $@
endef
ifneq (,$(objpfx))
-sed-remove-objpfx = -e 's@ $(subst @,\@,$(objpfx))@ $$(objpfx)@g' \
- -e 's@^$(subst @,\@,$(objpfx))@$$(objpfx)@g'
+sed-remove-objpfx = -e 's@ $(subst .,\., \
+ $(subst @,\@,$(objpfx)))@ $$(objpfx)@g' \
+ -e 's@^$(subst .,\.,$(subst @,\@,$(objpfx)))@$$(objpfx)@g'
endif
\f
# Figure out the source filenames in this directory.
ifdef +depfiles
ifneq ($(no_deps),t)
-include $(+depfiles)
+-include $(+depfiles)
endif
endif
\f\f
lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
# Pattern rule for libraries: depend on the __.SYMDEF member updated by ranlib.
-lib%.a: lib%.a(__.SYMDEF) ;
+lib%.a: lib%.a($(ar-symtab-name)) ;
libobjs: $(foreach o,$(object-suffixes),\
$(common-objpfx)$(patsubst %,$(libtype$o),c)(\
endif
-# Rules to update the __.SYMDEF member with ranlib.
-# To consolidate, each flavor library's __.SYMDEF member
-# depends on the imaginary intermediate file `symdef.SUFFIX',
-# where SUFFIX is that flavor's object suffix; then a pattern rule
-# "remakes" symdef.% depending on all the libc.a(foo.%) files in $(objects).
-$(common-objpfx)$(patsubst %,$(libtype.o),c)(__.SYMDEF): symdef.o
-$(common-objpfx)$(patsubst %,$(libtype.so),c)(__.SYMDEF): symdef.so
-$(common-objpfx)$(patsubst %,$(libtype.po),c)(__.SYMDEF): symdef.po
-$(common-objpfx)$(patsubst %,$(libtype.go),c)(__.SYMDEF): symdef.go
-symdef.%: $(foreach o,$(object-suffixes),\
- $(common-objpfx)$(patsubst %,$(libtype$o),c)(\
- $(patsubst $(objpfx)%.o,%.%,$(objects)))) \
- $(filter subdir_lib,$(firstword $(subdir) subdir_lib))
-# The last line above makes it also depend on subdir_lib for the parent.
- $(RANLIB) $(common-objpfx)$(patsubst %,$(libtype.$*),c)
+# Rules to update the $(ar-symtab-name) member with ranlib,
+# one for each object flavor.
+define o-iterator-doit
+$(common-objpfx)$(patsubst %,$(libtype$o),c)($(ar-symtab-name)): \
+ $(common-objpfx)$(patsubst %,$(libtype$o),c)(\
+ $(patsubst $(objpfx)%.o,%$o,$(objects))) \
+ $(filter subdir_lib,$(firstword $(subdir) subdir_lib)); \
+ $$(RANLIB) $$(common-objpfx)$$(patsubst %,$$(libtype$o),c)
+endef
+object-suffixes-left = $(object-suffixes)
+include $(o-iterator)
+
# This makes all the object files.
.PHONY: objects objs
$(RANLIB) $@
endef
\f
+# Shared library building.
+
+ifeq (yes,$(build-shared))
+
+# Process the shlib-versions file, which tells us what shared library
+# version numbers to use when we install shared objects on this system.
+-include $(common-objpfx)soversions.mk
+$(common-objpfx)soversions.mk: $(..)shlib-versions $(..)Makerules \
+ $(common-objpfx)config.make
+ sed 's/#.*$$//' $< | while read conf versions; do \
+ test -n "$$versions" || continue; \
+ case '$(config-machine)-$(config-vendor)-$(config-os)' in $$conf)\
+ for v in $$versions; do \
+ lib="$${v%%=*}"; if eval "test -z \"\$$vers_lib$$lib\""; then \
+ eval vers_lib$${lib}=yes; \
+ echo $$lib.so-version=.$${v##$$lib=}; fi; \
+ done ;; esac; done > $@T
+ mv -f $@T $@
+
+# Get $(version) defined with the release version number.
+-include $(common-objpfx)version.mk
+
+
+# Pattern rule to build a shared object from an archive of PIC objects.
+# This must come after the installation rules so Make doesn't try to
+# build shared libraries in place from the installed *_pic.a files.
+# $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
+# on other shared objects.
+lib%.so: lib%_pic.a; $(build-shlib)
+
+ifeq ($(have-no-whole-archive),yes)
+no-whole-archive = -Wl,--no-whole-archive
+else
+no-whole-archive =
+endif
+
+define build-shlib
+$(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \
+ -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
+ $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
+ -Wl,-rpath-link=$(common-objdir) \
+ -Wl,--whole-archive $^ $(no-whole-archive) \
+ $(LDLIBS-$(@F:lib%.so=%).so)
+endef
+
+# Don't try to use -lc when making libc.so itself.
+# Also omits crti.o and crtn.o, which we do not want
+# since we define our own `.init' section specially.
+LDFLAGS-c.so = -nostdlib -nostartfiles
+# Give libc.so an entry point and make it directly runnable itself.
+LDFLAGS-c.so += -e __libc_print_version
+# Use our own special initializer and finalizer files for libc.so.
+elfobjdir := $(firstword $(objdir) $(..)elf)
+$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
+ $(common-objpfx)libc_pic.a \
+ $(elfobjdir)/sofini.so
+ $(build-shlib)
+
+ifdef libc.so-version
+$(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
+ rm -f $@
+ ln -s $(<F) $@ || ln $< $@
+endif
+endif
+\f
# Installation.
# $(install-lib) are installed from the object directory into $(libdir);
$(INSTALL_DATA) $< $@
endef
-# Make the target directory if it doesn't exist. Because of make's
-# directory cache, this will produce the `mkdir' command when the directory
-# already exists, if it didn't exist at the start of the `make' run. The
-# `-' prefix ignores errors from mkdir, so there will just be some
-# gratuitous but harmless `File exists' messages.
+# Make the target directory if it doesn't exist, using the `mkinstalldirs'
+# script that does `mkdir -p' even if `mkdir' doesn't support that flag.
define make-target-directory
-$(addprefix -mkdir ,$(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
+$(addprefix $(..)mkinstalldirs ,\
+ $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
endef
# Any directory (parent or subdir) that has any object files to build
installed-libcs := $(foreach o,$(object-suffixes),\
$(libdir)/$(patsubst %,$(libtype$o),\
$(libprefix)$(libc-name)))
+installed-libcs := $(filter-out %_pic.a,$(installed-libcs))
install: $(installed-libcs)
$(installed-libcs): $(libdir)/lib$(libprefix)%: lib
$(make-target-directory)
install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
install-lib := $(filter-out %.so %_pic.a,$(install-lib))
ifeq (yes,$(build-shared))
-install-lib-nosubdir: $(foreach so,$(install-lib.so),\
- $(libdir)/$(patsubst $(libprefix)lib%,lib$(libprefix)%,\
- $(libprefix)$(so))$($(so)-version))
-install: $(slibdir)/libc.so$(libc.so-version)
-$(slibdir)/lib$(libprefix)c.so$(libc.so-version): $(common-objpfx)libc.so
- $(do-install-program)
+install-lib-nosubdir: $(install-lib.so:%=$(libdir)/%)
+
+# Find which .so's have versions.
+versioned := $(strip $(foreach so,$(install-lib.so),\
+ $(patsubst %,$(so),$($(so)-version))))
+
+# Install all the unversioned shared libraries.
+$(addprefix $(libdir)/,$(filter-out $(versioned),$(install-lib.so))): \
+$(libdir)/%.so: $(objpfx)%.so; $(do-install-program)
+
+make-link = cd $(@D); rm -f $(@F); $(LN_S) $(<F) $(@F)
+
+ifdef libc.so-version
+# For a library specified to be version N, install three files:
+# libc.so -> libc.so.N (e.g. libc.so.6)
+# libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
+
+$(slibdir)/libc.so$(libc.so-version): $(slibdir)/libc-$(version).so
+ $(make-link)
+$(slibdir)/libc-$(version).so: $(common-objpfx)libc.so; $(do-install-program)
+
+# What we install as libc.so for programs to link against is in fact an
+# archive. It contains the various $(static-only-routines) objects, and
+# the special object libc-syms.so that contains just the dynamic symbol
+# table of the shared libc object.
+install: $(libdir)/libc.so
+$(libdir)/libc.so: $(common-objpfx)libc-syms.so subdir_install
+ $(AR) crvs $@ $< `cat $(addprefix $(common-objpfx)sor-,$(subdirs))`
-$(foreach v,$(sort $(foreach so,$(install-lib.so),.so$($(so)-version))),\
+# Extract from the shared object file just the dynamic symbol table
+# needed to link against the shared library.
+$(common-objpfx)libc-syms.so: $(common-objpfx)libc.so
+ AWK='$(AWK)' OBJCOPY='$(OBJCOPY)' OBJDUMP='$(OBJDUMP)' \
+ ./extract-dynsym $< $@
+ifndef subdir
+generated += libc-syms.so
+endif
+
+else
+install: $(slibdir)/libc.so
+$(slibdir)/libc.so: $(common-objpfx)libc.so; $(do-install-program)
+endif
+
+
+ifneq (,$(versioned))
+# Produce three sets of rules as above for all the smaller versioned libraries.
+
+define o-iterator-doit
+$(libdir)/$o: $(libdir)/$o$($o-version); $$(make-link)
+endef
+object-suffixes-left := $(versioned)
+include $(..)o-iterator.mk
+
+define o-iterator-doit
+$(libdir)/$o$($o-version): $(libdir)/$(o:.so=)-$(version).so; $$(make-link)
+endef
+object-suffixes-left := $(versioned)
+include $(..)o-iterator.mk
+
+define o-iterator-doit
+$(libdir)/$(o:.so=)-$(version).so: $(objpfx)$o; $$(do-install-program)
+endef
+object-suffixes-left := $(versioned)
+include $(..)o-iterator.mk
+endif
+
+define do-install-so
+$(do-install-program)
+$(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
+ $(filter-out %.so,$@))
+endef
+
+so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
+$(foreach v,$(so-versions),\
$(libdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so
- $(do-install-program)
-$(foreach v,$(sort $(foreach so,$(install-lib.so),.so$($(so)-version))),\
+ $(do-install-so)
+$(foreach v,$(so-versions),\
$(libdir)/$(libprefix)%$v): $(common-objpfx)%.so
- $(do-install-program)
+ $(do-install-so)
endif
ifdef install-bin
install-lib-non.a := $(filter-out lib%.a,$(install-lib))
ifdef install-lib-non.a
$(addprefix $(libdir)/$(libprefix),$(install-lib-non.a)): \
- $(libdir)/$(libprefix)%: $(objpfx)%
+ $(libdir)/$(libprefix)%: $(common-objpfx)%
$(do-install)
endif
ifdef install-lib.a
$(install-lib.a:lib%.a=$(libdir)/lib$(libprefix)%.a): \
- $(libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a
+ $(libdir)/lib$(libprefix)%.a: $(common-objpfx)lib%.a
$(do-install)
$(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F)))
endif
install-others-nosubdir install-sbin-nosubdir
install: install-no-libc.a-nosubdir
\f
-ifeq (yes,$(build-shared))
-# Pattern rule to build a shared object from an archive of PIC objects.
-# This must come after the installation rules so Make doesn't try to
-# build shared libraries in place from the installed *_pic.a files.
-# $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
-# on other shared objects.
-lib%.so: lib%_pic.a; $(build-shlib)
-
-define build-shlib
-$(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \
- -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
- $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
- -Wl,-rpath-link=$(common-objdir) -Wl,-rpath=$(libdir) \
- -Wl,--whole-archive $^ $(LDLIBS-$(@F:lib%.so=%).so)
-endef
-
-# Don't try to use -lc when making libc.so itself.
-# Also omits crti.o and crtn.o, which we do not want
-# since we define our own `.init' section specially.
-LDFLAGS-c.so = -nostdlib -nostartfiles
-# Give libc.so an entry point and make it directly runnable itself.
-LDFLAGS-c.so += -e __libc_print_version
-# Use our own special initializer and finalizer files for libc.so.
-elfobjdir := $(firstword $(objdir) $(..)elf)
-$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
- $(common-objpfx)libc_pic.a \
- $(elfobjdir)/sofini.so
- $(build-shlib)
-endif
-
-
# Command to compile $< in $(objdir) using the native libraries.
define native-compile
cwd=`pwd`; cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) \
endef
# We always want to use configuration definitions.
-BUILD_CFLAGS = -include $(common-objpfx)config.h
+ifdef objdir
+# This is always used in $(common-objdir), so we use no directory name.
+BUILD_CFLAGS = -include config.h
+else
+BUILD_CFLAGS = -include $(..)config.h
+endif
# Support the GNU standard name for this target.
.PHONY: check
\f
.PHONY: TAGS
TAGS: distinfo $(..)MakeTAGS
- $(MAKE) $(addprefix -f ,$^)
+ $(MAKE) $(addprefix -f ,$^) $@
+
+$(..)po/%.pot: distinfo $(..)MakeTAGS FORCE
+ $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@
+FORCE:
+
.PHONY: echo-headers
echo-headers:
sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
`sed -n 's@^.*$s/\([a-z0-9_-]*\.c\).*$$@'"$$s"/'\1@p' \
$(patsubst $(objpfx)%,%,$^) /dev/null` \
- /dev/null > $@T
+ /dev/null > $(@F)T
mv -f $@T $@
\f
# Make the distribution tar file.
define distinfo-vars
rm -f $@.new
-$(foreach var,subdir sources elided-routines headers distribute \
+$(foreach var,subdir subdir-dirs sources elided-routines headers distribute \
dont_distribute generated others tests,
echo >> $@.new '$(var) := $($(var))')
echo >> $@.new 'sources := $$(sources) $$(addsuffix .c,$$(elided-routines))'