From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas.monjalon@6wind.com>
Received: from mail-we0-f180.google.com (mail-we0-f180.google.com
 [74.125.82.180]) by dpdk.org (Postfix) with ESMTP id 85B17B0AC
 for <dev@dpdk.org>; Tue, 10 Jun 2014 18:38:02 +0200 (CEST)
Received: by mail-we0-f180.google.com with SMTP id x48so5009134wes.11
 for <dev@dpdk.org>; Tue, 10 Jun 2014 09:38:17 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references;
 bh=f79SFA1t0Ha9z/O01E5Zx5dbcOQCoBD0081nZTexfoE=;
 b=i8Ph9Jirnll2N3wza3sDTn8OJdDU9TY4NmDz/4tKhiAd2Qi0GZHri8AZh4OsFB137X
 YrpwrWw6h/wF0vl021DjWts5LQ9ohLncs/HKw/Tv2ytl6HdxUmBQ+/J6PyrutCnNgAfW
 Hgk1jf57oxU/+dKWHY7v6H3UKue3LMaxQI8Lah5FGbOm7B7s8v6J4Z8qVI80/d2M5F/Y
 w6OlUjGwzSP14L9idgJSsE3M5xdKv1qZ58RGESZO9a8u5wamyeCozP41qcXrzgovKd+M
 OmugAhdGzx+X2qCNXI3/z3V0A1dY5eHEgQctKWZWourzalzMfRSxeSkDfwaXt1joqufY
 Z2aw==
X-Gm-Message-State: ALoCoQkewH8knaCJfI78rNUAfrl2KgUQ2BITkLyg97bAXEqwVstUa3x/ioEgjvlRlq9SmDHj8agn
X-Received: by 10.194.110.71 with SMTP id hy7mr43337550wjb.23.1402418297053;
 Tue, 10 Jun 2014 09:38:17 -0700 (PDT)
Received: from XPS13.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237])
 by mx.google.com with ESMTPSA id na4sm21819085wic.21.2014.06.10.09.38.15
 for <multiple recipients>
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
 Tue, 10 Jun 2014 09:38:16 -0700 (PDT)
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: dev@dpdk.org
Date: Tue, 10 Jun 2014 18:38:03 +0200
Message-Id: <1402418283-21950-1-git-send-email-thomas.monjalon@6wind.com>
X-Mailer: git-send-email 2.0.0
In-Reply-To: <59AF69C657FD0841A61C55336867B5B01AA3475A@IRSMSX103.ger.corp.intel.com>
References: <59AF69C657FD0841A61C55336867B5B01AA3475A@IRSMSX103.ger.corp.intel.com>
Subject: [dpdk-dev] [PATCH v4] mk: allow updates to build config on make
	install
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 10 Jun 2014 16:38:02 -0000

From: Bruce Richardson <bruce.richardson@intel.com>

When running "make config", an additional config.orig file is also
generated, which is intended to hold the original, clean configuration
from the template.
When running make install, we first check if there is no existing
.config file, and run make config if not. If there is a file, we then
check if it's unmodified, in which case we regenerate a new .config to
take account of any possible updates to the template. Finally, in the
case where there is an existing .config file, and it HAS been modified,
we then do a check to see if the template has had further updates, and
throw an error if so. If no updates, we continue with the build using
the existing, user-modified config.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 mk/rte.sdkconfig.mk  |  1 +
 mk/rte.sdkinstall.mk | 12 ++++++++++++
 2 files changed, 13 insertions(+)

changes in v3:
- typos commented by Olivier
- compatibility with old builds without .orig
- prefix and suffix in tmp path
- remove tmp directory if no conflict

changes in v4:
- tmp directory in build directory
- do not remove tmp directory to speed up rebuild

diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index d0692e7..3124dce 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -74,6 +74,7 @@ $(RTE_OUTPUT)/.config: $(RTE_CONFIG_TEMPLATE) FORCE
 		-o $(RTE_OUTPUT)/.config_tmp $(RTE_CONFIG_TEMPLATE) ; \
 		if ! cmp -s $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config; then \
 			cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config ; \
+			cp $(RTE_OUTPUT)/.config_tmp $(RTE_OUTPUT)/.config.orig ; \
 		fi ; \
 		rm -f $(RTE_OUTPUT)/.config_tmp ; \
 	else \
diff --git a/mk/rte.sdkinstall.mk b/mk/rte.sdkinstall.mk
index 24b60cf..8571196 100644
--- a/mk/rte.sdkinstall.mk
+++ b/mk/rte.sdkinstall.mk
@@ -58,6 +58,18 @@ install: $(INSTALL_TARGETS)
 	@echo ================== Installing $*
 	$(Q)if [ ! -f $(BUILD_DIR)/$*/.config ]; then \
 		$(MAKE) config T=$* O=$(BUILD_DIR)/$*; \
+	elif cmp -s $(BUILD_DIR)/$*/.config.orig $(BUILD_DIR)/$*/.config; then \
+		$(MAKE) config T=$* O=$(BUILD_DIR)/$*; \
+	else \
+		if [ -f $(BUILD_DIR)/$*/.config.orig ] ; then \
+			tmp_build=$(BUILD_DIR)/$*/.config.tmp; \
+			$(MAKE) config T=$* O=$$tmp_build; \
+			if ! cmp -s $(BUILD_DIR)/$*/.config.orig $$tmp_build/.config ; then \
+				echo "Conflict: local config and template config have both changed"; \
+				exit 1; \
+			fi; \
+		fi; \
+		echo "Using local configuration"; \
 	fi
 	$(Q)$(MAKE) all O=$(BUILD_DIR)/$*
 
-- 
2.0.0