-#!/bin/sh -
+#!/bin/bash -
# libguestfs
# Copyright (C) 2009 Red Hat Inc.
#
set -e
set -v
-export AUTOMAKE='automake --foreign'
-autoreconf
-cd daemon
-autoreconf
\ No newline at end of file
+
+mkdir -p daemon/m4
+autoreconf -i
+
+CONFIGUREDIR=.
+
+# Run configure in BUILDDIR if it's set
+if [ ! -z "$BUILDDIR" ]; then
+ mkdir -p $BUILDDIR
+ cd $BUILDDIR
+
+ CONFIGUREDIR=..
+fi
+
+# If no arguments were specified and configure has run before, use the previous
+# arguments
+if [ $# == 0 -a -x ./config.status ]; then
+ ./config.status --recheck
+else
+ $CONFIGUREDIR/configure "$@"
+fi