blob: 5a215880b2688c2ffadd3248410ee29cf19c510c [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 \
Tetsuo Handa89b90602019-12-17 18:42:06 +090072 helpnewconfig yes2modconfig mod2yesconfig
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'
Sam Ravnborg861b4ea2010-07-31 23:35:28 +0200137 @echo ' listnewconfig - List new options'
Laura Abbott5d8b42a2019-11-04 17:10:08 -0500138 @echo ' helpnewconfig - List new options and help text'
Marc Herbertcedd55d2018-01-26 14:59:00 -0800139 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
140 @echo ' default value without prompting'
Josh Triplett0da1d4a2014-08-08 16:25:47 -0700141 @echo ' tinyconfig - Configure the tiniest possible kernel'
Petr Voreld6a0c8a2018-06-02 11:08:02 +0200142 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144# ===========================================================================
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145# object files used by all kconfig flavours
Masahiro Yamadaa77a05d2021-04-14 00:08:17 +0900146common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
147 preprocess.o symbol.o util.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Masahiro Yamada769a1c02019-01-24 19:47:30 +0900149$(obj)/lexer.lex.o: $(obj)/parser.tab.h
Masahiro Yamada9cc342f2019-05-13 15:22:16 +0900150HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
151HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900153# conf: Used for defconfig, oldconfig and related targets
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900154hostprogs += conf
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900155conf-objs := conf.o $(common-objs)
156
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900157# nconf: Used for the nconfig target based on ncurses
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900158hostprogs += nconf
Masahiro Yamada558e78e2018-12-21 17:33:04 +0900159nconf-objs := nconf.o nconf.gui.o $(common-objs)
Arnaud Lacombe7080e472010-08-16 00:19:04 -0400160
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900161HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs)
162HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
163HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900164
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900165$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900166
167# mconf: Used for the menuconfig target based on lxdialog
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900168hostprogs += mconf
Masahiro Yamada54b8ae62019-08-30 13:34:01 +0900169lxdialog := $(addprefix lxdialog/, \
170 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
171mconf-objs := mconf.o $(lxdialog) $(common-objs)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900172
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900173HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900174$(foreach f, mconf.o $(lxdialog), \
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900175 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
Masahiro Yamada1c5af5c2018-05-22 16:22:21 +0900176
Masahiro Yamada54b8ae62019-08-30 13:34:01 +0900177$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900179# qconf: Used for the xconfig target based on Qt
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900180hostprogs += qconf
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900181qconf-cxxobjs := qconf.o qconf-moc.o
Masahiro Yamada3b541978562018-12-21 17:33:07 +0900182qconf-objs := images.o $(common-objs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900184HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs)
185HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900186HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900187
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900188$(obj)/qconf.o: $(obj)/qconf-cfg
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900189
190quiet_cmd_moc = MOC $@
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900191 cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900192
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900193$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
Masahiro Yamadac3cd7cf2020-07-30 02:02:37 +0900194 $(call if_changed,moc)
195
Masahiro Yamada0e912c02020-07-30 02:02:38 +0900196targets += qconf-moc.cc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Masahiro Yamadab464ef52018-05-22 16:22:20 +0900198# gconf: Used for the gconfig target based on GTK+
Masahiro Yamada5f2fb522020-02-02 01:49:24 +0900199hostprogs += gconf
Masahiro Yamada3b541978562018-12-21 17:33:07 +0900200gconf-objs := gconf.o images.o $(common-objs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900202HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs)
203HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900205$(obj)/gconf.o: $(obj)/gconf-cfg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900207# check if necessary packages are available, and configure build flags
Masahiro Yamadaba97df42019-01-03 10:16:54 +0900208filechk_conf_cfg = $(CONFIG_SHELL) $<
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900209
Masahiro Yamadad86271a2019-01-05 12:01:51 +0900210$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
Masahiro Yamada0b669a52018-05-22 16:22:19 +0900211 $(call filechk,conf_cfg)
212
Masahiro Yamada2648ca12019-01-11 11:51:48 +0900213clean-files += *conf-cfg