]> rtime.felk.cvut.cz Git - omk.git/commitdiff
QT: Added QT_PROJECT variable
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 17 Feb 2009 13:36:23 +0000 (14:36 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 17 Feb 2009 13:36:23 +0000 (14:36 +0100)
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
tests/qt/qtapp/Makefile [new file with mode: 0644]
tests/qt/qtapp/Makefile.omk [new file with mode: 0644]
tests/qt/runtest

index 613b16ff1517efdef9f45dc17441d6b31483cd49..df11bc0199ceae78a5215a76ccf56cf25219fca3 100644 (file)
@@ -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,<qt-subdir>)
-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 (file)
index 0000000..08cf5ff
--- /dev/null
@@ -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 (file)
index 0000000..38283a1
--- /dev/null
@@ -0,0 +1 @@
+QT_PROJECTS=qtapp.pro
index 4961fd3cd849466702dc0995a68aaa7bd4c6554f..96bf360b94951257530e71af09d2a1ec7c545644 100755 (executable)
@@ -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"