build: new fixes for symlinked .config handling

When running "make {config|defconfig|oldconfig}" with symlinked .config
(e.g. to env/.config) it renames symlink to .config.old, creates new
.config file, and writes the updated configuration into it.

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

The things become even worse when working with feeds, since feeds script
quite often silently invokes "make {oldconfig|defconfig}" and breaks the
symlink.

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.

This change uses the same behaviour as "make menucofig", which has
already been fixed in commit 5bf98b1acc.

Also make a tiny cosmetic update to the "make menuconfig" target code
layout to make it look like other config handling targets.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
This commit is contained in:
Sergey Ryazanov 2017-05-07 20:19:13 +03:00 committed by Jo-Philipp Wich
parent 44da45a881
commit e06d8f0f6f

View file

@ -107,6 +107,7 @@ scripts/config/conf:
@$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC_WRAPPER)" @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC_WRAPPER)"
config: scripts/config/conf prepare-tmpinfo FORCE config: scripts/config/conf prepare-tmpinfo FORCE
[ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
$< Config.in $< Config.in
config-clean: FORCE config-clean: FORCE
@ -115,6 +116,7 @@ config-clean: FORCE
defconfig: scripts/config/conf prepare-tmpinfo FORCE defconfig: scripts/config/conf prepare-tmpinfo FORCE
touch .config touch .config
@if [ ! -s .config -a -e $(HOME)/.openwrt/defconfig ]; then cp $(HOME)/.openwrt/defconfig .config; fi @if [ ! -s .config -a -e $(HOME)/.openwrt/defconfig ]; then cp $(HOME)/.openwrt/defconfig .config; fi
[ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
$< --defconfig=.config Config.in $< --defconfig=.config Config.in
confdefault-y=allyes confdefault-y=allyes
@ -123,13 +125,15 @@ confdefault-n=allno
confdefault:=$(confdefault-$(CONFDEFAULT)) confdefault:=$(confdefault-$(CONFDEFAULT))
oldconfig: scripts/config/conf prepare-tmpinfo FORCE oldconfig: scripts/config/conf prepare-tmpinfo FORCE
[ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
$< --$(if $(confdefault),$(confdefault),old)config Config.in $< --$(if $(confdefault),$(confdefault),old)config Config.in
menuconfig: scripts/config/mconf prepare-tmpinfo FORCE menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \ if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
cp $(HOME)/.openwrt/defconfig .config; \ cp $(HOME)/.openwrt/defconfig .config; \
fi fi
[ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; $< Config.in [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
$< Config.in
prepare_kernel_conf: .config FORCE prepare_kernel_conf: .config FORCE