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 <yamada.masahiro@socionext.com>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
This commit is contained in:
Masahiro Yamada 2018-05-22 16:22:19 +09:00
parent e6ecfb4507
commit 0b669a5076
2 changed files with 51 additions and 43 deletions

View File

@ -188,8 +188,6 @@ HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
# Utilizes ncurses # Utilizes ncurses
# mconf: Used for the menuconfig target # mconf: Used for the menuconfig target
# Utilizes the lxdialog package # Utilizes the lxdialog package
# qconf: Used for the xconfig target
# Based on Qt which needs to be installed to compile it
# gconf: Used for the gconfig target # gconf: Used for the gconfig target
# Based on GTK+ which needs to be installed to compile it # Based on GTK+ which needs to be installed to compile it
# object files used by all kconfig flavours # object files used by all kconfig flavours
@ -201,14 +199,12 @@ conf-objs := conf.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o $(lxdialog) mconf-objs := mconf.o zconf.tab.o $(lxdialog)
nconf-objs := nconf.o zconf.tab.o nconf.gui.o nconf-objs := nconf.o zconf.tab.o nconf.gui.o
kxgettext-objs := kxgettext.o zconf.tab.o kxgettext-objs := kxgettext.o zconf.tab.o
qconf-cxxobjs := qconf.o
qconf-objs := zconf.tab.o
gconf-objs := gconf.o zconf.tab.o gconf-objs := gconf.o zconf.tab.o
hostprogs-y := conf nconf mconf kxgettext qconf gconf hostprogs-y := conf nconf mconf kxgettext gconf
targets += zconf.lex.c targets += zconf.lex.c
clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck clean-files := .tmp_gtkcheck
clean-files += gconf.glade.h clean-files += gconf.glade.h
clean-files += config.pot linux.pot clean-files += config.pot linux.pot
@ -228,9 +224,6 @@ HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTC
HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.lex.o := -I$(src)
HOSTCFLAGS_zconf.tab.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src)
HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
-Wno-missing-prototypes -Wno-missing-prototypes
@ -241,34 +234,22 @@ HOSTLOADLIBES_nconf = $(shell \
pkg-config --libs menuw panelw ncursesw 2>/dev/null \ pkg-config --libs menuw panelw ncursesw 2>/dev/null \
|| pkg-config --libs menu panel ncurses 2>/dev/null \ || pkg-config --libs menu panel ncurses 2>/dev/null \
|| echo "-lmenu -lpanel -lncurses" ) || echo "-lmenu -lpanel -lncurses" )
$(obj)/qconf.o: $(obj)/.tmp_qtcheck
ifeq ($(MAKECMDGOALS),xconfig) # qconf: Used for the xconfig target based on Qt
$(obj)/.tmp_qtcheck: $(src)/Makefile hostprogs-y += qconf
-include $(obj)/.tmp_qtcheck qconf-cxxobjs := qconf.o
qconf-objs := zconf.tab.o
# Qt needs some extra effort... HOSTLOADLIBES_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs)
$(obj)/.tmp_qtcheck: HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags)
@set -e; $(kecho) " CHECK qt"; \
if pkg-config --exists Qt5Core; then \ $(obj)/qconf.o: $(obj)/.qconf-cfg $(obj)/qconf.moc
cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \
libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \ quiet_cmd_moc = MOC $@
moc=`pkg-config --variable=host_bins Qt5Core`/moc; \ cmd_moc = $(shell . $(obj)/.qconf-cfg && echo $$moc) -i $< -o $@
elif pkg-config --exists QtCore; then \
cflags=`pkg-config --cflags QtCore QtGui`; \ $(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
libs=`pkg-config --libs QtCore QtGui`; \ $(call cmd,moc)
moc=`pkg-config --variable=moc_location QtCore`; \
else \
echo >&2 "*"; \
echo >&2 "* Could not find Qt via pkg-config."; \
echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \
echo >&2 "*"; \
exit 1; \
fi; \
echo "KC_QT_CFLAGS=$$cflags" > $@; \
echo "KC_QT_LIBS=$$libs" >> $@; \
echo "KC_QT_MOC=$$moc" >> $@
endif
$(obj)/gconf.o: $(obj)/.tmp_gtkcheck $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
@ -298,15 +279,17 @@ endif
$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.tab.o: $(obj)/zconf.lex.c
$(obj)/qconf.o: $(obj)/qconf.moc
quiet_cmd_moc = MOC $@
cmd_moc = $(KC_QT_MOC) -i $< -o $@
$(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
$(call cmd,moc)
# Extract gconf menu items for i18n support # Extract gconf menu items for i18n support
$(obj)/gconf.glade.h: $(obj)/gconf.glade $(obj)/gconf.glade.h: $(obj)/gconf.glade
$(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
$(obj)/gconf.glade $(obj)/gconf.glade
# check if necessary packages are available, and configure build flags
define filechk_conf_cfg
$(CONFIG_SHELL) $<
endef
$(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE
$(call filechk,conf_cfg)
clean-files += .*conf-cfg

25
scripts/kconfig/qconf-cfg.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
PKG="Qt5Core Qt5Gui Qt5Widgets"
PKG2="QtCore QtGui"
if pkg-config --exists $PKG; then
echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)\"
echo libs=\"$(pkg-config --libs $PKG)\"
echo moc=\"$(pkg-config --variable=host_bins Qt5Core)/moc\"
exit 0
fi
if pkg-config --exists $PKG2; then
echo cflags=\"$(pkg-config --cflags $PKG2)\"
echo libs=\"$(pkg-config --libs $PKG2)\"
echo moc=\"$(pkg-config --variable=moc_location QtCore)\"
exit 0
fi
echo >&2 "*"
echo >&2 "* Could not find Qt via pkg-config."
echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"
echo >&2 "*"
exit 1