# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=ctpl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
pkgver=0.3.5
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
pkgdesc="C Template (Parser) Library (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
license=("spdx:GPL-3.0-or-later")
url="https://ctpl.tuxfamily.org/"
msys2_repository_url="https://github.com/b4n/ctpl"
source=("https://download.tuxfamily.org/ctpl/releases/$_realname-$pkgver.tar.gz")
sha256sums=('21108fc7567ed216deea4591adbfece8e88b1f4bb1ca77c37400920644d756be')

prepare() {
  cd "${_realname}-${pkgver}"

  ./autogen.sh
}

build() {
  mkdir -p "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  ../"${_realname}-${pkgver}"/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib

  make
}

package() {
  cd "build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
