set -e
-TEMPDIR=`mktemp -d /tmp/nmh-test-XXXXXXXX`
-echo $TEMPDIR > test-temp-dir
+if TEMPDIR="`cat test-temp-dir 2>/dev/null`" \
+ && [ -f "$TEMPDIR/build/Makefile" ]; then
+ (cd "$TEMPDIR/build" && make all install)
+ exit
+fi
+
+TEMPDIR="`mktemp -d /tmp/mmh-test-XXXXXXXX`"
+echo "$TEMPDIR" >test-temp-dir
cd ..
-autoheader && autoconf && date > stamp-h.in
-./configure --prefix=$TEMPDIR --with-locking=fcntl --enable-debug
-make clean
-make install
+srcdir="$PWD"
+if [ ! -f configure ]; then
+ ./autogen.sh
+fi
+if [ -f Makefile ]; then
+ make -s clean
+fi
-echo "Path: $TEMPDIR/Mail" > $TEMPDIR/mh_profile
+mkdir "$TEMPDIR/build"
+cd "$TEMPDIR/build"
+"$srcdir/configure" -q --prefix="$TEMPDIR" --enable-debug
+make -s all install