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

_realname=libcdr
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.1.7
pkgrel=1
pkgdesc="libcdr is a library and a set of tools for reading and converting binary files produced by Corel DRAW (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('MPL2')
url="https://wiki.documentfoundation.org/DLP/Libraries/libcdr"
options=('staticlibs' 'strip')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-boost"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-cppunit")
depends=("${MINGW_PACKAGE_PREFIX}-icu"
         "${MINGW_PACKAGE_PREFIX}-lcms2"
         "${MINGW_PACKAGE_PREFIX}-librevenge"
         "${MINGW_PACKAGE_PREFIX}-zlib")
source=("https://dev-www.libreoffice.org/src/${_realname}/${_realname}-${pkgver}.tar.xz")
sha256sums=('5666249d613466b9aa1e987ea4109c04365866e9277d80f6cd9663e86b8ecdd4')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-silent-rules

  make -j1
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -k check || true
}

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