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 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 \ 72c39afe62SJosh Triplett helpnewconfig yes2modconfig mod2yesconfig mod2noconfig 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: 105f8f0d064SMasahiro Yamada $(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig 106f8f0d064SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile tiny.config 1070da1d4a0SJosh Triplett 108022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working? 109022a4bf6SMasahiro YamadaPHONY += testconfig 110022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf 11123cd88c9SMasahiro Yamada $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 112022a4bf6SMasahiro Yamada -o cache_dir=$(abspath $(obj)/tests/.cache) \ 113022a4bf6SMasahiro Yamada $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 1141634f2bfSMasahiro Yamadaclean-files += tests/.cache 115022a4bf6SMasahiro Yamada 1161da177e4SLinus Torvalds# Help text used by make help 1171da177e4SLinus Torvaldshelp: 1181da177e4SLinus Torvalds @echo ' config - Update current config utilising a line-oriented program' 119bb6d83ddSPetr Vorel @echo ' nconfig - Update current config utilising a ncurses menu based program' 1201da177e4SLinus Torvalds @echo ' menuconfig - Update current config utilising a menu based program' 121092373c2SDiego Viola @echo ' xconfig - Update current config utilising a Qt based front-end' 12239c3f1baSDiego Viola @echo ' gconfig - Update current config utilising a GTK+ based front-end' 1231da177e4SLinus Torvalds @echo ' oldconfig - Update current config utilising a provided .config as base' 12403fa25daSSteven Rostedt @echo ' localmodconfig - Update current config disabling modules not loaded' 125c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 126281c9dadSSteven Rostedt @echo ' localyesconfig - Update current config converting local mods to core' 127c027b02dSChangbin Du @echo ' except those preserved by LMC_KEEP environment variable' 1280748cb3eSSam Ravnborg @echo ' defconfig - New config with default from ARCH supplied defconfig' 1297cf3d73bSSam Ravnborg @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 130e11f0496SJesper Juhl @echo ' allnoconfig - New config where all options are answered with no' 1310748cb3eSSam Ravnborg @echo ' allyesconfig - New config where all options are accepted with yes' 1320748cb3eSSam Ravnborg @echo ' allmodconfig - New config selecting modules when possible' 1330748cb3eSSam Ravnborg @echo ' alldefconfig - New config with all symbols set to default' 1340748cb3eSSam Ravnborg @echo ' randconfig - New config with random answer to all options' 13589b90609STetsuo Handa @echo ' yes2modconfig - Change answers from yes to mod if possible' 13689b90609STetsuo Handa @echo ' mod2yesconfig - Change answers from mod to yes if possible' 137c39afe62SJosh Triplett @echo ' mod2noconfig - Change answers from mod to no if possible' 138861b4ea4SSam Ravnborg @echo ' listnewconfig - List new options' 1395d8b42aaSLaura Abbott @echo ' helpnewconfig - List new options and help text' 140cedd55d4SMarc Herbert @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' 141cedd55d4SMarc Herbert @echo ' default value without prompting' 1420da1d4a0SJosh Triplett @echo ' tinyconfig - Configure the tiniest possible kernel' 143d6a0c8a1SPetr Vorel @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' 1441da177e4SLinus Torvalds 1451da177e4SLinus Torvalds# =========================================================================== 1461da177e4SLinus Torvalds# object files used by all kconfig flavours 147a77a05dcSMasahiro Yamadacommon-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \ 148a77a05dcSMasahiro Yamada preprocess.o symbol.o util.o 1491da177e4SLinus Torvalds 150769a1c02SMasahiro Yamada$(obj)/lexer.lex.o: $(obj)/parser.tab.h 1519cc342f6SMasahiro YamadaHOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) 1529cc342f6SMasahiro YamadaHOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) 1531da177e4SLinus Torvalds 154558e78e3SMasahiro Yamada# conf: Used for defconfig, oldconfig and related targets 1555f2fb52fSMasahiro Yamadahostprogs += conf 156558e78e3SMasahiro Yamadaconf-objs := conf.o $(common-objs) 157558e78e3SMasahiro Yamada 1581c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses 1595f2fb52fSMasahiro Yamadahostprogs += nconf 160558e78e3SMasahiro Yamadanconf-objs := nconf.o nconf.gui.o $(common-objs) 1617080e47bSArnaud Lacombe 162*3122c844SMasahiro YamadaHOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs) 163*3122c844SMasahiro YamadaHOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags) 164*3122c844SMasahiro YamadaHOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags) 1651c5af5cfSMasahiro Yamada 166*3122c844SMasahiro Yamada$(obj)/nconf: | $(obj)/nconf-libs 167*3122c844SMasahiro Yamada$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags 1681c5af5cfSMasahiro Yamada 1691c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog 1705f2fb52fSMasahiro Yamadahostprogs += mconf 17154b8ae66SMasahiro Yamadalxdialog := $(addprefix lxdialog/, \ 17254b8ae66SMasahiro Yamada checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) 17354b8ae66SMasahiro Yamadamconf-objs := mconf.o $(lxdialog) $(common-objs) 1741c5af5cfSMasahiro Yamada 175*3122c844SMasahiro YamadaHOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs) 1761c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \ 177*3122c844SMasahiro Yamada $(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags))) 1781c5af5cfSMasahiro Yamada 179*3122c844SMasahiro Yamada$(obj)/mconf: | $(obj)/mconf-libs 180*3122c844SMasahiro Yamada$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags 1811da177e4SLinus Torvalds 1820b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt 1835f2fb52fSMasahiro Yamadahostprogs += qconf 1840e912c03SMasahiro Yamadaqconf-cxxobjs := qconf.o qconf-moc.o 1853b541978SMasahiro Yamadaqconf-objs := images.o $(common-objs) 1861da177e4SLinus Torvalds 187*3122c844SMasahiro YamadaHOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs) 188*3122c844SMasahiro YamadaHOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) 189*3122c844SMasahiro YamadaHOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) 190*3122c844SMasahiro Yamada$(obj)/qconf: | $(obj)/qconf-libs 191*3122c844SMasahiro Yamada$(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags 1920b669a50SMasahiro Yamada 1930b669a50SMasahiro Yamadaquiet_cmd_moc = MOC $@ 194*3122c844SMasahiro Yamada cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@ 1950b669a50SMasahiro Yamada 196*3122c844SMasahiro Yamada$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin 197c3cd7cfaSMasahiro Yamada $(call if_changed,moc) 198c3cd7cfaSMasahiro Yamada 1990e912c03SMasahiro Yamadatargets += qconf-moc.cc 2001da177e4SLinus Torvalds 201b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+ 2025f2fb52fSMasahiro Yamadahostprogs += gconf 2033b541978SMasahiro Yamadagconf-objs := gconf.o images.o $(common-objs) 2041da177e4SLinus Torvalds 205*3122c844SMasahiro YamadaHOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs) 206*3122c844SMasahiro YamadaHOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags) 2071da177e4SLinus Torvalds 208*3122c844SMasahiro Yamada$(obj)/gconf: | $(obj)/gconf-libs 209*3122c844SMasahiro Yamada$(obj)/gconf.o: | $(obj)/gconf-cflags 2101da177e4SLinus Torvalds 2110b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags 212*3122c844SMasahiro Yamadacmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin) 2130b669a50SMasahiro Yamada 214*3122c844SMasahiro Yamada$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh 215*3122c844SMasahiro Yamada $(call cmd,conf_cfg) 2160b669a50SMasahiro Yamada 217*3122c844SMasahiro Yamadaclean-files += *conf-cflags *conf-libs *conf-bin 218