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 12dd465996SMasahiro Yamadaifndef KBUILD_DEFCONFIG 13dd465996SMasahiro YamadaKBUILD_DEFCONFIG := defconfig 14dd465996SMasahiro Yamadaendif 15dd465996SMasahiro Yamada 160a1f00a1SMichal Marekifeq ($(quiet),silent_) 170a1f00a1SMichal Mareksilent := -s 180a1f00a1SMichal Marekendif 190a1f00a1SMichal Marek 20b75b0a81SMasahiro Yamadaexport KCONFIG_DEFCONFIG_LIST := 21f02aa48dSMasahiro Yamadaifndef cross_compiling 22b75b0a81SMasahiro Yamadakernel-release := $(shell uname -r) 23f02aa48dSMasahiro YamadaKCONFIG_DEFCONFIG_LIST += \ 24b75b0a81SMasahiro Yamada /lib/modules/$(kernel-release)/.config \ 25b75b0a81SMasahiro Yamada /etc/kernel-config \ 26f02aa48dSMasahiro Yamada /boot/config-$(kernel-release) 27b75b0a81SMasahiro Yamadaendif 28f02aa48dSMasahiro YamadaKCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) 29b75b0a81SMasahiro Yamada 30*92ef432fSMasahiro Yamadaifneq ($(findstring c, $(KBUILD_EXTRA_WARN)),) 31*92ef432fSMasahiro Yamadaexport KCONFIG_WARN_UNKNOWN_SYMBOLS=1 32*92ef432fSMasahiro Yamadaendif 33*92ef432fSMasahiro Yamada 34*92ef432fSMasahiro Yamadaifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),) 35*92ef432fSMasahiro Yamadaexport KCONFIG_WERROR=1 36*92ef432fSMasahiro Yamadaendif 37*92ef432fSMasahiro Yamada 38c2838e6eSYann E. MORIN# We need this, in case the user has it in its environment 39c2838e6eSYann E. MORINunexport CONFIG_ 40c2838e6eSYann E. MORIN 41f91e46b1SMasahiro Yamadaconfig-prog := conf 42f91e46b1SMasahiro Yamadamenuconfig-prog := mconf 43f91e46b1SMasahiro Yamadanconfig-prog := nconf 44f91e46b1SMasahiro Yamadagconfig-prog := gconf 45f91e46b1SMasahiro Yamadaxconfig-prog := qconf 461da177e4SLinus Torvalds 47f91e46b1SMasahiro Yamadadefine config_rule 48f91e46b1SMasahiro YamadaPHONY += $(1) 49f91e46b1SMasahiro Yamada$(1): $(obj)/$($(1)-prog) 50f91e46b1SMasahiro Yamada $(Q)$$< $(silent) $(Kconfig) 511da177e4SLinus Torvalds 52f91e46b1SMasahiro YamadaPHONY += build_$(1) 53f91e46b1SMasahiro Yamadabuild_$(1): $(obj)/$($(1)-prog) 54f91e46b1SMasahiro Yamadaendef 551da177e4SLinus Torvalds 56f91e46b1SMasahiro Yamada$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c)))) 571da177e4SLinus Torvalds 58f91e46b1SMasahiro YamadaPHONY += localmodconfig localyesconfig 592a616258SUlf Magnussonlocalyesconfig localmodconfig: $(obj)/conf 60c8138a57SMasahiro Yamada $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config 61a7c02602SSteven Rostedt $(Q)if [ -f .config ]; then \ 62a7c02602SSteven Rostedt cmp -s .tmp.config .config || \ 6303fa25daSSteven Rostedt (mv -f .config .config.old.1; \ 6403fa25daSSteven Rostedt mv -f .tmp.config .config; \ 652a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 66a7c02602SSteven Rostedt mv -f .config.old.1 .config.old) \ 67a7c02602SSteven Rostedt else \ 68a7c02602SSteven Rostedt mv -f .tmp.config .config; \ 692a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 70a7c02602SSteven Rostedt fi 7103fa25daSSteven Rostedt $(Q)rm -f .tmp.config 7203fa25daSSteven Rostedt 731cba0c30SMichal Marek# These targets map 1:1 to the commandline options of 'conf' 7479123b13SMasahiro Yamada# 7579123b13SMasahiro Yamada# Note: 7679123b13SMasahiro Yamada# syncconfig has become an internal implementation detail and is now 7779123b13SMasahiro Yamada# deprecated for external use 781cba0c30SMichal Mareksimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ 795d8b42aaSLaura Abbott alldefconfig randconfig listnewconfig olddefconfig syncconfig \ 80c39afe62SJosh Triplett helpnewconfig yes2modconfig mod2yesconfig mod2noconfig 815d8b42aaSLaura Abbott 821cba0c30SMichal MarekPHONY += $(simple-targets) 831da177e4SLinus Torvalds 841cba0c30SMichal Marek$(simple-targets): $(obj)/conf 8523cd88c9SMasahiro Yamada $(Q)$< $(silent) --$@ $(Kconfig) 861da177e4SLinus Torvalds 870085b419SMasahiro YamadaPHONY += savedefconfig defconfig 88911a91c3SMasahiro Yamada 897cf3d73bSSam Ravnborgsavedefconfig: $(obj)/conf 9023cd88c9SMasahiro Yamada $(Q)$< $(silent) --$@=defconfig $(Kconfig) 917cf3d73bSSam Ravnborg 921da177e4SLinus Torvaldsdefconfig: $(obj)/conf 93e0a26686SMasahiro Yamadaifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) 940a1f00a1SMichal Marek @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 950a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 96d2036f30SMichael Ellermanelse 97d2036f30SMichael Ellerman @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" 98d2036f30SMichael Ellerman $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) 991da177e4SLinus Torvaldsendif 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds%_defconfig: $(obj)/conf 1020a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 1031da177e4SLinus Torvalds 104feec5e1fSKees Cookconfigfiles = $(wildcard $(srctree)/kernel/configs/$(1) $(srctree)/arch/$(SRCARCH)/configs/$(1)) 105feec5e1fSKees Cookall-config-fragments = $(call configfiles,*.config) 106feec5e1fSKees Cookconfig-fragments = $(call configfiles,$@) 1073aaefce1SJosh Triplett 10863a91033SMasahiro Yamada%.config: $(obj)/conf 109feec5e1fSKees Cook $(if $(config-fragments),, $(error $@ fragment does not exists on this architecture)) 110feec5e1fSKees Cook $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(config-fragments) 1113266c806SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 1123aaefce1SJosh Triplett 1130da1d4a0SJosh TriplettPHONY += tinyconfig 11463a91033SMasahiro Yamadatinyconfig: 115f8f0d064SMasahiro Yamada $(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig 116f8f0d064SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile tiny.config 1170da1d4a0SJosh Triplett 118022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working? 119022a4bf6SMasahiro YamadaPHONY += testconfig 120022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf 12123cd88c9SMasahiro Yamada $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 122022a4bf6SMasahiro Yamada -o cache_dir=$(abspath $(obj)/tests/.cache) \ 123022a4bf6SMasahiro Yamada $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 1241634f2bfSMasahiro Yamadaclean-files += tests/.cache 125022a4bf6SMasahiro Yamada 1261da177e4SLinus Torvalds# Help text used by make help 1271da177e4SLinus Torvaldshelp: 128feec5e1fSKees Cook @echo 'Configuration targets:' 1291da177e4SLinus Torvalds @echo ' config - Update current config utilising a line-oriented program' 130bb6d83ddSPetr Vorel @echo ' nconfig - Update current config utilising a ncurses menu based program' 1311da177e4SLinus Torvalds @echo ' menuconfig - Update current config utilising a menu based program' 132092373c2SDiego Viola @echo ' xconfig - Update current config utilising a Qt based front-end' 13339c3f1baSDiego Viola @echo ' gconfig - Update current config utilising a GTK+ based front-end' 1341da177e4SLinus Torvalds @echo ' oldconfig - Update current config utilising a provided .config as base' 13503fa25daSSteven Rostedt @echo ' localmodconfig - Update current config disabling modules not loaded' 136c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 137281c9dadSSteven Rostedt @echo ' localyesconfig - Update current config converting local mods to core' 138c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 1390748cb3eSSam Ravnborg @echo ' defconfig - New config with default from ARCH supplied defconfig' 1407cf3d73bSSam Ravnborg @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 141e11f0496SJesper Juhl @echo ' allnoconfig - New config where all options are answered with no' 1420748cb3eSSam Ravnborg @echo ' allyesconfig - New config where all options are accepted with yes' 1430748cb3eSSam Ravnborg @echo ' allmodconfig - New config selecting modules when possible' 1440748cb3eSSam Ravnborg @echo ' alldefconfig - New config with all symbols set to default' 1450748cb3eSSam Ravnborg @echo ' randconfig - New config with random answer to all options' 14689b90609STetsuo Handa @echo ' yes2modconfig - Change answers from yes to mod if possible' 14789b90609STetsuo Handa @echo ' mod2yesconfig - Change answers from mod to yes if possible' 148c39afe62SJosh Triplett @echo ' mod2noconfig - Change answers from mod to no if possible' 149861b4ea4SSam Ravnborg @echo ' listnewconfig - List new options' 1505d8b42aaSLaura Abbott @echo ' helpnewconfig - List new options and help text' 151cedd55d4SMarc Herbert @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' 152cedd55d4SMarc Herbert @echo ' default value without prompting' 1530da1d4a0SJosh Triplett @echo ' tinyconfig - Configure the tiniest possible kernel' 154d6a0c8a1SPetr Vorel @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' 155feec5e1fSKees Cook @echo '' 156feec5e1fSKees Cook @echo 'Configuration topic targets:' 157feec5e1fSKees Cook @$(foreach f, $(all-config-fragments), \ 158feec5e1fSKees Cook if help=$$(grep -m1 '^# Help: ' $(f)); then \ 159feec5e1fSKees Cook printf ' %-25s - %s\n' '$(notdir $(f))' "$${help#*: }"; \ 160feec5e1fSKees Cook fi;) 1611da177e4SLinus Torvalds 1621da177e4SLinus Torvalds# =========================================================================== 1631da177e4SLinus Torvalds# object files used by all kconfig flavours 164a77a05dcSMasahiro Yamadacommon-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \ 165a77a05dcSMasahiro Yamada preprocess.o symbol.o util.o 1661da177e4SLinus Torvalds 167769a1c02SMasahiro Yamada$(obj)/lexer.lex.o: $(obj)/parser.tab.h 1689cc342f6SMasahiro YamadaHOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) 1699cc342f6SMasahiro YamadaHOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) 1701da177e4SLinus Torvalds 171558e78e3SMasahiro Yamada# conf: Used for defconfig, oldconfig and related targets 1725f2fb52fSMasahiro Yamadahostprogs += conf 173558e78e3SMasahiro Yamadaconf-objs := conf.o $(common-objs) 174558e78e3SMasahiro Yamada 1751c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses 1765f2fb52fSMasahiro Yamadahostprogs += nconf 177558e78e3SMasahiro Yamadanconf-objs := nconf.o nconf.gui.o $(common-objs) 1787080e47bSArnaud Lacombe 1793122c844SMasahiro YamadaHOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs) 1803122c844SMasahiro YamadaHOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags) 1813122c844SMasahiro YamadaHOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags) 1821c5af5cfSMasahiro Yamada 1833122c844SMasahiro Yamada$(obj)/nconf: | $(obj)/nconf-libs 1843122c844SMasahiro Yamada$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags 1851c5af5cfSMasahiro Yamada 1861c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog 1875f2fb52fSMasahiro Yamadahostprogs += mconf 18854b8ae66SMasahiro Yamadalxdialog := $(addprefix lxdialog/, \ 18954b8ae66SMasahiro Yamada checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) 19054b8ae66SMasahiro Yamadamconf-objs := mconf.o $(lxdialog) $(common-objs) 1911c5af5cfSMasahiro Yamada 1923122c844SMasahiro YamadaHOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs) 1931c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \ 1943122c844SMasahiro Yamada $(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags))) 1951c5af5cfSMasahiro Yamada 1963122c844SMasahiro Yamada$(obj)/mconf: | $(obj)/mconf-libs 1973122c844SMasahiro Yamada$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags 1981da177e4SLinus Torvalds 1990b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt 2005f2fb52fSMasahiro Yamadahostprogs += qconf 2010e912c03SMasahiro Yamadaqconf-cxxobjs := qconf.o qconf-moc.o 2023b541978SMasahiro Yamadaqconf-objs := images.o $(common-objs) 2031da177e4SLinus Torvalds 2043122c844SMasahiro YamadaHOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs) 2053122c844SMasahiro YamadaHOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) 2063122c844SMasahiro YamadaHOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) 2073122c844SMasahiro Yamada$(obj)/qconf: | $(obj)/qconf-libs 2083122c844SMasahiro Yamada$(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags 2090b669a50SMasahiro Yamada 2100b669a50SMasahiro Yamadaquiet_cmd_moc = MOC $@ 2113122c844SMasahiro Yamada cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@ 2120b669a50SMasahiro Yamada 2133122c844SMasahiro Yamada$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin 214c3cd7cfaSMasahiro Yamada $(call if_changed,moc) 215c3cd7cfaSMasahiro Yamada 2160e912c03SMasahiro Yamadatargets += qconf-moc.cc 2171da177e4SLinus Torvalds 218b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+ 2195f2fb52fSMasahiro Yamadahostprogs += gconf 2203b541978SMasahiro Yamadagconf-objs := gconf.o images.o $(common-objs) 2211da177e4SLinus Torvalds 2223122c844SMasahiro YamadaHOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs) 2233122c844SMasahiro YamadaHOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags) 2241da177e4SLinus Torvalds 2253122c844SMasahiro Yamada$(obj)/gconf: | $(obj)/gconf-libs 2263122c844SMasahiro Yamada$(obj)/gconf.o: | $(obj)/gconf-cflags 2271da177e4SLinus Torvalds 2280b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags 229aedee9e8SPeter Foleycmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin); touch $(obj)/$*conf-bin 2300b669a50SMasahiro Yamada 2313122c844SMasahiro Yamada$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh 2323122c844SMasahiro Yamada $(call cmd,conf_cfg) 2330b669a50SMasahiro Yamada 2343122c844SMasahiro Yamadaclean-files += *conf-cflags *conf-libs *conf-bin 235