# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=pkg-config
pkgver=0.29.2
pkgrel=4
pkgdesc="A system for managing library compile/link flags"
arch=('i686' 'x86_64')
url="https://www.freedesktop.org/wiki/Software/pkg-config/"
license=('GPL')
depends=('libiconv')
source=(https://pkgconfig.freedesktop.org/releases/${pkgname}-${pkgver}.tar.gz
        glib-cygwin.patch
        pkg-config-0.28-msys2.patch
        fix-glib-gettext-m4-error.patch)
sha256sums=('6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591'
            '622ae8c52e6051209e8703b06bbffa622902b484f796d4de4617c96a221580fd'
            '7d8a3d5544046b38d0eccacb8f8ed1b2d145251a12e317c24d3c5f8d6108b5f4'
            '84c78da6d6eb292945a0e9229a3f38f53ee072faa03f2c56a304d106e1e137b3')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p2 -i ${srcdir}/glib-cygwin.patch
  patch -p1 -i ${srcdir}/pkg-config-0.28-msys2.patch
  patch -p1 -i ${srcdir}/fix-glib-gettext-m4-error.patch

  autoreconf -fiv
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure \
    --build=${CHOST} \
    --host=${CHOST} \
    --prefix=/usr \
    --with-internal-glib \
    --enable-indirect-deps
  make
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
}
