From ff43c03c146cad19ce43a5412df0b39eb61c3bf5 Mon Sep 17 00:00:00 2001 From: "Alif M. Ahmad" Date: Sun, 23 Jul 2017 03:08:17 +0000 Subject: [PATCH] scripts/config: Add qconf target to Makefile qconf is kconfig UI utilizing QT toolkit. This makes it possible to use graphical interface interaction to configure LEDE build target. This commit adds qconf target to ./script/config/Makefile to be used by toplevel ``make xconfig`` later. Signed-off-by: Alif M. Ahmad --- scripts/config/Makefile | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/scripts/config/Makefile b/scripts/config/Makefile index 60e1bbdcb4..9620273202 100644 --- a/scripts/config/Makefile +++ b/scripts/config/Makefile @@ -7,6 +7,8 @@ # conf: Used for defconfig, oldconfig and related targets # mconf: Used for the mconfig target. # Utilizes the lxdialog package +# qconf: Used for the xconfig target +# Based on Qt which needs to be installed to compile it # object files used by all kconfig flavours @@ -18,19 +20,33 @@ check_lxdialog = $(shell $(SHELL) $(CURDIR)/lxdialog/check-lxdialog.sh -$(1)) export CFLAGS += -DKBUILD_NO_NLS -I. $(call check_lxdialog,ccflags) export CXXFLAGS += -DKBUILD_NO_NLS +DISTRO-PKG-CONFIG := $(shell which -a pkg-config | grep -E '\/usr' | head -n 1) + conf-objs := conf.o zconf.tab.o mconf-objs := mconf.o zconf.tab.o +qconf-cxxobjs := qconf.o +qconf-objs := zconf.tab.o + lxdialog-objs := \ lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o \ lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o clean-files := zconf.tab.c lex.zconf.c zconf.hash.c +# Remove qconf junk files +clean-files += $(qconf-cxxobjs) qconf.moc .tmp_qtcheck all: conf mconf conf: $(conf-objs) mconf: $(mconf-objs) $(lxdialog-objs) $(CC) -o $@ $^ $(call check_lxdialog,ldflags $(CC)) +qconf: $(qconf-cxxobjs) $(qconf-objs) +ifneq ($(DISTRO-PKG-CONFIG),) + $(CXX) $(HOSTLOADLIBES_qconf) -o $@ $^ +else + echo "You don't have 'pkg-config' installed. Cannot continue" + echo "For now, you may use 'make menuconfig' instead of 'make xconfig'" +endif clean: rm -f *.o lxdialog/*.o $(clean-files) conf mconf @@ -51,3 +67,43 @@ zconf.hash.c: zconf.gperf %.hash.c: %.gperf cp $@_shipped $@ || gperf < $< > $@ + +ifeq ($(MAKECMDGOALS),qconf) +qconf.o: .tmp_qtcheck +.tmp_qtcheck: Makefile +-include .tmp_qtcheck + +# Qt needs some extra effort... +.tmp_qtcheck: + @set -e; echo " CHECK qt"; \ + if $(DISTRO-PKG-CONFIG) --exists Qt5Core; then \ + cflags="-std=c++11 -fPIC `$(DISTRO-PKG-CONFIG) --cflags Qt5Core Qt5Gui Qt5Widgets`"; \ + libs=`$(DISTRO-PKG-CONFIG) --libs Qt5Core Qt5Gui Qt5Widgets`; \ + moc=`$(DISTRO-PKG-CONFIG) --variable=host_bins Qt5Core`/moc; \ + elif $(DISTRO-PKG-CONFIG) --exists QtCore; then \ + cflags=`$(DISTRO-PKG-CONFIG) --cflags QtCore QtGui`; \ + libs=`$(DISTRO-PKG-CONFIG) --libs QtCore QtGui`; \ + moc=`$(DISTRO-PKG-CONFIG) --variable=moc_location QtCore`; \ + else \ + echo >&2 "*"; \ + echo >&2 "* Could not find Qt via $(DISTRO-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 + +#Define compiler flags to build qconf +HOSTLOADLIBES_qconf = $(KC_QT_LIBS) +HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) + +qconf.o: qconf.moc +qconf.o: CXXFLAGS+=$(HOSTCXXFLAGS_qconf.o) + +moc = $(KC_QT_MOC) -i $< -o $@ + +%.moc: %.h .tmp_qtcheck + $(call moc)