# Maintainer: Oscar Fuentes <ofv@wanadoo.es>

_realname=ctags
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.2.1
pkgrel=1
pkgdesc="Generates an index file of language objects found in source files (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
provides=("${MINGW_PACKAGE_PREFIX}-universal-${_realname}"
          "${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
conflicts=("${MINGW_PACKAGE_PREFIX}-universal-${_realname}"
           "${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
replaces=("${MINGW_PACKAGE_PREFIX}-universal-${_realname}"
          "${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
url='https://ctags.io/'
msys2_repository_url="https://github.com/universal-ctags/ctags"
msys2_references=(
  'archlinux: ctags'
  'cygwin: ctags'
)
license=('spdx:GPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-python-docutils")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-jansson"
         "${MINGW_PACKAGE_PREFIX}-libiconv"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-libyaml"
         "${MINGW_PACKAGE_PREFIX}-pcre2")
source=("https://github.com/universal-ctags/ctags/releases/download/v${pkgver}/universal-ctags-${pkgver}.tar.gz")
sha256sums=('2c63efe9e0e083dc50e6fdd8c5414781cc8873d8c8940cf553c01870ed962f8c')

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

  ../"universal-${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --disable-etags \
    --disable-external-sort

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/universal-${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
