#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=pkgconf
pkgver=2.1.0
pkgrel=02
pkgdesc="Package compiler and linker metadata toolkit w/o i686 module"
# old url="https://github.com/pkgconf/pkgconf"
url="https://gitea.treehouse.systems/ariadne/pkgconf"
groups=( jobbot )
depends=(glibc sh)
makedepends=(git meson)
# to run tests needs kyua atf libliftoff but then they are needed as run dependencies too
# checkdepends=(kyua)
provides=(pkg-config pkgconfig libpkgconf.so)
conflicts=(pkg-config)
replaces=(pkg-config)
_commit=61d39ad899867713e73752cf23c40f0275bf71c3  # tags/pkgconf-2.1.0
source=("git+$url#commit=$_commit"
        i686-pc-linux-gnu.personality
        x86_64-pc-linux-gnu.personality)

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^pkgconf-//;s/[^-]*-g/r&/;s/-/+/g'

}

prepare() {
  cd $pkgname

  # Fix --modversion (broke WebKitGTK build)
  # https://github.com/pkgconf/pkgconf/issues/317
  # https://github.com/pkgconf/pkgconf/issues/332
  git revert -n 97d907ba93b7e4eef67e4c0a80939421ad3183f0

}

build() {
  arch-meson $pkgname build -D tests=disabled  # Tests need kyua * atf-sh provided by atf
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir"

  install -Dt "$pkgdir/usr/share/pkgconfig/personality.d" -m644 \
    i686-pc-linux-gnu.personality \
    x86_64-pc-linux-gnu.personality

  ln -s pkgconf "$pkgdir/usr/bin/i686-pc-linux-gnu-pkg-config"
  ln -s pkgconf "$pkgdir/usr/bin/x86_64-pc-linux-gnu-pkg-config"
  ln -s pkgconf "$pkgdir/usr/bin/pkg-config"

  ln -s pkgconf.1 "$pkgdir/usr/share/man/man1/pkg-config.1"

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 $pkgname/COPYING
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=(custom:ISC)

sha256sums=(SKIP
	6697c6db7deaae269ea75624a70e80949241f2cf59a537f31ecfcac726d90bc1  # i686-pc-linux-gnu.personality
	c8297817ba0b57d003878db247ff34b4c47a7594c9f67dcfe8ff8d6567956cd5) # x86_64-pc-linux-gnu.personality

##  991df4ae7c92b9306c45bf82e63e958e77fe13eee22b04d5d9483ed993659fbb  pkgconf-2.1.0-02-x86_64.pkg.tar.lz

