diff --git a/Makefile b/Makefile
index 71d68847a737e92b01416f9599497e2b22093a01..0c224041f38f424beac0939db0bab58a41b22cd4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 #
-# $Id: Makefile,v 1.6 1999/03/09 14:41:38 mast Exp $
+# $Id: Makefile,v 1.7 1999/04/29 09:37:45 mast Exp $
 #
 # Meta Makefile
 #
@@ -11,22 +11,28 @@ OS=`uname -srm|sed -e 's/ /-/g'|tr '[A-Z]' '[a-z]'|tr '/' '_'`
 BUILDDIR=build/$(OS)
 METATARGET=
 
+# Use this to pass arguments to configure. Leave empty to keep previous args.
+CONFIGUREARGS=
+
 # Used to avoid make compatibility problems.
 BIN_TRUE=":"
 
 all: bin/pike compile
 	-@$(BIN_TRUE)
 
+force:
+	-@$(BIN_TRUE)
+
 src/configure: src/configure.in
 	cd src && ./run_autoconfig . 2>&1 | grep -v warning
-	-@(cd "$(BUILDDIR)" && rm -f Makefile .prefix-h)
+	-@(cd "$(BUILDDIR)" 2>/dev/null && rm -f Makefile .configureargs || :)
 
 force_configure:
 	cd src && ./run_autoconfig . 2>&1 | grep -v warning
+	-@(cd "$(BUILDDIR)" 2>/dev/null && rm -f Makefile .configureargs || :)
 
-configure: src/configure
+builddir:
 	@builddir="$(BUILDDIR)"; \
-	srcdir=`pwd`/src; \
 	( \
 	  IFS='/'; dir=""; \
 	  for d in $$builddir; do \
@@ -34,13 +40,28 @@ configure: src/configure
 	    test -z "$$dir" -o -d "$$dir" || mkdir "$$dir" || exit 1; \
 	    dir="$$dir/"; \
 	  done \
-	) && \
-	cd "$$builddir" && \
-	if test -f Makefile -a -f .prefix-h && test "`cat .prefix-h`" = "$(prefix)"; then :; else \
-	  echo Running "$$srcdir"/configure in "$$builddir"; \
-	  CONFIG_SITE=x "$$srcdir"/configure --prefix=$(prefix) $(CONFIGFLAGS) && \
-	  ( echo "$(prefix)" > .prefix-h; rm -f main.o; :; ) \
-	fi
+	)
+
+configure: src/configure builddir
+	@builddir="$(BUILDDIR)"; \
+	srcdir=`pwd`/src; \
+	cd "$$builddir" && ( \
+	  if test -f .configureargs -a -z "$(CONFIGUREARGS)"; then \
+	    configureargs="`cat .configureargs`"; \
+	  else \
+	    configureargs="--prefix=$(prefix) $(CONFIGUREARGS)"; \
+	  fi; \
+	  if test -f Makefile -a -f config.cache -a -f .configureargs && \
+	     test "`cat .configureargs`" = "$$configureargs"; then :; \
+	  else \
+	    echo Running "$$srcdir"/configure $$configureargs in "$$builddir"; \
+	    CONFIG_SITE=x "$$srcdir"/configure $$configureargs && ( \
+	      echo "$$configureargs" > .configureargs; \
+	      $(MAKE) clean > /dev/null; \
+	      : \
+	    ) \
+	  fi \
+	)
 
 compile: configure
 	@builddir="$(BUILDDIR)"; \
@@ -52,9 +73,6 @@ compile: configure
 	  $(MAKE) all $$metatarget || ( test -f remake && $(MAKE) all $$metatarget ) \
 	)
 
-force:
-	-@$(BIN_TRUE)
-
 bin/pike: force
 	sed -e "s|\"BASEDIR\"|\"`pwd`\"|" < bin/pike.in > bin/pike
 	chmod a+x bin/pike