Commit 711ec0e3 authored by Henry Weller's avatar Henry Weller
Browse files

etc/bashrc, etc/config.sh: Updates provided by Bruno Santos:

 1. "foamCompiler" was changed to a more permanent "WM_COMPILER_TYPE"
    environment variable, so that it can be used by 3rd party
    installation scripts, such as "makeGcc", "makeLLVM" and so on. More
    on this will be provided in issue #1215.

 2. The script functions such as "_foamSource()" and "_foamAddPath()"
    were moved to a new file "etc/config.sh/functions". It has the
    ability to set or unset, depending on whether "WM_BASH_FUNCTIONS" is
    defined or not. This allows for these functions to be reused by
    other scripts, such as "makeGcc".

 3. The script "etc/config.sh/CGAL" relies on whether a local
    environment variable "SOURCE_CGAL_VERSIONS_ONLY" is defined or not,
    so that it will load only the version settings if it's defined. This
    is to make it easier to call this script from "makeCGAL". Although
    it still feels a bit of a clunky hack, but I didn't manage to deduce
    any other way we could do this :( I didn't add indentation within
    the if-block, to make it easier to read the changes. In addition,
    the local variable "common_path" is used to shorten the length of
    the lines and use slightly less repeated code.

 4. Added another new script "etc/config.sh/compiler", which has only
    the version numbers for the compilers taken out from the "settings"
    file. It currently depends on "WM_COMPILER_TYPE" for setting the
    variables, the same way it did with "foamCompiler". This script is
    now always sourced from the "settings" file, for the following
    reasons:

   - "makeGCC" and "makeLLVM" can now take advantage of this script file.

   - The example "compiler" script (detailed next) can rely on this
     script file and then override parameters on-demand, as well as
     allowing for system compilers to have dedicated settings, such as
     setting "WM_CC". This is similar to how the example environment
     script for "paraview" works.

 5. To the script "etc/config.sh/example/compiler" were added a few more examples:

   - It now starts with a block where it first loads the default "compiler" script.

   - Has a "WM_COMPILER=Gcc48u" case example for when we try to use GCC
     4.8 in Ubuntu 15.10. This is just to give the idea that in a
     particular system, we might have several system-wide compiler
     versions. For example, in Ubuntu 15.10, there is GCC 4.7, 4.8 and
     5.2, which could be used for testing performances or compatibility
     with some other 3rd party library.

   - Has the "WM_COMPILER=Icc" case example, related to the original bug
     report, where "WM_CC=icc" and "WM_CXX=icpc", so that the user then
     simply copies this file to their own local preferences folder.

 6. Small bug fix in "etc/config.sh/mpi", where unsetting "minBufferSize" was missing at the end of the script.

 7. Small change in "etc/config.sh/paraview", where "CMAKE_ROOT" is set
    along with "CMAKE_HOME". This is due to a rare issue that occurs on
    people's systems where they have a custom system-wide CMake version
    installed and which is used by having "CMAKE_ROOT" set on that
    environment. This can mess up OpenFOAM's custom ParaView builds,
    given that conflicting CMake versions can lead to not building
    ParaView at all.

   - For more details about "CMAKE_ROOT":
     https://cmake.org/Wiki/CMake_Useful_Variables [^]

 8. The scripts "_foamAddPath _foamAddLib _foamAddMan" were not being
    unset at the end of "settings". They are now unset at the end of
    "bashrc", through a call to the new double-use "functions" script.

Additionally all references to "foamCompiler" have been changed to
"WM_COMPILER_TYPE".

See also http://www.openfoam.org/mantisbt/view.php?id=1232
parent 6cc3b057
......@@ -58,8 +58,8 @@ foamInstall=$HOME/$WM_PROJECT
: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
#- Compiler location:
# foamCompiler= system | ThirdParty (OpenFOAM)
foamCompiler=system
# WM_COMPILER_TYPE= system | ThirdParty (OpenFOAM)
export WM_COMPILER_TYPE=system
#- Compiler:
# WM_COMPILER = Gcc | Gcc45 | Gcc46 | Gcc47 | Gcc48 | Gcc49| Clang | Icc
......@@ -137,52 +137,9 @@ fi
# ~~~~~~~~~~~~~~~~~~~~~~
export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
# Source files, possibly with some verbosity
_foamSource()
{
while [ $# -ge 1 ]
do
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
. $1
shift
done
}
# Evaluate command-line parameters
_foamEval()
{
while [ $# -gt 0 ]
do
case "$1" in
-*)
# stray option (not meant for us here) -> get out
break
;;
*=)
# name= -> unset name
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "unset ${1%=}" 1>&2
eval "unset ${1%=}"
;;
*=*)
# name=value -> export name=value
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "export $1" 1>&2
eval "export $1"
;;
*)
# filename: source it
if [ -f "$1" ]
then
_foamSource "$1"
else
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"`
fi
;;
esac
shift
done
}
# Source initialization functions
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. $WM_PROJECT_DIR/etc/config.sh/functions
# Add in preset user or site preferences:
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh`
......@@ -245,9 +202,13 @@ then
fi
# cleanup environment:
# Cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~
unset cleaned foamClean foamInstall foamOldDirs
unset _foamSource _foamEval
# Unload initialization functions:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. $WM_PROJECT_DIR/etc/config.sh/functions
#------------------------------------------------------------------------------
......@@ -32,8 +32,13 @@
boost_version=boost-system
cgal_version=CGAL-4.7
export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version
if [ -z "$SOURCE_CGAL_VERSIONS_ONLY" ]
then
common_path=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
export BOOST_ARCH_PATH=$common_path/$boost_version
export CGAL_ARCH_PATH=$common_path/$cgal_version
if [ "$FOAM_VERBOSE" -a "$PS1" ]
then
......@@ -52,6 +57,8 @@ then
_foamAddLib $BOOST_ARCH_PATH/lib
fi
unset boost_version cgal_version
unset boost_version cgal_version common_path
fi
#------------------------------------------------------------------------------
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# File
# etc/config.sh/compiler
#
# Description
# Startup file for custom compiler versions for OpenFOAM
# Sourced from OpenFOAM-<VERSION>/etc/config.sh/settings
#
#------------------------------------------------------------------------------
case "$WM_COMPILER_TYPE" in
OpenFOAM | ThirdParty)
# Default versions of GMP, MPFR and MPC, override as necessary
gmp_version=gmp-5.1.2
mpfr_version=mpfr-3.1.2
mpc_version=mpc-1.0.1
case "$WM_COMPILER" in
Gcc | Gcc48)
gcc_version=gcc-4.8.5
;;
Gcc45)
gcc_version=gcc-4.5.4
;;
Gcc46)
gcc_version=gcc-4.6.4
;;
Gcc47)
gcc_version=gcc-4.7.4
;;
Gcc49)
gcc_version=gcc-4.9.3
;;
Gcc51)
gcc_version=gcc-5.1.0
;;
Gcc52)
gcc_version=gcc-5.2.0
;;
Gcc53)
gcc_version=gcc-5.3.0
;;
Clang)
# Using clang - not gcc
export WM_CC='clang'
export WM_CXX='clang++'
clang_version=llvm-3.7.0
;;
*)
echo 1>&2
echo "Warning in $WM_PROJECT_DIR/etc/config.sh/compiler:" 1>&2
echo " Unknown OpenFOAM compiler type '$WM_COMPILER'" 1>&2
echo " Please check your settings" 1>&2
echo 1>&2
;;
esac
;;
esac
......@@ -25,12 +25,19 @@
# config.sh/example/compiler
#
# Description
# Example of fine tuning ThirdParty compiler settings for OpenFOAM
# Example of fine tuning compiler versions and settings for OpenFOAM
# Sourced from OpenFOAM-<VERSION>/etc/config.sh/settings
#
#------------------------------------------------------------------------------
# Modified compiler settings
# First load the standard versions, if necessary
foamFile=$($WM_PROJECT_DIR/bin/foamEtcFile -mode o config.sh/compiler \
2>/dev/null)
[ $? -eq 0 ] && _foamSource $foamFile
unset foamFile
# Override compiler settings
case "$WM_COMPILER" in
Gcc46 | Gcc46++0x)
gcc_version=gcc-4.6.0
......@@ -44,6 +51,17 @@ Gcc45 | Gcc45++0x)
mpfr_version=mpfr-2.4.2
mpc_version=mpc-0.8.1
;;
Gcc48u)
# Example of using the system GCC 4.8 in Ubuntu 15.10. Keep in mind you
# will also need to create respective directory in "wmake/rules"
export WM_CC='gcc-4.8'
export WM_CXX='g++-4.8'
;;
Icc)
# Example for ensuring that 3rd software uses the Icc compilers
export WM_CC='icc'
export WM_CXX='icpc'
;;
esac
#------------------------------------------------------------------------------
......@@ -38,7 +38,7 @@
## Specify OpenFOAM ThirdParty compiler
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# foamCompiler=ThirdParty
#WM_COMPILER_TYPE=ThirdParty
## Specify compiler type
## ~~~~~~~~~~~~~~~~~~~~~
......@@ -46,7 +46,7 @@
## Specify system openmpi
## ~~~~~~~~~~~~~~~~~~~~~~
# export WM_MPLIB=SYSTEMOPENMPI
#export WM_MPLIB=SYSTEMOPENMPI
#------------------------------------------------------------------------------
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# File
# etc/config.sh/functions
#
# Description
# Initialization script functions for the bashrc environment
# Sourced from OpenFOAM-<VERSION>/etc/config.sh/bashrc
#
#------------------------------------------------------------------------------
if [ -z "$WM_BASH_FUNCTIONS" ]
then
# Temporary environment variable for automatically (un)loading functions
WM_BASH_FUNCTIONS=loaded
# Source files, possibly with some verbosity
_foamSource()
{
while [ $# -ge 1 ]
do
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
. $1
shift
done
}
# Evaluate command-line parameters
_foamEval()
{
while [ $# -gt 0 ]
do
case "$1" in
-*)
# stray option (not meant for us here) -> get out
break
;;
*=)
# name= -> unset name
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "unset ${1%=}" 1>&2
eval "unset ${1%=}"
;;
*=*)
# name=value -> export name=value
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "export $1" 1>&2
eval "export $1"
;;
*)
# filename: source it
if [ -f "$1" ]
then
_foamSource "$1"
else
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"`
fi
;;
esac
shift
done
}
# Prefix to PATH
_foamAddPath()
{
while [ $# -ge 1 ]
do
export PATH=$1:$PATH
shift
done
}
# Prefix to LD_LIBRARY_PATH
_foamAddLib()
{
while [ $# -ge 1 ]
do
export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
shift
done
}
# Prefix to MANPATH
_foamAddMan()
{
while [ $# -ge 1 ]
do
export MANPATH=$1:$MANPATH
shift
done
}
else
# Cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~
unset WM_BASH_FUNCTIONS
unset _foamAddPath _foamAddLib _foamAddMan
unset _foamSource _foamEval
fi
......@@ -267,4 +267,9 @@ then
fi
export MPI_BUFFER_SIZE
# Cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~
unset minBufferSize
#------------------------------------------------------------------------------
......@@ -49,6 +49,7 @@ do
if [ -r $cmake ]
then
export CMAKE_HOME=$cmake
export CMAKE_ROOT=$cmake
export PATH=$CMAKE_HOME/bin:$PATH
break
fi
......
......@@ -30,37 +30,6 @@
#
#------------------------------------------------------------------------------
# Prefix to PATH
_foamAddPath()
{
while [ $# -ge 1 ]
do
export PATH=$1:$PATH
shift
done
}
# Prefix to LD_LIBRARY_PATH
_foamAddLib()
{
while [ $# -ge 1 ]
do
export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
shift
done
}
# Prefix to MANPATH
_foamAddMan()
{
while [ $# -ge 1 ]
do
export MANPATH=$1:$MANPATH
shift
done
}
#------------------------------------------------------------------------------
# Set environment variables according to system type
export WM_ARCH=`uname -s`
......@@ -233,61 +202,19 @@ unset MPFR_ARCH_PATH GMP_ARCH_PATH
# Location of compiler installation
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ -z "$foamCompiler" ]
if [ -z "$WM_COMPILER_TYPE" ]
then
foamCompiler=system
WM_COMPILER_TYPE=system
echo "Warning in $WM_PROJECT_DIR/etc/config.sh/settings:" 1>&2
echo " foamCompiler not set, using '$foamCompiler'" 1>&2
echo " WM_COMPILER_TYPE not set, using '$WM_COMPILER_TYPE'" 1>&2
fi
case "${foamCompiler}" in
OpenFOAM | ThirdParty)
# Default versions of GMP, MPFR and MPC, overide as necessary
gmp_version=gmp-5.1.2
mpfr_version=mpfr-3.1.2
mpc_version=mpc-1.0.1
case "$WM_COMPILER" in
Gcc | Gcc48)
gcc_version=gcc-4.8.5
;;
Gcc45)
gcc_version=gcc-4.5.4
;;
Gcc46)
gcc_version=gcc-4.6.4
;;
Gcc47)
gcc_version=gcc-4.7.4
;;
Gcc49)
gcc_version=gcc-4.9.3
;;
Gcc51)
gcc_version=gcc-5.1.0
;;
Gcc52)
gcc_version=gcc-5.2.0
;;
Gcc53)
gcc_version=gcc-5.3.0
;;
Clang)
# Using clang - not gcc
export WM_CC='clang'
export WM_CXX='clang++'
clang_version=llvm-3.7.0
;;
*)
echo 1>&2
echo "Warning in $WM_PROJECT_DIR/etc/config.sh/settings:" 1>&2
echo " Unknown OpenFOAM compiler type '$WM_COMPILER'" 1>&2
echo " Please check your settings" 1>&2
echo 1>&2
;;
esac
# Load configured compiler versions, regardless of the compiler type
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler`
# Optional configuration tweaks:
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler`
case "$WM_COMPILER_TYPE" in
OpenFOAM | ThirdParty)
if [ -n "$gcc_version" ]
then
......@@ -303,7 +230,7 @@ OpenFOAM | ThirdParty)
echo " Cannot find $gccDir installation." 1>&2
echo " Please install this compiler version or if you wish to" \
" use the system compiler," 1>&2
echo " change the 'foamCompiler' setting to 'system'" 1>&2
echo " change the 'WM_COMPILER_TYPE' setting to 'system'" 1>&2
echo
}
......@@ -341,7 +268,7 @@ OpenFOAM | ThirdParty)
echo " Cannot find $clangDir installation." 1>&2
echo " Please install this compiler version or if you wish to" \
" use the system compiler," 1>&2
echo " change the 'foamCompiler' setting to 'system'" 1>&2
echo " change the 'WM_COMPILER_TYPE' setting to 'system'" 1>&2
echo 1>&2
}
......@@ -354,15 +281,9 @@ system)
# Use system compiler
;;
*)
echo "Warn: foamCompiler='$foamCompiler' is unsupported" 1>&2
echo "Warn: WM_COMPILER_TYPE='$WM_COMPILER_TYPE' is unsupported" 1>&2
echo " treating as 'system' instead" 1>&2
;;
esac
# Cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~
#keep _foamAddPath _foamAddLib _foamAddMan
unset foamCompiler minBufferSize
#------------------------------------------------------------------------------
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