From 3a964c04f3a8792b5807f9809cc5335f22080291 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Sun, 10 Nov 2019 11:24:07 +0100
Subject: [PATCH] COMP: report locations of build tools (such as flex, m4 etc)

- can assist diagnosing when things have gone wrong
---
 Allwmake                 | 16 +++++++++++-----
 bin/foamInstallationTest |  2 +-
 wmake/scripts/list_tools | 41 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 6 deletions(-)
 create mode 100644 wmake/scripts/list_tools

diff --git a/Allwmake b/Allwmake
index c4544892a4f..c5232516253 100755
--- a/Allwmake
+++ b/Allwmake
@@ -11,7 +11,7 @@ cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null || {
     exit 1
 }
 
-. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
+. "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments
 
 #------------------------------------------------------------------------------
 # Preamble. Report compiler version
@@ -19,9 +19,15 @@ case "$WM_COMPILER" in
     Gcc*)    gcc --version 2>/dev/null | sed -ne '1p' ;;
     Clang*)  clang --version 2>/dev/null | sed -ne '1p' ;;
 esac
-# Preamble. Report mpirun location
-command -v mpirun 2>/dev/null || true
 
+# Preamble. Report tools or at least the mpirun location
+if [ -f "$WM_PROJECT_DIR"/wmake/scripts/list_tools ]
+then  . "$WM_PROJECT_DIR"/wmake/scripts/list_tools ]
+else
+    echo "mpirun=$(command -v mpirun || true)"
+fi
+
+echo
 echo "========================================"
 date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown"
 echo "Starting compile ${WM_PROJECT_DIR##*/} ${0##*/}"
@@ -36,7 +42,7 @@ echo
 # Compile ThirdParty libraries and applications
 if [ -d "$WM_THIRD_PARTY_DIR" ]
 then
-    $WM_THIRD_PARTY_DIR/Allwmake
+    "$WM_THIRD_PARTY_DIR/Allwmake"
 else
     echo "No ThirdParty directory found - skipping"
 fi
@@ -57,7 +63,7 @@ then
     echo "========================================"
     echo "Compile OpenFOAM modules"
     echo
-    (cd $WM_PROJECT_DIR/modules 2>/dev/null && wmake -all)
+    (cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all)
 fi
 
 # Count files in given directory. Ignore "Test-*" binaries.
diff --git a/bin/foamInstallationTest b/bin/foamInstallationTest
index 326705c6d02..de9659c7a2a 100755
--- a/bin/foamInstallationTest
+++ b/bin/foamInstallationTest
@@ -241,7 +241,7 @@ reportExecutable()
             | sed -ne 's/flex \([0-9][0-9.]*\).*/\1/p')
         ;;
     wmake)
-        VERSION="$(wmake -show-api 2>/dev/null)"
+        VERSION="$(wmake --version 2>/dev/null)"
         ;;
     *gcc* | *g++*)
         VERSION=$($APP_NAME -v 2>&1 \
diff --git a/wmake/scripts/list_tools b/wmake/scripts/list_tools
new file mode 100644
index 00000000000..2184bc7e33a
--- /dev/null
+++ b/wmake/scripts/list_tools
@@ -0,0 +1,41 @@
+#----------------------------------*-sh-*--------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | www.openfoam.com
+#    \\/     M anipulation  |
+#------------------------------------------------------------------------------
+#     Copyright (C) 2019 OpenCFD Ltd.
+#------------------------------------------------------------------------------
+# License
+#     This file is part of OpenFOAM, licensed under GNU General Public License
+#     <http://www.gnu.org/licenses/>.
+#
+# Script
+#     list_tools
+#
+# Description
+#     List names and paths of some common build-related tools
+#
+# Note
+#     Uses 'true' on all commands to avoid triggering an exit-on-error
+#     issue when sourced
+#
+#------------------------------------------------------------------------------
+
+echo "gcc=$(command -v gcc || true)"
+echo "clang=$(command -v clang || true)"
+echo "mpirun=$(command -v mpirun || true)"
+echo "make=$(command -v make || true)"
+echo "cmake=$(command -v cmake || true)"
+echo "wmake=$(command -v wmake || true)"
+echo "m4=$(command -v m4 || true)"
+## echo "awk=$(command -v awk || true)"
+## echo "sed=$(command -v sed || true)"
+echo "flex=$(command -v flex || true)"
+## echo "bison=$(command -v bison || true)"
+## echo "ragel=$(command -v ragel || true)"
+
+true    # clean exit
+
+#------------------------------------------------------------------------------
-- 
GitLab