1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 21da177e4SLinus Torvalds# =========================================================================== 31da177e4SLinus Torvalds# Kernel configuration targets 41da177e4SLinus Torvalds# These targets are used from top-level makefile 51da177e4SLinus Torvalds 661bee204SAl Viroifdef KBUILD_KCONFIG 761bee204SAl ViroKconfig := $(KBUILD_KCONFIG) 861bee204SAl Viroelse 9838a2e55SArnaud LacombeKconfig := Kconfig 1061bee204SAl Viroendif 11e703f75dSSam Ravnborg 120a1f00a1SMichal Marekifeq ($(quiet),silent_) 130a1f00a1SMichal Mareksilent := -s 140a1f00a1SMichal Marekendif 150a1f00a1SMichal Marek 16*b75b0a81SMasahiro Yamadaexport KCONFIG_DEFCONFIG_LIST := 17*b75b0a81SMasahiro Yamadaifneq ($(SRCARCH),um) 18*b75b0a81SMasahiro Yamadakernel-release := $(shell uname -r) 19*b75b0a81SMasahiro YamadaKCONFIG_DEFCONFIG_LIST := \ 20*b75b0a81SMasahiro Yamada /lib/modules/$(kernel-release)/.config \ 21*b75b0a81SMasahiro Yamada /etc/kernel-config \ 22*b75b0a81SMasahiro Yamada /boot/config-$(kernel-release) \ 23*b75b0a81SMasahiro Yamada arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) 24*b75b0a81SMasahiro Yamadaendif 25*b75b0a81SMasahiro Yamada 26c2838e6eSYann E. MORIN# We need this, in case the user has it in its environment 27c2838e6eSYann E. MORINunexport CONFIG_ 28c2838e6eSYann E. MORIN 29f91e46b1SMasahiro Yamadaconfig-prog := conf 30f91e46b1SMasahiro Yamadamenuconfig-prog := mconf 31f91e46b1SMasahiro Yamadanconfig-prog := nconf 32f91e46b1SMasahiro Yamadagconfig-prog := gconf 33f91e46b1SMasahiro Yamadaxconfig-prog := qconf 341da177e4SLinus Torvalds 35f91e46b1SMasahiro Yamadadefine config_rule 36f91e46b1SMasahiro YamadaPHONY += $(1) 37f91e46b1SMasahiro Yamada$(1): $(obj)/$($(1)-prog) 38f91e46b1SMasahiro Yamada $(Q)$$< $(silent) $(Kconfig) 391da177e4SLinus Torvalds 40f91e46b1SMasahiro YamadaPHONY += build_$(1) 41f91e46b1SMasahiro Yamadabuild_$(1): $(obj)/$($(1)-prog) 42f91e46b1SMasahiro Yamadaendef 431da177e4SLinus Torvalds 44f91e46b1SMasahiro Yamada$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c)))) 451da177e4SLinus Torvalds 46f91e46b1SMasahiro YamadaPHONY += localmodconfig localyesconfig 472a616258SUlf Magnussonlocalyesconfig localmodconfig: $(obj)/conf 48c8138a57SMasahiro Yamada $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config 49a7c02602SSteven Rostedt $(Q)if [ -f .config ]; then \ 50a7c02602SSteven Rostedt cmp -s .tmp.config .config || \ 5103fa25daSSteven Rostedt (mv -f .config .config.old.1; \ 5203fa25daSSteven Rostedt mv -f .tmp.config .config; \ 532a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 54a7c02602SSteven Rostedt mv -f .config.old.1 .config.old) \ 55a7c02602SSteven Rostedt else \ 56a7c02602SSteven Rostedt mv -f .tmp.config .config; \ 572a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 58a7c02602SSteven Rostedt fi 5903fa25daSSteven Rostedt $(Q)rm -f .tmp.config 6003fa25daSSteven Rostedt 611cba0c30SMichal Marek# These targets map 1:1 to the commandline options of 'conf' 6279123b13SMasahiro Yamada# 6379123b13SMasahiro Yamada# Note: 6479123b13SMasahiro Yamada# syncconfig has become an internal implementation detail and is now 6579123b13SMasahiro Yamada# deprecated for external use 661cba0c30SMichal Mareksimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ 675d8b42aaSLaura Abbott alldefconfig randconfig listnewconfig olddefconfig syncconfig \ 6889b90609STetsuo Handa helpnewconfig yes2modconfig mod2yesconfig 695d8b42aaSLaura Abbott 701cba0c30SMichal MarekPHONY += $(simple-targets) 711da177e4SLinus Torvalds 721cba0c30SMichal Marek$(simple-targets): $(obj)/conf 7323cd88c9SMasahiro Yamada $(Q)$< $(silent) --$@ $(Kconfig) 741da177e4SLinus Torvalds 750085b419SMasahiro YamadaPHONY += savedefconfig defconfig 76911a91c3SMasahiro Yamada 777cf3d73bSSam Ravnborgsavedefconfig: $(obj)/conf 7823cd88c9SMasahiro Yamada $(Q)$< $(silent) --$@=defconfig $(Kconfig) 797cf3d73bSSam Ravnborg 801da177e4SLinus Torvaldsdefconfig: $(obj)/conf 81e0a26686SMasahiro Yamadaifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) 820a1f00a1SMichal Marek @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 830a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 84d2036f30SMichael Ellermanelse 85d2036f30SMichael Ellerman @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" 86d2036f30SMichael Ellerman $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) 871da177e4SLinus Torvaldsendif 881da177e4SLinus Torvalds 891da177e4SLinus Torvalds%_defconfig: $(obj)/conf 900a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 911da177e4SLinus Torvalds 9263a91033SMasahiro Yamadaconfigfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) 933aaefce1SJosh Triplett 9463a91033SMasahiro Yamada%.config: $(obj)/conf 9563a91033SMasahiro Yamada $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) 9663a91033SMasahiro Yamada $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) 973266c806SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 983aaefce1SJosh Triplett 990da1d4a0SJosh TriplettPHONY += tinyconfig 10063a91033SMasahiro Yamadatinyconfig: 10163a91033SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config 1020da1d4a0SJosh Triplett 103022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working? 104022a4bf6SMasahiro YamadaPHONY += testconfig 105022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf 10623cd88c9SMasahiro Yamada $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 107022a4bf6SMasahiro Yamada -o cache_dir=$(abspath $(obj)/tests/.cache) \ 108022a4bf6SMasahiro Yamada $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 1091634f2bfSMasahiro Yamadaclean-files += tests/.cache 110022a4bf6SMasahiro Yamada 1111da177e4SLinus Torvalds# Help text used by make help 1121da177e4SLinus Torvaldshelp: 1131da177e4SLinus Torvalds @echo ' config - Update current config utilising a line-oriented program' 114bb6d83ddSPetr Vorel @echo ' nconfig - Update current config utilising a ncurses menu based program' 1151da177e4SLinus Torvalds @echo ' menuconfig - Update current config utilising a menu based program' 116092373c2SDiego Viola @echo ' xconfig - Update current config utilising a Qt based front-end' 11739c3f1baSDiego Viola @echo ' gconfig - Update current config utilising a GTK+ based front-end' 1181da177e4SLinus Torvalds @echo ' oldconfig - Update current config utilising a provided .config as base' 11903fa25daSSteven Rostedt @echo ' localmodconfig - Update current config disabling modules not loaded' 120c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 121281c9dadSSteven Rostedt @echo ' localyesconfig - Update current config converting local mods to core' 122c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 1230748cb3eSSam Ravnborg @echo ' defconfig - New config with default from ARCH supplied defconfig' 1247cf3d73bSSam Ravnborg @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 125e11f0496SJesper Juhl @echo ' allnoconfig - New config where all options are answered with no' 1260748cb3eSSam Ravnborg @echo ' allyesconfig - New config where all options are accepted with yes' 1270748cb3eSSam Ravnborg @echo ' allmodconfig - New config selecting modules when possible' 1280748cb3eSSam Ravnborg @echo ' alldefconfig - New config with all symbols set to default' 1290748cb3eSSam Ravnborg @echo ' randconfig - New config with random answer to all options' 13089b90609STetsuo Handa @echo ' yes2modconfig - Change answers from yes to mod if possible' 13189b90609STetsuo Handa @echo ' mod2yesconfig - Change answers from mod to yes if possible' 132861b4ea4SSam Ravnborg @echo ' listnewconfig - List new options' 1335d8b42aaSLaura Abbott @echo ' helpnewconfig - List new options and help text' 134cedd55d4SMarc Herbert @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' 135cedd55d4SMarc Herbert @echo ' default value without prompting' 1360da1d4a0SJosh Triplett @echo ' tinyconfig - Configure the tiniest possible kernel' 137d6a0c8a1SPetr Vorel @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' 1381da177e4SLinus Torvalds 1391da177e4SLinus Torvalds# =========================================================================== 1401da177e4SLinus Torvalds# object files used by all kconfig flavours 141769a1c02SMasahiro Yamadacommon-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \ 142521b29b6SMasahiro Yamada symbol.o util.o 1431da177e4SLinus Torvalds 144769a1c02SMasahiro Yamada$(obj)/lexer.lex.o: $(obj)/parser.tab.h 1459cc342f6SMasahiro YamadaHOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) 1469cc342f6SMasahiro YamadaHOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) 1471da177e4SLinus Torvalds 148558e78e3SMasahiro Yamada# conf: Used for defconfig, oldconfig and related targets 1495f2fb52fSMasahiro Yamadahostprogs += conf 150558e78e3SMasahiro Yamadaconf-objs := conf.o $(common-objs) 151558e78e3SMasahiro Yamada 1521c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses 1535f2fb52fSMasahiro Yamadahostprogs += nconf 154558e78e3SMasahiro Yamadanconf-objs := nconf.o nconf.gui.o $(common-objs) 1557080e47bSArnaud Lacombe 156d86271afSMasahiro YamadaHOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) 157d86271afSMasahiro YamadaHOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) 158d86271afSMasahiro YamadaHOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) 1591c5af5cfSMasahiro Yamada 160d86271afSMasahiro Yamada$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg 1611c5af5cfSMasahiro Yamada 1621c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog 1635f2fb52fSMasahiro Yamadahostprogs += mconf 16454b8ae66SMasahiro Yamadalxdialog := $(addprefix lxdialog/, \ 16554b8ae66SMasahiro Yamada checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) 16654b8ae66SMasahiro Yamadamconf-objs := mconf.o $(lxdialog) $(common-objs) 1671c5af5cfSMasahiro Yamada 168d86271afSMasahiro YamadaHOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) 1691c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \ 170d86271afSMasahiro Yamada $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) 1711c5af5cfSMasahiro Yamada 17254b8ae66SMasahiro Yamada$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg 1731da177e4SLinus Torvalds 1740b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt 1755f2fb52fSMasahiro Yamadahostprogs += qconf 1760e912c03SMasahiro Yamadaqconf-cxxobjs := qconf.o qconf-moc.o 1773b541978SMasahiro Yamadaqconf-objs := images.o $(common-objs) 1781da177e4SLinus Torvalds 179d86271afSMasahiro YamadaHOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) 180d86271afSMasahiro YamadaHOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) 1810e912c03SMasahiro YamadaHOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) 1820b669a50SMasahiro Yamada 1830e912c03SMasahiro Yamada$(obj)/qconf.o: $(obj)/qconf-cfg 1840b669a50SMasahiro Yamada 1850b669a50SMasahiro Yamadaquiet_cmd_moc = MOC $@ 1860e912c03SMasahiro Yamada cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ 1870b669a50SMasahiro Yamada 1880e912c03SMasahiro Yamada$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE 189c3cd7cfaSMasahiro Yamada $(call if_changed,moc) 190c3cd7cfaSMasahiro Yamada 1910e912c03SMasahiro Yamadatargets += qconf-moc.cc 1921da177e4SLinus Torvalds 193b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+ 1945f2fb52fSMasahiro Yamadahostprogs += gconf 1953b541978SMasahiro Yamadagconf-objs := gconf.o images.o $(common-objs) 1961da177e4SLinus Torvalds 197d86271afSMasahiro YamadaHOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs) 198d86271afSMasahiro YamadaHOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags) 1991da177e4SLinus Torvalds 200d86271afSMasahiro Yamada$(obj)/gconf.o: $(obj)/gconf-cfg 2011da177e4SLinus Torvalds 2020b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags 203ba97df45SMasahiro Yamadafilechk_conf_cfg = $(CONFIG_SHELL) $< 2040b669a50SMasahiro Yamada 205d86271afSMasahiro Yamada$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE 2060b669a50SMasahiro Yamada $(call filechk,conf_cfg) 2070b669a50SMasahiro Yamada 2082648ca18SMasahiro Yamadaclean-files += *conf-cfg 209