xref: /linux/scripts/kconfig/Makefile (revision 0085b4191f3e30ec94beef4103679f2828d3c54f)
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
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
374bf6a9afSRandy Dunlapbuild_menuconfig: $(obj)/mconf
384bf6a9afSRandy Dunlap
394bf6a9afSRandy Dunlapbuild_nconfig: $(obj)/nconf
404bf6a9afSRandy Dunlap
414bf6a9afSRandy Dunlapbuild_gconfig: $(obj)/gconf
424bf6a9afSRandy Dunlap
434bf6a9afSRandy Dunlapbuild_xconfig: $(obj)/qconf
444bf6a9afSRandy Dunlap
452a616258SUlf Magnussonlocalyesconfig localmodconfig: $(obj)/conf
462a616258SUlf Magnusson	$(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
47a7c02602SSteven Rostedt	$(Q)if [ -f .config ]; then 					\
48a7c02602SSteven Rostedt			cmp -s .tmp.config .config ||			\
4903fa25daSSteven Rostedt			(mv -f .config .config.old.1;			\
5003fa25daSSteven Rostedt			 mv -f .tmp.config .config;			\
512a616258SUlf Magnusson			 $< $(silent) --oldconfig $(Kconfig);		\
52a7c02602SSteven Rostedt			 mv -f .config.old.1 .config.old)		\
53a7c02602SSteven Rostedt	else								\
54a7c02602SSteven Rostedt			mv -f .tmp.config .config;			\
552a616258SUlf Magnusson			$< $(silent) --oldconfig $(Kconfig);		\
56a7c02602SSteven Rostedt	fi
5703fa25daSSteven Rostedt	$(Q)rm -f .tmp.config
5803fa25daSSteven Rostedt
591cba0c30SMichal Marek# These targets map 1:1 to the commandline options of 'conf'
6079123b13SMasahiro Yamada#
6179123b13SMasahiro Yamada# Note:
6279123b13SMasahiro Yamada#  syncconfig has become an internal implementation detail and is now
6379123b13SMasahiro Yamada#  deprecated for external use
641cba0c30SMichal Mareksimple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
6579123b13SMasahiro Yamada	alldefconfig randconfig listnewconfig olddefconfig syncconfig
661cba0c30SMichal MarekPHONY += $(simple-targets)
671da177e4SLinus Torvalds
681cba0c30SMichal Marek$(simple-targets): $(obj)/conf
690a1f00a1SMichal Marek	$< $(silent) --$@ $(Kconfig)
701da177e4SLinus Torvalds
71*0085b419SMasahiro YamadaPHONY += savedefconfig defconfig
72911a91c3SMasahiro Yamada
737cf3d73bSSam Ravnborgsavedefconfig: $(obj)/conf
740a1f00a1SMichal Marek	$< $(silent) --$@=defconfig $(Kconfig)
757cf3d73bSSam Ravnborg
761da177e4SLinus Torvaldsdefconfig: $(obj)/conf
771da177e4SLinus Torvaldsifeq ($(KBUILD_DEFCONFIG),)
780a1f00a1SMichal Marek	$< $(silent) --defconfig $(Kconfig)
7942f9d3c6SJan Beulichelse
8042f9d3c6SJan Beulichifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
810a1f00a1SMichal Marek	@$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
820a1f00a1SMichal Marek	$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
83d2036f30SMichael Ellermanelse
84d2036f30SMichael Ellerman	@$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
85d2036f30SMichael Ellerman	$(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
861da177e4SLinus Torvaldsendif
8742f9d3c6SJan Beulichendif
881da177e4SLinus Torvalds
891da177e4SLinus Torvalds%_defconfig: $(obj)/conf
900a1f00a1SMichal Marek	$(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
911da177e4SLinus Torvalds
9263a91033SMasahiro Yamadaconfigfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
933aaefce1SJosh Triplett
9463a91033SMasahiro Yamada%.config: $(obj)/conf
9563a91033SMasahiro Yamada	$(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
9663a91033SMasahiro Yamada	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
97de461993SMasahiro Yamada	+$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
983aaefce1SJosh Triplett
993aaefce1SJosh TriplettPHONY += kvmconfig
10063a91033SMasahiro Yamadakvmconfig: kvm_guest.config
10163a91033SMasahiro Yamada	@:
1023aaefce1SJosh Triplett
1036c668505SLuis R. RodriguezPHONY += xenconfig
1046c668505SLuis R. Rodriguezxenconfig: xen.config
1056c668505SLuis R. Rodriguez	@:
1066c668505SLuis R. Rodriguez
1070da1d4a0SJosh TriplettPHONY += tinyconfig
10863a91033SMasahiro Yamadatinyconfig:
10963a91033SMasahiro Yamada	$(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
1100da1d4a0SJosh Triplett
111022a4bf6SMasahiro Yamada# CHECK: -o cache_dir=<path> working?
112022a4bf6SMasahiro YamadaPHONY += testconfig
113022a4bf6SMasahiro Yamadatestconfig: $(obj)/conf
114022a4bf6SMasahiro Yamada	$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
115022a4bf6SMasahiro Yamada	-o cache_dir=$(abspath $(obj)/tests/.cache) \
116022a4bf6SMasahiro Yamada	$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
117022a4bf6SMasahiro Yamadaclean-dirs += tests/.cache
118022a4bf6SMasahiro Yamada
1191da177e4SLinus Torvalds# Help text used by make help
1201da177e4SLinus Torvaldshelp:
1211da177e4SLinus Torvalds	@echo  '  config	  - Update current config utilising a line-oriented program'
122bb6d83ddSPetr Vorel	@echo  '  nconfig         - Update current config utilising a ncurses menu based program'
1231da177e4SLinus Torvalds	@echo  '  menuconfig	  - Update current config utilising a menu based program'
124092373c2SDiego Viola	@echo  '  xconfig	  - Update current config utilising a Qt based front-end'
12539c3f1baSDiego Viola	@echo  '  gconfig	  - Update current config utilising a GTK+ based front-end'
1261da177e4SLinus Torvalds	@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
12703fa25daSSteven Rostedt	@echo  '  localmodconfig  - Update current config disabling modules not loaded'
128281c9dadSSteven Rostedt	@echo  '  localyesconfig  - Update current config converting local mods to core'
1290748cb3eSSam Ravnborg	@echo  '  defconfig	  - New config with default from ARCH supplied defconfig'
1307cf3d73bSSam Ravnborg	@echo  '  savedefconfig   - Save current config as ./defconfig (minimal config)'
131e11f0496SJesper Juhl	@echo  '  allnoconfig	  - New config where all options are answered with no'
1320748cb3eSSam Ravnborg	@echo  '  allyesconfig	  - New config where all options are accepted with yes'
1330748cb3eSSam Ravnborg	@echo  '  allmodconfig	  - New config selecting modules when possible'
1340748cb3eSSam Ravnborg	@echo  '  alldefconfig    - New config with all symbols set to default'
1350748cb3eSSam Ravnborg	@echo  '  randconfig	  - New config with random answer to all options'
136861b4ea4SSam Ravnborg	@echo  '  listnewconfig   - List new options'
137cedd55d4SMarc Herbert	@echo  '  olddefconfig	  - Same as oldconfig but sets new symbols to their'
138cedd55d4SMarc Herbert	@echo  '                    default value without prompting'
1399bcd776dSLuis R. Rodriguez	@echo  '  kvmconfig	  - Enable additional options for kvm guest kernel support'
1406c668505SLuis R. Rodriguez	@echo  '  xenconfig       - Enable additional options for xen dom0 and guest kernel support'
1410da1d4a0SJosh Triplett	@echo  '  tinyconfig	  - Configure the tiniest possible kernel'
142d6a0c8a1SPetr Vorel	@echo  '  testconfig	  - Run Kconfig unit tests (requires python3 and pytest)'
1431da177e4SLinus Torvalds
1441da177e4SLinus Torvalds# ===========================================================================
1451da177e4SLinus Torvalds# Shared Makefile for the various kconfig executables:
1461da177e4SLinus Torvalds# conf:	  Used for defconfig, oldconfig and related targets
1471da177e4SLinus Torvalds# object files used by all kconfig flavours
1481da177e4SLinus Torvalds
1491da177e4SLinus Torvaldsconf-objs	:= conf.o  zconf.tab.o
1501da177e4SLinus Torvalds
151694c49a7SSam Ravnborghostprogs-y := conf
1521da177e4SLinus Torvalds
153b23d1a24SMasahiro Yamadatargets		+= zconf.lex.c
1541da177e4SLinus Torvalds
1551da177e4SLinus Torvalds# generated files seem to need this to find local include files
1562f76b358SArnaud LacombeHOSTCFLAGS_zconf.lex.o	:= -I$(src)
1571da177e4SLinus TorvaldsHOSTCFLAGS_zconf.tab.o	:= -I$(src)
1581da177e4SLinus Torvalds
1591c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses
1601c5af5cfSMasahiro Yamadahostprogs-y	+= nconf
1611c5af5cfSMasahiro Yamadanconf-objs	:= nconf.o zconf.tab.o nconf.gui.o
1627080e47bSArnaud Lacombe
1638377bd2bSLaura AbbottHOSTLDLIBS_nconf	= $(shell . $(obj)/.nconf-cfg && echo $$libs)
1641c5af5cfSMasahiro YamadaHOSTCFLAGS_nconf.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
1651c5af5cfSMasahiro YamadaHOSTCFLAGS_nconf.gui.o	= $(shell . $(obj)/.nconf-cfg && echo $$cflags)
1661c5af5cfSMasahiro Yamada
16798a4afbfSMasahiro Yamada$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/.nconf-cfg
1681c5af5cfSMasahiro Yamada
1691c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog
1701c5af5cfSMasahiro Yamadahostprogs-y	+= mconf
1711c5af5cfSMasahiro Yamadalxdialog	:= checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
1721c5af5cfSMasahiro Yamadamconf-objs	:= mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
1731c5af5cfSMasahiro Yamada
1748377bd2bSLaura AbbottHOSTLDLIBS_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
1751c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \
1761c5af5cfSMasahiro Yamada  $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
1771c5af5cfSMasahiro Yamada
17898a4afbfSMasahiro Yamada$(obj)/mconf.o: $(obj)/.mconf-cfg
17998a4afbfSMasahiro Yamada$(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/.mconf-cfg
1801da177e4SLinus Torvalds
1810b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt
1820b669a50SMasahiro Yamadahostprogs-y	+= qconf
1830b669a50SMasahiro Yamadaqconf-cxxobjs	:= qconf.o
1840b669a50SMasahiro Yamadaqconf-objs	:= zconf.tab.o
1851da177e4SLinus Torvalds
1868377bd2bSLaura AbbottHOSTLDLIBS_qconf	= $(shell . $(obj)/.qconf-cfg && echo $$libs)
1870b669a50SMasahiro YamadaHOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/.qconf-cfg && echo $$cflags)
1880b669a50SMasahiro Yamada
1890b669a50SMasahiro Yamada$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
1900b669a50SMasahiro Yamada
1910b669a50SMasahiro Yamadaquiet_cmd_moc = MOC     $@
1920b669a50SMasahiro Yamada      cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@
1930b669a50SMasahiro Yamada
1940b669a50SMasahiro Yamada$(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
1950b669a50SMasahiro Yamada	$(call cmd,moc)
1961da177e4SLinus Torvalds
197b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+
198b464ef58SMasahiro Yamadahostprogs-y	+= gconf
199b464ef58SMasahiro Yamadagconf-objs	:= gconf.o zconf.tab.o
2001da177e4SLinus Torvalds
2018377bd2bSLaura AbbottHOSTLDLIBS_gconf    = $(shell . $(obj)/.gconf-cfg && echo $$libs)
202b464ef58SMasahiro YamadaHOSTCFLAGS_gconf.o  = $(shell . $(obj)/.gconf-cfg && echo $$cflags)
2031da177e4SLinus Torvalds
204b464ef58SMasahiro Yamada$(obj)/gconf.o: $(obj)/.gconf-cfg
2051da177e4SLinus Torvalds
206bb3290d9SLinus Torvalds$(obj)/zconf.tab.o: $(obj)/zconf.lex.c
2071da177e4SLinus Torvalds
2080b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags
2090b669a50SMasahiro Yamadadefine filechk_conf_cfg
2100b669a50SMasahiro Yamada	$(CONFIG_SHELL) $<
2110b669a50SMasahiro Yamadaendef
2120b669a50SMasahiro Yamada
2130b669a50SMasahiro Yamada$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE
2140b669a50SMasahiro Yamada	$(call filechk,conf_cfg)
2150b669a50SMasahiro Yamada
2160b669a50SMasahiro Yamadaclean-files += .*conf-cfg
217