#!/bin/sh
set -e

# git-clean -x -d && ./xen-setup && make prefix=/usr CMDLINE_CFLAGS='-O0 -g' -j4 && make install DESTDIR=`pwd`/dist/ prefix=/usr && rsync -a --stats --delete . thule:shadow/qemu-iwj.git/ && rsync -a --stats dist/. root@thule:/

rm -f $target/Makefile
rm -f $target/config.mak
rm -f config-host.mak

if test -f config-host.h; then mv config-host.h config-host.h~; fi

./configure --disable-gcc-check --disable-curses --disable-slirp "$@" --prefix=/usr

target=i386-dm

if [ "x$XEN_ROOT" != x ]; then
	echo "XEN_ROOT=$XEN_ROOT" >>config-host.mak
fi

ln -sf ../Makefile.target $target/Makefile
ln -sf ../xen-config.mak $target/config.mak
cat xen-config-host.mak >>config-host.mak

sed -e 's,qemu,xen/qemu,' config-host.h >config-host.h.new
echo '#include "xen-config-host.h"' >>config-host.h.new

if test -f config-host.h~; then mv config-host.h~ config-host.h; fi
cmp -s config-host.h.new config-host.h || mv config-host.h.new config-host.h
