1# SPDX-License-Identifier: GPL-2.0 2# =========================================================================== 3# Kernel configuration targets 4# These targets are used from top-level makefile 5 6PHONY += xconfig gconfig menuconfig config syncconfig \ 7 localmodconfig localyesconfig 8 9ifdef KBUILD_KCONFIG 10Kconfig := $(KBUILD_KCONFIG) 11else 12Kconfig := Kconfig 13endif 14 15ifeq ($(quiet),silent_) 16silent := -s 17endif 18 19# We need this, in case the user has it in its environment 20unexport CONFIG_ 21 22xconfig: $(obj)/qconf 23 $< $(silent) $(Kconfig) 24 25gconfig: $(obj)/gconf 26 $< $(silent) $(Kconfig) 27 28menuconfig: $(obj)/mconf 29 $< $(silent) $(Kconfig) 30 31config: $(obj)/conf 32 $< $(silent) --oldaskconfig $(Kconfig) 33 34nconfig: $(obj)/nconf 35 $< $(silent) $(Kconfig) 36 37# This has become an internal implementation detail and is now deprecated 38# for external use. 39syncconfig: $(obj)/conf 40 $(Q)mkdir -p include/config include/generated 41 $< $(silent) --$@ $(Kconfig) 42 43localyesconfig localmodconfig: $(obj)/conf 44 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config 45 $(Q)if [ -f .config ]; then \ 46 cmp -s .tmp.config .config || \ 47 (mv -f .config .config.old.1; \ 48 mv -f .tmp.config .config; \ 49 $< $(silent) --oldconfig $(Kconfig); \ 50 mv -f .config.old.1 .config.old) \ 51 else \ 52 mv -f .tmp.config .config; \ 53 $< $(silent) --oldconfig $(Kconfig); \ 54 fi 55 $(Q)rm -f .tmp.config 56 57# These targets map 1:1 to the commandline options of 'conf' 58simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ 59 alldefconfig randconfig listnewconfig olddefconfig 60PHONY += $(simple-targets) 61 62$(simple-targets): $(obj)/conf 63 $< $(silent) --$@ $(Kconfig) 64 65PHONY += oldnoconfig silentoldconfig savedefconfig defconfig 66 67# oldnoconfig is an alias of olddefconfig, because people already are dependent 68# on its behavior (sets new symbols to their default value but not 'n') with the 69# counter-intuitive name. 70oldnoconfig: olddefconfig 71 @echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19" 72 @echo " Please use \"olddefconfig\" instead, which is an alias." 73 74# We do not expect manual invokcation of "silentoldcofig" (or "syncconfig"). 75silentoldconfig: syncconfig 76 @echo " WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\"" 77 @echo " and is now an internal implementation detail." 78 @echo " What you want is probably \"oldconfig\"." 79 @echo " \"silentoldconfig\" will be removed after Linux 4.19" 80 81savedefconfig: $(obj)/conf 82 $< $(silent) --$@=defconfig $(Kconfig) 83 84defconfig: $(obj)/conf 85ifeq ($(KBUILD_DEFCONFIG),) 86 $< $(silent) --defconfig $(Kconfig) 87else 88ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) 89 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 90 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 91else 92 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" 93 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) 94endif 95endif 96 97%_defconfig: $(obj)/conf 98 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 99 100configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) 101 102%.config: $(obj)/conf 103 $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) 104 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) 105 +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig 106 107PHONY += kvmconfig 108kvmconfig: kvm_guest.config 109 @: 110 111PHONY += xenconfig 112xenconfig: xen.config 113 @: 114 115PHONY += tinyconfig 116tinyconfig: 117 $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config 118 119# CHECK: -o cache_dir=<path> working? 120PHONY += testconfig 121testconfig: $(obj)/conf 122 $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 123 -o cache_dir=$(abspath $(obj)/tests/.cache) \ 124 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 125clean-dirs += tests/.cache 126 127# Help text used by make help 128help: 129 @echo ' config - Update current config utilising a line-oriented program' 130 @echo ' nconfig - Update current config utilising a ncurses menu based program' 131 @echo ' menuconfig - Update current config utilising a menu based program' 132 @echo ' xconfig - Update current config utilising a Qt based front-end' 133 @echo ' gconfig - Update current config utilising a GTK+ based front-end' 134 @echo ' oldconfig - Update current config utilising a provided .config as base' 135 @echo ' localmodconfig - Update current config disabling modules not loaded' 136 @echo ' localyesconfig - Update current config converting local mods to core' 137 @echo ' defconfig - New config with default from ARCH supplied defconfig' 138 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 139 @echo ' allnoconfig - New config where all options are answered with no' 140 @echo ' allyesconfig - New config where all options are accepted with yes' 141 @echo ' allmodconfig - New config selecting modules when possible' 142 @echo ' alldefconfig - New config with all symbols set to default' 143 @echo ' randconfig - New config with random answer to all options' 144 @echo ' listnewconfig - List new options' 145 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' 146 @echo ' default value without prompting' 147 @echo ' kvmconfig - Enable additional options for kvm guest kernel support' 148 @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' 149 @echo ' tinyconfig - Configure the tiniest possible kernel' 150 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' 151 152# =========================================================================== 153# Shared Makefile for the various kconfig executables: 154# conf: Used for defconfig, oldconfig and related targets 155# object files used by all kconfig flavours 156 157conf-objs := conf.o zconf.tab.o 158 159hostprogs-y := conf 160 161targets += zconf.lex.c 162 163# generated files seem to need this to find local include files 164HOSTCFLAGS_zconf.lex.o := -I$(src) 165HOSTCFLAGS_zconf.tab.o := -I$(src) 166 167# nconf: Used for the nconfig target based on ncurses 168hostprogs-y += nconf 169nconf-objs := nconf.o zconf.tab.o nconf.gui.o 170 171HOSTLOADLIBES_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs) 172HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags) 173HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags) 174 175$(obj)/nconf.o: $(obj)/.nconf-cfg 176 177# mconf: Used for the menuconfig target based on lxdialog 178hostprogs-y += mconf 179lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o 180mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog)) 181 182HOSTLOADLIBES_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs) 183$(foreach f, mconf.o $(lxdialog), \ 184 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags))) 185 186$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/.mconf-cfg 187 188# qconf: Used for the xconfig target based on Qt 189hostprogs-y += qconf 190qconf-cxxobjs := qconf.o 191qconf-objs := zconf.tab.o 192 193HOSTLOADLIBES_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs) 194HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags) 195 196$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc 197 198quiet_cmd_moc = MOC $@ 199 cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@ 200 201$(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg 202 $(call cmd,moc) 203 204# gconf: Used for the gconfig target based on GTK+ 205hostprogs-y += gconf 206gconf-objs := gconf.o zconf.tab.o 207 208HOSTLOADLIBES_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs) 209HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags) 210 211$(obj)/gconf.o: $(obj)/.gconf-cfg 212 213$(obj)/zconf.tab.o: $(obj)/zconf.lex.c 214 215# check if necessary packages are available, and configure build flags 216define filechk_conf_cfg 217 $(CONFIG_SHELL) $(srctree)/scripts/kconfig/check-pkgconfig.sh; \ 218 $(CONFIG_SHELL) $< 219endef 220 221$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE 222 $(call filechk,conf_cfg) 223 224clean-files += .*conf-cfg 225