# Maintainer: João Guerra <joca.bt@gmail.com>

pkgname=global
pkgver=6.6.14
pkgrel="1"
pkgdesc="A source code tagging system"
arch=("i686" "x86_64")
url="https://www.gnu.org/software/global/"
msys2_references=(
  'anitya: 7987'
  'archlinux: global'
  'cpe: cpe:2.3:a:gnu:global'
  'gentoo: dev-util/global'
)
license=('GPL3')
depends=("libltdl")
optdepends=("ctags" "python3-pygments")
makedepends=("ncurses-devel" 'autotools' 'gperf' 'gcc')
options=(libtool !emptydirs)
source=(
  "https://ftp.gnu.org/gnu/global/${pkgname}-${pkgver}.tar.gz"{,.sig}
  0001-Fixes-detecting-of-HAVE_SIGSETJMP-in-cygwin.patch
)
sha256sums=('f6e7fd0b68aed292e85bb686616baf6551d5c9424adcddca11d808ba318cb320'
            'SKIP'
            '46de890ef48c98f66f00b7fbed83ee08fa54d36b38ae007145a584dc3a8064c9')
validpgpkeys=("26F631B43D624A927E6F1C33969C3BE389DDA6EB") # Shigio YAMAGUCHI <shigio@gnu.org>

prepare() {
  cd "${pkgname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-Fixes-detecting-of-HAVE_SIGSETJMP-in-cygwin.patch"
  autoreconf -fiv
}

build () {
  cd "${pkgname}-${pkgver}"

  CFLAGS="$CFLAGS -std=gnu17" \
  ./configure --prefix=/usr \
              --build=${CHOST} \
              --host=${CHOST} \
              --enable-shared \
              --disable-static \
              --with-exuberant-ctags=ctags
  make
}

package () {
  cd "${pkgname}-${pkgver}"
  make prefix="${pkgdir}/usr" install
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
