NAME="ibus"
DESC="Intelligent Input Bus"
VERSION="1.5.29"

FILES=(
  "https://github.com/ibus/ibus/archive/refs/tags/${VERSION}/ibus-${VERSION}.tar.gz"
  "https://www.unicode.org/Public/zipped/15.0.0/UCD.zip"
)
HASHES=(
  "2e29a7fb0f8c5ffcf42462fda45348fd"
  "5fbde400f3e687d25cc9b0a8d30d7619e76cb2f4c3e85ba9df8ec1312cb6718c"
)

DEPENDS=(
  "libnotify" "libxkbcommon" "wayland"
  "dconf" "iso-codes" "gtk3"
)
BUILD=("gobject-introspection" "vala" "gtk-doc")

PACKAGE() {
  tar xf "${NAME}-${VERSION}.tar.gz"
  cd "${NAME}-${VERSION}"

  mkdir -p                "${ROOTDIR}/usr/share/unicode/ucd"
  unzip -uo ../UCD.zip -d "${ROOTDIR}/usr/share/unicode/ucd"

  sed -i 's@/desktop/ibus@/org/freedesktop/ibus@g' \
    data/dconf/org.freedesktop.ibus.gschema.xml

  SAVE_DIST_FILES=1 NOCONFIGURE=1 ./autogen.sh
  export CFLAGS="${CFLAGS} -std=gnu89 -fno-strict-aliasing"

  PYTHON=python3                   \
  ./configure --prefix=/usr        \
            --sysconfdir=/etc      \
            --disable-python2      \
            --disable-appindicator \
            --disable-gtk2         \
            --disable-emoji-dict
  rm -f tools/main.c

  make
  make DESTDIR="${ROOTDIR}" install

  cd .. && rm -r "${NAME}-${VERSION}"
}
