# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libsigsegv
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.13
pkgrel=2
pkgdesc="Page fault detection library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://www.gnu.org/software/libsigsegv/"
license=('spdx:GPL-2.0-or-later')
source=("https://ftp.gnu.org/gnu/${_realname}/${_realname}-${pkgver}.tar.gz"
        "0001-libsigsegv-2.11-fix-assembly.patch")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
sha256sums=('be78ee4176b05f7c75ff03298d84874db90f4b6c9d5503f0da1226b3a3c48119'
            '73d963f144531fad281ca3f4f374c1e328cc505080ef135e8728f114e5aec371')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -Np1 -i "${srcdir}/0001-libsigsegv-2.11-fix-assembly.patch"
  autoreconf -fiv
}

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

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

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