#!/bin/sh -e

export XSERVERLIBS_LIBS="/usr/lib/*.a -lz -lpng16"
export XSERVERCFLAGS_CFLAGS="--static"

sed -i 's/-flto//g' configure.ac

./autogen.sh

./configure \
    --prefix="$1"/usr \
    --with-fontdir=/usr/share/fonts

make
make PREFIX="$1" install

chmod u+s "$1/usr/bin/Xfbdev"

rm -rf "$1/usr/bin/Xvesa"

# Install minimum requirement for bitmap fonts.
mkdir -p "$1/usr/share/fonts/misc"
cp ./*.pcf.gz fonts.alias fonts.dir "$1/usr/share/fonts/misc"
