# Maintainer: Troy C < rstrox -ta yahoo -tod com >
# Contributor: Marek Skrobacki <skrobul@skrobul.com>
# Contributor: Alasdair Haswell <ali at arhaswell dot co dot uk>
# Maintainer: Zach Bacon <11doctorwhocanada@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>

_realname=meanwhile
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.0.2
pkgrel=4
pkgdesc="Meanwhile libraries (mingw64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://sourceforge.net/projects/meanwhile"
license=(LGPL2)
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-svn")
source=(https://downloads.sourceforge.net/sourceforge/meanwhile/${_realname}-${pkgver}.tar.gz
        broken-status.patch
        fix_glib_includes.patch
        fix_groupchat.patch)
sha256sums=('38a8059eaa549cbcb45ca0a5b453e9608ceadab360db2ae14581fb22ddabdf23'
            '9a60e2ca35d902d5dd9647254a20099ceb399a025f1b04c2676f90ffe2d276f0'
            'c3dc0e423f7f4ceee65e4c08c1daebee23c61c608b970185074d118ed0199c47'
            '90467c648c18086a3f7989b7bab8f21eb44631c19a7d531121e927a0a1e74e9c')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}/src
  patch -Np0 -i "${srcdir}/broken-status.patch"
  patch -Np2 -i "${srcdir}/fix_glib_includes.patch"
  patch -Np2 -i "${srcdir}/fix_groupchat.patch"

}
build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  #CFLAGS+=" -fno-stack-protector --param=ssp-buffer-size=4"
  #CXXFLAGS+=" -fno-stack-protector --param=ssp-buffer-size=4"
  export lt_cv_deplibs_check_method='pass_all'

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

  make
}

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