From f18bd2720b6ed6a726c24cb194a2f7863a42c7af Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 6 Aug 2020 17:50:44 +0200
Subject: [PATCH] BUG: directory information spoils "wmake -show-cxx" (fixes
 #1799)

- the various information queries MUST be executed with
  the '--no-print-directory' or risk polluting values
  in the information queries.

  This is mostly seen with the 'canCompile' test for tutorials running
  in parallel.

ENH: add wmake '-show-path-c', '-show-path-cxx' as per 1912 and later
---
 wmake/wmake | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/wmake/wmake b/wmake/wmake
index da80a880162..269183e0d49 100755
--- a/wmake/wmake
+++ b/wmake/wmake
@@ -7,7 +7,7 @@
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 #     Copyright (C) 2011-2016 OpenFOAM Foundation
-#     Copyright (C) 2017-2019 OpenCFD Ltd.
+#     Copyright (C) 2017-2020 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -80,14 +80,16 @@ options:
   -update           Update lnInclude dirs, dep files, remove deprecated files/dirs
   -show-api         Print api value
   -show-ext-so      Print shared library extension (with '.' separator)
-  -show-compile-c   Same as '-show-c -show-cflags'
-  -show-compile-cxx Same as '-show-cxx -show-cxxflags'
   -show-c           Print C compiler value
   -show-cflags      Print C compiler flags
   -show-cxx         Print C++ compiler value
   -show-cxxflags    Print C++ compiler flags
   -show-cflags-arch     The C compiler arch flag (eg, -m64 etc)
   -show-cxxflags-arch   The C++ compiler arch flag (eg, -m64 etc)
+  -show-compile-c   Same as '-show-c -show-cflags'
+  -show-compile-cxx Same as '-show-cxx -show-cxxflags'
+  -show-path-c      Print path to C compiler
+  -show-path-cxx    Print path to C++ compiler
   -version | --version  Print the api value
   -h | -help        Print the usage
 
@@ -116,6 +118,8 @@ USAGE
 # Default make is the "make" in the path
 make="make"
 
+# Print compiler/system information (serial only)
+printInfo() { make --no-print-directory -f "$WM_DIR"/makefiles/info "$@"; }
 
 #------------------------------------------------------------------------------
 
@@ -151,7 +155,11 @@ do
         -show-api | -show-ext-so | \
         -show-compile-c   | -show-c   | -show-cflags   | -show-cflags-arch | \
         -show-compile-cxx | -show-cxx | -show-cxxflags | -show-cxxflags-arch )
-            $make -f $WM_DIR/makefiles/info "${1#-show-}"
+            printInfo "${1#-show-}"
+            optShow=true
+            ;;
+        -show-path-c | -show-path-cxx )
+            command -v $(printInfo "${1#-show-path-}")
             optShow=true
             ;;
         -a | -all | all)
@@ -198,7 +206,7 @@ do
             : ${all:=all}  # implies 'all', unless previous set to 'queue' etc.
             ;;
         -version | --version)
-            $make -f $WM_DIR/makefiles/info api
+            printInfo api
             optShow=true
             break;
             ;;
-- 
GitLab