about summary refs log tree commit diff
path: root/Makerules
diff options
context:
space:
mode:
Diffstat (limited to 'Makerules')
-rw-r--r--Makerules130
1 files changed, 65 insertions, 65 deletions
diff --git a/Makerules b/Makerules
index 7f4b5fd16e..84afdd53a9 100644
--- a/Makerules
+++ b/Makerules
@@ -286,6 +286,71 @@ define sed-remove-objpfx
 endef
 endif
 
+# 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) \
+	  -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
+	  -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_main
+# Use our own special initializer and finalizer files for libc.so.
+elfobjdir := $(firstword $(objdir) $(patsubst ../$(subdir),.,$(..)elf))
+$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
+			 $(common-objpfx)libc_pic.a \
+			 $(elfobjdir)/sofini.so $(elfobjdir)/ld.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
+
 # Figure out the source filenames in this directory.
 
 override sources	:= $(addsuffix .c,$(filter-out $(elided-routines),\
@@ -452,71 +517,6 @@ $(AR) cru$(verbose) $(@:$(objpfx)%=%) \
 $(RANLIB) $@
 endef
 
-# 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) \
-	  -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
-	  -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_main
-# Use our own special initializer and finalizer files for libc.so.
-elfobjdir := $(firstword $(objdir) $(patsubst ../$(subdir),.,$(..)elf))
-$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
-			 $(common-objpfx)libc_pic.a \
-			 $(elfobjdir)/sofini.so $(elfobjdir)/ld.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
-
 # Installation.
 
 # $(install-lib) are installed from the object directory into $(libdir);