From f7e56763e12bdff2261929bbcb691e770341d043 Mon Sep 17 00:00:00 2001
From: Jo-Philipp Wich <jow@openwrt.org>
Date: Fri, 6 Feb 2015 00:00:43 +0000
Subject: [PATCH] tools: remove static linking support

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>

SVN-Revision: 44285
---
 tools/bison/Makefile             | 2 --
 tools/ccache/Makefile            | 1 -
 tools/dosfstools/Makefile        | 2 +-
 tools/e2fsprogs/Makefile         | 1 -
 tools/elftosb/Makefile           | 2 +-
 tools/firmware-utils/Makefile    | 2 +-
 tools/flex/Makefile              | 1 -
 tools/flock/Makefile             | 2 +-
 tools/genext2fs/Makefile         | 2 +-
 tools/lzma/Makefile              | 4 ++--
 tools/m4/Makefile                | 2 --
 tools/mkimage/Makefile           | 4 +---
 tools/mklibs/Makefile            | 1 -
 tools/mtd-utils/Makefile         | 2 +-
 tools/mtools/Makefile            | 2 --
 tools/padjffs2/Makefile          | 2 +-
 tools/patch-image/Makefile       | 4 ++--
 tools/pkg-config/Makefile        | 4 +---
 tools/qemu/Makefile              | 1 -
 tools/sed/Makefile               | 2 +-
 tools/squashfs/Makefile          | 2 +-
 tools/squashfs4/Makefile         | 1 -
 tools/sstrip/Makefile            | 2 +-
 tools/upslug2/Makefile           | 1 -
 tools/upx/Makefile               | 2 +-
 tools/wrt350nv2-builder/Makefile | 2 +-
 tools/xz/Makefile                | 5 +----
 tools/yaffs2/Makefile            | 2 +-
 28 files changed, 20 insertions(+), 40 deletions(-)

diff --git a/tools/bison/Makefile b/tools/bison/Makefile
index bf7b92b2c1..10d8720484 100644
--- a/tools/bison/Makefile
+++ b/tools/bison/Makefile
@@ -18,8 +18,6 @@ HOST_BUILD_PARALLEL:=1
 
 include $(INCLUDE_DIR)/host-build.mk
 
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
-
 define Host/Clean
 	-$(MAKE) -C $(HOST_BUILD_DIR) uninstall
 	$(call Host/Clean/Default)
diff --git a/tools/ccache/Makefile b/tools/ccache/Makefile
index aeac393051..d91bee19ef 100644
--- a/tools/ccache/Makefile
+++ b/tools/ccache/Makefile
@@ -16,7 +16,6 @@ PKG_MD5SUM:=522a6016bda56892653612bbdefff3e0
 
 include $(INCLUDE_DIR)/host-build.mk
 
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
 HOST_CONFIGURE_VARS += CC="$(HOSTCC_NOCACHE)"
 
 define Host/Install/ccache
diff --git a/tools/dosfstools/Makefile b/tools/dosfstools/Makefile
index f91d1b1015..ca4f284aa6 100644
--- a/tools/dosfstools/Makefile
+++ b/tools/dosfstools/Makefile
@@ -16,7 +16,7 @@ PKG_MD5SUM:=45012f5f56f2aae3afcd62120b9e5a08
 include $(INCLUDE_DIR)/host-build.mk
 
 define Host/Compile
-	$(MAKE) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)"
+	$(MAKE) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" LDFLAGS="$(HOST_LDFLAGS)"
 endef
 
 define Host/Install
diff --git a/tools/e2fsprogs/Makefile b/tools/e2fsprogs/Makefile
index 60047c763a..5632e1949d 100644
--- a/tools/e2fsprogs/Makefile
+++ b/tools/e2fsprogs/Makefile
@@ -20,7 +20,6 @@ HOST_BUILD_PARALLEL:=1
 include $(INCLUDE_DIR)/host-build.mk
 
 HOST_CFLAGS += $(FPIC)
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
 
 HOST_CONFIGURE_ARGS += \
 	--disable-shared \
diff --git a/tools/elftosb/Makefile b/tools/elftosb/Makefile
index 6f9b963975..5adafef736 100644
--- a/tools/elftosb/Makefile
+++ b/tools/elftosb/Makefile
@@ -16,7 +16,7 @@ PKG_MD5SUM:=e8005d606c1e0bb3507c82f6eceb3056
 include $(INCLUDE_DIR)/host-build.mk
 
 define Host/Compile
-	$(MAKE) -C $(HOST_BUILD_DIR) LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)"
+	$(MAKE) -C $(HOST_BUILD_DIR) LDFLAGS="$(HOST_LDFLAGS)"
 endef
 
 define Host/Install
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index 83c51d7d90..c18024a302 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 define cc
-	$(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_STATIC_LINKING) $(HOST_LDFLAGS) -o $(HOST_BUILD_DIR)/bin/$(firstword $(1)) $(foreach src,$(1),src/$(src).c) $(2)
+	$(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_LDFLAGS) -o $(HOST_BUILD_DIR)/bin/$(firstword $(1)) $(foreach src,$(1),src/$(src).c) $(2)
 endef
 
 define Host/Compile
diff --git a/tools/flex/Makefile b/tools/flex/Makefile
index 90082df43e..0e56edea50 100644
--- a/tools/flex/Makefile
+++ b/tools/flex/Makefile
@@ -19,7 +19,6 @@ HOST_BUILD_PARALLEL:=1
 include $(INCLUDE_DIR)/host-build.mk
 
 HOST_CONFIGURE_ARGS += --disable-shared
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
 
 define Host/Clean
 	-$(MAKE) -C $(HOST_BUILD_DIR) uninstall
diff --git a/tools/flock/Makefile b/tools/flock/Makefile
index f5e13cd911..a6a4758f05 100644
--- a/tools/flock/Makefile
+++ b/tools/flock/Makefile
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/host-build.mk
 
 define Host/Compile
 	mkdir -p $(HOST_BUILD_DIR)
-	$(HOSTCC) $(HOST_CFLAGS) $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/flock src/flock.c
+	$(HOSTCC) $(HOST_CFLAGS) -o $(HOST_BUILD_DIR)/flock src/flock.c
 endef
 
 define Host/Install
diff --git a/tools/genext2fs/Makefile b/tools/genext2fs/Makefile
index 57e8d35b51..ad941c71ac 100644
--- a/tools/genext2fs/Makefile
+++ b/tools/genext2fs/Makefile
@@ -36,7 +36,7 @@ HOST_CONFIGURE_ARGS = \
 define Host/Compile
 	$(MAKE) -C $(HOST_BUILD_DIR) \
 		CFLAGS="$(HOST_CFLAGS)" \
-		LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)" \
+		LDFLAGS="$(HOST_LDFLAGS)" \
 		all
 endef
 
diff --git a/tools/lzma/Makefile b/tools/lzma/Makefile
index 6e01051a3a..4922f8087f 100644
--- a/tools/lzma/Makefile
+++ b/tools/lzma/Makefile
@@ -21,8 +21,8 @@ UTIL_DIR=$(HOST_BUILD_DIR)/C/LzmaUtil
 ALONE_DIR=$(HOST_BUILD_DIR)/CPP/7zip/Compress/LZMA_Alone
 
 define Host/Compile
-	$(MAKE) -C $(UTIL_DIR) -f makefile.gcc LDFLAGS="$(HOST_STATIC_LINKING)"
-	$(MAKE) -C $(ALONE_DIR) -f makefile.gcc LDFLAGS="$(HOST_STATIC_LINKING)"
+	$(MAKE) -C $(UTIL_DIR) -f makefile.gcc
+	$(MAKE) -C $(ALONE_DIR) -f makefile.gcc
 endef
 
 define Host/Install
diff --git a/tools/m4/Makefile b/tools/m4/Makefile
index 71498b490a..47c332123b 100644
--- a/tools/m4/Makefile
+++ b/tools/m4/Makefile
@@ -20,8 +20,6 @@ include $(INCLUDE_DIR)/host-build.mk
 
 HOST_CONFIGURE_VARS += gl_cv_func_strstr_linear=no
 
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
-
 define Host/Clean
 	-$(MAKE) -C $(HOST_BUILD_DIR) uninstall
 	$(call Host/Clean/Default)
diff --git a/tools/mkimage/Makefile b/tools/mkimage/Makefile
index 2de13ab77b..a65eedfcc6 100644
--- a/tools/mkimage/Makefile
+++ b/tools/mkimage/Makefile
@@ -32,9 +32,7 @@ endef
 
 define Host/Compile
 	$(MAKE) -C $(HOST_BUILD_DIR) defconfig
-	$(MAKE) -C $(HOST_BUILD_DIR) \
-		HOSTLDFLAGS="$(HOST_STATIC_LINKING)" \
-		tools-only
+	$(MAKE) -C $(HOST_BUILD_DIR) tools-only
 endef
 
 define Host/Install
diff --git a/tools/mklibs/Makefile b/tools/mklibs/Makefile
index fa0bce70d9..6bf1431b8c 100644
--- a/tools/mklibs/Makefile
+++ b/tools/mklibs/Makefile
@@ -18,7 +18,6 @@ HOST_FIXUP:=autoreconf
 include $(INCLUDE_DIR)/host-build.mk
 
 HOST_CFLAGS += -I$(CURDIR)/include
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
 
 define Host/Install
        $(INSTALL_BIN) \
diff --git a/tools/mtd-utils/Makefile b/tools/mtd-utils/Makefile
index cc857d9e00..aa0919a7b9 100644
--- a/tools/mtd-utils/Makefile
+++ b/tools/mtd-utils/Makefile
@@ -29,7 +29,7 @@ endif
 
 MTD_MAKEOPTS = \
 	CFLAGS="$(CFLAGS)" \
-	LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)" \
+	LDFLAGS="$(HOST_LDFLAGS)" \
 	WITHOUT_LZO=1 WITHOUT_XATTR=1 \
 	LZMA_STATIC_LIB="$(STAGING_DIR_HOST)/lib/liblzma.a" \
 	SUBDIRS="" \
diff --git a/tools/mtools/Makefile b/tools/mtools/Makefile
index 3bbc1a41a7..674c8dd2cc 100644
--- a/tools/mtools/Makefile
+++ b/tools/mtools/Makefile
@@ -21,8 +21,6 @@ include $(INCLUDE_DIR)/host-build.mk
 HOST_CONFIGURE_VARS += \
 	ac_cv_header_iconv_h=no
 
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
-
 define Host/Compile
 	$(MAKE) -C $(HOST_BUILD_DIR) mcopy
 endef
diff --git a/tools/padjffs2/Makefile b/tools/padjffs2/Makefile
index 4535735d69..0a583b8e1a 100644
--- a/tools/padjffs2/Makefile
+++ b/tools/padjffs2/Makefile
@@ -19,7 +19,7 @@ define Host/Prepare
 endef
 
 define Host/Compile
-	$(MAKE) -C $(HOST_BUILD_DIR) LDFLAGS="$(HOST_STATIC_LINKING)"
+	$(MAKE) -C $(HOST_BUILD_DIR)
 endef
 
 define Host/Configure
diff --git a/tools/patch-image/Makefile b/tools/patch-image/Makefile
index cd2df5c8af..6f2900b96c 100644
--- a/tools/patch-image/Makefile
+++ b/tools/patch-image/Makefile
@@ -11,8 +11,8 @@ PKG_NAME:=patch-image
 include $(INCLUDE_DIR)/host-build.mk
 
 define Host/Compile
-	$(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/patch-cmdline src/patch-cmdline.c
-	$(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/patch-dtb src/patch-dtb.c
+	$(HOSTCC) $(HOST_CFLAGS) -include endian.h -o $(HOST_BUILD_DIR)/patch-cmdline src/patch-cmdline.c
+	$(HOSTCC) $(HOST_CFLAGS) -include endian.h -o $(HOST_BUILD_DIR)/patch-dtb src/patch-dtb.c
 endef
 
 define Host/Install
diff --git a/tools/pkg-config/Makefile b/tools/pkg-config/Makefile
index 0edc807e9d..9a1b3fb986 100644
--- a/tools/pkg-config/Makefile
+++ b/tools/pkg-config/Makefile
@@ -17,14 +17,12 @@ HOST_BUILD_PARALLEL:=1
 
 include $(INCLUDE_DIR)/host-build.mk
 
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
 unexport PKG_CONFIG
 
 HOST_CONFIGURE_ARGS += --with-internal-glib
 
 define Host/Install
-	$(MAKE) -C $(HOST_BUILD_DIR) install \
-		AM_LDFLAGS="$(if $(HOST_STATIC_LINKING),-all-static)"
+	$(MAKE) -C $(HOST_BUILD_DIR) install
 	mv $(STAGING_DIR_HOST)/bin/pkg-config $(STAGING_DIR_HOST)/bin/pkg-config.real
 	$(INSTALL_BIN) ./files/pkg-config $(STAGING_DIR_HOST)/bin/pkg-config
 endef
diff --git a/tools/qemu/Makefile b/tools/qemu/Makefile
index 34440ee853..bffbaa45e7 100644
--- a/tools/qemu/Makefile
+++ b/tools/qemu/Makefile
@@ -17,7 +17,6 @@ PKG_MD5SUM:=b6c713a8db638e173af53a62d5178640
 include $(INCLUDE_DIR)/host-build.mk
 
 HOST_CFLAGS += -I$(STAGING_DIR_HOST)/include/e2fsprogs
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
 
 define Host/Configure
 	(cd $(HOST_BUILD_DIR); \
diff --git a/tools/sed/Makefile b/tools/sed/Makefile
index 27169540b8..0e130e249a 100644
--- a/tools/sed/Makefile
+++ b/tools/sed/Makefile
@@ -29,7 +29,7 @@ HOST_CONFIGURE_VARS += \
 	ac_cv_header_selinux_selinux_h=no \
 
 define Host/Compile
-	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" LDFLAGS="$(HOST_STATIC_LINKING)"
+	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) SHELL="$(BASH)"
 endef
 
 define Host/Install
diff --git a/tools/squashfs/Makefile b/tools/squashfs/Makefile
index 6dc27d6750..88416bd95d 100644
--- a/tools/squashfs/Makefile
+++ b/tools/squashfs/Makefile
@@ -21,7 +21,7 @@ include $(INCLUDE_DIR)/host-build.mk
 define Host/Compile
 	$(MAKE) -C $(HOST_BUILD_DIR)/squashfs-tools \
 		CC="$(HOSTCC)" \
-		CXX="$(CXX) $(HOST_STATIC_LINKING)" \
+		CXX="$(CXX)" \
 		LZMAPATH=$(STAGING_DIR_HOST)/lib \
 		mksquashfs-lzma unsquashfs-lzma 
 endef
diff --git a/tools/squashfs4/Makefile b/tools/squashfs4/Makefile
index b838b46c55..50b70fbe1c 100644
--- a/tools/squashfs4/Makefile
+++ b/tools/squashfs4/Makefile
@@ -26,7 +26,6 @@ define Host/Compile
 		XATTR_SUPPORT= \
 		LZMA_LIB="$(STAGING_DIR_HOST)/lib/liblzma.a" \
 		EXTRA_CFLAGS="-I$(STAGING_DIR_HOST)/include" \
-		EXTRA_LDFLAGS="$(HOST_STATIC_LINKING)" \
 		mksquashfs unsquashfs
 endef
 
diff --git a/tools/sstrip/Makefile b/tools/sstrip/Makefile
index 045d080785..180bd1743e 100644
--- a/tools/sstrip/Makefile
+++ b/tools/sstrip/Makefile
@@ -11,7 +11,7 @@ PKG_NAME:=sstrip
 include $(INCLUDE_DIR)/host-build.mk
 
 define Host/Compile
-	$(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/sstrip src/sstrip.c
+	$(HOSTCC) $(HOST_CFLAGS) -include endian.h -o $(HOST_BUILD_DIR)/sstrip src/sstrip.c
 endef
 
 define Host/Install
diff --git a/tools/upslug2/Makefile b/tools/upslug2/Makefile
index e80cef0eb4..33b1ff5a42 100644
--- a/tools/upslug2/Makefile
+++ b/tools/upslug2/Makefile
@@ -18,7 +18,6 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 include $(INCLUDE_DIR)/host-build.mk
 
 unexport CFLAGS
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
 
 define Host/Configure
 	(cd $(HOST_BUILD_DIR); \
diff --git a/tools/upx/Makefile b/tools/upx/Makefile
index a095ee1268..7f212affb3 100644
--- a/tools/upx/Makefile
+++ b/tools/upx/Makefile
@@ -21,7 +21,7 @@ include $(INCLUDE_DIR)/host-build.mk
 define Host/Compile
 	rm -f $(HOST_BUILD_DIR)/src/.depend
 	$(MAKE) UPX_LZMADIR="$(BUILD_DIR_HOST)/lzma-4.65" -C $(HOST_BUILD_DIR)/src \
-		CXXFLAGS_WERROR="" LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)" \
+		CXXFLAGS_WERROR="" LDFLAGS="$(HOST_LDFLAGS)" \
 		CXX="$(HOSTCXX)"
 endef
 
diff --git a/tools/wrt350nv2-builder/Makefile b/tools/wrt350nv2-builder/Makefile
index 755f27dc60..a705b6dc8d 100644
--- a/tools/wrt350nv2-builder/Makefile
+++ b/tools/wrt350nv2-builder/Makefile
@@ -19,7 +19,7 @@ define Host/Compile
 	$(HOSTCC) $(HOST_CFLAGS) -c src/md5.c -o $(HOST_BUILD_DIR)/md5.o
 	$(HOSTCC) $(HOST_CFLAGS) -c src/ioapi.c -o $(HOST_BUILD_DIR)/ioapi.o
 	$(HOSTCC) $(HOST_CFLAGS) -c src/wrt350nv2-builder.c -o $(HOST_BUILD_DIR)/wrt350nv2-builder.o
-	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/wrt350nv2-builder \
+	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $(HOST_BUILD_DIR)/wrt350nv2-builder \
 		$(HOST_BUILD_DIR)/wrt350nv2-builder.o $(HOST_BUILD_DIR)/md5.o $(HOST_BUILD_DIR)/ioapi.o
 endef
 
diff --git a/tools/xz/Makefile b/tools/xz/Makefile
index 8156c92c7c..f80d896582 100644
--- a/tools/xz/Makefile
+++ b/tools/xz/Makefile
@@ -17,11 +17,8 @@ HOST_BUILD_PARALLEL:=1
 
 include $(INCLUDE_DIR)/host-build.mk
 
-HOST_LDFLAGS += $(HOST_STATIC_LINKING)
-
 define Host/Install
-	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) install xzlinks="unxz xzcat" \
-		AM_LDFLAGS="$(if $(HOST_STATIC_LINKING),-all-static)"
+	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) install xzlinks="unxz xzcat"
 endef
 
 $(eval $(call HostBuild))
diff --git a/tools/yaffs2/Makefile b/tools/yaffs2/Makefile
index 22c4ecaeb6..bc98a6c8f5 100644
--- a/tools/yaffs2/Makefile
+++ b/tools/yaffs2/Makefile
@@ -22,7 +22,7 @@ include $(INCLUDE_DIR)/host-build.mk
 
 define Host/Compile
 	$(MAKE) -C $(HOST_BUILD_DIR)/yaffs2/utils \
-		CC="$(HOSTCC) $(HOST_STATIC_LINKING)" \
+		CC="$(HOSTCC)" \
 		CFLAGS="$(HOST_CFLAGS) -include endian.h" \
 		mkyaffs2image
 endef
-- 
2.30.2