[klibc] [klibc:master] Build and install shared binaries only if KLIBCSHAREDFLAGS is defined

klibc-bot for Ben Hutchings ben at decadent.org.uk
Sat Jan 19 16:24:02 PST 2019


Commit-ID:  47e429ec6c758b98a00e69df541448942c6f3ba3
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=47e429ec6c758b98a00e69df541448942c6f3ba3
Author:     Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Sat, 19 Jan 2019 22:47:18 +0000
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 19 Jan 2019 22:51:00 +0000

[klibc] Build and install shared binaries only if KLIBCSHAREDFLAGS is defined

The shared library build has never worked on ia64, and Debian has a
longstanding patch that changes the install targets to install static
binaries for ia64.  This can be generalised to checking whether
KLIBCSHAREDFLAGS is defined, as without that we can't expect to build
a working shared library.

* Include the necessary files in scripts/Kbuild.install so that
  KLIBCSHAREDFLAGS is defined at install time.
* Install static binaries instead of shared if KLIBCSHAREDFLAGS is
  not defined.
* Only install the shared library if KLIBCSHAREDFLAGS is defined.
* Only build the shared library and binaries if KLIBCSHAREDFLAGS is
  defined.

Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 scripts/Kbuild.install    |  7 +++++++
 scripts/Kbuild.klibc      |  5 ++++-
 usr/dash/Kbuild           |  4 ++++
 usr/kinit/Kbuild          |  5 ++++-
 usr/kinit/fstype/Kbuild   |  4 ++++
 usr/kinit/ipconfig/Kbuild |  4 ++++
 usr/kinit/nfsmount/Kbuild |  4 ++++
 usr/kinit/resume/Kbuild   |  4 ++++
 usr/kinit/run-init/Kbuild |  4 ++++
 usr/klibc/Kbuild          | 12 ++++++++++--
 usr/utils/Kbuild          | 11 +++++++++--
 11 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
index 32aec84..c2b63f1 100644
--- a/scripts/Kbuild.install
+++ b/scripts/Kbuild.install
@@ -33,8 +33,15 @@ ifeq ($(KLIBC_INSTALL),1)
 # Reset variables (to get right type of assingment)
 subdir- :=
 
+# Read .config if it exist, otherwise ignore
+-include $(objtree)/.config
+
 # Include Kbuild file
 include $(srctree)/scripts/Kbuild.include
+
+# Arch specific definitions for klibc
+include $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG
+
 include $(srctree)/$(obj)/Kbuild
 
 # Directories to visit
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index de1cd27..7a8ad2a 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -304,7 +304,10 @@ ifdef kprogs
 # Compile klibc-programs for the target
 # ===========================================================================
 
-__build : $(kprog-dirs) $(static-y) $(shared-y)
+__build : $(kprog-dirs) $(static-y)
+ifdef KLIBCSHAREDFLAGS
+__build : $(shared-y)
+endif
 
 # Descend if needed
 $(sort $(addsuffix /lib.a,$(kprog-dirs))): $(kprog-dirs) ;
diff --git a/usr/dash/Kbuild b/usr/dash/Kbuild
index 3a98c1f..8682c0d 100644
--- a/usr/dash/Kbuild
+++ b/usr/dash/Kbuild
@@ -93,4 +93,8 @@ $(obj)/syntax.h: $(obj)/syntax.c
 	$(Q):
 
 # Targets to install
+ifdef KLIBCSHAREDFLAGS
 install-y := sh.shared
+else
+install-y := sh
+endif
diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild
index 5320127..84a636a 100644
--- a/usr/kinit/Kbuild
+++ b/usr/kinit/Kbuild
@@ -34,4 +34,7 @@ subdir- := fstype ipconfig nfsmount resume run-init
 
 
 # install binary
-install-y := kinit kinit.shared
+install-y := kinit
+ifdef KLIBCSHAREDFLAGS
+install-y += kinit.shared
+endif
diff --git a/usr/kinit/fstype/Kbuild b/usr/kinit/fstype/Kbuild
index 9b20db1..631eb32 100644
--- a/usr/kinit/fstype/Kbuild
+++ b/usr/kinit/fstype/Kbuild
@@ -22,4 +22,8 @@ shared/fstype-y := $(objs)
 clean-dirs := static shared
 
 # install binary
+ifdef KLIBCSHAREDFLAGS
 install-y := $(shared-y)
+else
+install-y := $(static-y)
+endif
diff --git a/usr/kinit/ipconfig/Kbuild b/usr/kinit/ipconfig/Kbuild
index 7f8d181..686b03b 100644
--- a/usr/kinit/ipconfig/Kbuild
+++ b/usr/kinit/ipconfig/Kbuild
@@ -28,4 +28,8 @@ shared/ipconfig-y := $(objs)
 clean-dirs := static shared
 
 # install binary
+ifdef KLIBCSHAREDFLAGS
 install-y := $(shared-y)
+else
+install-y := $(static-y)
+endif
diff --git a/usr/kinit/nfsmount/Kbuild b/usr/kinit/nfsmount/Kbuild
index 461e6f3..5f34950 100644
--- a/usr/kinit/nfsmount/Kbuild
+++ b/usr/kinit/nfsmount/Kbuild
@@ -24,4 +24,8 @@ dummypmap-y := dummypmap_test.o
 clean-dirs := static shared
 
 # Install binary
+ifdef KLIBCSHAREDFLAGS
 install-y := $(shared-y)
+else
+install-y := $(static-y)
+endif
diff --git a/usr/kinit/resume/Kbuild b/usr/kinit/resume/Kbuild
index 034195d..c804a85 100644
--- a/usr/kinit/resume/Kbuild
+++ b/usr/kinit/resume/Kbuild
@@ -27,4 +27,8 @@ shared/resume-lib := ../lib.a
 clean-dirs := static shared
 
 # install binary
+ifdef KLIBCSHAREDFLAGS
 install-y := $(shared-y)
+else
+install-y := $(static-y)
+endif
diff --git a/usr/kinit/run-init/Kbuild b/usr/kinit/run-init/Kbuild
index f7832b7..eeff906 100644
--- a/usr/kinit/run-init/Kbuild
+++ b/usr/kinit/run-init/Kbuild
@@ -31,4 +31,8 @@ shared/run-init-lib := ../lib.a
 clean-dirs := static shared
 
 # install binary
+ifdef KLIBCSHAREDFLAGS
 install-y := $(shared-y)
+else
+install-y := $(static-y)
+endif
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index b19f3ab..9efbb4e 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -91,7 +91,10 @@ SOHASH   := klibc.so
 CRT0     := arch/$(KLIBCARCHDIR)/crt0.o
 INTERP_O := interp.o
 
-always   := $(LIBC) $(SOLIB) $(SOHASH) $(INTERP_O)
+always   := $(LIBC)
+ifdef KLIBCSHAREDFLAGS
+always   += $(SOLIB) $(SOHASH) $(INTERP_O)
+endif
 LIBC     := $(call objectify,$(LIBC))
 SOLIB    := $(call objectify,$(SOLIB))
 SOHASH   := $(call objectify,$(SOHASH))
@@ -181,10 +184,15 @@ $(INTERP_O): $(obj)/interp.S $(SOLIB).hash
 # Install klibc
 install-rule:
 	@echo "  INSTALL klibc to $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib"
-	$(Q)$(foreach f, $(LIBC) $(SOLIB) $(CRT0) $(INTERP_O), \
+	$(Q)$(foreach f, $(LIBC) $(CRT0), \
+	  $(shell $(install-data) $(f) \
+	          $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib))
+ifdef KLIBCSHAREDFLAGS
+	$(Q)$(foreach f, $(SOLIB) $(INTERP_O), \
 	  $(shell $(install-data) $(f) \
 	          $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib))
 	$(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
 	                      $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib
 	$(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
 	                      $(INSTALLROOT)$(SHLIBDIR)
+endif
diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild
index 05aa794..38abb8f 100644
--- a/usr/utils/Kbuild
+++ b/usr/utils/Kbuild
@@ -62,7 +62,10 @@ static/losetup-y    := losetup.o
 shared/losetup-y    := losetup.o
 
 # Additionally linked targets
-always := static/reboot static/poweroff shared/reboot shared/poweroff
+always := static/reboot static/poweroff
+ifdef KLIBCSHAREDFLAGS
+always += shared/reboot shared/poweroff
+endif
 
 $(obj)/static/reboot $(obj)/static/poweroff: $(obj)/static/halt
 	$(call cmd,ln)
@@ -72,5 +75,9 @@ $(obj)/shared/reboot $(obj)/shared/poweroff: $(obj)/shared/halt
 # Clean deletes the static and shared dir
 clean-dirs := static shared
 
-# install only install the shared binaries
+# install the shared binaries by preference
+ifdef KLIBCSHAREDFLAGS
 install-y := $(shared-y) shared/reboot shared/poweroff
+else
+install-y := $(static-y) static/reboot static/poweroff
+endif


More information about the klibc mailing list