From 8dcd941d8b934891676a8d4bbef1ee78e89a4bf7 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 15 Apr 2018 19:24:02 +0200 Subject: [PATCH] tools/zlib: move zlib build to tools This allows us to link the other tools against our libz and we do not need the system zlib any more. Only the static linked library is copied to the staging directory so we have a statically linked library on all systems and not only on Linux. This also adds the new dependencies of the packages which are depending on zlib. Signed-off-by: Hauke Mehrtens Tested-by: Koen Vandeputte --- include/prereq-build.mk | 5 --- package/libs/zlib/Makefile | 2 - tools/Makefile | 14 ++++--- tools/lzma-old/Makefile | 2 + tools/lzma-old/patches/120-add-cflags.patch | 11 +++++ tools/make-ext4fs/Makefile | 8 +--- .../make-ext4fs/patches/100-add-ldflags.patch | 11 +++++ tools/squashfs4/Makefile | 2 +- tools/zlib/Makefile | 41 +++++++++++++++++++ 9 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 tools/lzma-old/patches/120-add-cflags.patch create mode 100644 tools/make-ext4fs/patches/100-add-ldflags.patch create mode 100644 tools/zlib/Makefile diff --git a/include/prereq-build.mk b/include/prereq-build.mk index 6917716342..5b9a7e049d 100644 --- a/include/prereq-build.mk +++ b/include/prereq-build.mk @@ -76,11 +76,6 @@ else zlib_link_flags := -lz endif -$(eval $(call TestHostCommand,zlib, \ - Please install a static zlib. (Missing libz.a or zlib.h), \ - echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \ - gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - $(zlib_link_flags))) - $(eval $(call TestHostCommand,perl-thread-queue, \ Please install the Perl Thread::Queue module, \ perl -MThread::Queue -e 1)) diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile index a7c61f7dd0..4a2a0e53b0 100644 --- a/package/libs/zlib/Makefile +++ b/package/libs/zlib/Makefile @@ -21,7 +21,6 @@ PKG_CPE_ID:=cpe:/a:gnu:zlib PKG_CONFIG_DEPENDS:= CONFIG_ZLIB_OPTIMIZE_SPEED -include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk @@ -95,6 +94,5 @@ define Package/zlib-dev/install $(1)/usr/lib/pkgconfig/ endef -$(eval $(call HostBuild)) $(eval $(call BuildPackage,zlib)) $(eval $(call BuildPackage,zlib-dev)) diff --git a/tools/Makefile b/tools/Makefile index 50bd552d75..8dfab9892b 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -22,7 +22,7 @@ ifneq ($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_PACKAGE_b43legacy-firmwar endif tools-$(BUILD_TOOLCHAIN) += gmp mpfr mpc libelf expat -tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs +tools-y += m4 libtool autoconf automake flex bison pkg-config mklibs zlib tools-y += sstrip make-ext4fs e2fsprogs mtd-utils mkimage tools-y += firmware-utils patch-image quilt padjffs2 tools-y += mm-macros missing-macros cmake scons bc findutils gengetopt patchelf @@ -43,16 +43,16 @@ $(curdir)/bison/compile := $(curdir)/flex/compile $(curdir)/flex/compile := $(curdir)/libtool/compile $(curdir)/libtool/compile := $(curdir)/m4/compile $(curdir)/autoconf/compile $(curdir)/automake/compile $(curdir)/missing-macros/compile $(curdir)/squashfs/compile := $(curdir)/lzma-old/compile -$(curdir)/squashfs4/compile := $(curdir)/xz/compile +$(curdir)/squashfs4/compile := $(curdir)/xz/compile $(curdir)/zlib/compile $(curdir)/quilt/compile := $(curdir)/autoconf/compile $(curdir)/findutils/compile $(curdir)/autoconf/compile := $(curdir)/m4/compile $(curdir)/automake/compile := $(curdir)/m4/compile $(curdir)/autoconf/compile $(curdir)/pkg-config/compile $(curdir)/xz/compile $(curdir)/gmp/compile := $(curdir)/libtool/compile $(curdir)/mpc/compile := $(curdir)/mpfr/compile $(curdir)/gmp/compile $(curdir)/mpfr/compile := $(curdir)/gmp/compile -$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile +$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/compile $(curdir)/zlib/compile $(curdir)/mklibs/compile := $(curdir)/libtool/compile -$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile +$(curdir)/qemu/compile := $(curdir)/e2fsprogs/compile $(curdir)/zlib/compile $(curdir)/upslug2/compile := $(curdir)/libtool/compile $(curdir)/mm-macros/compile := $(curdir)/libtool/compile $(curdir)/missing-macros/compile := $(curdir)/autoconf/compile @@ -69,8 +69,12 @@ $(curdir)/patchelf/compile := $(curdir)/libtool/compile $(curdir)/dosfstools/compile := $(curdir)/autoconf/compile $(curdir)/automake/compile $(curdir)/libressl/compile := $(curdir)/pkg-config/compile $(curdir)/mkimage/compile += $(curdir)/libressl/compile -$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile +$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile $(curdir)/zlib/compile $(curdir)/cmake/compile += $(curdir)/libressl/compile +$(curdir)/zlib/compile := $(curdir)/cmake/compile +$(curdir)/wrt350nv2-builder/compile := $(curdir)/zlib/compile +$(curdir)/lzma-old/compile := $(curdir)/zlib/compile +$(curdir)/make-ext4fs/compile := $(curdir)/zlib/compile ifneq ($(HOST_OS),Linux) tools-y += coreutils diff --git a/tools/lzma-old/Makefile b/tools/lzma-old/Makefile index 5982eab5db..5204127a80 100644 --- a/tools/lzma-old/Makefile +++ b/tools/lzma-old/Makefile @@ -21,7 +21,9 @@ LIB_DIR=$(HOST_BUILD_DIR)/C/7zip/Compress/LZMA_Lib ALONE_DIR=$(HOST_BUILD_DIR)/C/7zip/Compress/LZMA_Alone define Host/Compile + +$(HOST_MAKE_VARS) \ $(MAKE) -C $(LIB_DIR) + +$(HOST_MAKE_VARS) \ $(MAKE) -f makefile.gcc -C $(ALONE_DIR) endef diff --git a/tools/lzma-old/patches/120-add-cflags.patch b/tools/lzma-old/patches/120-add-cflags.patch new file mode 100644 index 0000000000..9022e7cd27 --- /dev/null +++ b/tools/lzma-old/patches/120-add-cflags.patch @@ -0,0 +1,11 @@ +--- a/C/7zip/Compress/LZMA_Lib/makefile ++++ b/C/7zip/Compress/LZMA_Lib/makefile +@@ -2,7 +2,7 @@ PROG = liblzma.a + CXX = g++ -O3 -Wall + AR = ar + RM = rm -f +-CFLAGS = -c -I ../../../ ++CFLAGS += -c -I ../../../ + + OBJS = \ + ZLib.o \ diff --git a/tools/make-ext4fs/Makefile b/tools/make-ext4fs/Makefile index f140101c8e..97f9e6369c 100644 --- a/tools/make-ext4fs/Makefile +++ b/tools/make-ext4fs/Makefile @@ -17,13 +17,7 @@ PKG_MIRROR_HASH:=d7ccd5e426b1d15331ff000a37dc15161f6eef594453e970fd584fcde5a2507 include $(INCLUDE_DIR)/host-build.mk -ifeq ($(HOST_OS),Linux) - MAKE_STATIC := STATIC=1 -endif - -define Host/Compile - $(MAKE) -C $(HOST_BUILD_DIR) make_ext4fs $(MAKE_STATIC) -endef +HOST_MAKE_FLAGS += STATIC=1 define Host/Install $(INSTALL_BIN) $(HOST_BUILD_DIR)/make_ext4fs $(STAGING_DIR_HOST)/bin/ diff --git a/tools/make-ext4fs/patches/100-add-ldflags.patch b/tools/make-ext4fs/patches/100-add-ldflags.patch new file mode 100644 index 0000000000..d9ce47bb80 --- /dev/null +++ b/tools/make-ext4fs/patches/100-add-ldflags.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -27,7 +27,7 @@ OBJ := \ + $(CC) $(CFLAGS) -c -o $@ $^ + + make_ext4fs: $(OBJ) libsparse/libsparse.a +- $(CC) -o $@ $^ $(ZLIB) ++ $(CC) $(LDFLAGS)-o $@ $^ $(ZLIB) + + libsparse/libsparse.a: + $(MAKE) -C libsparse/ libsparse.a diff --git a/tools/squashfs4/Makefile b/tools/squashfs4/Makefile index e9e2b7ca9a..409b1b5a23 100644 --- a/tools/squashfs4/Makefile +++ b/tools/squashfs4/Makefile @@ -20,8 +20,8 @@ HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/squashfs$(PKG_VERSION) include $(INCLUDE_DIR)/host-build.mk define Host/Compile + +$(HOST_MAKE_VARS) \ $(MAKE) -C $(HOST_BUILD_DIR)/squashfs-tools \ - CC="$(HOSTCC)" \ XZ_SUPPORT=1 \ LZMA_XZ_SUPPORT=1 \ XATTR_SUPPORT= \ diff --git a/tools/zlib/Makefile b/tools/zlib/Makefile new file mode 100644 index 0000000000..279851f758 --- /dev/null +++ b/tools/zlib/Makefile @@ -0,0 +1,41 @@ +# +# Copyright (C) 2006-2013 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=zlib +PKG_VERSION:=1.2.11 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@SF/libpng http://www.zlib.net +PKG_HASH:=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066 + +PKG_LICENSE:=Zlib +PKG_LICENSE_FILES:=README +PKG_CPE_ID:=cpe:/a:gnu:zlib + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/cmake.mk + +HOST_CFLAGS +=-fPIC + +define Host/Install + $(CP) $(HOST_BUILD_DIR)/libz.a $(STAGING_DIR_HOST)/lib/ + $(CP) $(HOST_BUILD_DIR)/zconf.h $(STAGING_DIR_HOST)/include/ + $(CP) $(HOST_BUILD_DIR)/zlib.h $(STAGING_DIR_HOST)/include/ + $(CP) $(HOST_BUILD_DIR)/zlib.pc $(STAGING_DIR_HOST)/lib/pkgconfig/ +endef + +define Host/Clean + rm -f $(STAGING_DIR_HOST)/lib/libz.a + rm -f $(STAGING_DIR_HOST)/include/zconf.h + rm -f $(STAGING_DIR_HOST)/include/zlib.h + rm -f $(STAGING_DIR_HOST)/lib/pkgconfig//zlib.pc +endef + +$(eval $(call HostBuild))