]> granicus.if.org Git - esp-idf/blob - tools/kconfig/Makefile
Merge branch 'bugfix/use_component_srcs' into 'master'
[esp-idf] / tools / kconfig / Makefile
1 # ===========================================================================
2 # Kernel configuration targets
3 # These targets are used from top-level makefile
4
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))))
8
9 PHONY += xconfig gconfig menuconfig config silentoldconfig \
10         localmodconfig localyesconfig clean
11
12 ifdef KBUILD_KCONFIG
13 Kconfig := $(KBUILD_KCONFIG)
14 else
15 Kconfig := Kconfig
16 endif
17
18 ifeq ($(quiet),silent_)
19 silent := -s
20 endif
21
22 # We need this, in case the user has it in its environment
23 unexport CONFIG_
24
25 # Unset some environment variables set in the project environment
26 CFLAGS :=
27 CPPFLAGS :=
28 LDFLAGS :=
29
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.
33 #
34 # See https://github.com/espressif/esp-idf/issues/1296
35 ifdef MSYSTEM
36 ifeq ("$(MSYSTEM)", "MINGW32")
37 ifeq ("$(CC)", "cc")
38 CC := /usr/bin/gcc
39 endif
40 ifeq ("$(LD)", "ld")
41 LD := /usr/bin/ld
42 endif
43 endif # MING32
44 endif # MSYSTEM
45
46 default: mconf-idf conf-idf
47
48 xconfig: qconf
49         $< $(silent) $(Kconfig)
50
51 gconfig: gconf
52         $< $(silent) $(Kconfig)
53
54 menuconfig: mconf-idf
55         $< $(silent) $(Kconfig)
56
57 config: conf-idf
58         $< $(silent) --oldaskconfig $(Kconfig)
59
60 nconfig: nconf
61         $< $(silent) $(Kconfig)
62
63 silentoldconfig: conf-idf
64         mkdir -p include/config include/generated
65         $< $(silent) --$@ $(Kconfig)
66
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)               \
76         else                                                            \
77                         mv -f .tmp.config .config;                      \
78                         conf-idf $(silent) --silentoldconfig $(Kconfig); \
79         fi
80         rm -f .tmp.config
81
82
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)
87
88 $(simple-targets): conf-idf
89         $< $(silent) --$@ $(Kconfig)
90
91 PHONY += oldnoconfig savedefconfig defconfig
92
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
97
98 savedefconfig: conf-idf
99         $< $(silent) --$@=defconfig $(Kconfig)
100
101 defconfig: conf-idf
102 ifeq ($(KBUILD_DEFCONFIG),)
103         $< $(silent) --defconfig $(Kconfig)
104 else
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)
108 else
109         @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
110         $(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
111 endif
112 endif
113
114 %_defconfig: conf-idf
115         $< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
116
117 configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
118
119 %.config: conf-idf
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
123
124 PHONY += kvmconfig
125 kvmconfig: kvm_guest.config
126         @:
127
128 PHONY += xenconfig
129 xenconfig: xen.config
130         @:
131
132 PHONY += tinyconfig
133 tinyconfig:
134         $(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
135
136 # Help text used by make help
137 help:
138         @echo  '  config          - Update current config utilising a line-oriented program'
139         @echo  '  nconfig         - Update current config utilising a ncurses menu based'
140         @echo  '                    program'
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'
161
162 # lxdialog stuff
163 check-lxdialog  := $(SRCDIR)/lxdialog/check-lxdialog.sh
164
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) \
168                     -DLOCALE -MMD
169
170 %.o: $(SRCDIR)/%.c
171         $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
172
173 lxdialog/%.o: $(SRCDIR)/lxdialog/%.c
174         $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
175
176 %.o: %.c
177         $(CC) -I $(SRCDIR) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
178
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.
183 #         Utilizes ncurses
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
191
192 lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
193 lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
194
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
202
203 hostprogs-y := conf-idf nconf mconf-idf kxgettext qconf gconf
204
205 all-objs := $(conf-objs) $(mconf-objs) $(lxdialog)
206 all-deps := $(all-objs:.o=.d)
207
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))
212
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)
218
219 lxdialog:
220         mkdir -p lxdialog
221
222 always := dochecklxdialog
223
224 # Add environment specific flags
225 EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(CC) $(CFLAGS))
226
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)
230
231 LEX_PREFIX_zconf        := zconf
232 YACC_PREFIX_zconf       := zconf
233
234 LOADLIBES_qconf = $(KC_QT_LIBS)
235 CXXFLAGS_qconf.o        = $(KC_QT_CFLAGS)
236
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
240
241 LOADLIBES_mconf   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(CC))
242
243 LOADLIBES_conf = $(LOADLIBES_mconf)
244
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"  )
249
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
255 endif
256
257 qconf.o: .tmp_qtcheck
258
259 ifeq ($(MAKECMDGOALS),xconfig)
260 .tmp_qtcheck: $(src)/Makefile
261 -include .tmp_qtcheck
262
263 # Qt needs some extra effort...
264 .tmp_qtcheck:
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`; \
274         else \
275             echo >&2 "*"; \
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"; \
278             echo >&2 "*"; \
279             exit 1; \
280         fi; \
281         echo "KC_QT_CFLAGS=$$cflags" > $@; \
282         echo "KC_QT_LIBS=$$libs" >> $@; \
283         echo "KC_QT_MOC=$$moc" >> $@
284 endif
285
286 gconf.o: .tmp_gtkcheck
287
288 ifeq ($(MAKECMDGOALS),gconfig)
289 -include .tmp_gtkcheck
290
291 # GTK+ needs some extra effort, too...
292 .tmp_gtkcheck:
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                  \
295                         touch $@;                                                               \
296                 else                                                                    \
297                         echo >&2 "*";                                                   \
298                         echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
299                         echo >&2 "*";                                                   \
300                         false;                                                          \
301                 fi                                                                      \
302         else                                                                            \
303                 echo >&2 "*";                                                           \
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.";             \
307                 echo >&2 "*";                                                           \
308                 false;                                                                  \
309         fi
310 endif
311
312 zconf.tab.o: zconf.lex.c zconf.hash.c
313
314 qconf.o: qconf.moc
315
316 quiet_cmd_moc = MOC     $@
317       cmd_moc = $(KC_QT_MOC) -i $< -o $@
318
319 %.moc: $(src)/%.h .tmp_qtcheck
320         $(call cmd,moc)
321
322 # Extract gconf menu items for i18n support
323 gconf.glade.h: gconf.glade
324         intltool-extract --type=gettext/glade --srcdir=$(srctree) \
325         gconf.glade
326
327
328 mconf-idf: lxdialog $(mconf-objs)
329         $(CC) -o $@ $(mconf-objs) $(LOADLIBES_mconf)
330
331 conf-idf: $(conf-objs)
332         $(CC) -o $@ $(conf-objs) $(LOADLIBES_conf)
333
334 zconf.tab.c: zconf.lex.c
335
336 zconf.lex.c: $(SRCDIR)/zconf.l
337         flex -L -P zconf -o zconf.lex.c $<
338
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
342
343 zconf.tab.c: $(SRCDIR)/zconf.y
344         bison -t -l -p zconf -o zconf.tab.c $<
345
346 clean:
347         rm -f $(clean-files)
348
349 -include $(all-deps)
350