# Contributor: Olliver Schinagl <oliver@schinagl.nl>
# Maintainer: Olliver Schinagl <oliver@schinagl.nl>
pkgname=imx_loader
pkgver=0_git20201102
pkgrel=1
pkgdesc="serial loader for i.MX5/6/7/8 series"
url="https://github.com/boundarydevices/imx_usb_loader"
arch="all"
license="LGPL-2.1-only"
options="!check" # No tests available
subpackages="imx_usb_loader imx_uart_loader"
depends="$subpackages"
makedepends="coreutils libusb-dev linux-headers"
_commit="30b43d69770cd69e84c045dc9dcabb1f3e9d975a"
source="$pkgname-$pkgver.tar.gz::https://github.com/boundarydevices/imx_usb_loader/archive/$_commit.tar.gz"
builddir="$srcdir/imx_usb_loader-$_commit"

build() {
	make
}

package() {
	make DESTDIR="$pkgdir" sysconfdir="/etc" install
}

imx_uart_loader() {
	depends=""
	pkgdesc="$pkgdesc (UART)"

	mkdir -p "$subpkgdir/usr/bin"
	mv "$pkgdir/usr/bin/${subpkgname%%_loader}" "$subpkgdir/usr/bin/"
}

imx_usb_loader() {
	imx_uart_loader
	pkgdesc="$pkgdesc (USB)"

	mkdir -p "$subpkgdir/etc/"
	mv "$pkgdir/etc/imx-loader.d/" "$subpkgdir/etc/"
}

sha512sums="5394f89da3d086db34a4ce7f2816bea6eee08d56c53390fb4b53492fab05c5c79674b8fdf00b3eb34ef4e0f5696f0b691d78b914ec9fb6661ec428f7c4d87fc9  imx_loader-0_git20201102.tar.gz"
