# Maintainer: Alberto Fanjul <albertofanjul@gmail.com>

_realname=odt2txt
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.5
pkgrel=2
pkgdesc="extracts the text out of OpenDocument Texts"
url="https://github.com/dstosberg/odt2txt/"
license=("GPL2")
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
depends=("${MINGW_PACKAGE_PREFIX}-libiconv"
         "${MINGW_PACKAGE_PREFIX}-libzip"
         "${MINGW_PACKAGE_PREFIX}-pcre")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/dstosberg/odt2txt/archive/v${pkgver}.tar.gz"
        "0001-Compile-for-Msys2.patch")
sha256sums=('23a889109ca9087a719c638758f14cc3b867a5dcf30a6c90bf6a0985073556dd'
            'bdab3b2fab929dc927ec51c7bb8d47dcd184b8b346d0184fe916cb030a98c224')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "$srcdir/0001-Compile-for-Msys2.patch"
}

build() {
  [[ "$CARCH" == "x86_64" ]] && arch_make=64
  [[ "$CARCH" == "i686" ]] && arch_make=32

  cd "${srcdir}/${_realname}-${pkgver}"
  make ARCH=${arch_make} CC=${MINGW_PREFIX}/bin/gcc
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make DESTDIR=${pkgdir} PREFIX=${MINGW_PREFIX} install
}
