blob: af1c96198f4919c1af966e5fc06dcddb7c405fef [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
Al Viro61bee202008-08-25 04:51:27 -04006ifdef KBUILD_KCONFIG
7Kconfig := $(KBUILD_KCONFIG)
8else
Arnaud Lacombe838a2e52010-09-04 17:10:20 -04009Kconfig := Kconfig
Al Viro61bee202008-08-25 04:51:27 -040010endif
Sam Ravnborge703f752007-10-25 20:42:18 +020011
Masahiro Yamadadd465992021-03-14 04:48:33 +090012ifndef KBUILD_DEFCONFIG
13KBUILD_DEFCONFIG := defconfig
14endif
15
Michal Marek0a1f00a2015-04-08 13:30:42 +020016ifeq ($(quiet),silent_)
17silent := -s
18endif
19
Masahiro Yamadab75b0a82021-03-14 04:48:32 +090020export KCONFIG_DEFCONFIG_LIST :=
Masahiro Yamadaf02aa482021-04-10 23:31:58 +090021ifndef cross_compiling
Masahiro Yamadab75b0a82021-03-14 04:48:32 +090022kernel-release := $(shell uname -r)
Masahiro Yamadaf02aa482021-04-10 23:31:58 +090023KCONFIG_DEFCONFIG_LIST += \
Masahiro Yamadab75b0a82021-03-14 04:48:32 +090024 /lib/modules/$(kernel-release)/.config \
25 /etc/kernel-config \
Masahiro Yamadaf02aa482021-04-10 23:31:58 +090026 /boot/config-$(kernel-release)
Masahiro Yamadab75b0a82021-03-14 04:48:32 +090027endif
Masahiro Yamadaf02aa482021-04-10 23:31:58 +090028KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
Masahiro Yamadab75b0a82021-03-14 04:48:32 +090029
Yann E. MORINc2838e62012-11-22 01:06:04 +010030# We need this, in case the user has it in its environment
31unexport CONFIG_
32
Masahiro Yamadaf91e46b2021-02-21 22:03:18 +090033config-prog := conf
34menuconfig-prog := mconf
35nconfig-prog := nconf
36gconfig-prog := gconf
37xconfig-prog := qconf
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Masahiro Yamadaf91e46b2021-02-21 22:03:18 +090039define config_rule
40PHONY += $(1)
41$(1): $(obj)/$($(1)-prog)
42 $(Q)$$< $(silent) $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Masahiro Yamadaf91e46b2021-02-21 22:03:18 +090044PHONY += build_$(1)
45build_$(1): $(obj)/$($(1)-prog)
46endef
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Masahiro Yamadaf91e46b2021-02-21 22:03:18 +090048$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c))))
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Masahiro Yamadaf91e46b2021-02-21 22:03:18 +090050PHONY += localmodconfig localyesconfig
Ulf Magnusson2a616252018-03-01 12:18:01 +010051localyesconfig localmodconfig: $(obj)/conf
Masahiro Yamadac8138a52019-12-17 13:18:19 +090052 $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
Masahiro Yamada1d135232019-12-17 13:18:18 +090053 $(Q)if [ -f .config ]; then \
54 cmp -s .tmp.config .config || \
55 (mv -f .config .config.old.1; \
56 mv -f .tmp.config .config; \
57 $< $(silent) --oldconfig $(Kconfig); \
58 mv -f .config.old.1 .config.old) \
59 else \
60 mv -f .tmp.config .config; \
61 $< $(silent) --oldconfig $(Kconfig); \
Steven Rostedta7c02602009-05-07 11:09:55 -040062 fi
Steven Rostedt03fa25d2009-04-29 22:52:22 -040063 $(Q)rm -f .tmp.config
64
Michal Marek1cba0c32015-04-08 11:11:57 +020065# These targets map 1:1 to the commandline options of 'conf'
Masahiro Yamada79123b12018-07-20 16:46:29 +090066#
67# Note:
68# syncconfig has become an internal implementation detail and is now
69# deprecated for external use
Michal Marek1cba0c32015-04-08 11:11:57 +020070simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
Laura Abbott5d8b42a2019-11-04 17:10:08 -050071 alldefconfig randconfig listnewconfig olddefconfig syncconfig \
Josh Triplettc39afe62021-10-17 19:43:13 +020072 helpnewconfig yes2modconfig mod2yesconfig mod2noconfig
Laura Abbott5d8b42a2019-11-04 17:10:08 -050073
Michal Marek1cba0c32015-04-08 11:11:57 +020074PHONY += $(simple-targets)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Michal Marek1cba0c32015-04-08 11:11:57 +020076$(simple-targets): $(obj)/conf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090077 $(Q)$< $(silent) --$@ $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Masahiro Yamada0085b412018-10-30 00:41:28 +090079PHONY += savedefconfig defconfig
Masahiro Yamada911a91c2018-03-01 15:34:37 +090080
Sam Ravnborg7cf3d732010-07-31 23:35:34 +020081savedefconfig: $(obj)/conf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +090082 $(Q)$< $(silent) --$@=defconfig $(Kconfig)
Sam Ravnborg7cf3d732010-07-31 23:35:34 +020083
Linus Torvalds1da177e2005-04-16 15:20:36 -070084defconfig: $(obj)/conf
Masahiro Yamadae0a26682019-05-27 23:37:21 +090085ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
Michal Marek0a1f00a2015-04-08 13:30:42 +020086 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
87 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
Michael Ellermand2036f32015-09-23 15:40:34 +100088else
89 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
90 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091endif
92
93%_defconfig: $(obj)/conf
Michal Marek0a1f00a2015-04-08 13:30:42 +020094 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Masahiro Yamada63a91032015-03-13 15:21:43 +090096configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
Josh Triplett3aaefce2014-08-06 15:21:00 -070097
Masahiro Yamada63a91032015-03-13 15:21:43 +090098%.config: $(obj)/conf
99 $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
100 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
Masahiro Yamada3266c802019-06-05 03:14:53 +0900101 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
Josh Triplett3aaefce2014-08-06 15:21:00 -0700102
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700103PHONY += tinyconfig
Masahiro Yamada63a91032015-03-13 15:21:43 +0900104tinyconfig:
Masahiro Yamadaf8f0d062021-03-14 04:48:34 +0900105 $(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig
106 $(Q)$(MAKE) -f $(srctree)/Makefile tiny.config
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700107
Masahiro Yamada022a4bf2018-03-13 18:12:03 +0900108# CHECK: -o cache_dir=<path> working?
109PHONY += testconfig
110testconfig: $(obj)/conf
Masahiro Yamada23cd88c2020-08-21 11:43:58 +0900111 $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
Masahiro Yamada022a4bf2018-03-13 18:12:03 +0900112 -o cache_dir=$(abspath $(obj)/tests/.cache) \
113 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
Masahiro Yamada1634f2b2019-08-25 10:31:27 +0900114clean-files += tests/.cache
Masahiro Yamada022a4bf2018-03-13 18:12:03 +0900115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116# Help text used by make help
117help:
118 @echo ' config - Update current config utilising a line-oriented program'
Petr Vorelbb6d83d2018-06-02 11:08:03 +0200119 @echo ' nconfig - Update current config utilising a ncurses menu based program'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 @echo ' menuconfig - Update current config utilising a menu based program'
Diego Viola092373c2015-04-06 06:27:45 -0300121 @echo ' xconfig - Update current config utilising a Qt based front-end'
Diego Viola39c3f1b2015-05-31 14:35:51 -0300122 @echo ' gconfig - Update current config utilising a GTK+ based front-end'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 @echo ' oldconfig - Update current config utilising a provided .config as base'
Steven Rostedt03fa25d2009-04-29 22:52:22 -0400124 @echo ' localmodconfig - Update current config disabling modules not loaded'
Changbin Duc027b022020-05-12 23:36:07 +0800125 @echo ' except those preserved by LMC_KEEP environment variable'
Steven Rostedt281c9da2009-04-29 22:52:23 -0400126 @echo ' localyesconfig - Update current config converting local mods to core'
Changbin Duc027b022020-05-12 23:36:07 +0800127 @echo ' except those preserved by LMC_KEEP environment variable'
Sam Ravnborg0748cb32010-07-31 23:35:31 +0200128 @echo ' defconfig - New config with default from ARCH supplied defconfig'
Sam Ravnborg7cf3d732010-07-31 23:35:34 +0200129 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
Jesper Juhle11f0492006-02-25 21:52:50 +0100130 @echo ' allnoconfig - New config where all options are answered with no'
Sam Ravnborg0748cb32010-07-31 23:35:31 +0200131 @echo ' allyesconfig - New config where all options are accepted with yes'
132 @echo ' allmodconfig - New config selecting modules when possible'
133 @echo ' alldefconfig - New config with all symbols set to default'
134 @echo ' randconfig - New config with random answer to all options'
Tetsuo Handa89b90602019-12-17 18:42:06 +0900135 @echo ' yes2modconfig - Change answers from yes to mod if possible'
136 @echo ' mod2yesconfig - Change answers from mod to yes if possible'
Josh Triplettc39afe62021-10-17 19:43:13 +0200137 @echo ' mod2noconfig - Change answers from mod to no if possible'
Sam Ravnborg861b4ea2010-07-31 23:35:28 +0200138 @echo ' listnewconfig - List new options'
Laura Abbott5d8b42a2019-11-04 17:10:08 -0500139 @echo ' helpnewconfig - List new options and help text'
Marc Herbertcedd55d2018-01-26 14:59:00 -0800140 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
141 @echo ' default value without prompting'
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700142 @echo ' tinyconfig - Configure the tiniest possible kernel'
Petr Voreld6a0c8a2018-06-02 11:08:02 +0200143 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145# ===========================================================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146# object files used by all kconfig flavours
Masahiro Yamadaa77a05d2021-04-14 00:08:17 +0900147common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
148 preprocess.o symbol.o util.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Masahiro Yamada769a1c02019-01-24 19:47:30 +0900150$(obj)/lexer.lex.o: $(obj)/parser.tab.h
Masahiro Yamada9cc342f2019-05-13 15:22:16 +0900151HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
152HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900154# conf: Used for defconfig, oldconfig and related targets
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900155hostprogs += conf
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900156conf-objs := conf.o $(common-objs)
157
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900158# nconf: Used for the nconfig target based on ncurses
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900159hostprogs += nconf
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900160nconf-objs := nconf.o nconf.gui.o $(common-objs)
Arnaud Lacombe7080e472010-08-16 00:19:04 -0400161
Masahiro Yamada3122c842022-12-11 11:54:48 +0900162HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs)
163HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags)
164HOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900165
Masahiro Yamada3122c842022-12-11 11:54:48 +0900166$(obj)/nconf: | $(obj)/nconf-libs
167$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900168
169# mconf: Used for the menuconfig target based on lxdialog
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900170hostprogs += mconf
Masahiro Yamada54b8ae62019-08-30 13:34:01 +0900171lxdialog := $(addprefix lxdialog/, \
172 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
173mconf-objs := mconf.o $(lxdialog) $(common-objs)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900174
Masahiro Yamada3122c842022-12-11 11:54:48 +0900175HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900176$(foreach f, mconf.o $(lxdialog), \
Masahiro Yamada3122c842022-12-11 11:54:48 +0900177 $(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags)))
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900178
Masahiro Yamada3122c842022-12-11 11:54:48 +0900179$(obj)/mconf: | $(obj)/mconf-libs
180$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags
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 Yamada3122c842022-12-11 11:54:48 +0900187HOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs)
188HOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
189HOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
190$(obj)/qconf: | $(obj)/qconf-libs
191$(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900192
193quiet_cmd_moc = MOC $@
Masahiro Yamada3122c842022-12-11 11:54:48 +0900194 cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900195
Masahiro Yamada3122c842022-12-11 11:54:48 +0900196$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin
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 Yamada3122c842022-12-11 11:54:48 +0900205HOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs)
206HOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
Masahiro Yamada3122c842022-12-11 11:54:48 +0900208$(obj)/gconf: | $(obj)/gconf-libs
209$(obj)/gconf.o: | $(obj)/gconf-cflags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900211# check if necessary packages are available, and configure build flags
Peter Foleyaedee9e2023-01-12 23:23:59 -0500212cmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin); touch $(obj)/$*conf-bin
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900213
Masahiro Yamada3122c842022-12-11 11:54:48 +0900214$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh
215 $(call cmd,conf_cfg)
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900216
Masahiro Yamada3122c842022-12-11 11:54:48 +0900217clean-files += *conf-cflags *conf-libs *conf-bin