Skip to contentSkip to conversation

package/zstd: rework build and install

PATCH In review Norbert Lange 2 participants 3 messages Aug 4, 2021 – Aug 5, 2021 Zstd

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/2 package/zstd: rework build and install

Move PREFIX=/usr to ZSTD_OPTS, even though it is only used by libzstd.pc for now it should be available in every step.

Create libzstd.pc in the build step instead of triggering a lazy build during installation when it is missing.

Attach '-release' to the targets, since the default is to build lib-release and zstd-release.

---
v4->v5:

*   rebase, remove the parts that are already upstream
*   improve commit message
*   try to keep changes minimal

v3->v4:
* revert to previous scheme of BR2_TOOLCHAIN_HAS_THREADS
fixing build options for both static and shared libs.
v2->v3:
* use normal = for assignment
v1->v2:
* rebased against upstream/master

---
 package/zstd/zstd.mk | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
package/zstd/zstd.mk +6 -4
index 5a96c11309..d7a0320df4 100644
@@ -12,6 +12,7 @@ ZSTD_LICENSE_FILES = LICENSE COPYING
 ZSTD_CPE_ID_VENDOR = facebook
 ZSTD_CPE_ID_PRODUCT = zstandard
 
+ZSTD_OPTS += PREFIX=/usr
 ZSTD_OPTS += ZSTD_LEGACY_SUPPORT=0
 ifeq ($(BR2_PACKAGE_ZLIB),y)
 ZSTD_DEPENDENCIES += zlib
@@ -60,12 +61,13 @@ else
 ZSTD_OPTS += HAVE_THREAD=0
 ZSTD_BUILD_LIBS := $(addsuffix -nomt,$(ZSTD_BUILD_LIBS))
 endif
+ZSTD_BUILD_LIBS := $(addsuffix -release,$(ZSTD_BUILD_LIBS))
 
 define ZSTD_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		-C $(@D)/lib $(ZSTD_BUILD_LIBS)
+		-C $(@D)/lib $(ZSTD_BUILD_LIBS) libzstd.pc
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		-C $(@D) zstd
+		-C $(@D) zstd-release
 endef
 
 define ZSTD_INSTALL_STAGING_CMDS
@@ -76,9 +78,9 @@ endef
 
 define ZSTD_INSTALL_TARGET_CMDS
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		DESTDIR=$(TARGET_DIR) PREFIX=/usr -C $(@D)/programs install
+		DESTDIR=$(TARGET_DIR) -C $(@D)/programs install
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		DESTDIR=$(TARGET_DIR) PREFIX=/usr -C $(@D)/lib $(ZSTD_INSTALL_LIBS)
+		DESTDIR=$(TARGET_DIR) -C $(@D)/lib $(ZSTD_INSTALL_LIBS)
 endef
 
 HOST_ZSTD_OPTS += PREFIX=$(HOST_DIR)
Signature · 6 lines
2.30.2

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#1 lore raw

PATCH v5 2/2 package/zstd: Prefer dynamically linked tool

If the libzstd DSO is available, then link the tool against it.

---
v3->v5:
* Rebase
v2->v3:
* Drop config options, just use zstd-dll if possible

---
 package/zstd/zstd.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
package/zstd/zstd.mk +8 -1
index d7a0320df4..58dd0dd9d4 100644
@@ -49,6 +49,13 @@ ZSTD_BUILD_LIBS = lib
 ZSTD_INSTALL_LIBS = install-static install-shared
 endif
 
+# prefer zstd-dll unless no library is available
+ifeq ($(BR2_STATIC_LIBS),y)
+ZSTD_BUILD_PROG_TARGET = zstd-release
+else
+ZSTD_BUILD_PROG_TARGET = zstd-dll
+endif
+
 # The HAVE_THREAD flag is read by the 'programs' makefile but not by  the 'lib'
 # one. Building a multi-threaded binary with a static library (which defaults
 # to single-threaded) gives a runtime error when compressing files.
@@ -67,7 +74,7 @@ define ZSTD_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
 		-C $(@D)/lib $(ZSTD_BUILD_LIBS) libzstd.pc
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		-C $(@D) zstd-release
+		-C $(@D)/programs $(ZSTD_BUILD_PROG_TARGET)
 endef
 
 define ZSTD_INSTALL_STAGING_CMDS
Signature · 6 lines
2.30.2

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#2 lore raw
In reply to Norbert Lange
Quoted 42 lines · Norbert Lange

Move PREFIX=/usr to ZSTD_OPTS, even though it is only used by libzstd.pc for now it should be available in every step.

Create libzstd.pc in the build step instead of triggering a lazy build during installation when it is missing.

Attach '-release' to the targets, since the default is to build lib-release and zstd-release.

---
v4->v5:

*   rebase, remove the parts that are already upstream
*   improve commit message
*   try to keep changes minimal

v3->v4:
* revert to previous scheme of BR2_TOOLCHAIN_HAS_THREADS
fixing build options for both static and shared libs.
v2->v3:
* use normal = for assignment
v1->v2:
* rebased against upstream/master

---
 package/zstd/zstd.mk | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
package/zstd/zstd.mk +1 -0
index 5a96c11309..d7a0320df4 100644
@@ -12,6 +12,7 @@ ZSTD_LICENSE_FILES = LICENSE COPYING
 ZSTD_CPE_ID_VENDOR = facebook
 ZSTD_CPE_ID_PRODUCT = zstandard
 
+ZSTD_OPTS += PREFIX=/usr
 ZSTD_OPTS += ZSTD_LEGACY_SUPPORT=0
 ifeq ($(BR2_PACKAGE_ZLIB),y)
 ZSTD_DEPENDENCIES += zlib

package/zstd/zstd.mk else · line 64

Quoted 4 lines
package/zstd/zstd.mk +1 -0
@@ -60,12 +61,13 @@ else
 ZSTD_OPTS += HAVE_THREAD=0
 ZSTD_BUILD_LIBS := $(addsuffix -nomt,$(ZSTD_BUILD_LIBS))
 endif
+ZSTD_BUILD_LIBS := $(addsuffix -release,$(ZSTD_BUILD_LIBS))

check-package complained about this override of the variable, so I added a
check-package disable comment above.

I also improved the commit message a little (though it was already good - I
just strive for perfection :-) and committed both to next, thanks! This series can finally be put to rest :-)

Regards,
Arnout

Quoted 14 lines
package/zstd/zstd.mk +2 -2
 define ZSTD_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		-C $(@D)/lib $(ZSTD_BUILD_LIBS)
+		-C $(@D)/lib $(ZSTD_BUILD_LIBS) libzstd.pc
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		-C $(@D) zstd
+		-C $(@D) zstd-release
 endef
 
 define ZSTD_INSTALL_STAGING_CMDS
@@ -76,9 +78,9 @@ endef
 

package/zstd/zstd.mk endef · line 86

Quoted 10 lines
package/zstd/zstd.mk +2 -2
 define ZSTD_INSTALL_TARGET_CMDS
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		DESTDIR=$(TARGET_DIR) PREFIX=/usr -C $(@D)/programs install
+		DESTDIR=$(TARGET_DIR) -C $(@D)/programs install
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-		DESTDIR=$(TARGET_DIR) PREFIX=/usr -C $(@D)/lib $(ZSTD_INSTALL_LIBS)
+		DESTDIR=$(TARGET_DIR) -C $(@D)/lib $(ZSTD_INSTALL_LIBS)
 endef
 
 HOST_ZSTD_OPTS += PREFIX=$(HOST_DIR)

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot