162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci# =========================================================================== 362306a36Sopenharmony_ci# Kernel configuration targets 462306a36Sopenharmony_ci# These targets are used from top-level makefile 562306a36Sopenharmony_ci 662306a36Sopenharmony_ciifdef KBUILD_KCONFIG 762306a36Sopenharmony_ciKconfig := $(KBUILD_KCONFIG) 862306a36Sopenharmony_cielse 962306a36Sopenharmony_ciKconfig := Kconfig 1062306a36Sopenharmony_ciendif 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciifndef KBUILD_DEFCONFIG 1362306a36Sopenharmony_ciKBUILD_DEFCONFIG := defconfig 1462306a36Sopenharmony_ciendif 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ciifeq ($(quiet),silent_) 1762306a36Sopenharmony_cisilent := -s 1862306a36Sopenharmony_ciendif 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciexport KCONFIG_DEFCONFIG_LIST := 2162306a36Sopenharmony_ciifndef cross_compiling 2262306a36Sopenharmony_cikernel-release := $(shell uname -r) 2362306a36Sopenharmony_ciKCONFIG_DEFCONFIG_LIST += \ 2462306a36Sopenharmony_ci /lib/modules/$(kernel-release)/.config \ 2562306a36Sopenharmony_ci /etc/kernel-config \ 2662306a36Sopenharmony_ci /boot/config-$(kernel-release) 2762306a36Sopenharmony_ciendif 2862306a36Sopenharmony_ciKCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci# We need this, in case the user has it in its environment 3162306a36Sopenharmony_ciunexport CONFIG_ 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciconfig-prog := conf 3462306a36Sopenharmony_cimenuconfig-prog := mconf 3562306a36Sopenharmony_cinconfig-prog := nconf 3662306a36Sopenharmony_cigconfig-prog := gconf 3762306a36Sopenharmony_cixconfig-prog := qconf 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_cidefine config_rule 4062306a36Sopenharmony_ciPHONY += $(1) 4162306a36Sopenharmony_ci$(1): $(obj)/$($(1)-prog) 4262306a36Sopenharmony_ci $(Q)$$< $(silent) $(Kconfig) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciPHONY += build_$(1) 4562306a36Sopenharmony_cibuild_$(1): $(obj)/$($(1)-prog) 4662306a36Sopenharmony_ciendef 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c)))) 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ciPHONY += localmodconfig localyesconfig 5162306a36Sopenharmony_cilocalyesconfig localmodconfig: $(obj)/conf 5262306a36Sopenharmony_ci $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config 5362306a36Sopenharmony_ci $(Q)if [ -f .config ]; then \ 5462306a36Sopenharmony_ci cmp -s .tmp.config .config || \ 5562306a36Sopenharmony_ci (mv -f .config .config.old.1; \ 5662306a36Sopenharmony_ci mv -f .tmp.config .config; \ 5762306a36Sopenharmony_ci $< $(silent) --oldconfig $(Kconfig); \ 5862306a36Sopenharmony_ci mv -f .config.old.1 .config.old) \ 5962306a36Sopenharmony_ci else \ 6062306a36Sopenharmony_ci mv -f .tmp.config .config; \ 6162306a36Sopenharmony_ci $< $(silent) --oldconfig $(Kconfig); \ 6262306a36Sopenharmony_ci fi 6362306a36Sopenharmony_ci $(Q)rm -f .tmp.config 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci# These targets map 1:1 to the commandline options of 'conf' 6662306a36Sopenharmony_ci# 6762306a36Sopenharmony_ci# Note: 6862306a36Sopenharmony_ci# syncconfig has become an internal implementation detail and is now 6962306a36Sopenharmony_ci# deprecated for external use 7062306a36Sopenharmony_cisimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ 7162306a36Sopenharmony_ci alldefconfig randconfig listnewconfig olddefconfig syncconfig \ 7262306a36Sopenharmony_ci helpnewconfig yes2modconfig mod2yesconfig mod2noconfig 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ciPHONY += $(simple-targets) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci$(simple-targets): $(obj)/conf 7762306a36Sopenharmony_ci $(Q)$< $(silent) --$@ $(Kconfig) 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ciPHONY += savedefconfig defconfig 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_cisavedefconfig: $(obj)/conf 8262306a36Sopenharmony_ci $(Q)$< $(silent) --$@=defconfig $(Kconfig) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_cidefconfig: $(obj)/conf 8562306a36Sopenharmony_ciifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) 8662306a36Sopenharmony_ci @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 8762306a36Sopenharmony_ci $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 8862306a36Sopenharmony_cielse 8962306a36Sopenharmony_ci @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" 9062306a36Sopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) 9162306a36Sopenharmony_ciendif 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci%_defconfig: $(obj)/conf 9462306a36Sopenharmony_ci $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ciconfigfiles = $(wildcard $(srctree)/kernel/configs/$(1) $(srctree)/arch/$(SRCARCH)/configs/$(1)) 9762306a36Sopenharmony_ciall-config-fragments = $(call configfiles,*.config) 9862306a36Sopenharmony_ciconfig-fragments = $(call configfiles,$@) 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci%.config: $(obj)/conf 10162306a36Sopenharmony_ci $(if $(config-fragments),, $(error $@ fragment does not exists on this architecture)) 10262306a36Sopenharmony_ci $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(config-fragments) 10362306a36Sopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ciPHONY += tinyconfig 10662306a36Sopenharmony_citinyconfig: 10762306a36Sopenharmony_ci $(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig 10862306a36Sopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile tiny.config 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci# CHECK: -o cache_dir=<path> working? 11162306a36Sopenharmony_ciPHONY += testconfig 11262306a36Sopenharmony_citestconfig: $(obj)/conf 11362306a36Sopenharmony_ci $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 11462306a36Sopenharmony_ci -o cache_dir=$(abspath $(obj)/tests/.cache) \ 11562306a36Sopenharmony_ci $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 11662306a36Sopenharmony_ciclean-files += tests/.cache 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci# Help text used by make help 11962306a36Sopenharmony_cihelp: 12062306a36Sopenharmony_ci @echo 'Configuration targets:' 12162306a36Sopenharmony_ci @echo ' config - Update current config utilising a line-oriented program' 12262306a36Sopenharmony_ci @echo ' nconfig - Update current config utilising a ncurses menu based program' 12362306a36Sopenharmony_ci @echo ' menuconfig - Update current config utilising a menu based program' 12462306a36Sopenharmony_ci @echo ' xconfig - Update current config utilising a Qt based front-end' 12562306a36Sopenharmony_ci @echo ' gconfig - Update current config utilising a GTK+ based front-end' 12662306a36Sopenharmony_ci @echo ' oldconfig - Update current config utilising a provided .config as base' 12762306a36Sopenharmony_ci @echo ' localmodconfig - Update current config disabling modules not loaded' 12862306a36Sopenharmony_ci @echo ' except those preserved by LMC_KEEP environment variable' 12962306a36Sopenharmony_ci @echo ' localyesconfig - Update current config converting local mods to core' 13062306a36Sopenharmony_ci @echo ' except those preserved by LMC_KEEP environment variable' 13162306a36Sopenharmony_ci @echo ' defconfig - New config with default from ARCH supplied defconfig' 13262306a36Sopenharmony_ci @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 13362306a36Sopenharmony_ci @echo ' allnoconfig - New config where all options are answered with no' 13462306a36Sopenharmony_ci @echo ' allyesconfig - New config where all options are accepted with yes' 13562306a36Sopenharmony_ci @echo ' allmodconfig - New config selecting modules when possible' 13662306a36Sopenharmony_ci @echo ' alldefconfig - New config with all symbols set to default' 13762306a36Sopenharmony_ci @echo ' randconfig - New config with random answer to all options' 13862306a36Sopenharmony_ci @echo ' yes2modconfig - Change answers from yes to mod if possible' 13962306a36Sopenharmony_ci @echo ' mod2yesconfig - Change answers from mod to yes if possible' 14062306a36Sopenharmony_ci @echo ' mod2noconfig - Change answers from mod to no if possible' 14162306a36Sopenharmony_ci @echo ' listnewconfig - List new options' 14262306a36Sopenharmony_ci @echo ' helpnewconfig - List new options and help text' 14362306a36Sopenharmony_ci @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' 14462306a36Sopenharmony_ci @echo ' default value without prompting' 14562306a36Sopenharmony_ci @echo ' tinyconfig - Configure the tiniest possible kernel' 14662306a36Sopenharmony_ci @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' 14762306a36Sopenharmony_ci @echo '' 14862306a36Sopenharmony_ci @echo 'Configuration topic targets:' 14962306a36Sopenharmony_ci @$(foreach f, $(all-config-fragments), \ 15062306a36Sopenharmony_ci if help=$$(grep -m1 '^# Help: ' $(f)); then \ 15162306a36Sopenharmony_ci printf ' %-25s - %s\n' '$(notdir $(f))' "$${help#*: }"; \ 15262306a36Sopenharmony_ci fi;) 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci# =========================================================================== 15562306a36Sopenharmony_ci# object files used by all kconfig flavours 15662306a36Sopenharmony_cicommon-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \ 15762306a36Sopenharmony_ci preprocess.o symbol.o util.o 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci$(obj)/lexer.lex.o: $(obj)/parser.tab.h 16062306a36Sopenharmony_ciHOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) 16162306a36Sopenharmony_ciHOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci# conf: Used for defconfig, oldconfig and related targets 16462306a36Sopenharmony_cihostprogs += conf 16562306a36Sopenharmony_ciconf-objs := conf.o $(common-objs) 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci# nconf: Used for the nconfig target based on ncurses 16862306a36Sopenharmony_cihostprogs += nconf 16962306a36Sopenharmony_cinconf-objs := nconf.o nconf.gui.o $(common-objs) 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ciHOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs) 17262306a36Sopenharmony_ciHOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags) 17362306a36Sopenharmony_ciHOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags) 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci$(obj)/nconf: | $(obj)/nconf-libs 17662306a36Sopenharmony_ci$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci# mconf: Used for the menuconfig target based on lxdialog 17962306a36Sopenharmony_cihostprogs += mconf 18062306a36Sopenharmony_cilxdialog := $(addprefix lxdialog/, \ 18162306a36Sopenharmony_ci checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) 18262306a36Sopenharmony_cimconf-objs := mconf.o $(lxdialog) $(common-objs) 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ciHOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs) 18562306a36Sopenharmony_ci$(foreach f, mconf.o $(lxdialog), \ 18662306a36Sopenharmony_ci $(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags))) 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci$(obj)/mconf: | $(obj)/mconf-libs 18962306a36Sopenharmony_ci$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci# qconf: Used for the xconfig target based on Qt 19262306a36Sopenharmony_cihostprogs += qconf 19362306a36Sopenharmony_ciqconf-cxxobjs := qconf.o qconf-moc.o 19462306a36Sopenharmony_ciqconf-objs := images.o $(common-objs) 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ciHOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs) 19762306a36Sopenharmony_ciHOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) 19862306a36Sopenharmony_ciHOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) 19962306a36Sopenharmony_ci$(obj)/qconf: | $(obj)/qconf-libs 20062306a36Sopenharmony_ci$(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ciquiet_cmd_moc = MOC $@ 20362306a36Sopenharmony_ci cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@ 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin 20662306a36Sopenharmony_ci $(call if_changed,moc) 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_citargets += qconf-moc.cc 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci# gconf: Used for the gconfig target based on GTK+ 21162306a36Sopenharmony_cihostprogs += gconf 21262306a36Sopenharmony_cigconf-objs := gconf.o images.o $(common-objs) 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ciHOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs) 21562306a36Sopenharmony_ciHOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags) 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci$(obj)/gconf: | $(obj)/gconf-libs 21862306a36Sopenharmony_ci$(obj)/gconf.o: | $(obj)/gconf-cflags 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci# check if necessary packages are available, and configure build flags 22162306a36Sopenharmony_cicmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin); touch $(obj)/$*conf-bin 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh 22462306a36Sopenharmony_ci $(call cmd,conf_cfg) 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ciclean-files += *conf-cflags *conf-libs *conf-bin 227