xref: /linux/scripts/kconfig/Makefile (revision 79123b1389cc775d8e60cb026256f79f0daef173)
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
6*79123b13SMasahiro YamadaPHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig
71da177e4SLinus Torvalds
861bee204SAl Viroifdef KBUILD_KCONFIG
961bee204SAl ViroKconfig := $(KBUILD_KCONFIG)
1061bee204SAl Viroelse
11838a2e55SArnaud LacombeKconfig := Kconfig
1261bee204SAl Viroendif
13e703f75dSSam Ravnborg
140a1f00a1SMichal Marekifeq ($(quiet),silent_)
150a1f00a1SMichal Mareksilent := -s
160a1f00a1SMichal Marekendif
170a1f00a1SMichal Marek
18c2838e6eSYann E. MORIN# We need this, in case the user has it in its environment
19c2838e6eSYann E. MORINunexport CONFIG_
20c2838e6eSYann E. MORIN
211da177e4SLinus Torvaldsxconfig: $(obj)/qconf
220a1f00a1SMichal Marek	$< $(silent) $(Kconfig)
231da177e4SLinus Torvalds
241da177e4SLinus Torvaldsgconfig: $(obj)/gconf
250a1f00a1SMichal Marek	$< $(silent) $(Kconfig)
261da177e4SLinus Torvalds
271da177e4SLinus Torvaldsmenuconfig: $(obj)/mconf
280a1f00a1SMichal Marek	$< $(silent) $(Kconfig)
291da177e4SLinus Torvalds
301da177e4SLinus Torvaldsconfig: $(obj)/conf
310a1f00a1SMichal Marek	$< $(silent) --oldaskconfig $(Kconfig)
321da177e4SLinus Torvalds
33692d97c3Snir.tzachar@gmail.comnconfig: $(obj)/nconf
340a1f00a1SMichal Marek	$< $(silent) $(Kconfig)
35692d97c3Snir.tzachar@gmail.com
362a616258SUlf Magnussonlocalyesconfig localmodconfig: $(obj)/conf
372a616258SUlf Magnusson	$(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
38a7c02602SSteven Rostedt	$(Q)if [ -f .config ]; then 					\
39a7c02602SSteven Rostedt			cmp -s .tmp.config .config ||			\
4003fa25daSSteven Rostedt			(mv -f .config .config.old.1;			\
4103fa25daSSteven Rostedt			 mv -f .tmp.config .config;			\
422a616258SUlf Magnusson			 $< $(silent) --oldconfig $(Kconfig);		\
43a7c02602SSteven Rostedt			 mv -f .config.old.1 .config.old)		\
44a7c02602SSteven Rostedt	else								\
45a7c02602SSteven Rostedt			mv -f .tmp.config .config;			\
462a616258SUlf Magnusson			$< $(silent) --oldconfig $(Kconfig);		\
47a7c02602SSteven Rostedt	fi
4803fa25daSSteven Rostedt	$(Q)rm -f .tmp.config
4903fa25daSSteven Rostedt
501cba0c30SMichal Marek# These targets map 1:1 to the commandline options of 'conf'
51*79123b13SMasahiro Yamada#
52*79123b13SMasahiro Yamada# Note:
53*79123b13SMasahiro Yamada#  syncconfig has become an internal implementation detail and is now
54*79123b13SMasahiro Yamada#  deprecated for external use
551cba0c30SMichal Mareksimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
56*79123b13SMasahiro Yamada	alldefconfig randconfig listnewconfig olddefconfig syncconfig
571cba0c30SMichal MarekPHONY += $(simple-targets)
581da177e4SLinus Torvalds
591cba0c30SMichal Marek$(simple-targets): $(obj)/conf
600a1f00a1SMichal Marek	$< $(silent) --$@ $(Kconfig)
611da177e4SLinus Torvalds
62911a91c3SMasahiro YamadaPHONY += oldnoconfig silentoldconfig savedefconfig defconfig
631da177e4SLinus Torvalds
64fb16d891SAdam Lee# oldnoconfig is an alias of olddefconfig, because people already are dependent
65fb16d891SAdam Lee# on its behavior (sets new symbols to their default value but not 'n') with the
66fb16d891SAdam Lee# counter-intuitive name.
671cba0c30SMichal Marekoldnoconfig: olddefconfig
68312ee687SMasahiro Yamada	@echo "  WARNING: \"oldnoconfig\" target will be removed after Linux 4.19"
69312ee687SMasahiro Yamada	@echo "            Please use \"olddefconfig\" instead, which is an alias."
70fb16d891SAdam Lee
71911a91c3SMasahiro Yamada# We do not expect manual invokcation of "silentoldcofig" (or "syncconfig").
72911a91c3SMasahiro Yamadasilentoldconfig: syncconfig
73911a91c3SMasahiro Yamada	@echo "  WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\""
74911a91c3SMasahiro Yamada	@echo "            and is now an internal implementation detail."
75911a91c3SMasahiro Yamada	@echo "            What you want is probably \"oldconfig\"."
76911a91c3SMasahiro Yamada	@echo "            \"silentoldconfig\" will be removed after Linux 4.19"
77911a91c3SMasahiro Yamada
787cf3d73bSSam Ravnborgsavedefconfig: $(obj)/conf
790a1f00a1SMichal Marek	$< $(silent) --$@=defconfig $(Kconfig)
807cf3d73bSSam Ravnborg
811da177e4SLinus Torvaldsdefconfig: $(obj)/conf
821da177e4SLinus Torvaldsifeq ($(KBUILD_DEFCONFIG),)
830a1f00a1SMichal Marek	$< $(silent) --defconfig $(Kconfig)
8442f9d3c6SJan Beulichelse
8542f9d3c6SJan Beulichifneq ($(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
9242f9d3c6SJan Beulichendif
931da177e4SLinus Torvalds
941da177e4SLinus Torvalds%_defconfig: $(obj)/conf
950a1f00a1SMichal Marek	$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
961da177e4SLinus Torvalds
9763a91033SMasahiro Yamadaconfigfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
983aaefce1SJosh Triplett
9963a91033SMasahiro Yamada%.config: $(obj)/conf
10063a91033SMasahiro Yamada	$(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
10163a91033SMasahiro Yamada	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
102de461993SMasahiro Yamada	+$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
1033aaefce1SJosh Triplett
1043aaefce1SJosh TriplettPHONY += kvmconfig
10563a91033SMasahiro Yamadakvmconfig: kvm_guest.config
10663a91033SMasahiro Yamada	@:
1073aaefce1SJosh Triplett
1086c668505SLuis R. RodriguezPHONY += xenconfig
1096c668505SLuis R. Rodriguezxenconfig: xen.config
1106c668505SLuis R. Rodriguez	@:
1116c668505SLuis R. Rodriguez
1120da1d4a0SJosh TriplettPHONY += tinyconfig
11363a91033SMasahiro Yamadatinyconfig:
11463a91033SMasahiro Yamada	$(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
1150da1d4a0SJosh Triplett
116022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working?
117022a4bf6SMasahiro YamadaPHONY += testconfig
118022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf
119022a4bf6SMasahiro Yamada	$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
120022a4bf6SMasahiro Yamada	-o cache_dir=$(abspath $(obj)/tests/.cache) \
121022a4bf6SMasahiro Yamada	$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
122022a4bf6SMasahiro Yamadaclean-dirs += tests/.cache
123022a4bf6SMasahiro Yamada
1241da177e4SLinus Torvalds# Help text used by make help
1251da177e4SLinus Torvaldshelp:
1261da177e4SLinus Torvalds	@echo  '  config	  - Update current config utilising a line-oriented program'
127bb6d83ddSPetr Vorel	@echo  '  nconfig         - Update current config utilising a ncurses menu based program'
1281da177e4SLinus Torvalds	@echo  '  menuconfig	  - Update current config utilising a menu based program'
129092373c2SDiego Viola	@echo  '  xconfig	  - Update current config utilising a Qt based front-end'
13039c3f1baSDiego Viola	@echo  '  gconfig	  - Update current config utilising a GTK+ based front-end'
1311da177e4SLinus Torvalds	@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
13203fa25daSSteven Rostedt	@echo  '  localmodconfig  - Update current config disabling modules not loaded'
133281c9dadSSteven Rostedt	@echo  '  localyesconfig  - Update current config converting local mods to core'
1340748cb3eSSam Ravnborg	@echo  '  defconfig	  - New config with default from ARCH supplied defconfig'
1357cf3d73bSSam Ravnborg	@echo  '  savedefconfig   - Save current config as ./defconfig (minimal config)'
136e11f0496SJesper Juhl	@echo  '  allnoconfig	  - New config where all options are answered with no'
1370748cb3eSSam Ravnborg	@echo  '  allyesconfig	  - New config where all options are accepted with yes'
1380748cb3eSSam Ravnborg	@echo  '  allmodconfig	  - New config selecting modules when possible'
1390748cb3eSSam Ravnborg	@echo  '  alldefconfig    - New config with all symbols set to default'
1400748cb3eSSam Ravnborg	@echo  '  randconfig	  - New config with random answer to all options'
141861b4ea4SSam Ravnborg	@echo  '  listnewconfig   - List new options'
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'
1456c668505SLuis R. Rodriguez	@echo  '  xenconfig       - Enable additional options for xen dom0 and guest kernel support'
1460da1d4a0SJosh Triplett	@echo  '  tinyconfig	  - Configure the tiniest possible kernel'
147d6a0c8a1SPetr Vorel	@echo  '  testconfig	  - Run Kconfig unit tests (requires python3 and pytest)'
1481da177e4SLinus Torvalds
1491da177e4SLinus Torvalds# ===========================================================================
1501da177e4SLinus Torvalds# Shared Makefile for the various kconfig executables:
1511da177e4SLinus Torvalds# conf:	  Used for defconfig, oldconfig and related targets
1521da177e4SLinus Torvalds# object files used by all kconfig flavours
1531da177e4SLinus Torvalds
1541da177e4SLinus Torvaldsconf-objs	:= conf.o  zconf.tab.o
1551da177e4SLinus Torvalds
156694c49a7SSam Ravnborghostprogs-y := conf
1571da177e4SLinus Torvalds
158b23d1a24SMasahiro Yamadatargets		+= zconf.lex.c
1591da177e4SLinus Torvalds
1601da177e4SLinus Torvalds# generated files seem to need this to find local include files
1612f76b358SArnaud LacombeHOSTCFLAGS_zconf.lex.o	:= -I$(src)
1621da177e4SLinus TorvaldsHOSTCFLAGS_zconf.tab.o	:= -I$(src)
1631da177e4SLinus Torvalds
1641c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses
1651c5af5cfSMasahiro Yamadahostprogs-y	+= nconf
1661c5af5cfSMasahiro Yamadanconf-objs	:= nconf.o zconf.tab.o nconf.gui.o
1677080e47bSArnaud Lacombe
1681c5af5cfSMasahiro YamadaHOSTLOADLIBES_nconf	= $(shell . $(obj)/.nconf-cfg && echo $$libs)
1691c5af5cfSMasahiro YamadaHOSTCFLAGS_nconf.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
1701c5af5cfSMasahiro YamadaHOSTCFLAGS_nconf.gui.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
1711c5af5cfSMasahiro Yamada
1721c5af5cfSMasahiro Yamada$(obj)/nconf.o: $(obj)/.nconf-cfg
1731c5af5cfSMasahiro Yamada
1741c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog
1751c5af5cfSMasahiro Yamadahostprogs-y	+= mconf
1761c5af5cfSMasahiro Yamadalxdialog	:= checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
1771c5af5cfSMasahiro Yamadamconf-objs	:= mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
1781c5af5cfSMasahiro Yamada
1791c5af5cfSMasahiro YamadaHOSTLOADLIBES_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
1801c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \
1811c5af5cfSMasahiro Yamada  $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
1821c5af5cfSMasahiro Yamada
1831c5af5cfSMasahiro 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
1880b669a50SMasahiro Yamadaqconf-objs	:= zconf.tab.o
1891da177e4SLinus Torvalds
1900b669a50SMasahiro YamadaHOSTLOADLIBES_qconf	= $(shell . $(obj)/.qconf-cfg && echo $$libs)
1910b669a50SMasahiro YamadaHOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/.qconf-cfg && echo $$cflags)
1920b669a50SMasahiro Yamada
1930b669a50SMasahiro Yamada$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
1940b669a50SMasahiro Yamada
1950b669a50SMasahiro Yamadaquiet_cmd_moc = MOC     $@
1960b669a50SMasahiro Yamada      cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@
1970b669a50SMasahiro Yamada
1980b669a50SMasahiro 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
203b464ef58SMasahiro Yamadagconf-objs	:= gconf.o zconf.tab.o
2041da177e4SLinus Torvalds
205b464ef58SMasahiro YamadaHOSTLOADLIBES_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
206b464ef58SMasahiro YamadaHOSTCFLAGS_gconf.o  = $(shell . $(obj)/.gconf-cfg && echo $$cflags)
2071da177e4SLinus Torvalds
208b464ef58SMasahiro Yamada$(obj)/gconf.o: $(obj)/.gconf-cfg
2091da177e4SLinus Torvalds
210bb3290d9SLinus Torvalds$(obj)/zconf.tab.o: $(obj)/zconf.lex.c
2111da177e4SLinus Torvalds
2120b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags
2130b669a50SMasahiro Yamadadefine filechk_conf_cfg
2144ab3b801SRandy Dunlap	$(CONFIG_SHELL) $(srctree)/scripts/kconfig/check-pkgconfig.sh; \
2150b669a50SMasahiro Yamada	$(CONFIG_SHELL) $<
2160b669a50SMasahiro Yamadaendef
2170b669a50SMasahiro Yamada
2180b669a50SMasahiro Yamada$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE
2190b669a50SMasahiro Yamada	$(call filechk,conf_cfg)
2200b669a50SMasahiro Yamada
2210b669a50SMasahiro Yamadaclean-files += .*conf-cfg
222