# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=wiringpi
pkgver=2.32
_commitid=5edd177
pkgrel=0
pkgdesc="command line interface for Raspberry Pi gpio"
url="http://wiringpi.com/the-gpio-utility/"
arch="armhf"
license="LGPL-3.0"
depends=""
makedepends="linux-headers"
install=""
subpackages=""
source="wiringpi-$pkgver.tar.gz::https://git.drogon.net/?p=wiringPi;a=snapshot;h=$_commitid;sf=tgz
	"

_srcdir="$srcdir"/wiringPi-$_commitid

prepare() {
	local i
	cd "$_srcdir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
	sed -i -e '/sys\/ioctl/i#include <asm/ioctl.h>' wiringPi/wiringPiSPI.c
}

build() {
	cd "$_srcdir"
	make -C wiringPi static CFLAGS="$CFLAGS -I." LDFLAGS="$LDFLAGS" || return 1
	make -C devLib static CFLAGS="$CFLAGS -I../wiringPi" LDFLAGS="$LDFLAGS" || return 1
	make -C gpio CFLAGS="$CFLAGS -I../wiringPi -I../devLib" LDFLAGS="$LDFLAGS -L../wiringPi -L../devLib" || return 1
}

package() {
	cd "$_srcdir"
	install -D -m755 gpio/gpio "$pkgdir"/usr/bin/gpio || return 1
}

md5sums="8c156806f2a7c2bf5573ef54955f0cda  wiringpi-2.32.tar.gz"
sha256sums="c5f7b4807317eb74d81212337b893cb5a27981d01f6037e6be8a3a6d6e58a540  wiringpi-2.32.tar.gz"
sha512sums="6891ea57e5829772c4567502f6ed93e40e46e0263913df6dd59977016668ebc7457955e34524c1b1838e7ffd64ddf6c5e7d18c16a26b4799d6255cdb32783801  wiringpi-2.32.tar.gz"
