xref: /linux/scripts/kconfig/Makefile (revision 89b9060987d988333de59dd218c9666bd7ee95a5)
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
64bf6a9afSRandy DunlapPHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \
74bf6a9afSRandy Dunlap	build_menuconfig build_nconfig build_gconfig build_xconfig
81da177e4SLinus Torvalds
961bee204SAl Viroifdef KBUILD_KCONFIG
1061bee204SAl ViroKconfig := $(KBUILD_KCONFIG)
1161bee204SAl Viroelse
12838a2e55SArnaud LacombeKconfig := Kconfig
1361bee204SAl Viroendif
14e703f75dSSam Ravnborg
15bd305f25SMasahiro Yamadaifndef KBUILD_DEFCONFIG
16bd305f25SMasahiro YamadaKBUILD_DEFCONFIG := defconfig
17bd305f25SMasahiro Yamadaendif
18bd305f25SMasahiro Yamada
190a1f00a1SMichal Marekifeq ($(quiet),silent_)
200a1f00a1SMichal Mareksilent := -s
210a1f00a1SMichal Marekendif
220a1f00a1SMichal Marek
23c2838e6eSYann E. MORIN# We need this, in case the user has it in its environment
24c2838e6eSYann E. MORINunexport CONFIG_
25c2838e6eSYann E. MORIN
261da177e4SLinus Torvaldsxconfig: $(obj)/qconf
270a1f00a1SMichal Marek	$< $(silent) $(Kconfig)
281da177e4SLinus Torvalds
291da177e4SLinus Torvaldsgconfig: $(obj)/gconf
300a1f00a1SMichal Marek	$< $(silent) $(Kconfig)
311da177e4SLinus Torvalds
321da177e4SLinus Torvaldsmenuconfig: $(obj)/mconf
330a1f00a1SMichal Marek	$< $(silent) $(Kconfig)
341da177e4SLinus Torvalds
351da177e4SLinus Torvaldsconfig: $(obj)/conf
360a1f00a1SMichal Marek	$< $(silent) --oldaskconfig $(Kconfig)
371da177e4SLinus Torvalds
38692d97c3Snir.tzachar@gmail.comnconfig: $(obj)/nconf
390a1f00a1SMichal Marek	$< $(silent) $(Kconfig)
40692d97c3Snir.tzachar@gmail.com
414bf6a9afSRandy Dunlapbuild_menuconfig: $(obj)/mconf
424bf6a9afSRandy Dunlap
434bf6a9afSRandy Dunlapbuild_nconfig: $(obj)/nconf
444bf6a9afSRandy Dunlap
454bf6a9afSRandy Dunlapbuild_gconfig: $(obj)/gconf
464bf6a9afSRandy Dunlap
474bf6a9afSRandy Dunlapbuild_xconfig: $(obj)/qconf
484bf6a9afSRandy Dunlap
492a616258SUlf Magnussonlocalyesconfig localmodconfig: $(obj)/conf
50c8138a57SMasahiro Yamada	$(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
51a7c02602SSteven Rostedt	$(Q)if [ -f .config ]; then 				\
52a7c02602SSteven Rostedt		cmp -s .tmp.config .config ||			\
5303fa25daSSteven Rostedt		(mv -f .config .config.old.1;			\
5403fa25daSSteven Rostedt		 mv -f .tmp.config .config;			\
552a616258SUlf Magnusson		 $< $(silent) --oldconfig $(Kconfig);		\
56a7c02602SSteven Rostedt		 mv -f .config.old.1 .config.old)		\
57a7c02602SSteven Rostedt	else							\
58a7c02602SSteven Rostedt		mv -f .tmp.config .config;			\
592a616258SUlf Magnusson		$< $(silent) --oldconfig $(Kconfig);		\
60a7c02602SSteven Rostedt	fi
6103fa25daSSteven Rostedt	$(Q)rm -f .tmp.config
6203fa25daSSteven Rostedt
631cba0c30SMichal Marek# These targets map 1:1 to the commandline options of 'conf'
6479123b13SMasahiro Yamada#
6579123b13SMasahiro Yamada# Note:
6679123b13SMasahiro Yamada#  syncconfig has become an internal implementation detail and is now
6779123b13SMasahiro Yamada#  deprecated for external use
681cba0c30SMichal Mareksimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
695d8b42aaSLaura Abbott	alldefconfig randconfig listnewconfig olddefconfig syncconfig \
70*89b90609STetsuo Handa	helpnewconfig yes2modconfig mod2yesconfig
715d8b42aaSLaura Abbott
721cba0c30SMichal MarekPHONY += $(simple-targets)
731da177e4SLinus Torvalds
741cba0c30SMichal Marek$(simple-targets): $(obj)/conf
750a1f00a1SMichal Marek	$< $(silent) --$@ $(Kconfig)
761da177e4SLinus Torvalds
770085b419SMasahiro YamadaPHONY += savedefconfig defconfig
78911a91c3SMasahiro Yamada
797cf3d73bSSam Ravnborgsavedefconfig: $(obj)/conf
800a1f00a1SMichal Marek	$< $(silent) --$@=defconfig $(Kconfig)
817cf3d73bSSam Ravnborg
821da177e4SLinus Torvaldsdefconfig: $(obj)/conf
83e0a26686SMasahiro Yamadaifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
840a1f00a1SMichal Marek	@$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
850a1f00a1SMichal Marek	$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
86d2036f30SMichael Ellermanelse
87d2036f30SMichael Ellerman	@$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
88d2036f30SMichael Ellerman	$(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
891da177e4SLinus Torvaldsendif
901da177e4SLinus Torvalds
911da177e4SLinus Torvalds%_defconfig: $(obj)/conf
920a1f00a1SMichal Marek	$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
931da177e4SLinus Torvalds
9463a91033SMasahiro Yamadaconfigfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
953aaefce1SJosh Triplett
9663a91033SMasahiro Yamada%.config: $(obj)/conf
9763a91033SMasahiro Yamada	$(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
9863a91033SMasahiro Yamada	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
993266c806SMasahiro Yamada	$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
1003aaefce1SJosh Triplett
1013aaefce1SJosh TriplettPHONY += kvmconfig
10263a91033SMasahiro Yamadakvmconfig: kvm_guest.config
10363a91033SMasahiro Yamada	@:
1043aaefce1SJosh Triplett
1056c668505SLuis R. RodriguezPHONY += xenconfig
1066c668505SLuis R. Rodriguezxenconfig: xen.config
1076c668505SLuis R. Rodriguez	@:
1086c668505SLuis R. Rodriguez
1090da1d4a0SJosh TriplettPHONY += tinyconfig
11063a91033SMasahiro Yamadatinyconfig:
11163a91033SMasahiro Yamada	$(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
1120da1d4a0SJosh Triplett
113022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working?
114022a4bf6SMasahiro YamadaPHONY += testconfig
115022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf
116022a4bf6SMasahiro Yamada	$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
117022a4bf6SMasahiro Yamada	-o cache_dir=$(abspath $(obj)/tests/.cache) \
118022a4bf6SMasahiro Yamada	$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
1191634f2bfSMasahiro Yamadaclean-files += tests/.cache
120022a4bf6SMasahiro Yamada
1211da177e4SLinus Torvalds# Help text used by make help
1221da177e4SLinus Torvaldshelp:
1231da177e4SLinus Torvalds	@echo  '  config	  - Update current config utilising a line-oriented program'
124bb6d83ddSPetr Vorel	@echo  '  nconfig         - Update current config utilising a ncurses menu based program'
1251da177e4SLinus Torvalds	@echo  '  menuconfig	  - Update current config utilising a menu based program'
126092373c2SDiego Viola	@echo  '  xconfig	  - Update current config utilising a Qt based front-end'
12739c3f1baSDiego Viola	@echo  '  gconfig	  - Update current config utilising a GTK+ based front-end'
1281da177e4SLinus Torvalds	@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
12903fa25daSSteven Rostedt	@echo  '  localmodconfig  - Update current config disabling modules not loaded'
130281c9dadSSteven Rostedt	@echo  '  localyesconfig  - Update current config converting local mods to core'
1310748cb3eSSam Ravnborg	@echo  '  defconfig	  - New config with default from ARCH supplied defconfig'
1327cf3d73bSSam Ravnborg	@echo  '  savedefconfig   - Save current config as ./defconfig (minimal config)'
133e11f0496SJesper Juhl	@echo  '  allnoconfig	  - New config where all options are answered with no'
1340748cb3eSSam Ravnborg	@echo  '  allyesconfig	  - New config where all options are accepted with yes'
1350748cb3eSSam Ravnborg	@echo  '  allmodconfig	  - New config selecting modules when possible'
1360748cb3eSSam Ravnborg	@echo  '  alldefconfig    - New config with all symbols set to default'
1370748cb3eSSam Ravnborg	@echo  '  randconfig	  - New config with random answer to all options'
138*89b90609STetsuo Handa	@echo  '  yes2modconfig	  - Change answers from yes to mod if possible'
139*89b90609STetsuo Handa	@echo  '  mod2yesconfig	  - Change answers from mod to yes if possible'
140861b4ea4SSam Ravnborg	@echo  '  listnewconfig   - List new options'
1415d8b42aaSLaura Abbott	@echo  '  helpnewconfig   - List new options and help text'
142cedd55d4SMarc Herbert	@echo  '  olddefconfig	  - Same as oldconfig but sets new symbols to their'
143cedd55d4SMarc Herbert	@echo  '                    default value without prompting'
1449bcd776dSLuis R. Rodriguez	@echo  '  kvmconfig	  - Enable additional options for kvm guest kernel support'
145a64c0440SGeert Uytterhoeven	@echo  '  xenconfig       - Enable additional options for xen dom0 and guest kernel'
146a64c0440SGeert Uytterhoeven	@echo  '                    support'
1470da1d4a0SJosh Triplett	@echo  '  tinyconfig	  - Configure the tiniest possible kernel'
148d6a0c8a1SPetr Vorel	@echo  '  testconfig	  - Run Kconfig unit tests (requires python3 and pytest)'
1491da177e4SLinus Torvalds
1501da177e4SLinus Torvalds# ===========================================================================
1511da177e4SLinus Torvalds# object files used by all kconfig flavours
152769a1c02SMasahiro Yamadacommon-objs	:= confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
153521b29b6SMasahiro Yamada		   symbol.o util.o
1541da177e4SLinus Torvalds
155769a1c02SMasahiro Yamada$(obj)/lexer.lex.o: $(obj)/parser.tab.h
1569cc342f6SMasahiro YamadaHOSTCFLAGS_lexer.lex.o	:= -I $(srctree)/$(src)
1579cc342f6SMasahiro YamadaHOSTCFLAGS_parser.tab.o	:= -I $(srctree)/$(src)
1581da177e4SLinus Torvalds
159558e78e3SMasahiro Yamada# conf: Used for defconfig, oldconfig and related targets
160558e78e3SMasahiro Yamadahostprogs-y	+= conf
161558e78e3SMasahiro Yamadaconf-objs	:= conf.o $(common-objs)
162558e78e3SMasahiro Yamada
1631c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses
1641c5af5cfSMasahiro Yamadahostprogs-y	+= nconf
165558e78e3SMasahiro Yamadanconf-objs	:= nconf.o nconf.gui.o $(common-objs)
1667080e47bSArnaud Lacombe
167d86271afSMasahiro YamadaHOSTLDLIBS_nconf	= $(shell . $(obj)/nconf-cfg && echo $$libs)
168d86271afSMasahiro YamadaHOSTCFLAGS_nconf.o	= $(shell . $(obj)/nconf-cfg && echo $$cflags)
169d86271afSMasahiro YamadaHOSTCFLAGS_nconf.gui.o	= $(shell . $(obj)/nconf-cfg && echo $$cflags)
1701c5af5cfSMasahiro Yamada
171d86271afSMasahiro Yamada$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
1721c5af5cfSMasahiro Yamada
1731c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog
1741c5af5cfSMasahiro Yamadahostprogs-y	+= mconf
17554b8ae66SMasahiro Yamadalxdialog	:= $(addprefix lxdialog/, \
17654b8ae66SMasahiro Yamada		     checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
17754b8ae66SMasahiro Yamadamconf-objs	:= mconf.o $(lxdialog) $(common-objs)
1781c5af5cfSMasahiro Yamada
179d86271afSMasahiro YamadaHOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
1801c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \
181d86271afSMasahiro Yamada  $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
1821c5af5cfSMasahiro Yamada
18354b8ae66SMasahiro Yamada$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
1841da177e4SLinus Torvalds
1850b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt
1860b669a50SMasahiro Yamadahostprogs-y	+= qconf
1870b669a50SMasahiro Yamadaqconf-cxxobjs	:= qconf.o
1883b541978SMasahiro Yamadaqconf-objs	:= images.o $(common-objs)
1891da177e4SLinus Torvalds
190d86271afSMasahiro YamadaHOSTLDLIBS_qconf	= $(shell . $(obj)/qconf-cfg && echo $$libs)
191d86271afSMasahiro YamadaHOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/qconf-cfg && echo $$cflags)
1920b669a50SMasahiro Yamada
193d86271afSMasahiro Yamada$(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.moc
1940b669a50SMasahiro Yamada
1950b669a50SMasahiro Yamadaquiet_cmd_moc = MOC     $@
196d86271afSMasahiro Yamada      cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) -i $< -o $@
1970b669a50SMasahiro Yamada
198d86271afSMasahiro Yamada$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg
1990b669a50SMasahiro Yamada	$(call cmd,moc)
2001da177e4SLinus Torvalds
201b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+
202b464ef58SMasahiro Yamadahostprogs-y	+= gconf
2033b541978SMasahiro Yamadagconf-objs	:= gconf.o images.o $(common-objs)
2041da177e4SLinus Torvalds
205d86271afSMasahiro YamadaHOSTLDLIBS_gconf    = $(shell . $(obj)/gconf-cfg && echo $$libs)
206d86271afSMasahiro YamadaHOSTCFLAGS_gconf.o  = $(shell . $(obj)/gconf-cfg && echo $$cflags)
2071da177e4SLinus Torvalds
208d86271afSMasahiro Yamada$(obj)/gconf.o: $(obj)/gconf-cfg
2091da177e4SLinus Torvalds
2100b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags
211ba97df45SMasahiro Yamadafilechk_conf_cfg = $(CONFIG_SHELL) $<
2120b669a50SMasahiro Yamada
213d86271afSMasahiro Yamada$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
2140b669a50SMasahiro Yamada	$(call filechk,conf_cfg)
2150b669a50SMasahiro Yamada
2162648ca18SMasahiro Yamadaclean-files += *conf-cfg
217