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 16c2838e6eSYann E. MORIN# We need this, in case the user has it in its environment 17c2838e6eSYann E. MORINunexport CONFIG_ 18c2838e6eSYann E. MORIN 19*f91e46b1SMasahiro Yamadaconfig-prog := conf 20*f91e46b1SMasahiro Yamadamenuconfig-prog := mconf 21*f91e46b1SMasahiro Yamadanconfig-prog := nconf 22*f91e46b1SMasahiro Yamadagconfig-prog := gconf 23*f91e46b1SMasahiro Yamadaxconfig-prog := qconf 241da177e4SLinus Torvalds 25*f91e46b1SMasahiro Yamadadefine config_rule 26*f91e46b1SMasahiro YamadaPHONY += $(1) 27*f91e46b1SMasahiro Yamada$(1): $(obj)/$($(1)-prog) 28*f91e46b1SMasahiro Yamada $(Q)$$< $(silent) $(Kconfig) 291da177e4SLinus Torvalds 30*f91e46b1SMasahiro YamadaPHONY += build_$(1) 31*f91e46b1SMasahiro Yamadabuild_$(1): $(obj)/$($(1)-prog) 32*f91e46b1SMasahiro Yamadaendef 331da177e4SLinus Torvalds 34*f91e46b1SMasahiro Yamada$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c)))) 351da177e4SLinus Torvalds 36*f91e46b1SMasahiro YamadaPHONY += localmodconfig localyesconfig 372a616258SUlf Magnussonlocalyesconfig localmodconfig: $(obj)/conf 38c8138a57SMasahiro Yamada $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config 39a7c02602SSteven Rostedt $(Q)if [ -f .config ]; then \ 40a7c02602SSteven Rostedt cmp -s .tmp.config .config || \ 4103fa25daSSteven Rostedt (mv -f .config .config.old.1; \ 4203fa25daSSteven Rostedt mv -f .tmp.config .config; \ 432a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 44a7c02602SSteven Rostedt mv -f .config.old.1 .config.old) \ 45a7c02602SSteven Rostedt else \ 46a7c02602SSteven Rostedt mv -f .tmp.config .config; \ 472a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 48a7c02602SSteven Rostedt fi 4903fa25daSSteven Rostedt $(Q)rm -f .tmp.config 5003fa25daSSteven Rostedt 511cba0c30SMichal Marek# These targets map 1:1 to the commandline options of 'conf' 5279123b13SMasahiro Yamada# 5379123b13SMasahiro Yamada# Note: 5479123b13SMasahiro Yamada# syncconfig has become an internal implementation detail and is now 5579123b13SMasahiro Yamada# deprecated for external use 561cba0c30SMichal Mareksimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ 575d8b42aaSLaura Abbott alldefconfig randconfig listnewconfig olddefconfig syncconfig \ 5889b90609STetsuo Handa helpnewconfig yes2modconfig mod2yesconfig 595d8b42aaSLaura Abbott 601cba0c30SMichal MarekPHONY += $(simple-targets) 611da177e4SLinus Torvalds 621cba0c30SMichal Marek$(simple-targets): $(obj)/conf 6323cd88c9SMasahiro Yamada $(Q)$< $(silent) --$@ $(Kconfig) 641da177e4SLinus Torvalds 650085b419SMasahiro YamadaPHONY += savedefconfig defconfig 66911a91c3SMasahiro Yamada 677cf3d73bSSam Ravnborgsavedefconfig: $(obj)/conf 6823cd88c9SMasahiro Yamada $(Q)$< $(silent) --$@=defconfig $(Kconfig) 697cf3d73bSSam Ravnborg 701da177e4SLinus Torvaldsdefconfig: $(obj)/conf 71e0a26686SMasahiro Yamadaifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) 720a1f00a1SMichal Marek @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 730a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 74d2036f30SMichael Ellermanelse 75d2036f30SMichael Ellerman @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" 76d2036f30SMichael Ellerman $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) 771da177e4SLinus Torvaldsendif 781da177e4SLinus Torvalds 791da177e4SLinus Torvalds%_defconfig: $(obj)/conf 800a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 811da177e4SLinus Torvalds 8263a91033SMasahiro Yamadaconfigfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) 833aaefce1SJosh Triplett 8463a91033SMasahiro Yamada%.config: $(obj)/conf 8563a91033SMasahiro Yamada $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) 8663a91033SMasahiro Yamada $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) 873266c806SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 883aaefce1SJosh Triplett 890da1d4a0SJosh TriplettPHONY += tinyconfig 9063a91033SMasahiro Yamadatinyconfig: 9163a91033SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config 920da1d4a0SJosh Triplett 93022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working? 94022a4bf6SMasahiro YamadaPHONY += testconfig 95022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf 9623cd88c9SMasahiro Yamada $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 97022a4bf6SMasahiro Yamada -o cache_dir=$(abspath $(obj)/tests/.cache) \ 98022a4bf6SMasahiro Yamada $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 991634f2bfSMasahiro Yamadaclean-files += tests/.cache 100022a4bf6SMasahiro Yamada 1011da177e4SLinus Torvalds# Help text used by make help 1021da177e4SLinus Torvaldshelp: 1031da177e4SLinus Torvalds @echo ' config - Update current config utilising a line-oriented program' 104bb6d83ddSPetr Vorel @echo ' nconfig - Update current config utilising a ncurses menu based program' 1051da177e4SLinus Torvalds @echo ' menuconfig - Update current config utilising a menu based program' 106092373c2SDiego Viola @echo ' xconfig - Update current config utilising a Qt based front-end' 10739c3f1baSDiego Viola @echo ' gconfig - Update current config utilising a GTK+ based front-end' 1081da177e4SLinus Torvalds @echo ' oldconfig - Update current config utilising a provided .config as base' 10903fa25daSSteven Rostedt @echo ' localmodconfig - Update current config disabling modules not loaded' 110c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 111281c9dadSSteven Rostedt @echo ' localyesconfig - Update current config converting local mods to core' 112c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 1130748cb3eSSam Ravnborg @echo ' defconfig - New config with default from ARCH supplied defconfig' 1147cf3d73bSSam Ravnborg @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 115e11f0496SJesper Juhl @echo ' allnoconfig - New config where all options are answered with no' 1160748cb3eSSam Ravnborg @echo ' allyesconfig - New config where all options are accepted with yes' 1170748cb3eSSam Ravnborg @echo ' allmodconfig - New config selecting modules when possible' 1180748cb3eSSam Ravnborg @echo ' alldefconfig - New config with all symbols set to default' 1190748cb3eSSam Ravnborg @echo ' randconfig - New config with random answer to all options' 12089b90609STetsuo Handa @echo ' yes2modconfig - Change answers from yes to mod if possible' 12189b90609STetsuo Handa @echo ' mod2yesconfig - Change answers from mod to yes if possible' 122861b4ea4SSam Ravnborg @echo ' listnewconfig - List new options' 1235d8b42aaSLaura Abbott @echo ' helpnewconfig - List new options and help text' 124cedd55d4SMarc Herbert @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' 125cedd55d4SMarc Herbert @echo ' default value without prompting' 1260da1d4a0SJosh Triplett @echo ' tinyconfig - Configure the tiniest possible kernel' 127d6a0c8a1SPetr Vorel @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' 1281da177e4SLinus Torvalds 1291da177e4SLinus Torvalds# =========================================================================== 1301da177e4SLinus Torvalds# object files used by all kconfig flavours 131769a1c02SMasahiro Yamadacommon-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \ 132521b29b6SMasahiro Yamada symbol.o util.o 1331da177e4SLinus Torvalds 134769a1c02SMasahiro Yamada$(obj)/lexer.lex.o: $(obj)/parser.tab.h 1359cc342f6SMasahiro YamadaHOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) 1369cc342f6SMasahiro YamadaHOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) 1371da177e4SLinus Torvalds 138558e78e3SMasahiro Yamada# conf: Used for defconfig, oldconfig and related targets 1395f2fb52fSMasahiro Yamadahostprogs += conf 140558e78e3SMasahiro Yamadaconf-objs := conf.o $(common-objs) 141558e78e3SMasahiro Yamada 1421c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses 1435f2fb52fSMasahiro Yamadahostprogs += nconf 144558e78e3SMasahiro Yamadanconf-objs := nconf.o nconf.gui.o $(common-objs) 1457080e47bSArnaud Lacombe 146d86271afSMasahiro YamadaHOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) 147d86271afSMasahiro YamadaHOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) 148d86271afSMasahiro YamadaHOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) 1491c5af5cfSMasahiro Yamada 150d86271afSMasahiro Yamada$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg 1511c5af5cfSMasahiro Yamada 1521c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog 1535f2fb52fSMasahiro Yamadahostprogs += mconf 15454b8ae66SMasahiro Yamadalxdialog := $(addprefix lxdialog/, \ 15554b8ae66SMasahiro Yamada checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) 15654b8ae66SMasahiro Yamadamconf-objs := mconf.o $(lxdialog) $(common-objs) 1571c5af5cfSMasahiro Yamada 158d86271afSMasahiro YamadaHOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) 1591c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \ 160d86271afSMasahiro Yamada $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) 1611c5af5cfSMasahiro Yamada 16254b8ae66SMasahiro Yamada$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg 1631da177e4SLinus Torvalds 1640b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt 1655f2fb52fSMasahiro Yamadahostprogs += qconf 1660e912c03SMasahiro Yamadaqconf-cxxobjs := qconf.o qconf-moc.o 1673b541978SMasahiro Yamadaqconf-objs := images.o $(common-objs) 1681da177e4SLinus Torvalds 169d86271afSMasahiro YamadaHOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) 170d86271afSMasahiro YamadaHOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) 1710e912c03SMasahiro YamadaHOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) 1720b669a50SMasahiro Yamada 1730e912c03SMasahiro Yamada$(obj)/qconf.o: $(obj)/qconf-cfg 1740b669a50SMasahiro Yamada 1750b669a50SMasahiro Yamadaquiet_cmd_moc = MOC $@ 1760e912c03SMasahiro Yamada cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ 1770b669a50SMasahiro Yamada 1780e912c03SMasahiro Yamada$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE 179c3cd7cfaSMasahiro Yamada $(call if_changed,moc) 180c3cd7cfaSMasahiro Yamada 1810e912c03SMasahiro Yamadatargets += qconf-moc.cc 1821da177e4SLinus Torvalds 183b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+ 1845f2fb52fSMasahiro Yamadahostprogs += gconf 1853b541978SMasahiro Yamadagconf-objs := gconf.o images.o $(common-objs) 1861da177e4SLinus Torvalds 187d86271afSMasahiro YamadaHOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs) 188d86271afSMasahiro YamadaHOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags) 1891da177e4SLinus Torvalds 190d86271afSMasahiro Yamada$(obj)/gconf.o: $(obj)/gconf-cfg 1911da177e4SLinus Torvalds 1920b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags 193ba97df45SMasahiro Yamadafilechk_conf_cfg = $(CONFIG_SHELL) $< 1940b669a50SMasahiro Yamada 195d86271afSMasahiro Yamada$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE 1960b669a50SMasahiro Yamada $(call filechk,conf_cfg) 1970b669a50SMasahiro Yamada 1982648ca18SMasahiro Yamadaclean-files += *conf-cfg 199