Skip to content
Permalink
Browse files

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 <hauke@hauke-m.de>
Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
  • Loading branch information...
hauke committed Apr 15, 2018
1 parent afdca53 commit 8dcd941d8b934891676a8d4bbef1ee78e89a4bf7
@@ -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))
@@ -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))
@@ -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
@@ -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

@@ -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 \
@@ -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/
@@ -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
@@ -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= \
@@ -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))

2 comments on commit 8dcd941

@hnyman

This comment has been minimized.

Copy link
Contributor

replied Apr 28, 2018

@hauke @commodo
This commit probably broke python compilation by removing zlib/host, as that has build dependency on zlib package host build.

(based on "make defconfig" complaining about it, but I haven't actually verified it myself)

WARNING: Makefile 'package/feeds/packages/python/Makefile' has a build dependency on 'zlib/host', which does not exist
WARNING: Makefile 'package/feeds/packages/python3/Makefile' has a build dependency on 'zlib/host', which does not exist
@hauke

This comment has been minimized.

Copy link
Member Author

replied Apr 28, 2018

The pull request is open here:
openwrt/packages#5975

Please sign in to comment.
You can’t perform that action at this time.