1 # ===========================================================================
2 # Kernel configuration targets
3 # These targets are used from top-level makefile
5 # SRCDIR is kconfig source dir, allows for out-of-tree builds
6 # if building in tree, SRCDIR==build dir
7 SRCDIR := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
9 PHONY += xconfig gconfig menuconfig config silentoldconfig \
10 localmodconfig localyesconfig clean
13 Kconfig := $(KBUILD_KCONFIG)
18 ifeq ($(quiet),silent_)
22 # We need this, in case the user has it in its environment
25 # Unset some environment variables set in the project environment
30 # Workaround for a bug on Windows if the mingw32 host compilers
31 # are installed in addition to the MSYS ones. The kconfig tools
32 # need to be compiled using the MSYS compiler.
34 # See https://github.com/espressif/esp-idf/issues/1296
36 ifeq ("$(MSYSTEM)", "MINGW32")
46 default: mconf-idf conf-idf
49 $< $(silent) $(Kconfig)
52 $< $(silent) $(Kconfig)
55 $< $(silent) $(Kconfig)
58 $< $(silent) --oldaskconfig $(Kconfig)
61 $< $(silent) $(Kconfig)
63 silentoldconfig: conf-idf
64 mkdir -p include/config include/generated
65 $< $(silent) --$@ $(Kconfig)
67 localyesconfig localmodconfig: streamline_config.pl conf-idf
68 mkdir -p include/config include/generated
69 perl $< --$@ . $(Kconfig) > .tmp.config
70 if [ -f .config ]; then \
71 cmp -s .tmp.config .config || \
72 (mv -f .config .config.old.1; \
73 mv -f .tmp.config .config; \
74 conf-idf $(silent) --silentoldconfig $(Kconfig); \
75 mv -f .config.old.1 .config.old) \
77 mv -f .tmp.config .config; \
78 conf-idf $(silent) --silentoldconfig $(Kconfig); \
83 # These targets map 1:1 to the commandline options of 'conf-idf'
84 simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
85 alldefconfig randconfig listnewconfig olddefconfig
86 PHONY += $(simple-targets)
88 $(simple-targets): conf-idf
89 $< $(silent) --$@ $(Kconfig)
91 PHONY += oldnoconfig savedefconfig defconfig
93 # oldnoconfig is an alias of olddefconfig, because people already are dependent
94 # on its behavior (sets new symbols to their default value but not 'n') with the
95 # counter-intuitive name.
96 oldnoconfig: olddefconfig
98 savedefconfig: conf-idf
99 $< $(silent) --$@=defconfig $(Kconfig)
102 ifeq ($(KBUILD_DEFCONFIG),)
103 $< $(silent) --defconfig $(Kconfig)
105 ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
106 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
107 $< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
109 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
110 $(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
114 %_defconfig: conf-idf
115 $< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
117 configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
120 $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
121 $(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
122 +yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
125 kvmconfig: kvm_guest.config
129 xenconfig: xen.config
134 $(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
136 # Help text used by make help
138 @echo ' config - Update current config utilising a line-oriented program'
139 @echo ' nconfig - Update current config utilising a ncurses menu based'
141 @echo ' menuconfig - Update current config utilising a menu based program'
142 @echo ' xconfig - Update current config utilising a Qt based front-end'
143 @echo ' gconfig - Update current config utilising a GTK+ based front-end'
144 @echo ' oldconfig - Update current config utilising a provided .config as base'
145 @echo ' localmodconfig - Update current config disabling modules not loaded'
146 @echo ' localyesconfig - Update current config converting local mods to core'
147 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
148 @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'
156 @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their'
157 @echo ' default value'
158 @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
159 @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
160 @echo ' tinyconfig - Configure the tiniest possible kernel'
163 check-lxdialog := $(SRCDIR)/lxdialog/check-lxdialog.sh
165 # Use recursively expanded variables so we do not call gcc unless
166 # we really need to do so. (Do not call gcc as part of make mrproper)
167 CFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
171 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
173 lxdialog/%.o: $(SRCDIR)/lxdialog/%.c
174 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
177 $(CC) -I $(SRCDIR) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
179 # ===========================================================================
180 # Shared Makefile for the various kconfig executables:
181 # conf-idf: Used for defconfig, oldconfig and related targets
182 # nconf: Used for the nconfig target.
184 # mconf-idf: Used for the menuconfig target
185 # Utilizes the lxdialog package
186 # qconf: Used for the xconfig target
187 # Based on Qt which needs to be installed to compile it
188 # gconf: Used for the gconfig target
189 # Based on GTK+ which needs to be installed to compile it
190 # object files used by all kconfig flavours
192 lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
193 lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
195 conf-objs := conf.o zconf.tab.o
196 mconf-objs := mconf.o zconf.tab.o $(lxdialog)
197 nconf-objs := nconf.o zconf.tab.o nconf.gui.o
198 kxgettext-objs := kxgettext.o zconf.tab.o
199 qconf-cxxobjs := qconf.o
200 qconf-objs := zconf.tab.o
201 gconf-objs := gconf.o zconf.tab.o
203 hostprogs-y := conf-idf nconf mconf-idf kxgettext qconf gconf
205 all-objs := $(conf-objs) $(mconf-objs) $(lxdialog)
206 all-deps := $(all-objs:.o=.d)
208 clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
209 clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
210 clean-files += $(all-objs) $(all-deps) conf-idf mconf-idf conf mconf
211 # (note: cleans both mconf & conf (old names) and conf-idf & mconf-idf (new names))
213 # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
214 PHONY += dochecklxdialog
215 $(addprefix ,$(lxdialog)): dochecklxdialog
216 dochecklxdialog: lxdialog
217 $(CONFIG_SHELL) $(check-lxdialog) -check $(CC) $(CFLAGS) $(LOADLIBES_mconf)
222 always := dochecklxdialog
224 # Add environment specific flags
225 EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(CC) $(CFLAGS))
227 # generated files seem to need this to find local include files
228 CFLAGS_zconf.lex.o := -I$(src)
229 CFLAGS_zconf.tab.o := -I$(src)
231 LEX_PREFIX_zconf := zconf
232 YACC_PREFIX_zconf := zconf
234 LOADLIBES_qconf = $(KC_QT_LIBS)
235 CXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
237 LOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
238 CFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
239 -Wno-missing-prototypes
241 LOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(CC))
243 LOADLIBES_conf = $(LOADLIBES_mconf)
245 LOADLIBES_nconf = $(shell \
246 pkg-config --libs menuw panelw ncursesw 2>/dev/null \
247 || pkg-config --libs menu panel ncurses 2>/dev/null \
248 || echo "-lmenu -lpanel -lncurses" )
250 ifeq ("$(OS)","Windows_NT")
251 # Windows toolchains don't seem to count libintl
252 # as a system library
253 LOADLIBES_mconf += -lintl
254 LOADLIBES_nconf += -lintl
257 qconf.o: .tmp_qtcheck
259 ifeq ($(MAKECMDGOALS),xconfig)
260 .tmp_qtcheck: $(src)/Makefile
261 -include .tmp_qtcheck
263 # Qt needs some extra effort...
265 @set -e; $(kecho) " CHECK qt"; \
266 if pkg-config --exists Qt5Core; then \
267 cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
268 libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \
269 moc=`pkg-config --variable=host_bins Qt5Core`/moc; \
270 elif pkg-config --exists QtCore; then \
271 cflags=`pkg-config --cflags QtCore QtGui`; \
272 libs=`pkg-config --libs QtCore QtGui`; \
273 moc=`pkg-config --variable=moc_location QtCore`; \
276 echo >&2 "* Could not find Qt via pkg-config."; \
277 echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
281 echo "KC_QT_CFLAGS=$$cflags" > $@; \
282 echo "KC_QT_LIBS=$$libs" >> $@; \
283 echo "KC_QT_MOC=$$moc" >> $@
286 gconf.o: .tmp_gtkcheck
288 ifeq ($(MAKECMDGOALS),gconfig)
289 -include .tmp_gtkcheck
291 # GTK+ needs some extra effort, too...
293 @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
294 if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
298 echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
304 echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \
305 echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \
306 echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
312 zconf.tab.o: zconf.lex.c zconf.hash.c
316 quiet_cmd_moc = MOC $@
317 cmd_moc = $(KC_QT_MOC) -i $< -o $@
319 %.moc: $(src)/%.h .tmp_qtcheck
322 # Extract gconf menu items for i18n support
323 gconf.glade.h: gconf.glade
324 intltool-extract --type=gettext/glade --srcdir=$(srctree) \
328 mconf-idf: lxdialog $(mconf-objs)
329 $(CC) -o $@ $(mconf-objs) $(LOADLIBES_mconf)
331 conf-idf: $(conf-objs)
332 $(CC) -o $@ $(conf-objs) $(LOADLIBES_conf)
334 zconf.tab.c: zconf.lex.c
336 zconf.lex.c: $(SRCDIR)/zconf.l
337 flex -L -P zconf -o zconf.lex.c $<
339 zconf.hash.c: $(SRCDIR)/zconf.gperf
340 # strip CRs on Windows systems where gperf will otherwise barf on them
341 sed -E "s/\\x0D$$//" $< | gperf -t --output-file zconf.hash.c -a -C -E -g -k '1,3,$$' -p -t
343 zconf.tab.c: $(SRCDIR)/zconf.y
344 bison -t -l -p zconf -o zconf.tab.c $<