@@ -66,6 +66,7 @@ lib_dir=$(src_dir)/lib
6666core_dir =$(src_dir ) /core
6767platforms_dir =$(src_dir ) /platform
6868configs_dir =$(cur_dir ) /configs
69+ config_repo_arg: =$(filter command environment,$(origin CONFIG_REPO ) )
6970CONFIG_REPO? =$(configs_dir )
7071scripts_dir: =$(cur_dir ) /scripts
7172ci_dir: =$(cur_dir ) /ci
@@ -193,15 +194,16 @@ seed_plat_defconfig=$(wildcard $(platform_dir)/defconfig)
193194seed_config_defconfig =$(strip $(if $(filter-out $(CONFIG_REPO ) ,$(config_dir ) ) , \
194195 $(wildcard $(config_dir ) /defconfig) ) )
195196seed_defconfigs =$(seed_plat_defconfig ) $(seed_config_defconfig )
196- seed_config_src_arg =$(if $(config_src ) ,--config-src $(abspath $(config_src ) ) )
197+ seed_config_src_arg =$(if $(CONFIG ) ,--config-src $(CONFIG ) ) \
198+ $(if $(config_repo_arg ) ,--config-repo $(CONFIG_REPO ) )
197199seed_defconfig_args =\
198200 $(if $(seed_plat_defconfig ) ,--platform-defconfig $(seed_plat_defconfig ) ) \
199201 $(if $(seed_config_defconfig ) ,--config-defconfig $(seed_config_defconfig ) ) \
200202 $(seed_config_src_arg )
201203
202204$(kconfig_file ) :
203205 $(if $(PLATFORM ) ,,$(error No configuration in $(build_dir ) : pass \
204- PLATFORM= and CONFIG=, or run make \
206+ PLATFORM= and CONFIG= for a classic build , or run make \
205207 $(if $(default_o ) ,,O=$(O ) ) < platform> _defconfig first))
206208 @echo " Seeding config $( patsubst $( cur_dir) /%,%, $@ ) "
207209 @mkdir -p $(dir $@ )
@@ -247,28 +249,57 @@ endif
247249ifneq ($(strip $(build_targets ) $(filter listconfig,$(targets ) ) ) ,)
248250-include $(kconfig_auto_conf )
249251
252+ # A missing or out-of-date auto.conf is about to be (re)generated, after
253+ # which make restarts: validation against its values only runs once it is
254+ # current, never against stale ones
255+ kconfig_auto_stale: =$(if $(wildcard $(kconfig_auto_conf ) ) ,$(shell \
256+ test $(kconfig_file ) -nt $(kconfig_auto_conf ) && echo y) ,y)
257+
250258ifneq ($(O ) ,)
251- # In the O= workflow the .config owns the platform and the VM configuration.
252- # PLATFORM= must then agree with it and CONFIG= overrides the configuration
253- # source for this invocation only. The checks are skipped while auto.conf is
254- # still being (re)generated; make restarts with the resolved values
259+ # In the O= workflow the .config owns the platform and the VM configuration
255260PLATFORM: =$(CONFIG_PLATFORM )
256- ifneq ($(wildcard $( kconfig_auto_conf ) ) ,)
261+ ifeq ($(kconfig_auto_stale ) ,)
257262ifneq ($(PLATFORM ) ,)
258263ifeq ($(wildcard $(platform_dir ) ) ,)
259264 $(error Target platform $(PLATFORM) is not supported)
260265endif
261266endif
262267ifeq ($(config_src ) ,)
263- config_src: =$(CONFIG_CONFIG_SRC )
264- config_dir: =$(patsubst % /,% ,$(dir $(config_src ) ) )
265- ifeq ($(notdir $(config_src ) ) ,config.c)
268+ config_spec: =$(CONFIG_CONFIG_SRC )
269+ config_repo: =$(strip $(if $(config_repo_arg ) ,$(CONFIG_REPO ) , \
270+ $(if $(CONFIG_CONFIG_REPO ) ,$(CONFIG_CONFIG_REPO ) ,$(configs_dir ) ) ) )
271+ ifneq ($(build_targets ) ,)
272+ ifeq ($(config_spec ) ,)
273+ $(error No VM configuration set in $(kconfig_file ) : set it via menuconfig)
274+ endif
275+ endif
276+ # The stored configuration is a name looked up in the repository, a
277+ # configuration folder, or a config.c path
278+ ifeq ($(findstring /,$(config_spec ) ) ,)
279+ config_src: =$(wildcard $(config_repo ) /$(config_spec ) .c)
280+ ifeq ($(config_src ) ,)
281+ config_dir: =$(config_repo ) /$(config_spec )
282+ -include $(config_dir ) /config.mk
283+ ifeq ($(config_src ) ,)
284+ config_src: =$(wildcard $(config_dir ) /config.c)
285+ endif
286+ else
287+ config_dir: =$(config_repo )
288+ endif
289+ else ifeq ($(filter %.c,$(config_spec)),)
290+ config_dir: =$(patsubst % /,% ,$(config_spec ) )
266291-include $(config_dir ) /config.mk
292+ ifeq ($(config_src ) ,)
293+ config_src: =$(wildcard $(config_dir ) /config.c)
294+ endif
295+ else
296+ config_src: =$(config_spec )
297+ config_dir: =$(patsubst % /,% ,$(dir $(config_spec ) ) )
267298endif
268299endif
269300ifneq ($(build_targets ) ,)
270- ifeq ($(config_src ) ,)
271- $(error No VM configuration : pass CONFIG= or set CONFIG_SRC in menuconfig )
301+ ifeq ($(wildcard $( config_src ) ) ,)
302+ $(error VM configuration $(if $(config_spec),$(config_spec),$( CONFIG)) not found )
272303endif
273304endif
274305endif
@@ -584,11 +615,11 @@ endif
584615# Configuration frontends operating on this build's .config
585616
586617.PHONY : menuconfig
587- menuconfig : $(if $(O ) ,$( if $( PLATFORM ) , $( kconfig_file ) ) ,$(kconfig_file ) )
618+ menuconfig : $(if $(O ) ,,$(kconfig_file ) )
588619 @$(kconfig_env ) python3 $(kconfig_tool ) menuconfig
589620
590621.PHONY : listconfig
591- listconfig : $(kconfig_file )
622+ listconfig : $(if $( O ) ,, $( kconfig_file ) )
592623 @$(kconfig_env ) python3 $(kconfig_tool ) list $(seed_defconfig_args )
593624
594625# Seed the build's .config without building
0 commit comments