blob: e46df0a2d4f9d200bee7ccaf3528431eca45206a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002# ===========================================================================
3# Kernel configuration targets
4# These targets are used from top-level makefile
5
Randy Dunlap4bf6a9a2018-08-14 17:36:49 -07006PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \
7 build_menuconfig build_nconfig build_gconfig build_xconfig
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Al Viro61bee202008-08-25 04:51:27 -04009ifdef KBUILD_KCONFIG
10Kconfig := $(KBUILD_KCONFIG)
11else
Arnaud Lacombe838a2e52010-09-04 17:10:20 -040012Kconfig := Kconfig
Al Viro61bee202008-08-25 04:51:27 -040013endif
Sam Ravnborge703f752007-10-25 20:42:18 +020014
Michal Marek0a1f00a2015-04-08 13:30:42 +020015ifeq ($(quiet),silent_)
16silent := -s
17endif
18
Yann E. MORINc2838e62012-11-22 01:06:04 +010019# We need this, in case the user has it in its environment
20unexport CONFIG_
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022xconfig: $(obj)/qconf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090023 $(Q)$< $(silent) $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25gconfig: $(obj)/gconf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090026 $(Q)$< $(silent) $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28menuconfig: $(obj)/mconf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090029 $(Q)$< $(silent) $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31config: $(obj)/conf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090032 $(Q)$< $(silent) --oldaskconfig $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020034nconfig: $(obj)/nconf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090035 $(Q)$< $(silent) $(Kconfig)
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020036
Randy Dunlap4bf6a9a2018-08-14 17:36:49 -070037build_menuconfig: $(obj)/mconf
38
39build_nconfig: $(obj)/nconf
40
41build_gconfig: $(obj)/gconf
42
43build_xconfig: $(obj)/qconf
44
Ulf Magnusson2a616252018-03-01 12:18:01 +010045localyesconfig localmodconfig: $(obj)/conf
Masahiro Yamadac8138a52019-12-17 13:18:19 +090046 $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
Masahiro Yamada1d135232019-12-17 13:18:18 +090047 $(Q)if [ -f .config ]; then \
48 cmp -s .tmp.config .config || \
49 (mv -f .config .config.old.1; \
50 mv -f .tmp.config .config; \
51 $< $(silent) --oldconfig $(Kconfig); \
52 mv -f .config.old.1 .config.old) \
53 else \
54 mv -f .tmp.config .config; \
55 $< $(silent) --oldconfig $(Kconfig); \
Steven Rostedta7c02602009-05-07 11:09:55 -040056 fi
Steven Rostedt03fa25d2009-04-29 22:52:22 -040057 $(Q)rm -f .tmp.config
58
Michal Marek1cba0c32015-04-08 11:11:57 +020059# These targets map 1:1 to the commandline options of 'conf'
Masahiro Yamada79123b12018-07-20 16:46:29 +090060#
61# Note:
62# syncconfig has become an internal implementation detail and is now
63# deprecated for external use
Michal Marek1cba0c32015-04-08 11:11:57 +020064simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
Laura Abbott5d8b42a2019-11-04 17:10:08 -050065 alldefconfig randconfig listnewconfig olddefconfig syncconfig \
Tetsuo Handa89b90602019-12-17 18:42:06 +090066 helpnewconfig yes2modconfig mod2yesconfig
Laura Abbott5d8b42a2019-11-04 17:10:08 -050067
Michal Marek1cba0c32015-04-08 11:11:57 +020068PHONY += $(simple-targets)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Michal Marek1cba0c32015-04-08 11:11:57 +020070$(simple-targets): $(obj)/conf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090071 $(Q)$< $(silent) --$@ $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Masahiro Yamada0085b412018-10-30 00:41:28 +090073PHONY += savedefconfig defconfig
Masahiro Yamada911a91c2018-03-01 15:34:37 +090074
Sam Ravnborg7cf3d732010-07-31 23:35:34 +020075savedefconfig: $(obj)/conf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090076 $(Q)$< $(silent) --$@=defconfig $(Kconfig)
Sam Ravnborg7cf3d732010-07-31 23:35:34 +020077
Linus Torvalds1da177e2005-04-16 15:20:36 -070078defconfig: $(obj)/conf
Masahiro Yamadae0a26682019-05-27 23:37:21 +090079ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
Michal Marek0a1f00a2015-04-08 13:30:42 +020080 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
81 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
Michael Ellermand2036f32015-09-23 15:40:34 +100082else
83 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
84 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085endif
86
87%_defconfig: $(obj)/conf
Michal Marek0a1f00a2015-04-08 13:30:42 +020088 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Masahiro Yamada63a91032015-03-13 15:21:43 +090090configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
Josh Triplett3aaefce2014-08-06 15:21:00 -070091
Masahiro Yamada63a91032015-03-13 15:21:43 +090092%.config: $(obj)/conf
93 $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
94 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
Masahiro Yamada3266c802019-06-05 03:14:53 +090095 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
Josh Triplett3aaefce2014-08-06 15:21:00 -070096
Greg Kroah-Hartman57dc19a2021-01-20 11:48:09 +010097PHONY += kvmconfig
98kvmconfig: kvm_guest.config
99 @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10"
100 @echo >&2 " Please use 'make $<' instead."
101
102PHONY += xenconfig
103xenconfig: xen.config
104 @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10"
105 @echo >&2 " Please use 'make $<' instead."
106
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700107PHONY += tinyconfig
Masahiro Yamada63a91032015-03-13 15:21:43 +0900108tinyconfig:
109 $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700110
Masahiro Yamada022a4bf2018-03-13 18:12:03 +0900111# CHECK: -o cache_dir=<path> working?
112PHONY += testconfig
113testconfig: $(obj)/conf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +0900114 $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
Masahiro Yamada022a4bf2018-03-13 18:12:03 +0900115 -o cache_dir=$(abspath $(obj)/tests/.cache) \
116 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
Masahiro Yamada1634f2b2019-08-25 10:31:27 +0900117clean-files += tests/.cache
Masahiro Yamada022a4bf2018-03-13 18:12:03 +0900118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119# Help text used by make help
120help:
121 @echo ' config - Update current config utilising a line-oriented program'
Petr Vorelbb6d83d2018-06-02 11:08:03 +0200122 @echo ' nconfig - Update current config utilising a ncurses menu based program'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 @echo ' menuconfig - Update current config utilising a menu based program'
Diego Viola092373c2015-04-06 06:27:45 -0300124 @echo ' xconfig - Update current config utilising a Qt based front-end'
Diego Viola39c3f1b2015-05-31 14:35:51 -0300125 @echo ' gconfig - Update current config utilising a GTK+ based front-end'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 @echo ' oldconfig - Update current config utilising a provided .config as base'
Steven Rostedt03fa25d2009-04-29 22:52:22 -0400127 @echo ' localmodconfig - Update current config disabling modules not loaded'
Changbin Duc027b022020-05-12 23:36:07 +0800128 @echo ' except those preserved by LMC_KEEP environment variable'
Steven Rostedt281c9da2009-04-29 22:52:23 -0400129 @echo ' localyesconfig - Update current config converting local mods to core'
Changbin Duc027b022020-05-12 23:36:07 +0800130 @echo ' except those preserved by LMC_KEEP environment variable'
Sam Ravnborg0748cb32010-07-31 23:35:31 +0200131 @echo ' defconfig - New config with default from ARCH supplied defconfig'
Sam Ravnborg7cf3d732010-07-31 23:35:34 +0200132 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
Jesper Juhle11f0492006-02-25 21:52:50 +0100133 @echo ' allnoconfig - New config where all options are answered with no'
Sam Ravnborg0748cb32010-07-31 23:35:31 +0200134 @echo ' allyesconfig - New config where all options are accepted with yes'
135 @echo ' allmodconfig - New config selecting modules when possible'
136 @echo ' alldefconfig - New config with all symbols set to default'
137 @echo ' randconfig - New config with random answer to all options'
Tetsuo Handa89b90602019-12-17 18:42:06 +0900138 @echo ' yes2modconfig - Change answers from yes to mod if possible'
139 @echo ' mod2yesconfig - Change answers from mod to yes if possible'
Sam Ravnborg861b4ea2010-07-31 23:35:28 +0200140 @echo ' listnewconfig - List new options'
Laura Abbott5d8b42a2019-11-04 17:10:08 -0500141 @echo ' helpnewconfig - List new options and help text'
Marc Herbertcedd55d2018-01-26 14:59:00 -0800142 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
143 @echo ' default value without prompting'
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700144 @echo ' tinyconfig - Configure the tiniest possible kernel'
Petr Voreld6a0c8a2018-06-02 11:08:02 +0200145 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147# ===========================================================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148# object files used by all kconfig flavours
Masahiro Yamada769a1c02019-01-24 19:47:30 +0900149common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
Masahiro Yamada521b29b2019-08-26 02:28:33 +0900150 symbol.o util.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
Masahiro Yamada769a1c02019-01-24 19:47:30 +0900152$(obj)/lexer.lex.o: $(obj)/parser.tab.h
Masahiro Yamada9cc342f2019-05-13 15:22:16 +0900153HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
154HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900156# conf: Used for defconfig, oldconfig and related targets
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900157hostprogs += conf
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900158conf-objs := conf.o $(common-objs)
159
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900160# nconf: Used for the nconfig target based on ncurses
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900161hostprogs += nconf
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900162nconf-objs := nconf.o nconf.gui.o $(common-objs)
Arnaud Lacombe7080e472010-08-16 00:19:04 -0400163
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900164HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs)
165HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
166HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900167
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900168$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900169
170# mconf: Used for the menuconfig target based on lxdialog
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900171hostprogs += mconf
Masahiro Yamada54b8ae62019-08-30 13:34:01 +0900172lxdialog := $(addprefix lxdialog/, \
173 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
174mconf-objs := mconf.o $(lxdialog) $(common-objs)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900175
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900176HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900177$(foreach f, mconf.o $(lxdialog), \
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900178 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900179
Masahiro Yamada54b8ae62019-08-30 13:34:01 +0900180$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900182# qconf: Used for the xconfig target based on Qt
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900183hostprogs += qconf
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900184qconf-cxxobjs := qconf.o qconf-moc.o
Masahiro Yamada3b541978562018-12-21 17:33:07 +0900185qconf-objs := images.o $(common-objs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900187HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs)
188HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900189HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900190
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900191$(obj)/qconf.o: $(obj)/qconf-cfg
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900192
193quiet_cmd_moc = MOC $@
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900194 cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900195
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900196$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
Masahiro Yamadac3cd7cf2020-07-30 02:02:37 +0900197 $(call if_changed,moc)
198
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900199targets += qconf-moc.cc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
Masahiro Yamadab464ef52018-05-22 16:22:20 +0900201# gconf: Used for the gconfig target based on GTK+
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900202hostprogs += gconf
Masahiro Yamada3b541978562018-12-21 17:33:07 +0900203gconf-objs := gconf.o images.o $(common-objs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900205HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs)
206HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900208$(obj)/gconf.o: $(obj)/gconf-cfg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900210# check if necessary packages are available, and configure build flags
Masahiro Yamadaba97df42019-01-03 10:16:54 +0900211filechk_conf_cfg = $(CONFIG_SHELL) $<
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900212
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900213$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900214 $(call filechk,conf_cfg)
215
Masahiro Yamada2648ca12019-01-11 11:51:48 +0900216clean-files += *conf-cfg