xref: /linux/scripts/kconfig/Makefile (revision f02aa48dde8b96eef5998b049ad11547bfc16080)
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 :=
21*f02aa48dSMasahiro Yamadaifndef cross_compiling
22b75b0a81SMasahiro Yamadakernel-release := $(shell uname -r)
23*f02aa48dSMasahiro YamadaKCONFIG_DEFCONFIG_LIST += \
24b75b0a81SMasahiro Yamada	/lib/modules/$(kernel-release)/.config \
25b75b0a81SMasahiro Yamada	/etc/kernel-config \
26*f02aa48dSMasahiro Yamada	/boot/config-$(kernel-release)
27b75b0a81SMasahiro Yamadaendif
28*f02aa48dSMasahiro 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 \
7289b90609STetsuo Handa	helpnewconfig yes2modconfig mod2yesconfig
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'
137861b4ea4SSam Ravnborg	@echo  '  listnewconfig   - List new options'
1385d8b42aaSLaura Abbott	@echo  '  helpnewconfig   - List new options and help text'
139cedd55d4SMarc Herbert	@echo  '  olddefconfig	  - Same as oldconfig but sets new symbols to their'
140cedd55d4SMarc Herbert	@echo  '                    default value without prompting'
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# object files used by all kconfig flavours
146769a1c02SMasahiro Yamadacommon-objs	:= confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
147521b29b6SMasahiro Yamada		   symbol.o util.o
1481da177e4SLinus Torvalds
149769a1c02SMasahiro Yamada$(obj)/lexer.lex.o: $(obj)/parser.tab.h
1509cc342f6SMasahiro YamadaHOSTCFLAGS_lexer.lex.o	:= -I $(srctree)/$(src)
1519cc342f6SMasahiro YamadaHOSTCFLAGS_parser.tab.o	:= -I $(srctree)/$(src)
1521da177e4SLinus Torvalds
153558e78e3SMasahiro Yamada# conf: Used for defconfig, oldconfig and related targets
1545f2fb52fSMasahiro Yamadahostprogs	+= conf
155558e78e3SMasahiro Yamadaconf-objs	:= conf.o $(common-objs)
156558e78e3SMasahiro Yamada
1571c5af5cfSMasahiro Yamada# nconf: Used for the nconfig target based on ncurses
1585f2fb52fSMasahiro Yamadahostprogs	+= nconf
159558e78e3SMasahiro Yamadanconf-objs	:= nconf.o nconf.gui.o $(common-objs)
1607080e47bSArnaud Lacombe
161d86271afSMasahiro YamadaHOSTLDLIBS_nconf	= $(shell . $(obj)/nconf-cfg && echo $$libs)
162d86271afSMasahiro YamadaHOSTCFLAGS_nconf.o	= $(shell . $(obj)/nconf-cfg && echo $$cflags)
163d86271afSMasahiro YamadaHOSTCFLAGS_nconf.gui.o	= $(shell . $(obj)/nconf-cfg && echo $$cflags)
1641c5af5cfSMasahiro Yamada
165d86271afSMasahiro Yamada$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
1661c5af5cfSMasahiro Yamada
1671c5af5cfSMasahiro Yamada# mconf: Used for the menuconfig target based on lxdialog
1685f2fb52fSMasahiro Yamadahostprogs	+= mconf
16954b8ae66SMasahiro Yamadalxdialog	:= $(addprefix lxdialog/, \
17054b8ae66SMasahiro Yamada		     checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
17154b8ae66SMasahiro Yamadamconf-objs	:= mconf.o $(lxdialog) $(common-objs)
1721c5af5cfSMasahiro Yamada
173d86271afSMasahiro YamadaHOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
1741c5af5cfSMasahiro Yamada$(foreach f, mconf.o $(lxdialog), \
175d86271afSMasahiro Yamada  $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
1761c5af5cfSMasahiro Yamada
17754b8ae66SMasahiro Yamada$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
1781da177e4SLinus Torvalds
1790b669a50SMasahiro Yamada# qconf: Used for the xconfig target based on Qt
1805f2fb52fSMasahiro Yamadahostprogs	+= qconf
1810e912c03SMasahiro Yamadaqconf-cxxobjs	:= qconf.o qconf-moc.o
1823b541978SMasahiro Yamadaqconf-objs	:= images.o $(common-objs)
1831da177e4SLinus Torvalds
184d86271afSMasahiro YamadaHOSTLDLIBS_qconf	= $(shell . $(obj)/qconf-cfg && echo $$libs)
185d86271afSMasahiro YamadaHOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/qconf-cfg && echo $$cflags)
1860e912c03SMasahiro YamadaHOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
1870b669a50SMasahiro Yamada
1880e912c03SMasahiro Yamada$(obj)/qconf.o: $(obj)/qconf-cfg
1890b669a50SMasahiro Yamada
1900b669a50SMasahiro Yamadaquiet_cmd_moc = MOC     $@
1910e912c03SMasahiro Yamada      cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
1920b669a50SMasahiro Yamada
1930e912c03SMasahiro Yamada$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
194c3cd7cfaSMasahiro Yamada	$(call if_changed,moc)
195c3cd7cfaSMasahiro Yamada
1960e912c03SMasahiro Yamadatargets += qconf-moc.cc
1971da177e4SLinus Torvalds
198b464ef58SMasahiro Yamada# gconf: Used for the gconfig target based on GTK+
1995f2fb52fSMasahiro Yamadahostprogs	+= gconf
2003b541978SMasahiro Yamadagconf-objs	:= gconf.o images.o $(common-objs)
2011da177e4SLinus Torvalds
202d86271afSMasahiro YamadaHOSTLDLIBS_gconf    = $(shell . $(obj)/gconf-cfg && echo $$libs)
203d86271afSMasahiro YamadaHOSTCFLAGS_gconf.o  = $(shell . $(obj)/gconf-cfg && echo $$cflags)
2041da177e4SLinus Torvalds
205d86271afSMasahiro Yamada$(obj)/gconf.o: $(obj)/gconf-cfg
2061da177e4SLinus Torvalds
2070b669a50SMasahiro Yamada# check if necessary packages are available, and configure build flags
208ba97df45SMasahiro Yamadafilechk_conf_cfg = $(CONFIG_SHELL) $<
2090b669a50SMasahiro Yamada
210d86271afSMasahiro Yamada$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
2110b669a50SMasahiro Yamada	$(call filechk,conf_cfg)
2120b669a50SMasahiro Yamada
2132648ca18SMasahiro Yamadaclean-files += *conf-cfg
214