zlib: switch to a virtual package
authorStefan Fröberg <stefan.froberg@petroprogram.com>
Wed, 29 Nov 2017 21:17:13 +0000 (23:17 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Wed, 3 Jan 2018 21:42:04 +0000 (22:42 +0100)
The existing zlib package is renamed to libzlib, and zlib is turned
into a virtual package. This is done in preparation to the
introduction of zlib-ng as an alternative implementation.

Signed-off-by: Stefan Fröberg <stefan.froberg@petroprogram.com>
[Thomas: define BR2_PACKAGE_PROVIDES_HOST_ZLIB as suggested by Yann
E. Morin.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/libzlib/libzlib.hash [new file with mode: 0644]
package/libzlib/libzlib.mk [new file with mode: 0644]
package/zlib/Config.in
package/zlib/zlib.hash [deleted file]
package/zlib/zlib.mk

diff --git a/package/libzlib/libzlib.hash b/package/libzlib/libzlib.hash
new file mode 100644 (file)
index 0000000..e3736b1
--- /dev/null
@@ -0,0 +1,4 @@
+# From http://www.zlib.net/
+sha256 4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066  zlib-1.2.11.tar.xz
+# License files, locally calculated
+sha256 7960b6b1cc63e619abb77acaea5427159605afee8c8b362664f4effc7d7f7d15  README
diff --git a/package/libzlib/libzlib.mk b/package/libzlib/libzlib.mk
new file mode 100644 (file)
index 0000000..eea0c12
--- /dev/null
@@ -0,0 +1,78 @@
+################################################################################
+#
+# libzlib
+#
+################################################################################
+
+LIBZLIB_VERSION = 1.2.11
+LIBZLIB_SOURCE = zlib-$(LIBZLIB_VERSION).tar.xz
+LIBZLIB_SITE = http://www.zlib.net
+LIBZLIB_LICENSE = Zlib
+LIBZLIB_LICENSE_FILES = README
+LIBZLIB_INSTALL_STAGING = YES
+LIBZLIB_PROVIDES = zlib
+
+# It is not possible to build only a shared version of zlib, so we build both
+# shared and static, unless we only want the static libs, and we eventually
+# selectively remove what we do not want
+ifeq ($(BR2_STATIC_LIBS),y)
+LIBZLIB_PIC =
+LIBZLIB_SHARED = --static
+else
+LIBZLIB_PIC = -fPIC
+LIBZLIB_SHARED = --shared
+endif
+
+define LIBZLIB_CONFIGURE_CMDS
+       (cd $(@D); rm -rf config.cache; \
+               $(TARGET_CONFIGURE_ARGS) \
+               $(TARGET_CONFIGURE_OPTS) \
+               CFLAGS="$(TARGET_CFLAGS) $(LIBZLIB_PIC)" \
+               ./configure \
+               $(LIBZLIB_SHARED) \
+               --prefix=/usr \
+       )
+endef
+
+define HOST_LIBZLIB_CONFIGURE_CMDS
+       (cd $(@D); rm -rf config.cache; \
+               $(HOST_CONFIGURE_ARGS) \
+               $(HOST_CONFIGURE_OPTS) \
+               ./configure \
+               --prefix="$(HOST_DIR)" \
+               --sysconfdir="$(HOST_DIR)/etc" \
+       )
+endef
+
+define LIBZLIB_BUILD_CMDS
+       $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D)
+endef
+
+define HOST_LIBZLIB_BUILD_CMDS
+       $(HOST_MAKE_ENV) $(MAKE1) -C $(@D)
+endef
+
+define LIBZLIB_INSTALL_STAGING_CMDS
+       $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) DESTDIR=$(STAGING_DIR) LDCONFIG=true install
+endef
+
+define LIBZLIB_INSTALL_TARGET_CMDS
+       $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) DESTDIR=$(TARGET_DIR) LDCONFIG=true install
+endef
+
+# We don't care removing the .a from target, since it not used at link
+# time to build other packages, and it is anyway removed later before
+# assembling the filesystem images anyway.
+ifeq ($(BR2_SHARED_LIBS),y)
+define LIBZLIB_RM_STATIC_STAGING
+       rm -f $(STAGING_DIR)/usr/lib/libz.a
+endef
+LIBZLIB_POST_INSTALL_STAGING_HOOKS += LIBZLIB_RM_STATIC_STAGING
+endif
+
+define HOST_LIBZLIB_INSTALL_CMDS
+       $(HOST_MAKE_ENV) $(MAKE1) -C $(@D) LDCONFIG=true install
+endef
+
+$(eval $(generic-package))
+$(eval $(host-generic-package))
index 6201aba1422ce45a707b85dec3de1e2852937da8..bdc1da60561d6d47ba24d359b0f255f70a49fc93 100644 (file)
@@ -1,7 +1,37 @@
 config BR2_PACKAGE_ZLIB
+       bool "zlib support"
+       help
+         Select the desired Zlib library provider.
+
+if BR2_PACKAGE_ZLIB
+
+choice
+       prompt "zlib variant"
+       default BR2_PACKAGE_LIBZLIB
+       help
+         Select the desired Zlib library provider.
+
+config BR2_PACKAGE_LIBZLIB
        bool "zlib"
+       select BR2_PACKAGE_HAS_ZLIB
        help
          Standard (de)compression library. Used by things like
          gzip and libpng.
 
          http://www.zlib.net
+
+endchoice
+
+config BR2_PACKAGE_HAS_ZLIB
+       bool
+
+config BR2_PACKAGE_PROVIDES_ZLIB
+       string
+       default "libzlib" if BR2_PACKAGE_LIBZLIB
+
+endif
+
+# ensure libzlib is used for the host variant
+config BR2_PACKAGE_PROVIDES_HOST_ZLIB
+       string
+       default "host-libzlib"
diff --git a/package/zlib/zlib.hash b/package/zlib/zlib.hash
deleted file mode 100644 (file)
index e3736b1..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# From http://www.zlib.net/
-sha256 4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066  zlib-1.2.11.tar.xz
-# License files, locally calculated
-sha256 7960b6b1cc63e619abb77acaea5427159605afee8c8b362664f4effc7d7f7d15  README
index 9b5f52e8074a79d01f5290f30a4b7911d678fe07..78f48ff0597f363e9331031e579790ad3e928568 100644 (file)
@@ -4,74 +4,5 @@
 #
 ################################################################################
 
-ZLIB_VERSION = 1.2.11
-ZLIB_SOURCE = zlib-$(ZLIB_VERSION).tar.xz
-ZLIB_SITE = http://www.zlib.net
-ZLIB_LICENSE = Zlib
-ZLIB_LICENSE_FILES = README
-ZLIB_INSTALL_STAGING = YES
-
-# It is not possible to build only a shared version of zlib, so we build both
-# shared and static, unless we only want the static libs, and we eventually
-# selectively remove what we do not want
-ifeq ($(BR2_STATIC_LIBS),y)
-ZLIB_PIC =
-ZLIB_SHARED = --static
-else
-ZLIB_PIC = -fPIC
-ZLIB_SHARED = --shared
-endif
-
-define ZLIB_CONFIGURE_CMDS
-       (cd $(@D); rm -rf config.cache; \
-               $(TARGET_CONFIGURE_ARGS) \
-               $(TARGET_CONFIGURE_OPTS) \
-               CFLAGS="$(TARGET_CFLAGS) $(ZLIB_PIC)" \
-               ./configure \
-               $(ZLIB_SHARED) \
-               --prefix=/usr \
-       )
-endef
-
-define HOST_ZLIB_CONFIGURE_CMDS
-       (cd $(@D); rm -rf config.cache; \
-               $(HOST_CONFIGURE_ARGS) \
-               $(HOST_CONFIGURE_OPTS) \
-               ./configure \
-               --prefix="$(HOST_DIR)" \
-               --sysconfdir="$(HOST_DIR)/etc" \
-       )
-endef
-
-define ZLIB_BUILD_CMDS
-       $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D)
-endef
-
-define HOST_ZLIB_BUILD_CMDS
-       $(HOST_MAKE_ENV) $(MAKE1) -C $(@D)
-endef
-
-define ZLIB_INSTALL_STAGING_CMDS
-       $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) DESTDIR=$(STAGING_DIR) LDCONFIG=true install
-endef
-
-define ZLIB_INSTALL_TARGET_CMDS
-       $(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) DESTDIR=$(TARGET_DIR) LDCONFIG=true install
-endef
-
-# We don't care removing the .a from target, since it not used at link
-# time to build other packages, and it is anyway removed later before
-# assembling the filesystem images anyway.
-ifeq ($(BR2_SHARED_LIBS),y)
-define ZLIB_RM_STATIC_STAGING
-       rm -f $(STAGING_DIR)/usr/lib/libz.a
-endef
-ZLIB_POST_INSTALL_STAGING_HOOKS += ZLIB_RM_STATIC_STAGING
-endif
-
-define HOST_ZLIB_INSTALL_CMDS
-       $(HOST_MAKE_ENV) $(MAKE1) -C $(@D) LDCONFIG=true install
-endef
-
-$(eval $(generic-package))
-$(eval $(host-generic-package))
+$(eval $(virtual-package))
+$(eval $(host-virtual-package))