From: Norbert Lange <nolange79@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 3/5] package/zstd: rework build and install
Date: Tue, 25 May 2021 19:14:29 +0200 [thread overview]
Message-ID: <20210525171432.819180-3-nolange79@gmail.com> (raw)
In-Reply-To: <20210525171432.819180-1-nolange79@gmail.com>
1.5.0 uses Threads by default for cli tool and DSO,
the build now does the same unless:
If only static libraries are build, then build
that library like the DSO is normally built.
This should ensure that programs requsting the DSO
will always get the multithreaded version.
Signed-off-by: Norbert Lange <nolange79@gmail.com>
---
package/zstd/zstd.mk | 55 ++++++++++++++++++++++++++------------------
1 file changed, 32 insertions(+), 23 deletions(-)
diff --git a/package/zstd/zstd.mk b/package/zstd/zstd.mk
index 35c45974dc..a7a5ba4e50 100644
--- a/package/zstd/zstd.mk
+++ b/package/zstd/zstd.mk
@@ -12,7 +12,7 @@ ZSTD_LICENSE_FILES = LICENSE COPYING
ZSTD_CPE_ID_VENDOR = facebook
ZSTD_CPE_ID_PRODUCT = zstandard
-ZSTD_OPTS += ZSTD_LEGACY_SUPPORT=0
+ZSTD_OPTS += PREFIX=/usr
ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
ZSTD_OPTS += HAVE_THREAD=1
@@ -41,46 +41,55 @@ else
ZSTD_OPTS += HAVE_LZ4=0
endif
-ifeq ($(BR2_STATIC_LIBS),y)
-ZSTD_BUILD_LIBS = libzstd.a
-ZSTD_INSTALL_LIBS = install-static
-else ifeq ($(BR2_SHARED_LIBS),y)
-ZSTD_BUILD_LIBS = libzstd
-ZSTD_INSTALL_LIBS = install-shared
+ZSTD_BUILD_PROG_TARGET := zstd-release
+
+# Since v1.5.0 the dynamic library is built for
+# multithreading, while the static library is not.
+#
+# Keep those defaults, unless Buildroot is not
+# providing the dynamic library and the
+# static library will be automatically used instead.
+ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+ZSTD_INSTALL_LIBS += install-static
+ifeq ($(BR2_STATIC_LIBS)$(BR2_TOOLCHAIN_HAS_THREADS),yy)
+# Use the static lib as replacement for the mt dynlib
+ZSTD_BUILD_LIBS += libzstd.a-mt
else
-ZSTD_BUILD_LIBS = libzstd.a libzstd
-ZSTD_INSTALL_LIBS = install-static install-shared
+ZSTD_BUILD_LIBS += libzstd.a-nomt
+endif
endif
-# The HAVE_THREAD flag is read by the 'programs' makefile but not by the 'lib'
-# one. Building a multi-threaded binary with a library (which defaults to
-# single-threaded) gives a runtime error when compressing files.
-# The 'lib' makefile provides specific '%-mt' targets for this purpose.
+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+ZSTD_INSTALL_LIBS += install-shared
ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
-ZSTD_BUILD_LIBS := $(addsuffix -mt,$(ZSTD_BUILD_LIBS))
+ZSTD_BUILD_LIBS += libzstd-mt
+else
+ZSTD_BUILD_LIBS += libzstd-nomt
+endif
endif
define ZSTD_BUILD_CMDS
$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
- -C $(@D)/lib $(ZSTD_BUILD_LIBS)
- $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
- -C $(@D) zstd
+ -C $(@D)/lib $(addsuffix -release,$(ZSTD_BUILD_LIBS) libzstd.pc)
$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
- -C $(@D)/programs zstd-small
+ -C $(@D)/programs $(ZSTD_BUILD_PROG_TARGET)
endef
define ZSTD_INSTALL_STAGING_CMDS
+ [ -e $(@D)/programs/zstd ] && [ -e $(@D)/lib/libzstd.pc ]
+ $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
+ -C $(@D)/lib DESTDIR=$(STAGING_DIR) $(ZSTD_INSTALL_LIBS) \
+ install-pc install-includes
$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
- DESTDIR=$(STAGING_DIR) PREFIX=/usr -C $(@D)/lib \
- install-pc install-includes $(ZSTD_INSTALL_LIBS)
+ -C $(@D)/programs DESTDIR=$(STAGING_DIR) install
endef
define ZSTD_INSTALL_TARGET_CMDS
+ [ -e $(@D)/programs/zstd ]
$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
- DESTDIR=$(TARGET_DIR) PREFIX=/usr -C $(@D)/programs install
- install $(@D)/programs/zstd-small $(TARGET_DIR)/usr/bin
+ -C $(@D)/lib DESTDIR=$(TARGET_DIR) $(ZSTD_INSTALL_LIBS)
$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
- DESTDIR=$(TARGET_DIR) PREFIX=/usr -C $(@D)/lib $(ZSTD_INSTALL_LIBS)
+ -C $(@D)/programs DESTDIR=$(TARGET_DIR) install
endef
HOST_ZSTD_OPTS += PREFIX=$(HOST_DIR)
--
2.30.2
next prev parent reply other threads:[~2021-05-25 17:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-25 17:14 [Buildroot] [PATCH 1/5] package/zstd: bump to version 1.5.0 Norbert Lange
2021-05-25 17:14 ` [Buildroot] [PATCH 2/5] package/zstd: Simplify host-build Norbert Lange
2021-05-25 17:14 ` Norbert Lange [this message]
2021-05-25 17:14 ` [Buildroot] [PATCH 4/5] package/zstd: Change Build options Norbert Lange
2021-05-25 17:14 ` [Buildroot] [PATCH 5/5] package/zstd: Add option for cli binary Norbert Lange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210525171432.819180-3-nolange79@gmail.com \
--to=nolange79@gmail.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.