Merge tag 'iommu-updates-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-block.git] / scripts / kconfig / Makefile
CommitLineData
b2441318 1# SPDX-License-Identifier: GPL-2.0
1da177e4
LT
2# ===========================================================================
3# Kernel configuration targets
4# These targets are used from top-level makefile
5
61bee204
AV
6ifdef KBUILD_KCONFIG
7Kconfig := $(KBUILD_KCONFIG)
8else
838a2e55 9Kconfig := Kconfig
61bee204 10endif
e703f75d 11
dd465996
MY
12ifndef KBUILD_DEFCONFIG
13KBUILD_DEFCONFIG := defconfig
14endif
15
0a1f00a1
MM
16ifeq ($(quiet),silent_)
17silent := -s
18endif
19
b75b0a81 20export KCONFIG_DEFCONFIG_LIST :=
f02aa48d 21ifndef cross_compiling
b75b0a81 22kernel-release := $(shell uname -r)
f02aa48d 23KCONFIG_DEFCONFIG_LIST += \
b75b0a81
MY
24 /lib/modules/$(kernel-release)/.config \
25 /etc/kernel-config \
f02aa48d 26 /boot/config-$(kernel-release)
b75b0a81 27endif
f02aa48d 28KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
b75b0a81 29
c2838e6e
YM
30# We need this, in case the user has it in its environment
31unexport CONFIG_
32
f91e46b1
MY
33config-prog := conf
34menuconfig-prog := mconf
35nconfig-prog := nconf
36gconfig-prog := gconf
37xconfig-prog := qconf
4bf6a9af 38
f91e46b1
MY
39define config_rule
40PHONY += $(1)
41$(1): $(obj)/$($(1)-prog)
42 $(Q)$$< $(silent) $(Kconfig)
4bf6a9af 43
f91e46b1
MY
44PHONY += build_$(1)
45build_$(1): $(obj)/$($(1)-prog)
46endef
4bf6a9af 47
f91e46b1 48$(foreach c, config menuconfig nconfig gconfig xconfig, $(eval $(call config_rule,$(c))))
4bf6a9af 49
f91e46b1 50PHONY += localmodconfig localyesconfig
2a616258 51localyesconfig localmodconfig: $(obj)/conf
c8138a57 52 $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
1d135237
MY
53 $(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); \
a7c02602 62 fi
03fa25da
SR
63 $(Q)rm -f .tmp.config
64
1cba0c30 65# These targets map 1:1 to the commandline options of 'conf'
79123b13
MY
66#
67# Note:
68# syncconfig has become an internal implementation detail and is now
69# deprecated for external use
1cba0c30 70simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
5d8b42aa 71 alldefconfig randconfig listnewconfig olddefconfig syncconfig \
c39afe62 72 helpnewconfig yes2modconfig mod2yesconfig mod2noconfig
5d8b42aa 73
1cba0c30 74PHONY += $(simple-targets)
1da177e4 75
1cba0c30 76$(simple-targets): $(obj)/conf
23cd88c9 77 $(Q)$< $(silent) --$@ $(Kconfig)
1da177e4 78
0085b419 79PHONY += savedefconfig defconfig
911a91c3 80
7cf3d73b 81savedefconfig: $(obj)/conf
23cd88c9 82 $(Q)$< $(silent) --$@=defconfig $(Kconfig)
7cf3d73b 83
1da177e4 84defconfig: $(obj)/conf
e0a26686 85ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
0a1f00a1
MM
86 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
87 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
d2036f30
ME
88else
89 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
90 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
1da177e4
LT
91endif
92
93%_defconfig: $(obj)/conf
0a1f00a1 94 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
1da177e4 95
63a91033 96configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
3aaefce1 97
63a91033
MY
98%.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)
3266c806 101 $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
3aaefce1 102
0da1d4a0 103PHONY += tinyconfig
63a91033 104tinyconfig:
f8f0d064
MY
105 $(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig
106 $(Q)$(MAKE) -f $(srctree)/Makefile tiny.config
0da1d4a0 107
022a4bf6
MY
108# CHECK: -o cache_dir=<path> working?
109PHONY += testconfig
110testconfig: $(obj)/conf
23cd88c9 111 $(Q)$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
022a4bf6
MY
112 -o cache_dir=$(abspath $(obj)/tests/.cache) \
113 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
1634f2bf 114clean-files += tests/.cache
022a4bf6 115
1da177e4
LT
116# Help text used by make help
117help:
118 @echo ' config - Update current config utilising a line-oriented program'
bb6d83dd 119 @echo ' nconfig - Update current config utilising a ncurses menu based program'
1da177e4 120 @echo ' menuconfig - Update current config utilising a menu based program'
092373c2 121 @echo ' xconfig - Update current config utilising a Qt based front-end'
39c3f1ba 122 @echo ' gconfig - Update current config utilising a GTK+ based front-end'
1da177e4 123 @echo ' oldconfig - Update current config utilising a provided .config as base'
03fa25da 124 @echo ' localmodconfig - Update current config disabling modules not loaded'
c027b02d 125 @echo ' except those preserved by LMC_KEEP environment variable'
281c9dad 126 @echo ' localyesconfig - Update current config converting local mods to core'
c027b02d 127 @echo ' except those preserved by LMC_KEEP environment variable'
0748cb3e 128 @echo ' defconfig - New config with default from ARCH supplied defconfig'
7cf3d73b 129 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
e11f0496 130 @echo ' allnoconfig - New config where all options are answered with no'
0748cb3e
SR
131 @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'
89b90609
TH
135 @echo ' yes2modconfig - Change answers from yes to mod if possible'
136 @echo ' mod2yesconfig - Change answers from mod to yes if possible'
c39afe62 137 @echo ' mod2noconfig - Change answers from mod to no if possible'
861b4ea4 138 @echo ' listnewconfig - List new options'
5d8b42aa 139 @echo ' helpnewconfig - List new options and help text'
cedd55d4
MH
140 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
141 @echo ' default value without prompting'
0da1d4a0 142 @echo ' tinyconfig - Configure the tiniest possible kernel'
d6a0c8a1 143 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
1da177e4
LT
144
145# ===========================================================================
1da177e4 146# object files used by all kconfig flavours
a77a05dc
MY
147common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
148 preprocess.o symbol.o util.o
1da177e4 149
769a1c02 150$(obj)/lexer.lex.o: $(obj)/parser.tab.h
9cc342f6
MY
151HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
152HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
1da177e4 153
558e78e3 154# conf: Used for defconfig, oldconfig and related targets
5f2fb52f 155hostprogs += conf
558e78e3
MY
156conf-objs := conf.o $(common-objs)
157
1c5af5cf 158# nconf: Used for the nconfig target based on ncurses
5f2fb52f 159hostprogs += nconf
558e78e3 160nconf-objs := nconf.o nconf.gui.o $(common-objs)
1c5af5cf 161
d86271af
MY
162HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs)
163HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
164HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
1c5af5cf 165
d86271af 166$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
1c5af5cf
MY
167
168# mconf: Used for the menuconfig target based on lxdialog
5f2fb52f 169hostprogs += mconf
54b8ae66
MY
170lxdialog := $(addprefix lxdialog/, \
171 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
172mconf-objs := mconf.o $(lxdialog) $(common-objs)
1c5af5cf 173
d86271af 174HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
1c5af5cf 175$(foreach f, mconf.o $(lxdialog), \
d86271af 176 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
7080e47b 177
54b8ae66 178$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
0b669a50
MY
179
180# qconf: Used for the xconfig target based on Qt
5f2fb52f 181hostprogs += qconf
0e912c03 182qconf-cxxobjs := qconf.o qconf-moc.o
3b541978 183qconf-objs := images.o $(common-objs)
0b669a50 184
d86271af
MY
185HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs)
186HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
0e912c03 187HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
0b669a50 188
0e912c03 189$(obj)/qconf.o: $(obj)/qconf-cfg
0b669a50
MY
190
191quiet_cmd_moc = MOC $@
0e912c03 192 cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
0b669a50 193
0e912c03 194$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
c3cd7cfa
MY
195 $(call if_changed,moc)
196
0e912c03 197targets += qconf-moc.cc
1da177e4 198
b464ef58 199# gconf: Used for the gconfig target based on GTK+
5f2fb52f 200hostprogs += gconf
3b541978 201gconf-objs := gconf.o images.o $(common-objs)
b464ef58 202
d86271af
MY
203HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs)
204HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags)
b464ef58 205
d86271af 206$(obj)/gconf.o: $(obj)/gconf-cfg
1da177e4 207
0b669a50 208# check if necessary packages are available, and configure build flags
ba97df45 209filechk_conf_cfg = $(CONFIG_SHELL) $<
0b669a50 210
d86271af 211$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
0b669a50
MY
212 $(call filechk,conf_cfg)
213
2648ca18 214clean-files += *conf-cfg