Commit b8d03dfc authored by Mark Olesen's avatar Mark Olesen

ENH: forward edit of gcc version to foamConfigurePaths

- foamConfigurePaths (1812) now supports a -gcc option.
  Eg,
      foamConfigurePaths -gcc gcc-4.8.5

  This avoids fragile complier versioning that was previously
  hardcoded into the legacyCompile script.
parent 0454b4be
......@@ -270,32 +270,6 @@ sed -n \
#------------------------------------------------------------------------------
# Special treatment for gcc sub-components (needs rethinking)
case "$compilerVERSION" in
Gcc | Gcc48)
gccVERSION=gcc-4.8.5 # match value in config.sh/compiler
;;
Gcc49)
gccVERSION=gcc-4.9.3 # match value in config.sh/compiler
;;
Gcc62)
gccVERSION=gcc-6.2.0 # match value in config.sh/compiler
;;
Gcc63)
gccVERSION=gcc-6.3.0 # match value in config.sh/compiler
;;
Gcc71)
gccVERSION=gcc-7.1.0 # match value in config.sh/compiler
;;
Gcc*)
echo "Error: unconfigured gcc version '$compilerVERSION'"
exit 1 # Really exit, since this must be an input error
;;
esac
# -----------------------------------------------------------------------------
# NO FURTHER EDITING BELOW THIS LINE
#------------------------------------------------------------------------------
# Name of qt source directory is a fixed value
qtSource="qt-everywhere-opensource-src-${qtVERSION##*-}"
......@@ -528,6 +502,58 @@ _ifDifferent()
[ "$#" -eq 3 -a "$2" != "$3" ] && echo "$1 $2"
}
# Function to do replacement on file. Checks if any replacement has been done.
# _inlineSed <file> <regexp> <replacement> <msg>
_inlineSed()
{
local file="$1"
local regexp="$2"
local replacement="$3"
local msg="$4"
local cmd='/^[^#]/s@'"$regexp"'@'"$replacement"'@'
[ -f "$file" ] || {
echo "Missing file: $file"
exit 2 # Fatal
}
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
echo "Failed: ${msg:-replacement} in $file"
return 1
}
[ -n "$msg" ] && echo " $msg ($file)"
return 0
}
# Standard <key> <val> type of replacements.
# replace <file> <key1> <val1> .. <keyN> <valN>
# looks for KEYWORD=.*
replace()
{
local file="$1"
shift
local key val
while [ "$#" -ge 2 ]
do
key=$1
val=$2
shift 2
_inlineSed \
$file \
"$key=.*" \
"$key=$val" \
"Replaced $key setting by '$val'"
done
}
#
# Unpack files and make any adjustments
#
......@@ -570,6 +596,7 @@ unpackAllFiles()
_mvdir "$TPsource" "$TPdirName"
_mvdir ThirdParty-plus "$TPdirName"
echo
cd $INSTALL_DIR/$OFdirName || {
echo "Error: cannot change to $INSTALL_DIR/$OFdirName"
......@@ -585,6 +612,9 @@ unpackAllFiles()
if true
then
# Pre-1812, no -gcc option for foamConfigurePaths
hasOptGcc="$(exec /bin/sh $foamConfigure -help 2>&1 | sed -ne 's/^ *-gcc.*$/true/p')"
# Compiler configuration (already sanity checked much further above)
compilerOpt="-$compilerTypeVERSION $compilerVERSION"
case "$compilerTypeVERSION:$compilerVERSION" in
......@@ -592,6 +622,17 @@ unpackAllFiles()
compilerOpt="$compilerOpt -clang $llvmVERSION"
;;
third:Gcc*)
case "$hasOptGcc:$gccVERSION" in
(true:gcc-[1-9]*)
# Can use the -gcc option, and have gcc-version
compilerOpt="$compilerOpt -gcc $gccVERSION"
;;
(:gcc-[1-9]*)
# Manual edit for gcc-version
echo "Simulated '-gcc $gccVERSION' option manually"
replace etc/config.sh/compiler gcc_version "$gccVERSION"
;;
esac
compilerOpt="$compilerOpt $gmpVERSION $mpfrVERSION $mpcVERSION"
;;
esac
......@@ -607,6 +648,7 @@ unpackAllFiles()
_ifDifferent -fftw $fftwVERSION $fftwDEFAULT
_ifDifferent -scotch $scotchVERSION $scotchDEFAULT
_ifDifferent -kahip $kahipVERSION $kahipDEFAULT
_ifDifferent -metis $metisVERSION $metisDEFAULT
_ifDifferent -openmpi $openmpiVERSION $openmpiDEFAULT
)
......@@ -633,6 +675,7 @@ unpackAllFiles()
_unpackIfDifferent $fftwVERSION $fftwDEFAULT
_unpackIfDifferent $scotchVERSION $scotchDEFAULT
_unpackIfDifferent $kahipVERSION $kahipDEFAULT
_unpackIfDifferent $metisVERSION $metisDEFAULT
_unpackIfDifferent $openmpiVERSION $openmpiDEFAULT
case "$compilerTypeVERSION:$compilerVERSION" in
......
Markdown is supported
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