blob: 46ddf2d6bd37bc2dbbe9a08be8d8222af468d1d0 [file] [log] [blame]
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +09001# ===========================================================================
2# Kernel configuration targets
3# These targets are used from top-level makefile
4
Masahiro Yamada331cec32015-07-05 01:56:54 +09005PHONY += xconfig gconfig menuconfig config silentoldconfig update-po-config \
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +09006 localmodconfig localyesconfig
7
Masahiro Yamada87192a12015-03-13 18:08:55 +09008# Added for U-Boot
9# Linux has defconfig files in arch/$(SRCARCH)/configs/,
10# on the other hand, U-Boot does in configs/.
11# Set SRCARCH to .. fake this Makefile.
12SRCARCH := ..
13
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090014ifdef KBUILD_KCONFIG
15Kconfig := $(KBUILD_KCONFIG)
16else
17Kconfig := Kconfig
18endif
19
Masahiro Yamada331cec32015-07-05 01:56:54 +090020ifeq ($(quiet),silent_)
21silent := -s
22endif
23
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090024# We need this, in case the user has it in its environment
25unexport CONFIG_
26
27xconfig: $(obj)/qconf
Masahiro Yamada331cec32015-07-05 01:56:54 +090028 $< $(silent) $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090029
30gconfig: $(obj)/gconf
Masahiro Yamada331cec32015-07-05 01:56:54 +090031 $< $(silent) $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090032
33menuconfig: $(obj)/mconf
Masahiro Yamada331cec32015-07-05 01:56:54 +090034 $< $(silent) $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090035
36config: $(obj)/conf
Masahiro Yamada331cec32015-07-05 01:56:54 +090037 $< $(silent) --oldaskconfig $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090038
39nconfig: $(obj)/nconf
Masahiro Yamada331cec32015-07-05 01:56:54 +090040 $< $(silent) $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090041
42silentoldconfig: $(obj)/conf
43 $(Q)mkdir -p include/config include/generated
Masahiro Yamada331cec32015-07-05 01:56:54 +090044 $< $(silent) --$@ $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090045
46localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
47 $(Q)mkdir -p include/config include/generated
48 $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
49 $(Q)if [ -f .config ]; then \
50 cmp -s .tmp.config .config || \
51 (mv -f .config .config.old.1; \
52 mv -f .tmp.config .config; \
Masahiro Yamada331cec32015-07-05 01:56:54 +090053 $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090054 mv -f .config.old.1 .config.old) \
55 else \
56 mv -f .tmp.config .config; \
Masahiro Yamada331cec32015-07-05 01:56:54 +090057 $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090058 fi
59 $(Q)rm -f .tmp.config
60
61# Create new linux.pot file
62# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
63update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
Masahiro Yamada331cec32015-07-05 01:56:54 +090064 $(Q)$(kecho) " GEN config.pot"
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090065 $(Q)xgettext --default-domain=linux \
66 --add-comments --keyword=_ --keyword=N_ \
67 --from-code=UTF-8 \
68 --files-from=$(srctree)/scripts/kconfig/POTFILES.in \
69 --directory=$(srctree) --directory=$(objtree) \
70 --output $(obj)/config.pot
71 $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
72 $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
73 $(srctree)/arch/*/um/Kconfig`; \
74 do \
Masahiro Yamada331cec32015-07-05 01:56:54 +090075 $(kecho) " GEN $$i"; \
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090076 $(obj)/kxgettext $$i \
77 >> $(obj)/config.pot; \
78 done )
Masahiro Yamada331cec32015-07-05 01:56:54 +090079 $(Q)$(kecho) " GEN linux.pot"
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090080 $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
81 --output $(obj)/linux.pot
82 $(Q)rm -f $(obj)/config.pot
83
Masahiro Yamada331cec32015-07-05 01:56:54 +090084# These targets map 1:1 to the commandline options of 'conf'
85simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
86 alldefconfig randconfig listnewconfig olddefconfig
87PHONY += $(simple-targets)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090088
Masahiro Yamada331cec32015-07-05 01:56:54 +090089$(simple-targets): $(obj)/conf
90 $< $(silent) --$@ $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090091
Masahiro Yamada331cec32015-07-05 01:56:54 +090092PHONY += oldnoconfig savedefconfig defconfig
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090093
94# oldnoconfig is an alias of olddefconfig, because people already are dependent
95# on its behavior(sets new symbols to their default value but not 'n') with the
96# counter-intuitive name.
Masahiro Yamada331cec32015-07-05 01:56:54 +090097oldnoconfig: olddefconfig
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +090098
99savedefconfig: $(obj)/conf
Masahiro Yamada331cec32015-07-05 01:56:54 +0900100 $< $(silent) --$@=defconfig $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900101
102defconfig: $(obj)/conf
103ifeq ($(KBUILD_DEFCONFIG),)
Masahiro Yamada331cec32015-07-05 01:56:54 +0900104 $< $(silent) --defconfig $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900105else
Masahiro Yamada331cec32015-07-05 01:56:54 +0900106 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
107 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900108endif
109
110%_defconfig: $(obj)/conf
Masahiro Yamada331cec32015-07-05 01:56:54 +0900111 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900112
Masahiro Yamada87192a12015-03-13 18:08:55 +0900113# Added for U-Boot (backward compatibility)
114%_config: %_defconfig
115 @:
116
Masahiro Yamada331cec32015-07-05 01:56:54 +0900117configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
Masahiro Yamadacfa337b2014-10-30 11:06:12 +0900118
Masahiro Yamada331cec32015-07-05 01:56:54 +0900119%.config: $(obj)/conf
120 $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
121 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
122 +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
Masahiro Yamadacfa337b2014-10-30 11:06:12 +0900123
124PHONY += kvmconfig
Masahiro Yamada331cec32015-07-05 01:56:54 +0900125kvmconfig: kvm_guest.config
126 @:
Masahiro Yamadacfa337b2014-10-30 11:06:12 +0900127
128PHONY += tinyconfig
Masahiro Yamada331cec32015-07-05 01:56:54 +0900129tinyconfig:
130 $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
Masahiro Yamadacfa337b2014-10-30 11:06:12 +0900131
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900132# 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 ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
143 @echo ' defconfig - New config with default from ARCH supplied defconfig'
144 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
145 @echo ' allnoconfig - New config where all options are answered with no'
146 @echo ' allyesconfig - New config where all options are accepted with yes'
147 @echo ' allmodconfig - New config selecting modules when possible'
148 @echo ' alldefconfig - New config with all symbols set to default'
149 @echo ' randconfig - New config with random answer to all options'
150 @echo ' listnewconfig - List new options'
151 @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
Masahiro Yamadacfa337b2014-10-30 11:06:12 +0900152# @echo ' kvmconfig - Enable additional options for guest kernel support'
153# @echo ' tinyconfig - Configure the tiniest possible kernel'
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900154
155# lxdialog stuff
156check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
157
158# Use recursively expanded variables so we do not call gcc unless
159# we really need to do so. (Do not call gcc as part of make mrproper)
160HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
161 -DLOCALE
162
163# ===========================================================================
164# Shared Makefile for the various kconfig executables:
165# conf: Used for defconfig, oldconfig and related targets
166# nconf: Used for the nconfig target.
167# Utilizes ncurses
168# mconf: Used for the menuconfig target
169# Utilizes the lxdialog package
170# qconf: Used for the xconfig target
171# Based on QT which needs to be installed to compile it
172# gconf: Used for the gconfig target
173# Based on GTK which needs to be installed to compile it
174# object files used by all kconfig flavours
175
176lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
177lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
178
179conf-objs := conf.o zconf.tab.o
180mconf-objs := mconf.o zconf.tab.o $(lxdialog)
181nconf-objs := nconf.o zconf.tab.o nconf.gui.o
182kxgettext-objs := kxgettext.o zconf.tab.o
183qconf-cxxobjs := qconf.o
184qconf-objs := zconf.tab.o
185gconf-objs := gconf.o zconf.tab.o
186
Masahiro Yamada8c4532f2014-10-30 11:06:10 +0900187hostprogs-y := conf nconf mconf kxgettext qconf gconf
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900188
189clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
190clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900191clean-files += config.pot linux.pot
192
193# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
194PHONY += $(obj)/dochecklxdialog
195$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
196$(obj)/dochecklxdialog:
197 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
198
199always := dochecklxdialog
200
201# Add environment specific flags
202HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
203
204# generated files seem to need this to find local include files
205HOSTCFLAGS_zconf.lex.o := -I$(src)
206HOSTCFLAGS_zconf.tab.o := -I$(src)
207
208LEX_PREFIX_zconf := zconf
209YACC_PREFIX_zconf := zconf
210
211HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
212HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
213
214HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
215HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
216 -Wno-missing-prototypes
217
218HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
219
220HOSTLOADLIBES_nconf = $(shell \
Masahiro Yamadacfa337b2014-10-30 11:06:12 +0900221 pkg-config --libs menuw panelw ncursesw 2>/dev/null \
222 || pkg-config --libs menu panel ncurses 2>/dev/null \
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900223 || echo "-lmenu -lpanel -lncurses" )
224$(obj)/qconf.o: $(obj)/.tmp_qtcheck
225
Masahiro Yamada8c4532f2014-10-30 11:06:10 +0900226ifeq ($(MAKECMDGOALS),xconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900227$(obj)/.tmp_qtcheck: $(src)/Makefile
228-include $(obj)/.tmp_qtcheck
229
230# QT needs some extra effort...
231$(obj)/.tmp_qtcheck:
Masahiro Yamada331cec32015-07-05 01:56:54 +0900232 @set -e; $(kecho) " CHECK qt"; dir=""; pkg=""; \
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900233 if ! pkg-config --exists QtCore 2> /dev/null; then \
234 echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \
235 pkg-config --exists qt 2> /dev/null && pkg=qt; \
236 pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
237 if [ -n "$$pkg" ]; then \
238 cflags="\$$(shell pkg-config $$pkg --cflags)"; \
239 libs="\$$(shell pkg-config $$pkg --libs)"; \
240 moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
241 dir="$$(pkg-config $$pkg --variable=prefix)"; \
242 else \
243 for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
244 if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
245 done; \
246 if [ -z "$$dir" ]; then \
247 echo >&2 "*"; \
248 echo >&2 "* Unable to find any QT installation. Please make sure that"; \
249 echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \
250 echo >&2 "* either qmake can be found or install pkg-config or set"; \
251 echo >&2 "* the QTDIR environment variable to the correct location."; \
252 echo >&2 "*"; \
253 false; \
254 fi; \
255 libpath=$$dir/lib; lib=qt; osdir=""; \
256 $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
257 osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
258 test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
259 test -f $$libpath/libqt-mt.so && lib=qt-mt; \
260 cflags="-I$$dir/include"; \
261 libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
262 moc="$$dir/bin/moc"; \
263 fi; \
264 if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
265 echo "*"; \
266 echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
267 echo "*"; \
268 moc="/usr/bin/moc"; \
269 fi; \
270 else \
271 cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
272 libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
273 moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \
274 [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \
275 fi; \
276 echo "KC_QT_CFLAGS=$$cflags" > $@; \
277 echo "KC_QT_LIBS=$$libs" >> $@; \
278 echo "KC_QT_MOC=$$moc" >> $@
279endif
280
281$(obj)/gconf.o: $(obj)/.tmp_gtkcheck
282
Masahiro Yamada8c4532f2014-10-30 11:06:10 +0900283ifeq ($(MAKECMDGOALS),gconfig)
Masahiro Yamadaed16f5a2014-07-30 14:08:13 +0900284-include $(obj)/.tmp_gtkcheck
285
286# GTK needs some extra effort, too...
287$(obj)/.tmp_gtkcheck:
288 @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
289 if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
290 touch $@; \
291 else \
292 echo >&2 "*"; \
293 echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
294 echo >&2 "*"; \
295 false; \
296 fi \
297 else \
298 echo >&2 "*"; \
299 echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \
300 echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \
301 echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
302 echo >&2 "*"; \
303 false; \
304 fi
305endif
306
307$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
308
309$(obj)/qconf.o: $(obj)/qconf.moc
310
311quiet_cmd_moc = MOC $@
312 cmd_moc = $(KC_QT_MOC) -i $< -o $@
313
314$(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
315 $(call cmd,moc)
316
317# Extract gconf menu items for I18N support
318$(obj)/gconf.glade.h: $(obj)/gconf.glade
319 $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
320 $(obj)/gconf.glade