]> git.ipfire.org Git - thirdparty/u-boot.git/blame - scripts/kconfig/Makefile
Makefile: Run defconfig files through the C preprocessor
[thirdparty/u-boot.git] / scripts / kconfig / Makefile
CommitLineData
83d290c5 1# SPDX-License-Identifier: GPL-2.0
0a9064fb
MY
2# ===========================================================================
3# Kernel configuration targets
4# These targets are used from top-level makefile
5
587e4a42
TR
6PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \
7 build_menuconfig build_nconfig build_gconfig build_xconfig
0a9064fb 8
5f9eb220
MY
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
0a9064fb
MY
15ifdef KBUILD_KCONFIG
16Kconfig := $(KBUILD_KCONFIG)
17else
18Kconfig := Kconfig
19endif
20
9b5f0b1d
MY
21ifeq ($(quiet),silent_)
22silent := -s
23endif
24
0a9064fb
MY
25# We need this, in case the user has it in its environment
26unexport CONFIG_
27
28xconfig: $(obj)/qconf
9b5f0b1d 29 $< $(silent) $(Kconfig)
0a9064fb
MY
30
31gconfig: $(obj)/gconf
9b5f0b1d 32 $< $(silent) $(Kconfig)
0a9064fb
MY
33
34menuconfig: $(obj)/mconf
9b5f0b1d 35 $< $(silent) $(Kconfig)
0a9064fb
MY
36
37config: $(obj)/conf
9b5f0b1d 38 $< $(silent) --oldaskconfig $(Kconfig)
0a9064fb
MY
39
40nconfig: $(obj)/nconf
9b5f0b1d 41 $< $(silent) $(Kconfig)
0a9064fb 42
587e4a42
TR
43build_menuconfig: $(obj)/mconf
44
45build_nconfig: $(obj)/nconf
46
47build_gconfig: $(obj)/gconf
48
49build_xconfig: $(obj)/qconf
0a9064fb 50
e91610da 51localyesconfig localmodconfig: $(obj)/conf
e91610da 52 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
0cf207ec 53 $(Q)if [ -f .config ]; then \
0a9064fb
MY
54 cmp -s .tmp.config .config || \
55 (mv -f .config .config.old.1; \
56 mv -f .tmp.config .config; \
e91610da 57 $< $(silent) --oldconfig $(Kconfig); \
0a9064fb
MY
58 mv -f .config.old.1 .config.old) \
59 else \
60 mv -f .tmp.config .config; \
e91610da 61 $< $(silent) --oldconfig $(Kconfig); \
0a9064fb
MY
62 fi
63 $(Q)rm -f .tmp.config
64
9b5f0b1d 65# These targets map 1:1 to the commandline options of 'conf'
587e4a42
TR
66#
67# Note:
68# syncconfig has become an internal implementation detail and is now
69# deprecated for external use
9b5f0b1d 70simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
587e4a42 71 alldefconfig randconfig listnewconfig olddefconfig syncconfig
9b5f0b1d 72PHONY += $(simple-targets)
0a9064fb 73
9b5f0b1d
MY
74$(simple-targets): $(obj)/conf
75 $< $(silent) --$@ $(Kconfig)
0a9064fb 76
473fc279 77PHONY += savedefconfig defconfig
0a9064fb
MY
78
79savedefconfig: $(obj)/conf
9b5f0b1d 80 $< $(silent) --$@=defconfig $(Kconfig)
0a9064fb
MY
81
82defconfig: $(obj)/conf
83ifeq ($(KBUILD_DEFCONFIG),)
9b5f0b1d 84 $< $(silent) --defconfig $(Kconfig)
0a9064fb 85else
bf7ab1e7 86ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
9b5f0b1d
MY
87 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
88 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
bf7ab1e7
MY
89else
90 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
91 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
92endif
0a9064fb
MY
93endif
94
95%_defconfig: $(obj)/conf
2027e99e
AD
96 $(Q)$(CPP) -nostdinc -I $(srctree) -undef -x assembler-with-cpp $(srctree)/arch/$(SRCARCH)/configs/$@ -o generated_defconfig
97 $(Q)$< $(silent) --defconfig=generated_defconfig $(Kconfig)
0a9064fb 98
5f9eb220
MY
99# Added for U-Boot (backward compatibility)
100%_config: %_defconfig
101 @:
102
06b51f77
JK
103configfiles=$(wildcard $(srctree)/kernel/configs/$@ \
104 $(srctree)/arch/$(SRCARCH)/configs/$@ \
105 $(shell find $(srctree)/board -name "$@"))
ad618992 106
9b5f0b1d
MY
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
ad618992
MY
111
112PHONY += kvmconfig
9b5f0b1d
MY
113kvmconfig: kvm_guest.config
114 @:
ad618992 115
bf7ab1e7
MY
116PHONY += xenconfig
117xenconfig: xen.config
118 @:
119
ad618992 120PHONY += tinyconfig
9b5f0b1d
MY
121tinyconfig:
122 $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
ad618992 123
e91610da
ER
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
0a9064fb
MY
132# Help text used by make help
133help:
134 @echo ' config - Update current config utilising a line-oriented program'
5972ff07 135 @echo ' nconfig - Update current config utilising a ncurses menu based program'
0a9064fb 136 @echo ' menuconfig - Update current config utilising a menu based program'
bf7ab1e7
MY
137 @echo ' xconfig - Update current config utilising a Qt based front-end'
138 @echo ' gconfig - Update current config utilising a GTK+ based front-end'
0a9064fb
MY
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'
0a9064fb
MY
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'
e91610da
ER
150 @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
151 @echo ' default value without prompting'
bf7ab1e7
MY
152# @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
153# @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
ad618992 154# @echo ' tinyconfig - Configure the tiniest possible kernel'
5972ff07 155 @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
0a9064fb
MY
156
157# ===========================================================================
158# Shared Makefile for the various kconfig executables:
159# conf: Used for defconfig, oldconfig and related targets
0a9064fb
MY
160# object files used by all kconfig flavours
161
0a9064fb 162conf-objs := conf.o zconf.tab.o
0a9064fb 163
5972ff07 164hostprogs-y := conf
0a9064fb 165
e91610da 166targets += zconf.lex.c
0a9064fb
MY
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
5972ff07
TR
172# nconf: Used for the nconfig target based on ncurses
173hostprogs-y += nconf
174nconf-objs := nconf.o zconf.tab.o nconf.gui.o
0a9064fb 175
587e4a42 176HOSTLDLIBS_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
5972ff07
TR
177HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
178HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
0a9064fb 179
587e4a42 180$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/.nconf-cfg
5972ff07
TR
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))
0a9064fb 186
587e4a42 187HOSTLDLIBS_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
5972ff07
TR
188$(foreach f, mconf.o $(lxdialog), \
189 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/.mconf-cfg && echo $$$$cflags)))
190
587e4a42
TR
191$(obj)/mconf.o: $(obj)/.mconf-cfg
192$(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/.mconf-cfg
5972ff07
TR
193
194# qconf: Used for the xconfig target based on Qt
195hostprogs-y += qconf
196qconf-cxxobjs := qconf.o
197qconf-objs := zconf.tab.o
198
587e4a42 199HOSTLDLIBS_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs)
5972ff07
TR
200HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags)
201
202$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
0a9064fb
MY
203
204quiet_cmd_moc = MOC $@
5972ff07 205 cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@
0a9064fb 206
5972ff07 207$(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
0a9064fb
MY
208 $(call cmd,moc)
209
5972ff07
TR
210# gconf: Used for the gconfig target based on GTK+
211hostprogs-y += gconf
212gconf-objs := gconf.o zconf.tab.o
213
587e4a42 214HOSTLDLIBS_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
5972ff07
TR
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