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

pkgname=swig
pkgver=4.3.1
pkgrel=1
pkgdesc="Generate scripting interfaces to C/C++ code"
arch=('i686' 'x86_64')
url="https://www.swig.org/"
msys2_references=(
  "anitya: 4919"
  "archlinux: swig"
  "cygwin: swig"
  "gentoo: dev-lang/swig"
)
license=('custom')
depends=('zlib' 'libpcre2_8')
makedepends=('zlib-devel' 'pcre2-devel' 'autotools' 'gcc')
source=(https://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.gz
        0001-no-stdcall.patch)
sha256sums=('44fc829f70f1e17d635a2b4d69acab38896699ecc24aa023e516e0eabbec61b8'
            '61f4b47694e89f566d50702def201bafba2ac84c2b35b3f0a00a5ccb834acf62')

prepare() {
  cd ${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/0001-no-stdcall.patch

  ./autogen.sh
}

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

  export MSYSTEM=CYGWIN
  ./configure -build=${CHOST} --prefix=/usr
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -D -m644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
  install -D -m644 LICENSE-UNIVERSITIES "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE-UNIVERSITIES
}
