# Maintainer: David SEGUELA <david.seguela@delair-tech.com>

_realname=zbar
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.23.1
pkgrel=3
pkgdesc="Application and library for reading bar codes from various sources (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/mchehab/zbar"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-imagemagick")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/mchehab/zbar/archive/${pkgver}.tar.gz
        zbar-autoconf-2.70.patch::"https://github.com/mchehab/zbar/commit/89e7900d.patch"
        "no-undefined.patch")
sha256sums=('297439f8859089d2248f55ab95b2a90bba35687975365385c87364c77fdb19f3'
            '82ac7723115d4c6aa8db6ff0e62764c310cc35f7b620413b36c4999a301216e2'
            'fd2b2e1d099e2100ab7374931715025c5ceedd338ba36c769bb622afda393e36')
options=('strip' 'staticlibs')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/no-undefined.patch
  patch -p1 -i ${srcdir}/zbar-autoconf-2.70.patch
  autoreconf -fiv
}

build() {
  [[ -d ${srcdir}/build-${CARCH} ]] && rm -rf ${srcdir}/build-${CARCH}
  cp -rf ${srcdir}/${_realname}-${pkgver} ${srcdir}/build-${CARCH}
  cd ${srcdir}/build-${CARCH}
  ./configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --without-qt \
      --without-gtk \
      --with-python=no \
      --with-directshow
  make
}

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