blob: 30b90cfde2382652d4342d223d926c3e53eb9a59 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0
Masahiro Yamada0a9064f2014-07-30 14:08:13 +09002# ===========================================================================
3# Kernel configuration targets
4# These targets are used from top-level makefile
5
Tom Rini5972ff02020-03-11 18:11:17 -04006PHONY += xconfig gconfig menuconfig config syncconfig \
Masahiro Yamada0a9064f2014-07-30 14:08:13 +09007 localmodconfig localyesconfig
8
Masahiro Yamada5f9eb222015-03-13 18:08:55 +09009# Added for U-Boot
10# Linux has defconfig files in arch/$(SRCARCH)/configs/,
11# on the other hand, U-Boot does in configs/.
12# Set SRCARCH to .. fake this Makefile.
13SRCARCH := ..
14
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090015ifdef KBUILD_KCONFIG
16Kconfig := $(KBUILD_KCONFIG)
17else
18Kconfig := Kconfig
19endif
20
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090021ifeq ($(quiet),silent_)
22silent := -s
23endif
24
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090025# We need this, in case the user has it in its environment
26unexport CONFIG_
27
28xconfig: $(obj)/qconf
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090029 $< $(silent) $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090030
31gconfig: $(obj)/gconf
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090032 $< $(silent) $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090033
34menuconfig: $(obj)/mconf
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090035 $< $(silent) $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090036
37config: $(obj)/conf
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090038 $< $(silent) --oldaskconfig $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090039
40nconfig: $(obj)/nconf
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090041 $< $(silent) $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090042
Eugeniu Roscae91610d2018-05-19 14:13:50 +020043# This has become an internal implementation detail and is now deprecated
44# for external use.
45syncconfig: $(obj)/conf
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090046 $(Q)mkdir -p include/config include/generated
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090047 $< $(silent) --$@ $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090048
Eugeniu Roscae91610d2018-05-19 14:13:50 +020049localyesconfig localmodconfig: $(obj)/conf
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090050 $(Q)mkdir -p include/config include/generated
Eugeniu Roscae91610d2018-05-19 14:13:50 +020051 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090052 $(Q)if [ -f .config ]; then \
53 cmp -s .tmp.config .config || \
54 (mv -f .config .config.old.1; \
55 mv -f .tmp.config .config; \
Eugeniu Roscae91610d2018-05-19 14:13:50 +020056 $< $(silent) --oldconfig $(Kconfig); \
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090057 mv -f .config.old.1 .config.old) \
58 else \
59 mv -f .tmp.config .config; \
Eugeniu Roscae91610d2018-05-19 14:13:50 +020060 $< $(silent) --oldconfig $(Kconfig); \
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090061 fi
62 $(Q)rm -f .tmp.config
63
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090064# These targets map 1:1 to the commandline options of 'conf'
65simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
66 alldefconfig randconfig listnewconfig olddefconfig
67PHONY += $(simple-targets)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090068
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090069$(simple-targets): $(obj)/conf
70 $< $(silent) --$@ $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090071
Eugeniu Roscae91610d2018-05-19 14:13:50 +020072PHONY += oldnoconfig silentoldconfig savedefconfig defconfig
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090073
74# oldnoconfig is an alias of olddefconfig, because people already are dependent
Masahiro Yamadabf7ab1e2017-02-11 12:39:54 +090075# on its behavior (sets new symbols to their default value but not 'n') with the
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090076# counter-intuitive name.
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090077oldnoconfig: olddefconfig
Eugeniu Roscae91610d2018-05-19 14:13:50 +020078 @echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19"
79 @echo " Please use \"olddefconfig\" instead, which is an alias."
80
81# We do not expect manual invokcation of "silentoldcofig" (or "syncconfig").
82silentoldconfig: syncconfig
83 @echo " WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\""
84 @echo " and is now an internal implementation detail."
85 @echo " What you want is probably \"oldconfig\"."
86 @echo " \"silentoldconfig\" will be removed after Linux 4.19"
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090087
88savedefconfig: $(obj)/conf
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090089 $< $(silent) --$@=defconfig $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090090
91defconfig: $(obj)/conf
92ifeq ($(KBUILD_DEFCONFIG),)
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090093 $< $(silent) --defconfig $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +090094else
Masahiro Yamadabf7ab1e2017-02-11 12:39:54 +090095ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +090096 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
97 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
Masahiro Yamadabf7ab1e2017-02-11 12:39:54 +090098else
99 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
100 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
101endif
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900102endif
103
104%_defconfig: $(obj)/conf
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +0900105 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900106
Masahiro Yamada5f9eb222015-03-13 18:08:55 +0900107# Added for U-Boot (backward compatibility)
108%_config: %_defconfig
109 @:
110
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +0900111configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
Masahiro Yamadaad618992014-10-30 11:06:12 +0900112
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +0900113%.config: $(obj)/conf
114 $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
115 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
116 +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
Masahiro Yamadaad618992014-10-30 11:06:12 +0900117
118PHONY += kvmconfig
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +0900119kvmconfig: kvm_guest.config
120 @:
Masahiro Yamadaad618992014-10-30 11:06:12 +0900121
Masahiro Yamadabf7ab1e2017-02-11 12:39:54 +0900122PHONY += xenconfig
123xenconfig: xen.config
124 @:
125
Masahiro Yamadaad618992014-10-30 11:06:12 +0900126PHONY += tinyconfig
Masahiro Yamada9b5f0b12015-07-05 01:56:54 +0900127tinyconfig:
128 $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
Masahiro Yamadaad618992014-10-30 11:06:12 +0900129
Eugeniu Roscae91610d2018-05-19 14:13:50 +0200130# CHECK: -o cache_dir=<path> working?
131PHONY += testconfig
132testconfig: $(obj)/conf
133 $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
134 -o cache_dir=$(abspath $(obj)/tests/.cache) \
135 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
136clean-dirs += tests/.cache
137
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900138# Help text used by make help
139help:
140 @echo ' config - Update current config utilising a line-oriented program'
Tom Rini5972ff02020-03-11 18:11:17 -0400141 @echo ' nconfig - Update current config utilising a ncurses menu based program'
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900142 @echo ' menuconfig - Update current config utilising a menu based program'
Masahiro Yamadabf7ab1e2017-02-11 12:39:54 +0900143 @echo ' xconfig - Update current config utilising a Qt based front-end'
144 @echo ' gconfig - Update current config utilising a GTK+ based front-end'
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900145 @echo ' oldconfig - Update current config utilising a provided .config as base'
146 @echo ' localmodconfig - Update current config disabling modules not loaded'
147 @echo ' localyesconfig - Update current config converting local mods to core'
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900148 @echo ' defconfig - New config with default from ARCH supplied defconfig'
149 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
150 @echo ' allnoconfig - New config where all options are answered with no'
151 @echo ' allyesconfig - New config where all options are accepted with yes'
152 @echo ' allmodconfig - New config selecting modules when possible'
153 @echo ' alldefconfig - New config with all symbols set to default'
154 @echo ' randconfig - New config with random answer to all options'
155 @echo ' listnewconfig - List new options'
Eugeniu Roscae91610d2018-05-19 14:13:50 +0200156 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
157 @echo ' default value without prompting'
Masahiro Yamadabf7ab1e2017-02-11 12:39:54 +0900158# @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
159# @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
Masahiro Yamadaad618992014-10-30 11:06:12 +0900160# @echo ' tinyconfig - Configure the tiniest possible kernel'
Tom Rini5972ff02020-03-11 18:11:17 -0400161 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900162
163# ===========================================================================
164# Shared Makefile for the various kconfig executables:
165# conf: Used for defconfig, oldconfig and related targets
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900166# object files used by all kconfig flavours
167
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900168conf-objs := conf.o zconf.tab.o
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900169
Tom Rini5972ff02020-03-11 18:11:17 -0400170hostprogs-y := conf
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900171
Eugeniu Roscae91610d2018-05-19 14:13:50 +0200172targets += zconf.lex.c
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900173
174# generated files seem to need this to find local include files
175HOSTCFLAGS_zconf.lex.o := -I$(src)
176HOSTCFLAGS_zconf.tab.o := -I$(src)
177
Tom Rini5972ff02020-03-11 18:11:17 -0400178# nconf: Used for the nconfig target based on ncurses
179hostprogs-y += nconf
180nconf-objs := nconf.o zconf.tab.o nconf.gui.o
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900181
Tom Rini5972ff02020-03-11 18:11:17 -0400182HOSTLOADLIBES_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
183HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
184HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900185
Tom Rini5972ff02020-03-11 18:11:17 -0400186$(obj)/nconf.o: $(obj)/.nconf-cfg
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900187
Tom Rini5972ff02020-03-11 18:11:17 -0400188# mconf: Used for the menuconfig target based on lxdialog
189hostprogs-y += mconf
190lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
191mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900192
Tom Rini5972ff02020-03-11 18:11:17 -0400193HOSTLOADLIBES_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
194$(foreach f, mconf.o $(lxdialog), \
195 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900196
Tom Rini5972ff02020-03-11 18:11:17 -0400197$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/.mconf-cfg
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900198
Tom Rini5972ff02020-03-11 18:11:17 -0400199# qconf: Used for the xconfig target based on Qt
200hostprogs-y += qconf
201qconf-cxxobjs := qconf.o
202qconf-objs := zconf.tab.o
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900203
Tom Rini5972ff02020-03-11 18:11:17 -0400204HOSTLOADLIBES_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs)
205HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900206
Tom Rini5972ff02020-03-11 18:11:17 -0400207$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
208
209quiet_cmd_moc = MOC $@
210 cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@
211
212$(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
213 $(call cmd,moc)
214
215# gconf: Used for the gconfig target based on GTK+
216hostprogs-y += gconf
217gconf-objs := gconf.o zconf.tab.o
218
219HOSTLOADLIBES_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
220HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags)
221
222$(obj)/gconf.o: $(obj)/.gconf-cfg
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900223
Eugeniu Roscae91610d2018-05-19 14:13:50 +0200224$(obj)/zconf.tab.o: $(obj)/zconf.lex.c
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900225
Tom Rini5972ff02020-03-11 18:11:17 -0400226# check if necessary packages are available, and configure build flags
227define filechk_conf_cfg
228 $(CONFIG_SHELL) $<
229endef
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900230
Tom Rini5972ff02020-03-11 18:11:17 -0400231$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE
232 $(call filechk,conf_cfg)
Masahiro Yamada0a9064f2014-07-30 14:08:13 +0900233
Tom Rini5972ff02020-03-11 18:11:17 -0400234clean-files += .*conf-cfg