From 2327162c38f6b85e74be8ce4bf4b5f37413f74b4 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Fri, 5 Apr 2019 15:30:30 +0200
Subject: [PATCH] ENH: provide 'sanitized' values for wmake -show compiler
 information (#1256)

- with the wmake rules we may have some compiler options bound to the
  internal compiler variable. For example,

     CC  = g++ -std=c++11 -m64

     c++FLAGS = ...

  So shift any flags from CC to CXXFLAGS for the output of
  'wmake -show-cxx', 'wmake -show-cxxflags', etc.

  This makes it much easier to handle the values correctly elsewhere.
  Eg,

      CXX="$(wmake -show-cxx)" CXXFLAGS="$(wmake -show-cxxflags)" \
         ./configure
---
 wmake/makefiles/info | 37 +++++++++++++++++++++++++++----------
 wmake/wmake          | 14 ++++++++------
 2 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/wmake/makefiles/info b/wmake/makefiles/info
index 600399a173..c43841dcf7 100644
--- a/wmake/makefiles/info
+++ b/wmake/makefiles/info
@@ -31,6 +31,13 @@ SHELL   = /bin/sh
 .SUFFIXES:
 
 
+#------------------------------------------------------------------------------
+# Some default values
+#------------------------------------------------------------------------------
+
+# Shared library extension (with '.' separator)
+EXT_SO  = .so
+
 #------------------------------------------------------------------------------
 # Compilation rules
 #------------------------------------------------------------------------------
@@ -38,34 +45,44 @@ SHELL   = /bin/sh
 GENERAL_RULES = $(WM_DIR)/rules/General
 include $(GENERAL_RULES)/general
 
+# Commands
+COMPILE_C    := $(strip $(cc) $(cFLAGS))
+COMPILE_CXX  := $(strip $(CC) $(c++FLAGS))
 
 #------------------------------------------------------------------------------
 # Display information
 #------------------------------------------------------------------------------
 
-.PHONY: compile
-compile:
-	@echo "$(strip $(CC) $(c++FLAGS))"
-
 .PHONY: api
 api:
-	@echo "$(WM_VERSION)" | sed -e 's/^.*=//'
+	@echo "$(lastword $(subst =, ,$(WM_VERSION)))"
+
+.PHONY: ext-so
+ext-so:
+	@echo "$(EXT_SO)"
+
+.PHONY: compile-c
+compile-c:
+	@echo "$(COMP_C)"
 
 .PHONY: c
 c:
-	@echo "$(strip $(cc))"
+	@echo "$(firstword $(cc))"
 
 .PHONY: cflags
 cflags:
-	@echo "$(strip $(cFLAGS))"
+	@echo "$(wordlist 2,$(words $(COMPILE_C)), $(COMPILE_C))"
+
+.PHONY: compile-cxx
+compile-cxx:
+	@echo "$(COMPILE_CXX)"
 
 .PHONY: cxx
 cxx:
-	@echo "$(strip $(CC))"
+	@echo "$(firstword $(CC))"
 
 .PHONY: cxxflags
 cxxflags:
-	@echo "$(strip $(c++FLAGS))"
-
+	@echo "$(wordlist 2,$(words $(COMPILE_CXX)), $(COMPILE_CXX))"
 
 #----------------------------- vim: set ft=make: ------------------------------
diff --git a/wmake/wmake b/wmake/wmake
index 20fef12ae3..225f0e780f 100755
--- a/wmake/wmake
+++ b/wmake/wmake
@@ -77,7 +77,11 @@ options:
   -pwd              Print root directory containing a Make/ directory
   -update           Update lnInclude dirs, dep files, remove deprecated files/dirs
   -show-api         Print api value
-  -show-compile     Print C++ compiler value and flags (shortcut: -show)
+  -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
   -h | -help        Print the usage
@@ -136,11 +140,9 @@ do
         -s | -silent)
             export WM_QUIET=true
             ;;
-        -show | -show-compile)
-            $make -f $WM_DIR/makefiles/info compile
-            optShow=true
-            ;;
-        -show-api | -show-cxx | -show-cxxflags | -show-c | -show-cflags)
+        -show-api | -show-ext-so | \
+        -show-compile-c | -show-c | -show-cflags | \
+        -show-compile-cxx | -show-cxx | -show-cxxflags)
             $make -f $WM_DIR/makefiles/info "${1#-show-}"
             optShow=true
             ;;
-- 
GitLab