app-arch/zstd: Use upstream fix for pkgconfig libdir
authorLars Wendler <polynomial-c@gentoo.org>
Fri, 20 Mar 2020 19:02:18 +0000 (20:02 +0100)
committerLars Wendler <polynomial-c@gentoo.org>
Fri, 20 Mar 2020 19:02:18 +0000 (20:02 +0100)
- Shortened make43 patch name
- Simplified ebuild a bit

Closes: https://bugs.gentoo.org/700780
Package-Manager: Portage-2.3.94, Repoman-2.3.21
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
app-arch/zstd/files/zstd-1.4.4-make43.patch [moved from app-arch/zstd/files/zstd-1.4.4-build-issue-More-portable-header-prefix-usage-1987.patch with 100% similarity]
app-arch/zstd/files/zstd-1.4.4-pkgconfig_fix.patch [deleted file]
app-arch/zstd/files/zstd-1.4.4-pkgconfig_libdir.patch [new file with mode: 0644]
app-arch/zstd/zstd-1.4.4-r3.ebuild

diff --git a/app-arch/zstd/files/zstd-1.4.4-pkgconfig_fix.patch b/app-arch/zstd/files/zstd-1.4.4-pkgconfig_fix.patch
deleted file mode 100644 (file)
index 2fab980..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-From a025c46969b76a10ce1618df4dbb11a09563c413 Mon Sep 17 00:00:00 2001
-From: Lars Wendler <polynomial-c@gentoo.org>
-Date: Wed, 20 Nov 2019 16:41:18 +0100
-Subject: [PATCH] Revert "In pkg-config File, Derive Lib and Include Dir from
- Prefix at Use-Time"
-
-This reverts commit 74bd76c3ffb3837a3fefc055edbc347620447236.
-
-This breaks systems that use lib32 and/or lib64 instead of lib
-See https://github.com/facebook/zstd/issues/1900
-
-Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
----
- build/cmake/lib/CMakeLists.txt | 3 ++-
- lib/Makefile                   | 2 ++
- lib/libzstd.pc.in              | 5 ++---
- 3 files changed, 6 insertions(+), 4 deletions(-)
-
-diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt
-index 7adca875..77b389ca 100644
---- a/build/cmake/lib/CMakeLists.txt
-+++ b/build/cmake/lib/CMakeLists.txt
-@@ -134,10 +134,11 @@ if (UNIX)
-     # pkg-config
-     set(PREFIX "${CMAKE_INSTALL_PREFIX}")
-     set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
-+    set(INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
-     set(VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}")
-     add_custom_target(libzstd.pc ALL
-             ${CMAKE_COMMAND} -DIN="${LIBRARY_DIR}/libzstd.pc.in" -DOUT="libzstd.pc"
--            -DPREFIX="${PREFIX}" -DVERSION="${VERSION}"
-+            -DPREFIX="${PREFIX}" -DLIBDIR="${LIBDIR}" -DINCLUDEDIR="${INCLUDEDIR}" -DVERSION="${VERSION}"
-             -P "${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig.cmake"
-             COMMENT "Creating pkg-config file")
-diff --git a/lib/Makefile b/lib/Makefile
-index fd1710cf..97375ad2 100644
---- a/lib/Makefile
-+++ b/lib/Makefile
-@@ -244,6 +244,8 @@ libzstd.pc:
- libzstd.pc: libzstd.pc.in
-       @echo creating pkgconfig
-       @sed -e 's|@PREFIX@|$(PREFIX)|' \
-+             -e 's|@LIBDIR@|$(LIBDIR)|' \
-+             -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
-              -e 's|@VERSION@|$(VERSION)|' \
-              $< >$@
-diff --git a/lib/libzstd.pc.in b/lib/libzstd.pc.in
-index e7880be4..1d07b91f 100644
---- a/lib/libzstd.pc.in
-+++ b/lib/libzstd.pc.in
-@@ -3,9 +3,8 @@
- #   BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
- prefix=@PREFIX@
--exec_prefix=${prefix}
--includedir=${prefix}/include
--libdir=${exec_prefix}/lib
-+libdir=@LIBDIR@
-+includedir=@INCLUDEDIR@
- Name: zstd
- Description: fast lossless compression algorithm library
--- 
-2.24.0
-
diff --git a/app-arch/zstd/files/zstd-1.4.4-pkgconfig_libdir.patch b/app-arch/zstd/files/zstd-1.4.4-pkgconfig_libdir.patch
new file mode 100644 (file)
index 0000000..e8d745a
--- /dev/null
@@ -0,0 +1,215 @@
+From e668c9b52896e1cf92c99da3b01e3bdbbae77100 Mon Sep 17 00:00:00 2001
+From: "W. Felix Handte" <w@felixhandte.com>
+Date: Tue, 18 Feb 2020 10:50:38 -0500
+Subject: [PATCH 1/3] Fix pkg-config File Generation Again
+
+Revises #1851. Fixes #1900. Replaces #1930.
+
+Thanks to @orbea, @neheb, @Polynomial-C, and particularly @eli-schwartz for
+pointing out the problem and suggesting solutions.
+
+Tested with
+
+  ```
+  make -C lib clean libzstd.pc
+  cat lib/libzstd.pc
+
+  # should fail
+  make -C lib clean libzstd.pc     LIBDIR=/foo
+  make -C lib clean libzstd.pc INCLUDEDIR=/foo
+  make -C lib clean libzstd.pc     LIBDIR=/usr/localfoo
+  make -C lib clean libzstd.pc INCLUDEDIR=/usr/localfoo
+  make -C lib clean libzstd.pc     LIBDIR=/usr/local/lib     prefix=/foo
+  make -C lib clean libzstd.pc INCLUDEDIR=/usr/local/include prefix=/foo
+
+  # should succeed
+  make -C lib clean libzstd.pc     LIBDIR=/usr/local/foo
+  make -C lib clean libzstd.pc INCLUDEDIR=/usr/local/foo
+  make -C lib clean libzstd.pc     LIBDIR=/usr/local/
+  make -C lib clean libzstd.pc INCLUDEDIR=/usr/local/
+  make -C lib clean libzstd.pc     LIBDIR=/usr/local
+  make -C lib clean libzstd.pc INCLUDEDIR=/usr/local
+  make -C lib clean libzstd.pc     LIBDIR=/tmp/foo prefix=/tmp
+  make -C lib clean libzstd.pc INCLUDEDIR=/tmp/foo prefix=/tmp
+  make -C lib clean libzstd.pc     LIBDIR=/tmp/foo prefix=/tmp/foo
+  make -C lib clean libzstd.pc INCLUDEDIR=/tmp/foo prefix=/tmp/foo
+
+  # should also succeed
+  make -C lib clean libzstd.pc prefix=/foo LIBDIR=/foo/bar INCLUDEDIR=/foo/
+  cat lib/libzstd.pc
+
+  mkdir out
+  cd out
+  cmake ../build/cmake
+  make
+  cat lib/libzstd.pc
+  ```
+---
+ build/cmake/lib/CMakeLists.txt |  5 +++--
+ lib/Makefile                   | 14 ++++++++++++--
+ lib/libzstd.pc.in              |  4 ++--
+ 3 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt
+index e92647bf1..29ff57aa0 100644
+--- a/build/cmake/lib/CMakeLists.txt
++++ b/build/cmake/lib/CMakeLists.txt
+@@ -134,11 +134,12 @@ endif ()
+ if (UNIX)
+     # pkg-config
+     set(PREFIX "${CMAKE_INSTALL_PREFIX}")
+-    set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
++    set(LIBDIR "${CMAKE_INSTALL_LIBDIR}")
++    set(INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
+     set(VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}")
+     add_custom_target(libzstd.pc ALL
+             ${CMAKE_COMMAND} -DIN="${LIBRARY_DIR}/libzstd.pc.in" -DOUT="libzstd.pc"
+-            -DPREFIX="${PREFIX}" -DVERSION="${VERSION}"
++            -DPREFIX="${PREFIX}" -DLIBDIR="${LIBDIR}" -DINCLUDEDIR="${INCLUDEDIR}" -DVERSION="${VERSION}"
+             -P "${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig.cmake"
+             COMMENT "Creating pkg-config file")
+diff --git a/lib/Makefile b/lib/Makefile
+index fd1710cf1..dbd64994c 100644
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -224,6 +224,16 @@ LIBDIR      ?= $(libdir)
+ includedir  ?= $(PREFIX)/include
+ INCLUDEDIR  ?= $(includedir)
++PCLIBDIR ?= $(shell echo "$(LIBDIR)" | sed -n -e "s@^$(exec_prefix)\\(/\\|$$\\)@@p")
++PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | sed -n -e "s@^$(prefix)\\(/\\|$$\\)@@p")
++
++ifeq (,$(shell echo "$(LIBDIR)" | sed -n -e "\\@^$(exec_prefix)\\(/\\|$$\\)@ p"))
++$(error configured libdir ($(LIBDIR)) is outside of prefix ($(prefix)), can't generate pkg-config file)
++endif
++ifeq (,$(shell echo "$(INCLUDEDIR)" | sed -n -e "\\@^$(prefix)\\(/\\|$$\\)@ p"))
++$(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(exec_prefix)), can't generate pkg-config file)
++endif
++
+ ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
+ PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
+ else
+@@ -239,11 +249,11 @@ endif
+ INSTALL_PROGRAM ?= $(INSTALL)
+ INSTALL_DATA    ?= $(INSTALL) -m 644
+-
+-libzstd.pc:
+ libzstd.pc: libzstd.pc.in
+       @echo creating pkgconfig
+       @sed -e 's|@PREFIX@|$(PREFIX)|' \
++             -e 's|@LIBDIR@|$(PCLIBDIR)|' \
++             -e 's|@INCLUDEDIR@|$(PCINCDIR)|' \
+              -e 's|@VERSION@|$(VERSION)|' \
+              $< >$@
+diff --git a/lib/libzstd.pc.in b/lib/libzstd.pc.in
+index e7880be47..8ec0235ad 100644
+--- a/lib/libzstd.pc.in
++++ b/lib/libzstd.pc.in
+@@ -4,8 +4,8 @@
+ prefix=@PREFIX@
+ exec_prefix=${prefix}
+-includedir=${prefix}/include
+-libdir=${exec_prefix}/lib
++includedir=${prefix}/@INCLUDEDIR@
++libdir=${exec_prefix}/@LIBDIR@
+ Name: zstd
+ Description: fast lossless compression algorithm library
+
+From 73737231b95976f24b7b9bff96240976b11dcce0 Mon Sep 17 00:00:00 2001
+From: "W. Felix Handte" <w@felixhandte.com>
+Date: Tue, 18 Feb 2020 13:17:17 -0500
+Subject: [PATCH 2/3] Allow Manual Overriding of pkg-config Lib and Include
+ Dirs
+
+When the `PCLIBDIR` or `PCINCDIR` is non-empty (either because we succeeded
+in removing the prefix, or because it was manually set), we don't need to
+perform the check. This lets us trust users who go to the trouble of setting
+a manual override, rather than still blindly failing the make.
+
+They'll still be prefixed with `${prefix}/` / `${exec_prefix}/` in the
+pkg-config file though.
+---
+ lib/Makefile | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/lib/Makefile b/lib/Makefile
+index dbd64994c..b067c11a2 100644
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -227,12 +227,21 @@ INCLUDEDIR  ?= $(includedir)
+ PCLIBDIR ?= $(shell echo "$(LIBDIR)" | sed -n -e "s@^$(exec_prefix)\\(/\\|$$\\)@@p")
+ PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | sed -n -e "s@^$(prefix)\\(/\\|$$\\)@@p")
++ifeq (,$(PCLIBDIR))
++# Additional prefix check is required, since the empty string is technically a
++# valid PCLIBDIR
+ ifeq (,$(shell echo "$(LIBDIR)" | sed -n -e "\\@^$(exec_prefix)\\(/\\|$$\\)@ p"))
+ $(error configured libdir ($(LIBDIR)) is outside of prefix ($(prefix)), can't generate pkg-config file)
+ endif
++endif
++
++ifeq (,$(PCINCDIR))
++# Additional prefix check is required, since the empty string is technically a
++# valid PCINCDIR
+ ifeq (,$(shell echo "$(INCLUDEDIR)" | sed -n -e "\\@^$(prefix)\\(/\\|$$\\)@ p"))
+ $(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(exec_prefix)), can't generate pkg-config file)
+ endif
++endif
+ ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
+ PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
+
+From e5ef935cf6160768e20cd73db3d9450aa8b7f8cf Mon Sep 17 00:00:00 2001
+From: "W. Felix Handte" <w@felixhandte.com>
+Date: Tue, 18 Feb 2020 13:40:58 -0500
+Subject: [PATCH 3/3] Fix Variable Capitalization
+
+---
+ lib/Makefile | 15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+
+diff --git a/lib/Makefile b/lib/Makefile
+index b067c11a2..db35207bb 100644
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -219,27 +219,28 @@ DESTDIR     ?=
+ prefix      ?= /usr/local
+ PREFIX      ?= $(prefix)
+ exec_prefix ?= $(PREFIX)
+-libdir      ?= $(exec_prefix)/lib
++EXEC_PREFIX ?= $(exec_prefix)
++libdir      ?= $(EXEC_PREFIX)/lib
+ LIBDIR      ?= $(libdir)
+ includedir  ?= $(PREFIX)/include
+ INCLUDEDIR  ?= $(includedir)
+-PCLIBDIR ?= $(shell echo "$(LIBDIR)" | sed -n -e "s@^$(exec_prefix)\\(/\\|$$\\)@@p")
+-PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | sed -n -e "s@^$(prefix)\\(/\\|$$\\)@@p")
++PCLIBDIR ?= $(shell echo "$(LIBDIR)" | sed -n -e "s@^$(EXEC_PREFIX)\\(/\\|$$\\)@@p")
++PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | sed -n -e "s@^$(PREFIX)\\(/\\|$$\\)@@p")
+ ifeq (,$(PCLIBDIR))
+ # Additional prefix check is required, since the empty string is technically a
+ # valid PCLIBDIR
+-ifeq (,$(shell echo "$(LIBDIR)" | sed -n -e "\\@^$(exec_prefix)\\(/\\|$$\\)@ p"))
+-$(error configured libdir ($(LIBDIR)) is outside of prefix ($(prefix)), can't generate pkg-config file)
++ifeq (,$(shell echo "$(LIBDIR)" | sed -n -e "\\@^$(EXEC_PREFIX)\\(/\\|$$\\)@ p"))
++$(error configured libdir ($(LIBDIR)) is outside of prefix ($(PREFIX)), can't generate pkg-config file)
+ endif
+ endif
+ ifeq (,$(PCINCDIR))
+ # Additional prefix check is required, since the empty string is technically a
+ # valid PCINCDIR
+-ifeq (,$(shell echo "$(INCLUDEDIR)" | sed -n -e "\\@^$(prefix)\\(/\\|$$\\)@ p"))
+-$(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(exec_prefix)), can't generate pkg-config file)
++ifeq (,$(shell echo "$(INCLUDEDIR)" | sed -n -e "\\@^$(PREFIX)\\(/\\|$$\\)@ p"))
++$(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(EXEC_PREFIX)), can't generate pkg-config file)
+ endif
+ endif
index d5c67e17ca2cf922da610ef2fc80f87b19fdc298..d9f50e82492135824bee9643cc232e4bdaec7c9f 100644 (file)
@@ -19,8 +19,8 @@ RDEPEND="app-arch/xz-utils
 DEPEND="${RDEPEND}"
 
 PATCHES=(
-       "${FILESDIR}/${PN}-1.4.4-pkgconfig_fix.patch" #700780
-       "${FILESDIR}/${P}-build-issue-More-portable-header-prefix-usage-1987.patch" #708110
+       "${FILESDIR}/${P}-pkgconfig_libdir.patch" #700780
+       "${FILESDIR}/${P}-make43.patch" #708110
 )
 
 src_prepare() {
@@ -39,11 +39,9 @@ mymake() {
 }
 
 multilib_src_compile() {
-       if use threads; then
-               mymake -C lib libzstd-mt libzstd.a-mt libzstd.pc
-       else
-               mymake -C lib libzstd libzstd.a libzstd.pc
-       fi
+       local libzstd_targets=( libzstd{,.a}$(usex threads '-mt' '') )
+
+       mymake -C lib ${libzstd_targets[@]} libzstd.pc
 
        if multilib_is_native_abi ; then
                mymake HAVE_LZ4="$(usex lz4 1 0)" zstd