# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=wiringpi
pkgver=2.61
_pkgver=$pkgver-1
pkgrel=0
pkgdesc="command line interface for Raspberry Pi gpio"
url="http://wiringpi.com/the-gpio-utility/"
arch="aarch64 armhf armv7"
license="LGPL-3.0-or-later"
options="!check" # no testsuite
makedepends="linux-headers"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/WiringPi/WiringPi/archive/refs/tags/$_pkgver.tar.gz"
builddir="$srcdir"/WiringPi-$_pkgver

build() {
	make -C wiringPi CFLAGS="$CFLAGS -fcommon -fpic -I." LDFLAGS="$LDFLAGS" WIRINGPI_SONAME_SUFFIX=".$pkgver"
	ln -sf libwiringPi.so.$pkgver wiringPi/libwiringPi.so
	make -C devLib CFLAGS="$CFLAGS -fpic -I../wiringPi" LDFLAGS="$LDFLAGS" WIRINGPI_SONAME_SUFFIX=".$pkgver"
	ln -sf libwiringPiDev.so.$pkgver devLib/libwiringPiDev.so
	make -C gpio CFLAGS="$CFLAGS -I../wiringPi -I../devLib" LDFLAGS="$LDFLAGS -L../wiringPi -L../devLib"
}

package() {
	install -d -m755 "$pkgdir"/usr/include
	install -D -m644 wiringPi/*.h devLib/*.h "$pkgdir"/usr/include
	install -D -m755 wiringPi/libwiringPi.so."$pkgver" "$pkgdir"/usr/lib/libwiringPi.so."$pkgver"
	ln -s libwiringPi.so."$pkgver" "$pkgdir"/usr/lib/libwiringPi.so
	install -D -m755 devLib/libwiringPiDev.so."$pkgver" "$pkgdir"/usr/lib/libwiringPiDev.so."$pkgver"
	ln -s libwiringPiDev.so."$pkgver" "$pkgdir"/usr/lib/libwiringPiDev.so
	install -D -m755 gpio/gpio "$pkgdir"/usr/bin/gpio
}

sha512sums="
8ac1c44a066ed8db6974428798927d31b84902cbe7cef1aa2c02a309741c208fbba8a571293aed8ccded12c8ce7c50ac227b5a7e51dc2557b4b4a94f981fd40b  wiringpi-2.61.tar.gz
"
