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 12*dd465996SMasahiro Yamadaifndef KBUILD_DEFCONFIG 13*dd465996SMasahiro YamadaKBUILD_DEFCONFIG := defconfig 14*dd465996SMasahiro Yamadaendif 15*dd465996SMasahiro Yamada 160a1f00a1SMichal Marekifeq ($(quiet),silent_) 170a1f00a1SMichal Mareksilent := -s 180a1f00a1SMichal Marekendif 190a1f00a1SMichal Marek 20b75b0a81SMasahiro Yamadaexport KCONFIG_DEFCONFIG_LIST := 21b75b0a81SMasahiro Yamadaifneq ($(SRCARCH),um) 22b75b0a81SMasahiro Yamadakernel-release := $(shell uname -r) 23b75b0a81SMasahiro YamadaKCONFIG_DEFCONFIG_LIST := \ 24b75b0a81SMasahiro Yamada /lib/modules/$(kernel-release)/.config \ 25b75b0a81SMasahiro Yamada /etc/kernel-config \ 26b75b0a81SMasahiro Yamada /boot/config-$(kernel-release) \ 27b75b0a81SMasahiro Yamada arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) 28b75b0a81SMasahiro Yamadaendif 29b75b0a81SMasahiro Yamada 30c2838e6eSYann E. MORIN# We need this, in case the user has it in its environment 31c2838e6eSYann E. MORINunexport CONFIG_ 32c2838e6eSYann E. MORIN 33f91e46b1SMasahiro Yamadaconfig-prog := conf 34f91e46b1SMasahiro Yamadamenuconfig-prog := mconf 35f91e46b1SMasahiro Yamadanconfig-prog := nconf 36f91e46b1SMasahiro Yamadagconfig-prog := gconf 37f91e46b1SMasahiro Yamadaxconfig-prog := qconf 381da177e4SLinus Torvalds 39f91e46b1SMasahiro Yamadadefine config_rule 40f91e46b1SMasahiro YamadaPHONY += $(1) 41f91e46b1SMasahiro Yamada$(1): $(obj)/$($(1)-prog) 42f91e46b1SMasahiro Yamada $(Q)$$< $(silent) $(Kconfig) 431da177e4SLinus Torvalds 44f91e46b1SMasahiro YamadaPHONY += build_$(1) 45f91e46b1SMasahiro Yamadabuild_$(1): $(obj)/$($(1)-prog) 46f91e46b1SMasahiro Yamadaendef 471da177e4SLinus Torvalds 48f91e46b1SMasahiro Yamada$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c)))) 491da177e4SLinus Torvalds 50f91e46b1SMasahiro YamadaPHONY += localmodconfig localyesconfig 512a616258SUlf Magnussonlocalyesconfig localmodconfig: $(obj)/conf 52c8138a57SMasahiro Yamada $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config 53a7c02602SSteven Rostedt $(Q)if [ -f .config ]; then \ 54a7c02602SSteven Rostedt cmp -s .tmp.config .config || \ 5503fa25daSSteven Rostedt (mv -f .config .config.old.1; \ 5603fa25daSSteven Rostedt mv -f .tmp.config .config; \ 572a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 58a7c02602SSteven Rostedt mv -f .config.old.1 .config.old) \ 59a7c02602SSteven Rostedt else \ 60a7c02602SSteven Rostedt mv -f .tmp.config .config; \ 612a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 62a7c02602SSteven Rostedt fi 6303fa25daSSteven Rostedt $(Q)rm -f .tmp.config 6403fa25daSSteven Rostedt 651cba0c30SMichal Marek# These targets map 1:1 to the commandline options of 'conf' 6679123b13SMasahiro Yamada# 6779123b13SMasahiro Yamada# Note: 6879123b13SMasahiro Yamada# syncconfig has become an internal implementation detail and is now 6979123b13SMasahiro Yamada# deprecated for external use 701cba0c30SMichal Mareksimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ 715d8b42aaSLaura Abbott alldefconfig randconfig listnewconfig olddefconfig syncconfig \ 7289b90609STetsuo Handa helpnewconfig yes2modconfig mod2yesconfig 735d8b42aaSLaura Abbott 741cba0c30SMichal MarekPHONY += $(simple-targets) 751da177e4SLinus Torvalds 761cba0c30SMichal Marek$(simple-targets): $(obj)/conf 7723cd88c9SMasahiro Yamada $(Q)$< $(silent) --$@ $(Kconfig) 781da177e4SLinus Torvalds 790085b419SMasahiro YamadaPHONY += savedefconfig defconfig 80911a91c3SMasahiro Yamada 817cf3d73bSSam Ravnborgsavedefconfig: $(obj)/conf 8223cd88c9SMasahiro Yamada $(Q)$< $(silent) --$@=defconfig $(Kconfig) 837cf3d73bSSam Ravnborg 841da177e4SLinus Torvaldsdefconfig: $(obj)/conf 85e0a26686SMasahiro Yamadaifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) 860a1f00a1SMichal Marek @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 870a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 88d2036f30SMichael Ellermanelse 89d2036f30SMichael Ellerman @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" 90d2036f30SMichael Ellerman $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) 911da177e4SLinus Torvaldsendif 921da177e4SLinus Torvalds 931da177e4SLinus Torvalds%_defconfig: $(obj)/conf 940a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 951da177e4SLinus Torvalds 9663a91033SMasahiro Yamadaconfigfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) 973aaefce1SJosh Triplett 9863a91033SMasahiro Yamada%.config: $(obj)/conf 9963a91033SMasahiro Yamada $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) 10063a91033SMasahiro Yamada $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) 1013266c806SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 1023aaefce1SJosh Triplett 1030da1d4a0SJosh TriplettPHONY += tinyconfig 10463a91033SMasahiro Yamadatinyconfig: 10563a91033SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config 1060da1d4a0SJosh Triplett 107022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working? 108022a4bf6SMasahiro YamadaPHONY += testconfig 109022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf 11023cd88c9SMasahiro Yamada $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 111022a4bf6SMasahiro Yamada -o cache_dir=$(abspath $(obj)/tests/.cache) \ 112022a4bf6SMasahiro Yamada $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 1131634f2bfSMasahiro Yamadaclean-files += tests/.cache 114022a4bf6SMasahiro Yamada 1151da177e4SLinus Torvalds# Help text used by make help 1161da177e4SLinus Torvaldshelp: 1171da177e4SLinus Torvalds @echo ' config - Update current config utilising a line-oriented program' 118bb6d83ddSPetr Vorel @echo ' nconfig - Update current config utilising a ncurses menu based program' 1191da177e4SLinus Torvalds @echo ' menuconfig - Update current config utilising a menu based program' 120092373c2SDiego Viola @echo ' xconfig - Update current config utilising a Qt based front-end' 12139c3f1baSDiego Viola @echo ' gconfig - Update current config utilising a GTK+ based front-end' 1221da177e4SLinus Torvalds @echo ' oldconfig - Update current config utilising a provided .config as base' 12303fa25daSSteven Rostedt @echo ' localmodconfig - Update current config disabling modules not loaded' 124c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 125281c9dadSSteven Rostedt @echo ' localyesconfig - Update current config converting local mods to core' 126c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 1270748cb3eSSam Ravnborg @echo ' defconfig - New config with default from ARCH supplied defconfig' 1287cf3d73bSSam Ravnborg @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 129e11f0496SJesper Juhl @echo ' allnoconfig - New config where all options are answered with no' 1300748cb3eSSam Ravnborg @echo ' allyesconfig - New config where all options are accepted with yes' 1310748cb3eSSam Ravnborg @echo ' allmodconfig - New config selecting modules when possible' 1320748cb3eSSam Ravnborg @echo ' alldefconfig - New config with all symbols set to default' 1330748cb3eSSam Ravnborg @echo ' randconfig - New config with random answer to all options' 13489b90609STetsuo Handa @echo ' yes2modconfig - Change answers from yes to mod if possible' 13589b90609STetsuo Handa @echo ' mod2yesconfig - Change answers from mod to yes if possible' 136861b4ea4SSam Ravnborg @echo ' listnewconfig - List new options' 1375d8b42aaSLaura Abbott @echo ' helpnewconfig - List new options and help text' 138cedd55d4SMarc Herbert @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' 139cedd55d4SMarc Herbert @echo ' default value without prompting' 1400da1d4a0SJosh Triplett @echo ' tinyconfig - Configure the tiniest possible kernel' 141d6a0c8a1SPetr Vorel @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' 1421da177e4SLinus Torvalds 1431da177e4SLinus Torvalds# =========================================================================== 1441da177e4SLinus Torvalds# object files used by all kconfig flavours 145769a1c02SMasahiro Yamadacommon-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \ 146521b29b6SMasahiro Yamada symbol.o util.o 1471da177e4SLinus Torvalds 148769a1c02SMasahiro Yamada$(obj)/lexer.lex.o: $(obj)/parser.tab.h 1499cc342f6SMasahiro YamadaHOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) 1509cc342f6SMasahiro YamadaHOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) 1511da177e4SLinus Torvalds 152558e78e3SMasahiro Yamada# conf: Used for defconfig, oldconfig and related targets 1535f2fb52fSMasahiro Yamadahostprogs += conf 154558e78e3SMasahiro Yamadaconf-objs := conf.o $(common-objs) 155558e78e3SMasahiro Yamada 1561c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses 1575f2fb52fSMasahiro Yamadahostprogs += nconf 158558e78e3SMasahiro Yamadanconf-objs := nconf.o nconf.gui.o $(common-objs) 1597080e47bSArnaud Lacombe 160d86271afSMasahiro YamadaHOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) 161d86271afSMasahiro YamadaHOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) 162d86271afSMasahiro YamadaHOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) 1631c5af5cfSMasahiro Yamada 164d86271afSMasahiro Yamada$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg 1651c5af5cfSMasahiro Yamada 1661c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog 1675f2fb52fSMasahiro Yamadahostprogs += mconf 16854b8ae66SMasahiro Yamadalxdialog := $(addprefix lxdialog/, \ 16954b8ae66SMasahiro Yamada checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) 17054b8ae66SMasahiro Yamadamconf-objs := mconf.o $(lxdialog) $(common-objs) 1711c5af5cfSMasahiro Yamada 172d86271afSMasahiro YamadaHOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) 1731c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \ 174d86271afSMasahiro Yamada $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) 1751c5af5cfSMasahiro Yamada 17654b8ae66SMasahiro Yamada$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg 1771da177e4SLinus Torvalds 1780b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt 1795f2fb52fSMasahiro Yamadahostprogs += qconf 1800e912c03SMasahiro Yamadaqconf-cxxobjs := qconf.o qconf-moc.o 1813b541978SMasahiro Yamadaqconf-objs := images.o $(common-objs) 1821da177e4SLinus Torvalds 183d86271afSMasahiro YamadaHOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) 184d86271afSMasahiro YamadaHOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) 1850e912c03SMasahiro YamadaHOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) 1860b669a50SMasahiro Yamada 1870e912c03SMasahiro Yamada$(obj)/qconf.o: $(obj)/qconf-cfg 1880b669a50SMasahiro Yamada 1890b669a50SMasahiro Yamadaquiet_cmd_moc = MOC $@ 1900e912c03SMasahiro Yamada cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ 1910b669a50SMasahiro Yamada 1920e912c03SMasahiro Yamada$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE 193c3cd7cfaSMasahiro Yamada $(call if_changed,moc) 194c3cd7cfaSMasahiro Yamada 1950e912c03SMasahiro Yamadatargets += qconf-moc.cc 1961da177e4SLinus Torvalds 197b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+ 1985f2fb52fSMasahiro Yamadahostprogs += gconf 1993b541978SMasahiro Yamadagconf-objs := gconf.o images.o $(common-objs) 2001da177e4SLinus Torvalds 201d86271afSMasahiro YamadaHOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs) 202d86271afSMasahiro YamadaHOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags) 2031da177e4SLinus Torvalds 204d86271afSMasahiro Yamada$(obj)/gconf.o: $(obj)/gconf-cfg 2051da177e4SLinus Torvalds 2060b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags 207ba97df45SMasahiro Yamadafilechk_conf_cfg = $(CONFIG_SHELL) $< 2080b669a50SMasahiro Yamada 209d86271afSMasahiro Yamada$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE 2100b669a50SMasahiro Yamada $(call filechk,conf_cfg) 2110b669a50SMasahiro Yamada 2122648ca18SMasahiro Yamadaclean-files += *conf-cfg 213