]> rtime.felk.cvut.cz Git - omk/sssa.git/commitdiff
Updated QT rules
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 17 Feb 2009 12:50:15 +0000 (13:50 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 17 Feb 2009 12:50:15 +0000 (13:50 +0100)
All temporary files are automatically put under _build and binaries under
_compiled. Also LDFLAGS are propagated to qmake-generated Makefile. Clean
target works correctly and no special target for distclean is needed as
everything is put under _build.

This behavior is problematic during development of QT application since it
cannot be compiled by running make in sources directory.

snippets/qt
tests/qt/runtest
tests/qt/somelib/Makefile.omk

index c09b28afcee9bb373191081bf9696e436866418c..613b16ff1517efdef9f45dc17441d6b31483cd49 100644 (file)
@@ -6,46 +6,42 @@ ifneq ($(QT_SUBDIRS),)
 .PHONY: qt-subpass clean-qt distclean-qt
 
 # Usage: $(call qt_makefile_template,<qt-subdir>)
-define qt_makefile_template
-$(SOURCES_DIR)/$(1)/Makefile: $(wildcard $(SOURCES_DIR)/$(1)/*.pro)
-       cd $(SOURCES_DIR)/$(1); $(QTDIR:%=%/bin/)qmake TOP_DIR=$(OUTPUT_DIR) \
-            RELATIVE_DIR=$(RELATIVE_PREFIX)$(1) $(QTDIR:%=QTDIR=%) CC=$(CC) \
-            CXX=$(CXX) LIBS+="-L$(USER_LIB_DIR)" INCLUDEPATH+="$(USER_INCLUDE_DIR)"
-endef
-$(foreach dir,$(QT_SUBDIRS), $(eval $(call qt_makefile_template,$(dir))))
-
-qt-subpass: $(foreach dir,$(QT_SUBDIRS), $(SOURCES_DIR)/$(dir)/Makefile)
-       $(foreach dir,$(QT_SUBDIRS),\
-               $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
-               RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(SOURCES_DIR)/$(dir) \
-               -f $(SOURCES_DIR)/$(dir)/Makefile || exit 1 ;)
+define qt_subdir_template
+
+$(LOCAL_BUILD_DIR)/$(1)/Makefile: $(wildcard $(SOURCES_DIR)/$(1)/*.pro)
+       $(Q)mkdir -p $(LOCAL_BUILD_DIR)/$(1) &&                         \
+       cd $(LOCAL_BUILD_DIR)/$(1) &&                                   \
+       $(QTDIR:%=%/bin/)qmake                                          \
+            TOP_DIR=$(OUTPUT_DIR) RELATIVE_DIR=$(RELATIVE_PREFIX)$(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
+
+# This horrible substitution is here to properly escape
+# -Wl,-rpath,$ORIGIN flags. It includes escaping for make, shell,
+# qmake and again make and shell run on qmake generated makefile.
+QMAKE_LFLAGS = $$(subst $$$$,\\\\\\$$$$\$$$$,$$(LDFLAGS))
 
 # Hook to binary pass
-binary-pass-submakes: qt-subpass
+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 ;
 
 # Hook to clean pass
-clean-local: clean-qt
-clean-qt:
-       +@$(foreach dir, $(QT_SUBDIRS), \
-               $(if $(wildcard $(SOURCES_DIR)/$(dir)/Makefile), \
-               @$(QUIET_CMD_ECHO) "  CLEAN   $(dir)"; \
-               $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
-               RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(SOURCES_DIR)/$(dir) \
-               -f $(SOURCES_DIR)/$(dir)/Makefile clean|| exit 1 ;))
-
-
-# Hook to distclean
-distclean: distclean-qt
-
-# TODO: Add distclean-qt-pass to handle QT_SUBDIRS in the whole
-# tree. This way we only distclean toplevel subdirs.
-distclean-qt:
-       +@$(foreach dir, $(QT_SUBDIRS), \
-               $(if $(wildcard $(SOURCES_DIR)/$(dir)/Makefile), \
-               @$(QUIET_CMD_ECHO) "  DISTCLEAN $(dir)"; \
-               $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) \
-               RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(SOURCES_DIR)/$(dir) \
-               -f $(SOURCES_DIR)/$(dir)/Makefile distclean|| exit 1 ;))
+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
+endef
+
+$(foreach dir,$(QT_SUBDIRS), $(eval $(call qt_subdir_template,$(dir))))
+
 endif
 
 # Local Variables:
index 45435374c5f571ac47a632dcad745191c19fbf4c..4961fd3cd849466702dc0995a68aaa7bd4c6554f 100755 (executable)
@@ -2,6 +2,8 @@
 
 . ../functions.sh
 
+trap 'rm -f qtapp/Makefile' EXIT
+
 touch config.omk-default
 QTDIR=/usr/share/qt4
 export QTDIR
@@ -9,10 +11,12 @@ export QTDIR
 
 cp Makefile1.omk Makefile.omk
 make || error "QT compilation"
-[ -x qtapp/qtapp ] || error "QT application was not compiled"
+[ -x _compiled/bin/qtapp ] || error "QT application was not compiled"
 
-make distclean || error "QT distclean"
+make clean || error "QT clean"
 
 cp Makefile2.omk Makefile.omk
 make || error "QT Compilation in subdir"
-[ -x qtapp/qtapp ] || error "QT application was not compiled"
+[ -x _compiled/bin/qtapp ] || error "QT application was not compiled"
+
+make clean || error "QT clean"
index 0726c154b6c775a90e15608f04ba270204128f9b..3d26c8901661783f19625b44b9837c96124f097f 100644 (file)
@@ -1,4 +1,5 @@
 include_HEADERS = header.h
-lib_LIBRARIES = somelib
+shared_LIBRARIES = somelib
+
 
 somelib_SOURCES = somelib.c