Skip to contentSkip to conversation

package/zlib: allow shared-only builds

PATCH New Yann E. MORIN 2 participants 2 messages Dec 16, 2014 – Dec 20, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/zlib: allow shared-only builds

Currently, we can build a static-only zlib, but not a shared-only one.

This is because zlib's build-system is a custom ./configure (not using autotools), and does not allow building/installing only the shared library.

Simply remove the .a as a post-staging install hook. We don't care removing it from target, since it is not used at link time to build other packages, and it is anyway removed later before assembling the filesystem images anyway.

Cc Thomas Petazzoni <[email protected]>
---
 package/zlib/zlib.mk | 13 +++++++++++++
 1 file changed, 13 insertions(+)
package/zlib/zlib.mk +13 -0
index 7c849cd..aec9daf 100644
@@ -11,6 +11,9 @@ ZLIB_LICENSE = zlib license
 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
@@ -56,6 +59,16 @@ define ZLIB_INSTALL_TARGET_CMDS
 	$(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
 	$(MAKE1) -C $(@D) LDCONFIG=true install
 endef
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 package/zlib: allow shared-only builds

Dear Yann E. MORIN,

Quoted 11 lines · Yann E. MORIN

Currently, we can build a static-only zlib, but not a shared-only one.

This is because zlib's build-system is a custom ./configure (not using autotools), and does not allow building/installing only the shared library.

Simply remove the .a as a post-staging install hook. We don't care removing it from target, since it is not used at link time to build other packages, and it is anyway removed later before assembling the filesystem images anyway.

Quoted 5 lines
Cc Thomas Petazzoni <[email protected]>
---
 package/zlib/zlib.mk | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Applied, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com