From 8b67a17d067fd2ac25eb35d15a150e516715b6ce Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Mon, 17 May 2010 09:06:19 +0000
Subject: [PATCH] Update linux Qt build script so that it will run whether
 qmake has already been run or not. Re #100

---
 Code/qtiplot/MantidQt/mantidqt.pri            | 25 +++-----
 .../QtPropertyBrowser/qtpropertybrowser.pro   | 14 ++---
 Code/qtiplot/build.sh                         | 57 +++++++-----------
 Code/qtiplot/qtiplot/qtiplot.pro              | 60 ++++++++-----------
 4 files changed, 62 insertions(+), 94 deletions(-)

diff --git a/Code/qtiplot/MantidQt/mantidqt.pri b/Code/qtiplot/MantidQt/mantidqt.pri
index 7f8fe762983..79e924e7493 100644
--- a/Code/qtiplot/MantidQt/mantidqt.pri
+++ b/Code/qtiplot/MantidQt/mantidqt.pri
@@ -6,7 +6,7 @@
 #------------------------
 # Compile mode
 #------------------------
-CONFIG += qt warn_on exceptions
+CONFIG += qt warn_on exceptions debug_and_release
 
 QMAKESPEC=win32-msvc2005
 
@@ -29,17 +29,14 @@ RESOURCES = "$$TOPBUILDDIR/../../../Images/images.qrc"
 
 # My variables
 MANTIDPATH = "$$TOPBUILDDIR/../../Mantid"
-MANTIDLIBPATH = "$$MANTIDPATH/Bin/Shared"
-win32 {
+build_pass:CONFIG(release, debug|release) {
+  # Put both Scons and Visual Studio output directories on the search path
+  LIBPATH += "$$MANTIDPATH/release"
+  MANTIDLIBPATH = "$$MANTIDPATH/Bin/Shared"
+  LIBPATH += $$MANTIDLIBPATH
+} else{
+  MANTIDLIBPATH = "$$MANTIDPATH/debug"
   LIBPATH += $$MANTIDLIBPATH
-  build_pass:CONFIG(release, debug|release) {
-    # Put both Scons and Visual Studio output directories on the search path
-    LIBPATH += "$$MANTIDPATH/release"
-  }
-  build_pass:CONFIG(debug, debug|release) {
-    MANTIDLIBPATH = "$$MANTIDPATH/debug"
-    LIBPATH += $$MANTIDLIBPATH
-  }
 }
 
 THIRDPARTY = "$$TOPBUILDDIR/../../Third_Party"
@@ -113,14 +110,10 @@ CONFIG(debug, debug|release) {
 }
 SIP_DIR = "$$TMPDIR"
 
-win32:build_pass:CONFIG(debug, debug|release) {
+build_pass:CONFIG(debug, debug|release) {
   # Put alongside Mantid libraries
   DESTDIR = "$$MANTIDLIBPATH"
 } else {
   # Put in local output directory
   DESTDIR = "$$TOPBUILDDIR/lib"
 }
-
-# This makes release the default build on running nmake. Must be here - after the config dependent parts above
-CONFIG += release
-
diff --git a/Code/qtiplot/QtPropertyBrowser/qtpropertybrowser.pro b/Code/qtiplot/QtPropertyBrowser/qtpropertybrowser.pro
index efeb9ff73dd..ce752d90570 100644
--- a/Code/qtiplot/QtPropertyBrowser/qtpropertybrowser.pro
+++ b/Code/qtiplot/QtPropertyBrowser/qtpropertybrowser.pro
@@ -1,6 +1,5 @@
 TEMPLATE=lib
-CONFIG += shared
-CONFIG += release_and_debug
+CONFIG += shared debug_and_release
 
 INCLUDEPATH += src
 DEPENDPATH += src
@@ -25,18 +24,19 @@ HEADERS += src/qtpropertybrowser.h \
         src/FilenameEditorFactory.h 
 RESOURCES += src/qtpropertybrowser.qrc
 
-win32 {
+build_pass:win32 {
     DEFINES += QT_QTPROPERTYBROWSER_EXPORT
 }
 
-win32:build_pass:CONFIG(debug, debug|release) {
+build_pass:CONFIG(debug, debug|release) {
   # Put alongside Mantid libraries
-  DESTDIR = ..\..\Mantid\debug
-  TARGET = QtPropertyBrowserd
+  DESTDIR = ../../Mantid/debug
+  win32:TARGET = QtPropertyBrowserd
+  unix:TARGET=QtPropertyBrowser
 } else {
   # Put in local output directory
   DESTDIR = lib
   TARGET = QtPropertyBrowser
 }
 
-CONFIG += release
+
diff --git a/Code/qtiplot/build.sh b/Code/qtiplot/build.sh
index e3b82e53b5c..004b0df4a76 100644
--- a/Code/qtiplot/build.sh
+++ b/Code/qtiplot/build.sh
@@ -2,12 +2,24 @@
 #
 # Build the Mantidplot user interface
 #
-#
-CLEAN="0"
-QMAKE_CONFIG=""
+build_library () {
+    if [ "$2" = "clean" -o ! -f Makefile ]; then
+	qmake-qt4 QMAKE_CC="${CC:-gcc}" QMAKE_CXX="${CXX:-g++}" QMAKE_LINK="${CXX:-g++}"
+    fi
+    if [ "$2" = "clean" ]; then
+	make clean
+    fi
+    make
+    ERRORCODE=$?
+    if [ $ERRORCODE != 0 ]; then
+	echo "Error: $1 build failed with error code $ERRORCODE"
+	exit $ERRORCODE
+    fi
+}
+
+CLEAN=""
 if [ $# -ge 1 ]; then 
-    if [ $1 = "clean" ]; then CLEAN="1"; fi
-    if [ $2 = "--debug" ]; then QMAKE_CONFIG="CONFIG+=debug"; fi
+    if [ $1 = "clean" ]; then CLEAN=$1; fi
 fi
 if [ $# -ge 2 ]; then 
     VERSION=$2
@@ -23,43 +35,16 @@ ROOTDIR=`pwd`
 
 # First, build dialog library
 cd $ROOTDIR/MantidQt
-if [ $CLEAN = "1" ]; then 
-    make clean 
-    qmake-qt4 QMAKE_CC="${CC:-gcc}" QMAKE_CXX="${CXX:-g++}" QMAKE_LINK="${CXX:-g++}" ${QMAKE_CONFIG}
-fi
-
-make
-ERRORCODE=$?
-if [ $ERRORCODE != 0 ]; then
-    echo "Error: MantidQt build failed with error code $ERRORCODE"
-    exit $ERRORCODE
-fi
+build_library "MantidQt" $CLEAN
 
 # QtPropertyBrowser library
 cd $ROOTDIR/QtPropertyBrowser
-if [ $CLEAN = "1" ]; then 
-    make clean
-    qmake-qt4 QMAKE_CC="${CC:-gcc}" QMAKE_CXX="${CXX:-g++}" QMAKE_LINK="${CXX:-g++}" ${QMAKE_CONFIG}
-fi
-make -j2
-ERRORCODE=$?
-if [ $ERRORCODE != 0 ]; then
-    echo "Error: QtPropertyBrowser build failed with error code $ERRORCODE"
-    exit $ERRORCODE
-fi
+build_library "QtPropertyBrowser" $CLEAN
 
 # Now build qtiplot
 cd $ROOTDIR/qtiplot
-if [ $CLEAN = "1" ]; then 
-    make clean
-    qmake-qt4 QMAKE_CC="${CC:-gcc}" QMAKE_CXX="${CXX:-g++}" QMAKE_LINK="${CXX:-g++}" ${QMAKE_CONFIG}
-fi
-make -j2
-ERRORCODE=$?
-if [ $ERRORCODE != 0 ]; then
-    echo "Error: MantidPlot build failed with error code $ERRORCODE"
-    exit $ERRORCODE
-fi
+build_library "MantidPlot" $CLEAN
 
 # If we reached this point then the build was successful
 echo "MantidQt and MantidPlot build succeeded"
+cd $ROOTDIR
diff --git a/Code/qtiplot/qtiplot/qtiplot.pro b/Code/qtiplot/qtiplot/qtiplot.pro
index 2091fbbc509..ac192f09e06 100644
--- a/Code/qtiplot/qtiplot/qtiplot.pro
+++ b/Code/qtiplot/qtiplot/qtiplot.pro
@@ -2,20 +2,6 @@
 ###################### USER-SERVICEABLE PART ################################
 #############################################################################
 
-win32 {
- QMAKESPEC=win32-msvc2005  
-}
-unix {
-QMAKE_CXXFLAGS_RELEASE += -g
-QMAKE_LFLAGS_RELEASE += -g
- macx{
- QMAKESPEC=macx-g++
- } else {
-# could also be linux-g++-64 so maybe best left to the system to determine
-# QMAKESPEC=linux-g++
- }
-}
-
 # building without muParser doesn't work yet
 SCRIPTING_LANGS += muParser
 SCRIPTING_LANGS += Python
@@ -39,20 +25,22 @@ RESOURCES        = ../../../Images/images.qrc
 # the *.path variables defined bellow. 
 ######################################################################################
 #CONFIG          += CustomInstall
-
+
+CONFIG += debug_and_release
+
 win32:build_pass:CONFIG(debug, debug|release) {
   CONFIG += console
-}
-
+}
+
 build_pass:CONFIG(debug, debug|release) {
   # Put the debug version alongside the Mantid debug dlls to make sure it picks them up
-  DESTDIR = ../../Mantid/debug
+  DESTDIR = "../../Mantid/debug"
 } else {
-  DESTDIR = ./
-}
-
-mac:CXXFLAGS+=-headerpad_max_install_names
-
+  DESTDIR = ./
+}
+
+mac:CXXFLAGS+=-headerpad_max_install_names
+
 ##################### 3rd PARTY HEADER FILES SECTION ########################
 #!!! Warning: You must modify these paths according to your computer settings
 #############################################################################
@@ -99,7 +87,7 @@ unix:!macx {
 ##################### Linux (Mac OS X) ######################################
 
 # dynamically link against dependencies if they are installed system-wide
-unix {
+unix {
   LIBS         += -lqscintilla2
   LIBS         += -lmuparser
 
@@ -145,21 +133,25 @@ macx {
 
   LIBS         += -lgsl -lgslcblas
 
-  LIBS		+= -L../../Mantid/Bin/Shared -lMantidAPI
-  LIBS		+= -L../../Mantid/Bin/Shared -lMantidGeometry
-  LIBS		+= -L../../Mantid/Bin/Shared -lMantidKernel
-
-  LIBS          += -L../QtPropertyBrowser/lib -lQtPropertyBrowser
-
-  LIBS   += -L../MantidQt/lib -lMantidQtAPI
-
-CONFIG(debug, debug|release) {
+
+build_pass:CONFIG(debug, debug|release) {				 
+  LIBS  += -L../../Mantid/debug
   LIBS	+= -lPocoUtild
   LIBS	+= -lPocoFoundationd
 } else {
+  LIBS  += -L../../Mantid/Bin/Shared	
+  LIBS  += -L../MantidQt/lib
+  LIBS  += -L../QtPropertyBrowser/lib
+
   LIBS	+= -lPocoUtil
   LIBS	+= -lPocoFoundation
+
  }
+ LIBS  += -lMantidAPI
+ LIBS  += -lMantidGeometry
+ LIBS  += -lMantidKernel
+ LIBS  += -lQtPropertyBrowser 
+ LIBS  += -lMantidQtAPI	
 }
 
 ##################### Windows ###############################################
@@ -212,8 +204,6 @@ win32 {
   LIBS += MantidKernel.lib
   LIBS += MantidQtAPI.lib
 
-  # This makes release the default build on running nmake. Must be here - after the config dependent parts above
-  CONFIG += release
 }
 #############################################################################
 ###################### END OF USER-SERVICEABLE PART #########################
-- 
GitLab