APP=wiringpi
VERSION=2.60
BUILD=1sml
HOMEPAGE="http://wiringpi.com"
DESC="utility for communicating with GPIO pins on the raspberry pi"
REQUIRES="musl"

build() {
  compileonlyfor aarch64
  mkandenterbuilddir
  rm -rf $APP-4B

  tar xf $SRCDIR/$APP-4B.tar.?z*
  cd $APP-4B
  fixbuilddirpermissions

  make -C wiringPi \
    CFLAGS="$CFLAGS -fpic -I." LDFLAGS="$LDFLAGS" \
    WIRINGPI_SONAME_SUFFIX=".$VERSION"
  ln -sf libwiringPi.so.$VERSION wiringPi/libwiringPi.so

  make -C devLib \
    CFLAGS="$CFLAGS -fpic -I../wiringPi" LDFLAGS="$LDFLAGS" \
    WIRINGPI_SONAME_SUFFIX=".$VERSION"
  ln -sf libwiringPiDev.so.$VERSION devLib/libwiringPiDev.so

  make -C gpio \
    CFLAGS="$CFLAGS -I../wiringPi -I../devLib" \
    LDFLAGS="$LDFLAGS -L../wiringPi -L../devLib"

  # Final packaging. 
  mkdir $PKG/include
  cp wiringPi/*.h devLib/*.h $PKG/include

  install -Dm 755 gpio/gpio $PKG/bin/gpio
  install -Dm 755 wiringPi/libwiringPi.so."$VERSION" \
    $PKG/lib/libwiringPi.so."$VERSION"
  install -Dm 755 devLib/libwiringPiDev.so."$VERSION" \
    $PKG/lib/libwiringPiDev.so."$VERSION"

  ( cd $PKG/lib ; ln -s libwiringPi.so."$VERSION" libwiringPi.so ) 
  ( cd $PKG/lib ; ln -s libwiringPiDev.so."$VERSION" libwiringPiDev.so ) 

  cp COPYING* $PKGDOCS/

  mkfinalpkg
}

SHA512SUMS="
a8ee6dc60a32c71f8b9db6ad294ae9affa7f5c99cd546919b8b2b1992f37891a2fb59482cec6ec5afd80b5873c018012245729111bdd43e2c26d61765d570c5c  wiringpi-4B.tar.xz
"
