package/lz4: make program installation optional
authorEd Spiridonov <edo.rus@gmail.com>
Sat, 23 May 2020 17:34:25 +0000 (20:34 +0300)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Mon, 27 Jul 2020 14:59:02 +0000 (16:59 +0200)
Often lz4 is used as a library, and not as a standalone program.
Excluding lz4 binary will save some space in this case. Indeed, the
lz4 program is always statically linked against its library, which
makes it duplicate the whole library size:

$ ls -l usr/lib/liblz4.so.1.9.2 usr/bin/lz4
-rwxr-xr-x 1 thomas thomas 226724 27 juil. 16:33 usr/bin/lz4
-rwxr-xr-x 1 thomas thomas 156996 27 juil. 16:33 usr/lib/liblz4.so.1.9.2

Since lz4 is now primarily a library, it's moved to the "Libraries"
section.

Of course, installation of programs defaults to "yes" to preserve
backward compatibility.

Signed-off-by: Ed Spiridonov <edo.rus@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/Config.in
package/lz4/Config.in
package/lz4/lz4.mk

index 5c30d27b7acde36e7b30899dbe6da3676867b197..d7e79f4795487e7896774ab040fa93ed8000af43 100644 (file)
@@ -70,7 +70,6 @@ menu "Compressors and decompressors"
        source "package/bzip2/Config.in"
        source "package/gzip/Config.in"
        source "package/lrzip/Config.in"
-       source "package/lz4/Config.in"
        source "package/lzip/Config.in"
        source "package/lzop/Config.in"
        source "package/p7zip/Config.in"
@@ -1296,6 +1295,7 @@ menu "Compression and decompression"
        source "package/libmspack/Config.in"
        source "package/libsquish/Config.in"
        source "package/libzip/Config.in"
+       source "package/lz4/Config.in"
        source "package/lzo/Config.in"
        source "package/minizip/Config.in"
        source "package/snappy/Config.in"
index 9f12299cebc67efa0b432bb69c7b2ac01065fa28..dbe3f2e24333a048f9a2fcaa49019da5dd132969 100644 (file)
@@ -8,3 +8,13 @@ config BR2_PACKAGE_LZ4
          speed limits on multi-core systems.
 
          http://www.lz4.org/
+
+if BR2_PACKAGE_LZ4
+
+config BR2_PACKAGE_LZ4_PROGS
+       bool "install programs"
+       default y
+       help
+         lz4, lz4c, unlz4 and lz4cat binaries
+
+endif
index 1d32666ccc46d871ff899687ae88ae00ea6b04f7..1cdd39106c14382ac3202448c3b3518733bf60f2 100644 (file)
@@ -32,21 +32,29 @@ define HOST_LZ4_INSTALL_CMDS
                install -C $(@D)
 endef
 
+ifeq ($(BR2_PACKAGE_LZ4_PROGS),y)
+LZ4_BUILD_TARGETS = lib lz4
+LZ4_INSTALL_OPTS = install -C $(@D)
+else
+LZ4_BUILD_TARGETS = lib
+LZ4_INSTALL_OPTS = install -C $(@D)/lib
+endif
+
 define LZ4_BUILD_CMDS
-       $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(LZ4_MAKE_OPTS) \
-               -C $(@D) lib
-       $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(LZ4_MAKE_OPTS) \
-               -C $(@D) lz4
+       $(foreach target,$(LZ4_BUILD_TARGETS),\
+               $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(LZ4_MAKE_OPTS) \
+                       -C $(@D) $(target)
+       )
 endef
 
 define LZ4_INSTALL_STAGING_CMDS
        $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) DESTDIR=$(STAGING_DIR) \
-               PREFIX=/usr $(LZ4_MAKE_OPTS) install -C $(@D)
+               PREFIX=/usr $(LZ4_MAKE_OPTS) $(LZ4_INSTALL_OPTS)
 endef
 
 define LZ4_INSTALL_TARGET_CMDS
        $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) DESTDIR=$(TARGET_DIR) \
-               PREFIX=/usr $(LZ4_MAKE_OPTS) install -C $(@D)
+               PREFIX=/usr $(LZ4_MAKE_OPTS) $(LZ4_INSTALL_OPTS)
 endef
 
 $(eval $(generic-package))