# Contributor: Olliver Schinagl <oliver@schinagl.nl>
# Maintainer: Olliver Schinagl <oliver@schinagl.nl>
pkgname=nxp-mfgtools
pkgver=1.5.21
pkgrel=2
pkgdesc="Freescale/NXP i.MX Chip image deploy tools"
url="https://github.com/NXPmicro/mfgtools"
arch="all"
license="LGPL-2.1-only"
options="!check" # No tests available
subpackages="$pkgname-uuu lib$pkgname-static lib$pkgname-dev"
makedepends="
	bzip2-dev
	cmake
	libusb-dev
	libzip-dev
	openssl-dev>3
	samurai
	zstd-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/nxp-imx/mfgtools/archive/refs/tags/uuu_$pkgver.tar.gz
	gcc13.patch
	lfs64.patch
	"
builddir="$srcdir/mfgtools-uuu_$pkgver/"

prepare() {
	default_prepare
	echo "$pkgver" > "$builddir/.tarball-version"
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	depends="$subpackages"

	DESTDIR="$pkgdir" cmake --install build

	install -Dm644 build/libuuu/libuuc_s.a "$pkgdir/usr/lib/libuuc_s.a"
	install -Dm644 libuuu/libuuu.h "$pkgdir/usr/include/libuuu.h"
}

uuu() {
	amove usr/bin/uuu
}

sha512sums="
4b77bab9028dd2270d7b4d7a17e85439e69df5de36fa9b02986df28b0439be0f51959294e684b8d33353621fc33e189db42b8dd83b0ca6c3a6ad76355d8b3515  nxp-mfgtools-1.5.21.tar.gz
873a2b3a6b091172ce1762dccac13583b25c6781133162f7a8c4cc3fc2ecc30549c324682e1004a3658c49681b87f1975632bf9c9e8f02ec5e02176c780999ce  gcc13.patch
47f6743eae55f9570ba33e06388c533338129b66848e009d38e4b752a998dba583aa4409bd54ef4890004adba41837ce3ec17bbedfda0a5c85a8b4276b4c4af4  lfs64.patch
"
