#!/bin/sh -e

./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --mandir=/usr/share/man \
    --localstatedir=/var \
    --without-xmlto \
    --disable-specs \
    --disable-static

make
make DESTDIR="$1" install

# Some X11 packages install to /usr/share.
! [ -d "$1/usr/share/pkgconfig" ] || {
    mkdir -p "$1/usr/lib"
    mv -f "$1/usr/share/pkgconfig" "$1/usr/lib"
}

# We need to keep this around.
! [ -d "$1/usr/share/aclocal" ] || {
    mkdir -p "$1/usr/share2"
    mv -f "$1/usr/share/aclocal" "$1/usr/share2"
}

# Remove library documentation.
# False positive.
# shellcheck disable=2115
rm -rf "$1/usr/share"

# Restore kept directories.
! [ -d "$1/usr/share2" ] || {
    mv -f "$1/usr/share2" "$1/usr/share"
}
