From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPD27-0001PX-Ox for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:54:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TPD22-0004rT-3d for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:54:39 -0400 Received: from 38.0.169.217.in-addr.arpa ([217.169.0.38]:46565 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPD21-0004pF-Td for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:54:34 -0400 From: Peter Maydell Date: Fri, 19 Oct 2012 14:54:23 +0100 Message-Id: <1350654863-26048-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH] Makefile: Forbid out-of-tree build from a source tree that has been built in List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: patches@linaro.org If we try to do an out-of-tree build but the source tree we're building from has been used in the past for an in-tree build then things will go confusingly wrong. Specifically, some parts of the build process will pull in generated files from the old in-tree build (because SRC_PATH is on the vpath). Diagnose this situation so we can produce a useful error message and tell the user how to fix it (run distclean in the source tree). Signed-off-by: Peter Maydell --- I got bitten by this again the other day so I figured it was worth adding a molly-guard. The check is not perfect (it won't notice if you did a distclean but didn't delete the *-softmmu &c directories, for instance) but it should catch most cases of this user error. Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Makefile b/Makefile index a9c22bf..5094a08 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,17 @@ ifneq ($(wildcard config-host.mak),) # Put the all: rule here so that config-host.mak can contain dependencies. all: include config-host.mak + +# Check that we're not trying to do an out-of-tree build from +# a tree that's been used for an in-tree build. +ifneq ($(realpath $(SRC_PATH)),$(realpath .)) +ifneq ($(wildcard $(SRC_PATH)/config-host.mak),) +$(error This is an out of tree build but your source tree ($(SRC_PATH)) \ +seems to have been used for an in-tree build. You can fix this by running \ +"make distclean && rm -rf *-linux-user *-softmmu" in your source tree) +endif +endif + include $(SRC_PATH)/rules.mak config-host.mak: $(SRC_PATH)/configure @echo $@ is out-of-date, running configure -- 1.7.9.5