APP=signify
VERSION=30
BUILD=1sml
LIBBSDVERSION=0.10.0
HOMEPAGE='https://github.com/aperezdc/signify'
DOWNLOAD='https://github.com/aperezdc/signify/releases/download/v30/signify-30.tar.xz'
DESC="Tools to cryptographically sign and verify files from OpenBSD folks"
REQUIRES="musl"

build() {
  mkandenterbuilddir
  rm -rf $APP-$VERSION

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

  # We don't need a system-wide libbsd install because it would then get sucked 
  # in by xorg and qt5-based applications. We'll keep it contained to the 
  # signify source directory by modifying the pkgconfig path and CFLAGS and LDFLAGS.

  mkdir libbsd && cd libbsd
  tar xf "$SRCDIR"/libbsd-$LIBBSDVERSION.tar.?z
  cd libbsd-$LIBBSDVERSION
  ./configure --prefix="$PWD"/../
  make && make install
  cd ..

  LIBBSDPATH="$PWD"
  cd ..

  PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$LIBBSDPATH/lib/pkgconfig"
  patch -p1 < $SRCDIR/sha2.h.patch
  make CC="$CC -static" \
   CFLAGS="-I$LIBBSDPATH/include" LDFLAGS="-L$LIBBSDPATH/lib"
  make install PREFIX="" DESTDIR=$PKG

  mkfinalpkg
}

SHA512SUMS="
b75529785b16c93d31401187f8a58258fbebe565dac071c8311775c913af989f62cd29d5ce2651af3ea6221cffd31cf04826577d3e546ab9ca14340f297777b9  libbsd-0.10.0.tar.xz
4a1ebcdbf7aa74865b97cadbf5380460702306b6d0a77306e6c943bb0c3419ca929ecd3455522da4448d780a56c8eddeb26fb4d7fb006fc3bf23f69693c39e87  signify-30.tar.gz
15d8eaa27c6e46862d8957341501c9f0dab254ed9652aca130c47b7478c025796d90b7ded10a74b69020c8da550b167a65b471b1c01d207abe0d281a785e6ffe  sha2.h.patch
"
