From 376a2b66f442223a58efc0f832b861ab08f3eb0f Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 14 Jun 2016 17:33:27 +0200
Subject: [PATCH 01/40] GIT: Merge in foundation/master with cleanup
 (2016-06-14)

The ThirdParty repository from the Foundation now includes some
3rd-party source code (paraview, scotch) as well.

To avoid this bloat (ca. 50MB), now and in the future, it is
unfortunately necessary to break the linear history and the direct
connection with the Foundation repository.

This commit is a squashed merge of the current Foundation master branch
with some minor adjustments.

Stop tracking of the derived README.html file.

===========================================================================
Changes prior to merge:

commit 3cb21d12be069561fbe13461440cbdf1c8b188d5
Author: mark <mark@opencfd>
Date:   Tue Jun 14 17:18:40 2016 +0200

    GIT: rationalize .gitignore

    - do not track derived content.
    - do track wmake files etc. (re-instates some content)

commit d1bf108bea922bf60a1002c4641770b91f09f226
Author: Henry Weller <http://cfd.direct>
Date:   Sat Nov 7 21:44:27 2015 +0000

    Reinstated Qt build scripts
    Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1905

commit 7302adf5d0a7bafe635c5d0470f00a6fe78a57f6
Author: mark <mark@opencfd>
Date:   Tue Jun 14 17:15:27 2016 +0200

    Revert "scotch_6.0.3: Added to the source tree to simplify building OpenFOAM"

    This reverts commit 1cce60aa78540bf96783684523e1cac4b6a78043.

commit fbe0018d5fd4d5f94f00f8e7efd3ae11b6ab41b5
Author: mark <mark@opencfd>
Date:   Tue Jun 14 17:15:03 2016 +0200

    Revert "ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file"

    This reverts commit eba760a6d6bb44860fc7d94d922be7215ee93c1f.

===========================================================================
All changes since NOV-2015 are included in the merge:

commit 17cafd35812493f9a39e56c7355f49c1d3eef2d0
Author: Henry Weller <http://cfd.direct>
Date:   Thu Jun 9 14:36:59 2016 +0100

    makeGcc, makeCGAL: lib -> lib64 on 64bit OSs
    Patch contributed by Bruno Santos
    Resolves patch request http://bugs.openfoam.org/view.php?id=2114

commit ce4951579b8e01ce524ed6e465ea352e6a243f1b
Author: Henry Weller <http://cfd.direct>
Date:   Wed Jun 8 15:14:47 2016 +0100

    ThirdParty-dev/makeGcc: added "-no-multilib" option
    Patch contributed by Bruno Santos
    Resolves patch request http://bugs.openfoam.org/view.php?id=2113

commit f72ad1f0a66338e5c342efed47079347e1db16d0
Author: Henry Weller <http://cfd.direct>
Date:   Tue May 31 09:16:57 2016 +0100

    README: Updated download instructions

commit eba760a6d6bb44860fc7d94d922be7215ee93c1f
Author: Henry Weller <http://cfd.direct>
Date:   Mon May 30 21:20:56 2016 +0100

    ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file
    Resolves bug-report http://bugs.openfoam.org/view.php?id=2098

commit 1cce60aa78540bf96783684523e1cac4b6a78043
Author: Henry Weller <http://cfd.direct>
Date:   Mon May 30 21:17:14 2016 +0100

    scotch_6.0.3: Added to the source tree to simplify building OpenFOAM
    Recent versions of scotch are rarely available in packaged form for
    ready installation on GNU/Linux distributions and so the sources are
    generally required.

commit 08df75f4c7339520880fcf9dd243e9c414cbfe7e
Author: Henry Weller <http://cfd.direct>
Date:   Mon May 30 21:16:54 2016 +0100

    .gitignore: Simplified

commit ef2d69ba55076ba14ab0c771ac2981b94ab60f2e
Author: Henry Weller <http://cfd.direct>
Date:   Mon May 30 21:16:27 2016 +0100

    README: Updated instructions for compiling ParaView-5.0.1

commit 7cdc8b196acfa021c4ff23036714aaee5e1b9612
Author: Henry Weller <http://cfd.direct>
Date:   Mon May 30 12:30:17 2016 +0100

    README: Upgraded to CGAL-4.8

commit bc8ce83166a05db0dc197a7a203634aa6d25c96f
Author: Henry Weller <http://cfd.direct>
Date:   Mon May 30 12:28:27 2016 +0100

    makeCGAL: Updated to CGAL-4.8

commit c0afdcde7920538ceaf9e0c78827e3a3f18f541d
Author: Henry Weller <http://cfd.direct>
Date:   Mon May 23 18:46:27 2016 +0100

    etc/tools/ParaViewFunctions: Improve instructions for updating the environment after compiling ParaView

commit b627924a4bf104521b567d3aa3dc80c864325b1a
Author: Henry Weller <http://cfd.direct>
Date:   Tue May 10 11:38:00 2016 +0100

    Allwmake: Added scripted changes for REALTYPEWIDTH and IDXTYPEWIDTH
    Patch contributed by Bruno Santos
    Resolves bug-report http://bugs.openfoam.org/view.php?id=2085

commit 69dba76b3195420c71173a65b1c227b2650eaebf
Author: Henry Weller <http://cfd.direct>
Date:   Sun Apr 3 14:43:58 2016 +0100

    Further changes for http://www.openfoam.org/mantisbt/view.php?id=2040
    Patch provided by Bruno Santos

commit 1379e08a39ef9e199307e9b6608e7ad97ed03b77
Author: Henry Weller <http://cfd.direct>
Date:   Sun Apr 3 10:30:43 2016 +0100

    Allwmake: Implement the default "stop on 1st error"
    Patch contributed by Bruno Santos
    Resolves tweak http://www.openfoam.org/mantisbt/view.php?id=2040

commit 8c9c235db686de2612c62112b37e132bfa773b16
Author: Henry Weller <http://cfd.direct>
Date:   Wed Mar 30 19:28:28 2016 +0100

    Updated handling of the ParaView installation path
    Patch contributed by Bruno Santos
    Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=2034

commit d88b4ea88db7d35c7b7fe8d869d59be32a224144
Author: Henry Weller <http://cfd.direct>
Date:   Mon Mar 21 23:03:59 2016 +0000

    makeCGAL: Corrected typo
    Patch contributed by Bruno Santos
    Resolves report http://www.openfoam.org/mantisbt/view.php?id=1215

commit 578f8827fbc5f709595fc5ab5185053aaa8cf678
Author: Henry Weller <http://cfd.direct>
Date:   Mon Mar 14 11:13:23 2016 +0000

    Make scripts updated to use the new OpenFOAM-dev/ets/config.sh variables
    Contributed by Bruno Santos
    Resolves patch request http://www.openfoam.org/mantisbt/view.php?id=1215
    See also http://www.openfoam.org/mantisbt/view.php?id=1232

commit c8904e60d2c97ee3c4865bb34419758a10cb2a5a
Author: Henry Weller <http://cfd.direct>
Date:   Tue Feb 16 08:57:29 2016 +0000

    scripts: Reformat with consistent section separators

commit 43f2b369458ff87d0c85c493586d12b75855cf32
Author: Henry Weller <http://cfd.direct>
Date:   Tue Feb 16 08:56:26 2016 +0000

    ThirdParty-dev/etc/tools/ParaViewFunctions: Updated docs
    Including patch from Bruno Santos
    Resolves report http://www.openfoam.org/mantisbt/view.php?id=1997

commit dfe9e823de452f4c540aa4d02dcf5058e063dd44
Author: Henry Weller <http://cfd.direct>
Date:   Wed Feb 10 20:44:32 2016 +0000

    README.org: Upgrade OpenMPI link to openmpi-1.10.2

commit 99d158539e21a3a86d9ac9d5d6f67834142a1847
Author: Henry Weller <http://cfd.direct>
Date:   Wed Feb 10 20:21:34 2016 +0000

    Rename makeParaView4 makeParaView and update to support versions 4 and 5
    Rename makeParaView makeParaView3 specifically for ParaView version 3

commit 8219a109a24d0699f689cf29a6ce6b4190dc84f0
Author: Henry Weller <http://cfd.direct>
Date:   Wed Feb 10 16:21:23 2016 +0000

    Updates for changes to etc/config structure

commit c6474e672655864b784950b3bc12e245745ea64d
Author: Henry Weller <http://cfd.direct>
Date:   Sun Feb 7 10:30:22 2016 +0000

    README: Added download link for ParaView-5.0.0

commit 2da4d8ccea67b4d194161f03c2aca8f693789121
Author: Henry Weller <http://cfd.direct>
Date:   Sun Feb 7 10:27:46 2016 +0000

    README: Updated for ParaView-5.0.0

commit 730b8840f7a47e4807c5c239caf337b49960fc9b
Author: Henry Weller <http://cfd.direct>
Date:   Sun Feb 7 10:26:15 2016 +0000

    makeGcc: Removed support for gcc versions older the 4.5

commit 2500c120b9cd29b5b46d4ca118a60dfac78a8923
Author: Henry Weller <http://cfd.direct>
Date:   Mon Nov 2 20:00:59 2015 +0000

    README.org: Added patch instructions for ParaView-4.4.0 from
    http://www.openfoam.org/mantisbt/view.php?id=1887

===========================================================================
---
 .gitignore                                    |  69 +---
 Allclean                                      |   2 +-
 Allwmake                                      |  34 +-
 AllwmakeLibccmio                              |   6 +-
 README.html                                   | 335 ------------------
 README.org                                    |  49 ++-
 ...{ParaView4Functions => ParaView3Functions} |  77 +++-
 etc/tools/ParaViewFunctions                   | 148 ++++----
 etc/tools/ThirdPartyFunctions                 |  22 +-
 makeCGAL                                      |  47 ++-
 makeCmake                                     |   2 +-
 makeGcc                                       |  63 ++--
 makeGperftools                                |   2 +-
 makeLLVM                                      |  11 +-
 makeParaView                                  |  15 +-
 makeParaView4 => makeParaView3                |  20 +-
 16 files changed, 324 insertions(+), 578 deletions(-)
 delete mode 100644 README.html
 rename etc/tools/{ParaView4Functions => ParaView3Functions} (86%)
 rename makeParaView4 => makeParaView3 (95%)

diff --git a/.gitignore b/.gitignore
index 4565478..b058312 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,79 +1,32 @@
-# man gitignore for more information
-
-# editor and misc backup files - anywhere
+# Ignore editor and misc backup files - anywhere
 *~
 .*~
 *.bak
 *.bak[0-9][0-9]
-*.orig
-*.orig[0-9][0-9]
 \#*\#
 
-# file-browser settings - anywhere
-.directory
-
-# CVS recovered versions - anywhere
-.#*
-
-# objects and archives - anywhere
-*.[oa]
-*.la
-*.so
-*.jar
-
-# derived files
-lex.yy.c
-
-# Corefiles
-core
-
-# dependency files - anywhere
-*.dep
-
-# lnInclude (symlink) folders - anywhere
-lnInclude
-
-# build folders - anywhere
-linux*Gcc*/
-linux*Icc*/
-linuxming*/
-SiCortex*Gcc*/
-solaris*Gcc*/
-SunOS*Gcc*/
-
-# source packages - anywhere
+# Ignore source packages - anywhere
 *.tar.bz2
 *.tar.gz
 *.tar
 *.tgz
 *.gtgz
 
+# Ignore build and platforms folders
+build/
+platforms/
 
-# ignore the persistent .build tag in the main directory
-/.build
-
-# ignore .timeStamp in the main directory
-/.timeStamp
+# Generated files in the main directory
+/*.html
 
-# ignore unpacked sources in the main directory (match pkg-ver)
+# Ignore unpacked sources in the main directory (match pkg-ver)
 # this also matches symlinks
 /*[-_][0-9]*
 
-# ignore all sub-directories
+# Ignore all top-level sub-directories
 /*/
 
-# do not ignore these ones
+# Do not ignore these ones though
 !/etc/
 
-# do not ignore the first level of these ones
-!/malloc/
-/malloc/*/
-!/malloc/fbsdmalloc/
-
-# ignore these extra symlinks
-libccmio
-
-# track this patched version directly - until metis gets dropped
-!/metis-5.0pre2/libmetis/metislib.h
-
-# end-of-file
+# End-of-file
diff --git a/Allclean b/Allclean
index 524fde9..de5c650 100755
--- a/Allclean
+++ b/Allclean
@@ -59,4 +59,4 @@ done
 [ -d platforms ] && ( set -x; rm -rf platforms/* )
 
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/Allwmake b/Allwmake
index 1b06a50..977a53e 100755
--- a/Allwmake
+++ b/Allwmake
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -77,7 +77,7 @@ OPENMPI)
         set -x
         cd "${MPI_ARCH_PATH##*/}" || exit 1    # change to openmpi-VERSION
 
-        make distclean 2>/dev/null
+        [ -e Makefile ] && make distclean 2>/dev/null
         rm -rf $MPI_ARCH_PATH
 
         # start with GridEngine support,
@@ -122,7 +122,7 @@ MPICH)
         set -x
         cd $MPI_HOME || exit 1    # change to mpich-VERSION
 
-        make distclean 2>/dev/null
+        [ -e Makefile ] && make distclean 2>/dev/null
         rm -rf $MPI_ARCH_PATH
         rm util/machines/machines.*
 
@@ -173,12 +173,12 @@ esac
 
 
 # get SCOTCH_VERSION, SCOTCH_ARCH_PATH
-if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config/scotch.sh`
+if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch`
 then
     . $settings
 else
     echo
-    echo "Error: no config/scotch.sh settings"
+    echo "Error: no config.sh/scotch settings"
     echo
 fi
 
@@ -306,14 +306,14 @@ then
 fi
 
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 
 # Metis is optional
 echo ========================================
 echo Build Metis decomposition
 
 # get METIS_VERSION, METIS_ARCH_PATH
-if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config/metis.sh`
+if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis`
 then
     . $settings
 fi
@@ -330,6 +330,24 @@ then
     (
         set -x
         cd $METIS_VERSION  || exit 1
+
+        if [ "$WM_PRECISION_OPTION" = "DP" ]
+        then
+            FLOAT_PRECISION=64
+        elif [ "$WM_PRECISION_OPTION" = "SP" ]
+        then
+            FLOAT_PRECISION=32
+        else
+            echo " Metis pre-configure error:"
+            echo "    WM_PRECISION_OPTION is neither DP nor SP"
+            exit 1
+        fi
+
+        # Change user settings automatically
+        sed -i -e 's=\(#define IDXTYPEWIDTH\).*=\1 '$WM_LABEL_SIZE'=' \
+               -e 's=\(#define REALTYPEWIDTH\).*=\1 '$FLOAT_PRECISION'=' \
+            include/metis.h
+
         make config shared=1 prefix=$METIS_ARCH_PATH
         make -j $WM_NCOMPPROCS install
         cp $METIS_ARCH_PATH/lib/libmetis.so $FOAM_EXT_LIBBIN
@@ -365,4 +383,4 @@ echo ========================================
 echo
 
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/AllwmakeLibccmio b/AllwmakeLibccmio
index a3473a5..87330ee 100755
--- a/AllwmakeLibccmio
+++ b/AllwmakeLibccmio
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -26,7 +26,7 @@
 #     AllwmakeLibccmio
 #
 # Description
-#     Get and build CD-adapco's ccmio library
+#     Build CD-adapco's ccmio library
 #
 #------------------------------------------------------------------------------
 packageDir=libccmio-2.6.1
@@ -82,4 +82,4 @@ set -x
 )
 
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/README.html b/README.html
deleted file mode 100644
index 97a4a94..0000000
--- a/README.html
+++ /dev/null
@@ -1,335 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
-<head>
-<title>OpenFOAM-3.0.x Third-Party packages</title>
-<!-- 2015-11-03 Tue 17:54 -->
-<meta  http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<meta  name="generator" content="Org-mode" />
-<style type="text/css">
- <!--/*--><![CDATA[/*><!--*/
-  .title  { text-align: center; }
-  .todo   { font-family: monospace; color: red; }
-  .done   { color: green; }
-  .tag    { background-color: #eee; font-family: monospace;
-            padding: 2px; font-size: 80%; font-weight: normal; }
-  .timestamp { color: #bebebe; }
-  .timestamp-kwd { color: #5f9ea0; }
-  .right  { margin-left: auto; margin-right: 0px;  text-align: right; }
-  .left   { margin-left: 0px;  margin-right: auto; text-align: left; }
-  .center { margin-left: auto; margin-right: auto; text-align: center; }
-  .underline { text-decoration: underline; }
-  #postamble p, #preamble p { font-size: 90%; margin: .2em; }
-  p.verse { margin-left: 3%; }
-  pre {
-    border: 1px solid #ccc;
-    box-shadow: 3px 3px 3px #eee;
-    padding: 8pt;
-    font-family: monospace;
-    overflow: auto;
-    margin: 1.2em;
-  }
-  pre.src {
-    position: relative;
-    overflow: visible;
-    padding-top: 1.2em;
-  }
-  pre.src:before {
-    display: none;
-    position: absolute;
-    background-color: white;
-    top: -10px;
-    right: 10px;
-    padding: 3px;
-    border: 1px solid black;
-  }
-  pre.src:hover:before { display: inline;}
-  pre.src-sh:before    { content: 'sh'; }
-  pre.src-bash:before  { content: 'sh'; }
-  pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
-  pre.src-R:before     { content: 'R'; }
-  pre.src-perl:before  { content: 'Perl'; }
-  pre.src-java:before  { content: 'Java'; }
-  pre.src-sql:before   { content: 'SQL'; }
-
-  table { border-collapse:collapse; }
-  caption.t-above { caption-side: top; }
-  caption.t-bottom { caption-side: bottom; }
-  td, th { vertical-align:top;  }
-  th.right  { text-align: center;  }
-  th.left   { text-align: center;   }
-  th.center { text-align: center; }
-  td.right  { text-align: right;  }
-  td.left   { text-align: left;   }
-  td.center { text-align: center; }
-  dt { font-weight: bold; }
-  .footpara:nth-child(2) { display: inline; }
-  .footpara { display: block; }
-  .footdef  { margin-bottom: 1em; }
-  .figure { padding: 1em; }
-  .figure p { text-align: center; }
-  .inlinetask {
-    padding: 10px;
-    border: 2px solid gray;
-    margin: 10px;
-    background: #ffffcc;
-  }
-  #org-div-home-and-up
-   { text-align: right; font-size: 70%; white-space: nowrap; }
-  textarea { overflow-x: auto; }
-  .linenr { font-size: smaller }
-  .code-highlighted { background-color: #ffff00; }
-  .org-info-js_info-navigation { border-style: none; }
-  #org-info-js_console-label
-    { font-size: 10px; font-weight: bold; white-space: nowrap; }
-  .org-info-js_search-highlight
-    { background-color: #ffff00; color: #000000; font-weight: bold; }
-  /*]]>*/-->
-</style>
-<script type="text/javascript">
-/*
-@licstart  The following is the entire license notice for the
-JavaScript code in this tag.
-
-Copyright (C) 2012-2013 Free Software Foundation, Inc.
-
-The JavaScript code in this tag is free software: you can
-redistribute it and/or modify it under the terms of the GNU
-General Public License (GNU GPL) as published by the Free Software
-Foundation, either version 3 of the License, or (at your option)
-any later version.  The code is distributed WITHOUT ANY WARRANTY;
-without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
-
-As additional permission under GNU GPL version 3 section 7, you
-may distribute non-source (e.g., minimized or compacted) forms of
-that code without the copy of the GNU GPL normally required by
-section 4, provided you include this license notice and a URL
-through which recipients can access the Corresponding Source.
-
-
-@licend  The above is the entire license notice
-for the JavaScript code in this tag.
-*/
-<!--/*--><![CDATA[/*><!--*/
- function CodeHighlightOn(elem, id)
- {
-   var target = document.getElementById(id);
-   if(null != target) {
-     elem.cacheClassElem = elem.className;
-     elem.cacheClassTarget = target.className;
-     target.className = "code-highlighted";
-     elem.className   = "code-highlighted";
-   }
- }
- function CodeHighlightOff(elem, id)
- {
-   var target = document.getElementById(id);
-   if(elem.cacheClassElem)
-     elem.className = elem.cacheClassElem;
-   if(elem.cacheClassTarget)
-     target.className = elem.cacheClassTarget;
- }
-/*]]>*///-->
-</script>
-</head>
-<body>
-<div id="content">
-<h1 class="title">OpenFOAM-3.0.x Third-Party packages</h1>
-<div id="table-of-contents">
-<h2>Table of Contents</h2>
-<div id="text-table-of-contents">
-<ul>
-<li><a href="#sec-1">1. Description</a></li>
-<li><a href="#sec-2">2. Order of execution:</a>
-<ul>
-<li><a href="#sec-2-1">2.1. Optional</a></li>
-</ul>
-</li>
-<li><a href="#sec-3">3. Versions and locations to download the third party packages</a>
-<ul>
-<li><a href="#sec-3-1">3.1. Gcc C++ Compiler</a></li>
-<li><a href="#sec-3-2">3.2. Parallel Processing</a></li>
-<li><a href="#sec-3-3">3.3. ParaView</a></li>
-<li><a href="#sec-3-4">3.4. CGAL</a></li>
-<li><a href="#sec-3-5">3.5. Miscellaneous</a></li>
-</ul>
-</li>
-<li><a href="#sec-4">4. Notes</a>
-<ul>
-<li><a href="#sec-4-1">4.1. Building ParaView-4.3.1/4.4.0</a></li>
-<li><a href="#sec-4-2">4.2. Building ParaView-4.1.0</a></li>
-</ul>
-</li>
-</ul>
-</div>
-</div>
-
-<div id="outline-container-sec-1" class="outline-2">
-<h2 id="sec-1"><span class="section-number-2">1</span> Description</h2>
-<div class="outline-text-2" id="text-1">
-<p>
-Scripts for building third-party packages.
-</p>
-</div>
-</div>
-<div id="outline-container-sec-2" class="outline-2">
-<h2 id="sec-2"><span class="section-number-2">2</span> Order of execution:</h2>
-<div class="outline-text-2" id="text-2">
-<ul class="org-ul">
-<li>makeGcc   (recommended if the system gcc is &lt; 4.7)
-</li>
-<li>Allwmake  (Builds OpenMPI, Scotch etc.)
-</li>
-<li>makeCmake (if the system cmake version is &lt; 2.8.8)
-</li>
-<li>makeParaView4
-</li>
-</ul>
-</div>
-<div id="outline-container-sec-2-1" class="outline-3">
-<h3 id="sec-2-1"><span class="section-number-3">2.1</span> Optional</h3>
-<div class="outline-text-3" id="text-2-1">
-<ul class="org-ul">
-<li>AllwmakeLibccmio (Only required for conversion of STAR-CCM+ meshes)
-</li>
-<li>Allclean (Only required to save disk space)
-</li>
-</ul>
-</div>
-</div>
-</div>
-<div id="outline-container-sec-3" class="outline-2">
-<h2 id="sec-3"><span class="section-number-2">3</span> Versions and locations to download the third party packages</h2>
-<div class="outline-text-2" id="text-3">
-</div><div id="outline-container-sec-3-1" class="outline-3">
-<h3 id="sec-3-1"><span class="section-number-3">3.1</span> Gcc C++ Compiler</h3>
-<div class="outline-text-3" id="text-3-1">
-<p>
-The minimum version of gcc required is 4.5.0
-</p>
-<ul class="org-ul">
-<li>gcc   <a href="http://gcc.gnu.org/releases.html">http://gcc.gnu.org/releases.html</a>
-</li>
-<li>gmp   <a href="http://gmplib.org/">http://gmplib.org/</a>
-            <a href="ftp://ftp.gnu.org/gnu/gmp/gmp-5.1.2.tar.bz2">ftp://ftp.gnu.org/gnu/gmp/gmp-5.1.2.tar.bz2</a>
-</li>
-<li>mpfr  <a href="http://www.mpfr.org/">http://www.mpfr.org/</a>
-            <a href="ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.bz2">ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.bz2</a>
-</li>
-<li>mpc   <a href="http://www.multiprecision.org/">http://www.multiprecision.org/</a>
-            <a href="http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz">http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz</a>
-</li>
-</ul>
-</div>
-</div>
-<div id="outline-container-sec-3-2" class="outline-3">
-<h3 id="sec-3-2"><span class="section-number-3">3.2</span> Parallel Processing</h3>
-<div class="outline-text-3" id="text-3-2">
-<ul class="org-ul">
-<li>OpenMPI: <a href="http://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.0.tar.bz2">http://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.0.tar.bz2</a>
-</li>
-<li>Scotch/PtScotch: <a href="https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz">https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz</a>
-</li>
-</ul>
-</div>
-</div>
-<div id="outline-container-sec-3-3" class="outline-3">
-<h3 id="sec-3-3"><span class="section-number-3">3.3</span> ParaView</h3>
-<div class="outline-text-3" id="text-3-3">
-<ul class="org-ul">
-<li>cmake       <a href="http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz">http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz</a>
-</li>
-<li>ParaView    <a href="http://www.paraview.org/files/v4.4/ParaView-v4.4.0-source.tar.gz">http://www.paraview.org/files/v4.4/ParaView-v4.4.0-source.tar.gz</a>
-</li>
-</ul>
-</div>
-</div>
-<div id="outline-container-sec-3-4" class="outline-3">
-<h3 id="sec-3-4"><span class="section-number-3">3.4</span> CGAL</h3>
-<div class="outline-text-3" id="text-3-4">
-<ul class="org-ul">
-<li>CGAL        <a href="https://github.com/CGAL/cgal/releases/download/releases/CGAL-4.7/CGAL-4.7.tar.xz">https://github.com/CGAL/cgal/releases/download/releases/CGAL-4.7/CGAL-4.7.tar.xz</a>
-</li>
-<li>boost       <a href="http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download">http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download</a>
-</li>
-</ul>
-</div>
-</div>
-<div id="outline-container-sec-3-5" class="outline-3">
-<h3 id="sec-3-5"><span class="section-number-3">3.5</span> Miscellaneous</h3>
-<div class="outline-text-3" id="text-3-5">
-<ul class="org-ul">
-<li>libccmio    <a href="http://portal.nersc.gov/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz">http://portal.nersc.gov/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz</a>
-</li>
-</ul>
-</div>
-</div>
-</div>
-<div id="outline-container-sec-4" class="outline-2">
-<h2 id="sec-4"><span class="section-number-2">4</span> Notes</h2>
-<div class="outline-text-2" id="text-4">
-</div><div id="outline-container-sec-4-1" class="outline-3">
-<h3 id="sec-4-1"><span class="section-number-3">4.1</span> Building ParaView-4.3.1/4.4.0</h3>
-<div class="outline-text-3" id="text-4-1">
-<p>
-The ParaView-4.3.1/4.4.0 source-pack provided by KitWare will not build and
-install correctly without a minor correction: lines 653-656 must be removed
-or commented from file
-<i>ThirdParty-3.0.0/ParaView-4.?.?/Qt/Components/CMakeLists.txt</i> after
-unpacking and renaming the ParaView-4.?.? directory.  This is because the
-file ui_pqExportStateWizard.h referred to in the lines 653-656:
-</p>
-<div class="org-src-container">
-
-<pre class="src src-C"><span style="color: #0000cd; font-weight: bold;">if</span>(PARAVIEW_INSTALL_DEVELOPMENT_FILES)
-  install(FILES <span style="color: #008b00;">"${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"</span>
-          DESTINATION <span style="color: #008b00;">"${VTK_INSTALL_INCLUDE_DIR}"</span>)
-endif()
-</pre>
-</div>
-<p>
-does not exist and cannot be installed causing the build and installation to
-fail.
-</p>
-
-<p>
-Additionally for ParaView-4.4.0 there is a bug in the STL reader which can
-be patched by running the following command from within the ThirdParty-???
-directory:
-</p>
-<ul class="org-ul">
-<li>wget <a href="https://raw.githubusercontent.com/Kitware/VTK/40937e934308e5009e80769dc0c451ee4f157749/IO/Geometry/vtkSTLReader.cxx">https://raw.githubusercontent.com/Kitware/VTK/40937e934308e5009e80769dc0c451ee4f157749/IO/Geometry/vtkSTLReader.cxx</a> -O ParaView-4.4.0/VTK/IO/Geometry/vtkSTLReader.cxx
-</li>
-</ul>
-<p>
-See also <a href="http://www.openfoam.org/mantisbt/view.php?id=1887">http://www.openfoam.org/mantisbt/view.php?id=1887</a>
-</p>
-</div>
-</div>
-
-<div id="outline-container-sec-4-2" class="outline-3">
-<h3 id="sec-4-2"><span class="section-number-3">4.2</span> Building ParaView-4.1.0</h3>
-<div class="outline-text-3" id="text-4-2">
-<p>
-On Ubuntu 14.10 and higher, OpenSuSE 13.2 and probably other recent
-GNU/Linux distributions there is an issue in the GL libraries requiring a
-change to the vtkXOpenGLRenderWindow.cxx file in ParaView: Uncomment line 30
-</p>
-
-<p>
-#define GLX_GLXEXT_LEGACY
-</p>
-</div>
-</div>
-</div>
-</div>
-<div id="postamble" class="status">
-<p class="date">Date: 3rd November 2015</p>
-<p class="date">Created: 2015-11-03 Tue 17:54</p>
-<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.5 (<a href="http://orgmode.org">Org</a> mode 8.2.10)</p>
-<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
-</div>
-</body>
-</html>
diff --git a/README.org b/README.org
index 01f8d50..9129eb3 100644
--- a/README.org
+++ b/README.org
@@ -1,11 +1,11 @@
 #                            -*- mode: org; -*-
 #
-#+TITLE:              OpenFOAM-3.0.x Third-Party packages
+#+TITLE:                 OpenFOAM Third-Party packages
 #+AUTHOR:                  The OpenFOAM Foundation
-#+DATE:                       3rd November 2015
+#+DATE:                       31th May 2016
 #+LINK:                     http://www.openfoam.org
 #+OPTIONS: author:nil ^:{}
-# Copyright (c) 2015 OpenFOAM Foundation.
+# Copyright (c) 2014-2016 OpenFOAM Foundation.
 
 * Description
   Scripts for building third-party packages.
@@ -13,7 +13,7 @@
   + makeGcc   (recommended if the system gcc is < 4.7)
   + Allwmake  (Builds OpenMPI, Scotch etc.)
   + makeCmake (if the system cmake version is < 2.8.8)
-  + makeParaView4
+  + makeParaView
 *** Optional
     + AllwmakeLibccmio (Only required for conversion of STAR-CCM+ meshes)
     + Allclean (Only required to save disk space)
@@ -28,24 +28,29 @@
     + mpc   http://www.multiprecision.org/
             http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz
 *** Parallel Processing
-    + OpenMPI: http://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.0.tar.bz2
-    + Scotch/PtScotch: https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz
+***** Scotch
+      + Scotch/PtScotch: https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz
+***** OpenMPI
+      + OpenMPI: http://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.2.tar.bz2
 *** ParaView
-    + cmake       http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz
-    + ParaView    http://www.paraview.org/files/v4.4/ParaView-v4.4.0-source.tar.gz
+    + cmake          http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz
+    + ParaView-4.4.0 http://www.paraview.org/files/v4.4/ParaView-v4.4.0-source.tar.gz
+    + ParaView-5.0.1 http://www.paraview.org/files/v5.0/ParaView-v5.0.1-source.tar.gz
+    but may need patching to compile (See [[Notes]]).
 *** CGAL
-    + CGAL        https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.7/CGAL-4.7.tar.xz
+    + CGAL        https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.8/CGAL-4.8.tar.xz
     + boost       http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download
 *** Miscellaneous
     + libccmio    http://portal.nersc.gov/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz
 * Notes
-*** Building ParaView-4.3.1/4.4.0
-    The ParaView-4.3.1/4.4.0 source-pack provided by KitWare will not build and
-    install correctly without a minor correction: lines 653-656 must be removed
-    or commented from file
-    /ThirdParty-3.0.0/ParaView-4.?.?/Qt/Components/CMakeLists.txt/ after
-    unpacking and renaming the ParaView-4.?.? directory.  This is because the
-    file ui_pqExportStateWizard.h referred to in the lines 653-656:
+*** Building ParaView-4.3.1/4.4.0/5.0.0/5.0.1
+    The ParaView-4.3.1/4.4.0/5.0.0 source-pack provided by KitWare will not
+    build and install correctly without a minor correction: lines 653-656
+    (650-653 in ParaView-5.0.0, 659-662 in ParaView-5.0.1) must be removed or
+    commented from file
+    /ThirdParty-???/ParaView-[45].?.?/Qt/Components/CMakeLists.txt/ after
+    unpacking and renaming the ParaView-[45].?.? directory.  This is because the
+    file ui_pqExportStateWizard.h referred to in
     #+begin_src C
     if(PARAVIEW_INSTALL_DEVELOPMENT_FILES)
       install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"
@@ -60,7 +65,17 @@
     directory:
     + wget https://raw.githubusercontent.com/Kitware/VTK/40937e934308e5009e80769dc0c451ee4f157749/IO/Geometry/vtkSTLReader.cxx -O ParaView-4.4.0/VTK/IO/Geometry/vtkSTLReader.cxx
     See also http://www.openfoam.org/mantisbt/view.php?id=1887
-
+*** Building ParaView-5.0.1 with gcc-6.1.0
+***** Add support for gcc-6.?.?
+      The following cmake files
+      + ParaView-5.0.1/VTK/CMake/vtkCompilerExtras.cmake
+      + ParaView-5.0.1/VTK/CMake/GenerateExportHeader.cmake
+      specifically limit the gcc versions supported.  To add support gcc-6.?.?
+      replace '[345]' with '[3456]'
+***** SciberQuestToolKit
+      The SciberQuestToolKit plugin fails to compile with gcc-6.1.0 and causes
+      the compilation of ParaView to halt.  The easiest solution is to delete
+      the ParaView-5.0.1/Plugins/SciberQuestToolKit directory.
 *** Building ParaView-4.1.0
     On Ubuntu 14.10 and higher, OpenSuSE 13.2 and probably other recent
     GNU/Linux distributions there is an issue in the GL libraries requiring a
diff --git a/etc/tools/ParaView4Functions b/etc/tools/ParaView3Functions
similarity index 86%
rename from etc/tools/ParaView4Functions
rename to etc/tools/ParaView3Functions
index 04323da..fe7e9fd 100644
--- a/etc/tools/ParaView4Functions
+++ b/etc/tools/ParaView3Functions
@@ -2,7 +2,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -63,6 +63,9 @@ setDirs()
     echo "ParaView_SOURCE_DIR=$ParaView_SOURCE_DIR"
     echo "ParaView_BINARY_DIR=$ParaView_BINARY_DIR"
     echo "ParaView_DIR=$ParaView_DIR"
+
+    # Forcefully override the .git path for the ParaView source code directory
+    export GIT_DIR=$ParaView_SOURCE_DIR/.git
 }
 
 
@@ -71,7 +74,10 @@ setDirs()
 #
 setVersion()
 {
-    [ "$#" -ge 1 ] && ParaView_VERSION="${1##paraview-}"
+    if [ "$#" -ge 1 ]
+    then
+        ParaView_VERSION="${1##paraview-}"
+    fi
 
     # the major version is "<digits>.<digits>"
     ParaView_MAJOR=$(echo $ParaView_VERSION | \
@@ -152,7 +158,10 @@ addCMakeVariable()
 #
 addVerbosity()
 {
-    [ "$withVERBOSE" = true ] && addCMakeVariable  "CMAKE_VERBOSE_MAKEFILE=TRUE"
+    if [ "${withVERBOSE:=false}" = true ]
+    then
+        addCMakeVariable  "CMAKE_VERBOSE_MAKEFILE=TRUE"
+    fi
 }
 
 
@@ -161,7 +170,11 @@ addVerbosity()
 #
 addMpiSupport()
 {
-    [ "${withMPI:=false}" = true ] || return
+    if [ "${withMPI:=false}" != true ]
+    then
+        return
+    fi
+
     OBJ_ADD="$OBJ_ADD-mpi"
 
     addCMakeVariable  "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON"
@@ -174,7 +187,11 @@ addMpiSupport()
 #
 addPythonSupport()
 {
-    [ "${withPYTHON:=false}" = true ] || return
+    if [ "${withPYTHON:=false}" != true ]
+    then
+        return
+    fi
+
     OBJ_ADD="$OBJ_ADD-py"
 
     if pythonBin=$(which python 2>/dev/null)
@@ -242,7 +259,10 @@ addPythonSupport()
 #
 addMesaSupport()
 {
-    [ "${withMESA:=false}" = true ] || return
+    if [ "${withMESA:=false}" != true ]
+    then
+       return
+    fi
 
     if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ]
     then
@@ -266,7 +286,10 @@ addMesaSupport()
 addQtSupport()
 {
     QtVersion=none
-    [ "${withQT:=false}" = true ] || return
+    if [ "${withQT:=false}" != true ]
+    then
+        return
+    fi
 
     addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"
 
@@ -325,10 +348,10 @@ addQtSupport()
         QtMajor=$1
         QtMinor=$2
 
-        if [ $QtMajor -lt 4 ] || [ $QtMajor -eq 4 -a $QtMinor -lt 5 ]
+        if [ $QtMajor -ne 4 -o $QtMajor -eq 4 -a $QtMinor -lt 5 ]
         then
             echo "*** Error: Qt version provided < 4.5"
-            echo "***     Please use the -qmake option to specify the location of a version of Qt >= 4.5 "
+            echo "***     Please use the -qmake option to specify the location of a version of Qt >= 4.5 and < 5.0"
             echo "***     e.g."
             echo "***         -qmake /usr/local/qt-4.6.2/bin/qmake"
             echo "***         -qmake $installBASE/qt-4.6.2/bin/qmake"
@@ -380,7 +403,10 @@ configParaView()
     fi
 
     # default to using cmake from the path
-    [ -n "$cmakeExe" ] || cmakeExe=cmake
+    if [ -z "$cmakeExe" ]
+    then
+        cmakeExe=cmake
+    fi
 
     # remove any existing build folder and recreate
     if [ -d $ParaView_BINARY_DIR ]
@@ -391,8 +417,6 @@ configParaView()
     fi
     mkdir -p $ParaView_BINARY_DIR
 
-    addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=$buildType"
-
     cd $ParaView_BINARY_DIR || exit 1  # change to build folder
 
     echo "----"
@@ -404,7 +428,6 @@ configParaView()
     echo "    Source         : $ParaView_SOURCE_DIR"
     echo "    Build          : $ParaView_BINARY_DIR"
     echo "    Target         : $ParaView_DIR"
-    echo "    Build type     : $buildType"
     echo "----"
     echo
     echo "$cmakeExe" \
@@ -436,7 +459,10 @@ makeParaView()
 
     # remove lib if it is a link
     # (how this was previously handled before 'make install' worked)
-    [ -L lib ] && rm lib 2>/dev/null
+    if [ -L lib ]
+    then
+        rm lib 2>/dev/null
+    fi
 }
 
 
@@ -450,6 +476,19 @@ installParaView()
 
     make install
 
+# hack for missing files after install of version 3.14.1
+    echo "Copying missing files to install folder"
+    CMAKE_SRC_DIR=$ParaView_SOURCE_DIR/CMake
+    CMAKE_INSTALL_DIR=$ParaView_DIR/lib/paraview-$ParaView_MAJOR/CMake
+    cp -f $ParaView_SOURCE_DIR/ParaViewUse.cmake $CMAKE_INSTALL_DIR
+    cp -f $CMAKE_SRC_DIR/generate_proxydocumentation.cmake $CMAKE_INSTALL_DIR
+    cp -f $CMAKE_SRC_DIR/smxml_to_xml.xsl $CMAKE_INSTALL_DIR
+    cp -f $CMAKE_SRC_DIR/xml_to_html.xsl $CMAKE_INSTALL_DIR
+    cp -f $CMAKE_SRC_DIR/xml_to_wiki.xsl.in $CMAKE_INSTALL_DIR
+    cp -f $CMAKE_SRC_DIR/generate_qhp.cmake $CMAKE_INSTALL_DIR
+    unset CMAKE_SRC_DIR CMAKE_INSTALL_DIR
+# --- end hack
+
 cat<< INFO
     ---
     Installation complete for paraview-$ParaView_VERSION
@@ -472,16 +511,20 @@ 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  "VTK_USE_TK:BOOL=OFF"
 addCMakeVariable  "BUILD_SHARED_LIBS:BOOL=ON  VTK_USE_RPATH:BOOL=OFF"
+addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=Release"
 
 # include development files in "make install"
-addCMakeVariable  "PARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON"
+addCMakeVariable  "PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON"
 
 # don't build test tree
 addCMakeVariable  "BUILD_TESTING:BOOL=OFF"
 
+# remove dependency on WebKit
+# addCMakeVariable  VTK_QT_USE_WEBKIT:BOOL=OFF
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 96bf8a4..e5fb200 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -2,7 +2,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -32,7 +32,7 @@
 # buildBASE, installBASE defined from tools/ThirdPartyFunctions
 
 #
-# where things are or should be put
+# Where things are or should be put
 #   ParaView_VERSION and ParaView_MAJOR should already have been set
 #
 #   ParaView_SOURCE_DIR : location of the original sources
@@ -63,17 +63,23 @@ setDirs()
     echo "ParaView_SOURCE_DIR=$ParaView_SOURCE_DIR"
     echo "ParaView_BINARY_DIR=$ParaView_BINARY_DIR"
     echo "ParaView_DIR=$ParaView_DIR"
+
+    # Forcefully override the .git path for the ParaView source code directory
+    export GIT_DIR=$ParaView_SOURCE_DIR/.git
 }
 
 
 #
-# set ParaView_VERSION and adjust ParaView_MAJOR accordingly
+# Set ParaView_VERSION and adjust ParaView_MAJOR accordingly
 #
 setVersion()
 {
-    [ "$#" -ge 1 ] && ParaView_VERSION="${1##paraview-}"
+    if [ "$#" -ge 1 ]
+    then
+        ParaView_VERSION="${1##paraview-}"
+    fi
 
-    # the major version is "<digits>.<digits>"
+    # The major version is "<digits>.<digits>"
     ParaView_MAJOR=$(echo $ParaView_VERSION | \
         sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/')
 
@@ -84,7 +90,7 @@ setVersion()
 #------------------------------------------------------------------------------
 
 #
-# extract and echo date stamp information from
+# Extract and echo date stamp information from
 #     VTK/Utilities/kwsys/kwsysDateStamp.cmake
 # since the order of the entries is already correct, can use simple sed script
 #
@@ -101,9 +107,8 @@ echoDateStamp()
     )
 }
 
-
 #
-# extract version information from
+# Extract version information from
 #     CMakeLists.txt
 # since the order of the entries is already correct, can use simple sed script
 #
@@ -121,7 +126,7 @@ getVersion()
 }
 
 #
-# compare version information
+# Compare version information
 #
 checkVersion()
 {
@@ -135,7 +140,7 @@ checkVersion()
 }
 
 #
-# set CMake cache variables
+# Set CMake cache variables
 #
 addCMakeVariable()
 {
@@ -148,20 +153,27 @@ addCMakeVariable()
 
 
 #
-# verbose makefiles
+# Verbose makefiles
 #
 addVerbosity()
 {
-    [ "$withVERBOSE" = true ] && addCMakeVariable  "CMAKE_VERBOSE_MAKEFILE=TRUE"
+    if [ "${withVERBOSE:=false}" = true ]
+    then
+        addCMakeVariable  "CMAKE_VERBOSE_MAKEFILE=TRUE"
+    fi
 }
 
 
 #
-# define options for mpi support
+# Define options for mpi support
 #
 addMpiSupport()
 {
-    [ "${withMPI:=false}" = true ] || return
+    if [ "${withMPI:=false}" != true ]
+    then
+        return
+    fi
+
     OBJ_ADD="$OBJ_ADD-mpi"
 
     addCMakeVariable  "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON"
@@ -170,18 +182,22 @@ addMpiSupport()
 
 
 #
-# define options for python support
+# Define options for python support
 #
 addPythonSupport()
 {
-    [ "${withPYTHON:=false}" = true ] || return
+    if [ "${withPYTHON:=false}" != true ]
+    then
+        return
+    fi
+
     OBJ_ADD="$OBJ_ADD-py"
 
     if pythonBin=$(which python 2>/dev/null)
     then
         if [ -n "$PYTHON_LIBRARY" ]
         then
-            # check $PYTHON_LIBRARY if it has been set
+            # Check $PYTHON_LIBRARY if it has been set
             if [ ! -e "$PYTHON_LIBRARY" ]
             then
                 echo "*** Error: libpython not found at location specified " \
@@ -208,7 +224,7 @@ addPythonSupport()
         pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
         pythonInclude=/usr/include/python$pythonMajor
 
-        # note - we could also allow for a PYTHON_INCLUDE variable ...
+        # Note - we could also allow for a PYTHON_INCLUDE variable ...
         [ -d "$pythonInclude" ] || {
             echo "    No python headers found in $pythonInclude/"
             echo "    Please install python headers or deactivate "
@@ -238,11 +254,14 @@ addPythonSupport()
 
 
 #
-# define options for mesa support
+# Define options for mesa support
 #
 addMesaSupport()
 {
-    [ "${withMESA:=false}" = true ] || return
+    if [ "${withMESA:=false}" != true ]
+    then
+       return
+    fi
 
     if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ]
     then
@@ -266,7 +285,11 @@ addMesaSupport()
 addQtSupport()
 {
     QtVersion=none
-    [ "${withQT:=false}" = true ] || return
+
+    if [ "${withQT:=false}" != true ]
+    then
+        return
+    fi
 
     addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"
 
@@ -289,7 +312,7 @@ addQtSupport()
 
         if [ -n "$qmakeExe" ]
         then
-            # use absolute path
+            # Use absolute path
             if [ "${qmakeExe#/}" = "$qmakeExe" ]
             then
                 qmakeExe="$(cd ${qmakeExe%/qmake} 2>/dev/null && pwd)/qmake"
@@ -303,7 +326,7 @@ addQtSupport()
         fi
     fi
 
-    # default to using qmake from the path
+    # Default to using qmake from the path
     if [ -n "$qmakeExe" ]
     then
         addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmakeExe"
@@ -319,16 +342,16 @@ addQtSupport()
         # parse -> "Using Qt version X.Y.Z in ..."
         QtVersion=$($qmakeExe -query QT_VERSION)
 
-        # split Major.Minor.Revision - could also use IFS hacking
+        # Split Major.Minor.Revision - could also use IFS hacking
         set -- $(echo "$QtVersion" | sed -e 's/\./ /g')
 
         QtMajor=$1
         QtMinor=$2
 
-        if [[ ($QtMajor -lt 4) || ($QtMajor -eq 4  && $QtMinor -lt 5) ]]
+        if [ $QtMajor -lt 4 -o $QtMajor -eq 4 -a $QtMinor -lt 5 ]
         then
             echo "*** Error: Qt version provided < 4.5"
-            echo "***     Please use the -qmake option to specify the location of a version of Qt >= 4.5 "
+            echo "***     Please use the -qmake option to specify the location of a version of Qt >= 4.5"
             echo "***     e.g."
             echo "***         -qmake /usr/local/qt-4.6.2/bin/qmake"
             echo "***         -qmake $installBASE/qt-4.6.2/bin/qmake"
@@ -342,7 +365,7 @@ addQtSupport()
 
 
 #
-# configure via cmake, but don't actually build anything
+# Configure via cmake, but don't actually build anything
 #
 configParaView()
 {
@@ -365,7 +388,7 @@ configParaView()
 
         if [ -n "$cmakeExe" ]
         then
-            # use absolute path
+            # Use absolute path
             if [ "${cmakeExe#/}" = "$cmakeExe" ]
             then
                 cmakeExe="$(cd ${cmakeExe%/cmake} 2>/dev/null && pwd)/cmake"
@@ -379,10 +402,13 @@ configParaView()
         fi
     fi
 
-    # default to using cmake from the path
-    [ -n "$cmakeExe" ] || cmakeExe=cmake
+    # Default to using cmake from the path
+    if [ -z "$cmakeExe" ]
+    then
+        cmakeExe=cmake
+    fi
 
-    # remove any existing build folder and recreate
+    # Remove any existing build folder and recreate
     if [ -d $ParaView_BINARY_DIR ]
     then
         echo "removing old build directory"
@@ -391,7 +417,9 @@ configParaView()
     fi
     mkdir -p $ParaView_BINARY_DIR
 
-    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
+    addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=$buildType"
+
+    cd $ParaView_BINARY_DIR || exit 1  # Change to build folder
 
     echo "----"
     echo "Configuring paraview-$ParaView_VERSION (major version: $ParaView_MAJOR)"
@@ -402,6 +430,7 @@ configParaView()
     echo "    Source         : $ParaView_SOURCE_DIR"
     echo "    Build          : $ParaView_BINARY_DIR"
     echo "    Target         : $ParaView_DIR"
+    echo "    Build type     : $buildType"
     echo "----"
     echo
     echo "$cmakeExe" \
@@ -412,7 +441,7 @@ configParaView()
     echo "----"
     echo
 
-    # run cmake to create Makefiles
+    # Run cmake to create Makefiles
     $cmakeExe \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
@@ -421,53 +450,40 @@ configParaView()
 
 
 #
-# invoke make
+# Invoke make
 # also link bin/ to lib/paraview-* for development without installation
 #
 makeParaView()
 {
-    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
+    cd $ParaView_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
+    # Remove lib if it is a link
     # (how this was previously handled before 'make install' worked)
-    [ -L lib ] && rm lib 2>/dev/null
+    if [ -L lib ]
+    then
+        rm lib 2>/dev/null
+    fi
 }
 
 
 #
-# install the program
+# Install the program
 #
 installParaView()
 {
-    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
+    cd $ParaView_BINARY_DIR || exit 1  # Change to build folder
     echo "    Installing ParaView to $ParaView_DIR"
 
     make install
 
-# hack for missing files after install of version 3.14.1
-    echo "Copying missing files to install folder"
-    CMAKE_SRC_DIR=$ParaView_SOURCE_DIR/CMake
-    CMAKE_INSTALL_DIR=$ParaView_DIR/lib/paraview-$ParaView_MAJOR/CMake
-    cp -f $ParaView_SOURCE_DIR/ParaViewUse.cmake $CMAKE_INSTALL_DIR
-    cp -f $CMAKE_SRC_DIR/generate_proxydocumentation.cmake $CMAKE_INSTALL_DIR
-    cp -f $CMAKE_SRC_DIR/smxml_to_xml.xsl $CMAKE_INSTALL_DIR
-    cp -f $CMAKE_SRC_DIR/xml_to_html.xsl $CMAKE_INSTALL_DIR
-    cp -f $CMAKE_SRC_DIR/xml_to_wiki.xsl.in $CMAKE_INSTALL_DIR
-    cp -f $CMAKE_SRC_DIR/generate_qhp.cmake $CMAKE_INSTALL_DIR
-    unset CMAKE_SRC_DIR CMAKE_INSTALL_DIR
-# --- end hack
-
 cat<< INFO
     ---
     Installation complete for paraview-$ParaView_VERSION
-    Set environment variables:
-
-        export ParaView_DIR=$ParaView_DIR
-        export PATH=\$ParaView_DIR/bin:\$PATH
-        export PV_PLUGIN_PATH=\$FOAM_LIBBIN/paraview-$ParaView_MAJOR
+    Now update the environment by running:
+        wmRefresh
     ---
 INFO
 }
@@ -475,27 +491,23 @@ INFO
 
 #------------------------------------------------------------------------------
 
-# clear the referenced variables before using any of the functions
+# 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  "VTK_USE_TK:BOOL=OFF"
+# Start with these general settings
 addCMakeVariable  "BUILD_SHARED_LIBS:BOOL=ON  VTK_USE_RPATH:BOOL=OFF"
-addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=Release"
 
-# include development files in "make install"
-addCMakeVariable  "PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON"
+# Include development files in "make install"
+addCMakeVariable  "PARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON"
 
-# don't build test tree
+# Don't build test tree
 addCMakeVariable  "BUILD_TESTING:BOOL=OFF"
 
-# remove dependency on WebKit
-# addCMakeVariable  VTK_QT_USE_WEBKIT:BOOL=OFF
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index a82a569..85c03e9 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -2,7 +2,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -31,12 +31,13 @@
 #     Define WM_NCOMPPROCS always.
 #------------------------------------------------------------------------------
 
-# define the normal build and prefix directories
+# Define the normal build and prefix directories
 buildBASE=$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER
 installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
 
+
 #
-# mostly building without wmake
+# Mostly building without wmake
 # - disable wmakeScheduler variables
 # - restrict WM_NCOMPPROCS to local number of cores
 #
@@ -53,7 +54,16 @@ fi
 
 
 #
-# download file $1 from url $2 into download/ directory
+# If WM_CONTINUE_ON_ERROR not set activate the shell option "stop on error"
+#
+if [ -z "${WM_CONTINUE_ON_ERROR}" ]
+then
+    set -e
+fi
+
+
+#
+# Download file $1 from url $2 into download/ directory
 #
 downloadFile()
 {
@@ -75,7 +85,7 @@ downloadFile()
 
 
 #
-# copy Make/{files,options} from wmakeFiles/PACKAGE
+# Copy Make/{files,options} from wmakeFiles/PACKAGE
 #
 # $1 = PACKAGE
 # $2 (optional) TARGET DIRECTORY
@@ -119,4 +129,4 @@ cpMakeFiles()
 }
 
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/makeCGAL b/makeCGAL
index 6291227..0fbd2c8 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2012-2014 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2012-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -37,15 +37,22 @@
 #     Mixing system and ThirdParty for gmp/mpfr is not supported.
 #
 #------------------------------------------------------------------------------
+
+# Get CGAL, boost and gmp/mpfr versions
+. $WM_PROJECT_DIR/etc/config.sh/functions
+_foamEval SOURCE_CGAL_VERSIONS_ONLY=yes \
+          $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
+
 set -x
 
-cgalPACKAGE=CGAL-4.7
-boostPACKAGE=boost-system
-gmpPACKAGE=gmp-system
-mpfrPACKAGE=mpfr-system
+cgalPACKAGE=${cgal_version:-CGAL-4.8}
+boostPACKAGE=${boost_version:-boost-system}
+gmpPACKAGE=${gmp_version:-gmp-system}
+mpfrPACKAGE=${mpfr_version:-mpfr-system}
 
 #------------------------------------------------------------------------------
-# run from third-party directory only
+# 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."
@@ -83,11 +90,11 @@ USAGE
 }
 
 
-# ensure CMake gets the correct C++ compiler
+# Ensure CMake gets the correct C++ compiler
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
 
-# parse options
+# Parse options
 while [ "$#" -gt 0 ]
 do
     case "$1" in
@@ -159,7 +166,7 @@ then
 else
     boostInc="/usr/include"
 
-    # for completeness:
+    # For completeness:
     # 64-bit needs lib64, but 32-bit needs lib (not lib32)
     if [ "$WM_ARCH_OPTION" = 64 ]
     then
@@ -170,7 +177,7 @@ else
 fi
 
 
-# retrieve boost version:
+# Retrieve boost version:
 if [ -f "$boostInc/boost/version.hpp" ]
 then
     BOOST_VERSION_NO=`sed -ne 's/^#define *BOOST_VERSION *\([0-9][0-9]*\).*$/\1/p' $boostInc/boost/version.hpp`
@@ -180,6 +187,11 @@ else
     exit 1
 fi
 
+if [ "$cgal_version" = "cgal-system" ]
+then
+    echo "Using system installation of CGAL"
+    exit 0
+fi
 
 #
 # Build CGAL
@@ -201,7 +213,7 @@ GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
 MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
 
 (
-    # remove any existing build folder and recreate
+    # Remove any existing build folder and recreate
     if [ -d $CGAL_BINARY_DIR ]
     then
         echo "removing old build directory"
@@ -246,13 +258,13 @@ CMAKE_OPTIONS
         echo "    ThirdParty     : gmp/mpfr"
         configGmpMpfr=$(cat <<CMAKE_OPTIONS
  -DGMP_INCLUDE_DIR=$GMP_ARCH_PATH/include
- -DGMP_LIBRARIES_DIR=$GMP_ARCH_PATH/lib
- -DGMP_LIBRARIES=$GMP_ARCH_PATH/lib/libgmp.so
+ -DGMP_LIBRARIES_DIR=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
+ -DGMP_LIBRARIES=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libgmp.so
  -DGMPXX_INCLUDE_DIR=$GMP_ARCH_PATH/include
- -DGMPXX_LIBRARIES=$GMP_ARCH_PATH/lib/libgmpxx.so
+ -DGMPXX_LIBRARIES=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libgmpxx.so
  -DMPFR_INCLUDE_DIR=$MPFR_ARCH_PATH/include
- -DMPFR_LIBRARIES_DIR=$MPFR_ARCH_PATH/lib
- -DMPFR_LIBRARIES=$MPFR_ARCH_PATH/lib/libmpfr.so
+ -DMPFR_LIBRARIES_DIR=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
+ -DMPFR_LIBRARIES=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmpfr.so
 CMAKE_OPTIONS
 )
     else
@@ -264,6 +276,7 @@ CMAKE_OPTIONS
     cmake \
         -DCMAKE_INSTALL_PREFIX=$CGAL_ARCH_PATH \
         -DCMAKE_BUILD_TYPE=Release \
+        -DWITH_CGAL_Qt5=OFF \
         $configBoost $configGmpMpfr \
         $CGAL_SOURCE_DIR \
     && make -j $WM_NCOMPPROCS \
@@ -287,4 +300,4 @@ CMAKE_OPTIONS
     echo "Done CGAL"
 )
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/makeCmake b/makeCmake
index 1e6d442..b3ca91d 100755
--- a/makeCmake
+++ b/makeCmake
@@ -120,4 +120,4 @@ else
 }
 fi
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/makeGcc b/makeGcc
index c2b5cdd..c455ce1 100755
--- a/makeGcc
+++ b/makeGcc
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -29,10 +29,16 @@
 #     Build script for gmp, mpfr and gcc-[4-9].?.?
 #
 #------------------------------------------------------------------------------
-gmpPACKAGE=gmp-5.1.2
-mpfrPACKAGE=mpfr-3.1.2
-mpcPACKAGE=mpc-1.0.1
-gccPACKAGE=
+
+# get default GCC, mpfr, gmp and mpc versions
+. $WM_PROJECT_DIR/etc/config.sh/functions
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
+
+gmpPACKAGE=${gmp_version:-gmp-5.1.2}
+mpfrPACKAGE=${mpfr_version:-mpfr-3.1.2}
+mpcPACKAGE=${mpc_version:-mpc-1.0.1}
+gccPACKAGE=$gcc_version
+
 
 #------------------------------------------------------------------------------
 # Run from third-party directory only
@@ -50,7 +56,10 @@ usage() {
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: ${0##*/} [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION] <gcc-VERSION>
+usage: ${0##*/} [option] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION] <gcc-VERSION>
+options:
+  -no-multilib      for 64-bit systems that don't have 32-bit support
+  -help
 
 * build combinations of gmp, mpfr, mpc and gcc
       $gmpPACKAGE
@@ -62,6 +71,7 @@ USAGE
     exit 1
 }
 
+GCC_BUILD_OPTIONS=""
 
 # Parse options
 while [ "$#" -gt 0 ]
@@ -70,6 +80,10 @@ do
     -h | -help)
         usage
         ;;
+    -no-multilib)
+        GCC_BUILD_OPTIONS="--disable-multilib"
+        shift
+        ;;
     gmp-[4-9]*)
         gmpPACKAGE="${1%%/}"
         shift
@@ -120,13 +134,6 @@ GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
 MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
 MPC_ARCH_PATH=$installBASE/$mpcPACKAGE
 
-# mpc is not needed for gcc older than 4.5
-case "$gccPACKAGE" in
-gcc-4.[0-4].*)
-   mpcPACKAGE=false
-   ;;
-esac
-
 #
 # Build GMP
 #
@@ -151,6 +158,7 @@ else
     set -x
     $sourceDIR/configure ABI=$ABI \
         --prefix=$GMP_ARCH_PATH \
+        --libdir=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
         --enable-cxx \
     && make -j $WM_NCOMPPROCS \
     && make install \
@@ -187,7 +195,9 @@ else
     set -x
     $sourceDIR/configure ABI=$ABI \
        --prefix=$MPFR_ARCH_PATH \
-       --with-gmp=$GMP_ARCH_PATH \
+       --libdir=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+       --with-gmp-include=$GMP_ARCH_PATH/include \
+       --with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $mpfrPACKAGE"
@@ -206,9 +216,6 @@ echo "---------------"
 if [ -d $MPC_ARCH_PATH ]
 then
     echo "Already built: $mpcPACKAGE"
-elif [ "$mpcPACKAGE" = false ]
-then
-    echo "Skip building mpc - not needed for older gcc versions"
 else
     echo "Starting build: $mpcPACKAGE"
     echo
@@ -226,8 +233,11 @@ else
     set -x
     $sourceDIR/configure ABI=$ABI \
         --prefix=$MPC_ARCH_PATH \
-        --with-gmp=$GMP_ARCH_PATH \
-        --with-mpfr=$MPFR_ARCH_PATH \
+        --libdir=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+        --with-gmp-include=$GMP_ARCH_PATH/include \
+        --with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+        --with-mpfr-include=$MPFR_ARCH_PATH/include \
+        --with-mpfr-lib=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $mpcPACKAGE"
@@ -263,9 +273,6 @@ else
     cd $sourceDIR || exit 1
     make distclean 2>/dev/null
 
-    unset withMpc
-    [ -d "$MPC_ARCH_PATH" ] && withMpc="--with-mpc=$MPC_ARCH_PATH"
-
     rm -rf $buildDIR
     mkdir -p $buildDIR
     cd $buildDIR
@@ -273,14 +280,18 @@ else
     set -x
     $sourceDIR/configure \
         --prefix=$GCC_ARCH_PATH \
-        --with-gmp=$GMP_ARCH_PATH \
-        --with-mpfr=$MPFR_ARCH_PATH \
-        $withMpc \
+        --with-gmp-include=$GMP_ARCH_PATH/include \
+        --with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+        --with-mpfr-include=$MPFR_ARCH_PATH/include \
+        --with-mpfr-lib=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+        --with-mpc-include=$MPC_ARCH_PATH/include \
+        --with-mpc-lib=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
         --with-pkgversion=OpenFOAM \
         --enable-languages=c,c++ \
         --enable-__cxa_atexit \
         --enable-libstdcxx-allocator=new \
         --with-system-zlib \
+        $GCC_BUILD_OPTIONS \
         MAKEINFO=missing \
     && make -j $WM_NCOMPPROCS \
     && make install \
@@ -292,4 +303,4 @@ else
 fi
 
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/makeGperftools b/makeGperftools
index 3bf9bd2..613c332 100755
--- a/makeGperftools
+++ b/makeGperftools
@@ -115,4 +115,4 @@ else
 }
 fi
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/makeLLVM b/makeLLVM
index 505d407..0551ead 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -37,7 +37,12 @@
 #        cd -
 #
 #------------------------------------------------------------------------------
-llvmPACKAGE=llvm-3.6.0
+
+# get default llvm version
+. $WM_PROJECT_DIR/etc/config.sh/functions
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
+
+llvmPACKAGE=${clang_version:-llvm-3.6.0}
 
 #------------------------------------------------------------------------------
 # run from third-party directory only
@@ -131,4 +136,4 @@ else
 }
 fi
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/makeParaView b/makeParaView
index 6de1398..10db8a8 100755
--- a/makeParaView
+++ b/makeParaView
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -26,7 +26,7 @@
 #     makeParaView
 #
 # Description
-#     Make and install paraview for version 3.14.1 and higher
+#     Make and install paraview 4 or 5
 #     - place the paraview source under $WM_THIRD_PARTY_DIR/ParaView-VERSION
 #       (note capitalisation)
 #
@@ -107,8 +107,8 @@ The -no-FEATURE option can be disable these features (if not already disabled):
 
 CMake options start with a capital letter and contain an '='.
 For example,
-    $Script BUILD_TESTING=ON PARAVIEW_GENERATE_PROXY_DOCUMENTATION=OFF
-to add tests and avoid building documentation
+    $Script BUILD_TESTING=ON
+to add tests
 
 For finer control, the build stages can be selected or deselected individually:
   -config    -no-config
@@ -146,6 +146,7 @@ setVersion
 #
 unset runCONFIG runMAKE runINSTALL
 runDEFAULT=true
+buildType=Release
 
 # parse options
 while [ "$#" -gt 0 ]
@@ -270,6 +271,11 @@ do
         export ParaView_MAJOR="$2"
         shift 2
         ;;
+    -buildType)
+        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        buildType="$2"
+        shift 2
+        ;;
     *)
         usage "unknown option/argument: '$*'"
         ;;
@@ -317,6 +323,7 @@ Version information
     qt        ${QtVersion:-none}
     version   ${ParaView_VERSION:-unknown}
     major     ${ParaView_MAJOR:-unknown}
+    build     ${buildType:-Release}
 $(checkVersion)
 ---------------------
 SUMMARY
diff --git a/makeParaView4 b/makeParaView3
similarity index 95%
rename from makeParaView4
rename to makeParaView3
index b9a312d..28101ee 100755
--- a/makeParaView4
+++ b/makeParaView3
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -23,10 +23,10 @@
 #     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 #
 # Script
-#     makeParaView
+#     makeParaView3
 #
 # Description
-#     Make and install paraview
+#     Make and install paraview for version 3.14.1 and higher
 #     - place the paraview source under $WM_THIRD_PARTY_DIR/ParaView-VERSION
 #       (note capitalisation)
 #
@@ -40,7 +40,7 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
     exit 1
 }
 . etc/tools/ThirdPartyFunctions
-. etc/tools/ParaView4Functions
+. etc/tools/ParaView3Functions
 #------------------------------------------------------------------------------
 #
 # USER OPTIONS:
@@ -107,8 +107,8 @@ The -no-FEATURE option can be disable these features (if not already disabled):
 
 CMake options start with a capital letter and contain an '='.
 For example,
-    $Script BUILD_TESTING=ON
-to add tests
+    $Script BUILD_TESTING=ON PARAVIEW_GENERATE_PROXY_DOCUMENTATION=OFF
+to add tests and avoid building documentation
 
 For finer control, the build stages can be selected or deselected individually:
   -config    -no-config
@@ -146,7 +146,6 @@ setVersion
 #
 unset runCONFIG runMAKE runINSTALL
 runDEFAULT=true
-buildType=Release
 
 # parse options
 while [ "$#" -gt 0 ]
@@ -271,11 +270,6 @@ do
         export ParaView_MAJOR="$2"
         shift 2
         ;;
-    -buildType)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
-        buildType="$2"
-        shift 2
-        ;;
     *)
         usage "unknown option/argument: '$*'"
         ;;
@@ -323,7 +317,6 @@ Version information
     qt        ${QtVersion:-none}
     version   ${ParaView_VERSION:-unknown}
     major     ${ParaView_MAJOR:-unknown}
-    build     ${buildType:-Release}
 $(checkVersion)
 ---------------------
 SUMMARY
@@ -334,4 +327,5 @@ SUMMARY
 
 echo
 echo Done
+
 #------------------------------------------------------------------------------
-- 
GitLab


From 6c13263e5901232595e815610a7f36858fb5dfa8 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Mon, 13 Jun 2016 17:55:23 +0200
Subject: [PATCH 02/40] STYLE: make WM_NCOMPPROCS consistent with Allwmake
 behaviour

---
 etc/tools/ThirdPartyFunctions | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 85c03e9..7af9534 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -39,17 +39,16 @@ installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
 #
 # Mostly building without wmake
 # - disable wmakeScheduler variables
-# - restrict WM_NCOMPPROCS to local number of cores
+# - use max number of cores for building
 #
 unset WM_HOSTS WM_SCHEDULER
-export WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo 2>/dev/null | wc -l)
-if [ $WM_NCOMPPROCS -le 1 ]
+if [ -r /proc/cpuinfo ]
 then
+    WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
+else
     WM_NCOMPPROCS=1
-elif [ $WM_NCOMPPROCS -ge 8 ]
-then
-    WM_NCOMPPROCS=8
 fi
+export WM_NCOMPPROCS
 # echo "Building on $WM_NCOMPPROCS cores"
 
 
-- 
GitLab


From f2e5aba3396a468ee96d0f3177eb7dd5c6da5a2f Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Mon, 13 Jun 2016 19:22:05 +0200
Subject: [PATCH 03/40] ENH: adjust build options for third-party IO libraries

- support building static libraries
---
 AllwmakeLibccmio                |  85 -------------------
 README.org                      |   8 +-
 etc/wmakeFiles/libccmio/files   |  27 ++++++
 etc/wmakeFiles/libccmio/options |   3 +
 makeCCMIO                       | 143 ++++++++++++++++++++++++++++++++
 5 files changed, 177 insertions(+), 89 deletions(-)
 delete mode 100755 AllwmakeLibccmio
 create mode 100644 etc/wmakeFiles/libccmio/files
 create mode 100644 etc/wmakeFiles/libccmio/options
 create mode 100755 makeCCMIO

diff --git a/AllwmakeLibccmio b/AllwmakeLibccmio
deleted file mode 100755
index 87330ee..0000000
--- a/AllwmakeLibccmio
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/sh
-#------------------------------------------------------------------------------
-# =========                 |
-# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-#  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     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
-#     AllwmakeLibccmio
-#
-# Description
-#     Build CD-adapco's ccmio library
-#
-#------------------------------------------------------------------------------
-packageDir=libccmio-2.6.1
-
-#------------------------------------------------------------------------------
-# 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
-#------------------------------------------------------------------------------
-
-usage()
-{
-    cat<<USAGE
-
-* The license of the libccmio library is proprietary:
-
-    Users wishing to make use of its functionality should contact CD-Adapco
-    for possible download and terms of use.
-
-
-Usage: ${0##*/}
-
-* This script will install the libccmio library
-* After obtaining the $packageDir library, place in folder
-
-    $WM_THIRD_PARTY_DIR/$packageDir/
-
-USAGE
-    exit 1
-}
-
-
-# get tar.gz file if required
-if [ ! -d ${packageDir} ]
-then
-    usage
-fi
-
-set -x
-
-# make libccmio
-(
-    cd $packageDir || exit 1
-    cpMakeFiles libccmio
-
-    wmake libso
-)
-
-
-#------------------------------------------------------------------------------
diff --git a/README.org b/README.org
index 9129eb3..551b2df 100644
--- a/README.org
+++ b/README.org
@@ -9,14 +9,14 @@
 
 * Description
   Scripts for building third-party packages.
-* Order of execution:
+* Build Order:
   + makeGcc   (recommended if the system gcc is < 4.7)
   + Allwmake  (Builds OpenMPI, Scotch etc.)
   + makeCmake (if the system cmake version is < 2.8.8)
   + makeParaView
-*** Optional
-    + AllwmakeLibccmio (Only required for conversion of STAR-CCM+ meshes)
-    + Allclean (Only required to save disk space)
+*** Optional Build Components:
+    + makeCCMIO (Only required for conversion of STAR-CCM+ meshes)
+    + Allclean  (Only required to save disk space)
 * Versions and locations to download the third party packages
 *** Gcc C++ Compiler
     The minimum version of gcc required is 4.5.0
diff --git a/etc/wmakeFiles/libccmio/files b/etc/wmakeFiles/libccmio/files
new file mode 100644
index 0000000..f4e9ca6
--- /dev/null
+++ b/etc/wmakeFiles/libccmio/files
@@ -0,0 +1,27 @@
+/* NOTE: make any changes to this file in etc/wmakeFiles/ */
+
+adf = libadf
+$(adf)/ADF_fortran_2_c.c
+$(adf)/ADF_interface.c
+$(adf)/ADF_internals.c
+
+ccmio = libccmio
+$(ccmio)/ccmio.c
+$(ccmio)/ccmiocore.c
+$(ccmio)/ccmioprivate.c
+$(ccmio)/ccmioutility.c
+$(ccmio)/ccmioversion.c
+
+/*
+ * the cgns library is not used by ccmio
+ * retain for documentation purposes only
+ *
+ cgns = libcgns
+ $(cgns)/adf_cond.c
+ $(cgns)/adf_ftoc.c
+ $(cgns)/cgns_error.c
+ $(cgns)/cgns_internals.c
+ $(cgns)/cgnslib.c
+*/
+
+LIB = $(FOAM_EXT_LIBBIN)/libccmio
diff --git a/etc/wmakeFiles/libccmio/options b/etc/wmakeFiles/libccmio/options
new file mode 100644
index 0000000..5f4fb60
--- /dev/null
+++ b/etc/wmakeFiles/libccmio/options
@@ -0,0 +1,3 @@
+/* NOTE: make any changes to this file in etc/wmakeFiles/ */
+
+/* EXE_INC = */
diff --git a/makeCCMIO b/makeCCMIO
new file mode 100755
index 0000000..12b1137
--- /dev/null
+++ b/makeCCMIO
@@ -0,0 +1,143 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+#    \\/     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
+#     makeCCMIO
+#
+# 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/libccmio)
+
+ccmio_version=${ccmio_version:-libccmio-2.6.1}
+targetType=libso
+
+#------------------------------------------------------------------------------
+# 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()
+{
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    /bin/cat<<USAGE
+
+Usage: ${0##*/} [OPTION] [lib|libso] [libccmio-VERSION]
+options:
+  -help
+
+* Compile the proprietary libccmio library
+      $ccmio_version
+
+  Users wishing to make use of the library should contact cd-adapco
+  (Siemens PLM) for possible download and terms of use.
+
+  After obtaining the $ccmio_version library, place in folder
+
+      $WM_THIRD_PARTY_DIR/$ccmio_version/
+
+  prior to running this script.
+
+USAGE
+    exit 1
+}
+
+
+# Parse options
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    lib|libso)
+        targetType="$1"
+        shift
+        ;;
+    libccmio-[1-9]*)
+        ccmio_version="${1%%/}"
+        shift
+        ;;
+    *)
+        usage "unknown option/argument: '$*'"
+        ;;
+    esac
+done
+
+# warn if unavailable
+if [ ! -d ${ccmio_version} ]
+then
+    usage "missing source directory '$ccmio_version'"
+fi
+
+
+#------------------------------------------------------------------------------
+CCMIO_ARCH_PATH=$installBASE/$ccmio_version
+
+#
+# Build LIBCCMIO
+#
+echo "---------------"
+(
+    cd $ccmio_version || exit 1
+    incDIR=$CCMIO_ARCH_PATH/include/libccmio
+    libDIR=$CCMIO_ARCH_PATH/lib
+
+    mkdir -p $incDIR 2>/dev/null
+    mkdir -p $libDIR 2>/dev/null
+
+    cpMakeFiles libccmio 2>/dev/null
+    set +x
+    if wmake $targetType
+    then
+        # 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
+)
+
+
+#------------------------------------------------------------------------------
-- 
GitLab


From b979e25f2834c0c2eec8b8b50bc76424b6b66bf2 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 14 Jun 2016 11:49:27 +0200
Subject: [PATCH 04/40] DOC: update download links for gmp,mpfr,mpc,cmake

- align fallback clang version with OpenFOAM config files
---
 README.org | 10 +++++-----
 makeLLVM   |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/README.org b/README.org
index 551b2df..7280012 100644
--- a/README.org
+++ b/README.org
@@ -22,24 +22,24 @@
     The minimum version of gcc required is 4.5.0
     + gcc   http://gcc.gnu.org/releases.html
     + gmp   http://gmplib.org/
-            ftp://ftp.gnu.org/gnu/gmp/gmp-5.1.2.tar.bz2
+            ftp://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.bz2
     + mpfr  http://www.mpfr.org/
-            ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.bz2
+            ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2
     + mpc   http://www.multiprecision.org/
-            http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz
+            ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
 *** Parallel Processing
 ***** Scotch
       + Scotch/PtScotch: https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz
 ***** OpenMPI
       + OpenMPI: http://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.2.tar.bz2
 *** ParaView
-    + cmake          http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz
+    + cmake          http://www.cmake.org/files/v3.5/cmake-3.5.2.tar.gz
     + ParaView-4.4.0 http://www.paraview.org/files/v4.4/ParaView-v4.4.0-source.tar.gz
     + ParaView-5.0.1 http://www.paraview.org/files/v5.0/ParaView-v5.0.1-source.tar.gz
     but may need patching to compile (See [[Notes]]).
 *** CGAL
     + CGAL        https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.8/CGAL-4.8.tar.xz
-    + boost       http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download
+    + boost       https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.bz2/download
 *** Miscellaneous
     + libccmio    http://portal.nersc.gov/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz
 * Notes
diff --git a/makeLLVM b/makeLLVM
index 0551ead..fb557ac 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -42,7 +42,7 @@
 . $WM_PROJECT_DIR/etc/config.sh/functions
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
 
-llvmPACKAGE=${clang_version:-llvm-3.6.0}
+llvmPACKAGE=${clang_version:-llvm-3.7.0}
 
 #------------------------------------------------------------------------------
 # run from third-party directory only
-- 
GitLab


From d75ec96234a53ad9b2885190cced6bc21b6b3c13 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 14 Jun 2016 12:42:23 +0200
Subject: [PATCH 05/40] ENH: add a patch mechanism for ParaView build

- this adds some flexiblity/robustness to the build
---
 README.org                        | 16 ++++++++++---
 etc/patches/mkdiff-paraview-5.0.1 | 13 +++++++++++
 etc/patches/paraview-5.0.1        | 39 +++++++++++++++++++++++++++++++
 etc/tools/ParaViewFunctions       | 30 +++++++++++++++++++++++-
 makeParaView                      | 17 ++++++++++++--
 5 files changed, 109 insertions(+), 6 deletions(-)
 create mode 100644 etc/patches/mkdiff-paraview-5.0.1
 create mode 100644 etc/patches/paraview-5.0.1

diff --git a/README.org b/README.org
index 7280012..9a5f9f7 100644
--- a/README.org
+++ b/README.org
@@ -2,7 +2,7 @@
 #
 #+TITLE:                 OpenFOAM Third-Party packages
 #+AUTHOR:                  The OpenFOAM Foundation
-#+DATE:                       31th May 2016
+#+DATE:                           2016-06-14
 #+LINK:                     http://www.openfoam.org
 #+OPTIONS: author:nil ^:{}
 # Copyright (c) 2014-2016 OpenFOAM Foundation.
@@ -15,6 +15,8 @@
   + makeCmake (if the system cmake version is < 2.8.8)
   + makeParaView
 *** Optional Build Components:
+    + makeLLVM  (Replaces makeGcc in the above description
+    - to use clang as compiler)
     + makeCCMIO (Only required for conversion of STAR-CCM+ meshes)
     + Allclean  (Only required to save disk space)
 * Versions and locations to download the third party packages
@@ -65,13 +67,21 @@
     directory:
     + wget https://raw.githubusercontent.com/Kitware/VTK/40937e934308e5009e80769dc0c451ee4f157749/IO/Geometry/vtkSTLReader.cxx -O ParaView-4.4.0/VTK/IO/Geometry/vtkSTLReader.cxx
     See also http://www.openfoam.org/mantisbt/view.php?id=1887
+
+    For ParaView-5.0.1, the necessary patches are supplied with the
+    ThirdParty repository (see the etc/patches directory) and are applied
+    when building paraview.
+
 *** Building ParaView-5.0.1 with gcc-6.1.0
 ***** Add support for gcc-6.?.?
       The following cmake files
       + ParaView-5.0.1/VTK/CMake/vtkCompilerExtras.cmake
       + ParaView-5.0.1/VTK/CMake/GenerateExportHeader.cmake
-      specifically limit the gcc versions supported.  To add support gcc-6.?.?
-      replace '[345]' with '[3456]'
+      specifically limit the gcc versions supported.
+      To add support gcc-6.?.? replace the '[345]' with '[3456]'.
+      This patch is also supplied with the ThirdParty repository and
+      applied when building paraview.
+
 ***** SciberQuestToolKit
       The SciberQuestToolKit plugin fails to compile with gcc-6.1.0 and causes
       the compilation of ParaView to halt.  The easiest solution is to delete
diff --git a/etc/patches/mkdiff-paraview-5.0.1 b/etc/patches/mkdiff-paraview-5.0.1
new file mode 100644
index 0000000..c6a7343
--- /dev/null
+++ b/etc/patches/mkdiff-paraview-5.0.1
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# simple script to generate patches
+paraview=ParaView-5.0.1
+
+for i in \
+    $paraview/VTK/CMake/vtkCompilerExtras.cmake \
+    $paraview/VTK/CMake/GenerateExportHeader.cmake \
+    $paraview/Qt/Components/CMakeLists.txt \
+    ;
+do
+    diff -uw $i.orig $i
+done
diff --git a/etc/patches/paraview-5.0.1 b/etc/patches/paraview-5.0.1
new file mode 100644
index 0000000..0c7156c
--- /dev/null
+++ b/etc/patches/paraview-5.0.1
@@ -0,0 +1,39 @@
+--- ParaView-5.0.1/VTK/CMake/vtkCompilerExtras.cmake.orig	2016-03-28 17:07:10.000000000 +0200
++++ ParaView-5.0.1/VTK/CMake/vtkCompilerExtras.cmake	2016-06-11 15:10:14.820958942 +0200
+@@ -32,7 +32,7 @@
+     OUTPUT_VARIABLE _gcc_version_info
+     ERROR_VARIABLE _gcc_version_info)
+ 
+-  string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]*"
++  string (REGEX MATCH "[3-6]\\.[0-9]\\.[0-9]*"
+     _gcc_version "${_gcc_version_info}")
+   if(NOT _gcc_version)
+     string (REGEX REPLACE ".*\\(GCC\\).*([34]\\.[0-9]).*" "\\1.0"
+--- ParaView-5.0.1/VTK/CMake/GenerateExportHeader.cmake.orig	2016-03-28 17:07:10.000000000 +0200
++++ ParaView-5.0.1/VTK/CMake/GenerateExportHeader.cmake	2016-06-11 15:12:16.344357746 +0200
+@@ -166,7 +166,7 @@
+     execute_process(COMMAND ${CMAKE_C_COMPILER} ARGS --version
+       OUTPUT_VARIABLE _gcc_version_info
+       ERROR_VARIABLE _gcc_version_info)
+-    string(REGEX MATCH "[345]\\.[0-9]\\.[0-9]*"
++    string(REGEX MATCH "[3-6]\\.[0-9]\\.[0-9]*"
+       _gcc_version "${_gcc_version_info}")
+     # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the
+     # patch level, handle this here:
+--- ParaView-5.0.1/Qt/Components/CMakeLists.txt.orig	2016-06-13 09:27:27.827849525 +0200
++++ ParaView-5.0.1/Qt/Components/CMakeLists.txt	2016-06-13 09:29:28.599318445 +0200
+@@ -656,10 +656,10 @@
+ #the pqSGExportStateWizard has subclasses that directly access
+ #the UI file, and currently we don't have a clean way to break this hard
+ #dependency, so for no we install this ui file.
+-if(PARAVIEW_INSTALL_DEVELOPMENT_FILES)
+-  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"
+-          DESTINATION "${VTK_INSTALL_INCLUDE_DIR}")
+-endif()
++#OPENFOAM patch#if(PARAVIEW_INSTALL_DEVELOPMENT_FILES)
++#OPENFOAM patch#  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"
++#OPENFOAM patch#          DESTINATION "${VTK_INSTALL_INCLUDE_DIR}")
++#OPENFOAM patch#endif()
+ 
+ #IF (NOT PV_INSTALL_NO_DEVELOPMENT)
+ #  # Headers
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index e5fb200..0ba774a 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -364,6 +364,34 @@ addQtSupport()
 }
 
 
+#
+# Apply source-code patch if possible
+#
+applyPatch()
+{
+    local patch="$WM_THIRD_PARTY_DIR/etc/patches/paraview-$ParaView_VERSION"
+    local sentinel="PATCHED_DURING_OPENFOAM_BUILD"
+
+    if [ -r "$patch" ]
+    then
+    (
+        cd $ParaView_SOURCE_DIR || exit 1
+        if [ -f "$sentinel" ]
+        then
+            echo "patch for paraview-$ParaView_VERSION was already applied"
+        else
+            echo "apply patch for paraview-$ParaView_VERSION"
+            touch "$sentinel"
+            patch -p1 < $patch
+
+        fi
+    )
+    else
+        echo "no patch found for paraview-$ParaView_VERSION"
+    fi
+}
+
+
 #
 # Configure via cmake, but don't actually build anything
 #
diff --git a/makeParaView b/makeParaView
index 10db8a8..8016a86 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -111,6 +111,7 @@ For example,
 to add tests
 
 For finer control, the build stages can be selected or deselected individually:
+  -patch     -no-patch
   -config    -no-config
   -make      -no-make
   -install   -no-install
@@ -144,7 +145,7 @@ setVersion
 #
 # various building stages
 #
-unset runCONFIG runMAKE runINSTALL
+unset runPATCH runCONFIG runMAKE runINSTALL
 runDEFAULT=true
 buildType=Release
 
@@ -163,6 +164,15 @@ do
         export CXX=g++   # use g++
         shift
         ;;
+    -patch)              # stage 0: patch sources
+        runPATCH=true
+        unset runDEFAULT
+        shift
+        ;;
+    -no-patch)
+        runPATCH=false
+        shift
+        ;;
     -config)             # stage 1: config only
         runCONFIG=true
         unset runDEFAULT
@@ -285,6 +295,7 @@ done
 
 if [ "$runDEFAULT" = true ]
 then
+    : ${runPATCH:=true}
     : ${runCONFIG:=true}
     : ${runMAKE:=true}
     : ${runINSTALL:=true}
@@ -309,6 +320,7 @@ cat<<SUMMARY
 
 Build stages selected
 ---------------------
+    -patch    ${runPATCH:-false}
     -config   ${runCONFIG:-false}
     -make     ${runMAKE:-false}
     -install  ${runINSTALL:-false}
@@ -328,6 +340,7 @@ $(checkVersion)
 ---------------------
 SUMMARY
 
+[ "$runPATCH"   = true ] && applyPatch
 [ "$runCONFIG"  = true ] && configParaView
 [ "$runMAKE"    = true ] && makeParaView
 [ "$runINSTALL" = true ] && installParaView
-- 
GitLab


From dc0ed1606aa3bbd95595d9acba5aad502206cae4 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 15 Jun 2016 08:43:08 +0200
Subject: [PATCH 06/40] STYLE: slight cleanup of paraview make

- align comments in ParaView3Functions with ParaViewFunctions
  (makes it easier to spot differences)

- mention '-buildType' option in usage
- fix the version extraction reporting
- drop broken date-stamp check

STYLE: align some naming in makeCCMIO with other files
---
 etc/tools/ParaView3Functions | 111 ++++++++++++-----------------------
 etc/tools/ParaViewFunctions  |  48 +++------------
 makeCCMIO                    |  18 +++---
 makeParaView                 |   4 +-
 makeParaView3                |   3 +-
 5 files changed, 60 insertions(+), 124 deletions(-)

diff --git a/etc/tools/ParaView3Functions b/etc/tools/ParaView3Functions
index fe7e9fd..c0703bc 100644
--- a/etc/tools/ParaView3Functions
+++ b/etc/tools/ParaView3Functions
@@ -32,7 +32,7 @@
 # buildBASE, installBASE defined from tools/ThirdPartyFunctions
 
 #
-# where things are or should be put
+# Where things are or should be put
 #   ParaView_VERSION and ParaView_MAJOR should already have been set
 #
 #   ParaView_SOURCE_DIR : location of the original sources
@@ -70,7 +70,7 @@ setDirs()
 
 
 #
-# set ParaView_VERSION and adjust ParaView_MAJOR accordingly
+# Set ParaView_VERSION and adjust ParaView_MAJOR accordingly
 #
 setVersion()
 {
@@ -79,7 +79,7 @@ setVersion()
         ParaView_VERSION="${1##paraview-}"
     fi
 
-    # the major version is "<digits>.<digits>"
+    # The major version is "<digits>.<digits>"
     ParaView_MAJOR=$(echo $ParaView_VERSION | \
         sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/')
 
@@ -90,58 +90,27 @@ setVersion()
 #------------------------------------------------------------------------------
 
 #
-# extract and echo date stamp information from
-#     VTK/Utilities/kwsys/kwsysDateStamp.cmake
-# since the order of the entries is already correct, can use simple sed script
+# Compare version information (specified vs what is found in CMakeLists.txt)
+# Parse this type of content:
+#   set (PARAVIEW_VERSION_FULL "3.98.1")
 #
-echoDateStamp()
+checkVersion()
 {
-    (
-        set -- $(
-            sed -ne 's/^SET(KWSYS_DATE_STAMP_[A-Z]*\([ 0-9]*\)).*$/\1/p' \
-            $ParaView_SOURCE_DIR/VTK/Utilities/kwsys/kwsysDateStamp.cmake
-        )
-
-        IFS='-'
-        echo "date-stamp: $*"
+    local ver=$(
+        sed -ne 's/^ *set *( *PARAVIEW_VERSION_FULL[ "]*\([.0-9]*\).*$/\1/ip' \
+        $ParaView_SOURCE_DIR/CMakeLists.txt
     )
-}
 
-
-#
-# extract version information from
-#     CMakeLists.txt
-# since the order of the entries is already correct, can use simple sed script
-#
-getVersion()
-{
-    (
-        set -- $(
-            sed -ne 's/^SET(PARAVIEW_VERSION_[A-Z]*\([ 0-9]*\)).*$/\1/p' \
-            $ParaView_SOURCE_DIR/CMakeLists.txt
-        )
-
-        IFS='.'
-        echo "$*"
-    )
-}
-
-#
-# compare version information
-#
-checkVersion()
-{
-    local ver=$(getVersion)
     if [ "$ParaView_VERSION" != "$ver" ]
     then
         echo "MISMATCH!"
         echo "    specified $ParaView_VERSION"
-        echo "    found     $ver"
+        echo "    found     ${ver:-NONE}"
     fi
 }
 
 #
-# set CMake cache variables
+# Set CMake cache variables
 #
 addCMakeVariable()
 {
@@ -154,7 +123,7 @@ addCMakeVariable()
 
 
 #
-# verbose makefiles
+# Verbose makefiles
 #
 addVerbosity()
 {
@@ -166,7 +135,7 @@ addVerbosity()
 
 
 #
-# define options for mpi support
+# Define options for mpi support
 #
 addMpiSupport()
 {
@@ -183,7 +152,7 @@ addMpiSupport()
 
 
 #
-# define options for python support
+# Define options for python support
 #
 addPythonSupport()
 {
@@ -198,7 +167,7 @@ addPythonSupport()
     then
         if [ -n "$PYTHON_LIBRARY" ]
         then
-            # check $PYTHON_LIBRARY if it has been set
+            # Check $PYTHON_LIBRARY if it has been set
             if [ ! -e "$PYTHON_LIBRARY" ]
             then
                 echo "*** Error: libpython not found at location specified " \
@@ -225,7 +194,7 @@ addPythonSupport()
         pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
         pythonInclude=/usr/include/python$pythonMajor
 
-        # note - we could also allow for a PYTHON_INCLUDE variable ...
+        # Note - we could also allow for a PYTHON_INCLUDE variable ...
         [ -d "$pythonInclude" ] || {
             echo "    No python headers found in $pythonInclude/"
             echo "    Please install python headers or deactivate "
@@ -255,7 +224,7 @@ addPythonSupport()
 
 
 #
-# define options for mesa support
+# Define options for mesa support
 #
 addMesaSupport()
 {
@@ -286,6 +255,7 @@ addMesaSupport()
 addQtSupport()
 {
     QtVersion=none
+
     if [ "${withQT:=false}" != true ]
     then
         return
@@ -312,7 +282,7 @@ addQtSupport()
 
         if [ -n "$qmakeExe" ]
         then
-            # use absolute path
+            # Use absolute path
             if [ "${qmakeExe#/}" = "$qmakeExe" ]
             then
                 qmakeExe="$(cd ${qmakeExe%/qmake} 2>/dev/null && pwd)/qmake"
@@ -326,7 +296,7 @@ addQtSupport()
         fi
     fi
 
-    # default to using qmake from the path
+    # Default to using qmake from the path
     if [ -n "$qmakeExe" ]
     then
         addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmakeExe"
@@ -342,7 +312,7 @@ addQtSupport()
         # parse -> "Using Qt version X.Y.Z in ..."
         QtVersion=$($qmakeExe -query QT_VERSION)
 
-        # split Major.Minor.Revision - could also use IFS hacking
+        # Split Major.Minor.Revision - could also use IFS hacking
         set -- $(echo "$QtVersion" | sed -e 's/\./ /g')
 
         QtMajor=$1
@@ -365,7 +335,7 @@ addQtSupport()
 
 
 #
-# configure via cmake, but don't actually build anything
+# Configure via cmake, but don't actually build anything
 #
 configParaView()
 {
@@ -388,7 +358,7 @@ configParaView()
 
         if [ -n "$cmakeExe" ]
         then
-            # use absolute path
+            # Use absolute path
             if [ "${cmakeExe#/}" = "$cmakeExe" ]
             then
                 cmakeExe="$(cd ${cmakeExe%/cmake} 2>/dev/null && pwd)/cmake"
@@ -402,13 +372,13 @@ configParaView()
         fi
     fi
 
-    # default to using cmake from the path
+    # Default to using cmake from the path
     if [ -z "$cmakeExe" ]
     then
         cmakeExe=cmake
     fi
 
-    # remove any existing build folder and recreate
+    # Remove any existing build folder and recreate
     if [ -d $ParaView_BINARY_DIR ]
     then
         echo "removing old build directory"
@@ -417,7 +387,7 @@ configParaView()
     fi
     mkdir -p $ParaView_BINARY_DIR
 
-    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
+    cd $ParaView_BINARY_DIR || exit 1  # Change to build folder
 
     echo "----"
     echo "Configuring paraview-$ParaView_VERSION (major version: $ParaView_MAJOR)"
@@ -438,7 +408,7 @@ configParaView()
     echo "----"
     echo
 
-    # run cmake to create Makefiles
+    # Run cmake to create Makefiles
     $cmakeExe \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
@@ -447,17 +417,17 @@ configParaView()
 
 
 #
-# invoke make
+# Invoke make
 # also link bin/ to lib/paraview-* for development without installation
 #
 makeParaView()
 {
-    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
+    cd $ParaView_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
+    # Remove lib if it is a link
     # (how this was previously handled before 'make install' worked)
     if [ -L lib ]
     then
@@ -467,11 +437,11 @@ makeParaView()
 
 
 #
-# install the program
+# Install the program
 #
 installParaView()
 {
-    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
+    cd $ParaView_BINARY_DIR || exit 1  # Change to build folder
     echo "    Installing ParaView to $ParaView_DIR"
 
     make install
@@ -492,11 +462,8 @@ installParaView()
 cat<< INFO
     ---
     Installation complete for paraview-$ParaView_VERSION
-    Set environment variables:
-
-        export ParaView_DIR=$ParaView_DIR
-        export PATH=\$ParaView_DIR/bin:\$PATH
-        export PV_PLUGIN_PATH=\$FOAM_LIBBIN/paraview-$ParaView_MAJOR
+    Now update the environment by running:
+        wmREFRESH
     ---
 INFO
 }
@@ -504,7 +471,7 @@ INFO
 
 #------------------------------------------------------------------------------
 
-# clear the referenced variables before using any of the functions
+# Clear the referenced variables before using any of the functions
 unset withMPI  withVERBOSE
 unset withQT      QMAKE_PATH
 unset withMESA    MESA_INCLUDE    MESA_LIBRARY
@@ -513,15 +480,15 @@ unset CMAKE_VARIABLES
 unset OBJ_ADD
 
 
-# start with these general settings
+# Start with these general settings
 addCMakeVariable  "VTK_USE_TK:BOOL=OFF"
 addCMakeVariable  "BUILD_SHARED_LIBS:BOOL=ON  VTK_USE_RPATH:BOOL=OFF"
 addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=Release"
 
-# include development files in "make install"
+# Include development files in "make install"
 addCMakeVariable  "PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON"
 
-# don't build test tree
+# Don't build test tree
 addCMakeVariable  "BUILD_TESTING:BOOL=OFF"
 
 # remove dependency on WebKit
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 0ba774a..e828ea8 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -90,52 +90,22 @@ setVersion()
 #------------------------------------------------------------------------------
 
 #
-# Extract and echo date stamp information from
-#     VTK/Utilities/kwsys/kwsysDateStamp.cmake
-# since the order of the entries is already correct, can use simple sed script
+# Compare version information (specified vs what is found in CMakeLists.txt)
+# Parse this type of content:
+#   set (PARAVIEW_VERSION_FULL "5.0.1")
 #
-echoDateStamp()
-{
-    (
-        set -- $(
-            sed -ne 's/^SET(KWSYS_DATE_STAMP_[A-Z]*\([ 0-9]*\)).*$/\1/p' \
-            $ParaView_SOURCE_DIR/VTK/Utilities/kwsys/kwsysDateStamp.cmake
-        )
-
-        IFS='-'
-        echo "date-stamp: $*"
-    )
-}
-
-#
-# Extract version information from
-#     CMakeLists.txt
-# since the order of the entries is already correct, can use simple sed script
-#
-getVersion()
+checkVersion()
 {
-    (
-        set -- $(
-            sed -ne 's/^SET(PARAVIEW_VERSION_[A-Z]*\([ 0-9]*\)).*$/\1/p' \
-            $ParaView_SOURCE_DIR/CMakeLists.txt
-        )
-
-        IFS='.'
-        echo "$*"
+    local ver=$(
+        sed -ne 's/^ *set *( *PARAVIEW_VERSION_FULL[ "]*\([.0-9]*\).*$/\1/ip' \
+        $ParaView_SOURCE_DIR/CMakeLists.txt
     )
-}
 
-#
-# Compare version information
-#
-checkVersion()
-{
-    local ver=$(getVersion)
     if [ "$ParaView_VERSION" != "$ver" ]
     then
         echo "MISMATCH!"
         echo "    specified $ParaView_VERSION"
-        echo "    found     $ver"
+        echo "    found     ${ver:-NONE}"
     fi
 }
 
@@ -511,7 +481,7 @@ cat<< INFO
     ---
     Installation complete for paraview-$ParaView_VERSION
     Now update the environment by running:
-        wmRefresh
+        wmREFRESH
     ---
 INFO
 }
diff --git a/makeCCMIO b/makeCCMIO
index 12b1137..8990572 100755
--- a/makeCCMIO
+++ b/makeCCMIO
@@ -34,7 +34,7 @@
 . $WM_PROJECT_DIR/etc/config.sh/functions
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/libccmio)
 
-ccmio_version=${ccmio_version:-libccmio-2.6.1}
+ccmioPACKAGE=${ccmio_version:-libccmio-2.6.1}
 targetType=libso
 
 #------------------------------------------------------------------------------
@@ -65,14 +65,14 @@ options:
   -help
 
 * Compile the proprietary libccmio library
-      $ccmio_version
+      $ccmioPACKAGE
 
   Users wishing to make use of the library should contact cd-adapco
   (Siemens PLM) for possible download and terms of use.
 
-  After obtaining the $ccmio_version library, place in folder
+  After obtaining the $ccmioPACKAGE library, place in folder
 
-      $WM_THIRD_PARTY_DIR/$ccmio_version/
+      $WM_THIRD_PARTY_DIR/$ccmioPACKAGE/
 
   prior to running this script.
 
@@ -93,7 +93,7 @@ do
         shift
         ;;
     libccmio-[1-9]*)
-        ccmio_version="${1%%/}"
+        ccmioPACKAGE="${1%%/}"
         shift
         ;;
     *)
@@ -103,21 +103,21 @@ do
 done
 
 # warn if unavailable
-if [ ! -d ${ccmio_version} ]
+if [ ! -d ${ccmioPACKAGE} ]
 then
-    usage "missing source directory '$ccmio_version'"
+    usage "missing source directory '$ccmioPACKAGE'"
 fi
 
 
 #------------------------------------------------------------------------------
-CCMIO_ARCH_PATH=$installBASE/$ccmio_version
+CCMIO_ARCH_PATH=$installBASE/$ccmioPACKAGE
 
 #
 # Build LIBCCMIO
 #
 echo "---------------"
 (
-    cd $ccmio_version || exit 1
+    cd $ccmioPACKAGE || exit 1
     incDIR=$CCMIO_ARCH_PATH/include/libccmio
     libDIR=$CCMIO_ARCH_PATH/lib
 
diff --git a/makeParaView b/makeParaView
index 8016a86..9380008 100755
--- a/makeParaView
+++ b/makeParaView
@@ -96,13 +96,14 @@ options:
   -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-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 disable these features (if not already disabled):
+The -no-FEATURE option can be used to forcibly disable these features:
   mesa mpi python qt
 
 CMake options start with a capital letter and contain an '='.
@@ -311,7 +312,6 @@ addMesaSupport      # set MESA-specific options
 addQtSupport        # add extra Qt support
 
 setDirs             # where things are or should be put
-echoDateStamp       # report kitware source code date-stamp
 
 
 # Build and install
diff --git a/makeParaView3 b/makeParaView3
index 28101ee..4d6ef61 100755
--- a/makeParaView3
+++ b/makeParaView3
@@ -102,7 +102,7 @@ options:
   -python-lib PATH  path to python library   (current value: ${PYTHON_LIBRARY:-none})
   -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:
   mesa mpi python qt
 
 CMake options start with a capital letter and contain an '='.
@@ -294,7 +294,6 @@ addMesaSupport      # set MESA-specific options
 addQtSupport        # add extra Qt support
 
 setDirs             # where things are or should be put
-echoDateStamp       # report kitware source code date-stamp
 
 
 # Build and install
-- 
GitLab


From b06f4a8639a11847e33c7902614c795bf24e531e Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 16 Jun 2016 10:00:15 +0200
Subject: [PATCH 07/40] ENH: generalize patching facilty - provide patch for
 scotch_6.0.4

- fixes #1
---
 Allwmake                      | 40 ++++++++++++++++-----------
 etc/patches/scotch_6.0.4      | 10 +++++++
 etc/tools/ParaViewFunctions   | 23 ++--------------
 etc/tools/ThirdPartyFunctions | 51 ++++++++++++++++++++++++++++++-----
 makeParaView                  |  2 +-
 5 files changed, 81 insertions(+), 45 deletions(-)
 create mode 100644 etc/patches/scotch_6.0.4

diff --git a/Allwmake b/Allwmake
index 977a53e..ce56f60 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -112,7 +112,6 @@ MPICH)
     then
         echo "    have $WM_MPLIB shared library ($FOAM_MPI)"
         echo
-        echo
     elif [ -r $MPI_ARCH_PATH/lib/libmpich.a ]
     then
         echo "    have $WM_MPLIB static library ($FOAM_MPI)"
@@ -172,6 +171,9 @@ MPICH)
 esac
 
 
+#------------------------------------------------------------------------------
+# building scotch is still a bit of a pain
+
 # get SCOTCH_VERSION, SCOTCH_ARCH_PATH
 if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch`
 then
@@ -182,7 +184,6 @@ else
     echo
 fi
 
-# building scotch is still a bit of a pain
 echo ========================================
 echo "Build Scotch decomposition library $SCOTCH_VERSION"
 echo "    $SCOTCH_ARCH_PATH"
@@ -197,10 +198,11 @@ then
     echo "    scotch header in $SCOTCH_ARCH_PATH/include"
     echo "    scotch libs   in $FOAM_EXT_LIBBIN"
     echo
-else
+elif [ -d "$SCOTCH_VERSION" ]
+then
 (
-    set -x
     cd $SCOTCH_VERSION/src || exit 1
+    applyPatch $SCOTCH_VERSION ..       # patch at parent-level
 
     prefixDIR=$SCOTCH_ARCH_PATH
     libDIR=$FOAM_EXT_LIBBIN
@@ -233,21 +235,22 @@ else
     # cleanup, could also remove Makefile.inc
     make realclean 2>/dev/null
 )
+else
+    echo "    optional component SCOTCH was not found"
 fi
 
-# verify existence of scotch include
-[ -f $SCOTCH_ARCH_PATH/include/scotch.h ] || {
-    echo
-    echo "    WARNING: required include file 'scotch.h' not found!"
+# build ptscotch if MPI (ThirdParty or system) is available
+# and there is a scotch include available (ie, normal scotch was built)
+if [ "${FOAM_MPI:-dummy}" != dummy ] && \
+   [ -f $SCOTCH_ARCH_PATH/include/scotch.h ] || \
+{
+    echo "    WARNING: skipping pt-scotch - 'scotch.h' include file not found!"
     echo
+    false
 }
-
-
-# build ptscotch if MPI (ThirdParty or system) is available
-if [ "${FOAM_MPI:-dummy}" != dummy ]
 then
     echo ========================================
-    echo "Build PTScotch decomposition library $SCOTCH_VERSION (uses MPI)"
+    echo "Build pt-scotch decomposition library $SCOTCH_VERSION (with $FOAM_MPI)"
     echo "    $SCOTCH_ARCH_PATH"
     echo
 
@@ -354,10 +357,12 @@ then
     )
     fi
 else
-    echo "    optional component Metis was not found"
+    echo "    optional component METIS was not found"
 fi
 
 
+#------------------------------------------------------------------------------
+
 # CGAL is optional
 echo ========================================
 echo Build CGAL
@@ -373,9 +378,12 @@ then
     fi
 )
 else
-    echo "    optional component was not found"
+    echo "    optional component CGAL was not found"
 fi
 
+
+#------------------------------------------------------------------------------
+
 echo
 echo ========================================
 echo Done ThirdParty Allwmake
diff --git a/etc/patches/scotch_6.0.4 b/etc/patches/scotch_6.0.4
new file mode 100644
index 0000000..87c8e5a
--- /dev/null
+++ b/etc/patches/scotch_6.0.4
@@ -0,0 +1,10 @@
+--- scotch_6.0.4/src/libscotch/common.h.orig	2015-03-01 10:14:02.000000000 +0100
++++ scotch_6.0.4/src/libscotch/common.h	2016-06-16 09:23:00.314985888 +0200
+@@ -306,6 +306,8 @@
+   ThreadLaunchStartFunc     stafptr;              /*+ Pointer to start routine +*/
+   ThreadLaunchJoinFunc      joifptr;              /*+ Pointer to join routine  +*/
+   ThreadBarrier             barrdat;              /*+ Barrier data structure   +*/
++#else
++  int                       thrdnbr;    /* dummy for non-threaded */
+ #endif /* ((defined COMMON_PTHREAD) || (defined SCOTCH_PTHREAD)) */
+ } ThreadGroupHeader;
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index e828ea8..67d7ebc 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -337,28 +337,9 @@ addQtSupport()
 #
 # Apply source-code patch if possible
 #
-applyPatch()
+patchParaView()
 {
-    local patch="$WM_THIRD_PARTY_DIR/etc/patches/paraview-$ParaView_VERSION"
-    local sentinel="PATCHED_DURING_OPENFOAM_BUILD"
-
-    if [ -r "$patch" ]
-    then
-    (
-        cd $ParaView_SOURCE_DIR || exit 1
-        if [ -f "$sentinel" ]
-        then
-            echo "patch for paraview-$ParaView_VERSION was already applied"
-        else
-            echo "apply patch for paraview-$ParaView_VERSION"
-            touch "$sentinel"
-            patch -p1 < $patch
-
-        fi
-    )
-    else
-        echo "no patch found for paraview-$ParaView_VERSION"
-    fi
+    applyPatch "paraview-$ParaView_VERSION" "$ParaView_SOURCE_DIR"
 }
 
 
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 7af9534..60cdf36 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -71,8 +71,8 @@ downloadFile()
         return 1
     }
 
-    file="$1"
-    url="$2"
+    local file="$1"
+    local url="$2"
 
     if [ ! -e download/$file ]
     then
@@ -84,10 +84,10 @@ downloadFile()
 
 
 #
-# Copy Make/{files,options} from wmakeFiles/PACKAGE
+# Copy Make/{files,options} from etc/wmakeFiles/PACKAGE
 #
 # $1 = PACKAGE
-# $2 (optional) TARGET DIRECTORY
+# $2 = TARGET DIRECTORY (optional)
 cpMakeFiles()
 {
     set +x
@@ -97,8 +97,8 @@ cpMakeFiles()
         return 1
     }
 
-    pkg=$1
-    dst=${2:-.}
+    local pkg=$1
+    local dst="${2:-.}"
     echo "cpMakeFiles" $pkg $dst
 
     wmakeFiles=$WM_THIRD_PARTY_DIR/etc/wmakeFiles/$pkg
@@ -128,4 +128,41 @@ cpMakeFiles()
 }
 
 
+#
+# Apply source-code patch if possible.
+# Patches are taken from etc/patches/PACKAGE
+#
+# $1 = PACKAGE
+# $2 = TARGET DIRECTORY (optional)
+applyPatch()
+{
+    [ "$#" -eq 1 -o "$#" -eq 2 ] || {
+        echo "applyPatch called with incorrect number of arguments ($#): $@"
+        return 1
+    }
+
+    local pkg="$1"
+    local dst="${2:-.}"
+
+    local patch="$WM_THIRD_PARTY_DIR/etc/patches/$pkg"
+    local sentinel="PATCHED_DURING_OPENFOAM_BUILD"
+
+    if [ -r "$patch" ]
+    then
+    (
+        cd $dst || exit 1
+        if [ -f "$sentinel" ]
+        then
+            echo "patch for $pkg was already applied"
+        else
+            echo "apply patch for $pkg"
+            touch "$sentinel"
+            patch -p1 < $patch
+        fi
+    )
+    else
+        echo "no patch found for $pkg"
+    fi
+}
+
 #------------------------------------------------------------------------------
diff --git a/makeParaView b/makeParaView
index 9380008..454eaa0 100755
--- a/makeParaView
+++ b/makeParaView
@@ -340,7 +340,7 @@ $(checkVersion)
 ---------------------
 SUMMARY
 
-[ "$runPATCH"   = true ] && applyPatch
+[ "$runPATCH"   = true ] && patchParaView
 [ "$runCONFIG"  = true ] && configParaView
 [ "$runMAKE"    = true ] && makeParaView
 [ "$runINSTALL" = true ] && installParaView
-- 
GitLab


From a66c85ce80e50352734bfc28ab6e43a89eedb6a2 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 16 Jun 2016 13:09:45 +0200
Subject: [PATCH 08/40] BUG: inconsistent gcc libraries between makeGcc and
 OpenFOAM

- explicitly define WM_COMPILER_TYPE=ThirdParty before sourcing
  the OpenFOAM settings. Provide system equivalents as fallbacks
  so that it is apparent what is happening.
  Make the same adjustment to makeLLVM.

BUG: inconsistent CGAL version between makeCGAL and OpenFOAM
---
 makeCGAL | 38 ++++++++++++++++++++++++++++----------
 makeGcc  | 46 ++++++++++++++++++++++++++--------------------
 makeLLVM | 19 ++++++++++++++++---
 3 files changed, 70 insertions(+), 33 deletions(-)

diff --git a/makeCGAL b/makeCGAL
index 0fbd2c8..8d2f9e8 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -44,12 +44,10 @@ _foamEval SOURCE_CGAL_VERSIONS_ONLY=yes \
           $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
 
-set -x
-
-cgalPACKAGE=${cgal_version:-CGAL-4.8}
 boostPACKAGE=${boost_version:-boost-system}
 gmpPACKAGE=${gmp_version:-gmp-system}
 mpfrPACKAGE=${mpfr_version:-mpfr-system}
+cgalPACKAGE=$cgal_version
 
 #------------------------------------------------------------------------------
 # Run from third-party directory only
@@ -88,7 +86,7 @@ Note: mixing system and ThirdParty for gmp/mpfr is not supported.
 USAGE
     exit 1
 }
-
+#------------------------------------------------------------------------------
 
 # Ensure CMake gets the correct C++ compiler
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
@@ -101,6 +99,9 @@ do
     -h | -help)
         usage
         ;;
+    '')
+        # discard empty arguments
+        ;;
     -gcc)
         export CXX=g++   # use g++
         shift
@@ -127,9 +128,12 @@ do
     esac
 done
 
+if [ -z "$cgalPACKAGE" ]
+then
+    usage "The cgal-VERSION was not specified"
+fi
 
 #------------------------------------------------------------------------------
-
 #
 # Build Boost
 #
@@ -176,6 +180,13 @@ else
     fi
 fi
 
+# nothing left to build
+if [ "$cgal_version" = "cgal-system" ]
+then
+    echo "Using system installation of CGAL"
+    exit 0
+fi
+
 
 # Retrieve boost version:
 if [ -f "$boostInc/boost/version.hpp" ]
@@ -187,12 +198,19 @@ else
     exit 1
 fi
 
-if [ "$cgal_version" = "cgal-system" ]
-then
-    echo "Using system installation of CGAL"
-    exit 0
-fi
+#------------------------------------------------------------------------------
 
+cat<<SUMMARY
+CGAL configuration
+------------------
+    CGAL    = $cgalPACKAGE
+    BOOST   = $boostPACKAGE
+    GMP     = $gmpPACKAGE
+    MPFR    = $mpfrPACKAGE
+------------------
+SUMMARY
+
+#------------------------------------------------------------------------------
 #
 # Build CGAL
 #
diff --git a/makeGcc b/makeGcc
index c455ce1..b505ed9 100755
--- a/makeGcc
+++ b/makeGcc
@@ -26,20 +26,22 @@
 #     makeGcc
 #
 # Description
-#     Build script for gmp, mpfr and gcc-[4-9].?.?
+#     Build script gcc and gmp, mpfr, mpc.
+#
 #
 #------------------------------------------------------------------------------
-
 # get default GCC, mpfr, gmp and mpc versions
+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)
 
-gmpPACKAGE=${gmp_version:-gmp-5.1.2}
-mpfrPACKAGE=${mpfr_version:-mpfr-3.1.2}
-mpcPACKAGE=${mpc_version:-mpc-1.0.1}
+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" || {
@@ -50,15 +52,16 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
+Script=${0##*/}
 
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: ${0##*/} [option] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION] <gcc-VERSION>
+usage: $Script [OPTION] [gcc-VERSION] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION]
 options:
-  -no-multilib      for 64-bit systems that don't have 32-bit support
+  -no-multilib      for 64-bit systems without 32-bit support
   -help
 
 * build combinations of gmp, mpfr, mpc and gcc
@@ -70,8 +73,9 @@ options:
 USAGE
     exit 1
 }
+#------------------------------------------------------------------------------
 
-GCC_BUILD_OPTIONS=""
+unset GCC_BUILD_OPTIONS
 
 # Parse options
 while [ "$#" -gt 0 ]
@@ -80,7 +84,7 @@ do
     -h | -help)
         usage
         ;;
-    -no-multilib)
+    -no-multi*)
         GCC_BUILD_OPTIONS="--disable-multilib"
         shift
         ;;
@@ -134,9 +138,9 @@ GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
 MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
 MPC_ARCH_PATH=$installBASE/$mpcPACKAGE
 
-#
+# ================
 # Build GMP
-#
+# ================
 echo "---------------"
 if [ -d $GMP_ARCH_PATH ]
 then
@@ -171,9 +175,9 @@ fi
 
 export LD_LIBRARY_PATH="$GMP_ARCH_PATH/lib:$LD_LIBRARY_PATH"
 
-#
+# ================
 # Build MPFR
-#
+# ================
 echo "---------------"
 if [ -d $MPFR_ARCH_PATH ]
 then
@@ -209,9 +213,10 @@ fi
 
 export LD_LIBRARY_PATH="$MPFR_ARCH_PATH/lib:$LD_LIBRARY_PATH"
 
-#
-# Build mpc
-#
+
+# ================
+# Build MPC
+# ================
 echo "---------------"
 if [ -d $MPC_ARCH_PATH ]
 then
@@ -247,17 +252,18 @@ else
 }
 fi
 
-
 if [ -d "$MPC_ARCH_PATH" ]
 then
     export LD_LIBRARY_PATH="$MPC_ARCH_PATH/lib:$LD_LIBRARY_PATH"
 fi
 
 
-#
+# ================
 # Build GCC
-# might need 32-bit glibc-devel headers to compile
+# ================
+# may need 32-bit glibc-devel headers to compile
 # E.g. on ubuntu install g++-multilib
+# or specify -no-multilib on the command-line
 #
 echo "---------------"
 if [ -d $GCC_ARCH_PATH ]
diff --git a/makeLLVM b/makeLLVM
index fb557ac..81f8a18 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -37,12 +37,14 @@
 #        cd -
 #
 #------------------------------------------------------------------------------
+# get default llvm/clang version
+WM_COMPILER_TYPE="ThirdParty"     # ensure we get the correct compiler settings
+WM_COMPILER=Clang                 # force values for 'clang'
 
-# get default llvm version
 . $WM_PROJECT_DIR/etc/config.sh/functions
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
 
-llvmPACKAGE=${clang_version:-llvm-3.7.0}
+llvmPACKAGE=$clang_version
 
 #------------------------------------------------------------------------------
 # run from third-party directory only
@@ -54,13 +56,16 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
+Script=${0##*/}
 
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: ${0##*/} [llvm-VERSION]
+usage: $Script [OPTION] [llvm-VERSION]
+options:
+  -help
 
 * build llvm/clang
       $llvmPACKAGE
@@ -69,6 +74,8 @@ USAGE
     exit 1
 }
 
+#-----------------------------------------------------------------------------
+
 
 # parse options
 while [ "$#" -gt 0 ]
@@ -87,6 +94,12 @@ do
     esac
 done
 
+if [ -z "$llvmPACKAGE" ]
+then
+    die "The llvm-VERSION was not specified"
+    exit 1
+fi
+
 #------------------------------------------------------------------------------
 # build/install without compiler name
 buildBASE=$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER_ARCH
-- 
GitLab


From 5d63dd1b5a708803ca7a674fc091f0b6ad98eb87 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 16 Jun 2016 17:49:23 +0200
Subject: [PATCH 09/40] BUG: missing library arch on 3rd party gmp/mpfr/mpc
 paths

---
 makeGcc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/makeGcc b/makeGcc
index b505ed9..b337cb9 100755
--- a/makeGcc
+++ b/makeGcc
@@ -173,7 +173,11 @@ else
 }
 fi
 
-export LD_LIBRARY_PATH="$GMP_ARCH_PATH/lib:$LD_LIBRARY_PATH"
+if [ -d "$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" ]
+then
+    _foamAddLib "$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
+fi
+
 
 # ================
 # Build MPFR
@@ -211,7 +215,10 @@ else
 }
 fi
 
-export LD_LIBRARY_PATH="$MPFR_ARCH_PATH/lib:$LD_LIBRARY_PATH"
+if [ -d "$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" ]
+then
+    _foamAddLib "$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
+fi
 
 
 # ================
@@ -252,9 +259,9 @@ else
 }
 fi
 
-if [ -d "$MPC_ARCH_PATH" ]
+if [ -d "$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" ]
 then
-    export LD_LIBRARY_PATH="$MPC_ARCH_PATH/lib:$LD_LIBRARY_PATH"
+    _foamAddLib "$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
 fi
 
 
-- 
GitLab


From b66ec91d01aa163302ea366b567b9d9a34b3fe76 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 16 Jun 2016 17:51:56 +0200
Subject: [PATCH 10/40] ENH: support use of system gmp/mpfr/mpc with ThirdParty
 gcc

- not previously possible to configure a third-party gcc
  with system gmp/mpfr/mpc.
  This makes it easier to switch between compilers for testing.
---
 etc/tools/ThirdPartyFunctions | 13 ++++++
 makeCGAL                      | 77 ++++++++++++++++++++++++-----------
 makeGcc                       | 40 ++++++++++++++++--
 3 files changed, 103 insertions(+), 27 deletions(-)

diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 60cdf36..2e27969 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -61,6 +61,19 @@ then
 fi
 
 
+# Test if it matches "*-none"
+_foamIsNone()
+{
+    test "${1##*-}" = none
+}
+
+# Test if it matches "*-system"
+_foamIsSystem()
+{
+    test "${1##*-}" = system
+}
+
+
 #
 # Download file $1 from url $2 into download/ directory
 #
diff --git a/makeCGAL b/makeCGAL
index 8d2f9e8..32aa5f8 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -59,15 +59,17 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 }
 . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
+Script="${0##*/}"
 
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: ${0##*/} [OPTION] [CGAL-VERSION] [boost-VERSION] [gmp-VERSION] [mpfr-VERSION]
+usage: $Script [OPTION] [CGAL-VERSION] [boost-VERSION] [gmp-VERSION] [mpfr-VERSION]
 options:
   -gcc              force g++ instead of the value from \$WM_CXX
+  -system           use system versions for boost/gmp/mpfr
   -help
 
 * build CGAL with
@@ -77,9 +79,9 @@ options:
       $mpfrPACKAGE
 
 Normally builds against ThirdParty boost and gmp/mpfr when possible.
-To override this behaviour (and use the system boost and/o gmp/mpfr),
+To override this behaviour (and use the system boost and/or gmp/mpfr),
 simply specify a 'system' version. For example,
-    ${0##*/} boost-system gmp-system
+    $Script boost-system gmp-system
 
 Note: mixing system and ThirdParty for gmp/mpfr is not supported.
 
@@ -106,11 +108,17 @@ do
         export CXX=g++   # use g++
         shift
         ;;
-    gmp-[4-9]* | gmp-sys*)
+    -sys*)
+        gmpPACKAGE="gmp-system"
+        mpfrPACKAGE="mpfr-system"
+        boostPACKAGE="boost-system"
+        shift
+        ;;
+    gmp-[4-9]* | gmp-system)
         gmpPACKAGE="${1%%/}"
         shift
         ;;
-    mpfr-[2-9]* | mpfr-sys*)
+    mpfr-[2-9]* | mpfr-system)
         mpfrPACKAGE="${1%%/}"
         shift
         ;;
@@ -118,7 +126,7 @@ do
         cgalPACKAGE="${1%%/}"
         shift
         ;;
-    boost-[0-9]* | boost_[0-9]* | boost-sys* )
+    boost-[0-9]* | boost_[0-9]* | boost-system )
         boostPACKAGE="${1%%/}"
         shift
         ;;
@@ -146,12 +154,27 @@ if [ -d "$BOOST_ARCH_PATH" ]
 then
     boostInc="$BOOST_ARCH_PATH/include"
     boostLib="$BOOST_ARCH_PATH/lib"
-elif [ -d "$BOOST_SOURCE_DIR" ]
+elif _foamIsSystem $BOOST_ARCH_PATH
 then
+    echo "Using boost-system"
+
+    boostInc="/usr/include"
+
+    # For completeness:
+    # 64-bit needs lib64, but 32-bit needs lib (not lib32)
+    if [ "$WM_ARCH_OPTION" = 64 ]
+    then
+        boostLib="/usr/lib$WM_ARCH_OPTION"
+    else
+        boostLib="/usr/lib"
+    fi
+else
+    echo "Starting build: boost"
+    echo
+
     boostInc="$BOOST_ARCH_PATH/include"
     boostLib="$BOOST_ARCH_PATH/lib"
 
-    echo "Starting build: boost"
     (
         cd $BOOST_SOURCE_DIR || exit 1
 
@@ -167,17 +190,13 @@ then
         echo "Error building: boost"
         exit 1
     }
-else
-    boostInc="/usr/include"
+fi
 
-    # For completeness:
-    # 64-bit needs lib64, but 32-bit needs lib (not lib32)
-    if [ "$WM_ARCH_OPTION" = 64 ]
-    then
-        boostLib="/usr/lib$WM_ARCH_OPTION"
-    else
-        boostLib="/usr/lib"
-    fi
+# nothing to build
+if _foamIsSystem "$cgalPACKAGE"
+then
+    echo "Using CGAL-system"
+    exit 0
 fi
 
 # nothing left to build
@@ -242,7 +261,7 @@ MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
 
     cd $CGAL_BINARY_DIR || exit 1
 
-    unset configBoost configGmpMpfr
+    unset configBoost configGmp configMpfr
     echo "----"
     echo "Configuring $cgalPACKAGE with boost $BOOST_VERSION_NO"
     echo "    Source         : $CGAL_SOURCE_DIR"
@@ -271,22 +290,32 @@ CMAKE_OPTIONS
 )
     fi
 
-    if [ -d "$GMP_ARCH_PATH" -a -d "$MPFR_ARCH_PATH" ]
+    if [ -d "$GMP_ARCH_PATH" ]
     then
-        echo "    ThirdParty     : gmp/mpfr"
-        configGmpMpfr=$(cat <<CMAKE_OPTIONS
+        echo "    ThirdParty     : gmp"
+        configGmp=$(cat <<CMAKE_OPTIONS
  -DGMP_INCLUDE_DIR=$GMP_ARCH_PATH/include
  -DGMP_LIBRARIES_DIR=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
  -DGMP_LIBRARIES=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libgmp.so
  -DGMPXX_INCLUDE_DIR=$GMP_ARCH_PATH/include
  -DGMPXX_LIBRARIES=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libgmpxx.so
+CMAKE_OPTIONS
+)
+    else
+        echo "    system         : gmp"
+    fi
+
+    if [ -d "$MPFR_ARCH_PATH" ]
+    then
+        echo "    ThirdParty     : mpfr"
+        configMpfr=$(cat <<CMAKE_OPTIONS
  -DMPFR_INCLUDE_DIR=$MPFR_ARCH_PATH/include
  -DMPFR_LIBRARIES_DIR=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
  -DMPFR_LIBRARIES=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmpfr.so
 CMAKE_OPTIONS
 )
     else
-        echo "    system         : gmp/mpfr"
+        echo "    system         : mpfr"
     fi
 
     echo "----"
@@ -295,7 +324,7 @@ CMAKE_OPTIONS
         -DCMAKE_INSTALL_PREFIX=$CGAL_ARCH_PATH \
         -DCMAKE_BUILD_TYPE=Release \
         -DWITH_CGAL_Qt5=OFF \
-        $configBoost $configGmpMpfr \
+        $configBoost $configGmp $configMpfr \
         $CGAL_SOURCE_DIR \
     && make -j $WM_NCOMPPROCS \
     && make install || exit 1
diff --git a/makeGcc b/makeGcc
index b337cb9..70721c4 100755
--- a/makeGcc
+++ b/makeGcc
@@ -28,6 +28,10 @@
 # Description
 #     Build script gcc and gmp, mpfr, mpc.
 #
+#     Normally builds against ThirdParty gmp/mpfr when possible.
+#     To override this behaviour (and use the system gmp/mpfr/mpc),
+#     simply specify a 'system' version. For example,
+#         makeGcc gmp-system
 #
 #------------------------------------------------------------------------------
 # get default GCC, mpfr, gmp and mpc versions
@@ -62,6 +66,7 @@ usage() {
 usage: $Script [OPTION] [gcc-VERSION] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION]
 options:
   -no-multilib      for 64-bit systems without 32-bit support
+  -system           use system versions for gmp/mpfr/mpc
   -help
 
 * build combinations of gmp, mpfr, mpc and gcc
@@ -88,15 +93,21 @@ do
         GCC_BUILD_OPTIONS="--disable-multilib"
         shift
         ;;
-    gmp-[4-9]*)
+    -sys*)
+        gmpPACKAGE="gmp-system"
+        mpfrPACKAGE="mpfr-system"
+        mpcPACKAGE="mpc-system"
+        shift
+        ;;
+    gmp-[4-9]* | gmp-system)
         gmpPACKAGE="${1%%/}"
         shift
         ;;
-    mpfr-[2-9]*)
+    mpfr-[2-9]* | mpfr-system)
         mpfrPACKAGE="${1%%/}"
         shift
         ;;
-    mpc-[0-9]*)
+    mpc-[0-9]* | mpc-system)
         mpcPACKAGE="${1%%/}"
         shift
         ;;
@@ -116,6 +127,15 @@ then
     exit 1
 fi
 
+cat<<SUMMARY
+GCC configuration
+------------------
+    GCC     = $gccPACKAGE
+    GMP     = $gmpPACKAGE
+    MPFR    = $mpfrPACKAGE
+    MPC     = $mpcPACKAGE
+------------------
+SUMMARY
 
 # Set 32 or 64 bit ABI
 case "$WM_ARCH_OPTION" in
@@ -138,6 +158,7 @@ GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
 MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
 MPC_ARCH_PATH=$installBASE/$mpcPACKAGE
 
+
 # ================
 # Build GMP
 # ================
@@ -145,6 +166,9 @@ echo "---------------"
 if [ -d $GMP_ARCH_PATH ]
 then
     echo "Already built: $gmpPACKAGE"
+elif _foamIsSystem $GMP_ARCH_PATH
+then
+    echo "Using gmp-system"
 else
     echo "Starting build: $gmpPACKAGE"
     echo
@@ -186,6 +210,9 @@ echo "---------------"
 if [ -d $MPFR_ARCH_PATH ]
 then
     echo "Already built: $mpfrPACKAGE"
+elif _foamIsSystem $MPFR_ARCH_PATH
+then
+    echo "Using mpfr-system"
 else
     echo "Starting build: $mpfrPACKAGE"
     echo
@@ -228,6 +255,9 @@ echo "---------------"
 if [ -d $MPC_ARCH_PATH ]
 then
     echo "Already built: $mpcPACKAGE"
+elif _foamIsSystem $MPC_ARCH_PATH
+then
+    echo "Using mpc-system"
 else
     echo "Starting build: $mpcPACKAGE"
     echo
@@ -290,6 +320,10 @@ else
     mkdir -p $buildDIR
     cd $buildDIR
 
+    _foamIsSystem "$GMP_ARCH_PATH"  && GMP_ARCH_PATH=/usr  # revert to system
+    _foamIsSystem "$MPFR_ARCH_PATH" && MPFR_ARCH_PATH=/usr # revert to system
+    _foamIsSystem "$MPC_ARCH_PATH"  && MPC_ARCH_PATH=/usr  # revert to system
+
     set -x
     $sourceDIR/configure \
         --prefix=$GCC_ARCH_PATH \
-- 
GitLab


From 0b1c761075f50ff273c0470b241f62f341de489c Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 16 Jun 2016 19:50:38 +0200
Subject: [PATCH 11/40] STYLE: provide 'die' as alternative to 'usage'

- make option parsing more consistent
---
 etc/relocateQt                |  5 ++-
 etc/tools/ThirdPartyFunctions | 11 +++++++
 makeCCMIO                     | 12 +++-----
 makeCGAL                      | 14 ++-------
 makeCmake                     |  5 ++-
 makeGcc                       | 17 +++--------
 makeGperftools                |  4 +--
 makeLLVM                      | 10 ++----
 makeParaView                  | 57 ++++++++++++-----------------------
 makeParaView3                 | 51 +++++++++++--------------------
 makeQt                        |  5 ++-
 11 files changed, 69 insertions(+), 122 deletions(-)

diff --git a/etc/relocateQt b/etc/relocateQt
index ac6f186..1542115 100755
--- a/etc/relocateQt
+++ b/etc/relocateQt
@@ -69,17 +69,16 @@ do
         ;;
     -f | -force)
         forceOpt=true
-        shift
         ;;
     [1-9]* | qt-[1-9]*)
         qtVERSION="${1%%/}";
         qtVERSION="${qtVERSION#qt-}"
-        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
 #------------------------------------------------------------------------------
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 2e27969..9cf85c1 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -61,6 +61,17 @@ then
 fi
 
 
+# Report error and exit
+die()
+{
+    exec 1>&2
+    echo
+    echo "Error: see '${0##*/} -help' for usage"
+    while [ "$#" -ge 1 ]; do echo "    $1"; shift; done
+    echo
+    exit 1
+}
+
 # Test if it matches "*-none"
 _foamIsNone()
 {
diff --git a/makeCCMIO b/makeCCMIO
index 8990572..022cb68 100755
--- a/makeCCMIO
+++ b/makeCCMIO
@@ -90,23 +90,19 @@ do
         ;;
     lib|libso)
         targetType="$1"
-        shift
         ;;
     libccmio-[1-9]*)
         ccmioPACKAGE="${1%%/}"
-        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
-# warn if unavailable
-if [ ! -d ${ccmioPACKAGE} ]
-then
-    usage "missing source directory '$ccmioPACKAGE'"
-fi
+# assert: directory must be available
+[ -d "${ccmioPACKAGE}" ] || die "missing source directory '$ccmioPACKAGE'"
 
 
 #------------------------------------------------------------------------------
diff --git a/makeCGAL b/makeCGAL
index 32aa5f8..4877165 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -106,40 +106,32 @@ do
         ;;
     -gcc)
         export CXX=g++   # use g++
-        shift
         ;;
     -sys*)
         gmpPACKAGE="gmp-system"
         mpfrPACKAGE="mpfr-system"
         boostPACKAGE="boost-system"
-        shift
         ;;
     gmp-[4-9]* | gmp-system)
         gmpPACKAGE="${1%%/}"
-        shift
         ;;
     mpfr-[2-9]* | mpfr-system)
         mpfrPACKAGE="${1%%/}"
-        shift
         ;;
     CGAL-[0-9]*)
         cgalPACKAGE="${1%%/}"
-        shift
         ;;
     boost-[0-9]* | boost_[0-9]* | boost-system )
         boostPACKAGE="${1%%/}"
-        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
-if [ -z "$cgalPACKAGE" ]
-then
-    usage "The cgal-VERSION was not specified"
-fi
+[ -n "$cgalPACKAGE" ] || die "The cgal-VERSION was not specified"
 
 #------------------------------------------------------------------------------
 #
diff --git a/makeCmake b/makeCmake
index b3ca91d..a32cd1e 100755
--- a/makeCmake
+++ b/makeCmake
@@ -74,16 +74,15 @@ do
     -gcc)
         export CC=gcc   # use gcc
         export CXX=g++  # use g++
-        shift
         ;;
     cmake-[1-9]*)
         cmakePACKAGE="${1%%/}"
-        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
 
diff --git a/makeGcc b/makeGcc
index 70721c4..2552b2d 100755
--- a/makeGcc
+++ b/makeGcc
@@ -91,41 +91,32 @@ do
         ;;
     -no-multi*)
         GCC_BUILD_OPTIONS="--disable-multilib"
-        shift
         ;;
     -sys*)
         gmpPACKAGE="gmp-system"
         mpfrPACKAGE="mpfr-system"
         mpcPACKAGE="mpc-system"
-        shift
         ;;
     gmp-[4-9]* | gmp-system)
         gmpPACKAGE="${1%%/}"
-        shift
         ;;
     mpfr-[2-9]* | mpfr-system)
         mpfrPACKAGE="${1%%/}"
-        shift
         ;;
     mpc-[0-9]* | mpc-system)
         mpcPACKAGE="${1%%/}"
-        shift
         ;;
     gcc-[4-9]*)
         gccPACKAGE="${1%%/}"
-        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
-if [ -z "$gccPACKAGE" ]
-then
-    usage "Please specify gcc-VERSION"
-    exit 1
-fi
+[ -n "$gccPACKAGE" ] || die "The gcc-VERSION was not specified"
 
 cat<<SUMMARY
 GCC configuration
@@ -143,7 +134,7 @@ case "$WM_ARCH_OPTION" in
     ABI=$WM_ARCH_OPTION
     ;;
 *)
-    usage "Please set WM_ARCH_OPTION to either 32 or 64'$*'"
+    die "The WM_ARCH_OPTION ($WM_ARCH_OPTION) must be 32 or 64"
     ;;
 esac
 
diff --git a/makeGperftools b/makeGperftools
index 613c332..31bf036 100755
--- a/makeGperftools
+++ b/makeGperftools
@@ -69,12 +69,12 @@ do
         ;;
     gperftools-[0-9]* | gperftools-svn*)
         gperftoolsPACKAGE="${1%%/}"
-        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
 #------------------------------------------------------------------------------
diff --git a/makeLLVM b/makeLLVM
index 81f8a18..f61f420 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -86,19 +86,15 @@ do
         ;;
     llvm-[0-9]* | llvm-svn*)
         llvmPACKAGE="${1%%/}"
-        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
-if [ -z "$llvmPACKAGE" ]
-then
-    die "The llvm-VERSION was not specified"
-    exit 1
-fi
+[ -n "$llvmPACKAGE" ] || die "The llvm-VERSION was not specified"
 
 #------------------------------------------------------------------------------
 # build/install without compiler name
diff --git a/makeParaView b/makeParaView
index 454eaa0..072a300 100755
--- a/makeParaView
+++ b/makeParaView
@@ -78,6 +78,7 @@ CMAKE_PATH=""
 Script=${0##*/}
 
 usage() {
+    exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
@@ -159,138 +160,118 @@ do
         ;;
     [A-Z]*=*)            # cmake variables
         addCMakeVariable "$1"
-        shift
         ;;
     -gcc)
         export CXX=g++   # use g++
-        shift
         ;;
     -patch)              # stage 0: patch sources
         runPATCH=true
         unset runDEFAULT
-        shift
         ;;
     -no-patch)
         runPATCH=false
-        shift
         ;;
     -config)             # stage 1: config only
         runCONFIG=true
         unset runDEFAULT
-        shift
         ;;
     -no-config)
         runCONFIG=false
-        shift
         ;;
     -make)               # stage 2: make only
         runMAKE=true
         unset runDEFAULT
-        shift
         ;;
     -no-make)
         runMAKE=false
-        shift
         ;;
     -install)            # stage 3: install only
         runINSTALL=true
         unset runDEFAULT
-        shift
         ;;
     -no-install)
         runINSTALL=false
-        shift
         ;;
     -rebuild)            # shortcut for rebuilding
         runMAKE=true
         runINSTALL=true
         unset runDEFAULT
-        shift
         ;;
     -mesa)
         withMESA=true
-        shift
         ;;
     -no-mesa)
         withMESA=false
-        shift
         ;;
     -mesa-include)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         MESA_INCLUDE="$2"
-        shift 2
+        shift
         ;;
     -mesa-lib)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         MESA_LIBRARY="$2"
-        shift 2
+        shift
         ;;
     -mpi)
         withMPI=true
-        shift
         ;;
     -no-mpi)
         withMPI=false
-        shift
         ;;
     -python)
         withPYTHON=true
-        shift
         ;;
     -no-python)
         withPYTHON=false
-        shift
         ;;
     -python-lib)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         PYTHON_LIBRARY="$2"
-        shift 2
+        shift
         ;;
     -cmake)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         CMAKE_PATH=$2
-        shift 2
+        shift
         ;;
     -qmake)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         QMAKE_PATH=$2
-        shift 2
+        shift
         ;;
     -qt)
         withQT=true
-        shift
         ;;
     -no-qt)
         withQT=false
-        shift
         ;;
     -qt-[1-9]*)
         QMAKE_PATH="$installBASE/${1##-}"
-        shift
         ;;
     -verbose)
         withVERBOSE=true
-        shift
         ;;
     -version)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         setVersion "$2"
-        shift 2
+        shift
         ;;
     -major)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         export ParaView_MAJOR="$2"
-        shift 2
+        shift
         ;;
     -buildType)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         buildType="$2"
-        shift 2
+        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
 
diff --git a/makeParaView3 b/makeParaView3
index 4d6ef61..76131d2 100755
--- a/makeParaView3
+++ b/makeParaView3
@@ -78,6 +78,7 @@ CMAKE_PATH=""
 Script=${0##*/}
 
 usage() {
+    exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
@@ -156,124 +157,106 @@ do
         ;;
     [A-Z]*=*)            # cmake variables
         addCMakeVariable "$1"
-        shift
         ;;
     -gcc)
         export CXX=g++   # use g++
-        shift
         ;;
     -config)             # stage 1: config only
         runCONFIG=true
         unset runDEFAULT
-        shift
         ;;
     -no-config)
         runCONFIG=false
-        shift
         ;;
     -make)               # stage 2: make only
         runMAKE=true
         unset runDEFAULT
-        shift
         ;;
     -no-make)
         runMAKE=false
-        shift
         ;;
     -install)            # stage 3: install only
         runINSTALL=true
         unset runDEFAULT
-        shift
         ;;
     -no-install)
         runINSTALL=false
-        shift
         ;;
     -rebuild)            # shortcut for rebuilding
         runMAKE=true
         runINSTALL=true
         unset runDEFAULT
-        shift
         ;;
     -mesa)
         withMESA=true
-        shift
         ;;
     -no-mesa)
         withMESA=false
-        shift
         ;;
     -mesa-include)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         MESA_INCLUDE="$2"
-        shift 2
+        shift
         ;;
     -mesa-lib)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         MESA_LIBRARY="$2"
-        shift 2
+        shift
         ;;
     -mpi)
         withMPI=true
-        shift
         ;;
     -no-mpi)
         withMPI=false
-        shift
         ;;
     -python)
         withPYTHON=true
-        shift
         ;;
     -no-python)
         withPYTHON=false
-        shift
         ;;
     -python-lib)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         PYTHON_LIBRARY="$2"
-        shift 2
+        shift
         ;;
     -cmake)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         CMAKE_PATH=$2
-        shift 2
+        shift
         ;;
     -qmake)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         QMAKE_PATH=$2
-        shift 2
+        shift
         ;;
     -qt)
         withQT=true
-        shift
         ;;
     -no-qt)
         withQT=false
-        shift
         ;;
     -qt-[1-9]*)
         QMAKE_PATH="$installBASE/${1##-}"
-        shift
         ;;
     -verbose)
         withVERBOSE=true
-        shift
         ;;
     -version)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         setVersion "$2"
-        shift 2
+        shift
         ;;
     -major)
-        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         export ParaView_MAJOR="$2"
-        shift 2
+        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
 
diff --git a/makeQt b/makeQt
index c2d94ed..97c26c7 100755
--- a/makeQt
+++ b/makeQt
@@ -73,17 +73,16 @@ do
         ;;
     -gcc)
         export CXX=g++   # use g++
-        shift
         ;;
     [1-9]* | qt-[1-9]*)
         qtVERSION="${1%%/}";
         qtVERSION="${qtVERSION#qt-}"
-        shift
         ;;
     *)
-        usage "unknown option/argument: '$*'"
+        die "unknown option/argument: '$1'"
         ;;
     esac
+    shift
 done
 
 #------------------------------------------------------------------------------
-- 
GitLab


From fde551c072cb856d16265cca3c39eca3b6634d92 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 17 Jun 2016 12:02:25 +0200
Subject: [PATCH 12/40] ENH: avoid repeated CGAL builds

- now check for existing third-party build and skip if all build
  components are unchanged.

- skip build entirely for boost-none or CGAL-none

This is primarily useful when makeCGAL is called directly and not from
Allwmake.

STYLE: use WM_COMPILER_LIB_ARCH for boost system lib
---
 makeCGAL | 109 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 93 insertions(+), 16 deletions(-)

diff --git a/makeCGAL b/makeCGAL
index 4877165..4e58844 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -133,9 +133,24 @@ done
 
 [ -n "$cgalPACKAGE" ] || die "The cgal-VERSION was not specified"
 
+# nothing to build
+if _foamIsNone "$boostPACKAGE"
+then
+    echo "Using boost-none (skip ThirdParty build of BOOST/CGAL)"
+    exit 0
+fi
+if _foamIsNone "$cgalPACKAGE"
+then
+    echo "Using cgal-none (skip ThirdParty build of CGAL)"
+    exit 0
+fi
+
 #------------------------------------------------------------------------------
 #
 # Build Boost
+# For 64-bit
+# - Third-Party builds into 'lib'
+# - system is normally built into 'lib64'
 #
 #   BOOST_SOURCE_DIR : location of the original sources
 
@@ -148,18 +163,10 @@ then
     boostLib="$BOOST_ARCH_PATH/lib"
 elif _foamIsSystem $BOOST_ARCH_PATH
 then
-    echo "Using boost-system"
+    echo "Using boost-system (skip ThirdParty build of BOOST)"
 
     boostInc="/usr/include"
-
-    # For completeness:
-    # 64-bit needs lib64, but 32-bit needs lib (not lib32)
-    if [ "$WM_ARCH_OPTION" = 64 ]
-    then
-        boostLib="/usr/lib$WM_ARCH_OPTION"
-    else
-        boostLib="/usr/lib"
-    fi
+    boostLib="/usr/lib$WM_COMPILER_LIB_ARCH"
 else
     echo "Starting build: boost"
     echo
@@ -184,10 +191,10 @@ else
     }
 fi
 
-# nothing to build
+# nothing left to build
 if _foamIsSystem "$cgalPACKAGE"
 then
-    echo "Using CGAL-system"
+    echo "Using cgal-system (skip ThirdParty build of CGAL)"
     exit 0
 fi
 
@@ -202,10 +209,13 @@ fi
 # Retrieve boost version:
 if [ -f "$boostInc/boost/version.hpp" ]
 then
-    BOOST_VERSION_NO=`sed -ne 's/^#define *BOOST_VERSION *\([0-9][0-9]*\).*$/\1/p' $boostInc/boost/version.hpp`
+    BOOST_VERSION=$(sed -ne 's/^ *# *define *BOOST_VERSION *\([0-9][0-9]*\).*$/\1/p' $boostInc/boost/version.hpp)
 else
-    echo "Boost does not appear to be installed"
+    echo
+    echo "ERROR: boost does not appear to be installed, but is required to build CGAL"
+    echo "    Change your settings, or disable entirely (with cgal-system, cgal-none, boost-none)"
     echo "stopping build"
+    echo
     exit 1
 fi
 
@@ -224,6 +234,9 @@ SUMMARY
 #------------------------------------------------------------------------------
 #
 # Build CGAL
+# For 64-bit
+# - Third-Party builds into 'lib'
+# - system is normally built into 'lib64'
 #
 #   CGAL_SOURCE_DIR : location of the original sources
 #   CGAL_BINARY_DIR : location of the build
@@ -241,6 +254,67 @@ installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH
 GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
 MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
 
+#
+# build information recorded for later use
+#
+buildInfoFile=$CGAL_ARCH_PATH/share/openfoam-build
+
+recordCGALinfo()
+{
+    CGAL_VERSION=$(sed -ne 's/^ *# *define *CGAL_VERSION_NR *\([0-9][0-9]*\).*$/\1/p' $CGAL_ARCH_PATH/include/CGAL/version.h 2>/dev/null)
+
+    cat<<BUILD_INFO > $buildInfoFile
+CGAL=${CGAL_ARCH_PATH##*/}
+BOOST=${BOOST_ARCH_PATH##*/}
+GMP=${GMP_ARCH_PATH##*/}
+MPFR=${MPFR_ARCH_PATH##*/}
+CGAL_VERSION=$CGAL_VERSION
+BOOST_VERSION=$BOOST_VERSION
+BUILD_INFO
+}
+
+
+# compare expected vs what is extracted as KEY=... in text
+# $1 = key
+# $2 = expected
+# $3 = text to extract from
+infoValueEq()
+{
+    local val=$(echo "${3:-unset}" | sed -ne "s/^$1=//p")
+    if [ "$2" = "$val" ]
+    then
+       :
+    else
+        echo "    $1=$2, previous build had $1='${val:-not-found}'"
+        return 1
+    fi
+}
+
+# needs build
+cgalIsCurrent()
+{
+    local info=$(cat $buildInfoFile 2>/dev/null)
+    [ -n "$info" ] || return 1
+
+    echo "checking information from existing build ..."
+    echo "  ${CGAL_ARCH_PATH}"
+
+    infoValueEq CGAL  "${CGAL_ARCH_PATH##*/}"     "$info" || return 1
+    infoValueEq BOOST "${BOOST_ARCH_PATH##*/}"    "$info" || return 1
+    infoValueEq GMP   "${GMP_ARCH_PATH##*/}"      "$info" || return 1
+    infoValueEq MPFR  "${MPFR_ARCH_PATH##*/}"     "$info" || return 1
+    infoValueEq BOOST_VERSION "${BOOST_VERSION}"  "$info" || return 1
+
+    return 0
+}
+
+if cgalIsCurrent
+then
+    echo "    ${CGAL_ARCH_PATH##*/} build appears to be up-to-date - skipping"
+    echo
+    exit 0
+fi
+
 (
     # Remove any existing build folder and recreate
     if [ -d $CGAL_BINARY_DIR ]
@@ -255,7 +329,7 @@ MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
 
     unset configBoost configGmp configMpfr
     echo "----"
-    echo "Configuring $cgalPACKAGE with boost $BOOST_VERSION_NO"
+    echo "Configuring $cgalPACKAGE with boost $BOOST_VERSION"
     echo "    Source         : $CGAL_SOURCE_DIR"
     echo "    Build          : $CGAL_BINARY_DIR"
     echo "    Target         : $CGAL_DIR"
@@ -271,7 +345,7 @@ MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
  -DBoost_THREAD_LIBRARY_RELEASE=$boostLib/libboost_thread.so
  -DBoost_SYSTEM_LIBRARY=$boostLib/libboost_system.so
  -DBoost_SYSTEM_LIBRARY_RELEASE=$boostLib/libboost_system.so
- -DBoost_VERSION=$BOOST_VERSION_NO
+ -DBoost_VERSION=$BOOST_VERSION
 CMAKE_OPTIONS
 )
     else
@@ -336,6 +410,9 @@ CMAKE_OPTIONS
         fi
     done
 
+    # record our build-status
+    recordCGALinfo
+
     echo "Done CGAL"
 )
 
-- 
GitLab


From f09aa2ebdc2984217a725864abe2ff14aca0f6ac Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 17 Jun 2016 16:59:53 +0200
Subject: [PATCH 13/40] ENH: SOURCE_CGAL_VERSIONS_ONLY workaround replaced in
 OpenFOAM

Unset the _foamAddLib function prior to sourcing config.sh/CGAL

DOC: restriction about mixing ThirdParty and system gmp/mpfr
     does not apply anymore.
---
 makeCGAL | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/makeCGAL b/makeCGAL
index 4e58844..8203b8c 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -34,14 +34,13 @@
 #     simply specify a 'system' version. For example,
 #         makeCGAL boost-system gmp-system
 #
-#     Mixing system and ThirdParty for gmp/mpfr is not supported.
-#
 #------------------------------------------------------------------------------
 
 # Get CGAL, boost and gmp/mpfr versions
 . $WM_PROJECT_DIR/etc/config.sh/functions
-_foamEval SOURCE_CGAL_VERSIONS_ONLY=yes \
-          $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
+unset _foamAddPath _foamAddLib _foamAddMan # get settings only
+
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
 
 boostPACKAGE=${boost_version:-boost-system}
@@ -83,8 +82,6 @@ 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
 
-Note: mixing system and ThirdParty for gmp/mpfr is not supported.
-
 USAGE
     exit 1
 }
-- 
GitLab


From 3da9455ca9d8999fb22966210dc11f578f016fa1 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 17 Jun 2016 19:00:50 +0200
Subject: [PATCH 14/40] ENH: makeGcc now uses --disable-multilib by default

Rationale: 32-bit support is not normally needed for OpenFOAM and
disabling reduces build issues.

Can use the '-multilib' option to enable 32-bit support if required.
---
 makeGcc | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/makeGcc b/makeGcc
index 2552b2d..5624296 100755
--- a/makeGcc
+++ b/makeGcc
@@ -28,14 +28,21 @@
 # Description
 #     Build script gcc and gmp, mpfr, mpc.
 #
-#     Normally builds against ThirdParty gmp/mpfr when possible.
-#     To override this behaviour (and use the system gmp/mpfr/mpc),
-#     simply specify a 'system' version. For example,
+#     To force building against the system gmp/mpfr/mpc libraries,
+#     use a corresponding '*-system' version. For example,
+#
 #         makeGcc gmp-system
 #
+#     or use the '-system' options to use system libraries everywhere.
+#
+#     The WM_COMPILER value can also be used specify a known gcc version.
+#     For example (also compiling against system gmp/mpfr/mpc),
+#
+#         WM_COMPILER=Gcc51 ./makeGcc -system
+#
 #------------------------------------------------------------------------------
 # get default GCC, mpfr, gmp and mpc versions
-WM_COMPILER_TYPE="ThirdParty"     # ensure we get the correct compiler settings
+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
@@ -65,7 +72,8 @@ usage() {
 
 usage: $Script [OPTION] [gcc-VERSION] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION]
 options:
-  -no-multilib      for 64-bit systems without 32-bit support
+  -multilib         for 64-bit systems with 32-bit support required
+  -no-multilib      for 64-bit systems without 32-bit support (DEFAULT)
   -system           use system versions for gmp/mpfr/mpc
   -help
 
@@ -80,7 +88,8 @@ USAGE
 }
 #------------------------------------------------------------------------------
 
-unset GCC_BUILD_OPTIONS
+# build 32-bit libraries on 64-bit systems (normally not needed)
+optMultilib=disable
 
 # Parse options
 while [ "$#" -gt 0 ]
@@ -89,8 +98,11 @@ do
     -h | -help)
         usage
         ;;
+    -multi*)
+        optMultilib=enable
+        ;;
     -no-multi*)
-        GCC_BUILD_OPTIONS="--disable-multilib"
+        optMultilib=disable
         ;;
     -sys*)
         gmpPACKAGE="gmp-system"
@@ -315,6 +327,10 @@ else
     _foamIsSystem "$MPFR_ARCH_PATH" && MPFR_ARCH_PATH=/usr # revert to system
     _foamIsSystem "$MPC_ARCH_PATH"  && MPC_ARCH_PATH=/usr  # revert to system
 
+    unset configOpt
+    # with/without multi-lib (32-bit support on 64-bit systems)
+    [ -n "$optMultilib" ] && configOpt="--${optMultilib}-multilib"
+
     set -x
     $sourceDIR/configure \
         --prefix=$GCC_ARCH_PATH \
@@ -329,7 +345,7 @@ else
         --enable-__cxa_atexit \
         --enable-libstdcxx-allocator=new \
         --with-system-zlib \
-        $GCC_BUILD_OPTIONS \
+        $configOpt \
         MAKEINFO=missing \
     && make -j $WM_NCOMPPROCS \
     && make install \
-- 
GitLab


From cf251ea18208b1945decb4dfc408967cb55bbee2 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Sun, 19 Jun 2016 14:00:54 +0200
Subject: [PATCH 15/40] ENH: support new rendering backend for paraview >= 5.0

ENH: patch paraview 4.4.0 directly before building

- this avoids more manual steps for the user
---
 README.org                    | 19 +++++++------
 etc/patches/paraview-4.4.0    | 50 +++++++++++++++++++++++++++++++++++
 etc/patches/paraview-5.0.1    |  4 +--
 etc/tools/ParaView3Functions  |  9 ++++---
 etc/tools/ParaViewFunctions   | 21 ++++++++++++---
 etc/tools/ThirdPartyFunctions |  2 +-
 makeParaView                  | 20 +++++++++++++-
 makeParaView3                 |  6 ++++-
 8 files changed, 108 insertions(+), 23 deletions(-)
 create mode 100644 etc/patches/paraview-4.4.0

diff --git a/README.org b/README.org
index 9a5f9f7..aaa005d 100644
--- a/README.org
+++ b/README.org
@@ -1,11 +1,12 @@
 #                            -*- mode: org; -*-
 #
 #+TITLE:                 OpenFOAM Third-Party packages
-#+AUTHOR:                  The OpenFOAM Foundation
-#+DATE:                           2016-06-14
+#+AUTHOR:            The OpenFOAM Foundation / OpenCFD Ltd.
+#+DATE:                           2016-06-19
 #+LINK:                     http://www.openfoam.org
 #+OPTIONS: author:nil ^:{}
 # Copyright (c) 2014-2016 OpenFOAM Foundation.
+# Copyright (c) 2016 OpenCFD Ltd.
 
 * Description
   Scripts for building third-party packages.
@@ -62,15 +63,12 @@
     does not exist and cannot be installed causing the build and installation to
     fail.
 
-    Additionally for ParaView-4.4.0 there is a bug in the STL reader which can
-    be patched by running the following command from within the ThirdParty-???
-    directory:
-    + wget https://raw.githubusercontent.com/Kitware/VTK/40937e934308e5009e80769dc0c451ee4f157749/IO/Geometry/vtkSTLReader.cxx -O ParaView-4.4.0/VTK/IO/Geometry/vtkSTLReader.cxx
-    See also http://www.openfoam.org/mantisbt/view.php?id=1887
+    Additionally for ParaView-4.4.0 there is a bug in the STL reader.
+    (see http://www.openfoam.org/mantisbt/view.php?id=1887).
 
-    For ParaView-5.0.1, the necessary patches are supplied with the
-    ThirdParty repository (see the etc/patches directory) and are applied
-    when building paraview.
+    For ParaView-4.4.0 and ParaView-5.0.1,
+    the necessary patches are supplied with the ThirdParty repository
+    (see the etc/patches directory) and are applied when building paraview.
 
 *** Building ParaView-5.0.1 with gcc-6.1.0
 ***** Add support for gcc-6.?.?
@@ -79,6 +77,7 @@
       + ParaView-5.0.1/VTK/CMake/GenerateExportHeader.cmake
       specifically limit the gcc versions supported.
       To add support gcc-6.?.? replace the '[345]' with '[3456]'.
+
       This patch is also supplied with the ThirdParty repository and
       applied when building paraview.
 
diff --git a/etc/patches/paraview-4.4.0 b/etc/patches/paraview-4.4.0
new file mode 100644
index 0000000..2c34de3
--- /dev/null
+++ b/etc/patches/paraview-4.4.0
@@ -0,0 +1,50 @@
+--- ParaView-4.4.0/VTK/IO/Geometry/vtkSTLReader.cxx.orig	2015-09-11 19:59:24.000000000 +0200
++++ ParaView-4.4.0/VTK/IO/Geometry/vtkSTLReader.cxx	2016-06-19 12:59:50.769770143 +0200
+@@ -448,7 +448,7 @@
+           done = done || (fscanf(fp,"%s", line)==EOF);
+           }
+         }
+-      if (!done)
++      else if (!done)
+         {
+         done = (fgets(line, 255, fp) == 0);
+         lineCount++;
+--- ParaView-5.0.1/VTK/CMake/vtkCompilerExtras.cmake.orig	2016-03-28 17:07:10.000000000 +0200
++++ ParaView-5.0.1/VTK/CMake/vtkCompilerExtras.cmake	2016-06-11 15:10:14.820958942 +0200
+@@ -32,7 +32,7 @@
+     OUTPUT_VARIABLE _gcc_version_info
+     ERROR_VARIABLE _gcc_version_info)
+
+-  string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]*"
++  string (REGEX MATCH "[3-6]\\.[0-9]\\.[0-9]*"
+     _gcc_version "${_gcc_version_info}")
+   if(NOT _gcc_version)
+     string (REGEX REPLACE ".*\\(GCC\\).*([34]\\.[0-9]).*" "\\1.0"
+--- ParaView-5.0.1/VTK/CMake/GenerateExportHeader.cmake.orig	2016-03-28 17:07:10.000000000 +0200
++++ ParaView-5.0.1/VTK/CMake/GenerateExportHeader.cmake	2016-06-11 15:12:16.344357746 +0200
+@@ -166,7 +166,7 @@
+     execute_process(COMMAND ${CMAKE_C_COMPILER} ARGS --version
+       OUTPUT_VARIABLE _gcc_version_info
+       ERROR_VARIABLE _gcc_version_info)
+-    string(REGEX MATCH "[345]\\.[0-9]\\.[0-9]*"
++    string(REGEX MATCH "[3-6]\\.[0-9]\\.[0-9]*"
+       _gcc_version "${_gcc_version_info}")
+     # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the
+     # patch level, handle this here:
+--- ParaView-5.0.1/Qt/Components/CMakeLists.txt.orig	2016-06-13 09:27:27.827849525 +0200
++++ ParaView-5.0.1/Qt/Components/CMakeLists.txt	2016-06-13 09:29:28.599318445 +0200
+@@ -656,10 +656,10 @@
+ #the pqSGExportStateWizard has subclasses that directly access
+ #the UI file, and currently we don't have a clean way to break this hard
+ #dependency, so for no we install this ui file.
+-if(PARAVIEW_INSTALL_DEVELOPMENT_FILES)
+-  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"
+-          DESTINATION "${VTK_INSTALL_INCLUDE_DIR}")
+-endif()
++#OPENFOAM patch#if(PARAVIEW_INSTALL_DEVELOPMENT_FILES)
++#OPENFOAM patch#  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"
++#OPENFOAM patch#          DESTINATION "${VTK_INSTALL_INCLUDE_DIR}")
++#OPENFOAM patch#endif()
+
+ #IF (NOT PV_INSTALL_NO_DEVELOPMENT)
+ #  # Headers
diff --git a/etc/patches/paraview-5.0.1 b/etc/patches/paraview-5.0.1
index 0c7156c..24aceba 100644
--- a/etc/patches/paraview-5.0.1
+++ b/etc/patches/paraview-5.0.1
@@ -3,7 +3,7 @@
 @@ -32,7 +32,7 @@
      OUTPUT_VARIABLE _gcc_version_info
      ERROR_VARIABLE _gcc_version_info)
- 
+
 -  string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]*"
 +  string (REGEX MATCH "[3-6]\\.[0-9]\\.[0-9]*"
      _gcc_version "${_gcc_version_info}")
@@ -34,6 +34,6 @@
 +#OPENFOAM patch#  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"
 +#OPENFOAM patch#          DESTINATION "${VTK_INSTALL_INCLUDE_DIR}")
 +#OPENFOAM patch#endif()
- 
+
  #IF (NOT PV_INSTALL_NO_DEVELOPMENT)
  #  # Headers
diff --git a/etc/tools/ParaView3Functions b/etc/tools/ParaView3Functions
index c0703bc..803ed9f 100644
--- a/etc/tools/ParaView3Functions
+++ b/etc/tools/ParaView3Functions
@@ -178,9 +178,9 @@ addPythonSupport()
             PYTHON_LIBRARY=$(ldd $pythonBin | \
                 sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p')
 
-           [ -e "$PYTHON_LIBRARY" ] || {
-               echo "*** Error: Unable to determine path to python library."
-           }
+            [ -e "$PYTHON_LIBRARY" ] || {
+                echo "*** Error: Unable to determine path to python library."
+            }
         fi
 
         [ -e "$PYTHON_LIBRARY" ] || {
@@ -230,7 +230,7 @@ addMesaSupport()
 {
     if [ "${withMESA:=false}" != true ]
     then
-       return
+        return
     fi
 
     if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ]
@@ -394,6 +394,7 @@ configParaView()
     echo "    MPI    support : ${withMPI:-false}"
     echo "    Python support : ${withPYTHON:-false}"
     echo "    MESA   support : ${withMESA:-false}"
+    echo "    GL2  rendering : false"
     echo "    Qt dev support : ${withQT:-false}"
     echo "    Source         : $ParaView_SOURCE_DIR"
     echo "    Build          : $ParaView_BINARY_DIR"
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 67d7ebc..d2c5cfd 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -178,9 +178,9 @@ addPythonSupport()
             PYTHON_LIBRARY=$(ldd $pythonBin | \
                 sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p')
 
-           [ -e "$PYTHON_LIBRARY" ] || {
-               echo "*** Error: Unable to determine path to python library."
-           }
+            [ -e "$PYTHON_LIBRARY" ] || {
+                echo "*** Error: Unable to determine path to python library."
+            }
         fi
 
         [ -e "$PYTHON_LIBRARY" ] || {
@@ -230,7 +230,7 @@ addMesaSupport()
 {
     if [ "${withMESA:=false}" != true ]
     then
-       return
+        return
     fi
 
     if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ]
@@ -252,6 +252,18 @@ addMesaSupport()
 }
 
 
+#
+# new rendering backend
+#
+addGL2Support()
+{
+    if [ "${withGL2:=false}" = true ]
+    then
+        addCMakeVariable  "VTK_RENDERING_BACKEND=OpenGL2"
+    fi
+}
+
+
 addQtSupport()
 {
     QtVersion=none
@@ -405,6 +417,7 @@ configParaView()
     echo "    MPI    support : ${withMPI:-false}"
     echo "    Python support : ${withPYTHON:-false}"
     echo "    MESA   support : ${withMESA:-false}"
+    echo "    GL2  rendering : ${withGL2:-false}"
     echo "    Qt dev support : ${withQT:-false}"
     echo "    Source         : $ParaView_SOURCE_DIR"
     echo "    Build          : $ParaView_BINARY_DIR"
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 9cf85c1..32dff52 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -181,7 +181,7 @@ applyPatch()
         else
             echo "apply patch for $pkg"
             touch "$sentinel"
-            patch -p1 < $patch
+            patch -p1 < $patch 2>&1 | tee $sentinel
         fi
     )
     else
diff --git a/makeParaView b/makeParaView
index 072a300..326baf2 100755
--- a/makeParaView
+++ b/makeParaView
@@ -71,6 +71,12 @@ QMAKE_PATH=""
 # Set the path to cmake
 CMAKE_PATH=""
 
+# new rendering backend (starting with paraview 5.0)
+withGL2=true
+if [ "${ParaView_VERSION%%.*}" = 4 ]
+then withGL2=false
+fi
+
 #
 # NO FURTHER EDITING BELOW THIS LINE
 #
@@ -85,6 +91,7 @@ usage() {
 usage: $Script [OPTION] [CMAKE-OPTION]
 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)
   -mpi              with mpi (if not already enabled)
   -python           with python (if not already enabled)
@@ -123,13 +130,17 @@ For finer control, the build stages can be selected or deselected individually:
       \$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
   ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION
 
+To change the paraview version, use the 'foamPV' command prior to '$Script'.
+For example,
+    foamPV 4.4.0 ; ./makeParaview
+
 USAGE
     exit 1
 }
 
 #------------------------------------------------------------------------------
 
-# ensure CMake gets the correct C++ compiler
+# ensure CMake gets the correct C/C++ compiler
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 [ -n "$WM_CC" ] && export CC="$WM_CC"
 
@@ -197,6 +208,12 @@ do
         runINSTALL=true
         unset runDEFAULT
         ;;
+    -gl2)
+        withGL2=true
+        ;;
+    -no-gl2)
+        withGL2=false
+        ;;
     -mesa)
         withMESA=true
         ;;
@@ -290,6 +307,7 @@ addVerbosity        # verbose makefiles
 addMpiSupport       # set MPI-specific options
 addPythonSupport    # set Python-specific options
 addMesaSupport      # set MESA-specific options
+addGL2Support       # new rendering backend
 addQtSupport        # add extra Qt support
 
 setDirs             # where things are or should be put
diff --git a/makeParaView3 b/makeParaView3
index 76131d2..294de8c 100755
--- a/makeParaView3
+++ b/makeParaView3
@@ -121,13 +121,17 @@ For finer control, the build stages can be selected or deselected individually:
       \$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
   ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION
 
+To make a different paraview version, use the 'foamPV' command prior to '$Script'.
+For example,
+    foamPV 3.14.0 ; ./makeParaview
+
 USAGE
     exit 1
 }
 
 #------------------------------------------------------------------------------
 
-# ensure CMake gets the correct C++ compiler
+# ensure CMake gets the correct C/C++ compiler
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 [ -n "$WM_CC" ] && export CC="$WM_CC"
 
-- 
GitLab


From 4cd3848a401040aae70ec0d709f565b821b9512f Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 21 Jun 2016 12:21:20 +0200
Subject: [PATCH 16/40] ENH: out-of-source build for openmpi

- update openmpi infiniband config options
---
 Allwmake | 56 +++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 35 insertions(+), 21 deletions(-)

diff --git a/Allwmake b/Allwmake
index ce56f60..4118983 100755
--- a/Allwmake
+++ b/Allwmake
@@ -61,7 +61,7 @@ echo
 
 echo ========================================
 echo Build MPI libraries if required
-echo
+echo "    $MPI_ARCH_PATH"
 case "$WM_MPLIB" in
 OPENMPI)
     if [ -r $MPI_ARCH_PATH/lib${WM_COMPILER_LIB_ARCH}/libmpi.so ]
@@ -74,24 +74,34 @@ OPENMPI)
         echo
     else
     (
-        set -x
-        cd "${MPI_ARCH_PATH##*/}" || exit 1    # change to openmpi-VERSION
+        # configuration options:
+        # Start with GridEngine support - builds without external libraries
+        configOpt="--with-sge"
 
-        [ -e Makefile ] && make distclean 2>/dev/null
-        rm -rf $MPI_ARCH_PATH
+        # 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
 
-        # start with GridEngine support,
-        # it can be built without external libraries
-        configOpt="--with-sge"
+        # end of configuration options
+        # ----------------------------
+        mpiPACKAGE="${MPI_ARCH_PATH##*/}"
+        sourceDIR=$WM_THIRD_PARTY_DIR/$mpiPACKAGE
+        buildDIR=$buildBASE/$mpiPACKAGE
 
-        # Infiniband support
-        # if [ -d /usr/local/ofed -a -d /usr/local/ofed/lib64 ]
-        # then
-        #     configOpt="$configOpt --with-openib=/usr/local/ofed"
-        #     configOpt="$configOpt --with-openib-libdir=/usr/local/ofed/lib64"
-        # fi
+        cd $sourceDIR || exit 1
+        [ -e Makefile ] && make distclean 2>/dev/null
 
-        ./configure \
+        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 \
@@ -99,11 +109,13 @@ OPENMPI)
             --enable-mpi-fortran=none \
             --disable-mpi-profile \
             $configOpt \
-            ;
-
-        make -j $WM_NCOMPPROCS && make install
-        make distclean
-    )
+        && make -j $WM_NCOMPPROCS \
+        && make install \
+        && echo "Built: $mpiPACKAGE"
+    ) || {
+        echo "Error building: $mpiPACKAGE"
+        exit 1
+    }
     fi
     ;;
 
@@ -118,12 +130,14 @@ MPICH)
         echo
     else
     (
+        # WARNING: unmaintained build code:
+        # ---------------------------------
         set -x
         cd $MPI_HOME || exit 1    # change to mpich-VERSION
 
         [ -e Makefile ] && make distclean 2>/dev/null
         rm -rf $MPI_ARCH_PATH
-        rm util/machines/machines.*
+        rm -rf util/machines/machines.*
 
         ./configure \
             --prefix=$MPI_ARCH_PATH \
-- 
GitLab


From f7ec8c304ec35db4b71dc87530c344db4758855c Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 28 Jun 2016 14:28:01 +0200
Subject: [PATCH 17/40] ENH: add makeFFTW build script

---
 README.org |   3 +-
 makeFFTW   | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 171 insertions(+), 1 deletion(-)
 create mode 100755 makeFFTW

diff --git a/README.org b/README.org
index aaa005d..c7b0ebb 100644
--- a/README.org
+++ b/README.org
@@ -2,7 +2,7 @@
 #
 #+TITLE:                 OpenFOAM Third-Party packages
 #+AUTHOR:            The OpenFOAM Foundation / OpenCFD Ltd.
-#+DATE:                           2016-06-19
+#+DATE:                           2016-06-28
 #+LINK:                     http://www.openfoam.org
 #+OPTIONS: author:nil ^:{}
 # Copyright (c) 2014-2016 OpenFOAM Foundation.
@@ -44,6 +44,7 @@
     + CGAL        https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.8/CGAL-4.8.tar.xz
     + boost       https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.bz2/download
 *** Miscellaneous
+    + FFTW        http://www.fftw.org/fftw-3.3.4.tar.gz
     + libccmio    http://portal.nersc.gov/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz
 * Notes
 *** Building ParaView-4.3.1/4.4.0/5.0.0/5.0.1
diff --git a/makeFFTW b/makeFFTW
new file mode 100755
index 0000000..f70539b
--- /dev/null
+++ b/makeFFTW
@@ -0,0 +1,169 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2016 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
+#     makeFFTW
+#
+# Description
+#     Build script for FFTW
+#
+#------------------------------------------------------------------------------
+
+# Get FFTW versions
+. $WM_PROJECT_DIR/etc/config.sh/functions
+unset _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
+#------------------------------------------------------------------------------
+Script="${0##*/}"
+
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: $Script [OPTION] [fftw-VERSION]
+options:
+  -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
+  -help
+
+* build FFTW with
+      $fftwPACKAGE
+
+USAGE
+    exit 1
+}
+#------------------------------------------------------------------------------
+
+# Parse options
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    '')
+        # discard empty arguments
+        ;;
+    -gcc)
+        export CC=gcc    # use gcc
+        export CXX=g++   # use g++
+        ;;
+    fftw-[0-9]* | fftw_[0-9]* | fftw-system )
+        fftwPACKAGE="${1%%/}"
+        ;;
+    *)
+        die "unknown option/argument: '$1'"
+        ;;
+    esac
+    shift
+done
+
+[ -n "$fftwPACKAGE" ] || die "The fftw-VERSION was not specified"
+
+# nothing to build
+if _foamIsNone "$fftwPACKAGE"
+then
+    echo "Using fftw-none (skip ThirdParty build of FFTW)"
+    exit 0
+fi
+
+if _foamIsSystem "$fftwPACKAGE"
+then
+    echo "Using fftw-system (skip ThirdParty build of FFTW)"
+    exit 0
+fi
+
+#------------------------------------------------------------------------------
+#
+# Build FFTW
+# For 64-bit
+# - FFTW itself will normally build into 'lib64',
+#   but provide --libdir on configure to be 100% certain
+# - Third-Party builds into 'lib64'
+# - system is normally built into 'lib64'
+#
+#   FFTW_SOURCE_DIR : location of the original sources
+
+FFTW_ARCH_PATH=$installBASE/$fftwPACKAGE
+FFTW_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$fftwPACKAGE
+
+if [ -r "$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libfftw3.so" ]
+then
+    echo "Already has FFTW shared library"
+else
+    echo "Starting build: FFTW ($fftwPACKAGE)"
+    echo
+
+    (
+        # configuration options:
+        unset configOpt
+
+        # Single-precision needed?
+        if [ "${WM_PRECISION_OPTION}" = SP ]
+        then
+            configOpt="$configOpt --enable-single"
+        fi
+
+        # end of configuration options
+        # ----------------------------
+        buildDIR=$buildBASE/$fftwPACKAGE
+
+        cd $FFTW_SOURCE_DIR || exit 1
+
+        rm -rf $FFTW_ARCH_PATH
+        rm -rf $buildDIR
+        mkdir -p $buildDIR
+        cd $buildDIR
+
+        set -x
+        $FFTW_SOURCE_DIR/configure \
+            --prefix=$FFTW_ARCH_PATH \
+            --libdir=$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+            --enable-shared --disable-static \
+            --disable-fortran \
+            $configOpt \
+            && make -j $WM_NCOMPPROCS \
+            && make install \
+            && echo "Built $fftwPACKAGE"
+    ) || {
+        echo "Error building: FFTW"
+        exit 1
+    }
+fi
+
+
+#------------------------------------------------------------------------------
-- 
GitLab


From 68b7b8c1357be88b473e9600c17116d0769b55b9 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 28 Jun 2016 16:50:29 +0200
Subject: [PATCH 18/40] ENH: integrate makeFFTW into Allwmake script

- issue warning message but not failure when optional things like
  (boost, CGAL, FFTW) encounter build issues in ThirdParty Allwmake.
---
 Allwmake | 57 ++++++++++++++++++++++++++++++++++++++++++--------------
 makeCGAL |  7 -------
 2 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/Allwmake b/Allwmake
index 4118983..973a013 100755
--- a/Allwmake
+++ b/Allwmake
@@ -250,7 +250,7 @@ then
     make realclean 2>/dev/null
 )
 else
-    echo "    optional component SCOTCH was not found"
+    echo "    Optional component (SCOTCH) was not found"
 fi
 
 # build ptscotch if MPI (ThirdParty or system) is available
@@ -371,28 +371,58 @@ then
     )
     fi
 else
-    echo "    optional component METIS was not found"
+    echo "    Optional component (METIS) was not found"
 fi
 
 
 #------------------------------------------------------------------------------
 
+warnBuildIssues()
+{
+    echo
+    echo "    ---------------------------------------------------"
+    echo "    Optional component ($1) had build issues"
+    echo "    OpenFOAM will nonetheless remain largely functional"
+    echo "    ---------------------------------------------------"
+    echo
+}
+
+warnNotFound()
+{
+    echo "    Optional component ($1) was not found"
+    echo
+}
+
+
 # CGAL is optional
 echo ========================================
 echo Build CGAL
-if [ -n "$CGAL_ARCH_PATH" ]
+if [ -d "$CGAL_ARCH_PATH/include" \
+  -a -r "$CGAL_ARCH_PATH/lib/libCGAL.so" ]
 then
-(
-    if [ -r $CGAL_ARCH_PATH/lib/libCGAL.so ]
-    then
-        echo "    CGAL headers in $CGAL_ARCH_PATH/include"
-        echo "    CGAL libs    in $CGAL_ARCH_PATH/lib"
-    else
-        ./makeCGAL
-    fi
-)
+    echo "    CGAL headers in $CGAL_ARCH_PATH/include"
+    echo "    CGAL libs    in $CGAL_ARCH_PATH/lib"
+elif [ -n "$CGAL_ARCH_PATH" ]
+then
+    ./makeCGAL || warnBuildIssues CGAL
+else
+    warnNotFound CGAL
+fi
+
+
+# FFTW is optional
+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" ]
+then
+    ./makeFFTW || warnBuildIssues FFTW
 else
-    echo "    optional component CGAL was not found"
+    warnNotFound FFTW
 fi
 
 
@@ -404,5 +434,4 @@ echo Done ThirdParty Allwmake
 echo ========================================
 echo
 
-
 #------------------------------------------------------------------------------
diff --git a/makeCGAL b/makeCGAL
index 8203b8c..91edb06 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -195,13 +195,6 @@ then
     exit 0
 fi
 
-# nothing left to build
-if [ "$cgal_version" = "cgal-system" ]
-then
-    echo "Using system installation of CGAL"
-    exit 0
-fi
-
 
 # Retrieve boost version:
 if [ -f "$boostInc/boost/version.hpp" ]
-- 
GitLab


From 7ec9f0713f00a470745d79e44aa1f9eb042e82fe Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 30 Jun 2016 15:55:20 +0200
Subject: [PATCH 19/40] STYLE: update some instructions in makeLLVM

---
 makeCGAL      |  9 +++++----
 makeCmake     | 10 +++++-----
 makeFFTW      |  8 ++++++--
 makeLLVM      | 28 +++++++++++++++++++++-------
 makeParaView  |  5 +++--
 makeParaView3 |  5 +++--
 makeQt        |  9 +++++----
 7 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/makeCGAL b/makeCGAL
index 91edb06..43db734 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -87,10 +87,10 @@ USAGE
 }
 #------------------------------------------------------------------------------
 
-# Ensure CMake gets the correct C++ compiler
+# Ensure CMake gets the correct C/C++ compiler
+[ -n "$WM_CC" ]  && export CC="$WM_CCX"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
-
 # Parse options
 while [ "$#" -gt 0 ]
 do
@@ -102,7 +102,8 @@ do
         # discard empty arguments
         ;;
     -gcc)
-        export CXX=g++   # use g++
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
         ;;
     -sys*)
         gmpPACKAGE="gmp-system"
diff --git a/makeCmake b/makeCmake
index a32cd1e..4de02ca 100755
--- a/makeCmake
+++ b/makeCmake
@@ -58,11 +58,11 @@ options:
 USAGE
     exit 1
 }
+#------------------------------------------------------------------------------
 
-# ensure CMake gets the correct C++ compiler
+# ensure CMake gets the correct /CC++ compiler
+[ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
-[ -n "$WM_CC" ] && export CC="$WM_CC"
-
 
 # parse options
 while [ "$#" -gt 0 ]
@@ -72,8 +72,8 @@ do
         usage
         ;;
     -gcc)
-        export CC=gcc   # use gcc
-        export CXX=g++  # use g++
+        export CC=gcc   # use gcc/g++
+        export CXX=g++
         ;;
     cmake-[1-9]*)
         cmakePACKAGE="${1%%/}"
diff --git a/makeFFTW b/makeFFTW
index f70539b..020cde2 100755
--- a/makeFFTW
+++ b/makeFFTW
@@ -68,6 +68,10 @@ USAGE
 }
 #------------------------------------------------------------------------------
 
+# 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
@@ -79,8 +83,8 @@ do
         # discard empty arguments
         ;;
     -gcc)
-        export CC=gcc    # use gcc
-        export CXX=g++   # use g++
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
         ;;
     fftw-[0-9]* | fftw_[0-9]* | fftw-system )
         fftwPACKAGE="${1%%/}"
diff --git a/makeLLVM b/makeLLVM
index f61f420..225f671 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -26,15 +26,29 @@
 #     makeLLVM
 #
 # Description
-#     Build script for llvm/clang etc.
+#     Build script for llvm, clang etc.
 #
-#    - Checkout LLVM:
-#        svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm-svn
+# Note
+#    - Ensure that you always use matching versions between llvm and clang.
+#    - The LLVM components reside in the LLVM tools/ subdirectory
 #
-#    - Checkout Clang:
-#        cd llvm-svn/tools
-#        svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
-#        cd -
+#    Example, building from svn repository:
+#      1) Checkout LLVM:
+#            svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm-svn
+#
+#      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
+#        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
+#        mv cfe-3.8.0.src  llvm-3.8.0/tools/clang
 #
 #------------------------------------------------------------------------------
 # get default llvm/clang version
diff --git a/makeParaView b/makeParaView
index 326baf2..357c85f 100755
--- a/makeParaView
+++ b/makeParaView
@@ -141,8 +141,8 @@ USAGE
 #------------------------------------------------------------------------------
 
 # ensure CMake gets the correct C/C++ compiler
+[ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
-[ -n "$WM_CC" ] && export CC="$WM_CC"
 
 #
 # add options based on script name:
@@ -173,7 +173,8 @@ do
         addCMakeVariable "$1"
         ;;
     -gcc)
-        export CXX=g++   # use g++
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
         ;;
     -patch)              # stage 0: patch sources
         runPATCH=true
diff --git a/makeParaView3 b/makeParaView3
index 294de8c..b015886 100755
--- a/makeParaView3
+++ b/makeParaView3
@@ -132,8 +132,8 @@ USAGE
 #------------------------------------------------------------------------------
 
 # ensure CMake gets the correct C/C++ compiler
+[ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
-[ -n "$WM_CC" ] && export CC="$WM_CC"
 
 #
 # add options based on script name:
@@ -163,7 +163,8 @@ do
         addCMakeVariable "$1"
         ;;
     -gcc)
-        export CXX=g++   # use g++
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
         ;;
     -config)             # stage 1: config only
         runCONFIG=true
diff --git a/makeQt b/makeQt
index 97c26c7..047d814 100755
--- a/makeQt
+++ b/makeQt
@@ -58,12 +58,12 @@ options:
 USAGE
     exit 1
 }
+#------------------------------------------------------------------------------
 
-
-# ensure configure gets the correct C++ compiler
+# 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
@@ -72,7 +72,8 @@ do
         usage
         ;;
     -gcc)
-        export CXX=g++   # use g++
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
         ;;
     [1-9]* | qt-[1-9]*)
         qtVERSION="${1%%/}";
-- 
GitLab


From 9bb96a7bcdbd71a0aaca60ed88a01d54dfb2d525 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 1 Jul 2016 17:47:05 +0200
Subject: [PATCH 20/40] BUG: need 'unset -f' to unset functions (issue #2)

- triggered by dash.
---
 makeCGAL | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/makeCGAL b/makeCGAL
index 43db734..c85f7ec 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -38,7 +38,7 @@
 
 # Get CGAL, boost and gmp/mpfr versions
 . $WM_PROJECT_DIR/etc/config.sh/functions
-unset _foamAddPath _foamAddLib _foamAddMan # get settings only
+unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
-- 
GitLab


From 17aaa3dc773a276cb2889f7f4ef382005d6442ad Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 6 Jul 2016 08:12:31 +0200
Subject: [PATCH 21/40] CONFIG: rename config file to avoid premature filtering
 of its name

---
 makeCCMIO | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/makeCCMIO b/makeCCMIO
index 022cb68..9d9b5d8 100755
--- a/makeCCMIO
+++ b/makeCCMIO
@@ -32,7 +32,7 @@
 
 # Get version info
 . $WM_PROJECT_DIR/etc/config.sh/functions
-_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/libccmio)
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
 
 ccmioPACKAGE=${ccmio_version:-libccmio-2.6.1}
 targetType=libso
-- 
GitLab


From b351eff392cee19fe5a7e2193326f504e6a1e795 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 12 Jul 2016 19:42:13 +0200
Subject: [PATCH 22/40] BUG: need 'unset -f' to unset functions (issue #2,
 issue #180)

- triggered by dash. makeFFTW needed the same fix.
---
 makeFFTW | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/makeFFTW b/makeFFTW
index 020cde2..3877fdd 100755
--- a/makeFFTW
+++ b/makeFFTW
@@ -32,7 +32,7 @@
 
 # Get FFTW versions
 . $WM_PROJECT_DIR/etc/config.sh/functions
-unset _foamAddPath _foamAddLib _foamAddMan # get settings only
+unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
 
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW)
 
-- 
GitLab


From 34023f31b813019b8259e3c676f778fdfd3058c7 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 12 Jul 2016 22:03:24 +0200
Subject: [PATCH 23/40] STYLE: echo more information about boost header/lib

- improve some other feedback information
---
 Allwmake      | 38 ++++++++++++++++++++++++++------------
 makeCGAL      |  4 ++--
 makeCmake     | 18 ++++++++++--------
 makeFFTW      |  2 +-
 makeGcc       |  2 +-
 makeLLVM      |  4 ++--
 makeParaView  |  2 +-
 makeParaView3 |  2 +-
 makeQt        |  2 +-
 9 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/Allwmake b/Allwmake
index 973a013..dca63e4 100755
--- a/Allwmake
+++ b/Allwmake
@@ -56,9 +56,9 @@ echo
 echo ========================================
 echo Start ThirdParty Allwmake
 echo ========================================
-echo
 
 
+echo
 echo ========================================
 echo Build MPI libraries if required
 echo "    $MPI_ARCH_PATH"
@@ -189,7 +189,7 @@ esac
 # building scotch is still a bit of a pain
 
 # get SCOTCH_VERSION, SCOTCH_ARCH_PATH
-if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch`
+if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch)
 then
     . $settings
 else
@@ -198,6 +198,7 @@ else
     echo
 fi
 
+echo
 echo ========================================
 echo "Build Scotch decomposition library $SCOTCH_VERSION"
 echo "    $SCOTCH_ARCH_PATH"
@@ -211,7 +212,6 @@ if [ -f $SCOTCH_ARCH_PATH/include/scotch.h \
 then
     echo "    scotch header in $SCOTCH_ARCH_PATH/include"
     echo "    scotch libs   in $FOAM_EXT_LIBBIN"
-    echo
 elif [ -d "$SCOTCH_VERSION" ]
 then
 (
@@ -258,15 +258,15 @@ fi
 if [ "${FOAM_MPI:-dummy}" != dummy ] && \
    [ -f $SCOTCH_ARCH_PATH/include/scotch.h ] || \
 {
-    echo "    WARNING: skipping pt-scotch - 'scotch.h' include file not found!"
     echo
+    echo "    WARNING: skipping pt-scotch - 'scotch.h' include file not found!"
     false
 }
 then
+    echo
     echo ========================================
     echo "Build pt-scotch decomposition library $SCOTCH_VERSION (with $FOAM_MPI)"
     echo "    $SCOTCH_ARCH_PATH"
-    echo
 
     if [ -f $SCOTCH_ARCH_PATH/include/$FOAM_MPI/ptscotch.h \
       -a -r $FOAM_EXT_LIBBIN/$FOAM_MPI/libptscotch.so \
@@ -274,9 +274,9 @@ then
     then
         echo "    ptscotch header in $SCOTCH_ARCH_PATH/include/$FOAM_MPI"
         echo "    ptscotch libs   in $FOAM_EXT_LIBBIN/$FOAM_MPI"
-        echo
     else
     (
+        echo
         set -x
         cd $SCOTCH_VERSION/src || exit 1
 
@@ -318,7 +318,6 @@ then
     [ -f $SCOTCH_ARCH_PATH/include/$FOAM_MPI/ptscotch.h ] || {
         echo
         echo "    WARNING: required include file 'ptscotch.h' not found!"
-        echo
     }
 fi
 
@@ -326,11 +325,12 @@ fi
 #------------------------------------------------------------------------------
 
 # Metis is optional
+echo
 echo ========================================
 echo Build Metis decomposition
 
 # get METIS_VERSION, METIS_ARCH_PATH
-if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis`
+if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis)
 then
     . $settings
 fi
@@ -395,13 +395,26 @@ warnNotFound()
 
 
 # CGAL is optional
+echo
 echo ========================================
 echo Build CGAL
 if [ -d "$CGAL_ARCH_PATH/include" \
   -a -r "$CGAL_ARCH_PATH/lib/libCGAL.so" ]
 then
-    echo "    CGAL headers in $CGAL_ARCH_PATH/include"
-    echo "    CGAL libs    in $CGAL_ARCH_PATH/lib"
+    # first some information about boost
+    if [ -d "$BOOST_ARCH_PATH/include/boost" \
+      -a -r "$BOOST_ARCH_PATH/lib/libboost_system.so" ]
+    then
+        echo "    BOOST headers in $BOOST_ARCH_PATH/include"
+        echo "    BOOST libs    in $BOOST_ARCH_PATH/lib"
+    elif [ -d "/usr/include/boost" \
+        -a -r "/usr/lib${WM_COMPILER_LIB_ARCH}/libboost_system.so" ]
+    then
+        echo "    BOOST headers in /usr/include"
+        echo "    BOOST libs    in /usr/lib${WM_COMPILER_LIB_ARCH}"
+    fi
+    echo "    CGAL  headers in $CGAL_ARCH_PATH/include"
+    echo "    CGAL  libs    in $CGAL_ARCH_PATH/lib"
 elif [ -n "$CGAL_ARCH_PATH" ]
 then
     ./makeCGAL || warnBuildIssues CGAL
@@ -411,13 +424,14 @@ 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"
+    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" ]
 then
     ./makeFFTW || warnBuildIssues FFTW
diff --git a/makeCGAL b/makeCGAL
index c85f7ec..c8f6796 100755
--- a/makeCGAL
+++ b/makeCGAL
@@ -67,12 +67,12 @@ usage() {
 
 usage: $Script [OPTION] [CGAL-VERSION] [boost-VERSION] [gmp-VERSION] [mpfr-VERSION]
 options:
-  -gcc              force g++ instead of the value from \$WM_CXX
+  -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -system           use system versions for boost/gmp/mpfr
   -help
 
 * build CGAL with
-      $cgalPACKAGE
+      ${cgalPACKAGE:-'unspecified CGAL version'}
       $boostPACKAGE
       $gmpPACKAGE
       $mpfrPACKAGE
diff --git a/makeCmake b/makeCmake
index 4de02ca..bdd906c 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -29,7 +29,8 @@
 #     Build script for cmake
 #
 #------------------------------------------------------------------------------
-cmakePACKAGE=cmake-3.2.1
+# Special purpose script, no default cmake version.
+unset cmakePACKAGE
 
 #------------------------------------------------------------------------------
 # run from third-party directory only
@@ -49,18 +50,18 @@ usage() {
 
 usage: ${0##*/} [OPTION] [cmake-VERSION]
 options:
-  -gcc              force g++ instead of the value from \$WM_CXX
+  -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -help
 
 * build cmake
-      $cmakePACKAGE
+      ${cmakePACKAGE:-'unspecified version'}
 
 USAGE
     exit 1
 }
 #------------------------------------------------------------------------------
 
-# ensure CMake gets the correct /CC++ compiler
+# ensure CMake gets the correct C/CC++ compiler
 [ -n "$WM_CC" ]  && export CC="$WM_CC"
 [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
 
@@ -85,15 +86,16 @@ do
     shift
 done
 
+[ -n "$cmakePACKAGE" ] || die "The cmake-VERSION was not specified"
 
 #------------------------------------------------------------------------------
-prefixDIR=$installBASE/$cmakePACKAGE
+CMAKE_ARCH_PATH=$installBASE/$cmakePACKAGE
 
 #
 # Build CMAKE
 #
 echo "---------------"
-if [ -d "$prefixDIR" -a -r "$prefixDIR/bin/cmake" ]
+if [ -d "$CMAKE_ARCH_PATH" -a -r "$CMAKE_ARCH_PATH/bin/cmake" ]
 then
     echo "Already built: $cmakePACKAGE"
 else
@@ -109,7 +111,7 @@ else
     mkdir -p $buildDIR
     cd $buildDIR
 
-    $sourceDIR/bootstrap --prefix=$prefixDIR \
+    $sourceDIR/bootstrap --prefix=$CMAKE_ARCH_PATH \
     && time make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $cmakePACKAGE"
diff --git a/makeFFTW b/makeFFTW
index 3877fdd..07e46d3 100755
--- a/makeFFTW
+++ b/makeFFTW
@@ -61,7 +61,7 @@ options:
   -help
 
 * build FFTW with
-      $fftwPACKAGE
+      ${fftwPACKAGE:-'unspecified FFTW version'}
 
 USAGE
     exit 1
diff --git a/makeGcc b/makeGcc
index 5624296..742d564 100755
--- a/makeGcc
+++ b/makeGcc
@@ -81,7 +81,7 @@ options:
       $gmpPACKAGE
       $mpfrPACKAGE
       $mpcPACKAGE
-      $gccPACKAGE
+      ${gccPACKAGE:-'unspecified GCC version'}
 
 USAGE
     exit 1
diff --git a/makeLLVM b/makeLLVM
index 225f671..67a9c40 100755
--- a/makeLLVM
+++ b/makeLLVM
@@ -82,7 +82,7 @@ options:
   -help
 
 * build llvm/clang
-      $llvmPACKAGE
+      ${llvmPACKAGE:-'unspecified LLVM version'}
 
 USAGE
     exit 1
@@ -148,7 +148,7 @@ else
     set -x
     $sourceDIR/configure \
         --prefix=$LLVM_ARCH_PATH \
-        --with-gcc-toolchain=`which gcc | sed s%/bin/gcc%%` \
+        --with-gcc-toolchain=$(which gcc | sed s%/bin/gcc%%) \
         --enable-optimized \
     && make -j $WM_NCOMPPROCS \
     && make install \
diff --git a/makeParaView b/makeParaView
index 357c85f..7fd1749 100755
--- a/makeParaView
+++ b/makeParaView
@@ -100,7 +100,7 @@ options:
   -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 g++ instead of the value from \$WM_CXX
+  -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
diff --git a/makeParaView3 b/makeParaView3
index b015886..7716daf 100755
--- a/makeParaView3
+++ b/makeParaView3
@@ -93,7 +93,7 @@ options:
   -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 g++ instead of the value from \$WM_CXX
+  -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
diff --git a/makeQt b/makeQt
index 047d814..d0723fa 100755
--- a/makeQt
+++ b/makeQt
@@ -50,7 +50,7 @@ usage() {
 
 usage: ${0##*/} [OPTION] [VERSION]
 options:
-  -gcc              force g++ instead of the value from \$WM_CXX
+  -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
   -help
 
 * build $qtTYPE, version $qtVERSION
-- 
GitLab


From bee5ef0d193c609aa147a1bb9808ea3eb74f3e87 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 13 Jul 2016 08:40:24 +0200
Subject: [PATCH 24/40] ENH: makeParaView now accepts paraview-VERSION directly
 as argument

- Symmetrical with the usage for most other ThirdParty build
  scripts. For example,

      "makeParaView ParaView-5.0.1"

- As a convenience, also allow a number directly. For example,

      "makeParaView 5.0.1"

  This should be clearer than the old instruction and does not
  rely on an alias:

      "foamPV 5.0.1; ./makeParaView"

BUG: heuristics for activating GL2 rendering backend missed when
     paraview version was specified from the command-line
---
 etc/tools/ParaView3Functions | 16 ++++++++-----
 etc/tools/ParaViewFunctions  | 12 ++++++----
 makeParaView                 | 45 ++++++++++++++++++++++++++----------
 makeParaView3                | 28 +++++++++++++++-------
 4 files changed, 71 insertions(+), 30 deletions(-)

diff --git a/etc/tools/ParaView3Functions b/etc/tools/ParaView3Functions
index 803ed9f..f95d1be 100644
--- a/etc/tools/ParaView3Functions
+++ b/etc/tools/ParaView3Functions
@@ -3,7 +3,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 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -72,12 +72,16 @@ setDirs()
 #
 # Set ParaView_VERSION and adjust ParaView_MAJOR accordingly
 #
+# $1 can contain something something like 4.4.0, paraview-4.4.0, ParaView-4.0.0
+#
 setVersion()
 {
-    if [ "$#" -ge 1 ]
-    then
-        ParaView_VERSION="${1##paraview-}"
-    fi
+    [ $# -gt 0 ] || {
+        echo "Error: function setVersion() called without an argument"
+        exit 1
+    }
+
+    ParaView_VERSION="${1##*-}"
 
     # The major version is "<digits>.<digits>"
     ParaView_MAJOR=$(echo $ParaView_VERSION | \
@@ -410,7 +414,7 @@ configParaView()
     echo
 
     # Run cmake to create Makefiles
-    $cmakeExe \
+    $cmakeExe -Wno-dev \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index d2c5cfd..590ba6b 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -72,12 +72,16 @@ setDirs()
 #
 # Set ParaView_VERSION and adjust ParaView_MAJOR accordingly
 #
+# $1 can contain something something like 4.4.0, paraview-4.4.0, ParaView-4.0.0
+#
 setVersion()
 {
-    if [ "$#" -ge 1 ]
-    then
-        ParaView_VERSION="${1##paraview-}"
-    fi
+    [ $# -gt 0 ] || {
+        echo "Error: function setVersion() called without an argument"
+        exit 1
+    }
+
+    ParaView_VERSION="${1##*-}"
 
     # The major version is "<digits>.<digits>"
     ParaView_MAJOR=$(echo $ParaView_VERSION | \
diff --git a/makeParaView b/makeParaView
index 7fd1749..951ee99 100755
--- a/makeParaView
+++ b/makeParaView
@@ -31,7 +31,7 @@
 #       (note capitalisation)
 #
 #------------------------------------------------------------------------------
-# run from third-party directory only
+# 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"
@@ -71,11 +71,9 @@ QMAKE_PATH=""
 # Set the path to cmake
 CMAKE_PATH=""
 
-# new rendering backend (starting with paraview 5.0)
-withGL2=true
-if [ "${ParaView_VERSION%%.*}" = 4 ]
-then withGL2=false
-fi
+# New rendering backend (starting with paraview 5.0).
+# Default to auto-config based on paraview version
+withGL2=auto
 
 #
 # NO FURTHER EDITING BELOW THIS LINE
@@ -88,7 +86,7 @@ usage() {
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: $Script [OPTION] [CMAKE-OPTION]
+usage: $Script [OPTION] [paraview-VERSION] [CMAKE-OPTION]
 options:
   -rebuild          for repeated builds (-make -install) *use with caution*
   -gl2              with new rendering backend (if not already enabled)
@@ -130,9 +128,10 @@ For finer control, the build stages can be selected or deselected individually:
       \$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
   ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION
 
-To change the paraview version, use the 'foamPV' command prior to '$Script'.
+To make a different paraview version, simply specify on the command-line.
 For example,
-    foamPV 4.4.0 ; ./makeParaview
+
+    ./makeParaview 4.4.0
 
 USAGE
     exit 1
@@ -152,8 +151,8 @@ case "$Script" in *-mpi*)    withMPI=true;; esac
 case "$Script" in *-python*) withPYTHON=true;; esac
 case "$Script" in *-qt*)     withQT=true;; esac
 
-# set ParaView_MAJOR based on current value of ParaView_VERSION
-setVersion
+# Set initial ParaView_MAJOR based on current value of ParaView_VERSION
+setVersion ${ParaView_VERSION:-none}
 
 #
 # various building stages
@@ -169,6 +168,9 @@ do
     -h | -help)
         usage
         ;;
+    [0-9]* | paraview-[0-9]* | ParaView-[0-9]*) # paraview version
+        setVersion "${1%%/}"
+        ;;
     [A-Z]*=*)            # cmake variables
         addCMakeVariable "$1"
         ;;
@@ -272,7 +274,7 @@ do
         ;;
     -version)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        setVersion "$2"
+        setVersion "${2%%/}"
         shift
         ;;
     -major)
@@ -292,6 +294,25 @@ do
     shift
 done
 
+[ -n "$ParaView_VERSION" ] || die "The paraview-VERSION was not specified"
+
+# nothing to build
+if _foamIsNone "$ParaView_VERSION"
+then
+    echo "Using paraview-none (skip ThirdParty build of ParaView)"
+    exit 0
+fi
+
+# Version-specific adjustments
+if [ "$withGL2" = auto ]
+then
+    if [ "${ParaView_VERSION%%.*}" = 4 ]
+    then
+        withGL2=false
+    else
+        withGL2=true
+    fi
+fi
 
 if [ "$runDEFAULT" = true ]
 then
diff --git a/makeParaView3 b/makeParaView3
index 7716daf..0c927b7 100755
--- a/makeParaView3
+++ b/makeParaView3
@@ -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 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -31,7 +31,7 @@
 #       (note capitalisation)
 #
 #------------------------------------------------------------------------------
-# run from third-party directory only
+# 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"
@@ -82,7 +82,7 @@ usage() {
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
 
-usage: $Script [OPTION] [CMAKE-OPTION]
+usage: $Script [OPTION] [paraview-VERSION] [CMAKE-OPTION]
 options:
   -rebuild          for repeated builds (-make -install) *use with caution*
   -mesa             with mesa (if not already enabled)
@@ -121,9 +121,10 @@ For finer control, the build stages can be selected or deselected individually:
       \$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
   ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION
 
-To make a different paraview version, use the 'foamPV' command prior to '$Script'.
+To make a different paraview version, simply specify on the command-line.
 For example,
-    foamPV 3.14.0 ; ./makeParaview
+
+    ./makeParaview 3.14.1
 
 USAGE
     exit 1
@@ -143,8 +144,8 @@ case "$Script" in *-mpi*)    withMPI=true;; esac
 case "$Script" in *-python*) withPYTHON=true;; esac
 case "$Script" in *-qt*)     withQT=true;; esac
 
-# set ParaView_MAJOR based on current value of ParaView_VERSION
-setVersion
+# Set initial ParaView_MAJOR based on current value of ParaView_VERSION
+setVersion ${ParaView_VERSION:-none}
 
 #
 # various building stages
@@ -159,6 +160,9 @@ do
     -h | -help)
         usage
         ;;
+    [0-9]* | paraview-[0-9]* | ParaView-[0-9]*) # paraview version
+        setVersion "${1%%/}"
+        ;;
     [A-Z]*=*)            # cmake variables
         addCMakeVariable "$1"
         ;;
@@ -249,7 +253,7 @@ do
         ;;
     -version)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        setVersion "$2"
+        setVersion "${2%%/}"
         shift
         ;;
     -major)
@@ -264,6 +268,14 @@ do
     shift
 done
 
+[ -n "$ParaView_VERSION" ] || die "The paraview-VERSION was not specified"
+
+# nothing to build
+if _foamIsNone "$ParaView_VERSION"
+then
+    echo "Using paraview-none (skip ThirdParty build of ParaView)"
+    exit 0
+fi
 
 if [ "$runDEFAULT" = true ]
 then
-- 
GitLab


From f3ef77b946ff1f4635e47daf42c0e18157af7c3a Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 13 Jul 2016 09:36:06 +0200
Subject: [PATCH 25/40] ENH: remove reliance on ParaView_VERSION env variable

- as per the other build scripts, use the OpenFOAM config
  files for the base settings and command-line arguments
  for refinement.

  Note that the $ParaView_DIR (the installation path) contains
  the paraview version information. So there is no need to
  keep a second variable just for that purpose.
---
 makeParaView  | 12 ++++++++++++
 makeParaView3 | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/makeParaView b/makeParaView
index 951ee99..a9f61b3 100755
--- a/makeParaView
+++ b/makeParaView
@@ -30,6 +30,15 @@
 #     - place the paraview source under $WM_THIRD_PARTY_DIR/ParaView-VERSION
 #       (note capitalisation)
 #
+#------------------------------------------------------------------------------
+# Get ParaView_DIR location from OpenFOAM config file
+. $WM_PROJECT_DIR/etc/config.sh/functions
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview)
+
+# Determine ParaView_VERSION from ParaView_DIR location:
+ParaView_VERSION="${ParaView_DIR##*/}"; export ParaView_VERSION
+: ${ParaView_VERSION##*-}
+
 #------------------------------------------------------------------------------
 # Run from third-party directory only
 cd ${0%/*} || exit 1
@@ -82,6 +91,7 @@ withGL2=auto
 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
@@ -133,6 +143,8 @@ For example,
 
     ./makeParaview 4.4.0
 
+Or change the \$WM_PROJECT_DIR/etc/config.sh/paraview settings.
+
 USAGE
     exit 1
 }
diff --git a/makeParaView3 b/makeParaView3
index 0c927b7..b310854 100755
--- a/makeParaView3
+++ b/makeParaView3
@@ -30,6 +30,15 @@
 #     - place the paraview source under $WM_THIRD_PARTY_DIR/ParaView-VERSION
 #       (note capitalisation)
 #
+#------------------------------------------------------------------------------
+# Get ParaView_DIR location from OpenFOAM config file
+. $WM_PROJECT_DIR/etc/config.sh/functions
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview)
+
+# Determine ParaView_VERSION from ParaView_DIR location:
+ParaView_VERSION="${ParaView_DIR##*/}"; export ParaView_VERSION
+: ${ParaView_VERSION##*-}
+
 #------------------------------------------------------------------------------
 # Run from third-party directory only
 cd ${0%/*} || exit 1
@@ -78,6 +87,7 @@ CMAKE_PATH=""
 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
@@ -126,6 +136,8 @@ For example,
 
     ./makeParaview 3.14.1
 
+Or change the \$WM_PROJECT_DIR/etc/config.sh/paraview settings.
+
 USAGE
     exit 1
 }
-- 
GitLab


From c20c2c2509fe46500d6415dd0e6a1e28c35e040c Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 14 Jul 2016 08:56:53 +0200
Subject: [PATCH 26/40] CONFIG: update paraview patch for paraview-5.1.0

ENH: include ThirdParty platforms when searching for cmake
---
 etc/patches/paraview-5.1.0  |  17 +++++
 etc/tools/ParaViewFunctions | 121 ++++++++++++++++++++++++------------
 makeParaView                |  10 +--
 3 files changed, 103 insertions(+), 45 deletions(-)
 create mode 100644 etc/patches/paraview-5.1.0

diff --git a/etc/patches/paraview-5.1.0 b/etc/patches/paraview-5.1.0
new file mode 100644
index 0000000..534e698
--- /dev/null
+++ b/etc/patches/paraview-5.1.0
@@ -0,0 +1,17 @@
+--- ParaView-5.1.0/Qt/Components/CMakeLists.txt.orig	2016-06-13 09:27:27.827849525 +0200
++++ ParaView-5.1.0/Qt/Components/CMakeLists.txt	2016-06-13 09:29:28.599318445 +0200
+@@ -656,10 +656,10 @@
+ #the pqSGExportStateWizard has subclasses that directly access
+ #the UI file, and currently we don't have a clean way to break this hard
+ #dependency, so for no we install this ui file.
+-if(PARAVIEW_INSTALL_DEVELOPMENT_FILES)
+-  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"
+-          DESTINATION "${VTK_INSTALL_INCLUDE_DIR}")
+-endif()
++#OPENFOAM patch#if(PARAVIEW_INSTALL_DEVELOPMENT_FILES)
++#OPENFOAM patch#  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_pqExportStateWizard.h"
++#OPENFOAM patch#          DESTINATION "${VTK_INSTALL_INCLUDE_DIR}")
++#OPENFOAM patch#endif()
+
+ #IF (NOT PV_INSTALL_NO_DEVELOPMENT)
+ #  # Headers
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 590ba6b..46ef0be 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -279,29 +279,49 @@ addQtSupport()
 
     addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"
 
-    unset qmakeExe
+    local candidate
+    local foundExe
     if [ -n "$QMAKE_PATH" ]
     then
+        # check as directory
         if [ -d "$QMAKE_PATH" ]
         then
-            if [ -x "$QMAKE_PATH/qmake" ]
-            then
-                qmakeExe=$QMAKE_PATH/qmake
-            elif [ -x "$QMAKE_PATH/bin/qmake" ]
-            then
-                qmakeExe=$QMAKE_PATH/bin/qmake
-            fi
-        elif [ -x "$QMAKE_PATH" ]
+            for candidate in \
+                $QMAKE_PATH/qmake \
+                $QMAKE_PATH/bin/qmake \
+            ;
+            do
+                if [ -f "$candidate" -a -x "$candidate" ]
+                then
+                    foundExe=$candidate
+                    break
+                fi
+            done
+        fi
+
+        # check as file, include ThirdParty installation in the search
+        if [ -z "$foundExe" ]
         then
-            qmakeExe=$QMAKE_PATH
+            for candidate in \
+                $QMAKE_PATH \
+                $installBASE/$QMAKE_PATH/bin/qmake \
+                $installBASE/qt-$QMAKE_PATH/bin/qmake \
+            ;
+            do
+                if [ -f "$candidate" -a -x "$candidate" ]
+                then
+                    foundExe=$candidate
+                    break
+                fi
+            done
         fi
 
-        if [ -n "$qmakeExe" ]
+        if [ -n "$foundExe" ]
         then
             # Use absolute path
-            if [ "${qmakeExe#/}" = "$qmakeExe" ]
+            if [ "${foundExe#/}" = "$foundExe" ]
             then
-                qmakeExe="$(cd ${qmakeExe%/qmake} 2>/dev/null && pwd)/qmake"
+                foundExe="$(cd ${foundExe%/qmake} 2>/dev/null && pwd)/qmake"
             fi
         else
             echo
@@ -312,21 +332,21 @@ addQtSupport()
         fi
     fi
 
-    # Default to using qmake from the path
-    if [ -n "$qmakeExe" ]
+    # Fallback to qmake from the path
+    if [ -n "$foundExe" ]
     then
-        addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmakeExe"
+        addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$foundExe"
     else
-        qmakeExe=qmake
+        foundExe=qmake
     fi
 
 
     # Check qmake can be found
-    if type $qmakeExe >/dev/null 2>&1
+    if type $foundExe >/dev/null 2>&1
     then
         # Check the Qt version selected
         # parse -> "Using Qt version X.Y.Z in ..."
-        QtVersion=$($qmakeExe -query QT_VERSION)
+        QtVersion=$($foundExe -query QT_VERSION)
 
         # Split Major.Minor.Revision - could also use IFS hacking
         set -- $(echo "$QtVersion" | sed -e 's/\./ /g')
@@ -364,29 +384,49 @@ patchParaView()
 #
 configParaView()
 {
-    unset cmakeExe
+    local candidate
+    local foundExe
     if [ -n "$CMAKE_PATH" ]
     then
+        # check as directory
         if [ -d "$CMAKE_PATH" ]
         then
-            if [ -x "$CMAKE_PATH/cmake" ]
-            then
-                cmakeExe=$CMAKE_PATH/cmake
-            elif [ -x "$CMAKE_PATH/bin/cmake" ]
-            then
-                cmakeExe=$CMAKE_PATH/bin/cmake
-            fi
-        elif [ -x "$CMAKE_PATH" ]
+            for candidate in \
+                $CMAKE_PATH/cmake \
+                $CMAKE_PATH/bin/cmake \
+            ;
+            do
+                if [ -f "$candidate" -a -x "$candidate" ]
+                then
+                    foundExe=$candidate
+                    break
+                fi
+            done
+        fi
+
+        # check as file, include ThirdParty installation in the search
+        if [ -z "$foundExe" ]
         then
-            cmakeExe=$CMAKE_PATH
+            for candidate in \
+                $CMAKE_PATH \
+                $installBASE/$CMAKE_PATH/bin/cmake \
+                $installBASE/cmake-$CMAKE_PATH/bin/cmake \
+            ;
+            do
+                if [ -f "$candidate" -a -x "$candidate" ]
+                then
+                    foundExe=$candidate
+                    break
+                fi
+            done
         fi
 
-        if [ -n "$cmakeExe" ]
+        if [ -n "$foundExe" ]
         then
             # Use absolute path
-            if [ "${cmakeExe#/}" = "$cmakeExe" ]
+            if [ "${foundExe#/}" = "$foundExe" ]
             then
-                cmakeExe="$(cd ${cmakeExe%/cmake} 2>/dev/null && pwd)/cmake"
+                foundExe="$(cd ${foundExe%/cmake} 2>/dev/null && pwd)/cmake"
             fi
         else
             echo
@@ -397,11 +437,8 @@ configParaView()
         fi
     fi
 
-    # Default to using cmake from the path
-    if [ -z "$cmakeExe" ]
-    then
-        cmakeExe=cmake
-    fi
+    # Fallback to cmake from the path
+    [ -n "$foundExe" ] || foundExe=cmake
 
     # Remove any existing build folder and recreate
     if [ -d $ParaView_BINARY_DIR ]
@@ -427,9 +464,10 @@ configParaView()
     echo "    Build          : $ParaView_BINARY_DIR"
     echo "    Target         : $ParaView_DIR"
     echo "    Build type     : $buildType"
+    echo "    Cmake          : $foundExe"
     echo "----"
     echo
-    echo "$cmakeExe" \
+    echo "$foundExe" \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
@@ -438,7 +476,7 @@ configParaView()
     echo
 
     # Run cmake to create Makefiles
-    $cmakeExe \
+    $foundExe \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
@@ -476,9 +514,12 @@ installParaView()
     make install
 
 cat<< INFO
+
     ---
     Installation complete for paraview-$ParaView_VERSION
-    Now update the environment by running:
+    ParaView_DIR=$ParaView_DIR
+
+    You may need to update the OpenFOAM environment by running:
         wmREFRESH
     ---
 INFO
diff --git a/makeParaView b/makeParaView
index a9f61b3..0aab9be 100755
--- a/makeParaView
+++ b/makeParaView
@@ -237,12 +237,12 @@ do
         ;;
     -mesa-include)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        MESA_INCLUDE="$2"
+        MESA_INCLUDE="${2%%/}"
         shift
         ;;
     -mesa-lib)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        MESA_LIBRARY="$2"
+        MESA_LIBRARY="${2%%/}"
         shift
         ;;
     -mpi)
@@ -259,17 +259,17 @@ do
         ;;
     -python-lib)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        PYTHON_LIBRARY="$2"
+        PYTHON_LIBRARY="${2%%/}"
         shift
         ;;
     -cmake)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        CMAKE_PATH=$2
+        CMAKE_PATH="${2%%/}"
         shift
         ;;
     -qmake)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        QMAKE_PATH=$2
+        QMAKE_PATH="${2%%/}"
         shift
         ;;
     -qt)
-- 
GitLab


From b36e02052ba1f14853681074d672c193d358fd7c Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 27 Jul 2016 17:02:28 +0200
Subject: [PATCH 27/40] CONFIG: enable shared libraries when building clang

---
 makeLLVM | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/makeLLVM b/makeLLVM
index 67a9c40..33c0e0b 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -90,7 +90,6 @@ USAGE
 
 #-----------------------------------------------------------------------------
 
-
 # parse options
 while [ "$#" -gt 0 ]
 do
@@ -150,6 +149,7 @@ else
         --prefix=$LLVM_ARCH_PATH \
         --with-gcc-toolchain=$(which gcc | sed s%/bin/gcc%%) \
         --enable-optimized \
+        --enable-shared \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $llvmPACKAGE"
-- 
GitLab


From 5de10e0e5abe318c3af06807cf4d85a1bc7713b3 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 27 Jul 2016 17:38:34 +0200
Subject: [PATCH 28/40] ENH: improve flexibility of makeGcc for non-gcc builds

- ThirdParty GMP/MPFR may be needed when making CGAL, but previously
  no convenient means of compiling them without also compiling a
  ThirdParty GCC.

  Now support the combination of building GMP or MPFR, without needing
  to build GCC as well. This could benefit people using clang.

- add a '-no-theadsafe' option when building MPFR via the makeGcc
  script. This may help avoid conflicts with existing, older,
  non-thread-safe system MPFR libraries.
---
 makeGcc | 64 ++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 21 deletions(-)

diff --git a/makeGcc b/makeGcc
index 742d564..a4223e2 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -74,6 +74,7 @@ usage: $Script [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)
+  -no-threadsafe    disable mpfr thread-safe (default is auto-detect)
   -system           use system versions for gmp/mpfr/mpc
   -help
 
@@ -90,6 +91,7 @@ USAGE
 
 # build 32-bit libraries on 64-bit systems (normally not needed)
 optMultilib=disable
+unset optThreadSafe # unset=auto
 
 # Parse options
 while [ "$#" -gt 0 ]
@@ -104,6 +106,9 @@ do
     -no-multi*)
         optMultilib=disable
         ;;
+    -no-thread*)
+        optThreadSafe=disable
+        ;;
     -sys*)
         gmpPACKAGE="gmp-system"
         mpfrPACKAGE="mpfr-system"
@@ -118,7 +123,7 @@ do
     mpc-[0-9]* | mpc-system)
         mpcPACKAGE="${1%%/}"
         ;;
-    gcc-[4-9]*)
+    gcc-[4-9]* | gcc-system)
         gccPACKAGE="${1%%/}"
         ;;
     *)
@@ -203,6 +208,14 @@ fi
 if [ -d "$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
+CONFIG_OPTIONS
+)
+else
+    unset configGMP
 fi
 
 
@@ -230,12 +243,15 @@ else
     mkdir -p $buildDIR
     cd $buildDIR
 
+    unset configOpt
+    # explicitly enable/disable thread-safe
+    [ -n "$optThreadSafe" ] && configOpt="--${optThreadSafe}-thread-safe"
+
     set -x
     $sourceDIR/configure ABI=$ABI \
-       --prefix=$MPFR_ARCH_PATH \
-       --libdir=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
-       --with-gmp-include=$GMP_ARCH_PATH/include \
-       --with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+        --prefix=$MPFR_ARCH_PATH \
+        --libdir=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+        $configGMP $configOpt \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $mpfrPACKAGE"
@@ -248,6 +264,14 @@ fi
 if [ -d "$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
+CONFIG_OPTIONS
+)
+else
+    unset configMPFR
 fi
 
 
@@ -279,10 +303,7 @@ else
     $sourceDIR/configure ABI=$ABI \
         --prefix=$MPC_ARCH_PATH \
         --libdir=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
-        --with-gmp-include=$GMP_ARCH_PATH/include \
-        --with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
-        --with-mpfr-include=$MPFR_ARCH_PATH/include \
-        --with-mpfr-lib=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
+        $configGMP $configMPFR \
     && make -j $WM_NCOMPPROCS \
     && make install \
     && echo "Built: $mpcPACKAGE"
@@ -295,6 +316,14 @@ fi
 if [ -d "$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
+CONFIG_OPTIONS
+)
+else
+    unset configMPC
 fi
 
 
@@ -309,6 +338,9 @@ echo "---------------"
 if [ -d $GCC_ARCH_PATH ]
 then
     echo "Already built: $gccPACKAGE"
+elif _foamIsSystem $GCC_ARCH_PATH
+then
+    echo "Using gcc-system"
 else
     echo "Starting build: $gccPACKAGE"
     echo
@@ -323,10 +355,6 @@ else
     mkdir -p $buildDIR
     cd $buildDIR
 
-    _foamIsSystem "$GMP_ARCH_PATH"  && GMP_ARCH_PATH=/usr  # revert to system
-    _foamIsSystem "$MPFR_ARCH_PATH" && MPFR_ARCH_PATH=/usr # revert to system
-    _foamIsSystem "$MPC_ARCH_PATH"  && MPC_ARCH_PATH=/usr  # revert to system
-
     unset configOpt
     # with/without multi-lib (32-bit support on 64-bit systems)
     [ -n "$optMultilib" ] && configOpt="--${optMultilib}-multilib"
@@ -334,18 +362,12 @@ else
     set -x
     $sourceDIR/configure \
         --prefix=$GCC_ARCH_PATH \
-        --with-gmp-include=$GMP_ARCH_PATH/include \
-        --with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
-        --with-mpfr-include=$MPFR_ARCH_PATH/include \
-        --with-mpfr-lib=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
-        --with-mpc-include=$MPC_ARCH_PATH/include \
-        --with-mpc-lib=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
         --with-pkgversion=OpenFOAM \
         --enable-languages=c,c++ \
         --enable-__cxa_atexit \
         --enable-libstdcxx-allocator=new \
         --with-system-zlib \
-        $configOpt \
+        $configGMP $configMPFR $configMPC $configOpt \
         MAKEINFO=missing \
     && make -j $WM_NCOMPPROCS \
     && make install \
-- 
GitLab


From 5dd69004925256f1d7b12e7081fec3490b3c1226 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 27 Jul 2016 18:33:33 +0200
Subject: [PATCH 29/40] ENH: relocate common functions into ThirdPartyFunctions

- Qualify some paraview-specific functions with 'ParaView' in the name.
  This helps with code-reuse.

STYLE: use lib$WM_COMPILER_LIB_ARCH instead of explicit lib64
---
 etc/tools/ParaView3Functions  |  98 +++---------------------
 etc/tools/ParaViewFunctions   | 136 ++++------------------------------
 etc/tools/ThirdPartyFunctions | 136 ++++++++++++++++++++++++++++++++++
 makeParaView                  |  23 ++++--
 makeParaView3                 |  15 ++--
 5 files changed, 183 insertions(+), 225 deletions(-)

diff --git a/etc/tools/ParaView3Functions b/etc/tools/ParaView3Functions
index f95d1be..0ce828d 100644
--- a/etc/tools/ParaView3Functions
+++ b/etc/tools/ParaView3Functions
@@ -39,7 +39,7 @@
 #   ParaView_BINARY_DIR : location of the build
 #   ParaView_DIR        : location of the installed program
 #
-setDirs()
+setParaViewDirs()
 {
     ParaView_SOURCE_DIR=$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
 
@@ -74,10 +74,10 @@ setDirs()
 #
 # $1 can contain something something like 4.4.0, paraview-4.4.0, ParaView-4.0.0
 #
-setVersion()
+setParaViewVersion()
 {
     [ $# -gt 0 ] || {
-        echo "Error: function setVersion() called without an argument"
+        echo "Error: function setParaViewVersion() called without an argument"
         exit 1
     }
 
@@ -241,7 +241,7 @@ addMesaSupport()
     then
         OBJ_ADD="$OBJ_ADD-mesa"
 
-        addCMakeVariable  "VTK_OPENGL_HAS_OSMESA=ON"
+        addCMakeVariable  "VTK_OPENGL_HAS_OSMESA:BOOL=ON"
         addCMakeVariable  "OSMESA_INCLUDE_DIR=$MESA_INCLUDE"
         addCMakeVariable  "OSMESA_LIBRARY=$MESA_LIBRARY"
 
@@ -267,54 +267,14 @@ addQtSupport()
 
     addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"
 
-    unset qmakeExe
-    if [ -n "$QMAKE_PATH" ]
-    then
-        if [ -d "$QMAKE_PATH" ]
-        then
-            if [ -x "$QMAKE_PATH/qmake" ]
-            then
-                qmakeExe=$QMAKE_PATH/qmake
-            elif [ -x "$QMAKE_PATH/bin/qmake" ]
-            then
-                qmakeExe=$QMAKE_PATH/bin/qmake
-            fi
-        elif [ -x "$QMAKE_PATH" ]
-        then
-            qmakeExe=$QMAKE_PATH
-        fi
-
-        if [ -n "$qmakeExe" ]
-        then
-            # Use absolute path
-            if [ "${qmakeExe#/}" = "$qmakeExe" ]
-            then
-                qmakeExe="$(cd ${qmakeExe%/qmake} 2>/dev/null && pwd)/qmake"
-            fi
-        else
-            echo
-            echo "qmake not found under specified QMAKE_PATH"
-            echo "    QMAKE_PATH=$QMAKE_PATH"
-            echo "leaving unspecified"
-            echo
-        fi
-    fi
-
-    # Default to using qmake from the path
-    if [ -n "$qmakeExe" ]
-    then
-        addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmakeExe"
-    else
-        qmakeExe=qmake
-    fi
-
+    local qmake=$(findQtMake)
 
     # Check qmake can be found
-    if type $qmakeExe >/dev/null 2>&1
+    if type $qmake >/dev/null 2>&1
     then
         # Check the Qt version selected
         # parse -> "Using Qt version X.Y.Z in ..."
-        QtVersion=$($qmakeExe -query QT_VERSION)
+        QtVersion=$($qmake -query QT_VERSION)
 
         # Split Major.Minor.Revision - could also use IFS hacking
         set -- $(echo "$QtVersion" | sed -e 's/\./ /g')
@@ -343,44 +303,7 @@ addQtSupport()
 #
 configParaView()
 {
-    unset cmakeExe
-    if [ -n "$CMAKE_PATH" ]
-    then
-        if [ -d "$CMAKE_PATH" ]
-        then
-            if [ -x "$CMAKE_PATH/cmake" ]
-            then
-                cmakeExe=$CMAKE_PATH/cmake
-            elif [ -x "$CMAKE_PATH/bin/cmake" ]
-            then
-                cmakeExe=$CMAKE_PATH/bin/cmake
-            fi
-        elif [ -x "$CMAKE_PATH" ]
-        then
-            cmakeExe=$CMAKE_PATH
-        fi
-
-        if [ -n "$cmakeExe" ]
-        then
-            # Use absolute path
-            if [ "${cmakeExe#/}" = "$cmakeExe" ]
-            then
-                cmakeExe="$(cd ${cmakeExe%/cmake} 2>/dev/null && pwd)/cmake"
-            fi
-        else
-            echo
-            echo "cmake not found under specified CMAKE_PATH"
-            echo "    CMAKE_PATH=$CMAKE_PATH"
-            echo "leaving unspecified"
-            echo
-        fi
-    fi
-
-    # Default to using cmake from the path
-    if [ -z "$cmakeExe" ]
-    then
-        cmakeExe=cmake
-    fi
+    local cmake=$(findCMake)
 
     # Remove any existing build folder and recreate
     if [ -d $ParaView_BINARY_DIR ]
@@ -403,9 +326,10 @@ configParaView()
     echo "    Source         : $ParaView_SOURCE_DIR"
     echo "    Build          : $ParaView_BINARY_DIR"
     echo "    Target         : $ParaView_DIR"
+    echo "    Cmake          : $cmake"
     echo "----"
     echo
-    echo "$cmakeExe" \
+    echo "$cmake" \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
@@ -414,7 +338,7 @@ configParaView()
     echo
 
     # Run cmake to create Makefiles
-    $cmakeExe -Wno-dev \
+    $cmake -Wno-dev \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 46ef0be..3150d68 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -39,7 +39,7 @@
 #   ParaView_BINARY_DIR : location of the build
 #   ParaView_DIR        : location of the installed program
 #
-setDirs()
+setParaViewDirs()
 {
     ParaView_SOURCE_DIR=$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
 
@@ -74,10 +74,10 @@ setDirs()
 #
 # $1 can contain something something like 4.4.0, paraview-4.4.0, ParaView-4.0.0
 #
-setVersion()
+setParaViewVersion()
 {
     [ $# -gt 0 ] || {
-        echo "Error: function setVersion() called without an argument"
+        echo "Error: function setParaViewVersion() called without an argument"
         exit 1
     }
 
@@ -241,7 +241,7 @@ addMesaSupport()
     then
         OBJ_ADD="$OBJ_ADD-mesa"
 
-        addCMakeVariable  "VTK_OPENGL_HAS_OSMESA=ON"
+        addCMakeVariable  "VTK_OPENGL_HAS_OSMESA:BOOL=ON"
         addCMakeVariable  "OSMESA_INCLUDE_DIR=$MESA_INCLUDE"
         addCMakeVariable  "OSMESA_LIBRARY=$MESA_LIBRARY"
 
@@ -279,74 +279,20 @@ addQtSupport()
 
     addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"
 
-    local candidate
-    local foundExe
-    if [ -n "$QMAKE_PATH" ]
-    then
-        # check as directory
-        if [ -d "$QMAKE_PATH" ]
-        then
-            for candidate in \
-                $QMAKE_PATH/qmake \
-                $QMAKE_PATH/bin/qmake \
-            ;
-            do
-                if [ -f "$candidate" -a -x "$candidate" ]
-                then
-                    foundExe=$candidate
-                    break
-                fi
-            done
-        fi
-
-        # check as file, include ThirdParty installation in the search
-        if [ -z "$foundExe" ]
-        then
-            for candidate in \
-                $QMAKE_PATH \
-                $installBASE/$QMAKE_PATH/bin/qmake \
-                $installBASE/qt-$QMAKE_PATH/bin/qmake \
-            ;
-            do
-                if [ -f "$candidate" -a -x "$candidate" ]
-                then
-                    foundExe=$candidate
-                    break
-                fi
-            done
-        fi
+    local qmake=$(findQtMake)
 
-        if [ -n "$foundExe" ]
-        then
-            # Use absolute path
-            if [ "${foundExe#/}" = "$foundExe" ]
-            then
-                foundExe="$(cd ${foundExe%/qmake} 2>/dev/null && pwd)/qmake"
-            fi
-        else
-            echo
-            echo "qmake not found under specified QMAKE_PATH"
-            echo "    QMAKE_PATH=$QMAKE_PATH"
-            echo "leaving unspecified"
-            echo
-        fi
-    fi
-
-    # Fallback to qmake from the path
-    if [ -n "$foundExe" ]
+    # From somewhere other than in the path
+    if [ "${qmake:=qmake}" != qmake ]
     then
-        addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$foundExe"
-    else
-        foundExe=qmake
+        addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmake"
     fi
 
-
     # Check qmake can be found
-    if type $foundExe >/dev/null 2>&1
+    if type $qmake >/dev/null 2>&1
     then
         # Check the Qt version selected
         # parse -> "Using Qt version X.Y.Z in ..."
-        QtVersion=$($foundExe -query QT_VERSION)
+        QtVersion=$($qmake -query QT_VERSION)
 
         # Split Major.Minor.Revision - could also use IFS hacking
         set -- $(echo "$QtVersion" | sed -e 's/\./ /g')
@@ -384,61 +330,7 @@ patchParaView()
 #
 configParaView()
 {
-    local candidate
-    local foundExe
-    if [ -n "$CMAKE_PATH" ]
-    then
-        # check as directory
-        if [ -d "$CMAKE_PATH" ]
-        then
-            for candidate in \
-                $CMAKE_PATH/cmake \
-                $CMAKE_PATH/bin/cmake \
-            ;
-            do
-                if [ -f "$candidate" -a -x "$candidate" ]
-                then
-                    foundExe=$candidate
-                    break
-                fi
-            done
-        fi
-
-        # check as file, include ThirdParty installation in the search
-        if [ -z "$foundExe" ]
-        then
-            for candidate in \
-                $CMAKE_PATH \
-                $installBASE/$CMAKE_PATH/bin/cmake \
-                $installBASE/cmake-$CMAKE_PATH/bin/cmake \
-            ;
-            do
-                if [ -f "$candidate" -a -x "$candidate" ]
-                then
-                    foundExe=$candidate
-                    break
-                fi
-            done
-        fi
-
-        if [ -n "$foundExe" ]
-        then
-            # Use absolute path
-            if [ "${foundExe#/}" = "$foundExe" ]
-            then
-                foundExe="$(cd ${foundExe%/cmake} 2>/dev/null && pwd)/cmake"
-            fi
-        else
-            echo
-            echo "cmake not found under specified CMAKE_PATH"
-            echo "    CMAKE_PATH=$CMAKE_PATH"
-            echo "leaving unspecified"
-            echo
-        fi
-    fi
-
-    # Fallback to cmake from the path
-    [ -n "$foundExe" ] || foundExe=cmake
+    local cmake=$(findCMake)
 
     # Remove any existing build folder and recreate
     if [ -d $ParaView_BINARY_DIR ]
@@ -464,10 +356,10 @@ configParaView()
     echo "    Build          : $ParaView_BINARY_DIR"
     echo "    Target         : $ParaView_DIR"
     echo "    Build type     : $buildType"
-    echo "    Cmake          : $foundExe"
+    echo "    Cmake          : $cmake"
     echo "----"
     echo
-    echo "$foundExe" \
+    echo "$cmake" \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
@@ -476,7 +368,7 @@ configParaView()
     echo
 
     # Run cmake to create Makefiles
-    $foundExe \
+    $cmake \
         -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
         $CMAKE_VARIABLES \
         $ParaView_SOURCE_DIR
diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 32dff52..40356ce 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -85,6 +85,142 @@ _foamIsSystem()
 }
 
 
+#
+# try to locate cmake according to the CMAKE_PATH
+# or just use what is found in the path
+#
+findCMake()
+{
+    local candidate
+    local foundExe
+
+    if [ -n "$CMAKE_PATH" ]
+    then
+        # check as directory
+        if [ -d "$CMAKE_PATH" ]
+        then
+            for candidate in \
+                $CMAKE_PATH/cmake \
+                $CMAKE_PATH/bin/cmake \
+            ;
+            do
+                if [ -f "$candidate" -a -x "$candidate" ]
+                then
+                    foundExe=$candidate
+                    break
+                fi
+            done
+        fi
+
+        # check as file, include ThirdParty installation in the search
+        if [ -z "$foundExe" ]
+        then
+            for candidate in \
+                $CMAKE_PATH \
+                $installBASE/$CMAKE_PATH/bin/cmake \
+                $installBASE/cmake-$CMAKE_PATH/bin/cmake \
+            ;
+            do
+                if [ -f "$candidate" -a -x "$candidate" ]
+                then
+                    foundExe=$candidate
+                    break
+                fi
+            done
+        fi
+
+        if [ -n "$foundExe" ]
+        then
+            # Use absolute path
+            if [ "${foundExe#/}" = "$foundExe" ]
+            then
+                foundExe="$(cd ${foundExe%/cmake} 2>/dev/null && pwd)/cmake"
+            fi
+
+            echo "$foundExe"
+            return 0
+        else
+            cat << NOT_FOUND 1>&2
+'cmake' not found under specified CMAKE_PATH
+    CMAKE_PATH=$CMAKE_PATH
+reverting to using command from path
+NOT_FOUND
+        fi
+    fi
+
+    # Default is cmake from the path
+    echo cmake
+}
+
+
+#
+# try to locate qmake according to the QMAKE_PATH
+# or just use what is found in the path
+#
+findQtMake()
+{
+    local candidate
+    local foundExe
+
+    if [ -n "$QMAKE_PATH" ]
+    then
+        # check as directory
+        if [ -d "$QMAKE_PATH" ]
+        then
+            for candidate in \
+                $QMAKE_PATH/qmake \
+                $QMAKE_PATH/bin/qmake \
+            ;
+            do
+                if [ -f "$candidate" -a -x "$candidate" ]
+                then
+                    foundExe=$candidate
+                    break
+                fi
+            done
+        fi
+
+        # check as file, include ThirdParty installation in the search
+        if [ -z "$foundExe" ]
+        then
+            for candidate in \
+                $QMAKE_PATH \
+                $installBASE/$QMAKE_PATH/bin/qmake \
+                $installBASE/qt-$QMAKE_PATH/bin/qmake \
+            ;
+            do
+                if [ -f "$candidate" -a -x "$candidate" ]
+                then
+                    foundExe=$candidate
+                    break
+                fi
+            done
+        fi
+
+        if [ -n "$foundExe" ]
+        then
+            # Use absolute path
+            if [ "${foundExe#/}" = "$foundExe" ]
+            then
+                foundExe="$(cd ${foundExe%/qmake} 2>/dev/null && pwd)/qmake"
+            fi
+
+            echo "$foundExe"
+            return 0
+        else
+            cat << NOT_FOUND 1>&2
+'qmake' not found under specified QMAKE_PATH
+    QMAKE_PATH=$QMAKE_PATH
+reverting to using command from path
+NOT_FOUND
+        fi
+    fi
+
+    # Default is qmake from the path
+    echo qmake
+}
+
+
 #
 # Download file $1 from url $2 into download/ directory
 #
diff --git a/makeParaView b/makeParaView
index 0aab9be..d571eb3 100755
--- a/makeParaView
+++ b/makeParaView
@@ -64,12 +64,12 @@ MPI_MAX_PROCS=32
 #       If it fails, specify the path using the PYTHON_LIBRARY variable
 withPYTHON=false
 PYTHON_LIBRARY=""
-# PYTHON_LIBRARY="/usr/lib64/libpython2.6.so.1.0"
+# PYTHON_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libpython2.6.so.1.0"
 
 # MESA graphics support:
 withMESA=false
 MESA_INCLUDE="/usr/include/GL"
-MESA_LIBRARY="/usr/lib64/libOSMesa.so"
+MESA_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
 
 # extra QT gui support (useful for some third party apps)
 withQT=true
@@ -113,8 +113,8 @@ 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)
-  -mesa-include DIR
-                    location of mesa headers (current value: ${MESA_INCLUDE:-none})
+  -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
@@ -164,7 +164,7 @@ 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
-setVersion ${ParaView_VERSION:-none}
+setParaViewVersion ${ParaView_VERSION:-none}
 
 #
 # various building stages
@@ -181,7 +181,7 @@ do
         usage
         ;;
     [0-9]* | paraview-[0-9]* | ParaView-[0-9]*) # paraview version
-        setVersion "${1%%/}"
+        setParaViewVersion "${1%%/}"
         ;;
     [A-Z]*=*)            # cmake variables
         addCMakeVariable "$1"
@@ -235,6 +235,13 @@ do
     -no-mesa)
         withMESA=false
         ;;
+    -mesa-prefix)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        withMESA=true
+        MESA_INCLUDE="${2%%/}/include"
+        MESA_LIBRARY="${2%%/}/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
+        shift
+        ;;
     -mesa-include)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         MESA_INCLUDE="${2%%/}"
@@ -286,7 +293,7 @@ do
         ;;
     -version)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        setVersion "${2%%/}"
+        setParaViewVersion "${2%%/}"
         shift
         ;;
     -major)
@@ -344,7 +351,7 @@ addMesaSupport      # set MESA-specific options
 addGL2Support       # new rendering backend
 addQtSupport        # add extra Qt support
 
-setDirs             # where things are or should be put
+setParaViewDirs     # where things are or should be put
 
 
 # Build and install
diff --git a/makeParaView3 b/makeParaView3
index b310854..6d86c09 100755
--- a/makeParaView3
+++ b/makeParaView3
@@ -64,12 +64,12 @@ MPI_MAX_PROCS=32
 #       If it fails, specify the path using the PYTHON_LIBRARY variable
 withPYTHON=false
 PYTHON_LIBRARY=""
-# PYTHON_LIBRARY="/usr/lib64/libpython2.6.so.1.0"
+# PYTHON_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libpython2.6.so.1.0"
 
 # MESA graphics support:
 withMESA=false
 MESA_INCLUDE="/usr/include/GL"
-MESA_LIBRARY="/usr/lib64/libOSMesa.so"
+MESA_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
 
 # extra QT gui support (useful for some third party apps)
 withQT=true
@@ -107,8 +107,7 @@ options:
   -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
-  -mesa-include DIR
-                    location of mesa headers (current value: ${MESA_INCLUDE:-none})
+  -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
@@ -157,7 +156,7 @@ 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
-setVersion ${ParaView_VERSION:-none}
+setParaViewVersion ${ParaView_VERSION:-none}
 
 #
 # various building stages
@@ -173,7 +172,7 @@ do
         usage
         ;;
     [0-9]* | paraview-[0-9]* | ParaView-[0-9]*) # paraview version
-        setVersion "${1%%/}"
+        setParaViewVersion "${1%%/}"
         ;;
     [A-Z]*=*)            # cmake variables
         addCMakeVariable "$1"
@@ -265,7 +264,7 @@ do
         ;;
     -version)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        setVersion "${2%%/}"
+        setParaViewVersion "${2%%/}"
         shift
         ;;
     -major)
@@ -305,7 +304,7 @@ addPythonSupport    # set Python-specific options
 addMesaSupport      # set MESA-specific options
 addQtSupport        # add extra Qt support
 
-setDirs             # where things are or should be put
+setParaViewDirs     # where things are or should be put
 
 
 # Build and install
-- 
GitLab


From cd07d9f6bcbec816dfc52bbc92868ba6289fef10 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Mon, 1 Aug 2016 10:28:56 +0200
Subject: [PATCH 30/40] ENH: provide makeMesa and makeVTK scripts

---
 makeMesa        | 200 ++++++++++++++++++++++++++++++++
 makeVTK         | 303 ++++++++++++++++++++++++++++++++++++++++++++++++
 makeVTK.example |  11 ++
 3 files changed, 514 insertions(+)
 create mode 100755 makeMesa
 create mode 100755 makeVTK
 create mode 100755 makeVTK.example

diff --git a/makeMesa b/makeMesa
new file mode 100755
index 0000000..f48ecb9
--- /dev/null
+++ b/makeMesa
@@ -0,0 +1,200 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2016 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
+#     makeMesa
+#
+# Description
+#     Build script for Mesa
+#
+# Note
+#     Building with mesa-12.0.1 failed to install an "osmesa.h" file,
+#     which renders it useless for off-screen VTK.
+#
+#------------------------------------------------------------------------------
+mesaPACKAGE=mesa-11.2.2
+
+#------------------------------------------------------------------------------
+# 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
+#------------------------------------------------------------------------------
+Script=${0##*/}
+
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: $Script [OPTION] [mesa-VERSION]
+options:
+  -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
+  -help
+
+* build Mesa with
+      ${mesaPACKAGE:-'unspecified MESA 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"
+
+# Non-standard location for clang?
+unset thirdPartyClang
+if [ "$WM_COMPILER_TYPE" = ThirdParty -a "$WM_COMPILER" = Clang ]
+then
+    thirdPartyClang=true
+fi
+
+# parse options
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    -gcc)
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
+        unset thirdPartyClang
+        ;;
+    mesa-*)
+        mesaPACKAGE="${1%%/}"
+        ;;
+    *)
+        die "unknown option/argument: '$1'"
+        ;;
+    esac
+    shift
+done
+
+[ -n "$mesaPACKAGE" ] || die "The mesa-VERSION was not specified"
+
+# nothing to build
+if _foamIsNone "$mesaPACKAGE"
+then
+    echo "Using mesa-none (skip ThirdParty build of MESA)"
+    exit 0
+fi
+
+if _foamIsSystem "$mesaPACKAGE"
+then
+    echo "Using mesa-system (skip ThirdParty build of MESA)"
+    exit 0
+fi
+
+#------------------------------------------------------------------------------
+# locate third-party clang as required
+if [ "$thirdPartyClang" = true ]
+then
+    thirdPartyClang=$(command -v clang) || {
+        echo "Error: could not properly locate clang"
+        exit 2
+    }
+
+    # root installation directory
+    thirdPartyClang=${thirdPartyClang%/bin/clang}
+
+    [ -d "$thirdPartyClang" ] || {
+        echo "Error: could not properly locate clang"
+        exit 2
+    }
+fi
+
+#------------------------------------------------------------------------------
+#
+# Build MESA
+# For 64-bit
+# - MESA itself will normally build into 'lib64'.
+#
+#   MESA_SOURCE_DIR : location of the original sources
+
+MESA_ARCH_PATH=$installBASE/$mesaPACKAGE
+MESA_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$mesaPACKAGE
+
+(
+    # configuration options:
+    unset configOpt
+
+    if [ -d "$thirdPartyClang" ]
+    then
+        configOpt="$configOpt --with-llvm-prefix=$thirdPartyClang"
+    fi
+
+    # end of configuration options
+    # ----------------------------
+    buildDIR=$buildBASE/$mesaPACKAGE
+
+    cd $MESA_SOURCE_DIR || exit 1
+
+    # remove any existing build
+    rm -rf $MESA_ARCH_PATH
+    rm -rf $buildDIR
+    mkdir -p $buildDIR
+    cd $buildDIR
+
+    echo "----"
+    echo "Building $mesaPACKAGE"
+    echo "    Source         : $MESA_SOURCE_DIR"
+    echo "    Target         : $MESA_ARCH_PATH"
+    if [ -d "$thirdPartyClang" ]
+    then
+        echo "    Clang          : $thirdPartyClang"
+    fi
+    echo "----"
+
+    # possibly for older mesa versions (see paraview wiki)
+    # CXXFLAGS="-O2 -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
+    # CFLAGS="-O2 -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
+
+    ## autoreconf -fi
+    set -x
+    $MESA_SOURCE_DIR/configure \
+        --prefix=$MESA_ARCH_PATH \
+        --disable-xvmc \
+        --disable-glx \
+        --disable-dri \
+        --disable-egl \
+        --enable-texture-float \
+        --enable-gallium-osmesa --with-gallium-drivers=swrast \
+        $configOpt \
+        && make -j $WM_NCOMPPROCS \
+        && make install \
+        && echo "Built $mesaPACKAGE"
+) || {
+    echo "Error building: MESA"
+    exit 1
+}
+
+# ----------------------------------------------------------------- end-of-file
diff --git a/makeVTK b/makeVTK
new file mode 100755
index 0000000..27eac17
--- /dev/null
+++ b/makeVTK
@@ -0,0 +1,303 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2016 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
+#     makeVTK
+#
+# Description
+#     Make and install VTK
+#     - place the VTK source under $WM_THIRD_PARTY_DIR/VTK-VERSION
+#
+#     To use the VTK source from the ParaView source tree, simply make an
+#     appropriate link first. For example,
+#
+#        ln -s ParaView-5.1.0/VTK  VTK-7.1.0
+#
+#------------------------------------------------------------------------------
+# 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
+. etc/tools/vtkFunctions
+#------------------------------------------------------------------------------
+#
+# USER OPTIONS:
+# ~~~~~~~~~~~~~
+
+# 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
+
+
+#
+# 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]
+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
+  -cmake PATH       with the cmake version corresponding to the cmake 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
+
+CMake options start with a capital letter and contain an '='.
+For example,
+    $Script BUILD_TESTING=ON
+to add tests and avoid building documentation
+
+For finer control, the build stages can be selected or deselected individually:
+  -config    -no-config
+  -make      -no-make
+  -install   -no-install
+
+
+* 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
+
+USAGE
+    exit 1
+}
+
+#------------------------------------------------------------------------------
+
+# ensure CMake gets the correct C/C++ compiler
+[ -n "$WM_CC" ]  && export CC="$WM_CC"
+[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
+
+#
+# various building stages
+#
+unset runPATCH runCONFIG runMAKE runINSTALL
+runDEFAULT=true
+buildType=Release
+withOSMESA=false
+
+# parse options
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    [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++
+        ;;
+    -config)             # stage 1: config only
+        runCONFIG=true
+        unset runDEFAULT
+        ;;
+    -no-config)
+        runCONFIG=false
+        ;;
+    -make)               # stage 2: make only
+        runMAKE=true
+        unset runDEFAULT
+        ;;
+    -no-make)
+        runMAKE=false
+        ;;
+    -install)            # stage 3: install only
+        runINSTALL=true
+        unset runDEFAULT
+        ;;
+    -no-install)
+        runINSTALL=false
+        ;;
+    -rebuild)            # shortcut for rebuilding
+        runMAKE=true
+        runINSTALL=true
+        unset runDEFAULT
+        ;;
+    -gl2)
+        withGL2=true
+        ;;
+    -no-gl2)
+        withGL2=false
+        ;;
+    -mesa)
+        withMESA=true
+        ;;
+    -osmesa)
+        withMESA=true
+        withOSMESA=true
+        ;;
+    -no-mesa)
+        withMESA=false
+        withOSMESA=false
+        ;;
+    -mesa-prefix)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        withMESA=true
+        MESA_INCLUDE="${2%%/}/include"
+        MESA_LIBRARY="${2%%/}/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
+        shift
+        ;;
+    -mesa-include)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        MESA_INCLUDE="${2%%/}"
+        shift
+        ;;
+    -mesa-lib)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        MESA_LIBRARY="${2%%/}"
+        shift
+        ;;
+    -cmake)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        CMAKE_PATH="${2%%/}"
+        shift
+        ;;
+    -verbose)
+        withVERBOSE=true
+        ;;
+    -version)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        setVtkVersion "${2%%/}"
+        VTK_VERSION="${2%%/}"
+        shift
+        ;;
+    -buildType)
+        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
+        buildType="$2"
+        shift
+        ;;
+    *)
+        die "unknown option/argument: '$1'"
+        ;;
+    esac
+    shift
+done
+
+[ -n "$VTK_VERSION" ] || die "The vtk-VERSION was not specified"
+
+# Version-specific adjustments
+if [ "$withGL2" = auto ]
+then
+    if [ "${VTK_VERSION%%.*}" -lt 7 ]
+    then
+        withGL2=false
+    else
+        withGL2=true
+    fi
+fi
+
+
+if [ "$runDEFAULT" = true ]
+then
+    : ${runPATCH:=true}
+    : ${runCONFIG:=true}
+    : ${runMAKE:=true}
+    : ${runINSTALL:=true}
+fi
+
+
+# Set configure options
+#~~~~~~~~~~~~~~~~~~~~~~
+addVerbosity        # verbose makefiles
+addMesaSupport      # set MESA-specific options
+addGL2Support       # new rendering backend
+
+# set off-screen only options
+if [ "$withOSMESA" = true ]
+then
+    addCMakeVariable "VTK_USE_X:BOOL=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"
+fi
+
+setVtkDirs          # where things are or should be put
+
+
+# Build and install
+# ~~~~~~~~~~~~~~~~~
+cat<<SUMMARY
+
+Build stages selected
+---------------------
+    -patch    ${runPATCH:-false}
+    -config   ${runCONFIG:-false}
+    -make     ${runMAKE:-false}
+    -install  ${runINSTALL:-false}
+---------------------
+Features selected
+    mesa      ${withMESA:-false}
+---------------------
+Version information
+    version   ${VTK_VERSION:-unknown}
+    build     ${buildType:-Release}
+---------------------
+SUMMARY
+
+[ "$runPATCH"   = true ] && patchVTK
+[ "$runCONFIG"  = true ] && configVTK
+[ "$runMAKE"    = true ] && makeVTK
+[ "$runINSTALL" = true ] && installVTK
+
+echo
+echo Done
+
+#------------------------------------------------------------------------------
diff --git a/makeVTK.example b/makeVTK.example
new file mode 100755
index 0000000..b4cdcda
--- /dev/null
+++ b/makeVTK.example
@@ -0,0 +1,11 @@
+#!/bin/sh
+# An example for building a particular combinations of VTK with off-screen mesa
+
+vtk=vtk-7.1.0
+mesa=mesa-11.2.2
+
+./makeVTK \
+    $vtk \
+    -osmesa -mesa-prefix $WM_THIRD_PARTY_DIR/platforms/linux64Gcc/$mesa
+
+#------------------------------------------------------------------------------
-- 
GitLab


From 2453d95ef7cb7ff5481aaae7314cd2b24a56c507 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Mon, 1 Aug 2016 11:03:58 +0200
Subject: [PATCH 31/40] ENH: provide makeADIOS script

---
 makeADIOS | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 217 insertions(+)
 create mode 100755 makeADIOS

diff --git a/makeADIOS b/makeADIOS
new file mode 100755
index 0000000..a731185
--- /dev/null
+++ b/makeADIOS
@@ -0,0 +1,217 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2016 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
+#     makeADIOS
+#
+# Description
+#     Build script for ADIOS (and MXML)
+#
+#------------------------------------------------------------------------------
+adiosPACKAGE=adios-git
+mxmlPACKAGE=mxml-2.9
+
+#------------------------------------------------------------------------------
+# 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
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: ${0##*/} [OPTION] [adios-VERSION] [mxml-VERSION]
+options:
+  -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
+  -help
+
+* Build ADIOS+MXML
+      $adiosPACKAGE
+      $mxmlPACKAGE
+
+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
+        ;;
+    -gcc)
+        export CC=gcc    # use gcc/g++
+        export CXX=g++
+        ;;
+    adios-[1-9]* | adios-git)
+        adiosPACKAGE="${1%%/}"
+        ;;
+    mxml-[1-9]*)
+        mxmlPACKAGE="${1%%/}"
+        ;;
+    *)
+        die "unknown option/argument: '$1'"
+        ;;
+    esac
+    shift
+done
+
+#------------------------------------------------------------------------------
+
+MXML_ARCH_PATH=$installBASE/$mxmlPACKAGE
+ADIOS_ARCH_PATH=$installBASE/$adiosPACKAGE
+
+# build MXML - not needed with more recent ADIOS
+if false
+then
+    echo
+    echo ========================================
+    echo "Build mxml library $mxmlPACKAGE"
+    echo
+
+    if [ -f $MXML_ARCH_PATH/include/mxml.h \
+      -a -r $FOAM_EXT_LIBBIN/libmxml.so ]
+    then
+        echo "    MXML header in $MXML_ARCH_PATH/include"
+        echo "    MXML libs   in $FOAM_EXT_LIBBIN"
+        echo
+    else
+    (
+        # use mxml packaged with adios (if possible)
+        # or revert to top-level
+        sourceDIR=$WM_THIRD_PARTY_DIR/$adiosPACKAGE/src/mxml/$mxmlPACKAGE
+        [ -d "$sourceDIR" ] || sourceDIR=$WM_THIRD_PARTY_DIR/$mxmlPACKAGE
+
+        cd $sourceDIR || exit 1
+
+        # Remove any existing build folder and recreate
+        \rm -rf $buildDIR 2>/dev/null
+        mkdir -p $buildDIR
+
+        [ -e Makefile ] && make clean 2>/dev/null # for safety
+        mkdir -p $FOAM_EXT_LIBBIN  2>/dev/null
+
+        # handle non-gcc compilers
+        unset configEnv
+        if [ "${WM_CC:-gcc}" != gcc ]
+        then
+            export CC=$WM_CC
+            export CCS=$WM_CC
+        fi
+
+        # installs into lib64/
+        cd $buildDIR && \
+        $sourceDIR/configure --prefix=$MXML_ARCH_PATH \
+        && make -j $WM_NCOMPPROCS all \
+        && make install \
+        && echo "Built: $mxmlPACKAGE" \
+        && rsync -a $MXML_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/*.so* $FOAM_EXT_LIBBIN/
+    ) || {
+        echo "Error building: $mxmlPACKAGE"
+    }
+    fi
+fi
+
+# build ADIOS
+echo
+echo ========================================
+echo "Build adios library $adiosPACKAGE"
+echo
+
+# Needs future adjustment for shared library, for mpi-specific library location
+if [ -f $ADIOS_ARCH_PATH/include/adios.h \
+  -a -r $FOAM_EXT_LIBBIN/$FOAM_MPI/libadios.so ]
+then
+    echo "    ADIOS header in $ADIOS_ARCH_PATH/include"
+    echo "    ADIOS libs   in $FOAM_EXT_LIBBIN"
+    echo
+else
+(
+    # configuration options:
+    # Start with GridEngine support - builds without external libraries
+    unset configOpt
+
+    # Add InfiniBand support
+    ibDir=/usr/local/ofed
+    if [ -d "$ibDir/include" ]
+    then
+        configOpt="$configOpt --with-infiniband=$ibDir"
+    fi
+    ## $configOpt="$configOpt --with-hdf5=..."
+
+    # for externally compiled MXML
+    # configOpt="$configOpt --with-mxml=$MXML_ARCH_PATH"
+
+    # end of configuration options
+    # ----------------------------
+
+    sourceDIR=$WM_THIRD_PARTY_DIR/$adiosPACKAGE
+    buildDIR=$buildBASE/$adiosPACKAGE
+
+    cd $sourceDIR || exit 1
+    export GIT_DIR=$sourceDIR/.git
+
+    # Remove any existing build folder and recreate
+    \rm -rf $buildDIR 2>/dev/null
+    mkdir -p $buildDIR
+
+    [ -e Makefile ] && make clean 2>/dev/null # for safety
+
+    [ -f configure ] || {
+        echo "no configure for $adiosPACKAGE ... trying autogen"
+        ./autogen.sh
+    }
+
+    # installs into lib64/
+    cd $buildDIR && \
+    CC=mpicc CXX=mpicxx CFLAGS="-fPIC" $sourceDIR/configure \
+        --prefix=$ADIOS_ARCH_PATH \
+        --disable-fortran \
+        --with-pic \
+        --without-fastbit \
+        $configOpt \
+    && make -j $WM_NCOMPPROCS all \
+    && make install \
+    && echo "Built: $adiosPACKAGE" \
+    && rsync -a --no-r $ADIOS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/ $FOAM_EXT_LIBBIN/$FOAM_MPI/
+) || {
+    echo "Error building: $adiosPACKAGE"
+}
+fi
+
+# ----------------------------------------------------------------- end-of-file
-- 
GitLab


From a5ab962792eb974dc9ae823d390a99b9806e6f1a Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 4 Aug 2016 16:02:09 +0200
Subject: [PATCH 32/40] STYLE: allow argument passing in makeVTK.example

---
 makeVTK.example | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/makeVTK.example b/makeVTK.example
index b4cdcda..4de6054 100755
--- a/makeVTK.example
+++ b/makeVTK.example
@@ -6,6 +6,8 @@ mesa=mesa-11.2.2
 
 ./makeVTK \
     $vtk \
-    -osmesa -mesa-prefix $WM_THIRD_PARTY_DIR/platforms/linux64Gcc/$mesa
+    -osmesa \
+    -mesa-prefix $WM_THIRD_PARTY_DIR/platforms/linux64Gcc/$mesa \
+    "$@"
 
 #------------------------------------------------------------------------------
-- 
GitLab


From 8f68d5171733881f1f164884f9ebe9dfba7dcc97 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Tue, 9 Aug 2016 09:54:11 +0200
Subject: [PATCH 33/40] CONFIG: change default library target for ccm to be
 static

- Makes it easier to locate for compiling/linking and lets us
  wrap away in a C++ interface to hide low-level C routines.
---
 makeCCMIO | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/makeCCMIO b/makeCCMIO
index 9d9b5d8..5d1beb6 100755
--- a/makeCCMIO
+++ b/makeCCMIO
@@ -35,7 +35,7 @@
 _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
 
 ccmioPACKAGE=${ccmio_version:-libccmio-2.6.1}
-targetType=libso
+targetType=lib
 
 #------------------------------------------------------------------------------
 # run from third-party directory only
-- 
GitLab


From f8e0b17acbb660c97697efe0ca207d2f2f93b2ec Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 8 Sep 2016 11:28:00 +0200
Subject: [PATCH 34/40] ENH: provide makeParaView.example (mpi + mesa)

- an example of compiling for pvserver

- make upper-limit on MPI processes command-line configurable for
  makeParaView and add MPI support into makeVTK
---
 etc/tools/ParaView3Functions |  4 ++--
 etc/tools/ParaViewFunctions  |  9 ++++++---
 makeParaView                 |  7 +++++++
 makeParaView.example         | 13 +++++++++++++
 makeVTK                      | 22 +++++++++++++++++++++-
 makeVTK.example              |  3 ++-
 6 files changed, 51 insertions(+), 7 deletions(-)
 create mode 100755 makeParaView.example

diff --git a/etc/tools/ParaView3Functions b/etc/tools/ParaView3Functions
index 0ce828d..7a3cd28 100644
--- a/etc/tools/ParaView3Functions
+++ b/etc/tools/ParaView3Functions
@@ -51,10 +51,10 @@ setParaViewDirs()
         exit 1
     }
 
-    # ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION-$OBJ_ADD
+    # 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
+    # ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION${OBJ_ADD:+-$OBJ_ADD}
     ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION
 
     export ParaView_SOURCE_DIR ParaView_BINARY_DIR ParaView_DIR
diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 3150d68..37915f0 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -51,10 +51,10 @@ setParaViewDirs()
         exit 1
     }
 
-    # ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION-$OBJ_ADD
+    # 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
+    # ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION${OBJ_ADD:+-$OBJ_ADD}
     ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION
 
     export ParaView_SOURCE_DIR ParaView_BINARY_DIR ParaView_DIR
@@ -151,7 +151,10 @@ addMpiSupport()
     OBJ_ADD="$OBJ_ADD-mpi"
 
     addCMakeVariable  "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON"
-    addCMakeVariable  "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
+    if [ "${MPI_MAX_PROCS:=0}" -gt 1 ]
+    then
+        addCMakeVariable  "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
+    fi
 }
 
 
diff --git a/makeParaView b/makeParaView
index d571eb3..3164fde 100755
--- a/makeParaView
+++ b/makeParaView
@@ -56,6 +56,7 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 # ~~~~~~~~~~~~~
 
 # MPI support:
+# use 0 or unset MPI_MAX_PROCS for no upper-limit
 withMPI=false
 MPI_MAX_PROCS=32
 
@@ -102,6 +103,8 @@ options:
   -gl2              with new rendering backend (if not already enabled)
   -mesa             with mesa (if not already enabled)
   -mpi              with mpi (if not already enabled)
+  -mpi=NPROCS       with mpi and max 'NPROCS' processes. NPROCS=0 for no
+                        upper-limit on processes.
   -python           with python (if not already enabled)
   -cmake PATH       with the cmake version corresponding to the cmake path given
   -qmake PATH       with the Qt version corresponding to the qmake path given
@@ -255,6 +258,10 @@ do
     -mpi)
         withMPI=true
         ;;
+    -mpi=[0-9]*) # mpi and max mpi processes
+        withMPI=true
+        MPI_MAX_PROCS="${1##*=}"
+        ;;
     -no-mpi)
         withMPI=false
         ;;
diff --git a/makeParaView.example b/makeParaView.example
new file mode 100755
index 0000000..e51f240
--- /dev/null
+++ b/makeParaView.example
@@ -0,0 +1,13 @@
+#!/bin/sh
+# An example for building particular combinations of ParaView with
+# - mpi (0 = no upper-limit on processes)
+# - off-screen mesa
+
+mesa=mesa-11.2.2
+
+./makeParaView \
+    -mpi=0 \
+    -mesa-prefix $WM_THIRD_PARTY_DIR/platforms/linux64Gcc/$mesa \
+    "$@"
+
+#------------------------------------------------------------------------------
diff --git a/makeVTK b/makeVTK
index 27eac17..4e084e6 100755
--- a/makeVTK
+++ b/makeVTK
@@ -51,6 +51,11 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 # USER OPTIONS:
 # ~~~~~~~~~~~~~
 
+# MPI support:
+# use 0 or unset MPI_MAX_PROCS for no upper-limit
+withMPI=false
+unset MPI_MAX_PROCS
+
 # MESA graphics support:
 withMESA=false
 MESA_INCLUDE="/usr/include/GL"
@@ -80,6 +85,9 @@ 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)
+  -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 the cmake version corresponding to the cmake path given
   -gcc              force g++ instead of the value from \$WM_CXX
@@ -92,7 +100,7 @@ options:
   -help
 
 The -no-FEATURE option can be disable these features (if not already disabled):
-  mesa
+  mesa mpi
 
 CMake options start with a capital letter and contain an '='.
 For example,
@@ -204,6 +212,16 @@ do
         MESA_LIBRARY="${2%%/}"
         shift
         ;;
+    -mpi)
+        withMPI=true
+        ;;
+    -mpi=[0-9]*) # mpi and max mpi processes
+        withMPI=true
+        MPI_MAX_PROCS="${1##*=}"
+        ;;
+    -no-mpi)
+        withMPI=false
+        ;;
     -cmake)
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
         CMAKE_PATH="${2%%/}"
@@ -256,6 +274,7 @@ fi
 # Set configure options
 #~~~~~~~~~~~~~~~~~~~~~~
 addVerbosity        # verbose makefiles
+addMpiSupport       # set MPI-specific options
 addMesaSupport      # set MESA-specific options
 addGL2Support       # new rendering backend
 
@@ -285,6 +304,7 @@ Build stages selected
 ---------------------
 Features selected
     mesa      ${withMESA:-false}
+    mpi       ${withMPI:-false}
 ---------------------
 Version information
     version   ${VTK_VERSION:-unknown}
diff --git a/makeVTK.example b/makeVTK.example
index 4de6054..ae08225 100755
--- a/makeVTK.example
+++ b/makeVTK.example
@@ -1,5 +1,6 @@
 #!/bin/sh
-# An example for building a particular combinations of VTK with off-screen mesa
+# An example for building particular combinations of VTK with
+# - off-screen mesa
 
 vtk=vtk-7.1.0
 mesa=mesa-11.2.2
-- 
GitLab


From 85180484c3d6d6103ebae6cc2635dc8301130cc0 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 14 Sep 2016 01:12:39 +0200
Subject: [PATCH 35/40] CONFIG: update cmake variables for paraview with python
 (issue #5)

- replace PYTHON_INCLUDE_PATH with PYTHON_INCLUDE_DIRS
  (changed in paraview 2014-10-30)

- add check for Python.h for earlier failure.
  Eg, when development headers are missing on the system.
---
 etc/tools/ParaViewFunctions | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/etc/tools/ParaViewFunctions b/etc/tools/ParaViewFunctions
index 37915f0..c989264 100644
--- a/etc/tools/ParaViewFunctions
+++ b/etc/tools/ParaViewFunctions
@@ -202,7 +202,7 @@ addPythonSupport()
         pythonInclude=/usr/include/python$pythonMajor
 
         # Note - we could also allow for a PYTHON_INCLUDE variable ...
-        [ -d "$pythonInclude" ] || {
+        [ -d "$pythonInclude" -a -f "$pythonInclude/Python.h" ] || {
             echo "    No python headers found in $pythonInclude/"
             echo "    Please install python headers or deactivate "
             echo "    python support by not using the -python option"
@@ -210,7 +210,7 @@ addPythonSupport()
         }
 
         addCMakeVariable  "PARAVIEW_ENABLE_PYTHON=ON"
-        addCMakeVariable  "PYTHON_INCLUDE_PATH=$pythonInclude"
+        addCMakeVariable  "PYTHON_INCLUDE_DIRS=$pythonInclude"
         addCMakeVariable  "PYTHON_LIBRARY=$PYTHON_LIBRARY"
 
         echo "----"
-- 
GitLab


From 375de7066d3e67a02305cf6204fad82d026920d8 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Wed, 14 Sep 2016 09:35:00 +0200
Subject: [PATCH 36/40] COMP: simplify scotch makefiles

As per patch provided by Bruno Santos @wyldckat to support Raspbian.
http://bugs.openfoam.org/view.php?id=2051

STYLE: drop unneeded linkage against old POSIX librt.so
---
 Allwmake                                      |  2 +-
 ...Makefile.inc.i686_pc_linux2.shlib-OpenFOAM | 33 +++++++++++++++++++
 ....inc.i686_pc_linux2.shlib-OpenFOAM-32Int32 | 21 ------------
 ....inc.i686_pc_linux2.shlib-OpenFOAM-64Int32 | 21 ------------
 ....inc.i686_pc_linux2.shlib-OpenFOAM-64Int64 | 21 ------------
 5 files changed, 34 insertions(+), 64 deletions(-)
 create mode 100644 etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
 delete mode 100644 etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-32Int32
 delete mode 100644 etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64Int32
 delete mode 100644 etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64Int64

diff --git a/Allwmake b/Allwmake
index dca63e4..9a8c381 100755
--- a/Allwmake
+++ b/Allwmake
@@ -204,7 +204,7 @@ echo "Build Scotch decomposition library $SCOTCH_VERSION"
 echo "    $SCOTCH_ARCH_PATH"
 
 # this needs generalizing
-scotchMakefile=../../etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-$WM_ARCH_OPTION$WM_LABEL_OPTION
+scotchMakefile=../../etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
 
 if [ -f $SCOTCH_ARCH_PATH/include/scotch.h \
   -a -r $FOAM_EXT_LIBBIN/libscotch.so \
diff --git a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM b/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
new file mode 100644
index 0000000..c90df08
--- /dev/null
+++ b/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
@@ -0,0 +1,33 @@
+# 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
+
+EXE         =
+LIB         = .so
+OBJ         = .o
+
+MAKE        = make
+AR          = gcc
+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
+
+# 32-bit vs. 64-bit labels
+ifeq ($(WM_LABEL_SIZE),64)
+CFLAGS     += -DINTSIZE64
+endif
+
+CLIBFLAGS   = -shared
+LDFLAGS     = -Xlinker --no-as-needed $(WM_LDFLAGS) -lz -lm
+CP          = cp
+LEX         = flex -Pscotchyy -olex.yy.c
+LN          = ln
+MKDIR       = mkdir
+MV          = mv
+RANLIB      = echo
+YACC        = bison -pscotchyy -y -b y
diff --git a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-32Int32 b/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-32Int32
deleted file mode 100644
index 62fec4c..0000000
--- a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-32Int32
+++ /dev/null
@@ -1,21 +0,0 @@
-EXE		=
-LIB		= .so
-OBJ		= .o
-
-MAKE		= make
-AR		= gcc
-ARFLAGS		= -m32 -shared -o
-CAT		= cat
-CCS		= gcc
-CCP		= mpicc
-CCD		= mpicc
-CFLAGS		= -m32 -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict
-CLIBFLAGS	= -shared -fPIC
-LDFLAGS		= -Xlinker --no-as-needed -L$MPI_ARCH_PATH/lib -m32 -lz -lm -lrt
-CP		= cp
-LEX		= flex -Pscotchyy -olex.yy.c
-LN		= ln
-MKDIR		= mkdir
-MV		= mv
-RANLIB		= echo
-YACC		= bison -pscotchyy -y -b y
diff --git a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64Int32 b/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64Int32
deleted file mode 100644
index 0598d56..0000000
--- a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64Int32
+++ /dev/null
@@ -1,21 +0,0 @@
-EXE		=
-LIB		= .so
-OBJ		= .o
-
-MAKE		= make
-AR		= gcc
-ARFLAGS		= -shared -o
-CAT		= cat
-CCS		= gcc
-CCP		= mpicc
-CCD		= mpicc
-CFLAGS		= -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict
-CLIBFLAGS	= -shared -fPIC
-LDFLAGS		= -Xlinker --no-as-needed -lz -lm -lrt
-CP		= cp
-LEX		= flex -Pscotchyy -olex.yy.c
-LN		= ln
-MKDIR		= mkdir
-MV		= mv
-RANLIB		= echo
-YACC		= bison -pscotchyy -y -b y
diff --git a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64Int64 b/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64Int64
deleted file mode 100644
index fe285a2..0000000
--- a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64Int64
+++ /dev/null
@@ -1,21 +0,0 @@
-EXE		=
-LIB		= .so
-OBJ		= .o
-
-MAKE		= make
-AR		= gcc
-ARFLAGS		= -shared -o
-CAT		= cat
-CCS		= gcc
-CCP		= mpicc
-CCD		= mpicc
-CFLAGS		= -O3 -DINTSIZE64 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict
-CLIBFLAGS	= -shared -fPIC
-LDFLAGS		= -Xlinker --no-as-needed -lz -lm -lrt
-CP		= cp
-LEX		= flex -Pscotchyy -olex.yy.c
-LN		= ln
-MKDIR		= mkdir
-MV		= mv
-RANLIB		= echo
-YACC		= bison -pscotchyy -y -b y
-- 
GitLab


From 105e8a0d50695048907926a675df7e99b762e3fb Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 7 Oct 2016 10:57:55 +0200
Subject: [PATCH 37/40] BUG: need -lrt when linking scotch on some systems
 (issue #6)

---
 .../scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 c90df08..8c83e09 100644
--- a/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
+++ b/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
@@ -23,7 +23,7 @@ CFLAGS     += -DINTSIZE64
 endif
 
 CLIBFLAGS   = -shared
-LDFLAGS     = -Xlinker --no-as-needed $(WM_LDFLAGS) -lz -lm
+LDFLAGS     = -Xlinker --no-as-needed $(WM_LDFLAGS) -lz -lm -lrt
 CP          = cp
 LEX         = flex -Pscotchyy -olex.yy.c
 LN          = ln
-- 
GitLab


From d07150e20ede6634876c77631af4d26ef09c5463 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 14 Oct 2016 17:33:29 +0200
Subject: [PATCH 38/40] BUG: Allclean removes platforms/ instead of build/
 (closes #7)

- Now only cleans the build/ directory.

- Add -all, -current options etc for also removing platforms,
  if wishing a complete clean.
---
 Allclean | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 100 insertions(+), 9 deletions(-)

diff --git a/Allclean b/Allclean
index de5c650..22792c1 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  |
+#    \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -23,7 +23,7 @@
 #     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 #
 # Script
-#     AllClean
+#     Allclean
 #
 # Description
 #     Clean script for third-party applications and libraries
@@ -39,24 +39,115 @@ wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
 }
 # . etc/tools/ThirdPartyFunctions
 #------------------------------------------------------------------------------
+Script=${0##*/}
 
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+Usage: $Script [OPTION] [<platform> [ ... <platformN> ]]
+options:
+  -all              remove all platforms directories.
+  -current          clean the current platform ($WM_OPTIONS).
+  -help             print the usage
 
-# clean various packages via 'distclean'
-for i in openmpi-*
+Cleanup intermediate build directories.
+Optionally remove specified platform(s) from the ThirdParty platforms
+directory $WM_THIRD_PARTY_DIR/platforms
+
+USAGE
+    exit 1
+}
+
+# Print help message
+if [ "$1" = "-h" -o "$1" = "-help" ]; then
+    usage
+fi
+
+#------------------------------------------------------------------------------
+
+# Clean various packages via 'distclean'
+for i in openmpi-* ADIOS-*
 do
-    [ -d "$i" ] && ( set -x; cd $i && make distclean )
+    [ -d "$i" ] && (
+        echo
+        echo "${i%/*}"
+        echo "    make distclean"
+        echo
+        cd $i && make distclean
+    )
 done
 
 
-# clean various packages via 'realclean'
+# Clean various packages via 'realclean'
 for i in scotch*/src
 do
-    [ -d "$i" ] && ( set -x; cd $i && make realclean )
+    [ -d "$i" ] && (
+        echo
+        echo "${i%/*}"
+        echo "    make realclean"
+        echo
+        cd $i && make realclean
+    )
 done
 
 
-# clean out-of-source build directories
-[ -d platforms ] && ( set -x; rm -rf platforms/* )
+# Clean out-of-source build directories
+if [ -d build ]
+then
+    echo
+    echo "Clean build/ directory"
+    rm -rf build/*
+fi
+
+# -----------------------------------------------------------------------------
+
+#
+# Clean platforms directories
+#
+if [ "$#" -ge 1 ]
+then
+    echo
+    echo "Clean platforms/sub-directories"
+fi
+
+removePlatform()
+{
+    local platform="$1"
+    if [ -n "$platform" -a -d "platforms/$platform" ]
+    then
+        echo
+        echo "Cleaning platform '$platform'"
+        \rm -rf "platforms/$platform"
+    else
+        echo
+        echo "Platform '$platform' not built"
+    fi
+}
+
 
+# Optionally cleanup platforms specified from the arguments
+while [ "$#" -ge 1 ]
+do
+    case "$1" in
+    -all)
+        echo
+        echo "Removing all platforms/sub-directories"
+        echo
+        \rm -rf platforms/*
+        break
+        ;;
+
+    -current)
+        echo "Current platform '$WM_OPTIONS'"
+        removePlatform "$WM_OPTIONS"
+        ;;
+
+    *)
+        removePlatform "$1"
+        ;;
+    esac
+    shift
+done
 
 #------------------------------------------------------------------------------
-- 
GitLab


From 26dc62a51f264cbde5db7f8c2d2f0273c10a4736 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Thu, 3 Nov 2016 16:13:08 +0100
Subject: [PATCH 39/40] MISC: update README to foundation information

---
 README.org    |   1 +
 README_scotch | 543 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 544 insertions(+)
 create mode 100644 README_scotch

diff --git a/README.org b/README.org
index c7b0ebb..88768f6 100644
--- a/README.org
+++ b/README.org
@@ -42,6 +42,7 @@
     but may need patching to compile (See [[Notes]]).
 *** CGAL
     + CGAL        https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.8/CGAL-4.8.tar.xz
+    + CGAL        https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.8.1/CGAL-4.8.1.tar.xz
     + boost       https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.bz2/download
 *** Miscellaneous
     + FFTW        http://www.fftw.org/fftw-3.3.4.tar.gz
diff --git a/README_scotch b/README_scotch
new file mode 100644
index 0000000..f61dec9
--- /dev/null
+++ b/README_scotch
@@ -0,0 +1,543 @@
+OpenFOAM uses shared object libraries from the Scotch/PT-Scotch software:
+https://www.labri.fr/perso/pelegrin/scotch/
+
+The software is licensed under the CeCILL-C Free Software Licence
+Agreement, a copy of which is reproduced below.
+
+Please note the limitation of both the Licensor's warranty and liability
+as set forth in Articles 8 and 9 of the Agreement.
+
+If only the object libraries of Scotch are provided, the full source code
+can be obtained from:
+
+http://gforge.inria.fr/projects/scotch/
+    Home page of the SCOTCH project repository.
+
+http://gforge.inria.fr/frs/?group_id=248
+    File download section of the SCOTCH project repository,
+    where source tarballs can be downloaded from.
+
+http://gforge.inria.fr/scm/?group_id=248
+    Source code repository of the SCOTCH project.
+
+http://gforge.inria.fr/docman/?group_id=248
+    Documentation regarding the SCOTCH project.
+
+---
+
+CeCILL-C FREE SOFTWARE LICENSE AGREEMENT
+
+
+    Notice
+
+This Agreement is a Free Software license agreement that is the result
+of discussions between its authors in order to ensure compliance with
+the two main principles guiding its drafting:
+
+    * firstly, compliance with the principles governing the distribution
+      of Free Software: access to source code, broad rights granted to
+      users,
+    * secondly, the election of a governing law, French law, with which
+      it is conformant, both as regards the law of torts and
+      intellectual property law, and the protection that it offers to
+      both authors and holders of the economic rights over software.
+
+The authors of the CeCILL-C (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre])
+license are:
+
+Commissariat � l'Energie Atomique - CEA, a public scientific, technical
+and industrial research establishment, having its principal place of
+business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France.
+
+Centre National de la Recherche Scientifique - CNRS, a public scientific
+and technological establishment, having its principal place of business
+at 3 rue Michel-Ange, 75794 Paris cedex 16, France.
+
+Institut National de Recherche en Informatique et en Automatique -
+INRIA, a public scientific and technological establishment, having its
+principal place of business at Domaine de Voluceau, Rocquencourt, BP
+105, 78153 Le Chesnay cedex, France.
+
+
+    Preamble
+
+The purpose of this Free Software license agreement is to grant users
+the right to modify and re-use the software governed by this license.
+
+The exercising of this right is conditional upon the obligation to make
+available to the community the modifications made to the source code of
+the software so as to contribute to its evolution.
+
+In consideration of access to the source code and the rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty and the software's author, the holder of the
+economic rights, and the successive licensors only have limited liability.
+
+In this respect, the risks associated with loading, using, modifying
+and/or developing or reproducing the software by the user are brought to
+the user's attention, given its Free Software status, which may make it
+complicated to use, with the result that its use is reserved for
+developers and experienced professionals having in-depth computer
+knowledge. Users are therefore encouraged to load and test the
+suitability of the software as regards their requirements in conditions
+enabling the security of their systems and/or data to be ensured and,
+more generally, to use and operate it in the same conditions of
+security. This Agreement may be freely reproduced and published,
+provided it is not altered, and that no provisions are either added or
+removed herefrom.
+
+This Agreement may apply to any or all software for which the holder of
+the economic rights decides to submit the use thereof to its provisions.
+
+
+    Article 1 - DEFINITIONS
+
+For the purpose of this Agreement, when the following expressions
+commence with a capital letter, they shall have the following meaning:
+
+Agreement: means this license agreement, and its possible subsequent
+versions and annexes.
+
+Software: means the software in its Object Code and/or Source Code form
+and, where applicable, its documentation, "as is" when the Licensee
+accepts the Agreement.
+
+Initial Software: means the Software in its Source Code and possibly its
+Object Code form and, where applicable, its documentation, "as is" when
+it is first distributed under the terms and conditions of the Agreement.
+
+Modified Software: means the Software modified by at least one
+Integrated Contribution.
+
+Source Code: means all the Software's instructions and program lines to
+which access is required so as to modify the Software.
+
+Object Code: means the binary files originating from the compilation of
+the Source Code.
+
+Holder: means the holder(s) of the economic rights over the Initial
+Software.
+
+Licensee: means the Software user(s) having accepted the Agreement.
+
+Contributor: means a Licensee having made at least one Integrated
+Contribution.
+
+Licensor: means the Holder, or any other individual or legal entity, who
+distributes the Software under the Agreement.
+
+Integrated Contribution: means any or all modifications, corrections,
+translations, adaptations and/or new functions integrated into the
+Source Code by any or all Contributors.
+
+Related Module: means a set of sources files including their
+documentation that, without modification to the Source Code, enables
+supplementary functions or services in addition to those offered by the
+Software.
+
+Derivative Software: means any combination of the Software, modified or
+not, and of a Related Module.
+
+Parties: mean both the Licensee and the Licensor.
+
+These expressions may be used both in singular and plural form.
+
+
+    Article 2 - PURPOSE
+
+The purpose of the Agreement is the grant by the Licensor to the
+Licensee of a non-exclusive, transferable and worldwide license for the
+Software as set forth in Article 5 hereinafter for the whole term of the
+protection granted by the rights over said Software.
+
+
+    Article 3 - ACCEPTANCE
+
+3.1 The Licensee shall be deemed as having accepted the terms and
+conditions of this Agreement upon the occurrence of the first of the
+following events:
+
+    * (i) loading the Software by any or all means, notably, by
+      downloading from a remote server, or by loading from a physical
+      medium;
+    * (ii) the first time the Licensee exercises any of the rights
+      granted hereunder.
+
+3.2 One copy of the Agreement, containing a notice relating to the
+characteristics of the Software, to the limited warranty, and to the
+fact that its use is restricted to experienced users has been provided
+to the Licensee prior to its acceptance as set forth in Article 3.1
+hereinabove, and the Licensee hereby acknowledges that it has read and
+understood it.
+
+
+    Article 4 - EFFECTIVE DATE AND TERM
+
+
+      4.1 EFFECTIVE DATE
+
+The Agreement shall become effective on the date when it is accepted by
+the Licensee as set forth in Article 3.1.
+
+
+      4.2 TERM
+
+The Agreement shall remain in force for the entire legal term of
+protection of the economic rights over the Software.
+
+
+    Article 5 - SCOPE OF RIGHTS GRANTED
+
+The Licensor hereby grants to the Licensee, who accepts, the following
+rights over the Software for any or all use, and for the term of the
+Agreement, on the basis of the terms and conditions set forth hereinafter.
+
+Besides, if the Licensor owns or comes to own one or more patents
+protecting all or part of the functions of the Software or of its
+components, the Licensor undertakes not to enforce the rights granted by
+these patents against successive Licensees using, exploiting or
+modifying the Software. If these patents are transferred, the Licensor
+undertakes to have the transferees subscribe to the obligations set
+forth in this paragraph.
+
+
+      5.1 RIGHT OF USE
+
+The Licensee is authorized to use the Software, without any limitation
+as to its fields of application, with it being hereinafter specified
+that this comprises:
+
+   1. permanent or temporary reproduction of all or part of the Software
+      by any or all means and in any or all form.
+
+   2. loading, displaying, running, or storing the Software on any or
+      all medium.
+
+   3. entitlement to observe, study or test its operation so as to
+      determine the ideas and principles behind any or all constituent
+      elements of said Software. This shall apply when the Licensee
+      carries out any or all loading, displaying, running, transmission
+      or storage operation as regards the Software, that it is entitled
+      to carry out hereunder.
+
+
+      5.2 RIGHT OF MODIFICATION
+
+The right of modification includes the right to translate, adapt,
+arrange, or make any or all modifications to the Software, and the right
+to reproduce the resulting software. It includes, in particular, the
+right to create a Derivative Software.
+
+The Licensee is authorized to make any or all modification to the
+Software provided that it includes an explicit notice that it is the
+author of said modification and indicates the date of the creation thereof.
+
+
+      5.3 RIGHT OF DISTRIBUTION
+
+In particular, the right of distribution includes the right to publish,
+transmit and communicate the Software to the general public on any or
+all medium, and by any or all means, and the right to market, either in
+consideration of a fee, or free of charge, one or more copies of the
+Software by any means.
+
+The Licensee is further authorized to distribute copies of the modified
+or unmodified Software to third parties according to the terms and
+conditions set forth hereinafter.
+
+
+        5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION
+
+The Licensee is authorized to distribute true copies of the Software in
+Source Code or Object Code form, provided that said distribution
+complies with all the provisions of the Agreement and is accompanied by:
+
+   1. a copy of the Agreement,
+
+   2. a notice relating to the limitation of both the Licensor's
+      warranty and liability as set forth in Articles 8 and 9,
+
+and that, in the event that only the Object Code of the Software is
+redistributed, the Licensee allows effective access to the full Source
+Code of the Software at a minimum during the entire period of its
+distribution of the Software, it being understood that the additional
+cost of acquiring the Source Code shall not exceed the cost of
+transferring the data.
+
+
+        5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE
+
+When the Licensee makes an Integrated Contribution to the Software, the
+terms and conditions for the distribution of the resulting Modified
+Software become subject to all the provisions of this Agreement.
+
+The Licensee is authorized to distribute the Modified Software, in
+source code or object code form, provided that said distribution
+complies with all the provisions of the Agreement and is accompanied by:
+
+   1. a copy of the Agreement,
+
+   2. a notice relating to the limitation of both the Licensor's
+      warranty and liability as set forth in Articles 8 and 9,
+
+and that, in the event that only the object code of the Modified
+Software is redistributed, the Licensee allows effective access to the
+full source code of the Modified Software at a minimum during the entire
+period of its distribution of the Modified Software, it being understood
+that the additional cost of acquiring the source code shall not exceed
+the cost of transferring the data.
+
+
+        5.3.3 DISTRIBUTION OF DERIVATIVE SOFTWARE
+
+When the Licensee creates Derivative Software, this Derivative Software
+may be distributed under a license agreement other than this Agreement,
+subject to compliance with the requirement to include a notice
+concerning the rights over the Software as defined in Article 6.4.
+In the event the creation of the Derivative Software required modification
+of the Source Code, the Licensee undertakes that:
+
+   1. the resulting Modified Software will be governed by this Agreement,
+   2. the Integrated Contributions in the resulting Modified Software
+      will be clearly identified and documented,
+   3. the Licensee will allow effective access to the source code of the
+      Modified Software, at a minimum during the entire period of
+      distribution of the Derivative Software, such that such
+      modifications may be carried over in a subsequent version of the
+      Software; it being understood that the additional cost of
+      purchasing the source code of the Modified Software shall not
+      exceed the cost of transferring the data.
+
+
+        5.3.4 COMPATIBILITY WITH THE CeCILL LICENSE
+
+When a Modified Software contains an Integrated Contribution subject to
+the CeCILL license agreement, or when a Derivative Software contains a
+Related Module subject to the CeCILL license agreement, the provisions
+set forth in the third item of Article 6.4 are optional.
+
+
+    Article 6 - INTELLECTUAL PROPERTY
+
+
+      6.1 OVER THE INITIAL SOFTWARE
+
+The Holder owns the economic rights over the Initial Software. Any or
+all use of the Initial Software is subject to compliance with the terms
+and conditions under which the Holder has elected to distribute its work
+and no one shall be entitled to modify the terms and conditions for the
+distribution of said Initial Software.
+
+The Holder undertakes that the Initial Software will remain ruled at
+least by this Agreement, for the duration set forth in Article 4.2.
+
+
+      6.2 OVER THE INTEGRATED CONTRIBUTIONS
+
+The Licensee who develops an Integrated Contribution is the owner of the
+intellectual property rights over this Contribution as defined by
+applicable law.
+
+
+      6.3 OVER THE RELATED MODULES
+
+The Licensee who develops a Related Module is the owner of the
+intellectual property rights over this Related Module as defined by
+applicable law and is free to choose the type of agreement that shall
+govern its distribution under the conditions defined in Article 5.3.3.
+
+
+      6.4 NOTICE OF RIGHTS
+
+The Licensee expressly undertakes:
+
+   1. not to remove, or modify, in any manner, the intellectual property
+      notices attached to the Software;
+
+   2. to reproduce said notices, in an identical manner, in the copies
+      of the Software modified or not;
+
+   3. to ensure that use of the Software, its intellectual property
+      notices and the fact that it is governed by the Agreement is
+      indicated in a text that is easily accessible, specifically from
+      the interface of any Derivative Software.
+
+The Licensee undertakes not to directly or indirectly infringe the
+intellectual property rights of the Holder and/or Contributors on the
+Software and to take, where applicable, vis-�-vis its staff, any and all
+measures required to ensure respect of said intellectual property rights
+of the Holder and/or Contributors.
+
+
+    Article 7 - RELATED SERVICES
+
+7.1 Under no circumstances shall the Agreement oblige the Licensor to
+provide technical assistance or maintenance services for the Software.
+
+However, the Licensor is entitled to offer this type of services. The
+terms and conditions of such technical assistance, and/or such
+maintenance, shall be set forth in a separate instrument. Only the
+Licensor offering said maintenance and/or technical assistance services
+shall incur liability therefor.
+
+7.2 Similarly, any Licensor is entitled to offer to its licensees, under
+its sole responsibility, a warranty, that shall only be binding upon
+itself, for the redistribution of the Software and/or the Modified
+Software, under terms and conditions that it is free to decide. Said
+warranty, and the financial terms and conditions of its application,
+shall be subject of a separate instrument executed between the Licensor
+and the Licensee.
+
+
+    Article 8 - LIABILITY
+
+8.1 Subject to the provisions of Article 8.2, the Licensee shall be
+entitled to claim compensation for any direct loss it may have suffered
+from the Software as a result of a fault on the part of the relevant
+Licensor, subject to providing evidence thereof.
+
+8.2 The Licensor's liability is limited to the commitments made under
+this Agreement and shall not be incurred as a result of in particular:
+(i) loss due the Licensee's total or partial failure to fulfill its
+obligations, (ii) direct or consequential loss that is suffered by the
+Licensee due to the use or performance of the Software, and (iii) more
+generally, any consequential loss. In particular the Parties expressly
+agree that any or all pecuniary or business loss (i.e. loss of data,
+loss of profits, operating loss, loss of customers or orders,
+opportunity cost, any disturbance to business activities) or any or all
+legal proceedings instituted against the Licensee by a third party,
+shall constitute consequential loss and shall not provide entitlement to
+any or all compensation from the Licensor.
+
+
+    Article 9 - WARRANTY
+
+9.1 The Licensee acknowledges that the scientific and technical
+state-of-the-art when the Software was distributed did not enable all
+possible uses to be tested and verified, nor for the presence of
+possible defects to be detected. In this respect, the Licensee's
+attention has been drawn to the risks associated with loading, using,
+modifying and/or developing and reproducing the Software which are
+reserved for experienced users.
+
+The Licensee shall be responsible for verifying, by any or all means,
+the suitability of the product for its requirements, its good working
+order, and for ensuring that it shall not cause damage to either persons
+or properties.
+
+9.2 The Licensor hereby represents, in good faith, that it is entitled
+to grant all the rights over the Software (including in particular the
+rights set forth in Article 5).
+
+9.3 The Licensee acknowledges that the Software is supplied "as is" by
+the Licensor without any other express or tacit warranty, other than
+that provided for in Article 9.2 and, in particular, without any warranty
+as to its commercial value, its secured, safe, innovative or relevant
+nature.
+
+Specifically, the Licensor does not warrant that the Software is free
+from any error, that it will operate without interruption, that it will
+be compatible with the Licensee's own equipment and software
+configuration, nor that it will meet the Licensee's requirements.
+
+9.4 The Licensor does not either expressly or tacitly warrant that the
+Software does not infringe any third party intellectual property right
+relating to a patent, software or any other property right. Therefore,
+the Licensor disclaims any and all liability towards the Licensee
+arising out of any or all proceedings for infringement that may be
+instituted in respect of the use, modification and redistribution of the
+Software. Nevertheless, should such proceedings be instituted against
+the Licensee, the Licensor shall provide it with technical and legal
+assistance for its defense. Such technical and legal assistance shall be
+decided on a case-by-case basis between the relevant Licensor and the
+Licensee pursuant to a memorandum of understanding. The Licensor
+disclaims any and all liability as regards the Licensee's use of the
+name of the Software. No warranty is given as regards the existence of
+prior rights over the name of the Software or as regards the existence
+of a trademark.
+
+
+    Article 10 - TERMINATION
+
+10.1 In the event of a breach by the Licensee of its obligations
+hereunder, the Licensor may automatically terminate this Agreement
+thirty (30) days after notice has been sent to the Licensee and has
+remained ineffective.
+
+10.2 A Licensee whose Agreement is terminated shall no longer be
+authorized to use, modify or distribute the Software. However, any
+licenses that it may have granted prior to termination of the Agreement
+shall remain valid subject to their having been granted in compliance
+with the terms and conditions hereof.
+
+
+    Article 11 - MISCELLANEOUS
+
+
+      11.1 EXCUSABLE EVENTS
+
+Neither Party shall be liable for any or all delay, or failure to
+perform the Agreement, that may be attributable to an event of force
+majeure, an act of God or an outside cause, such as defective
+functioning or interruptions of the electricity or telecommunications
+networks, network paralysis following a virus attack, intervention by
+government authorities, natural disasters, water damage, earthquakes,
+fire, explosions, strikes and labor unrest, war, etc.
+
+11.2 Any failure by either Party, on one or more occasions, to invoke
+one or more of the provisions hereof, shall under no circumstances be
+interpreted as being a waiver by the interested Party of its right to
+invoke said provision(s) subsequently.
+
+11.3 The Agreement cancels and replaces any or all previous agreements,
+whether written or oral, between the Parties and having the same
+purpose, and constitutes the entirety of the agreement between said
+Parties concerning said purpose. No supplement or modification to the
+terms and conditions hereof shall be effective as between the Parties
+unless it is made in writing and signed by their duly authorized
+representatives.
+
+11.4 In the event that one or more of the provisions hereof were to
+conflict with a current or future applicable act or legislative text,
+said act or legislative text shall prevail, and the Parties shall make
+the necessary amendments so as to comply with said act or legislative
+text. All other provisions shall remain effective. Similarly, invalidity
+of a provision of the Agreement, for any reason whatsoever, shall not
+cause the Agreement as a whole to be invalid.
+
+
+      11.5 LANGUAGE
+
+The Agreement is drafted in both French and English and both versions
+are deemed authentic.
+
+
+    Article 12 - NEW VERSIONS OF THE AGREEMENT
+
+12.1 Any person is authorized to duplicate and distribute copies of this
+Agreement.
+
+12.2 So as to ensure coherence, the wording of this Agreement is
+protected and may only be modified by the authors of the License, who
+reserve the right to periodically publish updates or new versions of the
+Agreement, each with a separate number. These subsequent versions may
+address new issues encountered by Free Software.
+
+12.3 Any Software distributed under a given version of the Agreement may
+only be subsequently distributed under the same version of the Agreement
+or a subsequent version.
+
+
+    Article 13 - GOVERNING LAW AND JURISDICTION
+
+13.1 The Agreement is governed by French law. The Parties agree to
+endeavor to seek an amicable solution to any disagreements or disputes
+that may arise during the performance of the Agreement.
+
+13.2 Failing an amicable solution within two (2) months as from their
+occurrence, and unless emergency proceedings are necessary, the
+disagreements or disputes shall be referred to the Paris Courts having
+jurisdiction, by the more diligent Party.
+
+
+Version 1.0 dated 2006-09-05.
-- 
GitLab


From 5bfb563dccff9dc157c03f35e44a53fc2965aca2 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 4 Nov 2016 08:31:51 +0100
Subject: [PATCH 40/40] ERRATA: add missing vtkFunctions file

- should have been in commit cd07d9f6bcbec816dfc5
---
 etc/tools/vtkFunctions | 204 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 204 insertions(+)
 create mode 100644 etc/tools/vtkFunctions

diff --git a/etc/tools/vtkFunctions b/etc/tools/vtkFunctions
new file mode 100644
index 0000000..a87e4e0
--- /dev/null
+++ b/etc/tools/vtkFunctions
@@ -0,0 +1,204 @@
+#---------------------------------*- sh -*-------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2016 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/>.
+#
+# File
+#     etc/tools/vtkFunctions
+#
+# Description
+#     VTK (library) make/install helper functions.
+#     To be loaded *after* etc/tools/ParaViewFunctions
+#
+#------------------------------------------------------------------------------
+
+# buildBASE, installBASE defined from tools/ThirdPartyFunctions
+
+#
+# Where things are or should be put
+#   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_DIR        : location of the installed program
+#
+setVtkDirs()
+{
+    VTK_SOURCE_DIR=$WM_THIRD_PARTY_DIR/VTK-$VTK_VERSION
+
+    [ -d "$VTK_SOURCE_DIR" ] || {
+        echo "did not find VTK-$VTK_VERSION in these directories:"
+        echo "  WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
+        echo
+        echo "abort build"
+        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
+
+    export VTK_SOURCE_DIR VTK_BINARY_DIR VTK_DIR
+
+    echo
+    echo "VTK_SOURCE_DIR=$VTK_SOURCE_DIR"
+    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
+}
+
+
+#
+# Set VTK_VERSION and adjust VTK_MAJOR accordingly
+#
+# $1 can contain something something like 4.4.0, vtk-4.4.0, VTK-4.0.0
+#
+setVtkVersion()
+{
+    [ $# -gt 0 ] || {
+        echo "Error: function setVtkVersion() called without an argument"
+        exit 1
+    }
+
+    VTK_VERSION="${1##*-}"
+
+    # The major version is "<digits>.<digits>"
+    VTK_MAJOR=$(echo $VTK_VERSION | \
+        sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/')
+
+    export VTK_VERSION VTK_MAJOR
+}
+
+
+#------------------------------------------------------------------------------
+
+#
+# Apply source-code patch if possible
+#
+patchVTK()
+{
+    applyPatch "vtk-$VTK_VERSION" "$VTK_SOURCE_DIR"
+}
+
+
+#
+# Configure via cmake, but don't actually build anything
+#
+configVTK()
+{
+    local cmake=$(findCMake)
+
+    # Remove any existing build folder and recreate
+    if [ -d $VTK_BINARY_DIR ]
+    then
+        echo "removing old build directory"
+        echo "    $VTK_BINARY_DIR"
+        rm -rf $VTK_BINARY_DIR
+    fi
+    mkdir -p $VTK_BINARY_DIR
+
+    addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=$buildType"
+
+    cd $VTK_BINARY_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 "    Target         : $VTK_DIR"
+    echo "    Build type     : $buildType"
+    echo "    Cmake          : $cmake"
+    echo "----"
+    echo
+    echo "$cmake" \
+        -DCMAKE_INSTALL_PREFIX:PATH=$VTK_DIR \
+        $CMAKE_VARIABLES \
+        $VTK_SOURCE_DIR
+    echo
+    echo "----"
+    echo
+
+    # Run cmake to create Makefiles
+    $cmake \
+        -DCMAKE_INSTALL_PREFIX:PATH=$VTK_DIR \
+        $CMAKE_VARIABLES \
+        $VTK_SOURCE_DIR
+}
+
+
+#
+# Invoke make
+# also link bin/ to lib/paraview-* for development without installation
+#
+makeVTK()
+{
+    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
+}
+
+
+#
+# Install the program
+#
+installVTK()
+{
+    cd $VTK_BINARY_DIR || exit 1  # Change to build folder
+    echo "    Installing VTK to $VTK_DIR"
+
+    make install
+
+cat<< INFO
+
+    ---
+    Installation complete for vtk-$VTK_VERSION
+    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"
+
+
+#------------------------------------------------------------------------------
-- 
GitLab