#!/bin/sh -e

export DESTDIR="$1"


TMPDIR=$1/tmp

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

sed -i 's/AR_FLAGS=.*/AR_FLAGS="-r -o"/g' libtool

make
make 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 "$TMPDIR"
    mv -f "$1/usr/share/aclocal" "$TMPDIR"
}

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