[PATCH 8/9] kconfig: qt flavour makefile fixes

davidgraeff
2013-07-02T15:23:42Z

* Add comments to the makefile
* fix moc/uic invocation
* Compile moc classes as objects and link to qconf instead of including with #include.
This is more compliant to the way IDEs like QtCreator work.
---
scripts/kconfig/qconfig/Makefile | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/scripts/kconfig/qconfig/Makefile b/scripts/kconfig/qconfig/Makefile
index 72e0bd1..b9857c3 100644
--- a/scripts/kconfig/qconfig/Makefile
+++ b/scripts/kconfig/qconfig/Makefile
@@ -4,9 +4,6 @@

PHONY += xconfig qconfig

-MOC_HEADERS := $(wildcard $(obj)/qconfig/*.h)
-MOCS := $(patsubst %.h,%.moc,$(MOC_HEADERS))
-
xconfig: $(obj)/qconf
$< $(Kconfig)

@@ -14,12 +11,24 @@ qconfig: $(obj)/qconf
$< $(Kconfig)

# ===========================================================================
-# qconf: Used for the xconfig target
-# Based on QT which needs to be installed to compile it
-# object files used by all kconfig flavours listed above
+# qconf: Used for the xconfig/qconfig target
+# Based on Qt4+ which needs to be installed to compile it
+
+# Meta object files (moc files) have to be considered for every class that uses the Q_OBJECT macro.
+# We collect all class header files below, build moc_[filename].o object filenames and store those in "MOCS".
+# Assumtion: All header files in this directory contain c++ code.
+MOC_HEADERS := $(wildcard $(obj)/qconfig/*.h)
+MOC_SOURCE_FILES := $(patsubst $(obj)/qconfig/%,%,$(MOC_HEADERS)) # remove directory part
+MOC_DEST_FILES := $(patsubst %.h,moc_%.o,$(MOC_SOURCE_FILES)) # add moc_ prefix
+MOCS := $(patsubst %,qconfig/%,$(MOC_DEST_FILES)) # add directory part

+# Object files used by this kconfig flavours listed below. Meta object files (moc files) are generated by
+# the Qt moc tool. We have to build and link those generated files, too.
qconf-cxxobjs := qconfig/qconf.o qconfig/configItem.o qconfig/configModel.o qconfig/configmodeldelegate.o \
- qconfig/infoViewWidget.o qconfig/mainwindow.o qconfig/searchfiltermodelproxy.o qconfig/searchmodel.o
+ qconfig/infoViewWidget.o qconfig/mainwindow.o qconfig/searchfiltermodelproxy.o qconfig/searchmodel.o \
+ $(MOCS)
+
+# Object files used by all kconfig flavours listed below
qconf-objs := zconf.tab.o

ifeq ($(MAKECMDGOALS),qconfig)
@@ -34,12 +43,12 @@ ifeq ($(qconf-target),1)
hostprogs-y += qconf
endif

-clean-files += qconfig/*.moc qconfig/ui_*.h qconfig/.tmp_qtcheck qconf
+clean-files += qconfig/moc_*.cc qconfig/ui_*.h qconfig/.tmp_qtcheck qconf

HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
-HOSTCXXFLAGS = $(KC_QT_CFLAGS) -DINCLUDEMOC
+HOSTCXXFLAGS = $(KC_QT_CFLAGS)

-$(obj)/qconfig/qconf.o: $(MOCS) $(UIS) $(src)/qconfig/.tmp_qtcheck
+$(obj)/qconfig/qconf.o: $(src)/qconfig/.tmp_qtcheck
$(obj)/qconfig/mainwindow.o: $(obj)/qconfig/ui_mainwindow.h

ifeq ($(qconf-target),1)
@@ -71,15 +80,15 @@ $(obj)/qconfig/.tmp_qtcheck:
echo "KC_QT_UIC=$$uic" >> $@
endif

-$(obj)/qconfig/%.o: $(obj)/qconfig/%.moc
-
quiet_cmd_moc = MOC $@
- cmd_moc = $(KC_QT_MOC) -nn -i $< -o $@
+ cmd_moc = $(KC_QT_MOC) -nn $< -o $@
quiet_cmd_uic = UIC $@
cmd_uic = $(KC_QT_UIC) -n $< -o $@

-$(obj)/qconfig/%.moc: $(obj)/qconfig/%.h $(obj)/qconfig/.tmp_qtcheck
+$(obj)/qconfig/moc_%.cc: $(obj)/qconfig/%.h
$(call cmd,moc)

-$(obj)/qconfig/ui_%.h: $(obj)/qconfig/%.ui $(obj)/qconfig/.tmp_qtcheck
+$(obj)/qconfig/ui_%.h: $(obj)/qconfig/%.ui
$(call cmd,uic)
+
+$(obj)/qconfig/%.o: $(obj)/qconfig/moc_%.o
--
1.8.1.2