--- buildcore.mk.orig	2006-04-06 23:01:05.000000000 +0200
+++ buildcore.mk	2006-04-13 19:28:08.000000000 +0200
@@ -37,20 +37,17 @@
 testroot:
 	test "`id -u`" = 0
 
-$(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES)) :: makebuilddir/% : 
-	if [ -n "$(DEB_BUILDDIR_$(cdbs_curpkg))" ]; then \
-	  mkdir -p "$(DEB_BUILDDIR_$(cdbs_curpkg))"; \
-	fi
 makebuilddir:: $(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES))
+makebuilddir $(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES)) :: DEB_BUILDDIR := $(if $(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR))
+makebuilddir $(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES)) ::
 	if [ ! -d "$(DEB_BUILDDIR)" ]; then \
 	  mkdir -p "$(DEB_BUILDDIR)"; \
 	fi
 
 cleanbuilddir:: $(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES))
+cleanbuilddir $(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES)) :: DEB_BUILDDIR := $(if $(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR))
+cleanbuilddir $(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES)) ::
 	-if test "$(DEB_BUILDDIR)" != "$(DEB_SRCDIR)"; then rmdir $(DEB_BUILDDIR); fi
-$(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES)) :: cleanbuilddir/% : 
-	-if test -n "$(DEB_BUILDDIR_$(cdbs_curpkg))" && test "$(DEB_BUILDDIR_$(cdbs_curpkg))" != "$(DEB_SRCDIR)"; then rmdir "$(DEB_BUILDDIR_$(cdbs_curpkg))"; fi
-
 
 # This variable is used by tarball.mk, but we want it here in order to check
 # tarball contents before unpacking.  tarball.mk imports this file anyway.
@@ -282,7 +279,7 @@
 common-install:: common-install-arch common-install-indep
 common-binary:: common-binary-arch common-binary-indep
 
-.PHONY: pre-build apply-patches post-patches common-configure-arch common-configure-indep $(patsubst %,configure/%,$(DEB_ALL_PACKAGES)) build common-build-arch common-build-indep $(patsubst %,build/%,$(DEB_ALL_PACKAGES)) build-arch build-indep clean common-install-arch common-install-indep install-arch install-indep $(patsubst %,install/%,$(DEB_ALL_PACKAGES)) common-binary-arch common-binary-indep $(patsubst %,binary/%,$(DEB_ALL_PACKAGES)) binary-indep binary-arch binary $(DEB_PHONY_RULES)
+.PHONY: pre-build apply-patches post-patches common-configure-arch common-configure-indep $(patsubst %,configure/%,$(DEB_ALL_PACKAGES)) build common-build-arch common-build-indep $(patsubst %,build/%,$(DEB_ALL_PACKAGES)) build-arch build-indep clean common-install-arch common-install-indep install-arch install-indep $(patsubst %,install/%,$(DEB_ALL_PACKAGES)) common-binary-arch common-binary-indep $(patsubst %,binary/%,$(DEB_ALL_PACKAGES)) binary-indep binary-arch binary $(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES)) $(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES)) $(DEB_PHONY_RULES)
 
 # Parallel execution of the cdbs makefile fragments will fail, but
 # this way you can call dpkg-buildpackage with MAKEFLAGS=-j in the
