From f92862a42c620d17ba722d35f09d2c0eda083525 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Sat, 28 Jan 2017 17:57:13 +0000
Subject: [PATCH] Allwmake: Provides clearer message when OpenFOAM environment
 is not loaded

Patch contributed by Bruno Santos
Resolves patch request https://bugs.openfoam.org/view.php?id=2424
---
 Allwmake                             |  3 ++-
 applications/Allwmake                |  3 ++-
 src/Allwmake                         |  3 ++-
 wmake/scripts/AllwmakeParseArguments | 11 ++++++++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/Allwmake b/Allwmake
index 67c26d0a3d5..3f6a7523d28 100755
--- a/Allwmake
+++ b/Allwmake
@@ -2,8 +2,9 @@
 cd ${0%/*} || exit 1    # Run from this directory
 
 # Parse arguments for library compilation
-. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
+. wmake/scripts/AllwmakeParseArguments
 
+# Perform various checks
 wmakeCheckPwd "$WM_PROJECT_DIR" || {
     echo "Allwmake error: Current directory is not \$WM_PROJECT_DIR"
     echo "    The environment variables are inconsistent with the installation."
diff --git a/applications/Allwmake b/applications/Allwmake
index d851254b23a..2b725832bf0 100755
--- a/applications/Allwmake
+++ b/applications/Allwmake
@@ -2,8 +2,9 @@
 cd ${0%/*} || exit 1    # Run from this directory
 
 # Parse arguments for library compilation
-. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
+. ../wmake/scripts/AllwmakeParseArguments
 
+# Perform various checks
 wmakeCheckPwd "$WM_PROJECT_DIR/applications" || {
     echo "Allwmake error: Current directory is not \$WM_PROJECT_DIR/applications"
     echo "    The environment variables are inconsistent with the installation."
diff --git a/src/Allwmake b/src/Allwmake
index 5e6eedf3fcc..29d16a15288 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -2,8 +2,9 @@
 cd ${0%/*} || exit 1    # Run from this directory
 
 # Parse arguments for library compilation
-. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
+. ../wmake/scripts/AllwmakeParseArguments
 
+# Perform various checks
 wmakeCheckPwd "$WM_PROJECT_DIR/src" || {
     echo "Allwmake error: Current directory is not \$WM_PROJECT_DIR/src"
     echo "    The environment variables are inconsistent with the installation."
diff --git a/wmake/scripts/AllwmakeParseArguments b/wmake/scripts/AllwmakeParseArguments
index a985064effb..0736876adf0 100644
--- a/wmake/scripts/AllwmakeParseArguments
+++ b/wmake/scripts/AllwmakeParseArguments
@@ -2,7 +2,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2014-2016 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2014-2017 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -34,6 +34,15 @@
 #------------------------------------------------------------------------------
 Script=${0##*/}
 
+if [ -z "$WM_PROJECT_DIR" ]
+then
+    echo "$Script error: The OpenFOAM environment is not set."
+    echo "    Check the OpenFOAM entries in your dot-files and source them."
+    echo "    If in doubt, please read:"
+    echo "       http://openfoam.org/download/source/setting-environment"
+    exit 1
+fi
+
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
-- 
GitLab