Subject: [PATCH] main/squashfs-tools: add static subpackage

From: Daniel Santana <[email-masked]>
Date: Sun, 31 May 2020 20:55:29 -0300

---
 main/squashfs-tools/APKBUILD | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/main/squashfs-tools/APKBUILD b/main/squashfs-tools/APKBUILD
index 44121f25db..185c967368 100644
--- a/main/squashfs-tools/APKBUILD
+++ b/main/squashfs-tools/APKBUILD
@@ -1,12 +1,15 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=squashfs-tools
 pkgver=4.4
-pkgrel=0
+pkgrel=1
 pkgdesc="Tools for squashfs, a highly compressed read-only filesystem for Linux."
 url="https://github.com/plougher/squashfs-tools"
 arch="all"
 license="GPL"
-makedepends="zlib-dev xz-dev lzo-dev lz4-dev attr-dev zstd-dev"
+makedepends="zlib-dev zlib-static xz-dev lzo-dev lz4-dev lz4-static attr-dev
+	zstd-dev zstd-static"
+subpackages="$pkgname-static"
+options="!check" # No testsuite
 source="$pkgname-$pkgver.tar.gz::https://github.com/plougher/squashfs-tools/archive/$pkgver.tar.gz
 	fix-compat.patch
 "
@@ -15,8 +18,16 @@ _builddir="$srcdir"/$pkgname-$pkgver
 
 build() {
 	cd "$builddir"/$pkgname
-	CFLAGS="$CFLAGS -std=gnu89" \
-	make XZ_SUPPORT=1 LZO_SUPPORT=1 LZ4_SUPPORT=1 ZSTD_SUPPORT=1
+
+	export XZ_SUPPORT=1 LZO_SUPPORT=1 LZ4_SUPPORT=1 ZSTD_SUPPORT=1
+
+	make clean
+	CFLAGS="$CFLAGS -std=gnu89" LDFLAGS="$LDFLAGS -static" make
+	mv mksquashfs mksquashfs.static
+	mv unsquashfs unsquashfs.static
+
+	make clean
+	CFLAGS="$CFLAGS -std=gnu89" make
 }
 
 package() {
@@ -24,5 +35,12 @@ package() {
 	mkdir -p "$pkgdir"/sbin
 	cp -a mksquashfs unsquashfs "$pkgdir"/sbin
 }
+
+static() {
+	cd "$builddir"/${pkgname%-static}
+	mkdir -p "$subpkgdir"/sbin
+	cp -a mksquashfs.static unsquashfs.static "$subpkgdir"/sbin
+}
+
 sha512sums="133ce437fb8c929933d52cff710b61dd9181f6f8be58250b0d6a59a7bb79a2b350f68f456b06a0e17c469409a71272d586802d570248273ddcd5dad088c00308  squashfs-tools-4.4.tar.gz
 157379cf4bafb72d717f14b1bc5dc350c97a9e68a7018e0febba4b1e59f9fd90c1de8485c4ffc48a035b53be8c3aa62046281291664bee4699100cec637b0bfa  fix-compat.patch"
-- 
2.26.2