mirror of
https://develop.openfoam.com/Development/ThirdParty-common.git
synced 2025-12-08 06:57:50 +00:00
BUG: shell quoting needed for dash (fixes #48)
- arguments passed to stripCompilerFlags caused the misbehaviour
This commit is contained in:
@ -6,11 +6,10 @@
|
|||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
# Copyright (C) 2016-2019 OpenCFD Ltd.
|
# Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
# <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
#
|
||||||
# File
|
# File
|
||||||
# etc/tools/ThirdPartyFunctions
|
# etc/tools/ThirdPartyFunctions
|
||||||
@ -57,12 +56,14 @@ fi
|
|||||||
unset BUILD_SUFFIX
|
unset BUILD_SUFFIX
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Service routine to strip out OpenFOAM-specific portions from the compiler
|
# Service routine to strip out OpenFOAM-specific portions from the compiler
|
||||||
# flags (ie, everything after "-DOPENFOAM=...") while retaining '-fPIC'
|
# flags (ie, everything after and including "-DOPENFOAM=...")
|
||||||
|
# while retaining '-fPIC'
|
||||||
|
#
|
||||||
|
# $1 = all flags concatenated as a single string
|
||||||
#
|
#
|
||||||
stripCompilerFlags()
|
stripCompilerFlags()
|
||||||
{
|
{
|
||||||
local input="$@"
|
local flags="${1%-DOPENFOAM=*}" # Strip out OpenFOAM-specific
|
||||||
local flags="${input%-DOPENFOAM=*}" # Strip out OpenFOAM-specific
|
|
||||||
flags="${flags## }" # Trim leading space
|
flags="${flags## }" # Trim leading space
|
||||||
flags="${flags%% }" # Trim trailing space
|
flags="${flags%% }" # Trim trailing space
|
||||||
|
|
||||||
@ -73,9 +74,9 @@ stripCompilerFlags()
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
(*)
|
(*)
|
||||||
case "$input" in
|
case "$1" in
|
||||||
(*-fPIC*)
|
(*-fPIC*)
|
||||||
# Add -fPIC back in (was after the -DOPENFOAM=... content)
|
# Add -fPIC back in (was after -DOPENFOAM=... content)
|
||||||
flags="$flags${flags+ }-fPIC"
|
flags="$flags${flags+ }-fPIC"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -104,11 +105,12 @@ exportCompiler()
|
|||||||
local comp flag
|
local comp flag
|
||||||
|
|
||||||
# C compiler and flags
|
# C compiler and flags
|
||||||
comp="$(wmake -show-c 2>/dev/null)" && \
|
if ! comp="$(wmake -show-c 2>/dev/null)" \
|
||||||
flag="$(wmake -show-cflags 2>/dev/null)" || {
|
|| ! flag="$(wmake -show-cflags 2>/dev/null)"
|
||||||
|
then
|
||||||
comp="$WM_CC"
|
comp="$WM_CC"
|
||||||
flag="$WM_CFLAGS"
|
flag="$WM_CFLAGS"
|
||||||
}
|
fi
|
||||||
|
|
||||||
if test -n "$comp" && command -v "$comp" >/dev/null
|
if test -n "$comp" && command -v "$comp" >/dev/null
|
||||||
then
|
then
|
||||||
@ -117,7 +119,7 @@ exportCompiler()
|
|||||||
then
|
then
|
||||||
case "$option" in
|
case "$option" in
|
||||||
(basic | minimal | strip)
|
(basic | minimal | strip)
|
||||||
flag="$(stripCompilerFlags $flag)"
|
flag="$(stripCompilerFlags "$flag")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
export CFLAGS="$flag"
|
export CFLAGS="$flag"
|
||||||
@ -125,11 +127,12 @@ exportCompiler()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# C++ compiler and flags
|
# C++ compiler and flags
|
||||||
comp="$(wmake -show-cxx 2>/dev/null)" && \
|
if ! comp="$(wmake -show-cxx 2>/dev/null)" \
|
||||||
flag="$(wmake -show-cxxflags 2>/dev/null)" || {
|
|| ! flag="$(wmake -show-cxxflags 2>/dev/null)"
|
||||||
|
then
|
||||||
comp="$WM_CXX"
|
comp="$WM_CXX"
|
||||||
flag="$WM_CXXFLAGS"
|
flag="$WM_CXXFLAGS"
|
||||||
}
|
fi
|
||||||
|
|
||||||
if test -n "$comp" && command -v "$comp" >/dev/null
|
if test -n "$comp" && command -v "$comp" >/dev/null
|
||||||
then
|
then
|
||||||
@ -138,7 +141,7 @@ exportCompiler()
|
|||||||
then
|
then
|
||||||
case "$option" in
|
case "$option" in
|
||||||
(basic | minimal | strip)
|
(basic | minimal | strip)
|
||||||
flag="$(stripCompilerFlags $flag)"
|
flag="$(stripCompilerFlags "$flag")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
export CXXFLAGS="$flag"
|
export CXXFLAGS="$flag"
|
||||||
|
|||||||
Reference in New Issue
Block a user