# Contributor: Carlo Bramini <carlo_bramini@users.sourceforge.net>

_realname=liblo
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.31
pkgrel=2
pkgdesc="An implementation of the Open Sound Control protocol"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="http://liblo.sourceforge.net/"
license=('LGPL2.1')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' 'staticlibs')
source=("http://downloads.sourceforge.net/${_realname}/${_realname}-${pkgver}.tar.gz"
        010-lld.patch)
sha256sums=('2b4f446e1220dcd624ecd8405248b08b7601e9a0d87a0b94730c2907dbccc750'
            'ec080eb239f3aa436a78190586ddadab844e3c1599e4bc69c1f623c50e7675b8')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/010-lld.patch"
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  export lt_cv_deplibs_check_method='pass_all'

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

  make -j
}

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