abinfo "Building Ruby bindings ..."
make ruby-bindings

abinfo "Fixing Ruby binding installation routines in Makefile ..."
sed -e 's:INSTALL = .*[^D]$:& -D:' \
    -i "$SRCDIR"/bindings/ruby/Makefile

abinfo "Installing Ruby bindings ..."
make install \
    -C "$SRCDIR"/bindings/ruby \
    exec_prefix="$PKGDIR"/usr \
    prefix=/usr

cd "$SRCDIR"/bindings/python-cffi

abinfo "Building Python 3 bindings ..."
python3 setup.py build

abinfo "Installing Python 3 bindings ..."
python3 setup.py install \
    --prefix=/usr \
    --root="$PKGDIR"

cd "$SRCDIR"

abinfo "Installing man pages and Emacs plugins ..."
make install-man install-emacs \
    DESTDIR="$PKGDIR" \
    prefix=/usr

abinfo "Installing Vim plugins ..."
make install \
    -C "$SRCDIR"/vim \
    DESTDIR="$PKGDIR" \
    prefix=/usr/share/vim/vimfiles

abinfo "Removing pre-installed MIME data cache ..."
rm -v "$PKGDIR"/usr/share/applications/mimeinfo.cache

abinfo "Building notmuch-mutt man page ..."
make notmuch-mutt.1 \
    -C "$SRCDIR"/contrib/notmuch-mutt

abinfo "Installing notmuch-mutt executable ..."
install -Dvm755 "$SRCDIR"/contrib/notmuch-mutt/notmuch-mutt \
    "$PKGDIR"/usr/bin/notmuch-mutt

abinfo "Installing notmuch-mutt man page ..."
install -Dvm644 "$SRCDIR"/contrib/notmuch-mutt/notmuch-mutt.1 \
    "$PKGDIR"/usr/share/man/man1/notmuch-mutt.1

abinfo "Setting executable bits for /usr/lib/*.so.* ..."
chmod -v +x "$PKGDIR"/usr/lib/*.so.*
