From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Date: Thu, 20 Apr 2017 02:10:45 +0000 (+0300)
Subject: build: fix symlinked .config handling
X-Git-Tag: v18.06.0-rc1~3055
X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5bf98b1acc3b6b178f8954c5075a58e1e6a99d6a;p=oweals%2Fopenwrt.git

build: fix symlinked .config handling

When running "make menuconfig" with symlinked .config (e.g. to
env/.config) it renames symlink to .config.old, creates new .config file
and writes updated configuration here.

This breaks the desired workflow when changes in the configuration could
be checked using "scripts/env diff" and commited with
"scripts/env save". Since the env/.config file is not updated.

Fix this issue by exporting KCONFIG_OVERWRITECONFIG=1, which forces
mconf to overwrite the .config content, instead of renaming it and
creating a new file. This variable is set only if .config is a symlink,
otherwise the variable is not exported and the old behaviour is
preserved.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---

diff --git a/include/toplevel.mk b/include/toplevel.mk
index ceafffb3a7..4b63e8ab47 100644
--- a/include/toplevel.mk
+++ b/include/toplevel.mk
@@ -129,7 +129,7 @@ menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
 	if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
 		cp $(HOME)/.openwrt/defconfig .config; \
 	fi
-	$< Config.in
+	[ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; $< Config.in
 
 prepare_kernel_conf: .config FORCE