From 80a4e38fe5eab6c1fe51390f96eefe600996adbf Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 17 Feb 2009 14:36:23 +0100 Subject: [PATCH] QT: Added QT_PROJECT variable This variable could be used as replacement for QT_SUBDIRS. Its purpose is to specify QT .pro files in the current directory to compile. Therefore, running make in a directory with QT application calls OMK, which in turn calls qmake with correct parameters and compiles QT application under _build tree. --- snippets/qt | 45 ++++++++++++++++++++----------------- tests/qt/qtapp/Makefile | 14 ++++++++++++ tests/qt/qtapp/Makefile.omk | 1 + tests/qt/runtest | 12 ++++++---- 4 files changed, 47 insertions(+), 25 deletions(-) create mode 100644 tests/qt/qtapp/Makefile create mode 100644 tests/qt/qtapp/Makefile.omk diff --git a/snippets/qt b/snippets/qt index 613b16f..df11bc0 100644 --- a/snippets/qt +++ b/snippets/qt @@ -1,23 +1,25 @@ -# QT_SUBDIRS .. subdirectories where to build QT applications using qmake +# QT_PROJECTS .. list of QT .pro file to use for compilation +# QT_SUBDIRS .. subdirectories where to build QT applications using qmake (depricated) # QTDIR .. where QT resides -ifneq ($(QT_SUBDIRS),) +ifneq ($(QT_SUBDIRS)$(QT_PROJECTS),) -.PHONY: qt-subpass clean-qt distclean-qt +# Usage: $(call qt_project_template,<.pro_file relative to SOURCES_DIR>) +define qt_project_template -# Usage: $(call qt_makefile_template,) -define qt_subdir_template +.PHONY: qt-subpass-$(1) clean-qt-$(dir $(1)) -$(LOCAL_BUILD_DIR)/$(1)/Makefile: $(wildcard $(SOURCES_DIR)/$(1)/*.pro) - $(Q)mkdir -p $(LOCAL_BUILD_DIR)/$(1) && \ - cd $(LOCAL_BUILD_DIR)/$(1) && \ +# FIXME: Handle multiple .pro files correctly +$(LOCAL_BUILD_DIR)/$(dir $(1))Makefile: $(SOURCES_DIR)/$(1) + $(Q)mkdir -p $$(dir $$(@)) && cd $$(dir $$(@)) && \ $(QTDIR:%=%/bin/)qmake \ - TOP_DIR=$(OUTPUT_DIR) RELATIVE_DIR=$(RELATIVE_PREFIX)$(1) \ + TOP_DIR=$(OUTPUT_DIR) \ + RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir $(1)) \ $(QTDIR:%=QTDIR=%) CC=$(CC) CXX=$(CXX) \ LIBS+="-L$(USER_LIB_DIR)" DESTDIR=$(USER_BIN_DIR) \ INCLUDEPATH+="$(USER_INCLUDE_DIR)" \ QMAKE_LFLAGS="-Wl,-rpath-link,$(USER_LIB_DIR) $$(QMAKE_LFLAGS)" \ - $(SOURCES_DIR)/$(1)/*.pro + $(SOURCES_DIR)/$(1) # This horrible substitution is here to properly escape # -Wl,-rpath,$ORIGIN flags. It includes escaping for make, shell, @@ -26,21 +28,22 @@ QMAKE_LFLAGS = $$(subst $$$$,\\\\\\$$$$\$$$$,$$(LDFLAGS)) # Hook to binary pass binary-pass-submakes: qt-subpass-$(1) -qt-subpass-$(1): $(LOCAL_BUILD_DIR)/$(1)/Makefile - $(Q)$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(1) \ - RELATIVE_DIR=$(RELATIVE_PREFIX)$(1) -C $(LOCAL_BUILD_DIR)/$(1) || exit 1 ; +qt-subpass-$(1): $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile + $(Q)$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir $(1)) \ + RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir $(1)) -C $(LOCAL_BUILD_DIR)/$(dir $(1)) || exit 1 ; # Hook to clean pass -clean-local: clean-qt-$(1) -clean-qt-$(1): $(LOCAL_BUILD_DIR)/$(1)/Makefile - @$(QUIET_CMD_ECHO) " QT CLEAN $(1)" - $(Q)$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(1) \ - RELATIVE_DIR=$(RELATIVE_PREFIX)$(1) \ - -C $(LOCAL_BUILD_DIR)/$(1) clean - $(Q)rm $(LOCAL_BUILD_DIR)/$(1)/Makefile +clean-local: clean-qt-$(dir $(1)) +clean-qt-$(dir $(1)): $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile + @$(QUIET_CMD_ECHO) " QT CLEAN $(dir $(1))" + $(Q)$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir $(1)) \ + RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir $(1)) \ + -C $(LOCAL_BUILD_DIR)/$(dir $(1)) clean + $(Q)rm $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile endef -$(foreach dir,$(QT_SUBDIRS), $(eval $(call qt_subdir_template,$(dir)))) +$(foreach pro,$(QT_PROJECTS), $(eval $(call qt_project_template,$(pro)))) +$(foreach pro,$(foreach dir,$(QT_SUBDIRS), $(wildcard $(dir)/*.pro)), $(eval $(call qt_project_template,$(pro)))) endif diff --git a/tests/qt/qtapp/Makefile b/tests/qt/qtapp/Makefile new file mode 100644 index 0000000..08cf5ff --- /dev/null +++ b/tests/qt/qtapp/Makefile @@ -0,0 +1,14 @@ +# Generic directory or leaf node makefile for OCERA make framework + +ifndef MAKERULES_DIR +MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) ) +endif + +ifeq ($(MAKERULES_DIR),) +all : default +.DEFAULT:: + @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n" +else +include $(MAKERULES_DIR)/Makefile.rules +endif + diff --git a/tests/qt/qtapp/Makefile.omk b/tests/qt/qtapp/Makefile.omk new file mode 100644 index 0000000..38283a1 --- /dev/null +++ b/tests/qt/qtapp/Makefile.omk @@ -0,0 +1 @@ +QT_PROJECTS=qtapp.pro diff --git a/tests/qt/runtest b/tests/qt/runtest index 4961fd3..96bf360 100755 --- a/tests/qt/runtest +++ b/tests/qt/runtest @@ -2,8 +2,6 @@ . ../functions.sh -trap 'rm -f qtapp/Makefile' EXIT - touch config.omk-default QTDIR=/usr/share/qt4 export QTDIR @@ -13,10 +11,16 @@ cp Makefile1.omk Makefile.omk make || error "QT compilation" [ -x _compiled/bin/qtapp ] || error "QT application was not compiled" -make clean || error "QT clean" +make clean || error "QT clean 1" cp Makefile2.omk Makefile.omk make || error "QT Compilation in subdir" [ -x _compiled/bin/qtapp ] || error "QT application was not compiled" -make clean || error "QT clean" +make clean || error "QT clean 2" + +cp Makefile3.omk Makefile.omk +make || error "QT_PROJECT test " +[ -x _compiled/bin/qtapp ] || error "QT application was not compiled" + +make clean || error "QT clean 3" -- 2.39.2