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

_realname=vcdimager
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.1
pkgrel=3
pkgdesc="A full-featured mastering suite for authoring disassembling and analyzing Video CD's and Super Video CD's (mingw-w64)"
arch=(any)
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="http://www.vcdimager.org/"
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-libcdio"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-popt")
source=("https://ftp.gnu.org/gnu/vcdimager/${_realname}-${pkgver}.tar.gz"
        002-no-undefined.patch
        003-static-vcd-lib.patch)
sha256sums=('67515fefb9829d054beae40f3e840309be60cda7d68753cafdd526727758f67a'
            'f09c49cc77bcfeaab2e23349a30fc57657e37426cc5d7f4ff63b7d79ce4e8111'
            '356a711f8201755b2ae330dfa37919ed08f3a6fed2d17a896751fae89a357e44')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}/002-no-undefined.patch"
  patch -p1 -i "${srcdir}/003-static-vcd-lib.patch"

  autoreconf -fvi
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    $( [[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]] && echo "--without-versioned-libs" || true )

  make
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
}
