From 851abe7661a29333cc93cc37f0d7dae3b5fa2c11 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@Germany>
Date: Fri, 8 Aug 2008 17:55:28 +0200
Subject: [PATCH] adjusted and improved buildParaView script

  - usage, explicit -fast option for rebuilding new -mpi, -python, -mesa
    options for specifying alternative modules to include without editing
    the file
  - the build options can also be grabbed from the script name itself.
    eg, the soft-link buildParaView3.3-cvs-python specifies that the python
    module should be included
  - misc. cleanup in tools/buildParaViewFunctions: give the user some
    feedback about the python version, set all variables at the bottom
    of the file rather between initialise and build.
  - be more careful when changing the hard-links to avoid the find
    '-execdir' option (fails when the user has '.' in the path), and
    do separate find/loop/grep/sed on the files to avoid touching too many
    files and ruining a later rebuild stage.

Notes:
  - the cmake uses -DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR, but this
    variable isn't defined anywhere.
---
 bin/buildParaView3.3-cvs         | 118 +++++---
 bin/buildParaView3.3-cvs-python  |   1 +
 bin/tools/buildParaView3.2.1     |  40 +--
 bin/tools/buildParaViewFunctions | 473 +++++++++++++++++--------------
 4 files changed, 366 insertions(+), 266 deletions(-)
 create mode 120000 bin/buildParaView3.3-cvs-python

diff --git a/bin/buildParaView3.3-cvs b/bin/buildParaView3.3-cvs
index 0327402419e..1f95596f3c5 100755
--- a/bin/buildParaView3.3-cvs
+++ b/bin/buildParaView3.3-cvs
@@ -29,66 +29,108 @@
 # Description
 #     Build and install ParaView
 #     - run from folder above ParaView source folder or place the
-#       ParaView source under $WM_PROJECT_INST_DIR
+#       ParaView source under $WM_THIRD_PARTY_DIR
 #
 #------------------------------------------------------------------------------
 . $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions
 
-# set -x
-
 PARAVIEW_SRC="ParaView3.3-cvs"
 PARAVIEW_MAJOR_VERSION="3.3"
-VERBOSE=OFF
-
 
-# User options
-# ~~~~~~~~~~~~
+# User options:
+# ~~~~~~~~~~~~~
 
-# MPI suport
-INCLUDE_MPI=OFF
+# MPI support:
+WITH_MPI=OFF
 MPI_MAX_PROCS=32
 
-# Python
-# note: script will try to determine python library. If it fails, specify the
-#       path using the PYTHON_LIBRARY variable
-INCLUDE_PYTHON=OFF
-#PYTHON_LIBRARY="/usr/lib64/libpython2.5.so.1.0"
+# Python support:
+# note: script will try to determine python library.
+#       If it fails, specify the path using the PYTHON_LIBRARY variable
+WITH_PYTHON=OFF
 PYTHON_LIBRARY=""
+# PYTHON_LIBRARY="/usr/lib64/libpython2.5.so.1.0"
 
-# MESA graphics
-INCLUDE_MESA=OFF
-
-
-# No further editing should be required below this line
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-set +x
-
-# Provide a shortcut for repeated builds - use with caution
-if [ "$#" -gt 0 ]
-then
-   CMAKE_SKIP=YES
-fi
-
-
-# Initialisation
-#~~~~~~~~~~~~~~~
-initialiseVariables
+# MESA graphics support:
+WITH_MESA=OFF
 
+#
+# No further editing below this line
+#------------------------------------------------------------------------------
+Script=${0##*/}
+
+usage() {
+   while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+   cat<<USAGE
+
+usage: ${0##*/} [OPTION]
+options:
+  -fast      skip cmake for repeated builds - use with caution
+  -mpi       with mpi (if not already enabled)
+  -python    with python (if not already enabled)
+  -mesa      with mesa (if not already enabled)
+  -verbose   verbose cmake output
+  -help
+
+Build and install $PARAVIEW_SRC
+  - run from folder above the ParaView source folder or place the
+    ParaView source under \$WM_THIRD_PARTY_DIR
+
+USAGE
+   exit 1
+}
+
+# options based on the script name:
+case "$Script" in *-fast*)   CMAKE_SKIP=ON;; esac
+case "$Script" in *-mpi*)    WITH_MPI=ON;; esac
+case "$Script" in *-python*) WITH_PYTHON=ON;; esac
+case "$Script" in *-mesa*)   WITH_MESA=ON;; esac
+
+# parse options
+while [ "$#" -gt 0 ]
+do
+   case "$1" in
+   -h | -help)
+      usage
+      ;;
+   -fast)
+      CMAKE_SKIP=YES
+      shift
+      ;;
+   -mpi)
+      WITH_MPI=ON
+      shift
+      ;;
+   -python)
+      WITH_PYTHON=ON
+      shift
+      ;;
+   -mesa)
+      WITH_MESA=ON
+      shift
+      ;;
+   -verbose)
+      VERBOSE=ON
+      shift
+      ;;
+   *)
+      usage "unknown option/argument: '$*'"
+      ;;
+   esac
+done
 
 # Set configure options
 #~~~~~~~~~~~~~~~~~~~~~~
-addMpiSupport       # set MPI specific options
-addPythonSupport    # set python specific options
-addMesaSupport      # set MESA specific options
-
+addVerbosity        # set CMake verbosity
+addMpiSupport       # set MPI-specific options
+addPythonSupport    # set Python-specific options
+addMesaSupport      # set MESA-specific options
 
 # Build and install
 # ~~~~~~~~~~~~~~~~~
 buildParaView
 installParaView
 
-
 echo "done"
 
 #------------------------------------------------------------------------------
diff --git a/bin/buildParaView3.3-cvs-python b/bin/buildParaView3.3-cvs-python
new file mode 120000
index 00000000000..db5ce4641b1
--- /dev/null
+++ b/bin/buildParaView3.3-cvs-python
@@ -0,0 +1 @@
+buildParaView3.3-cvs
\ No newline at end of file
diff --git a/bin/tools/buildParaView3.2.1 b/bin/tools/buildParaView3.2.1
index e6a87af07bb..904682581df 100755
--- a/bin/tools/buildParaView3.2.1
+++ b/bin/tools/buildParaView3.2.1
@@ -24,7 +24,7 @@
 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #
 # Script
-#     buildParaView
+#     buildParaView3.2.1
 #
 # Description
 #     Build and install ParaView
@@ -34,34 +34,38 @@
 #------------------------------------------------------------------------------
 . $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions
 
-# set -x
-
 PARAVIEW_SRC="ParaView3.2.1"
 PARAVIEW_MAJOR_VERSION="3.2"
 
-VERBOSE=OFF
-INCLUDE_MPI=ON
+# User options:
+# ~~~~~~~~~~~~~
+
+WITH_MPI=ON
 MPI_MAX_PROCS=32
-INCLUDE_PYTHON=ON
+WITH_PYTHON=ON
 PYTHON_LIBRARY=""
-INCLUDE_MESA=OFF
+WITH__MESA=OFF
 
-set +x
+#
+# No further editing below this line
+#------------------------------------------------------------------------------
 
-# provide a shortcut for repeated builds - use with caution
-if [ "$#" -gt 0 ]
+# shortcut for repeated builds - use with caution
+if [ "$1" = "-fast" ]
 then
    CMAKE_SKIP=YES
+elif [ "$#" -gt 0 ]
+then
+   echo "$0: only supports a -fast option"
+   exit 1
 fi
 
-# set paraview environment
-PARAVIEW_SRC_DIR=$PWD/$PARAVIEW_SRC
-#PARAVIEW_OBJ_DIR=$PARAVIEW_SRC_DIR/platforms/$WM_OPTIONS/obj$OBJ_ADD
-PARAVIEW_OBJ_DIR=$PARAVIEW_SRC_DIR/platforms/$WM_ARCH$WM_COMPILER
-
-addMpiSupport       # set MPI specific options
-addPythonSupport    # set python specific options
-addMesaSupport      # set MESA specific options
+# Set configure options
+#~~~~~~~~~~~~~~~~~~~~~~
+addVerbosity        # set cmake verbosity
+addMpiSupport       # set MPI-specific options
+addPythonSupport    # set Python-specific options
+addMesaSupport      # set MESA-specific options
 
 buildParaView
 installParaView
diff --git a/bin/tools/buildParaViewFunctions b/bin/tools/buildParaViewFunctions
index 7231ad140e7..ef5a25923a0 100644
--- a/bin/tools/buildParaViewFunctions
+++ b/bin/tools/buildParaViewFunctions
@@ -30,247 +30,300 @@
 #
 #------------------------------------------------------------------------------
 
-addCMakeVariable ()
+# ParaView_INST_DIR  : location of the original sources
+# ParaView_DIR       : location of the compiled output
+
+addCMakeVariable()
 {
-    while [ -n "$1" ]
-    do
-        CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
-        shift
-    done
+   while [ -n "$1" ]
+   do
+      CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
+      shift
+   done
 }
 
 
-initialiseVariables ()
+addVerbosity()
 {
-    unset CMAKE_VARIABLES OBJ_ADD
-
-    if [ "$VERBOSE" = ON ]; then
-        addCMakeVariable "CMAKE_VERBOSE_MAKEFILE=TRUE"
-    fi
-    addCMakeVariable "VTK_USE_TK=FALSE"
+   [ "$VERBOSE" = ON ] && addCMakeVariable  CMAKE_VERBOSE_MAKEFILE=TRUE
 }
 
 
-addMpiSupport ()
+addMpiSupport()
 {
-    [ "$INCLUDE_MPI" = ON ] || return
-
-    MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so
-    MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include
-    MPI_RUN=$MPI_ARCH_PATH/bin/mpirun
-
-    OBJ_ADD="$OBJ_ADD-mpi"
-    addCMakeVariable "VTK_USE_MPI=ON"
-    addCMakeVariable "PARAVIEW_USE_MPI=ON"
-    addCMakeVariable "MPI_INCLUDE_PATH=$MPI_INCLUDE_PATH"
-    addCMakeVariable "MPI_LIBRARY=$MPI_LIBRARY"
-    addCMakeVariable "VTK_MPIRUN_EXE=$MPI_RUN"
-    addCMakeVariable "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
+   [ "$WITH_MPI" = ON ] || return
+   OBJ_ADD="$OBJ_ADD-mpi"
+
+   addCMakeVariable  PARAVIEW_USE_MPI=ON
+   addCMakeVariable  VTK_USE_MPI=ON
+   addCMakeVariable  MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include
+   addCMakeVariable  MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so
+   addCMakeVariable  VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun
+   addCMakeVariable  VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS
 }
 
 
-addPythonSupport ()
+addPythonSupport()
 {
-    [ "$INCLUDE_PYTHON" = ON ] || return
-
-    WHICH_PYTHON=`which python`
-    if [ -n "$WHICH_PYTHON" ]; then
-        OBJ_ADD="$OBJ_ADD-py"
-
-        if [ -n "$PYTHON_LIBRARY" ]; then
-            # check $PYTHON_LIBRARY if it has been set
-            if [ ! -e "$PYTHON_LIBRARY" ]; then
-                echo "*** Error: libpython not found at location specified " \
-                     "by PYTHON_LIBRARY: $PYTHON_LIBRARY"
-                echo "    Please set the variable PYTHON_LIBRARY to the full"
-                echo "    path to (and including) libpython, or deactivate"
-                echo "    python support by setting INCLUDE_PYTHON=OFF"
-                exit 1
-            fi
-        else
-            # Try to obtain $PYTHON_LIBRARY if not set
-            # - assumes dynamically linked
-            PYTHON_LIBRARY=`ldd $WHICH_PYTHON | \
-                sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p'`
-        fi
-
-        if [ ! -n "$PYTHON_LIBRARY" ]; then
+   [ "$WITH_PYTHON" = ON ] || return
+   OBJ_ADD="$OBJ_ADD-py"
+
+   if pythonBin=$(which python 2>/dev/null)
+   then
+      if [ -n "$PYTHON_LIBRARY" ]
+      then
+         # check $PYTHON_LIBRARY if it has been set
+         if [ ! -e "$PYTHON_LIBRARY" ]
+         then
+            echo "*** Error: libpython not found at location specified " \
+                 "by PYTHON_LIBRARY=$PYTHON_LIBRARY"
+         fi
+      else
+         # Try to get $PYTHON_LIBRARY from dynamically linked binary
+         PYTHON_LIBRARY=$(ldd $pythonBin | \
+            sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p')
+
+         if [ ! -e "$PYTHON_LIBRARY" ]
+         then
             echo "*** Error: Unable to determine path to python library."
-            echo "    Please set the variable PYTHON_LIBRARY to the full"
-            echo "    path to (and including) libpython, or deactivate"
-            echo "    python support by setting INCLUDE_PYTHON=OFF"
-            exit 1
-        fi
-        PYTHON_MAJOR_VERSION=`echo $PYTHON_LIBRARY | \
-            sed 's/.*libpython\(.*\)\.so.*/\1/'`
-        PYTHON_INCLUDE_DIR=/usr/include/python$PYTHON_MAJOR_VERSION
-
-        addCMakeVariable "PARAVIEW_ENABLE_PYTHON=ON"
-        addCMakeVariable "PYTHON_INCLUDE_PATH=$PYTHON_INCLUDE_DIR"
-        addCMakeVariable "PYTHON_LIBRARY=$PYTHON_LIBRARY"
-    else
-        echo "*** Error: python not installed"
-        echo "***        De-activate python support by setting " \
-             "INCLUDE_PYTHON=OFF"
-        exit 1
-    fi
+         fi
+      fi
+
+      [ -e "$PYTHON_LIBRARY" ] || {
+         echo "    Please set the variable PYTHON_LIBRARY to the full"
+         echo "    path to (and including) libpython, or deactivate"
+         echo "    python support by setting WITH_PYTHON=OFF"
+         exit 1
+      }
+
+      pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
+      pythonInclude=/usr/include/python$pythonMajor
+
+      [ -e "$PYTHON_LIBRARY" ] || {
+         echo "    Please set the variable PYTHON_LIBRARY to the full"
+         echo "    path to (and including) libpython, or deactivate"
+         echo "    python support by setting WITH_PYTHON=OFF"
+         exit 1
+      }
+
+      # note - we could also allow for a PYTHON_INCLUDE variable ...
+      [ -e "$pythonInclude" ] || {
+         echo "    No python include headers found"
+         echo "    Please install python headers or deactivate "
+         echo "    python support by setting WITH_PYTHON=OFF"
+         exit 1
+      }
+
+      addCMakeVariable  PARAVIEW_ENABLE_PYTHON=ON
+      addCMakeVariable  PYTHON_INCLUDE_PATH=$pythonInclude
+      addCMakeVariable  PYTHON_LIBRARY=$PYTHON_LIBRARY
+
+      echo "----"
+      echo "Python information:"
+      echo "    executable     : $pythonBin"
+      echo "    version        : $pythonMajor"
+      echo "    include path   : $pythonInclude"
+      echo "    library        : $PYTHON_LIBRARY"
+
+      unset pythonBin pythonInclude pythonMajor
+   else
+      echo "*** Error: python not installed"
+      echo "***        Deactivate python support by setting WITH_PYTHON=OFF"
+      exit 1
+   fi
+}
+
+
+addMesaSupport()
+{
+   [ "$WITH_MESA" = ON ] || return
+
+   MESA_INCLUDE_DIR=/usr/include/GL
+   MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so
+
+   if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ]
+   then
+      OBJ_ADD="$OBJ_ADD-mesa"
+
+      addCMakeVariable  VTK_OPENGL_HAS_OSMESA=ON
+      addCMakeVariable  OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR
+      addCMakeVariable  OSMESA_LIBRARY=$MESA_LIBRARY
+
+   else
+      echo "*** Error: no MESA information found"
+      exit 1
+   fi
 }
 
 
-addMesaSupport ()
+buildParaView()
 {
-    [ "$INCLUDE_MESA" = ON ] || return
-
-    MESA_INCLUDE_DIR=/usr/include/GL
-    MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so
-
-    if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ]; then
-        OBJ_ADD="$OBJ_ADD-mesa"
-        addCMakeVariable "VTK_OPENGL_HAS_OSMESA=ON"
-        addCMakeVariable "OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR"
-        addCMakeVariable "OSMESA_LIBRARY=$MESA_LIBRARY"
-    else
-        echo "*** Error: no MESA information found"
-        exit 1
-    fi
+   # set paraview environment
+   for i in $PWD $WM_THIRD_PARTY_DIR
+   do
+      ParaView_INST_DIR=$i/$PARAVIEW_SRC
+      [ -d $ParaView_INST_DIR ] && break
+   done
+
+   if [ ! -d "$ParaView_INST_DIR" ]
+   then
+      # last chance: maybe already in the paraview directory
+      [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD
+
+      [ -d "$ParaView_INST_DIR" ] || {
+         echo "did not find $PARAVIEW_SRC in these directories:"
+         echo "  PWD=$PWD"
+         echo "  WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
+         echo "abort build"
+         exit 1
+      }
+   fi
+
+
+   # ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD
+   ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER
+
+   # shortcut for repeated builds - use with caution
+   if [ "$CMAKE_SKIP" = YES ]
+   then
+
+      # change to build/install folder
+      cd $ParaView_DIR || exit 1
+
+   else
+
+      # remove any existing build folder and recreate
+      rm -rf $ParaView_DIR
+      mkdir -p $ParaView_DIR
+      cd $ParaView_DIR
+
+      echo "----"
+      echo "Building $PARAVIEW_SRC"
+      echo "    MPI support    : $WITH_MPI"
+      echo "    Python support : $WITH_PYTHON"
+      echo "    MESA support   : $WITH_MESA"
+      echo "    Source         : $ParaView_INST_DIR"
+      echo "    Target         : $ParaView_DIR"
+      echo "----"
+
+      # make paraview
+      cmake \
+         -DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR \
+         $CMAKE_VARIABLES \
+         $ParaView_INST_DIR
+   fi
+
+   # change to build folder
+   echo "    Starting make"
+
+   if [ -r /proc/cpuinfo ]
+   then
+      WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
+
+      if [ $WM_NCOMPPROCS -gt 8 ]
+      then
+         WM_NCOMPPROCS=8
+      fi
+
+      make -j $WM_NCOMPPROCS
+   else
+      make
+   fi
 }
 
 
-buildParaView ()
+# adjust hard-links
+# Note: use loop with grep to avoid touching too many files
+fixCMakeHardLinks()
 {
-    # set general options
-    addCMakeVariable "BUILD_SHARED_LIBS:BOOL=ON"
-    addCMakeVariable "VTK_USE_RPATH:BOOL=OFF"
-    addCMakeVariable "CMAKE_BUILD_TYPE:STRING=Release"
-
-    # set paraview environment
-    unset PARAVIEW_SRC_DIR
-    for i in $PWD $WM_THIRD_PARTY_DIR
-    do
-       if [ -d $i/$PARAVIEW_SRC ]
-       then
-          PARAVIEW_SRC_DIR=$i/$PARAVIEW_SRC
-          break
-       fi
-    done
-
-    [ -d "$PARAVIEW_SRC_DIR" ] || {
-       echo "did not find $PARAVIEW_SRC in these directories:"
-       echo "  PWD=$PWD"
-       echo "  WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
-       echo "abort build"
-       exit 1
-    }
-
-    # PARAVIEW_OBJ_DIR=$PARAVIEW_SRC_DIR/platforms/$WM_OPTIONS/obj$OBJ_ADD
-    PARAVIEW_OBJ_DIR=$PARAVIEW_SRC_DIR/platforms/$WM_ARCH$WM_COMPILER
-
-    # provide a shortcut for repeated builds - use with caution
-    if [ "$CMAKE_SKIP" = YES ]
-    then
-
-       # change to build folder
-       cd $PARAVIEW_OBJ_DIR || exit 1
-
-    else
-
-       # remove existing build folder if present
-       if [ -e "$PARAVIEW_OBJ_DIR" ]; then
-           rm -rf $PARAVIEW_OBJ_DIR
-       fi
-
-       # create paraview build folder
-       mkdir -p $PARAVIEW_OBJ_DIR
-       cd $PARAVIEW_OBJ_DIR
-
-       echo "Building $PARAVIEW_SRC"
-       echo "    MPI support    : $INCLUDE_MPI"
-       echo "    Python support : $INCLUDE_PYTHON"
-       echo "    MESA support   : $INCLUDE_MESA"
-       echo "    Source         : $PARAVIEW_SRC_DIR"
-       echo "    Target         : $PARAVIEW_OBJ_DIR"
-
-       # make paraview
-       cmake \
-           -DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR \
-           $CMAKE_VARIABLES \
-           $PARAVIEW_SRC_DIR
-    fi
-
-    if [ -r /proc/cpuinfo ]; then
-        WM_NCOMPPROCS=`egrep "^processor" /proc/cpuinfo | wc -l`
-
-        if [ $WM_NCOMPPROCS -gt 8 ]; then
-            WM_NCOMPPROCS=8
-        fi
-
-        make -j $WM_NCOMPPROCS
-    else
-        make
-    fi
+   fileSpec=$1
+   string=$2
+   envName=$3
+
+   echo -n "    for \$$envName "
+   for i in $(find . -type f -iname "$fileSpec")
+   do
+      if grep -q "$string" $i
+      then
+         echo -n "#"
+         sed -i "s,$string,\$ENV{$envName},g" $i
+      fi
+   done
+   echo
 }
 
 
-installParaView ()
+installParaView()
 {
-    if [ -e "$PARAVIEW_OBJ_DIR/bin/paraview" ]; then
-        echo "    Build complete"
-
-        cd $PARAVIEW_OBJ_DIR
-
-        # Replace PARAVIEW_SRC_DIR path with ParaView_INST_DIR
-        # environment variables
-        echo "    Replacing path hard links"
-        find . -iname \*.cmake -execdir sed -i \
-            "s,$PARAVIEW_SRC_DIR,\$ENV{ParaView_INST_DIR},g" {} ';' \
-            -print
-
-        # Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH
-        # environment variables
-        if [ "$INCLUDE_MPI" = ON ]; then
-            find . -iname \*.cmake -execdir sed -i \
-                "s,$MPI_ARCH_PATH,\$ENV{MPI_ARCH_PATH},g" {} ';' \
-                -print
-        fi
-
-        # Replace local CMAKE_HOME path with CMAKE_HOME
-        # environment variables
-        find . -iname '*cmake*' -execdir sed -i \
-            "s,$CMAKE_HOME,\$ENV{CMAKE_HOME},g" {} ';' \
-            -print
-
-        # Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR
-        # environment variables
-        find . -iname '*cmake*' -execdir sed -i \
-            "s,$WM_COMPILER_DIR,\$ENV{WM_COMPILER_DIR},g" {} ';' \
-            -print
-
-        # create a softlink to the $PARAVIEW_OBJ_DIR/bin folder
-        # - workaround for chosen install location
-        echo "    Creating paraview $PARAVIEW_MAJOR_VERSION soft link to /bin"
-        (  mkdir lib && cd lib && ln -s ../bin \
-            paraview-$PARAVIEW_MAJOR_VERSION  )
-
-        # info on symlinks to screen
-        echo ""
-        echo "    ---"
-        echo "    Installation complete"
-        echo "    Set environment variables:"
-        echo "    - ParaView_INST_DIR to $PARAVIEW_SRC_DIR"
-        echo "    - ParaView_DIR to $PARAVIEW_OBJ_DIR"
-        echo "    - PV_PLUGIN_PATH to $FOAM_LIBBIN"
-        echo "    Add $PARAVIEW_OBJ_DIR/bin to PATH"
-        # echo "   Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH"
-        echo "    ---"
-    fi
+   if [ ! -e "$ParaView_DIR/bin/paraview" ]
+   then
+      echo "    Cannot install - no paraview binary found"
+      return
+   fi
+   echo "    Build complete"
+
+   cd $ParaView_DIR
+
+   echo "    Replacing path hard links"
+
+   # Replace local ParaView_INST_DIR path with ParaView_INST_DIR
+   # environment variable
+   fixCMakeHardLinks '*.cmake' "$ParaView_INST_DIR" ParaView_INST_DIR
+
+   # Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH
+   # environment variable
+   if [ "$WITH_MPI" = ON ]
+   then
+      fixCMakeHardLinks '*.cmake' "$MPI_ARCH_PATH" MPI_ARCH_PATH
+   fi
+
+   # Replace local CMAKE_HOME path with CMAKE_HOME
+   # environment variable
+   if [ -r "$CMAKE_HOME" ]
+   then
+      fixCMakeHardLinks '*cmake*' "$CMAKE_HOME" CMAKE_HOME
+   fi
+
+   # Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR
+   # environment variable
+   fixCMakeHardLinks '*cmake*' "$WM_COMPILER_DIR" WM_COMPILER_DIR
+
+   # create a softlink to the $ParaView_DIR/bin folder
+   # - workaround for chosen install location
+   echo "    Creating lib/paraview-$PARAVIEW_MAJOR_VERSION soft link to 'bin'"
+   rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION
+   [ -d lib ] || mkdir lib
+   ( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION )
+
+   # info on symlinks to screen
+   echo ""
+   echo "    ---"
+   echo "    Installation complete"
+   echo "    Set environment variables:"
+   echo "    - ParaView_INST_DIR to $ParaView_INST_DIR"
+   echo "    - ParaView_DIR to $ParaView_DIR"
+   echo "    - PV_PLUGIN_PATH to $FOAM_LIBBIN"
+   echo "    Add $ParaView_DIR/bin to PATH"
+   # echo "   Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH"
+   echo "    ---"
 }
 
 
-# for good measure - clear a few variables before using any of the functions
+# clear all the variables used before using any of the functions
 
-unset VERBOSE INCLUDE_MPI INCLUDE_PYTHON INCLUDE_MESA PYTHON_LIBRARY
-unset CMAKE_VARIABLES OBJ_ADD
+unset VERBOSE
+unset WITH_MPI
+unset WITH_MESA
+unset WITH_PYTHON
+unset PYTHON_LIBRARY
+unset CMAKE_VARIABLES
 unset CMAKE_SKIP
+unset OBJ_ADD
 
+# start with these general settings
+addCMakeVariable  VTK_USE_TK=FALSE
+addCMakeVariable  BUILD_SHARED_LIBS:BOOL=ON
+addCMakeVariable  VTK_USE_RPATH:BOOL=OFF
+addCMakeVariable  CMAKE_BUILD_TYPE:STRING=Release
 
 # ----------------------------------------------------------------- end-of-file
-- 
GitLab