"Das U-Boot" Source Tree
1# SPDX-License-Identifier: GPL-2.0
2# ===========================================================================
3# Kernel configuration targets
4# These targets are used from top-level makefile
5
6PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \
7 build_menuconfig build_nconfig build_gconfig build_xconfig
8
9# 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
15ifdef KBUILD_KCONFIG
16Kconfig := $(KBUILD_KCONFIG)
17else
18Kconfig := Kconfig
19endif
20
21ifeq ($(quiet),silent_)
22silent := -s
23endif
24
25# We need this, in case the user has it in its environment
26unexport CONFIG_
27
28xconfig: $(obj)/qconf
29 $< $(silent) $(Kconfig)
30
31gconfig: $(obj)/gconf
32 $< $(silent) $(Kconfig)
33
34menuconfig: $(obj)/mconf
35 $< $(silent) $(Kconfig)
36
37config: $(obj)/conf
38 $< $(silent) --oldaskconfig $(Kconfig)
39
40nconfig: $(obj)/nconf
41 $< $(silent) $(Kconfig)
42
43build_menuconfig: $(obj)/mconf
44
45build_nconfig: $(obj)/nconf
46
47build_gconfig: $(obj)/gconf
48
49build_xconfig: $(obj)/qconf
50
51localyesconfig localmodconfig: $(obj)/conf
52 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
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); \
62 fi
63 $(Q)rm -f .tmp.config
64
65# These targets map 1:1 to the commandline options of 'conf'
66#
67# Note:
68# syncconfig has become an internal implementation detail and is now
69# deprecated for external use
70simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
71 alldefconfig randconfig listnewconfig olddefconfig syncconfig
72PHONY += $(simple-targets)
73
74$(simple-targets): $(obj)/conf
75 $< $(silent) --$@ $(Kconfig)
76
77PHONY += savedefconfig defconfig
78
79savedefconfig: $(obj)/conf
80 $< $(silent) --$@=defconfig $(Kconfig)
81
82defconfig: $(obj)/conf
83ifeq ($(KBUILD_DEFCONFIG),)
84 $< $(silent) --defconfig $(Kconfig)
85else
86ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
87 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
88 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
89else
90 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
91 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
92endif
93endif
94
95%_defconfig: $(obj)/conf
96 $(Q)$(CPP) -nostdinc -P -I $(srctree) -undef -x assembler-with-cpp $(srctree)/arch/$(SRCARCH)/configs/$@ -o generated_defconfig
97 $(Q)$< $(silent) --defconfig=generated_defconfig $(Kconfig)
98
99# Added for U-Boot (backward compatibility)
100%_config: %_defconfig
101 @:
102
103configfiles=$(wildcard $(srctree)/kernel/configs/$@ \
104 $(srctree)/arch/$(SRCARCH)/configs/$@ \
105 $(shell find $(srctree)/board -name "$@"))
106
107%.config: $(obj)/conf
108 $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
109 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
110 +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
111
112PHONY += kvmconfig
113kvmconfig: kvm_guest.config
114 @:
115
116PHONY += xenconfig
117xenconfig: xen.config
118 @:
119
120PHONY += tinyconfig
121tinyconfig:
122 $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
123
124# CHECK: -o cache_dir=<path> working?
125PHONY += testconfig
126testconfig: $(obj)/conf
127 $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
128 -o cache_dir=$(abspath $(obj)/tests/.cache) \
129 $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
130clean-dirs += tests/.cache
131
132# Help text used by make help
133help:
134 @echo ' config - Update current config utilising a line-oriented program'
135 @echo ' nconfig - Update current config utilising a ncurses menu based program'
136 @echo ' menuconfig - Update current config utilising a menu based program'
137 @echo ' xconfig - Update current config utilising a Qt based front-end'
138 @echo ' gconfig - Update current config utilising a GTK+ based front-end'
139 @echo ' oldconfig - Update current config utilising a provided .config as base'
140 @echo ' localmodconfig - Update current config disabling modules not loaded'
141 @echo ' localyesconfig - Update current config converting local mods to core'
142 @echo ' defconfig - New config with default from ARCH supplied defconfig'
143 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
144 @echo ' allnoconfig - New config where all options are answered with no'
145 @echo ' allyesconfig - New config where all options are accepted with yes'
146 @echo ' allmodconfig - New config selecting modules when possible'
147 @echo ' alldefconfig - New config with all symbols set to default'
148 @echo ' randconfig - New config with random answer to all options'
149 @echo ' listnewconfig - List new options'
150 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
151 @echo ' default value without prompting'
152# @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
153# @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
154# @echo ' tinyconfig - Configure the tiniest possible kernel'
155 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
156
157# ===========================================================================
158# Shared Makefile for the various kconfig executables:
159# conf: Used for defconfig, oldconfig and related targets
160# object files used by all kconfig flavours
161
162conf-objs := conf.o zconf.tab.o
163
164hostprogs-y := conf
165
166targets += zconf.lex.c
167
168# generated files seem to need this to find local include files
169HOSTCFLAGS_zconf.lex.o := -I$(src)
170HOSTCFLAGS_zconf.tab.o := -I$(src)
171
172# nconf: Used for the nconfig target based on ncurses
173hostprogs-y += nconf
174nconf-objs := nconf.o zconf.tab.o nconf.gui.o
175
176HOSTLDLIBS_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
177HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
178HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
179
180$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/.nconf-cfg
181
182# mconf: Used for the menuconfig target based on lxdialog
183hostprogs-y += mconf
184lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
185mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
186
187HOSTLDLIBS_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
188$(foreach f, mconf.o $(lxdialog), \
189 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
190
191$(obj)/mconf.o: $(obj)/.mconf-cfg
192$(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/.mconf-cfg
193
194# qconf: Used for the xconfig target based on Qt
195hostprogs-y += qconf
196qconf-cxxobjs := qconf.o
197qconf-objs := zconf.tab.o
198
199HOSTLDLIBS_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs)
200HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags)
201
202$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
203
204quiet_cmd_moc = MOC $@
205 cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@
206
207$(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
208 $(call cmd,moc)
209
210# gconf: Used for the gconfig target based on GTK+
211hostprogs-y += gconf
212gconf-objs := gconf.o zconf.tab.o
213
214HOSTLDLIBS_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
215HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags)
216
217$(obj)/gconf.o: $(obj)/.gconf-cfg
218
219$(obj)/zconf.tab.o: $(obj)/zconf.lex.c
220
221# check if necessary packages are available, and configure build flags
222define filechk_conf_cfg
223 $(CONFIG_SHELL) $<
224endef
225
226$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE
227 $(call filechk,conf_cfg)
228
229clean-files += .*conf-cfg