Skip to content

Commit 0b669a5

Browse files
committed
kconfig: refactor Qt package checks for building qconf
Currently, the necessary package checks for building qconf is surrounded by ifeq ($(MAKECMDGOALS),xconfig) ... endif. Then, Make will restart when .tmp_qtcheck is generated. To simplify the Makefile, move the scripting to a separate file, and use filechk. The shell script is executed everytime xconfig is run, but it is not a costly script. In the old code, 'pkg-config --exists' only checked Qt5Core / QtCore, but the set of necessary packages should be checked. Signed-off-by: Masahiro Yamada <[email protected]> Tested-by: Randy Dunlap <[email protected]> Acked-by: Randy Dunlap <[email protected]> Reviewed-by: Sam Ravnborg <[email protected]>
1 parent e6ecfb4 commit 0b669a5

File tree

2 files changed

+53
-45
lines changed

2 files changed

+53
-45
lines changed

scripts/kconfig/Makefile

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
188188
# Utilizes ncurses
189189
# mconf: Used for the menuconfig target
190190
# Utilizes the lxdialog package
191-
# qconf: Used for the xconfig target
192-
# Based on Qt which needs to be installed to compile it
193191
# gconf: Used for the gconfig target
194192
# Based on GTK+ which needs to be installed to compile it
195193
# object files used by all kconfig flavours
@@ -201,14 +199,12 @@ conf-objs := conf.o zconf.tab.o
201199
mconf-objs := mconf.o zconf.tab.o $(lxdialog)
202200
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
203201
kxgettext-objs := kxgettext.o zconf.tab.o
204-
qconf-cxxobjs := qconf.o
205-
qconf-objs := zconf.tab.o
206202
gconf-objs := gconf.o zconf.tab.o
207203

208-
hostprogs-y := conf nconf mconf kxgettext qconf gconf
204+
hostprogs-y := conf nconf mconf kxgettext gconf
209205

210206
targets += zconf.lex.c
211-
clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
207+
clean-files := .tmp_gtkcheck
212208
clean-files += gconf.glade.h
213209
clean-files += config.pot linux.pot
214210

@@ -228,9 +224,6 @@ HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTC
228224
HOSTCFLAGS_zconf.lex.o := -I$(src)
229225
HOSTCFLAGS_zconf.tab.o := -I$(src)
230226

231-
HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
232-
HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
233-
234227
HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
235228
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
236229
-Wno-missing-prototypes
@@ -241,34 +234,22 @@ HOSTLOADLIBES_nconf = $(shell \
241234
pkg-config --libs menuw panelw ncursesw 2>/dev/null \
242235
|| pkg-config --libs menu panel ncurses 2>/dev/null \
243236
|| echo "-lmenu -lpanel -lncurses" )
244-
$(obj)/qconf.o: $(obj)/.tmp_qtcheck
245-
246-
ifeq ($(MAKECMDGOALS),xconfig)
247-
$(obj)/.tmp_qtcheck: $(src)/Makefile
248-
-include $(obj)/.tmp_qtcheck
249-
250-
# Qt needs some extra effort...
251-
$(obj)/.tmp_qtcheck:
252-
@set -e; $(kecho) " CHECK qt"; \
253-
if pkg-config --exists Qt5Core; then \
254-
cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
255-
libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \
256-
moc=`pkg-config --variable=host_bins Qt5Core`/moc; \
257-
elif pkg-config --exists QtCore; then \
258-
cflags=`pkg-config --cflags QtCore QtGui`; \
259-
libs=`pkg-config --libs QtCore QtGui`; \
260-
moc=`pkg-config --variable=moc_location QtCore`; \
261-
else \
262-
echo >&2 "*"; \
263-
echo >&2 "* Could not find Qt via pkg-config."; \
264-
echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
265-
echo >&2 "*"; \
266-
exit 1; \
267-
fi; \
268-
echo "KC_QT_CFLAGS=$$cflags" > $@; \
269-
echo "KC_QT_LIBS=$$libs" >> $@; \
270-
echo "KC_QT_MOC=$$moc" >> $@
271-
endif
237+
238+
# qconf: Used for the xconfig target based on Qt
239+
hostprogs-y += qconf
240+
qconf-cxxobjs := qconf.o
241+
qconf-objs := zconf.tab.o
242+
243+
HOSTLOADLIBES_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs)
244+
HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags)
245+
246+
$(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
247+
248+
quiet_cmd_moc = MOC $@
249+
cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@
250+
251+
$(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
252+
$(call cmd,moc)
272253

273254
$(obj)/gconf.o: $(obj)/.tmp_gtkcheck
274255

@@ -298,15 +279,17 @@ endif
298279

299280
$(obj)/zconf.tab.o: $(obj)/zconf.lex.c
300281

301-
$(obj)/qconf.o: $(obj)/qconf.moc
302-
303-
quiet_cmd_moc = MOC $@
304-
cmd_moc = $(KC_QT_MOC) -i $< -o $@
305-
306-
$(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
307-
$(call cmd,moc)
308-
309282
# Extract gconf menu items for i18n support
310283
$(obj)/gconf.glade.h: $(obj)/gconf.glade
311284
$(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
312285
$(obj)/gconf.glade
286+
287+
# check if necessary packages are available, and configure build flags
288+
define filechk_conf_cfg
289+
$(CONFIG_SHELL) $<
290+
endef
291+
292+
$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE
293+
$(call filechk,conf_cfg)
294+
295+
clean-files += .*conf-cfg

scripts/kconfig/qconf-cfg.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
PKG="Qt5Core Qt5Gui Qt5Widgets"
5+
PKG2="QtCore QtGui"
6+
7+
if pkg-config --exists $PKG; then
8+
echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)\"
9+
echo libs=\"$(pkg-config --libs $PKG)\"
10+
echo moc=\"$(pkg-config --variable=host_bins Qt5Core)/moc\"
11+
exit 0
12+
fi
13+
14+
if pkg-config --exists $PKG2; then
15+
echo cflags=\"$(pkg-config --cflags $PKG2)\"
16+
echo libs=\"$(pkg-config --libs $PKG2)\"
17+
echo moc=\"$(pkg-config --variable=moc_location QtCore)\"
18+
exit 0
19+
fi
20+
21+
echo >&2 "*"
22+
echo >&2 "* Could not find Qt via pkg-config."
23+
echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"
24+
echo >&2 "*"
25+
exit 1

0 commit comments

Comments
 (0)