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 6911a91c3SMasahiro YamadaPHONY += xconfig gconfig menuconfig config syncconfig update-po-config \ 7281c9dadSSteven Rostedt localmodconfig localyesconfig 81da177e4SLinus Torvalds 961bee204SAl Viroifdef KBUILD_KCONFIG 1061bee204SAl ViroKconfig := $(KBUILD_KCONFIG) 1161bee204SAl Viroelse 12838a2e55SArnaud LacombeKconfig := Kconfig 1361bee204SAl Viroendif 14e703f75dSSam Ravnborg 150a1f00a1SMichal Marekifeq ($(quiet),silent_) 160a1f00a1SMichal Mareksilent := -s 170a1f00a1SMichal Marekendif 180a1f00a1SMichal Marek 19c2838e6eSYann E. MORIN# We need this, in case the user has it in its environment 20c2838e6eSYann E. MORINunexport CONFIG_ 21c2838e6eSYann E. MORIN 221da177e4SLinus Torvaldsxconfig: $(obj)/qconf 230a1f00a1SMichal Marek $< $(silent) $(Kconfig) 241da177e4SLinus Torvalds 251da177e4SLinus Torvaldsgconfig: $(obj)/gconf 260a1f00a1SMichal Marek $< $(silent) $(Kconfig) 271da177e4SLinus Torvalds 281da177e4SLinus Torvaldsmenuconfig: $(obj)/mconf 290a1f00a1SMichal Marek $< $(silent) $(Kconfig) 301da177e4SLinus Torvalds 311da177e4SLinus Torvaldsconfig: $(obj)/conf 320a1f00a1SMichal Marek $< $(silent) --oldaskconfig $(Kconfig) 331da177e4SLinus Torvalds 34692d97c3Snir.tzachar@gmail.comnconfig: $(obj)/nconf 350a1f00a1SMichal Marek $< $(silent) $(Kconfig) 36692d97c3Snir.tzachar@gmail.com 37cedd55d4SMarc Herbert# This has become an internal implementation detail and is now deprecated 38cedd55d4SMarc Herbert# for external use. 39911a91c3SMasahiro Yamadasyncconfig: $(obj)/conf 409815594aSMasahiro Yamada $(Q)mkdir -p include/config include/generated 410a1f00a1SMichal Marek $< $(silent) --$@ $(Kconfig) 421da177e4SLinus Torvalds 432a616258SUlf Magnussonlocalyesconfig localmodconfig: $(obj)/conf 449815594aSMasahiro Yamada $(Q)mkdir -p include/config include/generated 452a616258SUlf Magnusson $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config 46a7c02602SSteven Rostedt $(Q)if [ -f .config ]; then \ 47a7c02602SSteven Rostedt cmp -s .tmp.config .config || \ 4803fa25daSSteven Rostedt (mv -f .config .config.old.1; \ 4903fa25daSSteven Rostedt mv -f .tmp.config .config; \ 502a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 51a7c02602SSteven Rostedt mv -f .config.old.1 .config.old) \ 52a7c02602SSteven Rostedt else \ 53a7c02602SSteven Rostedt mv -f .tmp.config .config; \ 542a616258SUlf Magnusson $< $(silent) --oldconfig $(Kconfig); \ 55a7c02602SSteven Rostedt fi 5603fa25daSSteven Rostedt $(Q)rm -f .tmp.config 5703fa25daSSteven Rostedt 581020026fSEGRY Gabor# Create new linux.pot file 59b70e325cSSam Ravnborg# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 6046d26319SEGRY Gaborupdate-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h 610a1f00a1SMichal Marek $(Q)$(kecho) " GEN config.pot" 621020026fSEGRY Gabor $(Q)xgettext --default-domain=linux \ 633b9fa093SArnaldo Carvalho de Melo --add-comments --keyword=_ --keyword=N_ \ 64b70e325cSSam Ravnborg --from-code=UTF-8 \ 65a24a1b8eSPeter Foley --files-from=$(srctree)/scripts/kconfig/POTFILES.in \ 66a24a1b8eSPeter Foley --directory=$(srctree) --directory=$(objtree) \ 67b70e325cSSam Ravnborg --output $(obj)/config.pot 68b70e325cSSam Ravnborg $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot 69fa0ad657SPaul Bolle $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \ 70fa0ad657SPaul Bolle $(srctree)/arch/*/um/Kconfig`; \ 71720d6c29SEgry Gabor do \ 720a1f00a1SMichal Marek $(kecho) " GEN $$i"; \ 734217516eSSam Ravnborg $(obj)/kxgettext $$i \ 741020026fSEGRY Gabor >> $(obj)/config.pot; \ 751020026fSEGRY Gabor done ) 760a1f00a1SMichal Marek $(Q)$(kecho) " GEN linux.pot" 771020026fSEGRY Gabor $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ 78b70e325cSSam Ravnborg --output $(obj)/linux.pot 79b70e325cSSam Ravnborg $(Q)rm -f $(obj)/config.pot 803b9fa093SArnaldo Carvalho de Melo 811cba0c30SMichal Marek# These targets map 1:1 to the commandline options of 'conf' 821cba0c30SMichal Mareksimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ 831cba0c30SMichal Marek alldefconfig randconfig listnewconfig olddefconfig 841cba0c30SMichal MarekPHONY += $(simple-targets) 851da177e4SLinus Torvalds 861cba0c30SMichal Marek$(simple-targets): $(obj)/conf 870a1f00a1SMichal Marek $< $(silent) --$@ $(Kconfig) 881da177e4SLinus Torvalds 89911a91c3SMasahiro YamadaPHONY += oldnoconfig silentoldconfig savedefconfig defconfig 901da177e4SLinus Torvalds 91fb16d891SAdam Lee# oldnoconfig is an alias of olddefconfig, because people already are dependent 92fb16d891SAdam Lee# on its behavior (sets new symbols to their default value but not 'n') with the 93fb16d891SAdam Lee# counter-intuitive name. 941cba0c30SMichal Marekoldnoconfig: olddefconfig 95312ee687SMasahiro Yamada @echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19" 96312ee687SMasahiro Yamada @echo " Please use \"olddefconfig\" instead, which is an alias." 97fb16d891SAdam Lee 98911a91c3SMasahiro Yamada# We do not expect manual invokcation of "silentoldcofig" (or "syncconfig"). 99911a91c3SMasahiro Yamadasilentoldconfig: syncconfig 100911a91c3SMasahiro Yamada @echo " WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\"" 101911a91c3SMasahiro Yamada @echo " and is now an internal implementation detail." 102911a91c3SMasahiro Yamada @echo " What you want is probably \"oldconfig\"." 103911a91c3SMasahiro Yamada @echo " \"silentoldconfig\" will be removed after Linux 4.19" 104911a91c3SMasahiro Yamada 1057cf3d73bSSam Ravnborgsavedefconfig: $(obj)/conf 1060a1f00a1SMichal Marek $< $(silent) --$@=defconfig $(Kconfig) 1077cf3d73bSSam Ravnborg 1081da177e4SLinus Torvaldsdefconfig: $(obj)/conf 1091da177e4SLinus Torvaldsifeq ($(KBUILD_DEFCONFIG),) 1100a1f00a1SMichal Marek $< $(silent) --defconfig $(Kconfig) 11142f9d3c6SJan Beulichelse 11242f9d3c6SJan Beulichifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) 1130a1f00a1SMichal Marek @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 1140a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 115d2036f30SMichael Ellermanelse 116d2036f30SMichael Ellerman @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" 117d2036f30SMichael Ellerman $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) 1181da177e4SLinus Torvaldsendif 11942f9d3c6SJan Beulichendif 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds%_defconfig: $(obj)/conf 1220a1f00a1SMichal Marek $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 1231da177e4SLinus Torvalds 12463a91033SMasahiro Yamadaconfigfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) 1253aaefce1SJosh Triplett 12663a91033SMasahiro Yamada%.config: $(obj)/conf 12763a91033SMasahiro Yamada $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) 12863a91033SMasahiro Yamada $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) 129de461993SMasahiro Yamada +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig 1303aaefce1SJosh Triplett 1313aaefce1SJosh TriplettPHONY += kvmconfig 13263a91033SMasahiro Yamadakvmconfig: kvm_guest.config 13363a91033SMasahiro Yamada @: 1343aaefce1SJosh Triplett 1356c668505SLuis R. RodriguezPHONY += xenconfig 1366c668505SLuis R. Rodriguezxenconfig: xen.config 1376c668505SLuis R. Rodriguez @: 1386c668505SLuis R. Rodriguez 1390da1d4a0SJosh TriplettPHONY += tinyconfig 14063a91033SMasahiro Yamadatinyconfig: 14163a91033SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config 1420da1d4a0SJosh Triplett 143022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working? 144022a4bf6SMasahiro YamadaPHONY += testconfig 145022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf 146022a4bf6SMasahiro Yamada $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ 147022a4bf6SMasahiro Yamada -o cache_dir=$(abspath $(obj)/tests/.cache) \ 148022a4bf6SMasahiro Yamada $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) 149022a4bf6SMasahiro Yamadaclean-dirs += tests/.cache 150022a4bf6SMasahiro Yamada 1511da177e4SLinus Torvalds# Help text used by make help 1521da177e4SLinus Torvaldshelp: 1531da177e4SLinus Torvalds @echo ' config - Update current config utilising a line-oriented program' 154fa75a727SGeert Uytterhoeven @echo ' nconfig - Update current config utilising a ncurses menu based' 155fa75a727SGeert Uytterhoeven @echo ' program' 1561da177e4SLinus Torvalds @echo ' menuconfig - Update current config utilising a menu based program' 157092373c2SDiego Viola @echo ' xconfig - Update current config utilising a Qt based front-end' 15839c3f1baSDiego Viola @echo ' gconfig - Update current config utilising a GTK+ based front-end' 1591da177e4SLinus Torvalds @echo ' oldconfig - Update current config utilising a provided .config as base' 16003fa25daSSteven Rostedt @echo ' localmodconfig - Update current config disabling modules not loaded' 161281c9dadSSteven Rostedt @echo ' localyesconfig - Update current config converting local mods to core' 1620748cb3eSSam Ravnborg @echo ' defconfig - New config with default from ARCH supplied defconfig' 1637cf3d73bSSam Ravnborg @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' 164e11f0496SJesper Juhl @echo ' allnoconfig - New config where all options are answered with no' 1650748cb3eSSam Ravnborg @echo ' allyesconfig - New config where all options are accepted with yes' 1660748cb3eSSam Ravnborg @echo ' allmodconfig - New config selecting modules when possible' 1670748cb3eSSam Ravnborg @echo ' alldefconfig - New config with all symbols set to default' 1680748cb3eSSam Ravnborg @echo ' randconfig - New config with random answer to all options' 169861b4ea4SSam Ravnborg @echo ' listnewconfig - List new options' 170cedd55d4SMarc Herbert @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' 171cedd55d4SMarc Herbert @echo ' default value without prompting' 1729bcd776dSLuis R. Rodriguez @echo ' kvmconfig - Enable additional options for kvm guest kernel support' 1736c668505SLuis R. Rodriguez @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' 1740da1d4a0SJosh Triplett @echo ' tinyconfig - Configure the tiniest possible kernel' 1751da177e4SLinus Torvalds 1762982de69SSam Ravnborg# lxdialog stuff 1772982de69SSam Ravnborgcheck-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh 1782982de69SSam Ravnborg 179e9e40e14SRob Landley# Use recursively expanded variables so we do not call gcc unless 1802982de69SSam Ravnborg# we really need to do so. (Do not call gcc as part of make mrproper) 1819ba95682SArnaud LacombeHOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \ 1829ba95682SArnaud Lacombe -DLOCALE 1832982de69SSam Ravnborg 1841da177e4SLinus Torvalds# =========================================================================== 1851da177e4SLinus Torvalds# Shared Makefile for the various kconfig executables: 1861da177e4SLinus Torvalds# conf: Used for defconfig, oldconfig and related targets 187692d97c3Snir.tzachar@gmail.com# nconf: Used for the nconfig target. 188692d97c3Snir.tzachar@gmail.com# Utilizes ncurses 1896f26e5e4SMarkus Heidelberg# mconf: Used for the menuconfig target 1901da177e4SLinus Torvalds# Utilizes the lxdialog package 1911da177e4SLinus Torvalds# object files used by all kconfig flavours 1921da177e4SLinus Torvalds 1932982de69SSam Ravnborglxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o 1942982de69SSam Ravnborglxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o 1952982de69SSam Ravnborg 1961da177e4SLinus Torvaldsconf-objs := conf.o zconf.tab.o 1972982de69SSam Ravnborgmconf-objs := mconf.o zconf.tab.o $(lxdialog) 198692d97c3Snir.tzachar@gmail.comnconf-objs := nconf.o zconf.tab.o nconf.gui.o 1993b9fa093SArnaldo Carvalho de Melokxgettext-objs := kxgettext.o zconf.tab.o 2001da177e4SLinus Torvalds 201*b464ef58SMasahiro Yamadahostprogs-y := conf nconf mconf kxgettext 2021da177e4SLinus Torvalds 203b23d1a24SMasahiro Yamadatargets += zconf.lex.c 2049a8dfb39SMasahiro Yamadaclean-files += gconf.glade.h 2051020026fSEGRY Gaborclean-files += config.pot linux.pot 2061da177e4SLinus Torvalds 2076e588f6dSSam Ravnborg# Check that we have the required ncurses stuff installed for lxdialog (menuconfig) 2086e588f6dSSam RavnborgPHONY += $(obj)/dochecklxdialog 209ff85a1a8SBorislav Petkov$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog 2106e588f6dSSam Ravnborg$(obj)/dochecklxdialog: 2117080e47bSArnaud Lacombe $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf) 2126e588f6dSSam Ravnborg 2136e588f6dSSam Ravnborgalways := dochecklxdialog 2146e588f6dSSam Ravnborg 215aa1e5ef5SSam Ravnborg# Add environment specific flags 216aa1e5ef5SSam RavnborgHOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) 217d0fd0428SYaakov SelkowitzHOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS)) 21870a6a0cbSYuri Vasilevski 2191da177e4SLinus Torvalds# generated files seem to need this to find local include files 2202f76b358SArnaud LacombeHOSTCFLAGS_zconf.lex.o := -I$(src) 2211da177e4SLinus TorvaldsHOSTCFLAGS_zconf.tab.o := -I$(src) 2221da177e4SLinus Torvalds 2237080e47bSArnaud LacombeHOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 2247080e47bSArnaud Lacombe 225544e7e54SJustin LecherHOSTLOADLIBES_nconf = $(shell \ 2267285996aSBrian Norris pkg-config --libs menuw panelw ncursesw 2>/dev/null \ 2277285996aSBrian Norris || pkg-config --libs menu panel ncurses 2>/dev/null \ 228544e7e54SJustin Lecher || echo "-lmenu -lpanel -lncurses" ) 2291da177e4SLinus Torvalds 2300b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt 2310b669a50SMasahiro Yamadahostprogs-y += qconf 2320b669a50SMasahiro Yamadaqconf-cxxobjs := qconf.o 2330b669a50SMasahiro Yamadaqconf-objs := zconf.tab.o 2341da177e4SLinus Torvalds 2350b669a50SMasahiro YamadaHOSTLOADLIBES_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs) 2360b669a50SMasahiro YamadaHOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags) 2370b669a50SMasahiro Yamada 2380b669a50SMasahiro Yamada$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc 2390b669a50SMasahiro Yamada 2400b669a50SMasahiro Yamadaquiet_cmd_moc = MOC $@ 2410b669a50SMasahiro Yamada cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@ 2420b669a50SMasahiro Yamada 2430b669a50SMasahiro Yamada$(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg 2440b669a50SMasahiro Yamada $(call cmd,moc) 2451da177e4SLinus Torvalds 246*b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+ 247*b464ef58SMasahiro Yamadahostprogs-y += gconf 248*b464ef58SMasahiro Yamadagconf-objs := gconf.o zconf.tab.o 2491da177e4SLinus Torvalds 250*b464ef58SMasahiro YamadaHOSTLOADLIBES_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs) 251*b464ef58SMasahiro YamadaHOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags) 2521da177e4SLinus Torvalds 253*b464ef58SMasahiro Yamada$(obj)/gconf.o: $(obj)/.gconf-cfg 2541da177e4SLinus Torvalds 255bb3290d9SLinus Torvalds$(obj)/zconf.tab.o: $(obj)/zconf.lex.c 2561da177e4SLinus Torvalds 25739c3f1baSDiego Viola# Extract gconf menu items for i18n support 25846d26319SEGRY Gabor$(obj)/gconf.glade.h: $(obj)/gconf.glade 2592d80eb0fSPeter Foley $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ 260a24a1b8eSPeter Foley $(obj)/gconf.glade 2610b669a50SMasahiro Yamada 2620b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags 2630b669a50SMasahiro Yamadadefine filechk_conf_cfg 2640b669a50SMasahiro Yamada $(CONFIG_SHELL) $< 2650b669a50SMasahiro Yamadaendef 2660b669a50SMasahiro Yamada 2670b669a50SMasahiro Yamada$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE 2680b669a50SMasahiro Yamada $(call filechk,conf_cfg) 2690b669a50SMasahiro Yamada 2700b669a50SMasahiro Yamadaclean-files += .*conf-cfg 271