Commit 51bf7af8 authored by Mark OLESEN's avatar Mark OLESEN Committed by Andrew Heather
Browse files

ENH: support wmake -show options for compiler information (#1256)

- can be useful for retrieving the compilation flags for use with other
  make systems (eg, cmake)

  * wmake -show-compile   (C++ not C)
  * wmake -show-cxx
  * wmake -show-cxxflags
parent baddaee7
......@@ -31,7 +31,7 @@ endif
#------------------------------------------------------------------------------
# Unset suffices list (suffix rules are not used)
# No default suffix rules used
#------------------------------------------------------------------------------
.SUFFIXES:
......
#----------------------------*- makefile-gmake -*------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# File
# wmake/makefiles/info
#
# Description
# Makefile to generate information.
# Used by wmake -show-*
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Use POSIX shell. Default to POSIX for the OS.
#------------------------------------------------------------------------------
SHELL = /bin/sh
#------------------------------------------------------------------------------
# No default suffix rules used
#------------------------------------------------------------------------------
.SUFFIXES:
#------------------------------------------------------------------------------
# Compilation rules
#------------------------------------------------------------------------------
GENERAL_RULES = $(WM_DIR)/rules/General
include $(GENERAL_RULES)/general
#------------------------------------------------------------------------------
# Display information
#------------------------------------------------------------------------------
export WM_VERSION
.PHONY: compile
compile:
@echo "$(strip $(CC) $(c++FLAGS))"
.PHONY: api
api:
@echo "$${WM_VERSION#*=}"
.PHONY: c
c:
@echo "$(strip $(cc))"
.PHONY: cflags
cflags:
@echo "$(strip $(cFLAGS))"
.PHONY: cxx
cxx:
@echo "$(strip $(CC))"
.PHONY: cxxflags
cxxflags:
@echo "$(strip $(c++FLAGS))"
#----------------------------- vim: set ft=make: ------------------------------
......@@ -77,6 +77,11 @@ options:
-pwd Print root directory containing a Make/ directory and exit
-update Update lnInclude directories, dep files, remove deprecated
files and directories
-show Identical to -show-compile
-show-api Print api value and exit
-show-compile Print C++ compiler value/flags and exit
-show-cxx Print C++ compiler value and exit
-show-cxxflags Print C++ compiler flags and exit
-h | -help Print the usage
......@@ -121,7 +126,7 @@ allCores()
#------------------------------------------------------------------------------
# Default to compiling the local target only
unset all update optPrintRootDir
unset all optShow update optPrintRootDir
while [ "$#" -gt 0 ]
do
......@@ -133,6 +138,14 @@ 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)
$make -f $WM_DIR/makefiles/info "${1#-show-}"
optShow=true
;;
-a | -all | all)
all=all
;;
......@@ -147,12 +160,12 @@ do
[ "$nCores" = 0 ] && allCores
export WM_NCOMPPROCS=$nCores
echo "Compiling enabled on $WM_NCOMPPROCS cores"
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
;;
# Parallel compilation on specified number of cores
-j[1-9]*)
export WM_NCOMPPROCS=${1#-j}
echo "Compiling enabled on $WM_NCOMPPROCS cores"
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
;;
# Keep going, ignoring errors
-k | -keep-going | -non-stop)
......@@ -190,6 +203,11 @@ do
shift
done
if [ "$optShow" = true ]
then
exit 0
fi
#------------------------------------------------------------------------------
# Check environment variables
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment