# Maintainer: Bjoern Lemke <lemke@lemke-it.com>

_realname=lfcxml
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.3.2
pkgrel=2
pkgdesc="LFC C++ xml classes (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='http://www.lemke-it.com/'
license=('GPL3')

source=("http://www.lemke-it.com/${_realname}-${pkgver}.tar.gz")

depends=("${MINGW_PACKAGE_PREFIX}-lfcbase")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")

sha256sums=("0c5a263cd2c82d137e97b510ba2f8b0408e4ef3e08954e5876c5d956ca65b0c4")

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

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

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make

  ${CC} -shared \
    -Wl,--out-implib,liblfcxml.dll.a \
    -o liblfcxml-0.dll \
    "${srcdir}"/build-${MSYSTEM}/src/*.o \
    -llfcbase -lsystre -lws2_32 -lpthread -lstdc++

}

check() {
  cd "${srcdir}"/build-${MSYSTEM}
  make check
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make install DESTDIR="${pkgdir}"
  mkdir -p "${pkgdir}"${MINGW_PREFIX}/{bin,lib}
  install -m 0755 liblfcxml-0.dll "${pkgdir}${MINGW_PREFIX}/bin"
  install -m 0644 liblfcxml.dll.a "${pkgdir}${MINGW_PREFIX}/lib"

}
