From 705556c3ebe70a8bd5e6ff784ecaee5066e19826 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 19 Jan 2017 10:37:41 +0100
Subject: [PATCH 01/27] ENH: support building of paraview with Qt5

- this is the upcoming default Qt version
---
 BUILD.md                      |   2 +-
 etc/tools/ParaViewFunctions   | 172 ++++++++++++++++++++--------------
 etc/tools/ThirdPartyFunctions |  44 ++++-----
 etc/tools/vtkFunctions        |  43 ++++-----
 makeParaView                  |  47 +++-------
 makeVTK                       |  22 ++---
 6 files changed, 164 insertions(+), 166 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index f650940..539da48 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -424,7 +424,7 @@ The minimum gcc/g++ requirements for building various components.
 [page Qt]: https://www.qt.io/download-open-source/
 [repo Qt]: http://code.qt.io/cgit/qt-creator/qt-creator.git
 [link Qt]: http://download.qt.io/official_releases/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz
-[newer Qt5]: http://download.qt.io/official_releases/qt/5.7/5.7.0/single/qt-everywhere-opensource-src-5.7.0.tar.gz
+[newer Qt5]: http://download.qt.io/official_releases/qt/5.7/5.7.1/single/qt-everywhere-opensource-src-5.7.0.tar.xz
 
 
 <!-- Standard Footer -->
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 2d428b4..f4d3bde 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -3,7 +3,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -29,7 +29,20 @@
 #
 #------------------------------------------------------------------------------
 
-# sourceBASE, buildBASE, installBASE defined in tools/ThirdPartyFunctions
+# Variables referenced by the functions. Initialization at the end of the file.
+unset CMAKE_VARIABLES
+unset withVERBOSE
+unset withMPI     MPI_MAX_PROCS
+unset withQT      QT_VERSION      QMAKE_PATH
+unset withMESA    MESA_INCLUDE    MESA_LIBRARY    withOSMESA
+unset withPYTHON  PYTHON_INCLUDE  PYTHON_LIBRARY
+unset OBJ_ADD
+
+BUILD_TYPE=Release  # The cmake build type
+
+# sourceBASE, buildBASE, installBASE
+#   are defined in tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
 
 #
 # Where things are or should be put
@@ -74,7 +87,7 @@ setParaViewDirs()
     echo "ParaView_BINARY_DIR=$ParaView_BINARY_DIR"
     echo "ParaView_DIR=$ParaView_DIR"
 
-    # Forcefully override the .git path for the ParaView source code directory
+    # Prevent git queries from using the ThirdParty repository
     export GIT_DIR=$ParaView_SOURCE_DIR/.git
 }
 
@@ -123,6 +136,7 @@ checkVersion()
     fi
 }
 
+
 #
 # Set CMake cache variables
 #
@@ -143,7 +157,7 @@ addVerbosity()
 {
     if [ "${withVERBOSE:=false}" = true ]
     then
-        addCMakeVariable  "CMAKE_VERBOSE_MAKEFILE=TRUE"
+        addCMakeVariable "CMAKE_VERBOSE_MAKEFILE=TRUE"
     fi
 }
 
@@ -160,10 +174,10 @@ addMpiSupport()
 
     OBJ_ADD="$OBJ_ADD-mpi"
 
-    addCMakeVariable  "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON"
+    addCMakeVariable "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON"
     if [ "${MPI_MAX_PROCS:=0}" -gt 1 ]
     then
-        addCMakeVariable  "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
+        addCMakeVariable "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
     fi
 }
 
@@ -219,9 +233,9 @@ addPythonSupport()
             exit 1
         }
 
-        addCMakeVariable  "PARAVIEW_ENABLE_PYTHON=ON"
-        addCMakeVariable  "PYTHON_INCLUDE_DIRS=$pythonInclude"
-        addCMakeVariable  "PYTHON_LIBRARY=$PYTHON_LIBRARY"
+        addCMakeVariable "PARAVIEW_ENABLE_PYTHON=ON"
+        addCMakeVariable "PYTHON_INCLUDE_DIRS=$pythonInclude"
+        addCMakeVariable "PYTHON_LIBRARY=$PYTHON_LIBRARY"
 
         echo "----"
         echo "Python information:"
@@ -254,17 +268,17 @@ addMesaSupport()
     then
         OBJ_ADD="$OBJ_ADD-mesa"
 
-        addCMakeVariable  "VTK_OPENGL_HAS_OSMESA:BOOL=ON"
-        addCMakeVariable  "OSMESA_INCLUDE_DIR=$MESA_INCLUDE"
-        addCMakeVariable  "OSMESA_LIBRARY=$MESA_LIBRARY"
+        addCMakeVariable "VTK_OPENGL_HAS_OSMESA:BOOL=ON"
+        addCMakeVariable "OSMESA_INCLUDE_DIR=$MESA_INCLUDE"
+        addCMakeVariable "OSMESA_LIBRARY=$MESA_LIBRARY"
 
     else
-       echo "*** Error: no MESA information found"
-       echo "***        Deactivate MESA support by not using the -mesa option, "
-       echo "***        or set the correct paths for:"
-       echo "***        -mesa-include ($MESA_INCLUDE)"
-       echo "***        -mesa-lib ($MESA_LIBRARY)"
-       exit 1
+        echo "*** Error: no MESA information found"
+        echo "***   Deactivate MESA support by not using the -mesa option, "
+        echo "***   or set the correct paths for:"
+        echo "***       -mesa-include ($MESA_INCLUDE)"
+        echo "***       -mesa-lib ($MESA_LIBRARY)"
+        exit 1
     fi
 }
 
@@ -276,45 +290,42 @@ addGL2Support()
 {
     if [ "${withGL2:=false}" = true ]
     then
-        addCMakeVariable  "VTK_RENDERING_BACKEND=OpenGL2"
+        addCMakeVariable "VTK_RENDERING_BACKEND=OpenGL2"
     fi
 }
 
 
+#
+# Qt 4/5 support
+#
 addQtSupport()
 {
-    QtVersion=none
+    QT_VERSION=none
+    : ${withQT:=true}  # default is on
 
-    if [ "${withQT:=false}" != true ]
+    if [ "$withQT" = false ]
     then
+        # Explicitly disabled
+        addCMakeVariable "PARAVIEW_BUILD_QT_GUI=OFF"
         return
     fi
 
-    addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"
+    local qmake qtLib
 
-    local qmake=$(findQtMake)
-
-    # From somewhere other than in the path
-    if [ "${qmake:=qmake}" != qmake ]
+    # Check qmake can be found and handle version differences
+    qmake=$(findQtMake)
+    if QT_VERSION=$($qmake -query QT_VERSION 2>/dev/null)
     then
-        addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmake"
-    fi
+        addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"
 
-    # Check qmake can be found
-    if type $qmake >/dev/null 2>&1
-    then
-        # Check the Qt version selected
-        # parse -> "Using Qt version X.Y.Z in ..."
-        QtVersion=$($qmake -query QT_VERSION)
-
-        case "$QtVersion" in
-        3.* | 4.[0-4]*)
+        case "$QT_VERSION" in
+        (3.* | 4.[0-4]*)
             # QT is too old
             cat <<ERROR
 ----
 Error: ${0##*/}
 
-QT version ($QtVersion) provided < 4.5
+QT version ($QT_VERSION) provided < 4.5
 Please use the -qmake option to specify the location of a newer QT version
 For example,
     ... -qmake /usr/local/qt-4.6.2/bin/qmake
@@ -324,12 +335,32 @@ ERROR
             exit 1
             ;;
 
-        5.*)
-            # QT4 is the default, must specify QT5 explicitly
-            addCMakeVariable "PARAVIEW_QT_VERSION:STRING=5"
+        (4.*)
+            # Default changed to Qt5 with paraview 5.2.1, so specify explicitly
+            addCMakeVariable "PARAVIEW_QT_VERSION=4"
+
+            # Non-system installation - specify location of qmake
+            if [ "$qmake" != /usr/bin/qmake ]
+            then
+                addCMakeVariable "QT_QMAKE_EXECUTABLE=$qmake"
+            fi
+            ;;
+
+        (5.*)
+            # Default changed to Qt5 with paraview 5.2.1, so specify explicitly
+            addCMakeVariable "PARAVIEW_QT_VERSION=5"
+
+            # Non-system installation - find CMake config files
+            if [ "$qmake" != /usr/bin/qmake ] \
+               && qtLib="$($qmake -query QT_INSTALL_LIBS)/cmake/Qt5" \
+               && [ -d "$qtLib" ]
+            then
+                addCMakeVariable "Qt5_DIR=$qtLib"
+            fi
             ;;
         esac
     else
+        QT_VERSION=none
         echo "Error: cannot find qmake either at \$QMAKE_PATH or in current \$PATH"
         echo
         exit 1
@@ -362,7 +393,7 @@ configParaView()
     fi
     mkdir -p $ParaView_BINARY_DIR
 
-    addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=$buildType"
+    addCMakeVariable "CMAKE_BUILD_TYPE=$BUILD_TYPE"
 
     cd $ParaView_BINARY_DIR || exit 1  # Change to build folder
 
@@ -372,16 +403,15 @@ configParaView()
     echo "    Python support : ${withPYTHON:-false}"
     echo "    MESA   support : ${withMESA:-false}"
     echo "    GL2  rendering : ${withGL2:-false}"
-    echo "    Qt dev support : ${withQT:-false}"
+    echo "    QT dev support : ${withQT:-true}"
     echo "    Source         : $ParaView_SOURCE_DIR"
     echo "    Build          : $ParaView_BINARY_DIR"
     echo "    Target         : $ParaView_DIR"
-    echo "    Build type     : $buildType"
-    echo "    Cmake          : $cmake"
+    echo "    cmake          : $cmake"
     echo "----"
     echo
     echo "$cmake" \
-        -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
+        -DCMAKE_INSTALL_PREFIX=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
     echo
@@ -390,7 +420,7 @@ configParaView()
 
     # Run cmake to create Makefiles
     $cmake \
-        -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
+        -DCMAKE_INSTALL_PREFIX=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
 }
@@ -426,38 +456,44 @@ installParaView()
 
     make install
 
-cat<< INFO
+    # System or non-system installation of QT?
+    local qmake qtLib QT_VERSION
+    if qmake=$(findQtMake 2>/dev/null)
+    then
+        qtLib=$($qmake -query QT_INSTALL_LIBS)
+        QT_VERSION=$($qmake -query QT_VERSION 2>/dev/null)
+    fi
 
-    ---
-    Installation complete for paraview-$ParaView_VERSION
+    /bin/cat<<INFO
+
+====
+Installation complete for paraview-$ParaView_VERSION with qt-${QT_VERSION:-none}
     ParaView_DIR=$ParaView_DIR
 
-    You may need to update the OpenFOAM environment by running:
-        wmRefresh
-    ---
+You may need to update the OpenFOAM environment by running:
+    wmRefresh
+INFO
+
+    # Non-system installation of QT?
+    if [ "$qmake" != /usr/bin/qmake -a -d "$qtLib" ]
+    then
+        cat<< INFO
+
+And adjust your LD_LIBRARY_PATH to include the following:
+    $qtLib
 INFO
+    fi
+
+    echo "===="
 }
 
 
 #------------------------------------------------------------------------------
 
-# Clear the referenced variables before using any of the functions
-unset withMPI  withVERBOSE
-unset withQT      QMAKE_PATH
-unset withMESA    MESA_INCLUDE    MESA_LIBRARY
-unset withPYTHON  PYTHON_INCLUDE  PYTHON_LIBRARY
-unset CMAKE_VARIABLES
-unset OBJ_ADD
-unset buildType
-
 # Start with these general settings
-addCMakeVariable  "BUILD_SHARED_LIBS:BOOL=ON  VTK_USE_RPATH:BOOL=OFF"
+addCMakeVariable "BUILD_SHARED_LIBS=ON" "BUILD_TESTING=OFF"
 
 # Include development files in "make install"
-addCMakeVariable  "PARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON"
-
-# Don't build test tree
-addCMakeVariable  "BUILD_TESTING:BOOL=OFF"
-
+addCMakeVariable "PARAVIEW_INSTALL_DEVELOPMENT_FILES=ON"
 
 #------------------------------------------------------------------------------
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index e2fd201..9efa322 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -86,18 +86,19 @@ _foamIsSystem()
 
 
 #
-# try to locate cmake according to the CMAKE_PATH
-# or just use what is found in the path
+# Try to locate cmake according to the CMAKE_PATH.
+#
+# On success: return the resolved value as output.
+# On failure: just report what is found in the path.
 #
 unset CMAKE_PATH # clear when first loaded
 findCMake()
 {
-    local candidate
-    local foundExe
+    local candidate foundExe
 
     if [ -n "$CMAKE_PATH" ]
     then
-        # check as directory
+        # Check as directory
         if [ -d "$CMAKE_PATH" ]
         then
             for candidate in \
@@ -113,7 +114,7 @@ findCMake()
             done
         fi
 
-        # check as file, include ThirdParty installation in the search
+        # Check as file, include ThirdParty installation in the search
         if [ -z "$foundExe" ]
         then
             for candidate in \
@@ -137,9 +138,8 @@ findCMake()
             then
                 foundExe="$(cd ${foundExe%/cmake} 2>/dev/null && pwd)/cmake"
             fi
-
             echo "Using cmake=$foundExe" 1>&2
-            echo "$foundExe"
+            echo $foundExe
             return 0
         else
             cat << NOT_FOUND 1>&2
@@ -150,26 +150,27 @@ NOT_FOUND
         fi
     fi
 
-    # Default to use the path, try resolving (so we know what we are using)
-    foundExe=$(command -v cmake 2> /dev/null) || foundExe=cmake
-    echo "Using cmake=${foundExe:-NotFound}"  1>&2
-    echo "${foundExe:-cmake}"
+    # Default to use the path. Resolve so we know what we are using.
+    foundExe=$(command -v cmake 2> /dev/null) || foundExe=false
+    echo "Using cmake=$foundExe" 1>&2
+    echo $foundExe
 }
 
 
 #
 # try to locate qmake according to the QMAKE_PATH
-# or just use what is found in the path
+#
+# On success: return the resolved value as output.
+# On failure: just report what is found in the path.
 #
 unset QMAKE_PATH # clear when first loaded
 findQtMake()
 {
-    local candidate
-    local foundExe
+    local candidate foundExe
 
     if [ -n "$QMAKE_PATH" ]
     then
-        # check as directory
+        # Check as directory
         if [ -d "$QMAKE_PATH" ]
         then
             for candidate in \
@@ -185,7 +186,7 @@ findQtMake()
             done
         fi
 
-        # check as file, include ThirdParty installation in the search
+        # Check as file, include ThirdParty installation in the search
         if [ -z "$foundExe" ]
         then
             for candidate in \
@@ -209,9 +210,8 @@ findQtMake()
             then
                 foundExe="$(cd ${foundExe%/qmake} 2>/dev/null && pwd)/qmake"
             fi
-
             echo "Using qmake=$foundExe" 1>&2
-            echo "$foundExe"
+            echo $foundExe
             return 0
         else
             cat << NOT_FOUND 1>&2
@@ -223,9 +223,9 @@ NOT_FOUND
     fi
 
     # Default to use the path, try resolving (so we know what we are using)
-    foundExe=$(command -v qmake 2> /dev/null) || foundExe=qmake
-    echo "Using qmake=${foundExe:-NotFound}"  1>&2
-    echo "${foundExe:-qmake}"
+    foundExe=$(command -v qmake 2> /dev/null) || foundExe=false
+    echo "Using qmake=$foundExe" 1>&2
+    echo $foundExe
 }
 
 
diff --git a/etc/tools/vtkFunctions b/etc/tools/vtkFunctions
index 3d2a4cb..d5eefee 100644
--- a/etc/tools/vtkFunctions
+++ b/etc/tools/vtkFunctions
@@ -2,7 +2,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+#   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -30,8 +30,13 @@
 #
 #------------------------------------------------------------------------------
 
+# Variables referenced by the functions. Initialization at the end of the file.
+unset CMAKE_VARIABLES
+
 # sourceBASE, buildBASE, installBASE defined in tools/ThirdPartyFunctions
 
+#------------------------------------------------------------------------------
+
 #
 # Where things are or should be put
 #   VTK_VERSION and VTK_MAJOR should already have been set
@@ -75,8 +80,8 @@ setVtkDirs()
     echo "VTK_BINARY_DIR=$VTK_BINARY_DIR"
     echo "VTK_DIR=$VTK_DIR"
 
-    # Forcefully override the .git path for the VTK source code directory
-    export GIT_DIR=$ParaView_SOURCE_DIR/.git
+    # Prevent git queries from using the ThirdParty repository
+    export GIT_DIR=$VTK_SOURCE_DIR/.git
 }
 
 
@@ -129,7 +134,7 @@ configVTK()
     fi
     mkdir -p $VTK_BINARY_DIR
 
-    addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=$buildType"
+    addCMakeVariable "CMAKE_BUILD_TYPE=$BUILD_TYPE"
 
     cd $VTK_BINARY_DIR || exit 1  # change to build folder
 
@@ -139,12 +144,11 @@ configVTK()
     echo "    Source         : $VTK_SOURCE_DIR"
     echo "    Build          : $VTK_BINARY_DIR"
     echo "    Target         : $VTK_DIR"
-    echo "    Build type     : $buildType"
-    echo "    Cmake          : $cmake"
+    echo "    cmake          : $cmake"
     echo "----"
     echo
     echo "$cmake" \
-        -DCMAKE_INSTALL_PREFIX:PATH=$VTK_DIR \
+        -DCMAKE_INSTALL_PREFIX=$VTK_DIR \
         $CMAKE_VARIABLES \
         $VTK_SOURCE_DIR
     echo
@@ -153,7 +157,7 @@ configVTK()
 
     # Run cmake to create Makefiles
     $cmake \
-        -DCMAKE_INSTALL_PREFIX:PATH=$VTK_DIR \
+        -DCMAKE_INSTALL_PREFIX=$VTK_DIR \
         $CMAKE_VARIABLES \
         $VTK_SOURCE_DIR
 }
@@ -165,17 +169,14 @@ configVTK()
 #
 makeVTK()
 {
-    cd $VTK_BINARY_DIR || exit 1  # change to build folder
+    cd $VTK_BINARY_DIR || exit 1  # Change to build folder
     echo "    Starting make"
     time make -j $WM_NCOMPPROCS
     echo "    Done make"
 
     # Remove lib if it is a link
     # (how this was previously handled before 'make install' worked)
-    if [ -L lib ]
-    then
-        rm lib 2>/dev/null
-    fi
+    [ -L lib ] && rm -f lib 2>/dev/null
 }
 
 
@@ -189,26 +190,20 @@ installVTK()
 
     make install
 
-cat<< INFO
+    /bin/cat<<INFO
 
-    ---
-    Installation complete for vtk-$VTK_VERSION
+====
+Installation complete for vtk-$VTK_VERSION as
     VTK_DIR=$VTK_DIR
-    ---
+====
 INFO
 }
 
 
 #------------------------------------------------------------------------------
 
-# Clear the referenced variables before using any of the functions
-unset CMAKE_VARIABLES
-
 # Start with these general settings
-addCMakeVariable  "BUILD_SHARED_LIBS:BOOL=ON  VTK_USE_RPATH:BOOL=OFF"
-
-# Don't build test tree
-addCMakeVariable  "BUILD_TESTING:BOOL=OFF"
+addCMakeVariable "BUILD_SHARED_LIBS=ON" "BUILD_TESTING=OFF"
 
 
 #------------------------------------------------------------------------------
diff --git a/makeParaView b/makeParaView
index 2ca6ebf..600a46a 100755
--- a/makeParaView
+++ b/makeParaView
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -56,34 +56,20 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 . etc/tools/ParaViewFunctions
 #------------------------------------------------------------------------------
 #
-# USER OPTIONS:
-# ~~~~~~~~~~~~~
-
-# MPI support:
-# use 0 or unset MPI_MAX_PROCS for no upper-limit
-withMPI=false
-MPI_MAX_PROCS=32
-
-# Python support:
-# note: script will try to determine the appropriate python library.
-#       If it fails, specify the path using the PYTHON_LIBRARY variable
-withPYTHON=false
-PYTHON_LIBRARY=""
-# PYTHON_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libpython2.6.so.1.0"
+# USER DEFAULTS:
+# ~~~~~~~~~~~~~~
 
 # MESA graphics support:
 withMESA=false
 MESA_INCLUDE="/usr/include/GL"
 MESA_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
 
-# extra QT gui support (useful for some third party apps)
-withQT=true
-
-# Set the path to the Qt-4.5 (or later) qmake if the system Qt is older
-QMAKE_PATH=""
-
-# Set the path to cmake
-CMAKE_PATH=""
+# Python support:
+# - The script will try to determine the appropriate python library.
+#   If that fails, specify the path using the PYTHON_LIBRARY variable below.
+withPYTHON=false
+PYTHON_LIBRARY=""
+# PYTHON_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libpython2.6.so.1.0"
 
 # New rendering backend (starting with paraview 5.0).
 # Default to auto-config based on paraview version
@@ -159,14 +145,6 @@ USAGE
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
-#
-# Add options based on script name:
-#
-case "$Script" in *-mesa*)   withMESA=true;; esac
-case "$Script" in *-mpi*)    withMPI=true;; esac
-case "$Script" in *-python*) withPYTHON=true;; esac
-case "$Script" in *-qt*)     withQT=true;; esac
-
 # Set initial ParaView_MAJOR based on current value of ParaView_VERSION
 setParaViewVersion ${ParaView_VERSION:-none}
 
@@ -175,7 +153,6 @@ setParaViewVersion ${ParaView_VERSION:-none}
 #
 unset runPATCH runCONFIG runMAKE runINSTALL
 runDEFAULT=true
-buildType=Release
 
 # Parse options
 while [ "$#" -gt 0 ]
@@ -311,7 +288,7 @@ do
         ;;
     -buildType)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        buildType="$2"
+        BUILD_TYPE="$2"
         shift
         ;;
     *)
@@ -380,10 +357,10 @@ Features selected
     qt        ${withQT:-false}
 ---------------------
 Version information
-    qt        ${QtVersion:-none}
+    qt        ${QT_VERSION:-none}
     version   ${ParaView_VERSION:-unknown} $(checkVersion)
     major     ${ParaView_MAJOR:-unknown}
-    build     ${buildType:-Release}
+    build     ${BUILD_TYPE:-unknown}
 ---------------------
 SUMMARY
 
diff --git a/makeVTK b/makeVTK
index 1206ab6..92d4ffa 100755
--- a/makeVTK
+++ b/makeVTK
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+#   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -50,22 +50,14 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 . etc/tools/vtkFunctions
 #------------------------------------------------------------------------------
 #
-# USER OPTIONS:
-# ~~~~~~~~~~~~~
-
-# MPI support:
-# use 0 or unset MPI_MAX_PROCS for no upper-limit
-withMPI=false
-unset MPI_MAX_PROCS
+# USER DEFAULTS:
+# ~~~~~~~~~~~~~~
 
 # MESA graphics support:
 withMESA=false
 MESA_INCLUDE="/usr/include/GL"
 MESA_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
 
-# Set the path to cmake
-CMAKE_PATH=""
-
 # New rendering backend (starting with vtk 7?).
 # Default to auto-config based on VTK version
 withGL2=auto
@@ -85,10 +77,10 @@ options:
   -rebuild          for repeated builds (-make -install) *use with caution*
   -gl2              with new rendering backend (if not already enabled)
   -mesa             with mesa (if not already enabled)
+  -osmesa           with off-screen mesa only
   -mpi              with mpi (if not already enabled)
   -mpi=NPROCS       with mpi and max 'NPROCS' processes. NPROCS=0 for no
                         upper-limit on processes.
-  -osmesa           with off-screen mesa only
   -cmake PATH       with cmake from the path given
   -gcc              force g++ instead of the value from \$WM_CXX
   -verbose          verbose output in Makefiles
@@ -130,8 +122,6 @@ USAGE
 #
 unset runPATCH runCONFIG runMAKE runINSTALL
 runDEFAULT=true
-buildType=Release
-withOSMESA=false
 
 # Parse options
 while [ "$#" -gt 0 ]
@@ -236,7 +226,7 @@ do
         ;;
     -buildType)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        buildType="$2"
+        BUILD_TYPE="$2"
         shift
         ;;
     *)
@@ -306,7 +296,7 @@ Features selected
 ---------------------
 Version information
     version   ${VTK_VERSION:-unknown}
-    build     ${buildType:-Release}
+    build     ${BUILD_TYPE:-unknown}
 ---------------------
 SUMMARY
 
-- 
GitLab


From 45caecb85bedcd57b3fa468bff30cb0e366b3297 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 19 Jan 2017 12:58:10 +0100
Subject: [PATCH 02/27] COMP: ensure GLES(1) includes are not installed with
 mesa

---
 BUILD.md |  2 +-
 makeMesa | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index 539da48..98e09f9 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -418,7 +418,7 @@ The minimum gcc/g++ requirements for building various components.
 [newer ParaView-52]:  http://www.paraview.org/files/v5.2/ParaView-v5.2.0.tar.gz
 
 [page mesa]:  http://mesa3d.org/
-[link mesa]:  ftp://ftp.freedesktop.org/pub/mesa/13.0.1/mesa-13.0.1.tar.xz
+[link mesa]:  ftp://ftp.freedesktop.org/pub/mesa/13.0.3/mesa-13.0.3.tar.xz
 [older mesa]: ftp://ftp.freedesktop.org/pub/mesa/11.2.2/mesa-11.2.2.tar.xz
 
 [page Qt]: https://www.qt.io/download-open-source/
diff --git a/makeMesa b/makeMesa
index c1befd4..123c9df 100755
--- a/makeMesa
+++ b/makeMesa
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+#   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -142,6 +142,15 @@ fi
 MESA_SOURCE_DIR=$sourceBASE/$mesaPACKAGE
 MESA_ARCH_PATH=$installBASE/$mesaPACKAGE
 
+#
+# Manual adjustments to mesa
+# - avoid GLES (GLES1) since <GLES/gl.h> may mask the <GL/gl.h> header
+adjustMESA()
+{
+    \rm -rf $MESA_ARCH_PATH/include/GLES $MESA_ARCH_PATH/include/GLES1
+    echo "removed all gles1 includes"
+}
+
 (
     # configuration options:
     unset configOpt
@@ -185,11 +194,13 @@ MESA_ARCH_PATH=$installBASE/$mesaPACKAGE
         --disable-glx \
         --disable-dri \
         --disable-egl \
+        --disable-gles1 \
         --enable-texture-float \
         --enable-gallium-osmesa --with-gallium-drivers=swrast \
         $configOpt \
         && make -j $WM_NCOMPPROCS \
         && make install \
+        && adjustMESA \
         && echo "Built $mesaPACKAGE"
 ) || {
     echo "Error building: MESA"
-- 
GitLab


From ae464766e61b20c88a113adffe2fc261bc8c72e2 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 19 Jan 2017 15:34:48 +0100
Subject: [PATCH 03/27] COMP: patch paraview 5.0.1 for building with osmesa

- reference: https://gitlab.kitware.com/vtk/vtk/merge_requests/1642
---
 etc/patches/paraview-5.0.1 | 134 +++++++++++++++++++++++++++++++++++++
 1 file changed, 134 insertions(+)

diff --git a/etc/patches/paraview-5.0.1 b/etc/patches/paraview-5.0.1
index 4b00f66..c4126f9 100644
--- a/etc/patches/paraview-5.0.1
+++ b/etc/patches/paraview-5.0.1
@@ -85,3 +85,137 @@
 
  set (xslt_xml)
 
+--- ParaView-5.0.1/VTK/CMake/vtkOpenGL.cmake.orig	2016-03-28 17:07:10.000000000 +0200
++++ ParaView-5.0.1/VTK/CMake/vtkOpenGL.cmake	2017-01-19 10:23:19.170743269 +0100
+@@ -19,9 +19,11 @@
+ # OSMesa logic for offscreen mesa rendering.
+ option(VTK_OPENGL_HAS_OSMESA
+   "The OpenGL library being used supports off screen Mesa calls" OFF)
++
+ # EGL offscreen rendering
+ option(VTK_USE_OFFSCREEN_EGL
+   "Use EGL for OpenGL client API for offscreen rendering." OFF)
++
+ set(VTK_EGL_DEVICE_INDEX 0 CACHE STRING
+   "Index of the EGL device (graphics card) to use.")
+
+@@ -33,21 +35,26 @@
+ endif()
+
+ option(VTK_USE_OFFSCREEN "Use off screen calls by default" OFF)
++
+ unset(VTK_CAN_DO_OFFSCREEN)
++unset(VTK_CAN_DO_ONSCREEN)
++
+ if(VTK_OPENGL_HAS_OSMESA OR WIN32 OR VTK_USE_OFFSCREEN_EGL)
+   set(VTK_CAN_DO_OFFSCREEN 1)
+ endif()
++
+ if(VTK_USE_X OR VTK_USE_COCOA OR WIN32 OR ANDROID OR APPLE_IOS)
+-  set(VTK_USE_OSMESA FALSE)
++  set(VTK_USE_OSMESA ${VTK_OPENGL_HAS_OSMESA})
+   if (VTK_USE_OFFSCREEN_EGL)
+     message(FATAL_ERROR "VTK_USE_OFFSCREEN_EGL set together with one of ("
+       "VTK_USE_X, VTK_USE_COCOA, WIN32, ANDROID OR APPLE_IOS). "
+       "You cannot use both offscreen and one of the listed windowing systems.")
+   endif()
++  set(VTK_CAN_DO_ONSCREEN 1)
+ elseif(VTK_USE_OFFSCREEN_EGL)
+   set(VTK_USE_OSMESA FALSE)
+ else()
+-  set(VTK_USE_OSMESA TRUE)
++  set(VTK_USE_OSMESA ${VTK_OPENGL_HAS_OSMESA})
+ endif()
+
+ mark_as_advanced(VTK_USE_X VTK_OPENGL_HAS_OSMESA VTK_USE_OFFSCREEN_EGL
+@@ -56,10 +63,17 @@
+ if(VTK_USE_OSMESA)
+   find_package(OSMesa REQUIRED)
+   include_directories(SYSTEM ${OSMESA_INCLUDE_DIR})
+-elseif(VTK_USE_OFFSCREEN_EGL)
++endif()
++
++if(VTK_USE_OFFSCREEN_EGL)
+     find_package(EGL REQUIRED)
+     include_directories(SYSTEM ${EGL_INCLUDE_DIR})
+-else()
++endif()
++
++if(VTK_CAN_DO_ONSCREEN)
++  # OpenGL libraries are explicity needed if windowing system-based API is being
++  # used. Otherwise, if only doing OFFSCREEN, the GL API is provided by the
++  # offscreen library be it EGL or OSMESA.
+   find_package(OpenGL REQUIRED)
+   include_directories(SYSTEM ${OPENGL_INCLUDE_DIR})
+   if(APPLE)
+@@ -83,9 +97,11 @@
+ function(vtk_opengl_link target)
+   if(VTK_USE_OSMESA)
+     vtk_module_link_libraries(${target} LINK_PRIVATE ${OSMESA_LIBRARY})
+-  elseif(VTK_USE_OFFSCREEN_EGL)
++  endif()
++  if(VTK_USE_OFFSCREEN_EGL)
+     vtk_module_link_libraries(${target} LINK_PRIVATE ${EGL_LIBRARIES})
+-  else()
++  endif()
++  if(VTK_CAN_DO_ONSCREEN)
+     vtk_module_link_libraries(${target} LINK_PRIVATE ${OPENGL_LIBRARIES})
+   endif()
+ endfunction()
+--- ParaView-5.0.1/VTK/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx.orig	2016-03-28 17:07:10.000000000 +0200
++++ ParaView-5.0.1/VTK/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx	2017-01-19 15:24:21.783214877 +0100
+@@ -30,10 +30,25 @@
+ typedef ptrdiff_t GLsizeiptr;
+ #include "GL/glx.h"
+
++
++#ifndef GLAPI
++#define GLAPI extern
++#endif
++
++#ifndef GLAPIENTRY
++#define GLAPIENTRY
++#endif
++
++#ifndef APIENTRY
++#define APIENTRY GLAPIENTRY
++#endif
++
+ #include "vtkToolkits.h"
+
+ #ifdef VTK_USE_OSMESA
+ #include <GL/osmesa.h>
++
++typedef OSMesaContext GLAPIENTRY (*OSMesaCreateContextAttribs_func)( const int *attribList, OSMesaContext sharelist );
+ #endif
+
+ #include "vtkCommand.h"
+@@ -757,6 +772,28 @@
+       this->Size[1] = height;
+       this->OwnWindow = 1;
+       }
++
++#if (OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 1102) && defined(OSMESA_CONTEXT_MAJOR_VERSION)
++    static const int attribs[] = {
++       OSMESA_FORMAT, OSMESA_RGBA,
++       OSMESA_DEPTH_BITS, 32,
++       OSMESA_STENCIL_BITS, 0,
++       OSMESA_ACCUM_BITS, 0,
++       OSMESA_PROFILE, OSMESA_CORE_PROFILE,
++       OSMESA_CONTEXT_MAJOR_VERSION, 3,
++       OSMESA_CONTEXT_MINOR_VERSION, 2,
++       0 };
++
++    OSMesaCreateContextAttribs_func OSMesaCreateContextAttribs =
++       (OSMesaCreateContextAttribs_func)
++       OSMesaGetProcAddress("OSMesaCreateContextAttribs");
++
++    if (OSMesaCreateContextAttribs != NULL)
++    {
++      this->Internal->OffScreenContextId = OSMesaCreateContextAttribs(attribs, NULL);
++    }
++#endif
++    // if we still have no context fall back to the generic signature
+     if (!this->Internal->OffScreenContextId)
+       {
+       this->Internal->OffScreenContextId = OSMesaCreateContext(GL_RGBA, NULL);
-- 
GitLab


From 907e04f35c8e16f3db7081d6d2d3493371c12d73 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 19 Jan 2017 16:38:14 +0100
Subject: [PATCH 04/27] COMP: adjust makeParaView for build with mesa

---
 etc/tools/ParaViewFunctions |  5 ++---
 makeParaView                | 35 +++++++++++++++++++++++++++--------
 makeParaView.example        |  6 +++---
 makeVTK                     | 29 +++++++++++++++++++----------
 makeVTK.example             |  4 ++--
 5 files changed, 53 insertions(+), 26 deletions(-)

diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index f4d3bde..9232332 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -36,6 +36,7 @@ unset withMPI     MPI_MAX_PROCS
 unset withQT      QT_VERSION      QMAKE_PATH
 unset withMESA    MESA_INCLUDE    MESA_LIBRARY    withOSMESA
 unset withPYTHON  PYTHON_INCLUDE  PYTHON_LIBRARY
+unset withGL2
 unset OBJ_ADD
 
 BUILD_TYPE=Release  # The cmake build type
@@ -266,9 +267,7 @@ addMesaSupport()
 
     if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ]
     then
-        OBJ_ADD="$OBJ_ADD-mesa"
-
-        addCMakeVariable "VTK_OPENGL_HAS_OSMESA:BOOL=ON"
+        addCMakeVariable "VTK_OPENGL_HAS_OSMESA=ON"
         addCMakeVariable "OSMESA_INCLUDE_DIR=$MESA_INCLUDE"
         addCMakeVariable "OSMESA_LIBRARY=$MESA_LIBRARY"
 
diff --git a/makeParaView b/makeParaView
index 600a46a..91a64a6 100755
--- a/makeParaView
+++ b/makeParaView
@@ -88,31 +88,30 @@ usage() {
 
 usage: $Script [OPTION] [paraview-VERSION] [CMAKE-OPTION]
 options:
+  -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -rebuild          for repeated builds (-make -install) *use with caution*
   -gl2              with new rendering backend (if not already enabled)
   -mesa             with mesa (if not already enabled)
+  -mesa-prefix DIR  location of mesa installation (sets -mesa-include, -mesa-lib)
+  -mesa-include DIR location of mesa headers (current value: ${MESA_INCLUDE:-none})
+  -mesa-lib PATH    path to mesa library     (current value: ${MESA_LIBRARY:-none})
   -mpi              with mpi (if not already enabled)
-  -mpi=NPROCS       with mpi and max 'NPROCS' processes. NPROCS=0 for no
-                        upper-limit on processes.
+  -mpi=N            with max 'N' mpi processes. N=0 for no upper-limit.
   -python           with python (if not already enabled)
+  -python-lib PATH  path to python library   (current value: ${PYTHON_LIBRARY:-none})
   -cmake PATH       with cmake from the path given
   -qmake PATH       with the Qt version corresponding to the qmake path given
   -qt               with extra Qt gui support (if not already enabled)
   -qt-VER           with Qt version corresponding to
                         \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/qt-VER/bin/qmake
-  -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -verbose          verbose output in Makefiles
   -version VER      specify an alternative version (current value: $ParaView_VERSION)
   -major   VER      specify an alternative major version for special builds
   -buildType NAME   specify the build type (default: Release)
-  -mesa-prefix DIR  location of mesa installation (sets -mesa-include, -mesa-lib)
-  -mesa-include DIR location of mesa headers (current value: ${MESA_INCLUDE:-none})
-  -mesa-lib PATH    path to mesa library     (current value: ${MESA_LIBRARY:-none})
-  -python-lib PATH  path to python library   (current value: ${PYTHON_LIBRARY:-none})
   -help
 
 The -no-FEATURE option can be used to forcibly disable these features:
-  mesa mpi python qt
+  -no-gl2 | -no-mesa | -no-mpi | -no-python | -no-qt
 
 CMake options start with a capital letter and contain an '='.
 For example,
@@ -213,8 +212,16 @@ do
     -mesa)
         withMESA=true
         ;;
+    -osmesa)
+        echo
+        echo "The -osmesa option is currently ignored"
+        echo
+        # withMESA=true
+        # withOSMESA=true
+        ;;
     -no-mesa)
         withMESA=false
+        withOSMESA=false
         ;;
     -mesa-prefix)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
@@ -225,11 +232,13 @@ do
         ;;
     -mesa-include)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        withMESA=true
         MESA_INCLUDE="${2%%/}"
         shift
         ;;
     -mesa-lib)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        withMESA=true
         MESA_LIBRARY="${2%%/}"
         shift
         ;;
@@ -326,6 +335,16 @@ then
     : ${runINSTALL:=true}
 fi
 
+if [ "$withMESA" = true ]
+then
+    : ${withQT:=false}  # No QT unless explicitly requested
+    addCMakeVariable "VTK_USE_X=OFF"
+    # addCMakeVariable "OPENGL_INCLUDE_DIR=IGNORE"
+    # addCMakeVariable "OPENGL_gl_LIBRARY=IGNORE"
+    # addCMakeVariable "OPENGL_xmesa_INCLUDE_DIR=IGNORE"
+    ## seems to be unnecessary => addCMakeVariable "VTK_USE_OFFSCREEN=OFF"
+fi
+
 
 # Set configure options
 #~~~~~~~~~~~~~~~~~~~~~~
diff --git a/makeParaView.example b/makeParaView.example
index 5fe489e..aeb60be 100755
--- a/makeParaView.example
+++ b/makeParaView.example
@@ -1,10 +1,10 @@
 #!/bin/sh
 # An example for building particular combinations of ParaView with
 # - mpi (0 = no upper-limit on processes)
-# - off-screen mesa
+# - mesa
 
-mesa=mesa-11.2.2
-# mesa=mesa-13.0.2
+# mesa=mesa-11.2.2
+mesa=mesa-13.0.3
 
 ./makeParaView \
     -mpi=0 \
diff --git a/makeVTK b/makeVTK
index 92d4ffa..ea01f2a 100755
--- a/makeVTK
+++ b/makeVTK
@@ -74,25 +74,24 @@ usage() {
 
 usage: $Script [OPTION] [vtk-VERSION] [CMAKE-OPTION]
 options:
+  -gcc              force g++ instead of the value from \$WM_CXX
   -rebuild          for repeated builds (-make -install) *use with caution*
   -gl2              with new rendering backend (if not already enabled)
   -mesa             with mesa (if not already enabled)
+  -mesa-prefix DIR  location of mesa installation
+  -mesa-include DIR location of mesa headers (current value: ${MESA_INCLUDE:-none})
+  -mesa-lib PATH    path to mesa library     (current value: ${MESA_LIBRARY:-none})
   -osmesa           with off-screen mesa only
   -mpi              with mpi (if not already enabled)
-  -mpi=NPROCS       with mpi and max 'NPROCS' processes. NPROCS=0 for no
-                        upper-limit on processes.
+  -mpi=N            with max 'N' mpi processes. N=0 for no upper-limit.
   -cmake PATH       with cmake from the path given
-  -gcc              force g++ instead of the value from \$WM_CXX
   -verbose          verbose output in Makefiles
   -version VER      specify an alternative version (current value: $VTK_VERSION)
   -buildType NAME   specify the build type (default: Release)
-  -mesa-prefix DIR  location of mesa installation
-  -mesa-include DIR location of mesa headers (current value: ${MESA_INCLUDE:-none})
-  -mesa-lib PATH    path to mesa library     (current value: ${MESA_LIBRARY:-none})
   -help
 
 The -no-FEATURE option can be disable these features (if not already disabled):
-  mesa mpi
+  -no-gl2 | -no-mesa | -no-mpi
 
 CMake options start with a capital letter and contain an '='.
 For example,
@@ -100,6 +99,7 @@ For example,
 to add tests and avoid building documentation
 
 For finer control, the build stages can be selected or deselected individually:
+  -patch     -no-patch
   -config    -no-config
   -make      -no-make
   -install   -no-install
@@ -140,6 +140,13 @@ do
         export CC=gcc    # use gcc/g++
         export CXX=g++
         ;;
+    -patch)              # stage 0: patch sources
+        runPATCH=true
+        unset runDEFAULT
+        ;;
+    -no-patch)
+        runPATCH=false
+        ;;
     -config)             # stage 1: config only
         runCONFIG=true
         unset runDEFAULT
@@ -192,11 +199,13 @@ do
         ;;
     -mesa-include)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        withMESA=true
         MESA_INCLUDE="${2%%/}"
         shift
         ;;
     -mesa-lib)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        withMESA=true
         MESA_LIBRARY="${2%%/}"
         shift
         ;;
@@ -266,14 +275,14 @@ addMpiSupport       # set MPI-specific options
 addMesaSupport      # set MESA-specific options
 addGL2Support       # new rendering backend
 
-# set off-screen only options
+# Set off-screen options
 if [ "$withOSMESA" = true ]
 then
-    addCMakeVariable "VTK_USE_X:BOOL=OFF"
+    addCMakeVariable "VTK_USE_X=OFF"
     addCMakeVariable "OPENGL_INCLUDE_DIR=$MESA_INCLUDE"
-    addCMakeVariable "OPENGL_xmesa_INCLUDE_DIR=$MESA_INCLUDE"
     addCMakeVariable "OPENGL_gl_LIBRARY=$MESA_LIBRARY"
     addCMakeVariable "OPENGL_glu_LIBRARY=$MESA_LIBRARY"
+    addCMakeVariable "OPENGL_xmesa_INCLUDE_DIR=$MESA_INCLUDE"
 fi
 
 setVtkDirs          # where things are or should be put
diff --git a/makeVTK.example b/makeVTK.example
index a4566d1..3cd33d2 100755
--- a/makeVTK.example
+++ b/makeVTK.example
@@ -1,10 +1,10 @@
 #!/bin/sh
 # An example for building particular combinations of VTK with
-# - off-screen mesa
+# - mesa (off-screen only)
 
 vtk=VTK-7.1.0
 # mesa=mesa-11.2.2
-mesa=mesa-13.0.1
+mesa=mesa-13.0.3
 
 ./makeVTK \
     $vtk \
-- 
GitLab


From fc3ea2f1823b044cc30e2b7b8f038b43537ea00a Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 19 Jan 2017 17:16:50 +0100
Subject: [PATCH 05/27] ENH: add pkgconf editing into ThirdPartyFunctions

- allows reuse for other packages using pkgconf
---
 etc/relocateQt                |  20 ++++---
 etc/tools/QtFunctions         | 110 +++++-----------------------------
 etc/tools/ThirdPartyFunctions |  75 ++++++++++++++++++++++-
 makeParaView                  |   2 +-
 makeQt                        |   8 +--
 5 files changed, 105 insertions(+), 110 deletions(-)

diff --git a/etc/relocateQt b/etc/relocateQt
index 915ab0b..74e7f93 100755
--- a/etc/relocateQt
+++ b/etc/relocateQt
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -29,7 +29,7 @@
 #     Change prefix when relocating QT installation
 #
 #------------------------------------------------------------------------------
-qtVERSION=4.8.7
+unset qtVERSION # No default version
 
 #------------------------------------------------------------------------------
 # Run from third-party directory only
@@ -42,13 +42,12 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 . etc/tools/ThirdPartyFunctions
 . etc/tools/QtFunctions
 #------------------------------------------------------------------------------
-
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: ${0##*/} [OPTION] [VERSION]
+usage: ${0##*/} [OPTION] [qt-VERSION]
 options:
   -force            Create qt.conf and edit pkgconfig to use \${prefix}
   -help
@@ -62,9 +61,9 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-
 unset forceOpt
-# parse options
+
+# Parse options
 while [ "$#" -gt 0 ]
 do
     case "$1" in
@@ -89,11 +88,14 @@ done
 #------------------------------------------------------------------------------
 QT_ARCH_PATH=$installBASE/qt-$qtVERSION
 
+[ -n "$qtVERSION" ]    || die "No QT version specified"
+[ -d "$QT_ARCH_PATH" ] || die "No QT installation"
+
 if [ "${forceOpt:-false}" = true ]
 then
+    # Create qt.conf and adjust locations to use '${prefix}' internally
     finalizeQt
 fi
-changePrefix
-
+pkgconfigSetPrefix $QT_ARCH_PATH
 
-# ----------------------------------------------------------------- end-of-file
+# -----------------------------------------------------------------------------
diff --git a/etc/tools/QtFunctions b/etc/tools/QtFunctions
index 363de9e..c8a6a95 100644
--- a/etc/tools/QtFunctions
+++ b/etc/tools/QtFunctions
@@ -3,7 +3,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -26,6 +26,7 @@
 #
 # Description
 #     Functions for helping relocate a QT installation
+#     To be loaded *after* etc/tools/ThirdPartyFunctions
 #
 #------------------------------------------------------------------------------
 
@@ -35,114 +36,33 @@
 #
 createQtConf()
 {
-    echo "create:"
-    echo "    $QT_ARCH_PATH/bin/qt.conf"
+    local confFile="$QT_ARCH_PATH/bin/qt.conf"
 
-    [ -n "$QT_ARCH_PATH" -a -d "$QT_ARCH_PATH/bin" ] || {
-        echo "Error: QT_ARCH_PATH not correctly set"
-        return
-    }
-
-    echo "[Paths]"            > $QT_ARCH_PATH/bin/qt.conf
-    echo "Prefix=$QT_ARCH_PATH" >> $QT_ARCH_PATH/bin/qt.conf
-}
+    if [ -n "$QT_ARCH_PATH" -a -d "$QT_ARCH_PATH/bin" ]
+    then
+        /bin/cat << QT_CONF > $confFile
+[Paths]
+Prefix=$QT_ARCH_PATH
+QT_CONF
+        echo "    created qt.conf"
 
-
-#
-# Adjust pkgconfig information
-# to generalize *location=, -L/... and -I/...
-# to use ${prefix}
-#
-adjustPkgConfig()
-{
-    echo "edit pkgconfig:"
-    echo "    $QT_ARCH_PATH/lib/pkgconfig/*.pc"
-
-    [ -n "$QT_ARCH_PATH" -a -d "$QT_ARCH_PATH/lib/pkgconfig" ] || {
+    else
         echo "Error: QT_ARCH_PATH not correctly set"
-        return
-    }
-
-    (
-        cd $QT_ARCH_PATH/lib/pkgconfig || exit
-
-        unset nfiles
-        for i in *.pc
-        do
-            if [ -f "$i" ]
-            then
-                nfiles="x$nfiles"
-                sed -i \
-                    -e 's@\(location=\)'"$QT_ARCH_PATH/"'@\1${prefix}/@' \
-                    -e 's@\(-[IL]\)'"$QT_ARCH_PATH/"'@\1${prefix}/@g'    \
-                    $i
-            fi
-        done
-        echo "    edited ${#nfiles} files"
-    )
+    fi
 }
 
 
-#
-# Change prefix=... and Prefix=... to use ${prefix}
-#
-changePrefix()
-{
-    echo "relocate QT installation to new prefix directory:"
-    echo "    $QT_ARCH_PATH"
-    echo "edit:"
-    echo "    $QT_ARCH_PATH/bin/qt.conf"
-    echo "    $QT_ARCH_PATH/lib/pkgconfig/*.pc"
-
-    [ -n "$QT_ARCH_PATH" -a -d "$QT_ARCH_PATH/bin" -a -d "$QT_ARCH_PATH/lib/pkgconfig" ] || {
-        echo "Error: QT_ARCH_PATH not correctly set"
-        return
-    }
-
-    # adjust qt.conf
-    for i in $QT_ARCH_PATH/bin/qt.conf
-    do
-        if [ -f "$i" ]
-        then
-            nfiles="x$nfiles"
-            sed -i \
-                -e 's@^\([Pp]refix=\).*$@\1'"$QT_ARCH_PATH@" \
-                $i
-            echo "    edited 1 file"
-        fi
-    done
-
-    # adjust pkgconfig files
-    (
-        cd $QT_ARCH_PATH/lib/pkgconfig || exit
-
-        unset nfiles
-        for i in *.pc
-        do
-            if [ -f "$i" ]
-            then
-                nfiles="x$nfiles"
-                sed -i \
-                    -e 's@^\([Pp]refix=\).*$@\1'"$QT_ARCH_PATH@" \
-                    $i
-            fi
-        done
-        echo "    edited ${#nfiles} files"
-    )
-
-}
-
 # ------------------------------------------------------------------------------
 
 #
-# create qt.conf and adjustPkgConfig to use ${prefix} internally
+# create qt.conf and adjust locations to use ${prefix} internally
 #
 finalizeQt()
 {
     echo "Create/Edit files to ease later relocation of a QT installation"
     createQtConf
-    adjustPkgConfig
+    pkgconfigAdjust $QT_ARCH_PATH
 }
 
 
-# ----------------------------------------------------------------- end-of-file
+# -----------------------------------------------------------------------------
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 9efa322..911ca75 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -3,7 +3,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -229,6 +229,79 @@ NOT_FOUND
 }
 
 
+#
+# Change prefix=... and Prefix=... in pkgconfig
+#
+pkgconfigSetPrefix()
+{
+    local dir="$1"
+    local nfiles
+
+    if [ -n "$dir" -a -d "$dir/lib/pkgconfig" ]
+    then
+    (
+        cd $dir/lib/pkgconfig || exit
+
+        echo "Set pkgconfig prefix : $dir"
+        echo "    files ... lib/pkgconfig/*.pc"
+
+        for i in *.pc
+        do
+            if [ -f "$i" ]
+            then
+                nfiles="x$nfiles"
+                sed -i \
+                    -e 's@^\([Pp]refix=\).*$@\1'"$dir@" \
+                    $i
+            fi
+        done
+        echo "    edited ${#nfiles} files"
+    )
+    else
+        echo "Error: incorrect prefix value: $dir" 1>&2
+        return 1
+    fi
+}
+
+
+#
+# Adjust pkgconfig information
+#   to generalize *location=, -I/... and -L/...
+#   to use ${prefix}
+#
+pkgconfigAdjust()
+{
+    local dir="$1"
+    local nfiles
+
+    if [ -n "$dir" -a -d "$dir/lib/pkgconfig" ]
+    then
+    (
+        cd $dir/lib/pkgconfig || exit
+
+        echo "Adjust pkgconfig locations : $dir"
+        echo "    files ... lib/pkgconfig/*.pc"
+
+        for i in *.pc
+        do
+            if [ -f "$i" ]
+            then
+                nfiles="x$nfiles"
+                sed -i \
+                    -e 's@\(location=\)'"$dir/"'@\1${prefix}/@' \
+                    -e 's@\(-[IL]\)'"$dir/"'@\1${prefix}/@g'    \
+                    $i
+            fi
+        done
+        echo "    edited ${#nfiles} files"
+    )
+    else
+        echo "Error: incorrect prefix value: $dir" 1>&2
+        return 1
+    fi
+}
+
+
 #
 # Download file $1 from url $2 into download/ directory
 #
diff --git a/makeParaView b/makeParaView
index 91a64a6..3edb55b 100755
--- a/makeParaView
+++ b/makeParaView
@@ -132,7 +132,7 @@ For finer control, the build stages can be selected or deselected individually:
 To make a different paraview version, simply specify on the command-line.
 For example,
 
-    ./makeParaview 4.4.0
+    ./makeParaview 5.0.1
 
 Or change the \$WM_PROJECT_DIR/etc/config.sh/paraview settings.
 
diff --git a/makeQt b/makeQt
index 5c27532..41ff348 100755
--- a/makeQt
+++ b/makeQt
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -29,7 +29,7 @@
 #     Build script for QT (the qt-everywhere-opensource-src package)
 #
 #------------------------------------------------------------------------------
-qtVERSION=4.8.7
+unset qtVERSION # No default version
 qtTYPE=qt-everywhere-opensource-src
 
 #------------------------------------------------------------------------------
@@ -48,7 +48,7 @@ usage() {
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: ${0##*/} [OPTION] [VERSION]
+usage: ${0##*/} [OPTION] [qt-VERSION]
 options:
   -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -help
@@ -174,4 +174,4 @@ else
     }
 fi
 
-# ----------------------------------------------------------------- end-of-file
+# -----------------------------------------------------------------------------
-- 
GitLab


From 9926569ca108794dba791aace8c448c682813298 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 19 Jan 2017 18:27:11 +0100
Subject: [PATCH 06/27] ENH: add -suffix option for makeParaView and makeVTK

- simple means of distinguishing between types of builds
  (mesa, mpi, python).
---
 etc/tools/ParaViewFunctions   | 16 ++++------------
 etc/tools/ThirdPartyFunctions | 19 +++++++++++++++++++
 etc/tools/vtkFunctions        | 12 +++++-------
 makeADIOS                     |  2 +-
 makeCGAL                      |  4 ++--
 makeLLVM                      |  2 +-
 makeParaView                  |  8 +++++++-
 makeParaView.example          |  1 +
 makeVTK                       |  8 +++++++-
 9 files changed, 47 insertions(+), 25 deletions(-)

diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 9232332..ba4a32a 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -37,11 +37,9 @@ unset withQT      QT_VERSION      QMAKE_PATH
 unset withMESA    MESA_INCLUDE    MESA_LIBRARY    withOSMESA
 unset withPYTHON  PYTHON_INCLUDE  PYTHON_LIBRARY
 unset withGL2
-unset OBJ_ADD
-
 BUILD_TYPE=Release  # The cmake build type
 
-# sourceBASE, buildBASE, installBASE
+# sourceBASE, buildBASE, installBASE and BUILD_SUFFIX
 #   are defined in tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
 
@@ -75,11 +73,8 @@ setParaViewDirs()
         exit 1
     }
 
-    # ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION${OBJ_ADD:+-$OBJ_ADD}
-    ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION
-
-    # ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION${OBJ_ADD:+-$OBJ_ADD}
-    ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION
+    ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION$BUILD_SUFFIX
+    ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION$BUILD_SUFFIX
 
     export ParaView_SOURCE_DIR ParaView_BINARY_DIR ParaView_DIR
 
@@ -173,8 +168,6 @@ addMpiSupport()
         return
     fi
 
-    OBJ_ADD="$OBJ_ADD-mpi"
-
     addCMakeVariable "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON"
     if [ "${MPI_MAX_PROCS:=0}" -gt 1 ]
     then
@@ -193,8 +186,6 @@ addPythonSupport()
         return
     fi
 
-    OBJ_ADD="$OBJ_ADD-py"
-
     if pythonBin=$(which python 2>/dev/null)
     then
         if [ -n "$PYTHON_LIBRARY" ]
@@ -407,6 +398,7 @@ configParaView()
     echo "    Build          : $ParaView_BINARY_DIR"
     echo "    Target         : $ParaView_DIR"
     echo "    cmake          : $cmake"
+    echo "    Build suffix   : ${BUILD_SUFFIX:-none}"
     echo "----"
     echo
     echo "$cmake" \
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 911ca75..f979c9c 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -36,6 +36,25 @@ sourceBASE=$WM_THIRD_PARTY_DIR
 buildBASE=$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER
 installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
 
+unset BUILD_SUFFIX
+#------------------------------------------------------------------------------
+
+#
+# Set a suffix for the build
+# - eg, for -mpi, or -mesa etc
+#
+setBuildSuffix()
+{
+    BUILD_SUFFIX="${1##-}"
+    if [ -n "$BUILD_SUFFIX" ]
+    then
+        BUILD_SUFFIX="-${BUILD_SUFFIX}"
+    else
+        unset BUILD_SUFFIX
+    fi
+}
+
+
 #
 # Mostly building without wmake
 # - disable wmakeScheduler variables
diff --git a/etc/tools/vtkFunctions b/etc/tools/vtkFunctions
index d5eefee..ea13bb7 100644
--- a/etc/tools/vtkFunctions
+++ b/etc/tools/vtkFunctions
@@ -33,8 +33,8 @@
 # Variables referenced by the functions. Initialization at the end of the file.
 unset CMAKE_VARIABLES
 
-# sourceBASE, buildBASE, installBASE defined in tools/ThirdPartyFunctions
-
+# sourceBASE, buildBASE, installBASE and BUILD_SUFFIX
+#   are defined in tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
 
 #
@@ -67,11 +67,8 @@ setVtkDirs()
         exit 1
     }
 
-    # VTK_BINARY_DIR=$buildBASE/VTK-$VTK_VERSION${OBJ_ADD:+-$OBJ_ADD}
-    VTK_BINARY_DIR=$buildBASE/VTK-$VTK_VERSION
-
-    # VTK_DIR=$installBASE/VTK-$VTK_VERSION${OBJ_ADD:+-$OBJ_ADD}
-    VTK_DIR=$installBASE/VTK-$VTK_VERSION
+    VTK_BINARY_DIR=$buildBASE/VTK-$VTK_VERSION$BUILD_SUFFIX
+    VTK_DIR=$installBASE/VTK-$VTK_VERSION$BUILD_SUFFIX
 
     export VTK_SOURCE_DIR VTK_BINARY_DIR VTK_DIR
 
@@ -145,6 +142,7 @@ configVTK()
     echo "    Build          : $VTK_BINARY_DIR"
     echo "    Target         : $VTK_DIR"
     echo "    cmake          : $cmake"
+    echo "    Build suffix   : ${BUILD_SUFFIX:-none}"
     echo "----"
     echo
     echo "$cmake" \
diff --git a/makeADIOS b/makeADIOS
index 0c8d4d7..e80afef 100755
--- a/makeADIOS
+++ b/makeADIOS
@@ -353,7 +353,7 @@ else
         cd $buildDIR && $cmake \
             -DCMAKE_INSTALL_PREFIX=$ADIOS_ARCH_PATH \
             -DCMAKE_BUILD_TYPE=Release \
-            -DBUILD_FORTRAN:BOOL=FALSE \
+            -DBUILD_FORTRAN=FALSE \
             $ADIOS_SOURCE_DIR \
         && make -j $WM_NCOMPPROCS all \
         && make install \
diff --git a/makeCGAL b/makeCGAL
index b5d49e4..bde8d26 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -403,7 +403,7 @@ CMAKE_OPTIONS
     elif _foamIsNone $GMP_ARCH_PATH
     then
         echo "    disabled       : gmp"
-        configGmp="-DCGAL_DISABLE_GMP:BOOL=TRUE"  # Also used for mpfr
+        configGmp="-DCGAL_DISABLE_GMP=TRUE"  # Also used for mpfr
     elif [ -d "$GMP_ARCH_PATH" ]
     then
         echo "    ThirdParty     : gmp"
@@ -425,7 +425,7 @@ CMAKE_OPTIONS
     elif _foamIsNone $MPFR_ARCH_PATH
     then
         echo "    disabled       : mpfr"
-        configGmp="-DCGAL_DISABLE_GMP:BOOL=TRUE"  # Also used for mpfr
+        configGmp="-DCGAL_DISABLE_GMP=TRUE"  # Also used for mpfr
     elif [ -d "$MPFR_ARCH_PATH" ]
     then
         echo "    ThirdParty     : mpfr"
diff --git a/makeLLVM b/makeLLVM
index bd5914f..08aafd8 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -189,7 +189,7 @@ else
         $cmake \
             -DCMAKE_INSTALL_PREFIX=$LLVM_ARCH_PATH \
             -DCMAKE_BUILD_TYPE=Release \
-            -DBUILD_SHARED_LIBS:BOOL=ON \
+            -DBUILD_SHARED_LIBS=ON \
             $LLVM_SOURCE_DIR \
         && make -j $WM_NCOMPPROCS \
         && make install \
diff --git a/makeParaView b/makeParaView
index 3edb55b..82bf26a 100755
--- a/makeParaView
+++ b/makeParaView
@@ -108,6 +108,7 @@ options:
   -version VER      specify an alternative version (current value: $ParaView_VERSION)
   -major   VER      specify an alternative major version for special builds
   -buildType NAME   specify the build type (default: Release)
+  -suffix NAME      specify a suffix to distinguish the build
   -help
 
 The -no-FEATURE option can be used to forcibly disable these features:
@@ -127,7 +128,7 @@ For finer control, the build stages can be selected or deselected individually:
 
 * Make and install paraview-$ParaView_VERSION located under
       \$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
-  ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION
+  ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION$BUILD_SUFFIX
 
 To make a different paraview version, simply specify on the command-line.
 For example,
@@ -300,6 +301,11 @@ do
         BUILD_TYPE="$2"
         shift
         ;;
+    -suffix)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        setBuildSuffix "$2"
+        shift
+        ;;
     *)
         die "unknown option/argument: '$1'"
         ;;
diff --git a/makeParaView.example b/makeParaView.example
index aeb60be..b32d784 100755
--- a/makeParaView.example
+++ b/makeParaView.example
@@ -9,6 +9,7 @@ mesa=mesa-13.0.3
 ./makeParaView \
     -mpi=0 \
     -mesa-prefix $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$mesa \
+    -suffix mesa \
     "$@"
 
 #------------------------------------------------------------------------------
diff --git a/makeVTK b/makeVTK
index ea01f2a..34fc7e8 100755
--- a/makeVTK
+++ b/makeVTK
@@ -88,6 +88,7 @@ options:
   -verbose          verbose output in Makefiles
   -version VER      specify an alternative version (current value: $VTK_VERSION)
   -buildType NAME   specify the build type (default: Release)
+  -suffix NAME      specify a suffix to distinguish the build
   -help
 
 The -no-FEATURE option can be disable these features (if not already disabled):
@@ -107,7 +108,7 @@ For finer control, the build stages can be selected or deselected individually:
 
 * Make and install VTK-$VTK_VERSION located under
       \$WM_THIRD_PARTY_DIR/VTK-$VTK_VERSION
-  ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/VTK-$VTK_VERSION
+  ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/VTK-$VTK_VERSION$BUILD_SUFFIX
 
 USAGE
     exit 1
@@ -238,6 +239,11 @@ do
         BUILD_TYPE="$2"
         shift
         ;;
+    -suffix)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        setBuildSuffix "$2"
+        shift
+        ;;
     *)
         die "unknown option/argument: '$1'"
         ;;
-- 
GitLab


From 1622a468320cfce13da2c100f3a39e4e6aa290b6 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 19 Jan 2017 20:47:15 +0100
Subject: [PATCH 07/27] STYLE: clearly document which scripts contain
 user-configurable settings

- unify cd, check for the cwd and error message
---
 Allclean       | 36 +++++++++++++++++-------------------
 Allwmake       | 16 ++++++++--------
 etc/relocateQt | 16 ++++++++--------
 makeADIOS      | 26 +++++++++++++-------------
 makeCCMIO      | 32 +++++++++++++++-----------------
 makeCGAL       | 29 ++++++++++++++---------------
 makeCmake      | 20 ++++++++++----------
 makeFFTW       | 24 ++++++++++++------------
 makeGcc        | 28 +++++++++++++---------------
 makeGperftools | 24 ++++++++++++------------
 makeLLVM       | 44 ++++++++++++++++++--------------------------
 makeMesa       | 26 +++++++++++++++-----------
 makeParaView   | 33 +++++++++++++++------------------
 makeQt         | 18 +++++++++---------
 makeTecio      | 35 +++++++++++++++++------------------
 makeVTK        | 28 +++++++++++++++++-----------
 minCmake       | 11 ++++++-----
 17 files changed, 219 insertions(+), 227 deletions(-)

diff --git a/Allclean b/Allclean
index 2416e67..6c3e0b0 100755
--- a/Allclean
+++ b/Allclean
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -26,26 +26,24 @@
 #     Allclean
 #
 # Description
-#     Clean script for third-party applications and libraries
+#     Clean script for ThirdParty applications and libraries
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-# run from third-party directory only
-cd ${0%/*} || exit 1
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 # . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-Script=${0##*/}
-
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
-Usage: $Script [OPTION] [<platform> [ ... <platformN> ]]
+Usage: ${0##*/} [OPTION] [<platform> [ ... <platformN> ]]
 options:
   -all              remove all platforms directories.
   -current          clean the current platform ($WM_OPTIONS).
@@ -60,14 +58,15 @@ USAGE
 }
 
 # Print help message
-if [ "$1" = "-h" -o "$1" = "-help" ]; then
+if [ "$1" = "-h" -o "$1" = "-help" ]
+then
     usage
 fi
 
 #------------------------------------------------------------------------------
 
 # Clean various packages via 'distclean'
-for i in openmpi-* ADIOS-* metis-*
+for i in openmpi-* metis-* adios-* ADIOS-*
 do
     [ -d "$i" ] && (
         echo
@@ -105,12 +104,6 @@ fi
 #
 # Clean platforms directories
 #
-if [ "$#" -ge 1 ]
-then
-    echo
-    echo "Clean platforms/sub-directories"
-fi
-
 removePlatform()
 {
     local platform="$1"
@@ -125,6 +118,11 @@ removePlatform()
     fi
 }
 
+if [ "$#" -ge 1 ]
+then
+    echo
+    echo "Clean platforms/sub-directories"
+fi
 
 # Optionally cleanup platforms specified from the arguments
 while [ "$#" -ge 1 ]
diff --git a/Allwmake b/Allwmake
index 06642ef..13a4821 100755
--- a/Allwmake
+++ b/Allwmake
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -28,18 +28,18 @@
 # Description
 #     Build script for ThirdParty
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} || exit 1
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 [ -n "$FOAM_EXT_LIBBIN" ] || {
-    echo "Error: FOAM_EXT_LIBBIN not set"
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+    echo "Error (${0##*/}) : \$FOAM_EXT_LIBBIN not set"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
diff --git a/etc/relocateQt b/etc/relocateQt
index 74e7f93..0a13408 100755
--- a/etc/relocateQt
+++ b/etc/relocateQt
@@ -28,20 +28,20 @@
 # Description
 #     Change prefix when relocating QT installation
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-unset qtVERSION # No default version
-
-#------------------------------------------------------------------------------
-# Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+# Run from third-party (parent) directory only
+wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : current directory is not \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 . etc/tools/QtFunctions
 #------------------------------------------------------------------------------
+unset qtVERSION # No default version
+#------------------------------------------------------------------------------
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
diff --git a/makeADIOS b/makeADIOS
index e80afef..0081fab 100755
--- a/makeADIOS
+++ b/makeADIOS
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+#   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -28,23 +28,23 @@
 # Description
 #     Build script for ADIOS
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-# Get version info
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+# ADIOS version from OpenFOAM etc/config.sh file
 . $WM_PROJECT_DIR/etc/config.sh/functions
 unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS)
 
 adiosPACKAGE=${adios_version:-adios-none}
-
-#------------------------------------------------------------------------------
-# Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-. etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -365,4 +365,4 @@ else
     }
 fi
 
-# ----------------------------------------------------------------- end-of-file
+# -----------------------------------------------------------------------------
diff --git a/makeCCMIO b/makeCCMIO
index 8b7282c..1e1d5ec 100755
--- a/makeCCMIO
+++ b/makeCCMIO
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  |
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -28,30 +28,29 @@
 # Description
 #     Build CD-adapco's ccmio library
 #
-#------------------------------------------------------------------------------
-# Get version info
-. $WM_PROJECT_DIR/etc/config.sh/functions
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
-
-ccmioPACKAGE=${ccmio_version:-libccmio-2.6.1}
-targetType=lib
-
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} || exit 1
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 [ -n "$FOAM_EXT_LIBBIN" ] || {
-    echo "Error: FOAM_EXT_LIBBIN not set"
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+    echo "Error (${0##*/}) : \$FOAM_EXT_LIBBIN not set"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
+# libccmio version from OpenFOAM etc/config.sh file
+. $WM_PROJECT_DIR/etc/config.sh/functions
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
+
+ccmioPACKAGE=${ccmio_version:-libccmio-2.6.1}
+targetType=lib
+#------------------------------------------------------------------------------
 usage()
 {
     exec 1>&2
@@ -79,7 +78,6 @@ USAGE
 }
 #------------------------------------------------------------------------------
 
-
 # Parse options
 while [ "$#" -gt 0 ]
 do
diff --git a/makeCGAL b/makeCGAL
index bde8d26..c4acdc2 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2012-2016 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -34,8 +34,18 @@
 #     simply specify a 'system' version. For example,
 #         makeCGAL boost-system gmp-system
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-# Get CGAL, boost and gmp/mpfr versions
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+# CGAL, boost and gmp/mpfr versions from OpenFOAM etc/config.sh file
 . $WM_PROJECT_DIR/etc/config.sh/functions
 unset -f _foamAddPath _foamAddLib _foamAddMan   # get settings only
 unset BOOST_ARCH_PATH CGAL_ARCH_PATH            # purge current values
@@ -48,24 +58,13 @@ boostPACKAGE=${boost_version:-boost-system}
 gmpPACKAGE=${gmp_version:-gmp-system}
 mpfrPACKAGE=${mpfr_version:-mpfr-system}
 cgalPACKAGE=$cgal_version
-
-#------------------------------------------------------------------------------
-# Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-. etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-Script="${0##*/}"
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: $Script [OPTION] [CGAL-VERSION] [boost-VERSION] [gmp-VERSION] [mpfr-VERSION]
+usage: ${0##*/} [OPTION] [CGAL-VERSION] [boost-VERSION] [gmp-VERSION] [mpfr-VERSION]
 options:
   -cmake PATH       with cmake from the path given
   -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
@@ -82,7 +81,7 @@ options:
 Normally builds against ThirdParty boost and gmp/mpfr when possible.
 To override this behaviour (and use the system boost and/or gmp/mpfr),
 simply specify a 'system' version. For example,
-    $Script boost-system gmp-system
+    ${0##*/} boost-system gmp-system
 
 Use gmp-none to disable use of gmp/mpfr (eg, not available)
 
diff --git a/makeCmake b/makeCmake
index b60bef5..6f566b9 100755
--- a/makeCmake
+++ b/makeCmake
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -28,20 +28,20 @@
 # Description
 #     Build script for cmake
 #
-#------------------------------------------------------------------------------
-# Special purpose script, no default version.
-unset cmakePACKAGE
-
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
+# Special purpose script - no default version.
+unset cmakePACKAGE
+#------------------------------------------------------------------------------
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
@@ -53,7 +53,7 @@ options:
   -help
 
 * build cmake
-      ${cmakePACKAGE:-'unspecified version'}
+      ${cmakePACKAGE:-'unspecified'}
 
 USAGE
     exit 1
diff --git a/makeFFTW b/makeFFTW
index 7d63984..9a66583 100755
--- a/makeFFTW
+++ b/makeFFTW
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+#   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -28,24 +28,24 @@
 # Description
 #     Build script for FFTW
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-# Get FFTW versions
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+# FFTW version from OpenFOAM etc/config.sh file
 . $WM_PROJECT_DIR/etc/config.sh/functions
 unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW)
 
 fftwPACKAGE=${fftw_version:-fftw-system}
-
-#------------------------------------------------------------------------------
-# Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-. etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
diff --git a/makeGcc b/makeGcc
index b5f10ae..85b1571 100755
--- a/makeGcc
+++ b/makeGcc
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -40,8 +40,18 @@
 #
 #         WM_COMPILER=Gcc51 ./makeGcc -system
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-# get default GCC, mpfr, gmp and mpc versions
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+# Default GCC, mpfr, gmp and mpc versions from OpenFOAM etc/config.sh file
 WM_COMPILER_TYPE=ThirdParty       # ensure we get the correct compiler settings
 : ${WM_COMPILER:=Gcc}             # this will still fail if 'Clang' was set
 
@@ -52,25 +62,13 @@ gmpPACKAGE=${gmp_version:-gmp-system}
 mpfrPACKAGE=${mpfr_version:-mpfr-system}
 mpcPACKAGE=${mpc_version:-mpc-system}
 gccPACKAGE=$gcc_version
-
 #------------------------------------------------------------------------------
-# Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-. etc/tools/ThirdPartyFunctions
-#------------------------------------------------------------------------------
-Script=${0##*/}
-
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: $Script [OPTION] [gcc-VERSION] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION]
+usage: ${0##*/} [OPTION] [gcc-VERSION] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION]
 options:
   -multilib         for 64-bit systems with 32-bit support required
   -no-multilib      for 64-bit systems without 32-bit support (DEFAULT)
diff --git a/makeGperftools b/makeGperftools
index e12efd5..767921c 100755
--- a/makeGperftools
+++ b/makeGperftools
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2012 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -28,24 +28,24 @@
 # Description
 #     Build script for gperftools
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-# Get gperftools version
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+# Gperftools version from OpenFOAM etc/config.sh file
 . $WM_PROJECT_DIR/etc/config.sh/functions
 unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools)
 
 gperftoolsPACKAGE=${gperftools_version:-gperftools-system}
-
-#------------------------------------------------------------------------------
-# Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-. etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
diff --git a/makeLLVM b/makeLLVM
index 08aafd8..c9ec115 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -30,28 +30,30 @@
 #
 # Note
 #    - Ensure that you always use matching versions between llvm and clang.
-#    - The LLVM components reside in the LLVM tools/ subdirectory
+#    - LLVM components such as clang reside in the LLVM tools/ subdirectory
 #
-#    Example, building from svn repository:
-#      1) Checkout LLVM:
-#            svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm-svn
+#    For example, when building from tar files (version 3.8.0)
 #
-#      2) Checkout Clang, in the correct location
-#            cd llvm-svn/tools
-#            svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
-#            cd -
-#
-#    Example, building from tar files (version 3.8.0)
-#    - Unpack LLVM:
-#        tar -Jvf llvm-3.8.0.src.tar.xz
+#    1) Unpack LLVM:
+#        tar -xJvf llvm-3.8.0.src.tar.xz
 #        mv llvm-3.8.0.src  llvm-3.8.0
 #
-#    - Unpack Clang (also know as cfe):
-#        tar -Jvf cfe-3.8.0.src.tar.xz
+#    2) Unpack Clang (also know as cfe):
+#        tar -xJvf cfe-3.8.0.src.tar.xz
 #        mv cfe-3.8.0.src  llvm-3.8.0/tools/clang
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
+#------------------------------------------------------------------------------
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# Get default llvm/clang version
+# LLVM/Clang version from OpenFOAM etc/config.sh file
 WM_COMPILER_TYPE=ThirdParty       # ensure we get the correct compiler settings
 WM_COMPILER=Clang                 # force values for 'clang'
 
@@ -59,16 +61,6 @@ WM_COMPILER=Clang                 # force values for 'clang'
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
 
 llvmPACKAGE=$clang_version
-
-#------------------------------------------------------------------------------
-# run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-. etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
diff --git a/makeMesa b/makeMesa
index 123c9df..dc17402 100755
--- a/makeMesa
+++ b/makeMesa
@@ -32,23 +32,27 @@
 #     Building with mesa-12.x.x fails to create an include/GL directory and
 #     an "osmesa.h" file. Both make it fairly useless for off-screen VTK.
 #
-#     Building with mesa-11.x is fine and mesa-13.x also seems to be okay.
+#     Building with mesa-11.x and mesa-13.x seem to be okay.
 #
-#------------------------------------------------------------------------------
-# Special purpose script, no default version.
-unset mesaPACKAGE
-
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} || exit 1
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
+# MESA version from OpenFOAM etc/config.sh file
+. $WM_PROJECT_DIR/etc/config.sh/functions
+unset -f _foamAddPath _foamAddLib               # get settings only
+unset vtk_version mesa_version                  # purge current values
+
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk)
+mesaPACKAGE=$mesa_version
+#------------------------------------------------------------------------------
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
@@ -207,4 +211,4 @@ adjustMESA()
     exit 1
 }
 
-# ----------------------------------------------------------------- end-of-file
+# -----------------------------------------------------------------------------
diff --git a/makeParaView b/makeParaView
index 82bf26a..114da6a 100755
--- a/makeParaView
+++ b/makeParaView
@@ -33,27 +33,25 @@
 #
 #     Note the capitalization of ParaView in the directory names.
 #
+# ------------------------------------------------
+# SOME USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-# Get ParaView_VERSION location from OpenFOAM config file
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+. etc/tools/ParaViewFunctions
+#------------------------------------------------------------------------------
+# ParaView_VERSION from OpenFOAM etc/config.sh file
 . $WM_PROJECT_DIR/etc/config.sh/functions
 unset -f _foamAddPath _foamAddLib               # get settings only
 unset ParaView_VERSION                          # purge current values
 
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview)
-
 : ${ParaView_VERSION##*-}
-
-#------------------------------------------------------------------------------
-# Run from third-party directory only
-cd ${0%/*} || exit 1
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-. etc/tools/ThirdPartyFunctions
-. etc/tools/ParaViewFunctions
 #------------------------------------------------------------------------------
 #
 # USER DEFAULTS:
@@ -69,7 +67,7 @@ MESA_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
 #   If that fails, specify the path using the PYTHON_LIBRARY variable below.
 withPYTHON=false
 PYTHON_LIBRARY=""
-# PYTHON_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libpython2.6.so.1.0"
+# PYTHON_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libpython2.7.so.1.0"
 
 # New rendering backend (starting with paraview 5.0).
 # Default to auto-config based on paraview version
@@ -79,14 +77,13 @@ withGL2=auto
 # NO FURTHER EDITING BELOW THIS LINE
 #
 #-----------------------------------------------------------------------------
-Script=${0##*/}
 usage() {
     : ${ParaView_VERSION:=none} # some dummy value for usage information
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: $Script [OPTION] [paraview-VERSION] [CMAKE-OPTION]
+usage: ${0##*/} [OPTION] [paraview-VERSION] [CMAKE-OPTION]
 options:
   -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -rebuild          for repeated builds (-make -install) *use with caution*
@@ -116,7 +113,7 @@ The -no-FEATURE option can be used to forcibly disable these features:
 
 CMake options start with a capital letter and contain an '='.
 For example,
-    $Script BUILD_TESTING=ON
+    ${0##*/} BUILD_TESTING=ON
 to add tests
 
 For finer control, the build stages can be selected or deselected individually:
diff --git a/makeQt b/makeQt
index 41ff348..a131099 100755
--- a/makeQt
+++ b/makeQt
@@ -28,21 +28,21 @@
 # Description
 #     Build script for QT (the qt-everywhere-opensource-src package)
 #
-#------------------------------------------------------------------------------
-unset qtVERSION # No default version
-qtTYPE=qt-everywhere-opensource-src
-
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 . etc/tools/QtFunctions
 #------------------------------------------------------------------------------
+qtTYPE=qt-everywhere-opensource-src
+unset qtVERSION # No default version
+#------------------------------------------------------------------------------
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
@@ -53,7 +53,7 @@ options:
   -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -help
 
-* build $qtTYPE, version $qtVERSION
+* build $qtTYPE, version ${qtVERSION:-undefined}
 
 USAGE
     exit 1
diff --git a/makeTecio b/makeTecio
index df7daff..3628803 100755
--- a/makeTecio
+++ b/makeTecio
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+#   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -28,8 +28,23 @@
 # Description
 #     Build Tecplot library
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
-# Get boost version (headers only)
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+[ -n "$FOAM_EXT_LIBBIN" ] || {
+    echo "Error (${0##*/}) : \$FOAM_EXT_LIBBIN not set"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+# Boost version (headers only) from OpenFOAM etc/config.sh file
 . $WM_PROJECT_DIR/etc/config.sh/functions
 unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 
@@ -38,22 +53,6 @@ _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
 boostPACKAGE=${boost_version:-boost-system}
 tecioPACKAGE=tecio
 targetType=lib
-
-#------------------------------------------------------------------------------
-# Run from third-party directory only
-cd ${0%/*} || exit 1
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-[ -n "$FOAM_EXT_LIBBIN" ] || {
-    echo "Error: FOAM_EXT_LIBBIN not set"
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
-    exit 1
-}
-. etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
 usage()
 {
diff --git a/makeVTK b/makeVTK
index 34fc7e8..39f1ffe 100755
--- a/makeVTK
+++ b/makeVTK
@@ -28,27 +28,34 @@
 # Description
 #     Make and install VTK.
 #     The VTK sources should be located under one of these locations:
-#       - $WM_THIRD_PARTY_DIR/ParaView-VERSION
-#       - $WM_THIRD_PARTY_DIR/ParaView-vVERSION
+#       - $WM_THIRD_PARTY_DIR/VTK-VERSION
 #
 #     To use the VTK source from the ParaView source tree, simply make an
 #     appropriate link first. For example,
 #
 #        (cd $WM_THIRD_PARTY_DIR && ln -s ParaView-v5.2.0/VTK VTK-7.1.0)
 #
+# ------------------------------------------------
+# SOME USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} || exit 1
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 . etc/tools/ParaViewFunctions
 . etc/tools/vtkFunctions
 #------------------------------------------------------------------------------
+# VTK version from OpenFOAM etc/config.sh file
+. $WM_PROJECT_DIR/etc/config.sh/functions
+unset -f _foamAddPath _foamAddLib               # get settings only
+unset vtk_version mesa_version                  # purge current values
+
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk)
+VTK_VERSION=$vtk_version
+#------------------------------------------------------------------------------
 #
 # USER DEFAULTS:
 # ~~~~~~~~~~~~~~
@@ -66,13 +73,12 @@ withGL2=auto
 # NO FURTHER EDITING BELOW THIS LINE
 #
 #-----------------------------------------------------------------------------
-Script=${0##*/}
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: $Script [OPTION] [vtk-VERSION] [CMAKE-OPTION]
+usage: ${0##*/} [OPTION] [vtk-VERSION] [CMAKE-OPTION]
 options:
   -gcc              force g++ instead of the value from \$WM_CXX
   -rebuild          for repeated builds (-make -install) *use with caution*
@@ -91,12 +97,12 @@ options:
   -suffix NAME      specify a suffix to distinguish the build
   -help
 
-The -no-FEATURE option can be disable these features (if not already disabled):
+The -no-FEATURE option can be used to forcibly disable these features:
   -no-gl2 | -no-mesa | -no-mpi
 
 CMake options start with a capital letter and contain an '='.
 For example,
-    $Script BUILD_TESTING=ON
+    ${0##*/} BUILD_TESTING=ON
 to add tests and avoid building documentation
 
 For finer control, the build stages can be selected or deselected individually:
diff --git a/minCmake b/minCmake
index f6bcc6b..921811e 100755
--- a/minCmake
+++ b/minCmake
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+#   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -28,12 +28,13 @@
 # Description
 #     Scour CMakeLists.txt files to report the cmake_minimum required.
 #
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
-    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
-    echo "    The environment variables are inconsistent with the installation."
-    echo "    Check the OpenFOAM entries in your dot-files and source them."
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 #------------------------------------------------------------------------------
-- 
GitLab


From e3190722e57c6995105d149be30fd773d3eb77d9 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 20 Jan 2017 09:23:22 +0100
Subject: [PATCH 08/27] STYLE: add build information for ADIOS

---
 BUILD.md | 41 +++++++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 10 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index 98e09f9..5148f5e 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -3,7 +3,7 @@
    | =========                 |                                              |
    | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox        |
    |  \\    /   O peration     |                                              |
-   |   \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.              |
+   |   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.         |
    |    \\/     M anipulation  |                                              |
    |--------------------------------------------------------------------------|
   -->
@@ -24,8 +24,8 @@ The ThirdParty directory contains a number of build scripts as well as
 some directories:
 
 | Directory         | Contains
-|-------------------|--------------------------------------------
-| etc/              | auxiliary scripts used for the build process
+|-------------------|-------------------------------------------------------
+| etc/              | auxiliary tools and content used for the build process
 | build/            | intermediate build objects
 | platforms/        | the installation directories
 
@@ -121,6 +121,10 @@ ThirdParty components prior to building OpenFOAM itself.
 
 #### Optional Components
 
+`makeADIOS`
+- Only required for ADIOS support,
+  which is currently staged in the [add-ons repository][link AddOns].
+
 `makeCGAL`
 - Builds third-party boost and CGAL.
   Automatically invoked from the ThirdParty `Allwmake`,
@@ -146,6 +150,8 @@ ThirdParty components prior to building OpenFOAM itself.
 `makeQt`
 - Script to build a [third-party installation of Qt](#makeQt), including qmake.
 - Possibly needed for `makeParaView`.
+- The associated `etc/relocateQt` may be of independent use.
+  Read the file for more details.
 
 `makeGperftools`
 - Build gperftools (originally Google Performance Tools)
@@ -167,7 +173,7 @@ and save some disk space.
 
 ### Mesa
 - Needed for off-screen rendering.
-- Building with [mesa-11][older mesa] is fine and [mesa-13][link mesa] also seems to be okay.
+- Building with [mesa-11][older mesa] and [mesa-13][link mesa] both seem okay.
 - Building with mesa-12 is not possible since it fails to create
   the necessary `include/GL` directory and `osmesa.h` file.
 
@@ -203,7 +209,8 @@ and save some disk space.
 #### 5.2.0
 - Compiles without patching, but the OpenFOAM reader modules
   (eg, to visualize a `blockMeshDict`) have not yet been migrated
-  to this version.
+  to this version. Note that the native OpenFOAM reader appears to be
+  partially broken in this version.
 
 #### 4.4.0/5.0.0/5.0.1/5.1.2
 - When using `makeParaView`, the following patches will be automatically
@@ -215,6 +222,15 @@ and save some disk space.
     the compilation of ParaView to halt. The easiest solution is to delete
     the ParaView-5.0.1/Plugins/SciberQuestToolKit directory.
 
+### ADIOS
+- The github release currently requires GNU autoconf tools (eg,
+  autoconf, autoheader, automake) for its configuration.
+- Some inconsistency in directory names (ADIOS vs. adios) between releases.
+- Optionally uses bzip2, zlib development headers (eg, libbz2-devel, zlib-devel)
+  for the corresponding compression tranforms.
+- The [zfp floating point compression][page zfp] library is now included as
+  part of ADIOS.
+
 ### Making Qt <a name="makeQt"></a>
 - Building a third-party Qt installation (prior to building ParaView) requires
   some additional effort, but should nonetheless work smoothly.
@@ -229,7 +245,7 @@ and save some disk space.
 
        ./makeParaView -qt-4.8.7 5.0.1
 
-- ParaView does not yet support QT5.
+- ParaView does not yet support QT5 (Dec-2016, but this will soon change).
 
 - If you relocate the third-party directory to another location
   (eg, you built in your home directory, but want to install it in a
@@ -426,17 +442,22 @@ The minimum gcc/g++ requirements for building various components.
 [link Qt]: http://download.qt.io/official_releases/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz
 [newer Qt5]: http://download.qt.io/official_releases/qt/5.7/5.7.1/single/qt-everywhere-opensource-src-5.7.0.tar.xz
 
+<!-- OpenFOAM -->
+
+[link AddOns]: https://develop.openfoam.com/Community/OpenFOAM-addOns
+[link community-projects]: http://www.openfoam.com/services/community-projects.php
+
 
 <!-- Standard Footer -->
 ## Additional OpenFOAM Links
 
+- [Community AddOns][link AddOns] repository
+- [Collaborative and Community-based Developments][link community-projects]
 - [Download](http://www.openfoam.com/releases) and
   [installation instructions](http://www.openfoam.com/download/installation.php)
 - [Documentation](http://www.openfoam.com/documentation)
-- [Reporting bugs/issues (including bugs/suggestions/feature requests) in OpenFOAM+](http://www.openfoam.com/code/bug-reporting.php)
-- [Collaborative and Community-based Developments](http://www.openfoam.com/services/community-projects.php)
+- [Reporting bugs/issues](http://www.openfoam.com/code/bug-reporting.php) (including bugs/suggestions/feature requests) in OpenFOAM+
 - [Contacting OpenCFD](http://www.openfoam.com/contact)
-
 ---
 
-Copyright 2016 OpenCFD Ltd
+Copyright 2016-2017 OpenCFD Ltd
-- 
GitLab


From d55ae084d49328aa5546e44a47e865b929b004e9 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 20 Jan 2017 12:01:23 +0100
Subject: [PATCH 09/27] ENH: generalize and improve pkgconfig editing

- now handles both lib/pkgconfig and lib64/pkgconfig locations
- also adjust includedir= and libdir= entries
---
 etc/relocateQt                |   2 +-
 etc/tools/ThirdPartyFunctions | 104 ++++++++++++++++++++--------------
 2 files changed, 63 insertions(+), 43 deletions(-)

diff --git a/etc/relocateQt b/etc/relocateQt
index 0a13408..7a10433 100755
--- a/etc/relocateQt
+++ b/etc/relocateQt
@@ -96,6 +96,6 @@ then
     # Create qt.conf and adjust locations to use '${prefix}' internally
     finalizeQt
 fi
-pkgconfigSetPrefix $QT_ARCH_PATH
+pkgconfigNewPrefix $QT_ARCH_PATH
 
 # -----------------------------------------------------------------------------
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index f979c9c..fd57ed1 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -249,75 +249,99 @@ NOT_FOUND
 
 
 #
-# Change prefix=... and Prefix=... in pkgconfig
+# Set a new prefix=... in pkgconfig files
 #
-pkgconfigSetPrefix()
+pkgconfigNewPrefix()
 {
-    local dir="$1"
-    local nfiles
+    local dir="${1%%/}"
 
-    if [ -n "$dir" -a -d "$dir/lib/pkgconfig" ]
+    if [ -n "$dir" -a -d "$dir" ]
     then
-    (
-        cd $dir/lib/pkgconfig || exit
+        # Require absolute path, but use logical (not physical) location
+        [ "${dir}" != "${dir#/}" ] || dir=$(cd $dir 2>/dev/null && /bin/pwd -L)
+        # Strip sub-level
+        case "$dir" in (*/pkgconfig) dir="${dir%/*}";; esac
+        # Strip a level
+        case "$dir" in (*/lib | */lib64 | */bin) dir="${dir%/*}";; esac
+    fi
+
+    # Verify that the prefix path is valid
+    # Warning (not an error) - thus no special return code
+    [ -n "$dir" -a -d "$dir" ] || {
+        echo "Warning: invalid prefix directory: $dir" 1>&2
+        return 0
+    }
 
-        echo "Set pkgconfig prefix : $dir"
-        echo "    files ... lib/pkgconfig/*.pc"
+    echo "Set pkgconfig prefix : $dir"
 
-        for i in *.pc
+    local nfiles
+    for libdir in lib/pkgconfig lib64/pkgconfig
+    do
+        unset nfiles
+        [ -d "$dir/$libdir" ] || continue
+        for i in $dir/$libdir/*.pc
         do
             if [ -f "$i" ]
             then
                 nfiles="x$nfiles"
-                sed -i \
-                    -e 's@^\([Pp]refix=\).*$@\1'"$dir@" \
-                    $i
+                sed -i -e 's@^\(prefix=\).*$@\1'"$dir@" $i
             fi
         done
-        echo "    edited ${#nfiles} files"
-    )
-    else
-        echo "Error: incorrect prefix value: $dir" 1>&2
-        return 1
-    fi
+        echo "    $libdir/*.pc  (edited ${#nfiles})"
+    done
 }
 
 
 #
-# Adjust pkgconfig information
-#   to generalize *location=, -I/... and -L/...
-#   to use ${prefix}
+# Adjust pkgconfig information to use '${prefix} where possible instead
+# of directory paths.
+#
+# Adjusts includedir=, libdir=, -I/... and -L/... and
+# any *_location= entries (QT)
 #
 pkgconfigAdjust()
 {
-    local dir="$1"
-    local nfiles
+    local dir="${1%%/}"
 
-    if [ -n "$dir" -a -d "$dir/lib/pkgconfig" ]
+    if [ -n "$dir" -a -d "$dir" ]
     then
-    (
-        cd $dir/lib/pkgconfig || exit
+        # Require absolute path, but use logical (not physical) location
+        [ "${dir}" != "${dir#/}" ] || dir=$(cd $dir 2>/dev/null && /bin/pwd -L)
+        # Strip sub-level
+        case "$dir" in (*/pkgconfig) dir="${dir%/*}";; esac
+        # Strip a level
+        case "$dir" in (*/lib | */lib64 | */bin) dir="${dir%/*}";; esac
+    fi
 
-        echo "Adjust pkgconfig locations : $dir"
-        echo "    files ... lib/pkgconfig/*.pc"
+    # Verify that the prefix path is valid
+    # Warning (not an error) - thus no special return code
+    [ -n "$dir" -a -d "$dir" ] || {
+        echo "Warning: invalid prefix directory: $dir" 1>&2
+        return 0
+    }
 
-        for i in *.pc
+    echo "Adjust pkgconfig locations : $dir"
+
+    local nfiles
+    for libdir in lib/pkgconfig lib64/pkgconfig
+    do
+        unset nfiles
+        [ -d "$dir/$libdir" ] || continue
+        for i in $dir/$libdir/*.pc
         do
             if [ -f "$i" ]
             then
                 nfiles="x$nfiles"
                 sed -i \
-                    -e 's@\(location=\)'"$dir/"'@\1${prefix}/@' \
-                    -e 's@\(-[IL]\)'"$dir/"'@\1${prefix}/@g'    \
+                    -e 's@^\(includedir=\)'"$dir/"'@\1${prefix}/@' \
+                    -e 's@^\(libdir=\)'"$dir/"'@\1${prefix}/@'     \
+                    -e 's@\(_location=\)'"$dir/"'@\1${prefix}/@'   \
+                    -e 's@\(-[IL]\)'"$dir/"'@\1${prefix}/@g'       \
                     $i
             fi
         done
-        echo "    edited ${#nfiles} files"
-    )
-    else
-        echo "Error: incorrect prefix value: $dir" 1>&2
-        return 1
-    fi
+        echo "    $libdir/*.pc  (edited ${#nfiles})"
+    done
 }
 
 
@@ -350,8 +374,6 @@ downloadFile()
 # $2 = TARGET DIRECTORY (optional)
 cpMakeFiles()
 {
-    set +x
-
     [ "$#" -eq 1 -o "$#" -eq 2 ] || {
         echo "cpMakeFiles called with incorrect number of arguments $@"
         return 1
@@ -383,8 +405,6 @@ cpMakeFiles()
             cp $wmakeFiles/$i $dst/$d/Make/$b
         fi
     done
-
-    set -x
 }
 
 
-- 
GitLab


From 82595ca8236e22593d6f3c38983feafaa54ac30e Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 20 Jan 2017 12:04:40 +0100
Subject: [PATCH 10/27] ENH: provide etc/pkgconfigAdjust etc/pkgconfigPrefix
 wrappers

- both can operate on several directories, which means that the
  following is possible when relocating an entire third-party
  directory:

     etc/pkgconfigPrefix $(find platforms -type d -name pkgconfig)
---
 etc/pkgconfigAdjust | 88 +++++++++++++++++++++++++++++++++++++++++++++
 etc/pkgconfigPrefix | 85 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 173 insertions(+)
 create mode 100755 etc/pkgconfigAdjust
 create mode 100755 etc/pkgconfigPrefix

diff --git a/etc/pkgconfigAdjust b/etc/pkgconfigAdjust
new file mode 100755
index 0000000..cfb77de
--- /dev/null
+++ b/etc/pkgconfigAdjust
@@ -0,0 +1,88 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+#    \\/     M anipulation  |
+#------------------------------------------------------------------------------
+# License
+#     This file is part of OpenFOAM.
+#
+#     OpenFOAM is free software: you can redistribute it and/or modify it
+#     under the terms of the GNU General Public License as published by
+#     the Free Software Foundation, either version 3 of the License, or
+#     (at your option) any later version.
+#
+#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#     for more details.
+#
+#     You should have received a copy of the GNU General Public License
+#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Script
+#     etc/pkgconfigAdjust
+#
+# Description
+#     Adjust pkgconfig information to use '${prefix} where possible instead of
+#     directory paths. This makes it easier when relocating software.
+#     Adjusts includedir=, libdir=, -I/... and -L/... entries.
+#
+#     The specified directory can be any of the following:
+#         - base-dir
+#         - base-dir/bin
+#         - base-dir/lib
+#         - base-dir/lib64
+#         - base-dir/lib/pkgconfig
+#         - base-dir/lib64/pkgconfig
+#
+#     This allows this type of shell command
+#
+#        etc/pkgconfigAdjust $(find platforms -type d -name pkgconfig)
+#
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
+#------------------------------------------------------------------------------
+# Run from third-party (parent) directory only
+wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : current directory is not \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: ${0##*/} [OPTION] [directory1 [... directoryN]]
+options:
+  -help
+
+Adjust pkgconfig files after relocating third-party files.
+Locates pkgconfig files under the lib/ or lib64/ directories and adjusts them
+to use '${prefix}' instead of absolute directory paths where possible.
+
+USAGE
+    exit 1
+}
+#------------------------------------------------------------------------------
+
+# Process options/arguments
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    *)
+        pkgconfigAdjust "$1"
+        ;;
+    esac
+    shift
+done
+
+#------------------------------------------------------------------------------
diff --git a/etc/pkgconfigPrefix b/etc/pkgconfigPrefix
new file mode 100755
index 0000000..849eb83
--- /dev/null
+++ b/etc/pkgconfigPrefix
@@ -0,0 +1,85 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+#    \\/     M anipulation  |
+#------------------------------------------------------------------------------
+# License
+#     This file is part of OpenFOAM.
+#
+#     OpenFOAM is free software: you can redistribute it and/or modify it
+#     under the terms of the GNU General Public License as published by
+#     the Free Software Foundation, either version 3 of the License, or
+#     (at your option) any later version.
+#
+#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#     for more details.
+#
+#     You should have received a copy of the GNU General Public License
+#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Script
+#     etc/pkgconfigPrefix
+#
+# Description
+#     Set the prefix= entry for pkgconfig files to account for a new location.
+#
+#     The specified directory can be any of the following:
+#         - base-dir
+#         - base-dir/bin
+#         - base-dir/lib
+#         - base-dir/lib64
+#         - base-dir/lib/pkgconfig
+#         - base-dir/lib64/pkgconfig
+#
+#     This allows this type of shell command
+#
+#        etc/pkgconfigPrefix $(find platforms -type d -name pkgconfig)
+#
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
+#------------------------------------------------------------------------------
+# Run from third-party (parent) directory only
+wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : current directory is not \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: ${0##*/} [OPTION] [directory1 [... directoryN]]
+options:
+  -help
+
+Set the 'prefix=' entry for pkgconfig files.
+The pkgconfig files are located under lib/pkgconfig or lib64/pkgconfig.
+
+USAGE
+    exit 1
+}
+#------------------------------------------------------------------------------
+
+# Process options/arguments
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    *)
+        pkgconfigAdjust "$1"
+        ;;
+    esac
+    shift
+done
+
+#------------------------------------------------------------------------------
-- 
GitLab


From 59432b7b2dd2d67ccab0fb4781b71cdc9edaa2cf Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 20 Jan 2017 13:21:34 +0100
Subject: [PATCH 11/27] ENH: use pkgconfigAdjust when compiling software that
 has pkgconfig files

- simplifies relocation at a later stage
---
 Allwmake       |  5 +++--
 makeCCMIO      |  7 +++----
 makeCGAL       |  2 +-
 makeFFTW       |  8 +++++---
 makeGcc        |  4 ++++
 makeGperftools |  1 +
 makeLLVM       |  2 ++
 makeMesa       | 11 +++++++----
 8 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/Allwmake b/Allwmake
index 13a4821..e21941f 100755
--- a/Allwmake
+++ b/Allwmake
@@ -127,9 +127,11 @@ OPENMPI)
             --enable-mpi-fortran=none \
             --disable-mpi-profile \
             $configOpt \
+        && set +x \
         && make -j $WM_NCOMPPROCS \
         && make install \
-        && echo "Built: $mpiPACKAGE"
+        && echo "Built: $mpiPACKAGE" \
+        && pkgconfigAdjust $MPI_ARCH_PATH
     ) || {
         echo "Error building: $mpiPACKAGE"
         exit 1
@@ -201,7 +203,6 @@ MPICH)
     )
     fi
     ;;
-
 esac
 
 
diff --git a/makeCCMIO b/makeCCMIO
index 1e1d5ec..02e7c21 100755
--- a/makeCCMIO
+++ b/makeCCMIO
@@ -26,7 +26,7 @@
 #     makeCCMIO
 #
 # Description
-#     Build CD-adapco's ccmio library
+#     Build the libccmio library
 #
 # ----------------------------------------------
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
@@ -64,8 +64,8 @@ options:
 * Compile the proprietary libccmio library
       $ccmioPACKAGE
 
-  Users wishing to make use of the library should contact cd-adapco
-  (Siemens PLM) for possible download and terms of use.
+  Users wishing to obtain the library should contact Siemens PLM (cd-adapco)
+  for terms of use.
 
   After obtaining the $ccmioPACKAGE library, place in folder
 
@@ -118,7 +118,6 @@ echo "---------------"
     mkdir -p $libDIR 2>/dev/null
 
     cpMakeFiles libccmio 2>/dev/null
-    set +x
     if wmake $targetType
     then
         # make headers available:
diff --git a/makeCGAL b/makeCGAL
index c4acdc2..a3db8aa 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -452,9 +452,9 @@ CMAKE_OPTIONS
         ${optHeadersOnly:+-DCGAL_HEADER_ONLY=TRUE} \
         $configBoost $configGmp $configMpfr \
         $CGAL_SOURCE_DIR \
+    && set +x \
     && make -j $WM_NCOMPPROCS \
     && make install || exit 1
-    set +x
 
     echo "----"
     echo "create '\$CGAL_ARCH_PATH/share/files'"
diff --git a/makeFFTW b/makeFFTW
index 9a66583..fc8a10e 100755
--- a/makeFFTW
+++ b/makeFFTW
@@ -143,9 +143,11 @@ else
             --libdir=$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
             --enable-shared --disable-static \
             --disable-fortran \
-            && make -j $WM_NCOMPPROCS \
-            && make install \
-            && echo "Built $fftwPACKAGE"
+        && set +x \
+        && make -j $WM_NCOMPPROCS \
+        && make install \
+        && echo "Built $fftwPACKAGE" \
+        && pkgconfigAdjust $FFTW_ARCH_PATH
     ) || {
         echo "Error building: FFTW"
         exit 1
diff --git a/makeGcc b/makeGcc
index 85b1571..265d617 100755
--- a/makeGcc
+++ b/makeGcc
@@ -193,6 +193,7 @@ else
         --prefix=$GMP_ARCH_PATH \
         --libdir=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
         --enable-cxx \
+    && set +x \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $gmpPACKAGE"
@@ -249,6 +250,7 @@ else
         --prefix=$MPFR_ARCH_PATH \
         --libdir=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
         $configGMP $configOpt \
+    && set +x \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $mpfrPACKAGE"
@@ -301,6 +303,7 @@ else
         --prefix=$MPC_ARCH_PATH \
         --libdir=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
         $configGMP $configMPFR \
+    && set +x \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $mpcPACKAGE"
@@ -366,6 +369,7 @@ else
         --with-system-zlib \
         $configGMP $configMPFR $configMPC $configOpt \
         MAKEINFO=missing \
+    && set +x \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $gccPACKAGE"
diff --git a/makeGperftools b/makeGperftools
index 767921c..87cdc4c 100755
--- a/makeGperftools
+++ b/makeGperftools
@@ -130,6 +130,7 @@ else
         set -x
         $GPERFTOOLS_SOURCE_DIR/configure \
             --prefix=$GPERFTOOLS_ARCH_PATH \
+        && set +x \
         && make -j $WM_NCOMPPROCS \
         && make install \
         && echo "Built: $gperftoolsPACKAGE" \
diff --git a/makeLLVM b/makeLLVM
index c9ec115..1d45d3a 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -155,6 +155,7 @@ then
             --with-gcc-toolchain=$(which gcc | sed s%/bin/gcc%%) \
             --enable-optimized \
             --enable-shared \
+        && set +x \
         && make -j $WM_NCOMPPROCS \
         && make install \
         && echo "Built: $llvmPACKAGE"
@@ -183,6 +184,7 @@ else
             -DCMAKE_BUILD_TYPE=Release \
             -DBUILD_SHARED_LIBS=ON \
             $LLVM_SOURCE_DIR \
+        && set +x \
         && make -j $WM_NCOMPPROCS \
         && make install \
         && echo "Built: $llvmPACKAGE"
diff --git a/makeMesa b/makeMesa
index dc17402..edb8d81 100755
--- a/makeMesa
+++ b/makeMesa
@@ -151,6 +151,8 @@ MESA_ARCH_PATH=$installBASE/$mesaPACKAGE
 # - avoid GLES (GLES1) since <GLES/gl.h> may mask the <GL/gl.h> header
 adjustMESA()
 {
+    pkgconfigAdjust $MESA_ARCH_PATH
+
     \rm -rf $MESA_ARCH_PATH/include/GLES $MESA_ARCH_PATH/include/GLES1
     echo "removed all gles1 includes"
 }
@@ -202,10 +204,11 @@ adjustMESA()
         --enable-texture-float \
         --enable-gallium-osmesa --with-gallium-drivers=swrast \
         $configOpt \
-        && make -j $WM_NCOMPPROCS \
-        && make install \
-        && adjustMESA \
-        && echo "Built $mesaPACKAGE"
+    && set +x \
+    && make -j $WM_NCOMPPROCS \
+    && make install \
+    && echo "Built $mesaPACKAGE" \
+    && adjustMESA
 ) || {
     echo "Error building: MESA"
     exit 1
-- 
GitLab


From 9f6a77a1ab4f70fea565732c7e4310509a5d55be Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 20 Jan 2017 16:02:25 +0100
Subject: [PATCH 12/27] ENH: introduce a separate makeOPENMPI

- makes is easier to quickly build different versions and reduces
  clutter in Allwmake.

- provide some quick '-test' options for makeCGAL, makeFFTW etc
  to reduce duplication of logic in Allwmake.
---
 Allwmake    | 166 +++-----------------------------------------
 makeCGAL    |  27 ++++++++
 makeFFTW    |  15 ++++
 makeMPICH   | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 makeOPENMPI | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 439 insertions(+), 157 deletions(-)
 create mode 100755 makeMPICH
 create mode 100755 makeOPENMPI

diff --git a/Allwmake b/Allwmake
index e21941f..066fc48 100755
--- a/Allwmake
+++ b/Allwmake
@@ -74,140 +74,19 @@ echo
 echo ========================================
 echo Start ThirdParty Allwmake
 echo ========================================
-
-
 echo
 echo ========================================
 echo Build MPI libraries if required
 echo "    $MPI_ARCH_PATH"
 case "$WM_MPLIB" in
-OPENMPI)
-    if [ -r $MPI_ARCH_PATH/lib${WM_COMPILER_LIB_ARCH}/libmpi.so ]
-    then
-        echo "    have $WM_MPLIB shared library ($FOAM_MPI)"
-        echo
-    elif [ -r $MPI_ARCH_PATH/lib${WM_COMPILER_LIB_ARCH}/libmpi.a ]
-    then
-        echo "    have $WM_MPLIB static library ($FOAM_MPI)"
-        echo
-    else
-    (
-        # configuration options:
-        # Start with GridEngine support - builds without external libraries
-        configOpt="--with-sge"
-
-        # Add InfiniBand support
-        ibDir=/usr/local/ofed
-        ibLib=$infbDIR/lib${WM_COMPILER_LIB_ARCH}
-        if [ -d "$ibDir" -a -d "$ibLib" ]
-        then
-            configOpt="$configOpt --with-verbs=$ibDir --with-verbs-lib=$ibLib"
-        fi
-
-        # end of configuration options
-        # ----------------------------
-        mpiPACKAGE="${MPI_ARCH_PATH##*/}"
-        sourceDIR=$sourceBASE/$mpiPACKAGE
-        buildDIR=$buildBASE/$mpiPACKAGE
-
-        cd $sourceDIR || exit 1
-        [ -e Makefile ] && make distclean 2>/dev/null
-
-        rm -rf $MPI_ARCH_PATH
-        rm -rf $buildDIR
-        mkdir -p $buildDIR
-        cd $buildDIR
-
-        set -x
-        $sourceDIR/configure \
-            --prefix=$MPI_ARCH_PATH \
-            --disable-orterun-prefix-by-default \
-            --enable-shared --disable-static \
-            --libdir=$MPI_ARCH_PATH/lib${WM_COMPILER_LIB_ARCH} \
-            --enable-mpi-fortran=none \
-            --disable-mpi-profile \
-            $configOpt \
-        && set +x \
-        && make -j $WM_NCOMPPROCS \
-        && make install \
-        && echo "Built: $mpiPACKAGE" \
-        && pkgconfigAdjust $MPI_ARCH_PATH
-    ) || {
-        echo "Error building: $mpiPACKAGE"
-        exit 1
-    }
-    fi
-    ;;
-
-MPICH)
-    if [ -r $MPI_ARCH_PATH/lib/libmpich.so ]
-    then
-        echo "    have $WM_MPLIB shared library ($FOAM_MPI)"
-        echo
-    elif [ -r $MPI_ARCH_PATH/lib/libmpich.a ]
-    then
-        echo "    have $WM_MPLIB static library ($FOAM_MPI)"
-        echo
-    else
-    (
-        # WARNING: unmaintained build code:
-        # ---------------------------------
-        mpiPACKAGE="${MPI_ARCH_PATH##*/}"
-        sourceDIR=$sourceBASE/$mpiPACKAGE
-        cd $sourceDIR || exit 1
-
-        set -x
-        [ -e Makefile ] && make distclean 2>/dev/null
-        rm -rf $MPI_ARCH_PATH
-        rm -rf util/machines/machines.*
-
-        ./configure \
-            --prefix=$MPI_ARCH_PATH \
-            --without-mpe \
-            --disable-f77 \
-            --disable-f90 \
-            --disable-f90modules \
-            --disable-mpedbg \
-            --disable-devdebug \
-            --disable-debug \
-            --enable-sharedlib=$MPI_ARCH_PATH/lib \
-            --with-device=ch_p4 \
-            ;
-
-        # For MPICH2 below 1.5a1 uncomment this line and comment next
-        # make && make install
-
-        # For MPICH2 1.5a1 or above
-        make -j $WM_NCOMPPROCS && make install
-
-        make distclean
-
-        if [ -r $MPI_ARCH_PATH ]
-        then
-            cd $MPI_ARCH_PATH/bin
-            for file in *
-            do
-                sed s%$MPI_ARCH_PATH%'$MPI_ARCH_PATH'%g $file > temp.$$
-                mv temp.$$ $file
-                chmod 0755 $file
-            done
-
-            cd $MPI_ARCH_PATH/lib
-
-            if [ -r libmpich.so.1.0 ]
-            then
-                rm *.so
-                ln -s libmpich.so.1.0 libmpich.so
-            fi
-        fi
-    )
-    fi
+(OPENMPI | MPICH)
+    ./make$WM_MPLIB -test "$MPI_ARCH_PATH" || ./make$WM_MPLIB
     ;;
 esac
 
 
 #------------------------------------------------------------------------------
-# Building scotch is still a bit of a pain
+# Building scotch on different platforms is still a bit of a pain
 
 # Get SCOTCH_VERSION, SCOTCH_ARCH_PATH
 if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch)
@@ -367,7 +246,6 @@ if [ -f $METIS_ARCH_PATH/include/metis.h \
 then
     echo "    metis header in $METIS_ARCH_PATH/include"
     echo "    metis libs   in $FOAM_EXT_LIBBIN"
-    echo
 elif [ -d "$METIS_SOURCE_DIR" ]
 then
 (
@@ -393,54 +271,28 @@ fi
 
 
 #------------------------------------------------------------------------------
-
-# CGAL is optional
 echo
 echo ========================================
 echo Build CGAL
-if [ -d "$CGAL_ARCH_PATH/include" \
-  -a -r "$CGAL_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libCGAL.so" ]
-then
-    # first some information about boost
-    for root in "$BOOST_ARCH_PATH" /usr
-    do
-        if [ -d "$root/include/boost" \
-          -a -r "$root/lib$WM_COMPILER_LIB_ARCH/libboost_system.so" ]
-        then
-            echo "    BOOST headers in $root/include"
-            echo "    BOOST libs    in $root/lib$WM_COMPILER_LIB_ARCH"
-            break
-        fi
-    done
-    echo "    CGAL  headers in $CGAL_ARCH_PATH/include"
-    echo "    CGAL  libs    in $CGAL_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
-elif [ -n "$CGAL_ARCH_PATH" ]
+if [ -n "$CGAL_ARCH_PATH" ]
 then
+    ./makeCGAL -test "$CGAL_ARCH_PATH" "$BOOST_ARCH_PATH" || \
     ./makeCGAL || warnBuildIssues CGAL
 else
-    warnNotFound CGAL
+    warnNotFound CGAL   # CGAL is optional
 fi
 
-
-# FFTW is optional
 echo
 echo ========================================
 echo Build FFTW
-if [ -d "$FFTW_ARCH_PATH/include" \
-  -a -r "$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libfftw3.so" ]
-then
-    echo "    FFTW  headers in $FFTW_ARCH_PATH/include"
-    echo "    FFTW  libs    in $FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
-elif [ -n "$FFTW_ARCH_PATH" ]
+if [ -n "$FFTW_ARCH_PATH" ]
 then
+    ./makeFFTW -test "$FFTW_ARCH_PATH" || \
     ./makeFFTW || warnBuildIssues FFTW
 else
-    warnNotFound FFTW
+    warnNotFound FFTW   # FFTW is optional
 fi
 
-
-#------------------------------------------------------------------------------
-
 echo
 echo ========================================
 echo Done ThirdParty Allwmake
diff --git a/makeCGAL b/makeCGAL
index a3db8aa..60d15e2 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -37,6 +37,33 @@
 # ----------------------------------------------
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
+# Short-circuit test for an installation
+if [ "$1" = "-test" ]
+then
+    [ "$#" -eq 3 ] || { echo "${0##*/} -test : needs 2 argument"; exit 1; }
+    dir="$2" # <- CGAL_ARCH_PATH
+    if [ -d "$dir/include" -a -r "$dir/lib$WM_COMPILER_LIB_ARCH/libCGAL.so" ]
+    then
+        echo "    CGAL  headers in $dir/include"
+        echo "    CGAL  libs    in $dir/lib$WM_COMPILER_LIB_ARCH"
+        # Additional information about boost
+        dir="$3" # <- BOOST_ARCH_PATH
+        for root in "$dir" /usr
+        do
+            if [ -d "$root/include/boost" \
+              -a -r "$root/lib$WM_COMPILER_LIB_ARCH/libboost_system.so" ]
+            then
+                echo "    BOOST headers in $root/include"
+                echo "    BOOST libs    in $root/lib$WM_COMPILER_LIB_ARCH"
+                break
+            fi
+        done
+        exit 0
+    else
+        exit 2
+    fi
+fi
+#------------------------------------------------------------------------------
 # Run from third-party directory only
 cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
diff --git a/makeFFTW b/makeFFTW
index fc8a10e..437efab 100755
--- a/makeFFTW
+++ b/makeFFTW
@@ -31,6 +31,21 @@
 # ----------------------------------------------
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
+# Short-circuit test for an installation
+if [ "$1" = "-test" ]
+then
+    [ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
+    dir="$2" # <- FFTW_ARCH_PATH
+    if [ -d "$dir/include" -a -r "$dir/lib$WM_COMPILER_LIB_ARCH/libfftw3.so" ]
+    then
+        echo "    FFTW headers in $dir/include"
+        echo "    FFTW libs    in $dir/lib$WM_COMPILER_LIB_ARCH"
+        exit 0
+    else
+        exit 2
+    fi
+fi
+#------------------------------------------------------------------------------
 # Run from third-party directory only
 cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
diff --git a/makeMPICH b/makeMPICH
new file mode 100755
index 0000000..9514c85
--- /dev/null
+++ b/makeMPICH
@@ -0,0 +1,195 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+#    \\/     M anipulation  |
+#------------------------------------------------------------------------------
+# License
+#     This file is part of OpenFOAM.
+#
+#     OpenFOAM is free software: you can redistribute it and/or modify it
+#     under the terms of the GNU General Public License as published by
+#     the Free Software Foundation, either version 3 of the License, or
+#     (at your option) any later version.
+#
+#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#     for more details.
+#
+#     You should have received a copy of the GNU General Public License
+#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Script
+#     makeMPICH
+#
+# Description
+#     Build script for mpich - legacy (unmaintained) build code!
+#
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
+#------------------------------------------------------------------------------
+# Short-circuit test for an installation
+if [ "$1" = "-test" ]
+then
+    [ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
+    dir="$2" # <- MPI_ARCH_PATH
+    if [ -r "$dir/lib/libmpich.so" ]
+    then
+        echo "Have mpich shared library"
+        exit 0
+    elif [ -r "$dir/lib/libmpich.a" ]
+    then
+        echo "Have mpich static library"
+        exit 0
+    else
+        echo "No mpich libraries found: ${dir:-not-specified}"
+        exit 2
+    fi
+fi
+#------------------------------------------------------------------------------
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+# get mpich version
+WM_MPLIB=MPICH       # ensure we get the third-party settings
+
+. $WM_PROJECT_DIR/etc/config.sh/functions
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi)
+
+mpiPACKAGE=${FOAM_MPI:-mpich-system}
+#------------------------------------------------------------------------------
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: ${0##*/} [OPTION] [openmpi-VERSION]
+options:
+  -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
+  -help
+
+* build mpich with
+      ${mpiPACKAGE:-'unspecified mpich version'}
+
+USAGE
+    exit 1
+}
+#------------------------------------------------------------------------------
+# Ensure configure gets the correct C/C++ compiler
+[ -n "$WM_CC" ]  && export CC="$WM_CC"
+[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
+
+# Parse options
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    '')
+        # discard empty arguments
+        ;;
+    -gcc)
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
+        ;;
+    mpich*)
+        mpiPACKAGE="${1%%/}"
+        ;;
+    *)
+        die "unknown option/argument: '$1'"
+        ;;
+    esac
+    shift
+done
+
+[ -n "$mpiPACKAGE" ] || die "The mpich-VERSION was not specified"
+
+# Nothing to build
+if _foamIsNone "$mpiPACKAGE"
+then
+    echo "Using mpich-none (skip ThirdParty build of mpich)"
+    exit 0
+elif _foamIsSystem "$mpiPACKAGE"
+then
+    echo "Using mpich-system (skip ThirdParty build of mpich)"
+    exit 0
+fi
+
+#------------------------------------------------------------------------------
+#
+# Build openmpi
+#
+#   MPI_SOURCE_DIR : location of the original sources
+#   MPI_ARCH_PATH  : installation directory
+
+MPI_SOURCE_DIR=$sourceBASE/$mpiPACKAGE
+MPI_ARCH_PATH=$installBASE/$mpiPACKAGE
+
+if [ -r "$MPI_ARCH_PATH/lib_ARCH/libmpi.so" ]
+then
+    echo "Already has shared library"
+elif [ -r "$MPI_ARCH_PATH/lib/libmpi.a" ]
+then
+    echo "Already has static library"
+else
+    echo "Starting build: $WM_MPLIB ($mpiPACKAGE)"
+    echo
+
+    (
+        # WARNING: unmaintained build code:
+        # ---------------------------------
+        cd $MPI_SOURCE_DIR || exit 1
+
+        set -x
+        [ -e Makefile ] && make distclean 2>/dev/null
+        rm -rf $MPI_ARCH_PATH
+        rm -rf util/machines/machines.*
+
+        ./configure \
+            --prefix=$MPI_ARCH_PATH \
+            --without-mpe \
+            --disable-f77 --disable-f90 --disable-f90modules \
+            --disable-debug --disable-mpedbg --disable-devdebug \
+            --enable-sharedlib=$MPI_ARCH_PATH/lib \
+            --with-device=ch_p4 \
+            ;
+
+        # For MPICH2 below 1.5a1 uncomment this line and comment next
+        # make && make install
+
+        # For MPICH2 1.5a1 or above
+        make -j $WM_NCOMPPROCS && make install
+
+        make distclean
+
+        if [ -r $MPI_ARCH_PATH ]
+        then
+            cd $MPI_ARCH_PATH/bin
+            for file in *
+            do
+                sed s%$MPI_ARCH_PATH%'$MPI_ARCH_PATH'%g $file > temp.$$
+                mv temp.$$ $file
+                chmod 0755 $file
+            done
+
+            cd $MPI_ARCH_PATH/lib
+
+            if [ -r libmpich.so.1.0 ]
+            then
+                rm *.so
+                ln -s libmpich.so.1.0 libmpich.so
+            fi
+        fi
+    )
+fi
+
+#------------------------------------------------------------------------------
diff --git a/makeOPENMPI b/makeOPENMPI
new file mode 100755
index 0000000..a3a03ff
--- /dev/null
+++ b/makeOPENMPI
@@ -0,0 +1,193 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+#    \\/     M anipulation  |
+#------------------------------------------------------------------------------
+# License
+#     This file is part of OpenFOAM.
+#
+#     OpenFOAM is free software: you can redistribute it and/or modify it
+#     under the terms of the GNU General Public License as published by
+#     the Free Software Foundation, either version 3 of the License, or
+#     (at your option) any later version.
+#
+#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#     for more details.
+#
+#     You should have received a copy of the GNU General Public License
+#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Script
+#     makeOPENMPI
+#
+# Description
+#     Build script for openmpi
+#
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
+#------------------------------------------------------------------------------
+# Short-circuit test for an installation
+if [ "$1" = "-test" ]
+then
+    [ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
+    dir="$2" # <- MPI_ARCH_PATH
+    if [ -r "$dir/lib$WM_COMPILER_LIB_ARCH/libmpi.so" ]
+    then
+        echo "    Have openmpi shared library (${dir##*/})"
+        exit 0
+    elif [ -r "$dir/lib$WM_COMPILER_LIB_ARCH/libmpi.a" ]
+    then
+        echo "    Have openmpi static library (${dir##*/})"
+        exit 0
+    else
+        echo "No openmpi libraries found: ${dir:-not-specified}"
+        exit 2
+    fi
+fi
+#------------------------------------------------------------------------------
+# Run from third-party directory only
+cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
+    echo "    Check your OpenFOAM environment and installation"
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+# get openmpi version
+WM_MPLIB=OPENMPI       # ensure we get the third-party settings
+
+. $WM_PROJECT_DIR/etc/config.sh/functions
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi)
+
+mpiPACKAGE=${FOAM_MPI:-openmpi-system}
+#------------------------------------------------------------------------------
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: ${0##*/} [OPTION] [openmpi-VERSION]
+options:
+  -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
+  -help
+
+* build openmpi with
+      ${mpiPACKAGE:-'unspecified openmpi version'}
+
+USAGE
+    exit 1
+}
+#------------------------------------------------------------------------------
+# Ensure configure gets the correct C/C++ compiler
+[ -n "$WM_CC" ]  && export CC="$WM_CC"
+[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
+
+# Parse options
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    '')
+        # discard empty arguments
+        ;;
+    -gcc)
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
+        ;;
+    openmpi-[0-9]* | openmpi_[0-9]* | openmpi-system )
+        mpiPACKAGE="${1%%/}"
+        ;;
+    *)
+        die "unknown option/argument: '$1'"
+        ;;
+    esac
+    shift
+done
+
+[ -n "$mpiPACKAGE" ] || die "The openmpi-VERSION was not specified"
+
+# Nothing to build
+if _foamIsNone "$mpiPACKAGE"
+then
+    echo "Using openmpi-none (skip ThirdParty build of openmpi)"
+    exit 0
+elif _foamIsSystem "$mpiPACKAGE"
+then
+    echo "Using openmpi-system (skip ThirdParty build of openmpi)"
+    exit 0
+fi
+
+#------------------------------------------------------------------------------
+#
+# Build openmpi
+#
+#   MPI_SOURCE_DIR : location of the original sources
+#   MPI_ARCH_PATH  : installation directory
+
+MPI_SOURCE_DIR=$sourceBASE/$mpiPACKAGE
+MPI_ARCH_PATH=$installBASE/$mpiPACKAGE
+
+if [ -r "$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmpi.so" ]
+then
+    echo "Already has shared library"
+elif [ -r "$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmpi.a" ]
+then
+    echo "Already has static library"
+else
+    echo "Starting build: $WM_MPLIB ($mpiPACKAGE)"
+    echo
+
+    (
+        # configuration options:
+        # Start with GridEngine support - builds without external libraries
+        configOpt="--with-sge"
+
+        # Add InfiniBand support
+        ibDir=/usr/local/ofed
+        ibLib=$infbDIR/lib$WM_COMPILER_LIB_ARCH
+        if [ -d "$ibDir" -a -d "$ibLib" ]
+        then
+            configOpt="$configOpt --with-verbs=$ibDir --with-verbs-lib=$ibLib"
+        fi
+
+        # end of configuration options
+        # ----------------------------
+
+        buildDIR=$buildBASE/$mpiPACKAGE
+
+        cd $MPI_SOURCE_DIR || exit 1
+        [ -e Makefile ] && make distclean 2>/dev/null
+
+        rm -rf $MPI_ARCH_PATH
+        rm -rf $buildDIR
+        mkdir -p $buildDIR
+        cd $buildDIR
+
+        set -x
+        $MPI_SOURCE_DIR/configure \
+            --prefix=$MPI_ARCH_PATH \
+            --disable-orterun-prefix-by-default \
+            --enable-shared --disable-static \
+            --libdir=$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+            --enable-mpi-fortran=none \
+            --disable-mpi-profile \
+            $configOpt \
+        && set +x \
+        && make -j $WM_NCOMPPROCS \
+        && make install \
+        && echo "Built: $mpiPACKAGE" \
+        && pkgconfigAdjust $MPI_ARCH_PATH
+    ) || {
+        echo "Error building: $mpiPACKAGE"
+        exit 1
+    }
+fi
+
+#------------------------------------------------------------------------------
-- 
GitLab


From 5c09a6433fc38359b39a09a61bc958592d5a15f0 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 24 Jan 2017 22:10:21 +0100
Subject: [PATCH 13/27] COMP: avoid building CGAL ImageIO lib (fixes #15)

- OpenFOAM doesn't use any of the CGAL image library and the ImageIO
  library adds in an unnecessary OpenGL dependency (reported to fail
  on kubuntu-14.04)

STYLE: adjust documented link to main (non-svn) VisIt project directory
---
 BUILD.md | 3 ++-
 makeCGAL | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/BUILD.md b/BUILD.md
index 5148f5e..44206e8 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -415,7 +415,8 @@ The minimum gcc/g++ requirements for building various components.
 [link FFTW]:      http://www.fftw.org/fftw-3.3.5.tar.gz
 
 [page cgns]:      http://cgns.github.io/
-[link ccmio]:     http://portal.nersc.gov/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz (check usage conditions)
+[link ccmio]:     http://portal.nersc.gov/project/visit/third_party/libccmio-2.6.1.tar.gz (check usage conditions)
+[altlink ccmio]:  http://portal.nersc.gov/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz (check usage conditions)
 
 [page tecio]:     http://www.tecplot.com/
 [link tecio]:     http://www.tecplot.com/my/tecio-library/ (needs registration)
diff --git a/makeCGAL b/makeCGAL
index 60d15e2..e8b7045 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -475,6 +475,7 @@ CMAKE_OPTIONS
         -DCMAKE_INSTALL_PREFIX=$CGAL_ARCH_PATH \
         -DCGAL_INSTALL_LIB_DIR=lib$WM_COMPILER_LIB_ARCH \
         -DCMAKE_BUILD_TYPE=Release \
+        -DWITH_CGAL_ImageIO=OFF \
         -DWITH_CGAL_Qt5=OFF \
         ${optHeadersOnly:+-DCGAL_HEADER_ONLY=TRUE} \
         $configBoost $configGmp $configMpfr \
-- 
GitLab


From 1189ff23c9cfd63ae302ec13ea71227a2f902599 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 1 Feb 2017 09:49:05 +0000
Subject: [PATCH 14/27] BUG: pkgconfigPrefix calling the incorrect backend

ENH: avoid editing pkgconfig symlinks
---
 etc/pkgconfigPrefix           | 2 +-
 etc/tools/ThirdPartyFunctions | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/etc/pkgconfigPrefix b/etc/pkgconfigPrefix
index 849eb83..5c8156e 100755
--- a/etc/pkgconfigPrefix
+++ b/etc/pkgconfigPrefix
@@ -76,7 +76,7 @@ do
         usage
         ;;
     *)
-        pkgconfigAdjust "$1"
+        pkgconfigNewPrefix "$1"
         ;;
     esac
     shift
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index fd57ed1..b76e9a3 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -281,7 +281,7 @@ pkgconfigNewPrefix()
         [ -d "$dir/$libdir" ] || continue
         for i in $dir/$libdir/*.pc
         do
-            if [ -f "$i" ]
+            if [ -f "$i" -a ! -L "$i" ]
             then
                 nfiles="x$nfiles"
                 sed -i -e 's@^\(prefix=\).*$@\1'"$dir@" $i
@@ -329,7 +329,7 @@ pkgconfigAdjust()
         [ -d "$dir/$libdir" ] || continue
         for i in $dir/$libdir/*.pc
         do
-            if [ -f "$i" ]
+            if [ -f "$i" -a ! -L "$i" ]
             then
                 nfiles="x$nfiles"
                 sed -i \
-- 
GitLab


From 493d4b01aca9a332bafb93cd6c6da0c58ad2c67a Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 1 Feb 2017 17:41:48 +0000
Subject: [PATCH 15/27] ENH: provide -link option for makeCmake

- this creates a cmake-system link to the given cmake version, which
  is a simple means of providing an updated cmake version for the
  OpenFOAM build without actually needing to edit the
  etc/config.sh/paraview file
---
 makeCmake | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/makeCmake b/makeCmake
index 6f566b9..5dce1b5 100755
--- a/makeCmake
+++ b/makeCmake
@@ -26,7 +26,10 @@
 #     makeCmake
 #
 # Description
-#     Build script for cmake
+#     Build script for cmake.
+#
+#     The '-link' option can be used to create a 'cmake-system' pointing
+#     to this version.
 #
 # ----------------------------------------------
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
@@ -50,6 +53,7 @@ usage() {
 usage: ${0##*/} [OPTION] cmake-VERSION
 options:
   -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
+  -link             Create additional symlink as 'cmake-system'
   -help
 
 * build cmake
@@ -63,6 +67,7 @@ USAGE
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
+unset optLink
 # Parse options
 while [ "$#" -gt 0 ]
 do
@@ -74,6 +79,9 @@ do
         export CC=gcc   # use gcc/g++
         export CXX=g++
         ;;
+    -link)
+        optLink=true
+        ;;
     cmake-[1-9]*)
         cmakePACKAGE="${1%%/}"
         ;;
@@ -86,6 +94,11 @@ done
 
 [ -n "$cmakePACKAGE" ] || die "The cmake-VERSION was not specified"
 
+if _foamIsSystem "$cmakePACKAGE"
+then
+    unset optLink # basic sanity - cannot
+fi
+
 #------------------------------------------------------------------------------
 #
 # Build CMAKE
@@ -121,4 +134,19 @@ else
     }
 fi
 
+if [ "$optLink" = true -a -x "$CMAKE_ARCH_PATH/bin/cmake" ]
+then
+(
+    cd ${CMAKE_ARCH_PATH%/*} || exit 1
+    if [ -L cmake-system ]
+    then
+        rm cmake-system
+    elif [ -d cmake-system ]
+    then
+        exit 2
+    fi
+    ln -svf $cmakePACKAGE cmake-system
+)
+fi
+
 #------------------------------------------------------------------------------
-- 
GitLab


From 5d592841fd268afee54701757e93aca297b60dae Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 14 Mar 2017 15:08:09 +0100
Subject: [PATCH 16/27] COMP: update makeMPICH for mpich-3.2

- not necessarily supported by OpenFOAM, but at least the build script
  works again, and the build is now out-of-source.
---
 makeMPICH | 72 ++++++++++++++++++++++---------------------------------
 1 file changed, 28 insertions(+), 44 deletions(-)

diff --git a/makeMPICH b/makeMPICH
index 9514c85..dd7b8fc 100755
--- a/makeMPICH
+++ b/makeMPICH
@@ -36,13 +36,13 @@ if [ "$1" = "-test" ]
 then
     [ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
     dir="$2" # <- MPI_ARCH_PATH
-    if [ -r "$dir/lib/libmpich.so" ]
+    if [ -r "$dir/lib$WM_COMPILER_LIB_ARCH/libmpich.so" ]
     then
-        echo "Have mpich shared library"
+        echo "Have mpich shared library (${dir##*/})"
         exit 0
-    elif [ -r "$dir/lib/libmpich.a" ]
+    elif [ -r "$dir/lib$WM_COMPILER_LIB_ARCH/libmpich.a" ]
     then
-        echo "Have mpich static library"
+        echo "Have mpich static library (${dir##*/})"
         exit 0
     else
         echo "No mpich libraries found: ${dir:-not-specified}"
@@ -145,51 +145,35 @@ else
     echo
 
     (
-        # WARNING: unmaintained build code:
-        # ---------------------------------
-        cd $MPI_SOURCE_DIR || exit 1
+        # configuration options:
+        unset configOpt
+        # end of configuration options
+        # ----------------------------
 
-        set -x
+        cd $MPI_SOURCE_DIR || exit 1
         [ -e Makefile ] && make distclean 2>/dev/null
+
         rm -rf $MPI_ARCH_PATH
-        rm -rf util/machines/machines.*
+        rm -rf $buildDIR
+        mkdir -p $buildDIR
+        cd $buildDIR
 
-        ./configure \
+        set -x
+        $MPI_SOURCE_DIR/configure \
             --prefix=$MPI_ARCH_PATH \
-            --without-mpe \
-            --disable-f77 --disable-f90 --disable-f90modules \
-            --disable-debug --disable-mpedbg --disable-devdebug \
-            --enable-sharedlib=$MPI_ARCH_PATH/lib \
-            --with-device=ch_p4 \
-            ;
-
-        # For MPICH2 below 1.5a1 uncomment this line and comment next
-        # make && make install
-
-        # For MPICH2 1.5a1 or above
-        make -j $WM_NCOMPPROCS && make install
-
-        make distclean
-
-        if [ -r $MPI_ARCH_PATH ]
-        then
-            cd $MPI_ARCH_PATH/bin
-            for file in *
-            do
-                sed s%$MPI_ARCH_PATH%'$MPI_ARCH_PATH'%g $file > temp.$$
-                mv temp.$$ $file
-                chmod 0755 $file
-            done
-
-            cd $MPI_ARCH_PATH/lib
-
-            if [ -r libmpich.so.1.0 ]
-            then
-                rm *.so
-                ln -s libmpich.so.1.0 libmpich.so
-            fi
-        fi
-    )
+            --disable-fortran --disable-g \
+            --libdir=$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+            --enable-shared --disable-static \
+            $configOpt \
+        && set +x \
+        && make -j $WM_NCOMPPROCS \
+        && make install \
+        && echo "Built: $mpiPACKAGE" \
+        && pkgconfigAdjust $MPI_ARCH_PATH
+    ) || {
+        echo "Error building: $mpiPACKAGE"
+        exit 1
+    }
 fi
 
 #------------------------------------------------------------------------------
-- 
GitLab


From 59be96faedea69a8a613b07998ebc2a1dc120396 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 14 Mar 2017 15:37:21 +0100
Subject: [PATCH 17/27] ENH: remove reliance on OpenFOAM
 etc/config.sh/functions file.

- similar functionality in etc/tools/ThirdPartyFunctions to improve
  the independence of ThirdParty while reducing clutter in the callers.

- add useGcc function for convenience
- mask seeing our own git-repo when building

STYLE: various items

- eliminate old user-editable configuration in files - now command-line only.
- use *_BUILD_DIR instead of *_BINARY_DIR for more clarity of the purpose
- drop use of '-q' option for wmakeCheckPwd (already has stderr redirect)
- drop checkVersion for makeParaView since it stopped working properly
  with newer paraview version

CONFIG: update list of versions
---
 Allclean                      |  7 ++-
 Allwmake                      | 79 ++++++++++++++++++---------------
 BUILD.md                      | 49 ++++++++++-----------
 etc/pkgconfigAdjust           |  8 ++--
 etc/pkgconfigPrefix           |  8 ++--
 etc/relocateQt                | 16 +++----
 etc/tools/ParaViewFunctions   | 50 ++++++---------------
 etc/tools/QtFunctions         |  7 +++
 etc/tools/ThirdPartyFunctions | 24 ++++++++++
 etc/tools/vtkFunctions        | 27 ++++++------
 makeADIOS                     | 31 ++++++-------
 makeCCMIO                     | 49 +++++++++++----------
 makeCGAL                      | 51 ++++++++++-----------
 makeCmake                     | 18 ++++----
 makeFFTW                      | 26 +++++------
 makeGcc                       | 47 ++++++++++++--------
 makeGperftools                | 26 +++++------
 makeLLVM                      | 44 +++++++++----------
 makeMPICH                     | 37 ++++++++--------
 makeMesa                      | 35 ++++++++-------
 makeOPENMPI                   | 35 ++++++++-------
 makeParaView                  | 83 +++++++++++++----------------------
 makeQt                        | 19 +++-----
 makeTecio                     | 67 +++++++++++++---------------
 makeVTK                       | 62 ++++++++++----------------
 minCmake                      |  4 +-
 26 files changed, 437 insertions(+), 472 deletions(-)

diff --git a/Allclean b/Allclean
index 6c3e0b0..b50475c 100755
--- a/Allclean
+++ b/Allclean
@@ -32,7 +32,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -66,7 +66,10 @@ fi
 #------------------------------------------------------------------------------
 
 # Clean various packages via 'distclean'
-for i in openmpi-* metis-* adios-* ADIOS-*
+for i in \
+    openmpi-* metis-* adios-* ADIOS-* gperftools-* qt-* \
+    gmp-* mpfr-* mpc-* gcc-* llvm-* \
+;
 do
     [ -d "$i" ] && (
         echo
diff --git a/Allwmake b/Allwmake
index 066fc48..8ca2948 100755
--- a/Allwmake
+++ b/Allwmake
@@ -32,7 +32,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -44,7 +44,7 @@ cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# Export WM settings in a form that GNU configure recognizes
+# Compiler/linker settings for CMake/configure
 [ -n "$WM_CC" ]         &&  export CC="$WM_CC"
 [ -n "$WM_CXX" ]        &&  export CXX="$WM_CXX"
 [ -n "$WM_CFLAGS" ]     &&  export CFLAGS="$WM_CFLAGS"
@@ -105,7 +105,7 @@ echo "    $SCOTCH_ARCH_PATH"
 
 SCOTCH_SOURCE_DIR=$sourceBASE/$SCOTCH_VERSION
 
-# This needs generalizing, but works fairly well
+# Needs generalizing, but works fairly well
 scotchMakefile=../../etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
 
 if [ -f $SCOTCH_ARCH_PATH/include/scotch.h \
@@ -118,53 +118,56 @@ elif [ -d "$SCOTCH_SOURCE_DIR" ]
 then
 (
     cd $SCOTCH_SOURCE_DIR/src || exit 1
+    export GIT_DIR=$SCOTCH_SOURCE_DIR/.git # Mask seeing our own git-repo
     rm -rf $SCOTCH_ARCH_PATH
 
     applyPatch $SCOTCH_VERSION ..       # patch at parent-level
 
     prefixDIR=$SCOTCH_ARCH_PATH
+    incDIR=$SCOTCH_ARCH_PATH/include
     libDIR=$FOAM_EXT_LIBBIN
 
     mkdir -p $prefixDIR 2>/dev/null
-    mkdir -p $libDIR 2>/dev/null
+    mkdir -p $incDIR    2>/dev/null
+    mkdir -p $libDIR    2>/dev/null
 
-    configOpt="prefix=$prefixDIR libdir=$libDIR"
+    # 'CC' already set (eg, from WM_CC) - set scotch-specific 'CCS' too
+    [ -n "$CC" ] && export CCS="$CC"
 
     if [ -f $scotchMakefile ]
     then
         rm -f Makefile.inc
         ln -s $scotchMakefile Makefile.inc
     fi
-
     [ -f Makefile.inc ] || {
         echo " Error: scotch needs an appropriate Makefile.inc"
         exit 1
     }
 
-    # handle non-gcc compilers
-    unset configEnv
-    [ "${WM_CC:-gcc}" != gcc ] && configEnv="CC=$WM_CC CCS=$WM_CC"
-
-    make realclean 2>/dev/null  # for safety
+    make realclean 2>/dev/null                  # Extra safety
 
-    make -j $WM_NCOMPPROCS $configEnv scotch \
-    && make $configOpt install
+    make -j $WM_NCOMPPROCS scotch \
+     && make \
+        prefix=$prefixDIR \
+        includedir=$incDIR \
+        libdir=$libDIR \
+        install
 
-    # cleanup, could also remove Makefile.inc
-    make realclean 2>/dev/null
+    make realclean 2>/dev/null || true          # Failed cleanup is uncritical
 ) || warnBuildIssues SCOTCH
 else
     warnNotFound SCOTCH
 fi
 
 # Build ptscotch if MPI (ThirdParty or system) is available
-# and normal scotch was build (has include and library)
+# and normal scotch was built (has include and library)
 if [ "${FOAM_MPI:-dummy}" != dummy ] && \
    [ -f $SCOTCH_ARCH_PATH/include/scotch.h \
   -a -r $FOAM_EXT_LIBBIN/libscotch.so ] || \
 {
+    # Report that the above tests failed and pass-through the failure
     echo
-    echo "    WARNING: skipping pt-scotch - 'scotch.h' include file not found!"
+    echo "    WARNING: skipping pt-scotch - no mpi or <scotch.h> not found"
     false
 }
 then
@@ -182,6 +185,7 @@ then
     else
     (
         cd $SCOTCH_SOURCE_DIR/src || exit 1
+        export GIT_DIR=$SCOTCH_SOURCE_DIR/.git # Mask seeing our own git-repo
         echo
 
         prefixDIR=$SCOTCH_ARCH_PATH
@@ -189,42 +193,44 @@ then
         libDIR=$FOAM_EXT_LIBBIN/$FOAM_MPI
 
         mkdir -p $prefixDIR 2>/dev/null
-        mkdir -p $libDIR 2>/dev/null
+        mkdir -p $incDIR    2>/dev/null
+        mkdir -p $libDIR    2>/dev/null
 
-        configOpt="prefix=$prefixDIR includedir=$incDIR libdir=$libDIR"
+        # 'CC' already set (eg, from WM_CC) - set scotch-specific 'CCS' too
+        [ -n "$CC" ] && export CCS="$CC"
 
         if [ -f $scotchMakefile ]
         then
             rm -f Makefile.inc
             ln -s $scotchMakefile Makefile.inc
         fi
-
         [ -f Makefile.inc ] || {
-            echo " Error: scotch needs an appropriate Makefile.inc"
+            echo " Error: ptscotch needs an appropriate Makefile.inc"
             exit 1
         }
 
-        # handle non-gcc compilers
-        unset configEnv
-        [ "${WM_CC:-gcc}" != gcc ] && configEnv="CC=$WM_CC CCS=$WM_CC"
+        make realclean 2>/dev/null              # Extra safety
 
-        make realclean 2>/dev/null  # for safety
+        make -j $WM_NCOMPPROCS ptscotch \
+         && make \
+            prefix=$prefixDIR \
+            includedir=$incDIR \
+            libdir=$libDIR \
+            install
 
-        make -j $WM_NCOMPPROCS $configEnv ptscotch \
-        && make $configOpt install
-
-        # cleanup, could also remove Makefile.inc
-        make realclean 2>/dev/null
-    )
+        make realclean 2>/dev/null || true      # Failed cleanup is uncritical
+    ) || warnBuildIssues PTSCOTCH
     fi
 
-    # verify existence of ptscotch include
+    # Verify existence of ptscotch include
     [ -f $SCOTCH_ARCH_PATH/include/$FOAM_MPI/ptscotch.h ] || {
         echo
         echo "    WARNING: required include file 'ptscotch.h' not found!"
     }
 fi
 
+# Could now remove $SCOTCH_SOURCE_DIR/src/Makefile.inc
+
 
 #------------------------------------------------------------------------------
 
@@ -233,7 +239,7 @@ echo
 echo ========================================
 echo Build Metis decomposition
 
-# get METIS_VERSION, METIS_ARCH_PATH
+# Get METIS_VERSION, METIS_ARCH_PATH
 if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis)
 then
     . $settings
@@ -250,6 +256,7 @@ elif [ -d "$METIS_SOURCE_DIR" ]
 then
 (
     cd $METIS_SOURCE_DIR || exit 1
+    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
     rm -rf $METIS_ARCH_PATH
 
     # Adjust metis integer size to match OpenFOAM label-size
@@ -260,10 +267,10 @@ then
     # - build normally and use mv to relocate it
 
     make config shared=1 prefix=$METIS_ARCH_PATH \
-    && make -j $WM_NCOMPPROCS install \
-    && mv $METIS_ARCH_PATH/lib/libmetis.so $FOAM_EXT_LIBBIN
+     && make -j $WM_NCOMPPROCS install \
+     && mv $METIS_ARCH_PATH/lib/libmetis.so $FOAM_EXT_LIBBIN
 
-    rmdir $METIS_ARCH_PATH/lib 2>/dev/null || true # failure is not critical
+    rmdir $METIS_ARCH_PATH/lib 2>/dev/null || true # Failed rmdir is uncritical
 ) || warnBuildIssues METIS
 else
     warnNotFound METIS
diff --git a/BUILD.md b/BUILD.md
index 44206e8..43ca1f9 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -184,13 +184,13 @@ and save some disk space.
   sources that are bundled with ParaView.
   For example, by using a symbolic link:
 
-      ln -s ParaView-5.0.1/VTK  VTK-7.1.0
+      ln -s ParaView-v5.3.0/VTK  VTK-7.1.0
 
   The appropriate VTK version number can be found from the contents of
   the `vtkVersion.cmake` file.
   For example,
 
-      $ cat ParaView-5.0.1/VTK/CMake/vtkVersion.cmake
+      $ cat ParaView-v5.3.0/VTK/CMake/vtkVersion.cmake
 
       # VTK version number components.
       set(VTK_MAJOR_VERSION 7)
@@ -198,18 +198,17 @@ and save some disk space.
       set(VTK_BUILD_VERSION 0)
 
 ### ParaView
-- **ParaView-5.0.1** is the last version for which the OpenFOAM reader
-  modules (eg, to visualize a `blockMeshDict`) work in their present form.
-
 - Building ParaView requires CMake, qmake and a `qt` development files.
   Use the `-cmake`, `-qmake` and `-qt-*` options for `makeParaView` as
   required.
   See additional notes below about [making Qt](#makeQt) if necessary.
 
+#### 5.3.0
+- Compiles without patching.
+  No known issues with the native OpenFOAM reader.
+
 #### 5.2.0
-- Compiles without patching, but the OpenFOAM reader modules
-  (eg, to visualize a `blockMeshDict`) have not yet been migrated
-  to this version. Note that the native OpenFOAM reader appears to be
+- Compiles without patching, but the native OpenFOAM reader appears to be
   partially broken in this version.
 
 #### 4.4.0/5.0.0/5.0.1/5.1.2
@@ -245,7 +244,7 @@ and save some disk space.
 
        ./makeParaView -qt-4.8.7 5.0.1
 
-- ParaView does not yet support QT5 (Dec-2016, but this will soon change).
+- ParaView versions prior to 5.3.0 do not properly support QT5.
 
 - If you relocate the third-party directory to another location
   (eg, you built in your home directory, but want to install it in a
@@ -332,8 +331,8 @@ GNU *configure* can only be used prior to clang version 3.9.
 | Name                  | Location
 |-----------------------|------------------------
 | [MESA][page mesa]     | [download][link mesa] or [older][older mesa]
-| [ParaView][page ParaView] | [download][link ParaView]. The reader modules do not yet work with the newest paraview versions.
-| [Qt][page Qt]         | [repo][repo Qt] or [download][link Qt]. The newer [Qt5][newer Qt5] is **not** currently supported by ParaView.
+| [ParaView][page ParaView] | [download][link ParaView]
+| [Qt][page Qt]         | [repo][repo Qt] or [download][link Qt]. The newer [Qt5][newer Qt5] only works with ParaView-5.3.0 and later.
 
 
 ### CMake Minimum Requirements <a name="min-cmake"></a>
@@ -348,7 +347,8 @@ The minimum CMake requirements for building various components.
     2.8.4       cmake-3.6.0
     3.3         ParaView-5.1.2
     3.3         ParaView-5.2.0
-    3.4.3       llvm-3.9.0.src
+    3.3         ParaView-5.3.0
+    3.4.3       llvm-3.9.1
     3.5         ParaView-5.1.0
 
 
@@ -378,26 +378,26 @@ The minimum gcc/g++ requirements for building various components.
 [page clang]:     http://llvm.org/
 [page llvm]:      http://llvm.org/
 
-[link clang]:     http://llvm.org/releases/3.7.0/cfe-3.7.0.src.tar.xz
-[link llvm]:      http://llvm.org/releases/3.7.0/llvm-3.7.0.src.tar.xz
+[link clang]:     http://llvm.org/releases/3.7.1/cfe-3.7.1.src.tar.xz
+[link llvm]:      http://llvm.org/releases/3.7.1/llvm-3.7.1.src.tar.xz
 
-[newer clang]:    http://llvm.org/releases/3.9.0/cfe-3.9.0.src.tar.xz
-[newer llvm]:     http://llvm.org/releases/3.9.0/llvm-3.9.0.src.tar.xz
+[newer clang]:    http://llvm.org/releases/3.9.1/cfe-3.9.1.src.tar.xz
+[newer llvm]:     http://llvm.org/releases/3.9.1/llvm-3.9.1.src.tar.xz
 
 
 <!-- parallel -->
 [page adios]:     https://www.olcf.ornl.gov/center-projects/adios/
 [repo adios]:     https://github.com/ornladios/ADIOS
-[link adios]:     https://github.com/ornladios/ADIOS/archive/v1.11.0.tar.gz
-[altlink adios]:  http://users.nccs.gov/%7Epnorbert/adios-1.11.0.tar.gz
+[link adios]:     https://github.com/ornladios/ADIOS/archive/v1.11.1.tar.gz
+[altlink adios]:  http://users.nccs.gov/%7Epnorbert/adios-1.11.1.tar.gz
 [page zfp]:       http://computation.llnl.gov/projects/floating-point-compression/zfp-versions
 
 [page scotch]:    https://www.labri.fr/perso/pelegrin/scotch/
 [link scotch]:    https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz
 
 [page openmpi]:   http://www.open-mpi.org/
-[link openmpi]:   http://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.4.tar.bz2
-[newer openmpi]:  https://www.open-mpi.org/software/ompi/v2.0/downloads/openmpi-2.0.1.tar.bz2
+[older openmpi]:  http://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.6.tar.bz2
+[link openmpi]:   https://www.open-mpi.org/software/ompi/v2.0/downloads/openmpi-2.0.2.tar.bz2
 
 
 <!-- general -->
@@ -412,7 +412,7 @@ The minimum gcc/g++ requirements for building various components.
 [older CGAL]:     https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.8.2/CGAL-4.8.2.tar.xz
 
 [page FFTW]:      http://www.fftw.org/
-[link FFTW]:      http://www.fftw.org/fftw-3.3.5.tar.gz
+[link FFTW]:      http://www.fftw.org/fftw-3.3.6-pl1.tar.gz
 
 [page cgns]:      http://cgns.github.io/
 [link ccmio]:     http://portal.nersc.gov/project/visit/third_party/libccmio-2.6.1.tar.gz (check usage conditions)
@@ -428,11 +428,8 @@ The minimum gcc/g++ requirements for building various components.
 <!-- Visualization -->
 
 [page ParaView]:  http://www.paraview.org/
-[link ParaView]:  http://www.paraview.org/files/v5.0/ParaView-v5.0.1-source.tar.gz
-
-[older ParaView-44]:  http://www.paraview.org/files/v4.4/ParaView-v4.4.0-source.tar.gz
-[newer ParaView-51]:  http://www.paraview.org/files/v5.1/ParaView-v5.1.2-source.tar.gz
-[newer ParaView-52]:  http://www.paraview.org/files/v5.2/ParaView-v5.2.0.tar.gz
+[link ParaView]:  http://www.paraview.org/files/v5.3/ParaView-v5.3.0.tar.gz
+[older ParaView]: http://www.paraview.org/files/v5.0/ParaView-v5.0.1-source.tar.gz
 
 [page mesa]:  http://mesa3d.org/
 [link mesa]:  ftp://ftp.freedesktop.org/pub/mesa/13.0.3/mesa-13.0.3.tar.xz
diff --git a/etc/pkgconfigAdjust b/etc/pkgconfigAdjust
index cfb77de..26932a1 100755
--- a/etc/pkgconfigAdjust
+++ b/etc/pkgconfigAdjust
@@ -46,7 +46,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party (parent) directory only
-wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : current directory is not \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -75,9 +75,9 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+
     *)
         pkgconfigAdjust "$1"
         ;;
diff --git a/etc/pkgconfigPrefix b/etc/pkgconfigPrefix
index 5c8156e..469de6d 100755
--- a/etc/pkgconfigPrefix
+++ b/etc/pkgconfigPrefix
@@ -44,7 +44,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party (parent) directory only
-wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : current directory is not \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -72,9 +72,9 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+
     *)
         pkgconfigNewPrefix "$1"
         ;;
diff --git a/etc/relocateQt b/etc/relocateQt
index 7a10433..4b20454 100755
--- a/etc/relocateQt
+++ b/etc/relocateQt
@@ -32,7 +32,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party (parent) directory only
-wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : current directory is not \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -40,8 +40,6 @@ wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 . etc/tools/ThirdPartyFunctions
 . etc/tools/QtFunctions
 #------------------------------------------------------------------------------
-unset qtVERSION # No default version
-#------------------------------------------------------------------------------
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
@@ -61,17 +59,17 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-unset forceOpt
+unset optForce
 
 # Parse options
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+
     -f | -force)
-        forceOpt=true
+        optForce=true
         ;;
     -qt-[1-9]* | [1-9]* | qt-*)
         # -qt-VERSION, VERSION, qt-VERSION, qt-everywhere-opensource-src-VERSION
@@ -91,7 +89,7 @@ QT_ARCH_PATH=$installBASE/qt-$qtVERSION
 [ -n "$qtVERSION" ]    || die "No QT version specified"
 [ -d "$QT_ARCH_PATH" ] || die "No QT installation"
 
-if [ "${forceOpt:-false}" = true ]
+if [ "${optForce:-false}" = true ]
 then
     # Create qt.conf and adjust locations to use '${prefix}' internally
     finalizeQt
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index ba4a32a..a53bdda 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -48,7 +48,7 @@ BUILD_TYPE=Release  # The cmake build type
 #   ParaView_VERSION and ParaView_MAJOR should already have been set
 #
 #   ParaView_SOURCE_DIR : location of the original sources
-#   ParaView_BINARY_DIR : location of the build
+#   ParaView_BUILD_DIR  : location of the build
 #   ParaView_DIR        : location of the installed program
 #
 setParaViewDirs()
@@ -73,18 +73,17 @@ setParaViewDirs()
         exit 1
     }
 
-    ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION$BUILD_SUFFIX
+    ParaView_BUILD_DIR=$buildBASE/ParaView-$ParaView_VERSION$BUILD_SUFFIX
     ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION$BUILD_SUFFIX
 
-    export ParaView_SOURCE_DIR ParaView_BINARY_DIR ParaView_DIR
+    export ParaView_SOURCE_DIR ParaView_BUILD_DIR ParaView_DIR
 
     echo
     echo "ParaView_SOURCE_DIR=$ParaView_SOURCE_DIR"
-    echo "ParaView_BINARY_DIR=$ParaView_BINARY_DIR"
+    echo "ParaView_BUILD_DIR=$ParaView_BUILD_DIR"
     echo "ParaView_DIR=$ParaView_DIR"
 
-    # Prevent git queries from using the ThirdParty repository
-    export GIT_DIR=$ParaView_SOURCE_DIR/.git
+    export GIT_DIR=$ParaView_SOURCE_DIR/.git # Mask seeing our own git-repo
 }
 
 
@@ -112,27 +111,6 @@ setParaViewVersion()
 
 #------------------------------------------------------------------------------
 
-#
-# Compare version information (specified vs what is found in CMakeLists.txt)
-# Parse this type of content:
-#   set (PARAVIEW_VERSION_FULL "5.0.1")
-#
-checkVersion()
-{
-    local ver=$(
-        sed -ne 's/^ *set *( *PARAVIEW_VERSION_FULL[ "]*\([.0-9]*\).*$/\1/ip' \
-        $ParaView_SOURCE_DIR/CMakeLists.txt
-    )
-
-    if [ "$ParaView_VERSION" != "$ver" ]
-    then
-        echo "(${ver:-none}) mismatch?"
-    else
-        echo "(${ver:-none})"
-    fi
-}
-
-
 #
 # Set CMake cache variables
 #
@@ -375,17 +353,17 @@ configParaView()
     local cmake=$(findCMake)
 
     # Remove any existing build folder and recreate
-    if [ -d $ParaView_BINARY_DIR ]
+    if [ -d $ParaView_BUILD_DIR ]
     then
         echo "removing old build directory"
-        echo "    $ParaView_BINARY_DIR"
-        rm -rf $ParaView_BINARY_DIR
+        echo "    $ParaView_BUILD_DIR"
+        rm -rf $ParaView_BUILD_DIR
     fi
-    mkdir -p $ParaView_BINARY_DIR
+    mkdir -p $ParaView_BUILD_DIR
 
     addCMakeVariable "CMAKE_BUILD_TYPE=$BUILD_TYPE"
 
-    cd $ParaView_BINARY_DIR || exit 1  # Change to build folder
+    cd $ParaView_BUILD_DIR || exit 1  # Change to build folder
 
     echo "----"
     echo "Configuring paraview-$ParaView_VERSION (major version: $ParaView_MAJOR)"
@@ -395,7 +373,7 @@ configParaView()
     echo "    GL2  rendering : ${withGL2:-false}"
     echo "    QT dev support : ${withQT:-true}"
     echo "    Source         : $ParaView_SOURCE_DIR"
-    echo "    Build          : $ParaView_BINARY_DIR"
+    echo "    Build          : $ParaView_BUILD_DIR"
     echo "    Target         : $ParaView_DIR"
     echo "    cmake          : $cmake"
     echo "    Build suffix   : ${BUILD_SUFFIX:-none}"
@@ -423,7 +401,7 @@ configParaView()
 #
 makeParaView()
 {
-    cd $ParaView_BINARY_DIR || exit 1  # Change to build folder
+    cd $ParaView_BUILD_DIR || exit 1  # Change to build folder
     echo "    Starting make"
     time make -j $WM_NCOMPPROCS
     echo "    Done make"
@@ -442,7 +420,7 @@ makeParaView()
 #
 installParaView()
 {
-    cd $ParaView_BINARY_DIR || exit 1  # Change to build folder
+    cd $ParaView_BUILD_DIR || exit 1  # Change to build folder
     echo "    Installing ParaView to $ParaView_DIR"
 
     make install
@@ -468,7 +446,7 @@ INFO
     # Non-system installation of QT?
     if [ "$qmake" != /usr/bin/qmake -a -d "$qtLib" ]
     then
-        cat<< INFO
+        /bin/cat<<INFO
 
 And adjust your LD_LIBRARY_PATH to include the following:
     $qtLib
diff --git a/etc/tools/QtFunctions b/etc/tools/QtFunctions
index c8a6a95..6a6556f 100644
--- a/etc/tools/QtFunctions
+++ b/etc/tools/QtFunctions
@@ -30,6 +30,13 @@
 #
 #------------------------------------------------------------------------------
 
+# Qt-related variables. Initialization at the end of the file.
+
+qtTYPE=qt-everywhere-opensource-src
+unset qtVERSION # No default version
+
+#------------------------------------------------------------------------------
+
 #
 # Create a qt.conf file in the QT bin/
 # - this can be modified easily if the qt installation is relocated
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index b76e9a3..5c1258c 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -37,6 +37,30 @@ buildBASE=$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER
 installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
 
 unset BUILD_SUFFIX
+#------------------------------------------------------------------------------
+# Force use of gcc/g++
+useGcc()
+{
+    export CC=gcc    # Use gcc/g++
+    export CXX=g++
+}
+
+#------------------------------------------------------------------------------
+# Some functions as per OpenFOAM etc/config.sh/functions
+
+unset -f _foamAddLib _foamAddMan _foamAddPath   # Get settings only
+unset -f _foamEtc
+
+# Source an etc file
+_foamEtc()
+{
+    local file
+    if [ $# -gt 0 ] && file=$($WM_PROJECT_DIR/bin/foamEtcFile "$@")
+    then
+        . $file
+    fi
+}
+
 #------------------------------------------------------------------------------
 
 #
diff --git a/etc/tools/vtkFunctions b/etc/tools/vtkFunctions
index ea13bb7..eece891 100644
--- a/etc/tools/vtkFunctions
+++ b/etc/tools/vtkFunctions
@@ -42,7 +42,7 @@ unset CMAKE_VARIABLES
 #   VTK_VERSION and VTK_MAJOR should already have been set
 #
 #   VTK_SOURCE_DIR : location of the original sources
-#   VTK_BINARY_DIR : location of the build
+#   VTK_BUILD_DIR  : location of the build
 #   VTK_DIR        : location of the installed program
 #
 setVtkDirs()
@@ -67,18 +67,17 @@ setVtkDirs()
         exit 1
     }
 
-    VTK_BINARY_DIR=$buildBASE/VTK-$VTK_VERSION$BUILD_SUFFIX
+    VTK_BUILD_DIR=$buildBASE/VTK-$VTK_VERSION$BUILD_SUFFIX
     VTK_DIR=$installBASE/VTK-$VTK_VERSION$BUILD_SUFFIX
 
-    export VTK_SOURCE_DIR VTK_BINARY_DIR VTK_DIR
+    export VTK_SOURCE_DIR VTK_BUILD_DIR VTK_DIR
 
     echo
     echo "VTK_SOURCE_DIR=$VTK_SOURCE_DIR"
-    echo "VTK_BINARY_DIR=$VTK_BINARY_DIR"
+    echo "VTK_BUILD_DIR=$VTK_BUILD_DIR"
     echo "VTK_DIR=$VTK_DIR"
 
-    # Prevent git queries from using the ThirdParty repository
-    export GIT_DIR=$VTK_SOURCE_DIR/.git
+    export GIT_DIR=$VTK_SOURCE_DIR/.git # Mask seeing our own git-repo
 }
 
 
@@ -123,23 +122,23 @@ configVTK()
     local cmake=$(findCMake)
 
     # Remove any existing build folder and recreate
-    if [ -d $VTK_BINARY_DIR ]
+    if [ -d $VTK_BUILD_DIR ]
     then
         echo "removing old build directory"
-        echo "    $VTK_BINARY_DIR"
-        rm -rf $VTK_BINARY_DIR
+        echo "    $VTK_BUILD_DIR"
+        rm -rf $VTK_BUILD_DIR
     fi
-    mkdir -p $VTK_BINARY_DIR
+    mkdir -p $VTK_BUILD_DIR
 
     addCMakeVariable "CMAKE_BUILD_TYPE=$BUILD_TYPE"
 
-    cd $VTK_BINARY_DIR || exit 1  # change to build folder
+    cd $VTK_BUILD_DIR || exit 1  # change to build folder
 
     echo "----"
     echo "Configuring VTK-$VTK_VERSION"
     echo "    MESA   support : ${withMESA:-false}"
     echo "    Source         : $VTK_SOURCE_DIR"
-    echo "    Build          : $VTK_BINARY_DIR"
+    echo "    Build          : $VTK_BUILD_DIR"
     echo "    Target         : $VTK_DIR"
     echo "    cmake          : $cmake"
     echo "    Build suffix   : ${BUILD_SUFFIX:-none}"
@@ -167,7 +166,7 @@ configVTK()
 #
 makeVTK()
 {
-    cd $VTK_BINARY_DIR || exit 1  # Change to build folder
+    cd $VTK_BUILD_DIR || exit 1  # Change to build folder
     echo "    Starting make"
     time make -j $WM_NCOMPPROCS
     echo "    Done make"
@@ -183,7 +182,7 @@ makeVTK()
 #
 installVTK()
 {
-    cd $VTK_BINARY_DIR || exit 1  # Change to build folder
+    cd $VTK_BUILD_DIR || exit 1  # Change to build folder
     echo "    Installing VTK to $VTK_DIR"
 
     make install
diff --git a/makeADIOS b/makeADIOS
index 0081fab..f558be3 100755
--- a/makeADIOS
+++ b/makeADIOS
@@ -32,19 +32,19 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# ADIOS version from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS)
+
+# ADIOS version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/ADIOS
 
 adiosPACKAGE=${adios_version:-adios-none}
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -64,7 +64,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Export WM settings in a form that GNU configure recognizes
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]         &&  export CC="$WM_CC"
 [ -n "$WM_CXX" ]        &&  export CXX="$WM_CXX"
 [ -n "$WM_CFLAGS" ]     &&  export CFLAGS="$WM_CFLAGS"
@@ -74,13 +74,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     -cmake)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         CMAKE_PATH="${2%%/}"
@@ -280,9 +277,9 @@ then
         buildDIR=$buildBASE/$adiosPACKAGE
 
         cd $ADIOS_SOURCE_DIR || exit 1
-        [ -e Makefile ] && make distclean 2>/dev/null
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
 
-        export GIT_DIR=$ADIOS_SOURCE_DIR/.git
+        [ -e Makefile ] && make distclean 2>/dev/null
 
         applyPatch $adiosPACKAGE $ADIOS_SOURCE_DIR
 
@@ -328,8 +325,7 @@ else
     (
         buildDIR=$buildBASE/$adiosPACKAGE
         cd $ADIOS_SOURCE_DIR || exit 1
-
-        export GIT_DIR=$ADIOS_SOURCE_DIR/.git
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
 
         applyPatch $adiosPACKAGE $ADIOS_SOURCE_DIR
 
@@ -354,6 +350,7 @@ else
             -DCMAKE_INSTALL_PREFIX=$ADIOS_ARCH_PATH \
             -DCMAKE_BUILD_TYPE=Release \
             -DBUILD_FORTRAN=FALSE \
+            ${WM_QUIET:+-DCMAKE_RULE_MESSAGES=OFF} \
             $ADIOS_SOURCE_DIR \
         && make -j $WM_NCOMPPROCS all \
         && make install \
diff --git a/makeCCMIO b/makeCCMIO
index 02e7c21..2e1b976 100755
--- a/makeCCMIO
+++ b/makeCCMIO
@@ -32,7 +32,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -44,12 +44,13 @@ cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# libccmio version from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
+
+# libccmio version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/ccmio
 
 ccmioPACKAGE=${ccmio_version:-libccmio-2.6.1}
-targetType=lib
+targetType=lib  # Default is static linkage
+
 #------------------------------------------------------------------------------
 usage()
 {
@@ -59,6 +60,7 @@ usage()
 
 Usage: ${0##*/} [OPTION] [lib|libso] [libccmio-VERSION]
 options:
+  -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -help
 
 * Compile the proprietary libccmio library
@@ -82,9 +84,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     lib|libso)
         targetType="$1"
         ;;
@@ -98,19 +101,20 @@ do
     shift
 done
 
-# assert: directory must be available
-[ -d "$ccmioPACKAGE" ] || die "missing source directory '$ccmioPACKAGE'"
-
 #------------------------------------------------------------------------------
-CCMIO_SOURCE_DIR=$sourceBASE/$ccmioPACKAGE
-CCMIO_ARCH_PATH=$installBASE/$ccmioPACKAGE
-
 #
 # Build LIBCCMIO
 #
-echo "---------------"
+CCMIO_SOURCE_DIR=$sourceBASE/$ccmioPACKAGE
+CCMIO_ARCH_PATH=$installBASE/$ccmioPACKAGE
+
+# Sources must be available
+[ -d "$CCMIO_SOURCE_DIR" ] || die "Missing sources: '$ccmioPACKAGE'"
+
 (
     cd $CCMIO_SOURCE_DIR || exit 1
+    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
+
     incDIR=$CCMIO_ARCH_PATH/include/libccmio
     libDIR=$CCMIO_ARCH_PATH/lib
 
@@ -118,16 +122,17 @@ echo "---------------"
     mkdir -p $libDIR 2>/dev/null
 
     cpMakeFiles libccmio 2>/dev/null
+
+    # Place static libraries in sub-directory:
+    if [ "$targetType" = lib ]
+    then
+        export FOAM_EXT_LIBBIN=$libDIR
+    fi
+
     if wmake $targetType
     then
-        # make headers available:
+        # Make headers available:
         /bin/cp -pv libccmio/ccmio*.h $incDIR
-
-        # relocate static libraries to sub-directory:
-        if [ "$targetType" = lib ]
-        then
-            /bin/mv -v $FOAM_EXT_LIBBIN/libccmio.a $libDIR
-        fi
     fi
 )
 
diff --git a/makeCGAL b/makeCGAL
index e8b7045..7c27be6 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -65,26 +65,26 @@ then
 fi
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# CGAL, boost and gmp/mpfr versions from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-unset -f _foamAddPath _foamAddLib _foamAddMan   # get settings only
-unset BOOST_ARCH_PATH CGAL_ARCH_PATH            # purge current values
 
-# compiler first, let CGAL config override GMP (eg, when there is no GMP)
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
+unset BOOST_ARCH_PATH CGAL_ARCH_PATH                     # Purge current values
+
+# CGAL, boost and gmp/mpfr versions from OpenFOAM etc/config.sh files.
+# Get compiler first and let CGAL config override GMP (eg, when there is no GMP)
+_foamEtc config.sh/compiler
+_foamEtc config.sh/CGAL
 
 boostPACKAGE=${boost_version:-boost-system}
 gmpPACKAGE=${gmp_version:-gmp-system}
 mpfrPACKAGE=${mpfr_version:-mpfr-system}
 cgalPACKAGE=$cgal_version
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -116,7 +116,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure CMake gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -126,16 +126,10 @@ unset optHeadersOnly
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    '')
-        # discard empty arguments
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     -cmake)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         CMAKE_PATH="${2%%/}"
@@ -222,6 +216,7 @@ else
 
     (
         cd $BOOST_SOURCE_DIR || exit 1
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
 
         rm -rf $BOOST_ARCH_PATH
 
@@ -280,11 +275,11 @@ SUMMARY
 # CGAL-4.9 normally builds into 'lib64', older versions into 'lib'.
 #
 #   CGAL_SOURCE_DIR : location of the original sources
-#   CGAL_BINARY_DIR : location of the build
+#   CGAL_BUILD_DIR  : location of the build
 #   CGAL_ARCH_PATH  : installation directory
 
 CGAL_SOURCE_DIR=$sourceBASE/$cgalPACKAGE
-CGAL_BINARY_DIR=$buildBASE/$cgalPACKAGE
+CGAL_BUILD_DIR=$buildBASE/$cgalPACKAGE
 : ${CGAL_ARCH_PATH:=$installBASE/$cgalPACKAGE}      # Fallback
 
 # gmp/mpfr are installed without compiler name
@@ -379,21 +374,22 @@ fi
 
 (
     # Remove any existing build folder and recreate
-    if [ -d $CGAL_BINARY_DIR ]
+    if [ -d $CGAL_BUILD_DIR ]
     then
         echo "removing old build directory"
-        echo "    $CGAL_BINARY_DIR"
-        rm -rf $CGAL_BINARY_DIR
+        echo "    $CGAL_BUILD_DIR"
+        rm -rf $CGAL_BUILD_DIR
     fi
-    mkdir -p $CGAL_BINARY_DIR
+    mkdir -p $CGAL_BUILD_DIR
 
-    cd $CGAL_BINARY_DIR || exit 1
+    cd $CGAL_BUILD_DIR || exit 1
+    export GIT_DIR=$CGAL_SOURCE_DIR/.git # Mask seeing our own git-repo
 
     unset configBoost configGmp configMpfr
     echo "----"
     echo "Configuring $cgalPACKAGE with boost $BOOST_VERSION"
     echo "    Source         : $CGAL_SOURCE_DIR"
-    echo "    Build          : $CGAL_BINARY_DIR"
+    echo "    Build          : $CGAL_BUILD_DIR"
     echo "    Target         : $CGAL_ARCH_PATH"
 
 
@@ -479,6 +475,7 @@ CMAKE_OPTIONS
         -DWITH_CGAL_Qt5=OFF \
         ${optHeadersOnly:+-DCGAL_HEADER_ONLY=TRUE} \
         $configBoost $configGmp $configMpfr \
+        ${WM_QUIET:+-DCMAKE_RULE_MESSAGES=OFF} \
         $CGAL_SOURCE_DIR \
     && set +x \
     && make -j $WM_NCOMPPROCS \
diff --git a/makeCmake b/makeCmake
index 5dce1b5..f8d0cdb 100755
--- a/makeCmake
+++ b/makeCmake
@@ -35,15 +35,17 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
+
 # Special purpose script - no default version.
 unset cmakePACKAGE
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -63,7 +65,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure CMake gets the correct C/CC++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -72,13 +74,10 @@ unset optLink
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    -gcc)
-        export CC=gcc   # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     -link)
         optLink=true
         ;;
@@ -117,6 +116,7 @@ else
         buildDIR=$buildBASE/$cmakePACKAGE
 
         cd $CMAKE_SOURCE_DIR || exit 1
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
         make distclean 2>/dev/null
 
         rm -rf $buildDIR
diff --git a/makeFFTW b/makeFFTW
index 437efab..dd8ea35 100755
--- a/makeFFTW
+++ b/makeFFTW
@@ -47,20 +47,19 @@ then
 fi
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# FFTW version from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW)
+# FFTW version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/FFTW
 
 fftwPACKAGE=${fftw_version:-fftw-system}
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -79,7 +78,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure configure gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -87,16 +86,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    '')
-        # discard empty arguments
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     fftw-[0-9]* | fftw_[0-9]* | fftw-system )
         fftwPACKAGE="${1%%/}"
         ;;
@@ -146,6 +139,7 @@ else
         buildDIR=$buildBASE/$fftwPACKAGE
 
         cd $FFTW_SOURCE_DIR || exit 1
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
 
         rm -rf $FFTW_ARCH_PATH
         rm -rf $buildDIR
diff --git a/makeGcc b/makeGcc
index 265d617..cfe9c08 100755
--- a/makeGcc
+++ b/makeGcc
@@ -44,24 +44,25 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# Default GCC, mpfr, gmp and mpc versions from OpenFOAM etc/config.sh file
-WM_COMPILER_TYPE=ThirdParty       # ensure we get the correct compiler settings
-: ${WM_COMPILER:=Gcc}             # this will still fail if 'Clang' was set
 
-. $WM_PROJECT_DIR/etc/config.sh/functions
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
+[ "${WM_COMPILER#Gcc}" = "$WM_COMPILER" ] && WM_COMPILER=Gcc        # Force gcc
+WM_COMPILER_TYPE=ThirdParty                # Ensure we get the correct settings
+
+# Default GCC, mpfr, gmp and mpc versions from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/compiler
 
 gmpPACKAGE=${gmp_version:-gmp-system}
 mpfrPACKAGE=${mpfr_version:-mpfr-system}
 mpcPACKAGE=${mpc_version:-mpc-system}
 gccPACKAGE=$gcc_version
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -94,9 +95,9 @@ unset optThreadSafe # unset=auto
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+
     -multi*)
         optMultilib=enable
         ;;
@@ -163,6 +164,18 @@ GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
 MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
 MPC_ARCH_PATH=$installBASE/$mpcPACKAGE
 
+# Prefix <dir> to LD_LIBRARY_PATH, if it exists. 0 on success, 1 on failure
+addLib()
+{
+    if [ -d "$1" ]
+    then
+        export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
+        return 0
+    else
+        return 1
+    fi
+}
+
 
 # ================
 # Build GMP
@@ -182,6 +195,7 @@ else
     buildDIR=$buildBASE/$gmpPACKAGE
 
     cd $sourceDIR || exit 1
+    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
     make distclean 2>/dev/null
 
     rm -rf $buildDIR
@@ -203,10 +217,8 @@ else
 }
 fi
 
-if [ -d "$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" ]
+if addLib "$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
 then
-    _foamAddLib "$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
-
     configGMP=$(cat <<CONFIG_OPTIONS
     --with-gmp-include=$GMP_ARCH_PATH/include
     --with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
@@ -235,6 +247,7 @@ else
     buildDIR=$buildBASE/$mpfrPACKAGE
 
     cd $sourceDIR || exit 1
+    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
     make distclean 2>/dev/null
 
     rm -rf $buildDIR
@@ -260,10 +273,8 @@ else
 }
 fi
 
-if [ -d "$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" ]
+if addLib "$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
 then
-    _foamAddLib "$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
-
     configMPFR=$(cat <<CONFIG_OPTIONS
     --with-mpfr-include=$MPFR_ARCH_PATH/include \
     --with-mpfr-lib=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
@@ -292,6 +303,7 @@ else
     buildDIR=$buildBASE/$mpcPACKAGE
 
     cd $sourceDIR || exit 1
+    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
     make distclean 2>/dev/null
 
     rm -rf $buildDIR
@@ -313,10 +325,8 @@ else
 }
 fi
 
-if [ -d "$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" ]
+if addLib "$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
 then
-    _foamAddLib "$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
-
     configMPC=$(cat <<CONFIG_OPTIONS
     --with-mpc-include=$MPC_ARCH_PATH/include \
     --with-mpc-lib=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
@@ -349,6 +359,7 @@ else
     buildDIR=$buildBASE/$gccPACKAGE
 
     cd $sourceDIR || exit 1
+    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
     make distclean 2>/dev/null
 
     rm -rf $buildDIR
diff --git a/makeGperftools b/makeGperftools
index 87cdc4c..4ad0f94 100755
--- a/makeGperftools
+++ b/makeGperftools
@@ -32,20 +32,19 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# Gperftools version from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools)
+# Gperftools version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/gperftools
 
 gperftoolsPACKAGE=${gperftools_version:-gperftools-system}
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -64,7 +63,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure configure gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -72,13 +71,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     gperftools-[0-9]* | gperftools-svn* | gperftools-git)
         gperftoolsPACKAGE="${1%%/}"
         ;;
@@ -119,8 +115,8 @@ else
         buildDIR=$buildBASE/$gperftoolsPACKAGE
 
         cd $GPERFTOOLS_SOURCE_DIR || exit 1
-
-        make distclean 2>/dev/null
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
+        [ -e Makefile ] && make distclean 2>/dev/null
 
         rm -rf $GPERFTOOLS_ARCH_PATH
         rm -rf $buildDIR
diff --git a/makeLLVM b/makeLLVM
index 1d45d3a..5da443f 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -46,21 +46,22 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# LLVM/Clang version from OpenFOAM etc/config.sh file
-WM_COMPILER_TYPE=ThirdParty       # ensure we get the correct compiler settings
-WM_COMPILER=Clang                 # force values for 'clang'
 
-. $WM_PROJECT_DIR/etc/config.sh/functions
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
+[ "${WM_COMPILER#Clang}" = "$WM_COMPILER" ] && WM_COMPILER=Clang  # Force clang
+WM_COMPILER_TYPE=ThirdParty                # Ensure we get the correct settings
+
+# LLVM/Clang version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/compiler
 
 llvmPACKAGE=$clang_version
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -80,7 +81,7 @@ USAGE
     exit 1
 }
 #-----------------------------------------------------------------------------
-# Ensure CMake gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -88,13 +89,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     -cmake)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         CMAKE_PATH="${2%%/}"
@@ -119,12 +117,12 @@ installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH
 
 # Build LLVM (clang)
 #   LLVM_SOURCE_DIR : location of the original sources
-#   LLVM_BINARY_DIR : location of the build
+#   LLVM_BUILD_DIR  : location of the build
 #   LLVM_ARCH_PATH  : location of the installed program
 # - Strip any trailing '.src' from the proper names
 
 LLVM_SOURCE_DIR=$sourceBASE/$llvmPACKAGE
-LLVM_BINARY_DIR=$buildBASE/${llvmPACKAGE%%.src}
+LLVM_BUILD_DIR=$buildBASE/${llvmPACKAGE%%.src}
 LLVM_ARCH_PATH=$installBASE/${llvmPACKAGE%%.src}
 
 #
@@ -143,11 +141,12 @@ then
     echo
     (
         cd $LLVM_SOURCE_DIR || exit 1
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
         make distclean 2>/dev/null
 
-        rm -rf $LLVM_BINARY_DIR
-        mkdir -p $LLVM_BINARY_DIR
-        cd $LLVM_BINARY_DIR
+        rm -rf $LLVM_BUILD_DIR
+        mkdir -p $LLVM_BUILD_DIR
+        cd $LLVM_BUILD_DIR
 
         set -x
         $LLVM_SOURCE_DIR/configure \
@@ -171,10 +170,11 @@ else
     echo
     (
         cd $LLVM_SOURCE_DIR || exit 1
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
 
-        rm -rf $LLVM_BINARY_DIR
-        mkdir -p $LLVM_BINARY_DIR
-        cd $LLVM_BINARY_DIR
+        rm -rf $LLVM_BUILD_DIR
+        mkdir -p $LLVM_BUILD_DIR
+        cd $LLVM_BUILD_DIR
 
         cmake=$(findCMake)
 
diff --git a/makeMPICH b/makeMPICH
index dd7b8fc..2332153 100755
--- a/makeMPICH
+++ b/makeMPICH
@@ -51,27 +51,33 @@ then
 fi
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
+# Transition
+# ~~~~~~~~~~
+_foamAddLib()  { true; }
+_foamAddMan()  { true; }
+_foamAddPath() { true; }
 #------------------------------------------------------------------------------
-# get mpich version
-WM_MPLIB=MPICH       # ensure we get the third-party settings
 
-. $WM_PROJECT_DIR/etc/config.sh/functions
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi)
+WM_MPLIB=MPICH                                  # Ensure we get the correct MPI
+
+# mpich version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/mpi
 
 mpiPACKAGE=${FOAM_MPI:-mpich-system}
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: ${0##*/} [OPTION] [openmpi-VERSION]
+usage: ${0##*/} [OPTION] [mpich-VERSION]
 options:
   -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -help
@@ -83,7 +89,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure configure gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -91,16 +97,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    '')
-        # discard empty arguments
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     mpich*)
         mpiPACKAGE="${1%%/}"
         ;;
@@ -126,7 +126,7 @@ fi
 
 #------------------------------------------------------------------------------
 #
-# Build openmpi
+# Build mpich
 #
 #   MPI_SOURCE_DIR : location of the original sources
 #   MPI_ARCH_PATH  : installation directory
@@ -151,6 +151,7 @@ else
         # ----------------------------
 
         cd $MPI_SOURCE_DIR || exit 1
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
         [ -e Makefile ] && make distclean 2>/dev/null
 
         rm -rf $MPI_ARCH_PATH
diff --git a/makeMesa b/makeMesa
index edb8d81..31750cb 100755
--- a/makeMesa
+++ b/makeMesa
@@ -38,20 +38,21 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# MESA version from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-unset -f _foamAddPath _foamAddLib               # get settings only
-unset vtk_version mesa_version                  # purge current values
 
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk)
+unset vtk_version mesa_version                           # Purge current values
+
+# mesa version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/vtk
+
 mesaPACKAGE=$mesa_version
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -70,27 +71,28 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure configure gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
 # Non-standard location for clang?
-unset thirdPartyClang
-if [ "$WM_COMPILER_TYPE" = ThirdParty -a "$WM_COMPILER" = Clang ]
-then
+case "$WM_COMPILER_TYPE-$WM_COMPILER" in
+ThirdParty-Clang*)
     thirdPartyClang=true
-fi
+    ;;
+*)
+    unset thirdPartyClang
+    ;;
+esac
 
 # Parse options
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
     -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
+        useGcc
         unset thirdPartyClang
         ;;
     mesa-*)
@@ -171,6 +173,7 @@ adjustMESA()
     buildDIR=$buildBASE/$mesaPACKAGE
 
     cd $MESA_SOURCE_DIR || exit 1
+    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
 
     # remove any existing build
     rm -rf $MESA_ARCH_PATH
diff --git a/makeOPENMPI b/makeOPENMPI
index a3a03ff..a61f954 100755
--- a/makeOPENMPI
+++ b/makeOPENMPI
@@ -51,20 +51,26 @@ then
 fi
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
+# Transition
+# ~~~~~~~~~~
+_foamAddLib()  { true; }
+_foamAddMan()  { true; }
+_foamAddPath() { true; }
 #------------------------------------------------------------------------------
-# get openmpi version
-WM_MPLIB=OPENMPI       # ensure we get the third-party settings
 
-. $WM_PROJECT_DIR/etc/config.sh/functions
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi)
+WM_MPLIB=OPENMPI                                # Ensure we get the correct MPI
+
+# openmpi version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/mpi
 
 mpiPACKAGE=${FOAM_MPI:-openmpi-system}
+
 #------------------------------------------------------------------------------
 usage() {
     exec 1>&2
@@ -83,7 +89,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure configure gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -91,16 +97,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    '')
-        # discard empty arguments
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     openmpi-[0-9]* | openmpi_[0-9]* | openmpi-system )
         mpiPACKAGE="${1%%/}"
         ;;
@@ -163,6 +163,7 @@ else
         buildDIR=$buildBASE/$mpiPACKAGE
 
         cd $MPI_SOURCE_DIR || exit 1
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
         [ -e Makefile ] && make distclean 2>/dev/null
 
         rm -rf $MPI_ARCH_PATH
@@ -173,9 +174,9 @@ else
         set -x
         $MPI_SOURCE_DIR/configure \
             --prefix=$MPI_ARCH_PATH \
+            --libdir=$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
             --disable-orterun-prefix-by-default \
             --enable-shared --disable-static \
-            --libdir=$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
             --enable-mpi-fortran=none \
             --disable-mpi-profile \
             $configOpt \
diff --git a/makeParaView b/makeParaView
index 114da6a..4045767 100755
--- a/makeParaView
+++ b/makeParaView
@@ -33,11 +33,11 @@
 #
 #     Note the capitalization of ParaView in the directory names.
 #
-# ------------------------------------------------
-# SOME USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -45,41 +45,24 @@ cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 . etc/tools/ThirdPartyFunctions
 . etc/tools/ParaViewFunctions
 #------------------------------------------------------------------------------
-# ParaView_VERSION from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-unset -f _foamAddPath _foamAddLib               # get settings only
-unset ParaView_VERSION                          # purge current values
 
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview)
-: ${ParaView_VERSION##*-}
-#------------------------------------------------------------------------------
-#
-# USER DEFAULTS:
-# ~~~~~~~~~~~~~~
+unset ParaView_VERSION                                   # Purge current values
+
+# ParaView_VERSION from etc/config.sh file:
+_foamEtc config.sh/paraview
 
-# MESA graphics support:
-withMESA=false
-MESA_INCLUDE="/usr/include/GL"
-MESA_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
+ParaView_VERSION="${ParaView_VERSION##*-}"               # Without prefix
 
-# Python support:
-# - The script will try to determine the appropriate python library.
-#   If that fails, specify the path using the PYTHON_LIBRARY variable below.
-withPYTHON=false
-PYTHON_LIBRARY=""
-# PYTHON_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libpython2.7.so.1.0"
+# Set initial ParaView_MAJOR based on current value of ParaView_VERSION
+setParaViewVersion ${ParaView_VERSION:-none}
 
 # New rendering backend (starting with paraview 5.0).
-# Default to auto-config based on paraview version
-withGL2=auto
+withGL2=auto # auto-config based on version
 
-#
-# NO FURTHER EDITING BELOW THIS LINE
-#
-#-----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 usage() {
-    : ${ParaView_VERSION:=none} # some dummy value for usage information
     exec 1>&2
+    : ${ParaView_VERSION:=none} # some dummy value for usage information
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
@@ -87,22 +70,22 @@ usage: ${0##*/} [OPTION] [paraview-VERSION] [CMAKE-OPTION]
 options:
   -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -rebuild          for repeated builds (-make -install) *use with caution*
-  -gl2              with new rendering backend (if not already enabled)
-  -mesa             with mesa (if not already enabled)
+  -gl2              with new rendering backend (default: auto)
+  -mesa             with mesa
   -mesa-prefix DIR  location of mesa installation (sets -mesa-include, -mesa-lib)
-  -mesa-include DIR location of mesa headers (current value: ${MESA_INCLUDE:-none})
-  -mesa-lib PATH    path to mesa library     (current value: ${MESA_LIBRARY:-none})
-  -mpi              with mpi (if not already enabled)
+  -mesa-include DIR location of mesa headers (current: ${MESA_INCLUDE:-none})
+  -mesa-lib PATH    path to mesa library     (current: ${MESA_LIBRARY:-none})
+  -mpi              with mpi
   -mpi=N            with max 'N' mpi processes. N=0 for no upper-limit.
-  -python           with python (if not already enabled)
-  -python-lib PATH  path to python library   (current value: ${PYTHON_LIBRARY:-none})
+  -python           with python
+  -python-lib PATH  path to python library (current: ${PYTHON_LIBRARY:-none})
   -cmake PATH       with cmake from the path given
   -qmake PATH       with the Qt version corresponding to the qmake path given
   -qt               with extra Qt gui support (if not already enabled)
   -qt-VER           with Qt version corresponding to
                         \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/qt-VER/bin/qmake
   -verbose          verbose output in Makefiles
-  -version VER      specify an alternative version (current value: $ParaView_VERSION)
+  -version VER      specify an alternative version (current: $ParaView_VERSION)
   -major   VER      specify an alternative major version for special builds
   -buildType NAME   specify the build type (default: Release)
   -suffix NAME      specify a suffix to distinguish the build
@@ -138,16 +121,11 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure CMake gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
-# Set initial ParaView_MAJOR based on current value of ParaView_VERSION
-setParaViewVersion ${ParaView_VERSION:-none}
-
-#
 # Various building stages
-#
 unset runPATCH runCONFIG runMAKE runINSTALL
 runDEFAULT=true
 
@@ -155,19 +133,16 @@ runDEFAULT=true
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     [0-9]* | paraview-[0-9]* | ParaView-[0-9]*) # paraview version
         setParaViewVersion "${1%%/}"
         ;;
     [A-Z]*=*)            # cmake variables
         addCMakeVariable "$1"
         ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
     -patch)              # stage 0: patch sources
         runPATCH=true
         unset runDEFAULT
@@ -258,6 +233,7 @@ do
         ;;
     -python-lib)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        withPYTHON=true
         PYTHON_LIBRARY="${2%%/}"
         shift
         ;;
@@ -278,6 +254,7 @@ do
         withQT=false
         ;;
     -qt-[1-9]*)
+        withQT=true
         QMAKE_PATH="$installBASE/${1##-}"
         ;;
     -verbose)
@@ -379,10 +356,10 @@ Features selected
     qt        ${withQT:-false}
 ---------------------
 Version information
-    qt        ${QT_VERSION:-none}
-    version   ${ParaView_VERSION:-unknown} $(checkVersion)
+    paraview  ${ParaView_VERSION:-unknown}
     major     ${ParaView_MAJOR:-unknown}
     build     ${BUILD_TYPE:-unknown}
+    qt        ${QT_VERSION:-none}
 ---------------------
 SUMMARY
 
diff --git a/makeQt b/makeQt
index a131099..e50bcb5 100755
--- a/makeQt
+++ b/makeQt
@@ -32,7 +32,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -40,9 +40,6 @@ cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 . etc/tools/ThirdPartyFunctions
 . etc/tools/QtFunctions
 #------------------------------------------------------------------------------
-qtTYPE=qt-everywhere-opensource-src
-unset qtVERSION # No default version
-#------------------------------------------------------------------------------
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
@@ -59,7 +56,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Export WM settings in a form that GNU configure recognizes
+# Compiler/linker settings for CMake/configure
 [ -n "$WM_CC" ]         &&  export CC="$WM_CC"
 [ -n "$WM_CXX" ]        &&  export CXX="$WM_CXX"
 [ -n "$WM_CFLAGS" ]     &&  export CFLAGS="$WM_CFLAGS"
@@ -69,13 +66,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     -qt-[1-9]* | [1-9]* | qt-*)
         # -qt-VERSION, VERSION, qt-VERSION, qt-everywhere-opensource-src-VERSION
         qtVERSION="${1%%/}";
@@ -145,6 +139,7 @@ else
         buildDIR=$buildBASE/$qtPACKAGE
 
         cd $QT_SOURCE_DIR || exit 1
+        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
         [ -e Makefile ] && make distclean 2>/dev/null
 
         # Remove any existing build folder and recreate
diff --git a/makeTecio b/makeTecio
index 3628803..21a8076 100755
--- a/makeTecio
+++ b/makeTecio
@@ -32,7 +32,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -44,15 +44,14 @@ cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
-# Boost version (headers only) from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
+# Boost version (headers only) from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/CGAL
 
 boostPACKAGE=${boost_version:-boost-system}
 tecioPACKAGE=tecio
 targetType=lib
+
 #------------------------------------------------------------------------------
 usage()
 {
@@ -66,7 +65,6 @@ options:
   -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -help
 
-
 * Compile the proprietary libtecio library
       $tecioPACKAGE
   with $boostPACKAGE
@@ -75,7 +73,7 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure CMake gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -83,13 +81,10 @@ USAGE
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     -cmake)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         CMAKE_PATH="${2%%/}"
@@ -108,15 +103,23 @@ do
     shift
 done
 
-# assert: directory must be available
-[ -d "$tecioPACKAGE" ] || die "missing source directory '$tecioPACKAGE'"
-
-
 #------------------------------------------------------------------------------
+# Build TECIO library
 #
+#   TECIO_SOURCE_DIR : location of the original sources
+#   TECIO_BUILD_DIR  : location of the build
+#   TECIO_ARCH_PATH  : location of the installed program
+
+TECIO_SOURCE_DIR=$sourceBASE/$tecioPACKAGE/teciosrc
+TECIO_BUILD_DIR=$buildBASE/$tecioPACKAGE
+TECIO_ARCH_PATH=$installBASE/$tecioPACKAGE
+
+# Sources must be available
+[ -d "$TECIO_SOURCE_DIR" ] || die "Missing sources '$tecioPACKAGE'"
+
+
 # Get Boost information
 # - only headers are required
-
 : ${BOOST_ARCH_PATH:=$installBASE/$boostPACKAGE}    # Fallback
 
 boostInc="$BOOST_ARCH_PATH/include"
@@ -135,27 +138,17 @@ then
 fi
 
 
-# Build TECIO library
-#
-#   TECIO_SOURCE_DIR : location of the original sources
-#   TECIO_BINARY_DIR : location of the build
-#   TECIO_ARCH_PATH  : location of the installed program
-
-TECIO_SOURCE_DIR=$sourceBASE/$tecioPACKAGE/teciosrc
-TECIO_BINARY_DIR=$buildBASE/$tecioPACKAGE
-TECIO_ARCH_PATH=$installBASE/$tecioPACKAGE
-
 if [ -d "$TECIO_SOURCE_DIR" ]
 then
 (
     # Remove any existing build folder and recreate
-    if [ -d $TECIO_BINARY_DIR ]
+    if [ -d $TECIO_BUILD_DIR ]
     then
         echo "removing old build directory"
-        echo "    $TECIO_BINARY_DIR"
-        rm -rf $TECIO_BINARY_DIR
+        echo "    $TECIO_BUILD_DIR"
+        rm -rf $TECIO_BUILD_DIR
     fi
-    mkdir -p $TECIO_BINARY_DIR
+    mkdir -p $TECIO_BUILD_DIR
 
     rm -rf $TECIO_ARCH_PATH
 
@@ -163,7 +156,7 @@ then
     echo "----"
     echo "Configuring $tecioPACKAGE with boost $BOOST_VERSION"
     echo "    Source         : $TECIO_SOURCE_DIR"
-    echo "    Build          : $TECIO_BINARY_DIR"
+    echo "    Build          : $TECIO_BUILD_DIR"
     echo "    Target         : $TECIO_ARCH_PATH"
 
     if [ -d "$BOOST_ARCH_PATH" ]
@@ -177,9 +170,9 @@ then
 
     echo "----"
     set -x
-    cd $TECIO_BINARY_DIR && $cmake \
+    cd $TECIO_BUILD_DIR && $cmake \
         -DCMAKE_INSTALL_PREFIX=$TECIO_ARCH_PATH \
-        -DCMAKE_BINARY_TYPE=Release \
+        -DCMAKE_BUILD_TYPE=Release \
         -DBoost_INCLUDE_DIR=$boostInc \
         $TECIO_SOURCE_DIR \
     && make -j $WM_NCOMPPROCS \
@@ -189,7 +182,7 @@ then
         mkdir -p $TECIO_ARCH_PATH 2>/dev/null
 
         /bin/cp -pv \
-            $TECIO_BINARY_DIR/libtecio.a \
+            $TECIO_BUILD_DIR/libtecio.a \
             $TECIO_SOURCE_DIR/TECIO.h \
             $TECIO_SOURCE_DIR/tecio_Exports.h \
             $TECIO_ARCH_PATH
diff --git a/makeVTK b/makeVTK
index 39f1ffe..65aea19 100755
--- a/makeVTK
+++ b/makeVTK
@@ -33,13 +33,13 @@
 #     To use the VTK source from the ParaView source tree, simply make an
 #     appropriate link first. For example,
 #
-#        (cd $WM_THIRD_PARTY_DIR && ln -s ParaView-v5.2.0/VTK VTK-7.1.0)
+#         ln -s ParaView-v5.3.0/VTK VTK-7.1.0
 #
-# ------------------------------------------------
-# SOME USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -48,31 +48,18 @@ cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 . etc/tools/ParaViewFunctions
 . etc/tools/vtkFunctions
 #------------------------------------------------------------------------------
-# VTK version from OpenFOAM etc/config.sh file
-. $WM_PROJECT_DIR/etc/config.sh/functions
-unset -f _foamAddPath _foamAddLib               # get settings only
-unset vtk_version mesa_version                  # purge current values
 
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk)
-VTK_VERSION=$vtk_version
-#------------------------------------------------------------------------------
-#
-# USER DEFAULTS:
-# ~~~~~~~~~~~~~~
+unset vtk_version mesa_version                           # Purge current values
 
-# MESA graphics support:
-withMESA=false
-MESA_INCLUDE="/usr/include/GL"
-MESA_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
+# vtk version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/vtk
+
+VTK_VERSION=$vtk_version
 
 # New rendering backend (starting with vtk 7?).
-# Default to auto-config based on VTK version
-withGL2=auto
+withGL2=auto # auto-config based on version
 
-#
-# NO FURTHER EDITING BELOW THIS LINE
-#
-#-----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
@@ -82,17 +69,17 @@ usage: ${0##*/} [OPTION] [vtk-VERSION] [CMAKE-OPTION]
 options:
   -gcc              force g++ instead of the value from \$WM_CXX
   -rebuild          for repeated builds (-make -install) *use with caution*
-  -gl2              with new rendering backend (if not already enabled)
+  -gl2              with new rendering backend (default: auto)
   -mesa             with mesa (if not already enabled)
   -mesa-prefix DIR  location of mesa installation
-  -mesa-include DIR location of mesa headers (current value: ${MESA_INCLUDE:-none})
-  -mesa-lib PATH    path to mesa library     (current value: ${MESA_LIBRARY:-none})
+  -mesa-include DIR location of mesa headers (current: ${MESA_INCLUDE:-none})
+  -mesa-lib PATH    path to mesa library     (current: ${MESA_LIBRARY:-none})
   -osmesa           with off-screen mesa only
-  -mpi              with mpi (if not already enabled)
+  -mpi              with mpi
   -mpi=N            with max 'N' mpi processes. N=0 for no upper-limit.
   -cmake PATH       with cmake from the path given
   -verbose          verbose output in Makefiles
-  -version VER      specify an alternative version (current value: $VTK_VERSION)
+  -version VER      specify an alternative version (current: $VTK_VERSION)
   -buildType NAME   specify the build type (default: Release)
   -suffix NAME      specify a suffix to distinguish the build
   -help
@@ -120,13 +107,11 @@ USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
-# Ensure CMake gets the correct C/C++ compiler
+# Compiler settings for CMake/configure
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
-#
 # Various building stages
-#
 unset runPATCH runCONFIG runMAKE runINSTALL
 runDEFAULT=true
 
@@ -134,19 +119,16 @@ runDEFAULT=true
 while [ "$#" -gt 0 ]
 do
     case "$1" in
-    -h | -help)
-        usage
-        ;;
+    '') ;;      # Ignore empty
+    -h | -help) usage   ;;
+    -gcc)       useGcc  ;;
+
     [0-9]* | vtk-[0-9]* | VTK-[0-9]*) # VTK version
         setVtkVersion "${1%%/}"
         ;;
     [A-Z]*=*)            # cmake variables
         addCMakeVariable "$1"
         ;;
-    -gcc)
-        export CC=gcc    # use gcc/g++
-        export CXX=g++
-        ;;
     -patch)              # stage 0: patch sources
         runPATCH=true
         unset runDEFAULT
@@ -316,7 +298,7 @@ Features selected
     mpi       ${withMPI:-false}
 ---------------------
 Version information
-    version   ${VTK_VERSION:-unknown}
+    vtk       ${VTK_VERSION:-unknown}
     build     ${BUILD_TYPE:-unknown}
 ---------------------
 SUMMARY
diff --git a/minCmake b/minCmake
index 921811e..66693fe 100755
--- a/minCmake
+++ b/minCmake
@@ -32,7 +32,7 @@
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
 #------------------------------------------------------------------------------
 # Run from third-party directory only
-cd ${0%/*} && wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
+cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
@@ -82,7 +82,7 @@ do
     min=$(sed -n \
         -e 's/^.*cmake_minimum.*VERSION *\([0-9.][0-9.]*\).*/\1/p' \
         "$dir/CMakeLists.txt" \
-        2>/dev/null)
+        2>/dev/null | head -1)
 
     if [ -n "$min" ]
     then
-- 
GitLab


From d2da5b440e6879e44bf7a248d6c4a7b5a9b7f40e Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 18 Apr 2017 18:19:55 +0200
Subject: [PATCH 18/27] ENH: provide make script for MGridGen

- follow the standard *_ARCH_PATH style
---
 BUILD.md     |   3 +
 makeMGridGen | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 189 insertions(+)
 create mode 100755 makeMGridGen

diff --git a/BUILD.md b/BUILD.md
index 43ca1f9..1e44145 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -135,6 +135,9 @@ ThirdParty components prior to building OpenFOAM itself.
   Automatically invoked from the ThirdParty `Allwmake`,
   but can be invoked directly to resolve possible build errors.
 
+`makeMGridGen`
+- Optional agglomeration routines.
+
 `makeCCMIO`
 - Only required for conversion to/from STARCD/STARCCM+ files.
 
diff --git a/makeMGridGen b/makeMGridGen
new file mode 100755
index 0000000..fdf395f
--- /dev/null
+++ b/makeMGridGen
@@ -0,0 +1,186 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+#    \\/     M anipulation  |
+#------------------------------------------------------------------------------
+# License
+#     This file is part of OpenFOAM.
+#
+#     OpenFOAM is free software: you can redistribute it and/or modify it
+#     under the terms of the GNU General Public License as published by
+#     the Free Software Foundation, either version 3 of the License, or
+#     (at your option) any later version.
+#
+#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#     for more details.
+#
+#     You should have received a copy of the GNU General Public License
+#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Script
+#     makeMGridGen
+#
+# Description
+#     Build script for MGridGen (serial)
+#
+# ----------------------------------------------
+# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
+#------------------------------------------------------------------------------
+# Run from ThirdParty directory only
+wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
+    echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
+    echo "    The environment variables are inconsistent with the installation."
+    echo "    Check the OpenFOAM entries in your dot-files and source them."
+    exit 1
+}
+. etc/tools/ThirdPartyFunctions
+#------------------------------------------------------------------------------
+
+# mgridgen version from OpenFOAM etc/config.sh file:
+_foamEtc config.sh/mgridgen
+
+mgridgenPACKAGE=${MGRIDGEN_VERSION:-mgridgen-none}
+
+#------------------------------------------------------------------------------
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: ${0##*/} [OPTION] [mgridgen-VERSION]
+options:
+  -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
+  -help
+
+* Build MGridGen
+      $mgridgenPACKAGE
+
+USAGE
+    exit 1
+}
+
+#------------------------------------------------------------------------------
+# Compiler settings for CMake/configure
+[ -n "$WM_CC" ]  && export CC="$WM_CC"
+[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
+
+# Parse options
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    -gcc)
+        useGcc  # Use gcc/g++
+        ;;
+    mgridgen-[1-9]* | MGridGen-[1-9]* | parmgridgen-[1-9]* | ParMGridGen-[1-9]*)
+        mgridgenPACKAGE="${1%%/}"
+        ;;
+    *)
+        die "unknown option/argument: '$1'"
+        ;;
+    esac
+    shift
+done
+
+[ -n "$mgridgenPACKAGE" ] || die "The mgridgen-VERSION was not specified"
+
+# nothing to build
+if _foamIsNone "$mgridgenPACKAGE"
+then
+    echo "Using mgridgen-none (skip ThirdParty build of MGridGen)"
+    exit 0
+elif _foamIsSystem "$mgridgenPACKAGE"
+then
+    echo "Using mgridgen-system"
+    exit 0
+fi
+
+#------------------------------------------------------------------------------
+#
+# Build MGridGen
+
+#   MGRIDGEN_SOURCE_DIR : location of the original sources
+#   MGRIDGEN_ARCH_PATH  : installation directory
+
+MGRIDGEN_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$mgridgenPACKAGE
+MGRIDGEN_ARCH_PATH=$installBASE$WM_PRECISION_OPTION$WM_LABEL_OPTION/$mgridgenPACKAGE
+
+: ${FOAM_MPI:=dummy}
+
+echo
+echo ========================================
+echo "Build mgridgen library $mgridgenPACKAGE"
+echo
+
+#
+# Manual installation
+#
+install()
+{
+   echo "Install into $MGRIDGEN_ARCH_PATH"
+
+   local bindir=$MGRIDGEN_ARCH_PATH/bin
+   local incdir=$MGRIDGEN_ARCH_PATH/include
+   local libdir=$MGRIDGEN_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
+
+   for dir in $MGRIDGEN_ARCH_PATH $bindir $incdir $libdir
+   do
+       mkdir -m 0755 -p $dir
+   done
+
+   cp -vf mgridgen.h   $incdir
+   cp -vf libmgrid.a   $libdir
+   cp -vf mgridgen     $bindir
+
+   chmod -R 0644 $incdir/* $libdir/*
+   chmod -R 0755 $bindir/*
+}
+
+
+# Needs future adjustment
+# - for shared library
+# - for mpi-specific library locations
+if [ -f $MGRIDGEN_ARCH_PATH/include/mgridgen.h \
+  -a -r $MGRIDGEN_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmgrid.a ]
+then
+    echo "    MGridGen header in $MGRIDGEN_ARCH_PATH/include"
+    echo "    MGridGen libs   in $MGRIDGEN_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" # static
+    echo
+else
+(
+    cd $MGRIDGEN_SOURCE_DIR || exit 1
+    [ -e Makefile ] && make realclean 2>/dev/null
+
+    # Remove any existing build folder and recreate
+    rm -rf $MGRIDGEN_ARCH_PATH
+
+    serial="${CC:-$WM_CC}"   # CC (serial compiler)   default=cc
+    # parallel=$(whichMpicc)   # PARCC (parallel compiler) default=mpicc
+    # PARCC=$parallel
+    # PARLD=$parallel
+    # PARLIBS="-L../.. -lparmgrid -lmgrid -lm"
+
+    make \
+        COPTIONS="-fPIC"  \
+        LDOPTIONS="-fPIC" \
+        CC=$serial \
+        LD=$serial \
+        LIBDIR="-L../.." \
+        LIBS="-L../.. -lmgrid -lm" \
+        make=make \
+        serial \
+    && install \
+    && echo "Built: $mgridgenPACKAGE"
+) || {
+    echo "Error building: $mgridgenPACKAGE"
+}
+fi
+
+#------------------------------------------------------------------------------
-- 
GitLab


From c291d5742d052b7ee7ce858ef9ff5093bee178d9 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Mon, 24 Apr 2017 09:45:48 +0200
Subject: [PATCH 19/27] CONFIG: update version information for llvm

---
 BUILD.md |  5 +++--
 makeLLVM | 13 ++++++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index 1e44145..6cc4c2c 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -352,6 +352,7 @@ The minimum CMake requirements for building various components.
     3.3         ParaView-5.2.0
     3.3         ParaView-5.3.0
     3.4.3       llvm-3.9.1
+    3.4.3       llvm-4.0.0
     3.5         ParaView-5.1.0
 
 
@@ -384,8 +385,8 @@ The minimum gcc/g++ requirements for building various components.
 [link clang]:     http://llvm.org/releases/3.7.1/cfe-3.7.1.src.tar.xz
 [link llvm]:      http://llvm.org/releases/3.7.1/llvm-3.7.1.src.tar.xz
 
-[newer clang]:    http://llvm.org/releases/3.9.1/cfe-3.9.1.src.tar.xz
-[newer llvm]:     http://llvm.org/releases/3.9.1/llvm-3.9.1.src.tar.xz
+[newer clang]:    http://llvm.org/releases/4.0.0/cfe-4.0.0.src.tar.xz
+[newer llvm]:     http://llvm.org/releases/4.0.0/llvm-4.0.0.src.tar.xz
 
 
 <!-- parallel -->
diff --git a/makeLLVM b/makeLLVM
index 5da443f..102cce3 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -32,15 +32,15 @@
 #    - Ensure that you always use matching versions between llvm and clang.
 #    - LLVM components such as clang reside in the LLVM tools/ subdirectory
 #
-#    For example, when building from tar files (version 3.8.0)
+#    For example, when building from tar files (version 4.0.0)
 #
 #    1) Unpack LLVM:
-#        tar -xJvf llvm-3.8.0.src.tar.xz
-#        mv llvm-3.8.0.src  llvm-3.8.0
+#        tar -xJf llvm-4.0.0.src.tar.xz
+#        mv llvm-4.0.0.src  llvm-4.0.0
 #
 #    2) Unpack Clang (also know as cfe):
-#        tar -xJvf cfe-3.8.0.src.tar.xz
-#        mv cfe-3.8.0.src  llvm-3.8.0/tools/clang
+#        tar -xJf cfe-4.0.0.src.tar.xz
+#        mv cfe-4.0.0.src  llvm-4.0.0/tools/clang
 #
 # ----------------------------------------------
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
@@ -101,6 +101,9 @@ do
     llvm-[0-9]* | llvm-svn*)
         llvmPACKAGE="${1%%/}"
         ;;
+    [1-9]*)
+        llvmPACKAGE="llvm-${1%%/}"
+        ;;
     *)
         die "unknown option/argument: '$1'"
         ;;
-- 
GitLab


From ce4c19c717f6ea3a021746e3b934ae30022a3ab3 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 4 Apr 2017 18:23:31 +0200
Subject: [PATCH 20/27] COMP: adjust to use non-gcc compilers for scotch and
 ptscotch

---
 Allwmake                                      | 21 ++++++------
 etc/tools/ThirdPartyFunctions                 | 25 ++++++++++++++
 ...Makefile.inc.i686_pc_linux2.shlib-OpenFOAM | 33 ++++++++++++-------
 3 files changed, 57 insertions(+), 22 deletions(-)

diff --git a/Allwmake b/Allwmake
index 8ca2948..06fc4ff 100755
--- a/Allwmake
+++ b/Allwmake
@@ -38,7 +38,7 @@ cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
     exit 1
 }
 [ -n "$FOAM_EXT_LIBBIN" ] || {
-    echo "Error (${0##*/}) : \$FOAM_EXT_LIBBIN not set"
+    echo "Error (${0##*/}) : \$FOAM_EXT_LIBBIN not set for ThirdParty"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
@@ -51,6 +51,7 @@ cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 [ -n "$WM_CXXFLAGS" ]   &&  export CXXFLAGS="$WM_CXXFLAGS"
 [ -n "$WM_LDFLAGS" ]    &&  export LDFLAGS="$WM_LDFLAGS"
 
+useGccFlag $@           # Scan arguments for a '-gcc' option
 
 warnBuildIssues()
 {
@@ -131,9 +132,6 @@ then
     mkdir -p $incDIR    2>/dev/null
     mkdir -p $libDIR    2>/dev/null
 
-    # 'CC' already set (eg, from WM_CC) - set scotch-specific 'CCS' too
-    [ -n "$CC" ] && export CCS="$CC"
-
     if [ -f $scotchMakefile ]
     then
         rm -f Makefile.inc
@@ -144,8 +142,10 @@ then
         exit 1
     }
 
-    make realclean 2>/dev/null                  # Extra safety
+    export CCS="${CC:-$WM_CC}"  # CCS (serial compiler)   default=$(CC)
+    export CCP=$(whichMpicc)    # CCP (parallel compiler) default=mpicc
 
+    make realclean 2>/dev/null  # Extra safety
     make -j $WM_NCOMPPROCS scotch \
      && make \
         prefix=$prefixDIR \
@@ -153,7 +153,7 @@ then
         libdir=$libDIR \
         install
 
-    make realclean 2>/dev/null || true          # Failed cleanup is uncritical
+    make realclean 2>/dev/null || true      # Failed cleanup is uncritical
 ) || warnBuildIssues SCOTCH
 else
     warnNotFound SCOTCH
@@ -196,9 +196,6 @@ then
         mkdir -p $incDIR    2>/dev/null
         mkdir -p $libDIR    2>/dev/null
 
-        # 'CC' already set (eg, from WM_CC) - set scotch-specific 'CCS' too
-        [ -n "$CC" ] && export CCS="$CC"
-
         if [ -f $scotchMakefile ]
         then
             rm -f Makefile.inc
@@ -209,8 +206,10 @@ then
             exit 1
         }
 
-        make realclean 2>/dev/null              # Extra safety
+        export CCS="${CC:-$WM_CC}"  # CCS (serial compiler)   default=$(CC)
+        export CCP=$(whichMpicc)    # CCP (parallel compiler) default=mpicc
 
+        make realclean 2>/dev/null  # Extra safety
         make -j $WM_NCOMPPROCS ptscotch \
          && make \
             prefix=$prefixDIR \
@@ -218,7 +217,7 @@ then
             libdir=$libDIR \
             install
 
-        make realclean 2>/dev/null || true      # Failed cleanup is uncritical
+        make realclean 2>/dev/null || true  # Failed cleanup is uncritical
     ) || warnBuildIssues PTSCOTCH
     fi
 
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 5c1258c..6c5c6a7 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -45,6 +45,31 @@ useGcc()
     export CXX=g++
 }
 
+# Scan arguments for a '-gcc' option, forcing gcc/g++ when found
+useGccFlag()
+{
+    for i
+    do
+        if [ "$i" = "-gcc" ]
+        then
+            useGcc
+            break
+        fi
+    done
+}
+
+# Return mpiicc (for INTELMPI) or mpicc etc.
+whichMpicc()
+{
+    local mpicc
+    case "$WM_MPLIB" in
+    (INTELMPI)
+        mpicc=$(command -v mpiicc)      # Try using intel 'mpiicc'
+        ;;
+    esac
+    echo "${mpicc:-mpicc}"              # mpiicc | mpicc
+}
+
 #------------------------------------------------------------------------------
 # Some functions as per OpenFOAM etc/config.sh/functions
 
diff --git a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM b/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
index 8c83e09..c6f1bce 100644
--- a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
+++ b/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
@@ -1,21 +1,27 @@
-# openfoam notes:
+#-------------------------------*- makefile -*---------------------------------
+# OpenFOAM notes:
+#
 # WM_CFLAGS, WM_LDFLAGS contain "-m32 -fPIC" etc
 # WM_LABEL_SIZE == 64 for 'long' instead of 'int' for OpenFOAM labels
-
-# compiled without pthread
+#
+# - compiled without pthread
+#
+# Normally set CCS, CCP by caller
 
 EXE         =
 LIB         = .so
 OBJ         = .o
 
-MAKE        = make
-AR          = gcc
+AR          = $(CC)
 ARFLAGS     = $(WM_CFLAGS) -shared -o
-CAT         = cat
-CCS         = gcc
-CCP         = mpicc
-CCD         = mpicc
-CFLAGS      = $(WM_CFLAGS) -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict
+CCS        ?= $(CC)
+CCP        ?= mpicc
+CCD         = $(CCP)
+CFLAGS      = $(WM_CFLAGS) -O3 \
+    -DCOMMON_FILE_COMPRESS_GZ \
+    -DCOMMON_RANDOM_FIXED_SEED \
+    -DSCOTCH_RENAME \
+    -Drestrict=__restrict
 
 # 32-bit vs. 64-bit labels
 ifeq ($(WM_LABEL_SIZE),64)
@@ -24,10 +30,15 @@ endif
 
 CLIBFLAGS   = -shared
 LDFLAGS     = -Xlinker --no-as-needed $(WM_LDFLAGS) -lz -lm -lrt
+
+MAKE        = make
 CP          = cp
-LEX         = flex -Pscotchyy -olex.yy.c
+CAT         = cat
 LN          = ln
 MKDIR       = mkdir
 MV          = mv
 RANLIB      = echo
+LEX         = flex -Pscotchyy -olex.yy.c
 YACC        = bison -pscotchyy -y -b y
+
+#------------------------------------------------------------------------------
-- 
GitLab


From 43cffa29dbec62813d5df76312eb15fde0af5bc7 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 29 May 2017 10:52:24 +0200
Subject: [PATCH 21/27] COMP: update compilation for mesa-17.1.1

---
 BUILD.md | 10 ++++++----
 makeMesa |  3 ++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index 6cc4c2c..0e3106d 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -176,7 +176,8 @@ and save some disk space.
 
 ### Mesa
 - Needed for off-screen rendering.
-- Building with [mesa-11][older mesa] and [mesa-13][link mesa] both seem okay.
+- Building with [mesa-11][older11 mesa] and [mesa-13][older13 mesa] both
+  seem okay, as does building with [mesa-17][link mesa].
 - Building with mesa-12 is not possible since it fails to create
   the necessary `include/GL` directory and `osmesa.h` file.
 
@@ -333,7 +334,7 @@ GNU *configure* can only be used prior to clang version 3.9.
 
 | Name                  | Location
 |-----------------------|------------------------
-| [MESA][page mesa]     | [download][link mesa] or [older][older mesa]
+| [MESA][page mesa]     | [download][link mesa] or [older 13][older13 mesa], [older 11][older11 mesa]
 | [ParaView][page ParaView] | [download][link ParaView]
 | [Qt][page Qt]         | [repo][repo Qt] or [download][link Qt]. The newer [Qt5][newer Qt5] only works with ParaView-5.3.0 and later.
 
@@ -436,8 +437,9 @@ The minimum gcc/g++ requirements for building various components.
 [older ParaView]: http://www.paraview.org/files/v5.0/ParaView-v5.0.1-source.tar.gz
 
 [page mesa]:  http://mesa3d.org/
-[link mesa]:  ftp://ftp.freedesktop.org/pub/mesa/13.0.3/mesa-13.0.3.tar.xz
-[older mesa]: ftp://ftp.freedesktop.org/pub/mesa/11.2.2/mesa-11.2.2.tar.xz
+[link mesa]:  ftp://ftp.freedesktop.org/pub/mesa/mesa-17.1.1.tar.xz
+[older13 mesa]: ftp://ftp.freedesktop.org/pub/mesa/13.0.6/mesa-13.0.6.tar.xz
+[older11 mesa]: ftp://ftp.freedesktop.org/pub/mesa/older-versions/11.x/11.2.2/mesa-11.2.2.tar.xz
 
 [page Qt]: https://www.qt.io/download-open-source/
 [repo Qt]: http://code.qt.io/cgit/qt-creator/qt-creator.git
diff --git a/makeMesa b/makeMesa
index 31750cb..4ab89a5 100755
--- a/makeMesa
+++ b/makeMesa
@@ -32,7 +32,7 @@
 #     Building with mesa-12.x.x fails to create an include/GL directory and
 #     an "osmesa.h" file. Both make it fairly useless for off-screen VTK.
 #
-#     Building with mesa-11.x and mesa-13.x seem to be okay.
+#     Building with mesa-11.x, mesa-13.x and mesa-17.x seems to be okay.
 #
 # ----------------------------------------------
 # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
@@ -202,6 +202,7 @@ adjustMESA()
         --disable-xvmc \
         --disable-glx \
         --disable-dri \
+        --disable-gbm \
         --disable-egl \
         --disable-gles1 \
         --enable-texture-float \
-- 
GitLab


From 986d9120fdb5eae81c462ded50fb44225844f119 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 29 May 2017 17:16:59 +0200
Subject: [PATCH 22/27] CONFIG: update links for boost, CGAL

---
 BUILD.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index 0e3106d..5720266 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -410,10 +410,10 @@ The minimum gcc/g++ requirements for building various components.
 [link cmake]:     http://www.cmake.org/files/v3.5/cmake-3.5.2.tar.gz
 
 [page boost]:     http://boost.org
-[link boost]:     https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.tar.bz2
+[link boost]:     https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.bz2
 
 [page CGAL]:      http://cgal.org
-[link CGAL]:      https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.9/CGAL-4.9.tar.xz
+[link CGAL]:      https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.9.1/CGAL-4.9.1.tar.xz
 [older CGAL]:     https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.8.2/CGAL-4.8.2.tar.xz
 
 [page FFTW]:      http://www.fftw.org/
-- 
GitLab


From 4a0f78084b72ccfe728f08fd56b30f3d2900d549 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 14 Jun 2017 15:25:24 +0200
Subject: [PATCH 23/27] CONFIG: update links for paraview, qt

---
 BUILD.md | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index 5720266..4a3fb6a 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -352,6 +352,7 @@ The minimum CMake requirements for building various components.
     3.3         ParaView-5.1.2
     3.3         ParaView-5.2.0
     3.3         ParaView-5.3.0
+    3.3         ParaView-5.4.0
     3.4.3       llvm-3.9.1
     3.4.3       llvm-4.0.0
     3.5         ParaView-5.1.0
@@ -433,8 +434,9 @@ The minimum gcc/g++ requirements for building various components.
 <!-- Visualization -->
 
 [page ParaView]:  http://www.paraview.org/
-[link ParaView]:  http://www.paraview.org/files/v5.3/ParaView-v5.3.0.tar.gz
-[older ParaView]: http://www.paraview.org/files/v5.0/ParaView-v5.0.1-source.tar.gz
+[link ParaView]:  http://www.paraview.org/files/v5.4/ParaView-v5.4.0.tar.gz
+[older ParaView]:  http://www.paraview.org/files/v5.3/ParaView-v5.3.0.tar.gz
+[older5 ParaView]: http://www.paraview.org/files/v5.0/ParaView-v5.0.1-source.tar.gz
 
 [page mesa]:  http://mesa3d.org/
 [link mesa]:  ftp://ftp.freedesktop.org/pub/mesa/mesa-17.1.1.tar.xz
@@ -444,7 +446,7 @@ The minimum gcc/g++ requirements for building various components.
 [page Qt]: https://www.qt.io/download-open-source/
 [repo Qt]: http://code.qt.io/cgit/qt-creator/qt-creator.git
 [link Qt]: http://download.qt.io/official_releases/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz
-[newer Qt5]: http://download.qt.io/official_releases/qt/5.7/5.7.1/single/qt-everywhere-opensource-src-5.7.0.tar.xz
+[newer Qt5]: http://download.qt.io/official_releases/qt/5.9/5.9.0/single/qt-everywhere-opensource-src-5.9.0.tar.xz
 
 <!-- OpenFOAM -->
 
-- 
GitLab


From 62c8476a4e19c25c908a0d54df6d873eb6987eb6 Mon Sep 17 00:00:00 2001
From: Andrew Heather <a.heather@opencfd.co.uk>
Date: Wed, 21 Jun 2017 20:38:48 +0100
Subject: [PATCH 24/27] COMP: Updated link to current openmpi 2.1.1

---
 BUILD.md | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index 4a3fb6a..e9402f7 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -402,8 +402,7 @@ The minimum gcc/g++ requirements for building various components.
 [link scotch]:    https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz
 
 [page openmpi]:   http://www.open-mpi.org/
-[older openmpi]:  http://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.6.tar.bz2
-[link openmpi]:   https://www.open-mpi.org/software/ompi/v2.0/downloads/openmpi-2.0.2.tar.bz2
+[link openmpi]:   https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.1.tar.bz2
 
 
 <!-- general -->
-- 
GitLab


From aac32ece63a89f7bcd1c9c4e56e5e9c3d3c6d0a1 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 21 Jun 2017 08:28:40 +0100
Subject: [PATCH 25/27] STYLE: update build notes for paraview

---
 BUILD.md | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index e9402f7..fcaedc1 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -188,16 +188,16 @@ and save some disk space.
   sources that are bundled with ParaView.
   For example, by using a symbolic link:
 
-      ln -s ParaView-v5.3.0/VTK  VTK-7.1.0
+      ln -s ParaView-v5.4.0/VTK VTK-8.1.0
 
   The appropriate VTK version number can be found from the contents of
   the `vtkVersion.cmake` file.
   For example,
 
-      $ cat ParaView-v5.3.0/VTK/CMake/vtkVersion.cmake
+      $ cat ParaView-v5.4.0/VTK/CMake/vtkVersion.cmake
 
       # VTK version number components.
-      set(VTK_MAJOR_VERSION 7)
+      set(VTK_MAJOR_VERSION 8)
       set(VTK_MINOR_VERSION 1)
       set(VTK_BUILD_VERSION 0)
 
@@ -207,13 +207,17 @@ and save some disk space.
   required.
   See additional notes below about [making Qt](#makeQt) if necessary.
 
-#### 5.3.0
+#### 5.4.0
 - Compiles without patching.
   No known issues with the native OpenFOAM reader.
 
+#### 5.3.0
+- Compiles without patching.
+  The native OpenFOAM reader has a bug reading tetrahedrals.
+
 #### 5.2.0
-- Compiles without patching, but the native OpenFOAM reader appears to be
-  partially broken in this version.
+- Compiles without patching, but the native OpenFOAM reader is
+  broken in this version.
 
 #### 4.4.0/5.0.0/5.0.1/5.1.2
 - When using `makeParaView`, the following patches will be automatically
@@ -323,7 +327,7 @@ GNU *configure* can only be used prior to clang version 3.9.
 |-----------------------|------------------------
 | [CMake][page cmake]   | [download][link cmake]
 | [boost][page boost]   | [download][link boost]
-| [CGAL][page CGAL]     | [download][link CGAL] or [older][older CGAL]
+| [CGAL][page CGAL]     | [download][link CGAL]
 | [FFTW][page FFTW]     | [download][link FFTW]
 | [ADF/CGNS][page CGNS], ccm | [link ccmio][link ccmio]
 | [tecio][page tecio]   | [link tecio][link tecio]
@@ -414,7 +418,6 @@ The minimum gcc/g++ requirements for building various components.
 
 [page CGAL]:      http://cgal.org
 [link CGAL]:      https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.9.1/CGAL-4.9.1.tar.xz
-[older CGAL]:     https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.8.2/CGAL-4.8.2.tar.xz
 
 [page FFTW]:      http://www.fftw.org/
 [link FFTW]:      http://www.fftw.org/fftw-3.3.6-pl1.tar.gz
@@ -434,8 +437,6 @@ The minimum gcc/g++ requirements for building various components.
 
 [page ParaView]:  http://www.paraview.org/
 [link ParaView]:  http://www.paraview.org/files/v5.4/ParaView-v5.4.0.tar.gz
-[older ParaView]:  http://www.paraview.org/files/v5.3/ParaView-v5.3.0.tar.gz
-[older5 ParaView]: http://www.paraview.org/files/v5.0/ParaView-v5.0.1-source.tar.gz
 
 [page mesa]:  http://mesa3d.org/
 [link mesa]:  ftp://ftp.freedesktop.org/pub/mesa/mesa-17.1.1.tar.xz
-- 
GitLab


From 458d9dadbf76baa48af0a92b880ecc3cdcf18f2c Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 28 Jun 2017 13:44:48 +0200
Subject: [PATCH 26/27] CONFIG: revert to openmpi-1.10.4

- this is the same version as OpenFOAM-1612 shipped with and seems to
  have fewer issues than the newer openmpi-2.1.1
---
 BUILD.md    |  5 +++--
 sources.txt | 16 +++++++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/BUILD.md b/BUILD.md
index fcaedc1..b66b633 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -318,7 +318,7 @@ GNU *configure* can only be used prior to clang version 3.9.
 |-----------------------|------------------------
 | [adios][page adios]   | [repo][repo adios] or [github download][link adios] or [alt download][altlink adios]
 | [scotch, ptscotch][page scotch] | [download][link scotch]
-| [openmpi][page openmpi] | [download][link openmpi]
+| [openmpi][page openmpi] | [download][link openmpi]. The newer [openmpi][newer openmpi] make exhibit stability issues.
 
 
 ### General <a name="general-packages"></a>
@@ -406,7 +406,8 @@ The minimum gcc/g++ requirements for building various components.
 [link scotch]:    https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz
 
 [page openmpi]:   http://www.open-mpi.org/
-[link openmpi]:   https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.1.tar.bz2
+[link openmpi]:   https://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.4.tar.bz2
+[newer openmpi]:  https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.1.tar.bz2
 
 
 <!-- general -->
diff --git a/sources.txt b/sources.txt
index cc7f8e5..5518442 100644
--- a/sources.txt
+++ b/sources.txt
@@ -1,7 +1,17 @@
 Third-Party Sources
 ===================
 
-OpenFOAM+ v1612
+OpenFOAM-1706
+---------------
+CGAL-4.9.1
+ParaView-5.4.0
+boost_1_64_0
+fftw-3.3.6-pl1
+openmpi-1.10.4
+scotch_6.0.3
+
+
+OpenFOAM-1612
 ---------------
 CGAL-4.9
 ParaView-5.0.1
@@ -11,7 +21,7 @@ openmpi-1.10.4
 scotch_6.0.3
 
 
-OpenFOAM+ v1606
+OpenFOAM-1606
 ---------------
 CGAL-4.8
 ParaView-5.0.1
@@ -21,7 +31,7 @@ openmpi-1.10.2
 scotch_6.0.3
 
 
-OpenFOAM+ v3.0
+OpenFOAM v3.0+
 ---------------
 CGAL-4.7
 ParaView-4.4.0
-- 
GitLab


From 4a6ab3779f7973754467cc01ec15ccc167230531 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 29 Jun 2017 10:40:29 +0200
Subject: [PATCH 27/27] COMP: handle mesa library in lib64 or lib (fixes #16)

- only addresses -mesa-prefix behaviour.
  The -mesa-lib option makes no assumptions at all.

STYLE: update versions in makeParaView.example, makeVTK.example
---
 makeParaView         | 2 ++
 makeParaView.example | 3 ++-
 makeVTK              | 2 ++
 makeVTK.example      | 5 +++--
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/makeParaView b/makeParaView
index 4045767..666e5e0 100755
--- a/makeParaView
+++ b/makeParaView
@@ -200,7 +200,9 @@ do
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         withMESA=true
         MESA_INCLUDE="${2%%/}/include"
+        # Could be under (lib64 | lib)
         MESA_LIBRARY="${2%%/}/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
+        [ -f "$MESA_LIBRARY" ] || MESA_LIBRARY="${2%%/}/lib/libOSMesa.so"
         shift
         ;;
     -mesa-include)
diff --git a/makeParaView.example b/makeParaView.example
index b32d784..9caf442 100755
--- a/makeParaView.example
+++ b/makeParaView.example
@@ -4,7 +4,8 @@
 # - mesa
 
 # mesa=mesa-11.2.2
-mesa=mesa-13.0.3
+# mesa=mesa-13.0.3
+mesa=mesa-17.1.1
 
 ./makeParaView \
     -mpi=0 \
diff --git a/makeVTK b/makeVTK
index 65aea19..99ead3d 100755
--- a/makeVTK
+++ b/makeVTK
@@ -183,7 +183,9 @@ do
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         withMESA=true
         MESA_INCLUDE="${2%%/}/include"
+        # Could be under (lib64 | lib)
         MESA_LIBRARY="${2%%/}/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
+        [ -f "$MESA_LIBRARY" ] || MESA_LIBRARY="${2%%/}/lib/libOSMesa.so"
         shift
         ;;
     -mesa-include)
diff --git a/makeVTK.example b/makeVTK.example
index 3cd33d2..46d6e4c 100755
--- a/makeVTK.example
+++ b/makeVTK.example
@@ -2,9 +2,10 @@
 # An example for building particular combinations of VTK with
 # - mesa (off-screen only)
 
-vtk=VTK-7.1.0
+vtk=VTK-8.1.0
 # mesa=mesa-11.2.2
-mesa=mesa-13.0.3
+# mesa=mesa-13.0.3
+mesa=mesa-17.1.1
 
 ./makeVTK \
     $vtk \
-- 
GitLab