From patchwork Fri Oct 19 13:54:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 12375 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A992A23EFE for ; Fri, 19 Oct 2012 13:54:29 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 16D6CA18C54 for ; Fri, 19 Oct 2012 13:54:28 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so603911iej.11 for ; Fri, 19 Oct 2012 06:54:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=8ftw+lLy/U+RzlR6KvEZi0V9RHBBEC5+9hmQ55UsbwA=; b=YVuhqZX3BDPyxIdrtQAhK77NUJsQmEu1U9GsFwFt7jLvMIAF4hspV+jtKp8OjN4l1E PA9a0QM6Pfsn6R14EgwHOffeYo1U+1tCuLjsVBIIH13zRxvJavWec9PduJ80GPAsiKnR FUWDHF/Zd3WczVFoQpH/IvDSOq6q/91xSEqqlLFmMvK6DWj271G4g2K4d7+DgfQ55Lv5 f8wXBBuqEKQizA2bs31WXP8Nd0vLS+U9CrnujmcoAP7xLgKlYxjKzMw1mKbG7aJwEANW lYqzbsSoUW40chKvPxuV5Eq/6Ahyo4ObMCylOSOuCFfUv0OTf0P+PGiIwGrWX2a1ku16 eL6g== Received: by 10.50.152.137 with SMTP id uy9mr1305731igb.62.1350654868548; Fri, 19 Oct 2012 06:54:28 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp90821igt; Fri, 19 Oct 2012 06:54:27 -0700 (PDT) Received: by 10.180.87.42 with SMTP id u10mr3509496wiz.0.1350654867061; Fri, 19 Oct 2012 06:54:27 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id p8si1931550weo.43.2012.10.19.06.54.26 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 06:54:27 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1TPD1r-0006mZ-TN; Fri, 19 Oct 2012 14:54:23 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH] Makefile: Forbid out-of-tree build from a source tree that has been built in Date: Fri, 19 Oct 2012 14:54:23 +0100 Message-Id: <1350654863-26048-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-Gm-Message-State: ALoCoQkBXkVfih10E3RNes03rgSuyrm1uLk6+XHxnxmRZz/iqZa1W6kM1Kg08pExRa6AaM5fHJaL 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