From dd78e042fe5ef0134f1d445fc2e411b47712bec8 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@Germany>
Date: Tue, 4 Apr 2017 15:28:42 +0200
Subject: [PATCH] ENH: reduce reliance on FOAM_EXT_LIBBIN during builds

- just check WM_PROJECT_DIR instead.

- provide a fallback value when FOAM_EXT_LIBBIN might actually be needed.

Only strictly need FOAM_EXT_LIBBIN for scotch/metis decomposition, and
when these are actually supplied by ThirdParty.
All other ThirdParty dependencies are referenced by BOOST_ARCH_PATH etc.

Can therefore drop the FOAM_EXT_LIBBIN dependency for VTK-related
things, which do not use scotch/metis anyhow.
---
 Allwmake                                                 | 4 ++--
 applications/Allwmake                                    | 4 ++--
 applications/utilities/mesh/conversion/Optional/Allwmake | 3 +++
 etc/config.sh/ccmio                                      | 4 ++--
 src/Allwmake                                             | 4 ++--
 src/fvAgglomerationMethods/Allwmake                      | 3 +++
 src/parallel/decompose/Allwmake                          | 3 +++
 7 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/Allwmake b/Allwmake
index 158d10ad429..b9cfa95a5eb 100755
--- a/Allwmake
+++ b/Allwmake
@@ -5,8 +5,8 @@ cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null || {
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
-[ -n "$FOAM_EXT_LIBBIN" ] || {
-    echo "Error (${0##*/}) : FOAM_EXT_LIBBIN not set"
+[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
+    echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
diff --git a/applications/Allwmake b/applications/Allwmake
index e78e590f9c7..88211f13065 100755
--- a/applications/Allwmake
+++ b/applications/Allwmake
@@ -5,8 +5,8 @@ cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR/applications" 2>/dev/null || {
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
-[ -n "$FOAM_EXT_LIBBIN" ] || {
-    echo "Error (${0##*/}) : FOAM_EXT_LIBBIN not set"
+[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
+    echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake
index 6781cb71c65..3fcc6f474b5 100755
--- a/applications/utilities/mesh/conversion/Optional/Allwmake
+++ b/applications/utilities/mesh/conversion/Optional/Allwmake
@@ -22,6 +22,9 @@ fi
 # Build libccmio (.a|.so) - use static linkage for fewer issues
 $WM_THIRD_PARTY_DIR/makeCCMIO lib
 
+: ${FOAM_EXT_LIBBIN:=/usr/lib$WM_COMPILER_LIB_ARCH}  # Extra safety
+export FOAM_EXT_LIBBIN
+
 if [ -e $CCMIO_ARCH_PATH/include/libccmio/ccmio.h \
   -a \( -e $CCMIO_ARCH_PATH/lib/libccmio.a -o -e $FOAM_EXT_LIBBIN/libccmio.so \) ]
 then
diff --git a/etc/config.sh/ccmio b/etc/config.sh/ccmio
index 28e7334e8e2..782dcb77028 100644
--- a/etc/config.sh/ccmio
+++ b/etc/config.sh/ccmio
@@ -28,8 +28,8 @@
 #     Setup file for libccmio include/libraries.
 #     Sourced during wmake process only.
 #
-#     Dynamic libraries are found under the FOAM_EXT_LIBBIN path.
-#     Static libraries  are found under the CCMIO_ARCH_PATH/lib path.
+#     Static libraries (recommended) are found under CCMIO_ARCH_PATH/lib.
+#     Dynamic libraries are found under FOAM_EXT_LIBBIN path.
 #
 # Note
 #     A csh version is not needed, since the values here are only sourced
diff --git a/src/Allwmake b/src/Allwmake
index f668d9db048..a8e7b02ac23 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -5,8 +5,8 @@ cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR/src" 2>/dev/null || {
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
-[ -n "$FOAM_EXT_LIBBIN" ] || {
-    echo "Error (${0##*/}) : FOAM_EXT_LIBBIN not set"
+[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
+    echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
     echo "    Check your OpenFOAM environment and installation"
     exit 1
 }
diff --git a/src/fvAgglomerationMethods/Allwmake b/src/fvAgglomerationMethods/Allwmake
index dcef4328c21..c92771048a6 100755
--- a/src/fvAgglomerationMethods/Allwmake
+++ b/src/fvAgglomerationMethods/Allwmake
@@ -4,6 +4,9 @@ cd ${0%/*} || exit 1    # Run from this directory
 # Parse arguments for library compilation
 . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
 
+: ${FOAM_EXT_LIBBIN:=/usr/lib$WM_COMPILER_LIB_ARCH}  # Extra safety
+export FOAM_EXT_LIBBIN
+
 export ParMGridGen=$WM_THIRD_PARTY_DIR/ParMGridGen-1.0
 
 if [ -e "$FOAM_LIBBIN/libMGridGen.so" ]
diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake
index 19257df5459..b29e68ce29d 100755
--- a/src/parallel/decompose/Allwmake
+++ b/src/parallel/decompose/Allwmake
@@ -4,6 +4,9 @@ cd ${0%/*} || exit 1    # Run from this directory
 # Parse arguments for library compilation
 . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
 
+: ${FOAM_EXT_LIBBIN:=/usr/lib$WM_COMPILER_LIB_ARCH}  # Extra safety
+export FOAM_EXT_LIBBIN
+
 # Test for metis.
 # - return 0 and export METIS_ARCH_PATH on success
 hasMetis()
-- 
GitLab