#!/bin/sh -e

sed_i() {
    for file; do :; done
    sed "$@" > _
    cat _ > "$file"; rm -f _
}

# Remove 'atk-bridge' dependency which removes the 'dbus' dependency.
sed_i 's/ATK_PACKAGES="atk atk-bridge-2.0"/ATK_PACKAGES="atk"/' \
    configure

sed_i '/<atk-bridge.h>/d;/atk_bridge_adaptor_init/d' \
    gtk/a11y/gtkaccessibility.c

cpt l wayland >/dev/null 2>&1 && wayland=--enable-wayland-backend

./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --enable-static \
    --enable-xkb \
    --enable-xinerama \
    --enable-xrandr \
    --enable-xfixes \
    --enable-xcomposite \
    --enable-xdamage \
    --enable-x11-backend \
    "$wayland" \
    --enable-debug=no \
    --disable-schemas-compile \
    --disable-cups \
    --disable-papi \
    --disable-cloudprint \
    --enable-introspection \
    --enable-colord=no \
    --enable-gtk-doc-html=no

make
make DESTDIR="$1" install