aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2019-01-19 22:47:18 +0000
committerBen Hutchings <ben@decadent.org.uk>2019-01-19 22:51:00 +0000
commit47e429ec6c758b98a00e69df541448942c6f3ba3 (patch)
tree9a5b8e7e9982c226dfa8c7de2542f59eaf956069
parent95e6ed27e01232cd7ef14602a24219b5f605a1d2 (diff)
downloadklibc-47e429ec6c758b98a00e69df541448942c6f3ba3.tar.gz
[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@decadent.org.uk>
-rw-r--r--scripts/Kbuild.install7
-rw-r--r--scripts/Kbuild.klibc5
-rw-r--r--usr/dash/Kbuild4
-rw-r--r--usr/kinit/Kbuild5
-rw-r--r--usr/kinit/fstype/Kbuild4
-rw-r--r--usr/kinit/ipconfig/Kbuild4
-rw-r--r--usr/kinit/nfsmount/Kbuild4
-rw-r--r--usr/kinit/resume/Kbuild4
-rw-r--r--usr/kinit/run-init/Kbuild4
-rw-r--r--usr/klibc/Kbuild12
-rw-r--r--usr/utils/Kbuild11
11 files changed, 58 insertions, 6 deletions
diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
index 32aec84a1a8c7..c2b63f10b7e7c 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 de1cd278e9f81..7a8ad2ac0f600 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 3a98c1f5ba3d0..8682c0d79f793 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 53201279b1617..84a636a10af02 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 9b20db1625b48..631eb32698f39 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 7f8d1813cdfa1..686b03b770dcd 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 461e6f378b753..5f349500bf2db 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 034195d2ad2a9..c804a8508bb0b 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 f7832b7d0bee6..eeff906264102 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 b19f3ab11d19d..9efbb4e788684 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 05aa794f481d3..38abb8fe5f554 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