pkgname=cflow
pkgver=1.8
pkgrel=1
pkgdesc="C function call hierarchy analyzer"
arch=('i686' 'x86_64')
license=('spdx:GPL-3.0-or-later')
url="https://www.gnu.org/software/cflow/"
depends=('libintl' 'libiconv')
msys2_repository_url="https://cgit.git.savannah.gnu.org/cgit/cflow.git"
msys2_references=(
  "cpe: cpe:2.3:a:gnu:cflow"
)
makedepends=('flex' 'gettext-devel' 'libiconv-devel' 'autotools' 'gcc')
source=(https://ftp.gnu.org/gnu/cflow/${pkgname}-${pkgver}.tar.xz)
sha256sums=('a5830a708a587ebbf3b475b585935f89c33fc8fbd057af7d817d517aceaa7afa')

prepare() {
  cd "${pkgname}-${pkgver}"
  autoreconf -vfi
}

build() {
  mkdir -p "build-${MSYSTEM_CHOST}"
  cd "build-${MSYSTEM_CHOST}"
  ../"${pkgname}-${pkgver}"/configure -C \
    --prefix=/usr
  make
}

check() {
  cd "build-${MSYSTEM_CHOST}"
  make check
}

package() {
  make -C "build-${MSYSTEM_CHOST}" DESTDIR="${pkgdir}" install

  # license
  mkdir -p "${pkgdir}/usr/share/licenses/${pkgname}/"
  cp "${pkgname}-${pkgver}/COPYING" "${pkgdir}/usr/share/licenses/${pkgname}/"
}
