# Maintainer: David Macek <david.macek.0@gmail.com>

# todo -DBUILD_SHARED_LIBS=ON
_realname=badvpn
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.999.130
pkgrel=2
pkgdesc="NCD scripting language, tun2socks proxifier, P2P VPN (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/ambrop72/badvpn"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake")
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-nspr"
         "${MINGW_PACKAGE_PREFIX}-nss"
         "${MINGW_PACKAGE_PREFIX}-openssl")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/ambrop72/badvpn/archive/${pkgver}.tar.gz")
sha256sums=('bfd4bbfebd7274bcec792558c9a2fd60e39cd92e04673825ade5d04154766109')

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

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INCLUDE_PATH="${MINGW_PREFIX}/include/nspr:${MINGW_PREFIX}/include/nss3" \
    -DBUILD_EXAMPLES=OFF \
    -DBUILD_TESTS=OFF \
    ../${_realname}-${pkgver}

  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make DESTDIR=${pkgdir} install
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
