# Maintainer: Chih-Hsuan Yen <yan12125@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Andreas Radke <andyrtr@archlinux.org>
# Contributor: damir <damir@archlinux.org>

pkgname=gcin
pkgver=2.8.9
pkgrel=3
pkgdesc='Input method server supporting various input methods'
url='https://hyperrate.com/dir.php?eid=67'
license=('LGPL')
arch=('x86_64')
depends=('gtk3' 'libxtst')
makedepends=('qt5-base' 'gtk2' 'anthy')
optdepends=('qt5-base: support for qt5 input method'
            'gtk2: support for gtk2 input method'
            'anthy: support for anthy input method'
            'curl: for downloading and uploading vocabulary databases via ts-edit')
source=("https://hyperrate.com/gcin-source/${pkgname}-${pkgver}.tar.xz"
        fix-gtk-immodules-path.patch)
sha512sums=('36813c124bb0ad37a5d3e5fde2ce6aecab9d6702e294b0196da1a830690145371d051909244477dcaca66afce7bba96a8c8f0931b97ad81c61fae8eacef29e17'
            '54e90b04de45acf9f8821c92234b9708281907cbdf24ebb29f9820945615669d82a8443e49fd49d6c08be4a7b9f2857c8e763f170ef879c8fab1f232bb67e85d')

prepare() {
    cd "${srcdir}/${pkgname}-${pkgver}"
    sed 's/lib64/lib/g' -i configure
    sed '/include suffixes-rule/a \
        CFLAGS+='"${CFLAGS}"' \
        LDFLAGS+='"${LDFLAGS}"' \
        OPTFLAGS=' \
        -i Makefile
    sed \
        -e 's:QT=qt5:QT=qt:' \
        -i qt5-im/Makefile59
    patch -Np1 -i ../fix-gtk-immodules-path.patch
}

build() {
    cd "${srcdir}/${pkgname}-${pkgver}"
    ./configure --prefix=/usr --use_i18n=Y
    make -j1
}

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