CONFIG: rationalize compiler tuning

- support prefs.compiler with better possibilities to provide
  overload values

STYLE: reduce code for WM_ARCH_OPTION (seldom-used)
This commit is contained in:
Mark Olesen 2020-11-07 18:11:27 +01:00
parent 67b3c01e13
commit 26ec9b5a17
13 changed files with 191 additions and 186 deletions

29
.gitignore vendored
View File

@ -12,7 +12,7 @@
# File-browser settings - anywhere # File-browser settings - anywhere
.directory .directory
# CVS recovered versions - anywhere # Backup/recovery versions - anywhere
.#* .#*
# Objects and archives - anywhere # Objects and archives - anywhere
@ -23,7 +23,7 @@
# Derived files # Derived files
lex.yy.c lex.yy.c
# Corefiles # Core dumps
core core
# Dependency files - anywhere # Dependency files - anywhere
@ -47,22 +47,21 @@ platforms/
# Reinstate wmake rules that might look like build directories # Reinstate wmake rules that might look like build directories
!/wmake/rules/*/ !/wmake/rules/*/
# doxygen generated documentation # Doxygen generated
doc/Doxygen/html doc/Doxygen/html
doc/Doxygen/latex doc/Doxygen/latex
doc/Doxygen/man doc/Doxygen/man
doc/Doxygen/DTAGS doc/Doxygen/DTAGS
# Generated files in the main directory (e.g. ReleaseNotes-?.?.html) # Generated files in the main and doc directories
# and in the doc directory
/*.html /*.html
/doc/*.html /doc/*.html
# Untracked configuration files # Untracked configuration/preferences files
/etc/prefs.csh /etc/prefs.csh
/etc/prefs.sh /etc/prefs.sh
/etc/config.csh/prefs.csh /etc/config.csh/prefs.*
/etc/config.sh/prefs.sh /etc/config.sh/prefs.*
/wmake/rules/General/mplibUSER* /wmake/rules/General/mplibUSER*
# Source packages - anywhere # Source packages - anywhere
@ -73,19 +72,11 @@ doc/Doxygen/DTAGS
*.tgz *.tgz
*.gtgz *.gtgz
# Ignore the persistent .build tag in the main directory # Ignore tags or project files in the main directory
/.build
# Ignore .timeStamp in the main directory
/.timeStamp
# Ignore .tags in the main directory
/.tags
# Ignore project files in the main directory
/.cproject /.cproject
/.project
/.dir-locals.el /.dir-locals.el
/.project
/.tags
# Ignore the test directory # Ignore the test directory
/tutorialsTest /tutorialsTest

View File

@ -36,10 +36,17 @@ case ThirdParty:
set default_mpfr_version=mpfr-system set default_mpfr_version=mpfr-system
set default_mpc_version=mpc-system set default_mpc_version=mpc-system
# Clear any old values
set gcc_version=''
set clang_version=''
switch ("$WM_COMPILER") switch ("$WM_COMPILER")
case Gcc: case Gcc:
set gcc_version="$default_gcc_version" set gcc_version="$default_gcc_version"
breaksw breaksw
case Gcc102*:
set gcc_version=gcc-10.2.0
breaksw
case Gcc101*: case Gcc101*:
set gcc_version=gcc-10.1.0 set gcc_version=gcc-10.1.0
breaksw breaksw
@ -121,8 +128,11 @@ case ThirdParty:
case Clang: case Clang:
set clang_version="$default_clang_version" set clang_version="$default_clang_version"
breaksw breaksw
case Clang110*:
set clang_version=llvm-11.0.0
breaksw
case Clang100*: case Clang100*:
set clang_version=llvm-10.0.0 set clang_version=llvm-10.0.1
breaksw breaksw
case Clang90*: case Clang90*:
set clang_version=llvm-9.0.1 set clang_version=llvm-9.0.1
@ -155,7 +165,13 @@ case ThirdParty:
set clang_version=llvm-3.7.1 set clang_version=llvm-3.7.1
breaksw breaksw
default: endsw
_foamEtc -config prefs.compiler ## Optional adjustments
_foamEtc -config "compiler-$WM_COMPILER" ## Per-compiler override
# Trap errors
if ( "${gcc_version}${clang_version}" == "" ) then
/bin/cat << UNKNOWN_COMPILER /bin/cat << UNKNOWN_COMPILER
=============================================================================== ===============================================================================
Warning in $WM_PROJECT_DIR/etc/config.csh/compiler: Warning in $WM_PROJECT_DIR/etc/config.csh/compiler:
@ -164,14 +180,11 @@ Unknown ThirdParty compiler type/version - '$WM_COMPILER'
Please check your settings Please check your settings
=============================================================================== ===============================================================================
UNKNOWN_COMPILER UNKNOWN_COMPILER
breaksw endif
endsw
# Per-compiler overrides in "compiler-$WM_COMPILER" files
_foamEtc -config "compiler-$WM_COMPILER"
breaksw breaksw
endsw endsw
unset default_gcc_version default_clang_version unset default_gcc_version default_clang_version
unset default_gmp_version default_mpfr_version default_mpc_version unset default_gmp_version default_mpfr_version default_mpc_version

View File

@ -12,10 +12,12 @@
# #
# File # File
# config.csh/example/compiler-Gcc92 # config.csh/example/compiler-Gcc92
# - sourced by OpenFOAM-*/etc/config.csh/compiler
# #
# Description # Description
# Example of fine tuning compiler settings with a hook # Example of tuning compiler settings with a hook (C-shell).
#
# Copy to etc/config.csh (or ~/.OpenFOAM/config.csh) and it will be
# sourced by OpenFOAM-*/etc/config.csh/compiler
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com # \\ / A nd | www.openfoam.com
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2018 OpenCFD Ltd. # Copyright (C) 2018-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
# config.csh/example/paraview # config.csh/example/paraview

View File

@ -6,26 +6,26 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017 OpenCFD Ltd. # Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# #
# File # File
# config.csh/example/compiler # config.csh/example/prefs.compiler
# - sourced by OpenFOAM-*/etc/config.csh/settings
# #
# Description # Description
# Older example of fine tuning compiler settings for OpenFOAM # Example of tuning compiler settings with a hook (POSIX shell).
# #
# The preferred mechanism is now with a "compiler-$WM_COMPILER" file # Copy to etc/config.sh (or ~/.OpenFOAM/config.sh) and it will be
# sourced by OpenFOAM-*/etc/config.sh/compiler
#
# Note
# The preferred mechanism is often a "compiler-$WM_COMPILER" file
# in one of the etc/ directories. # in one of the etc/ directories.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Load the standard versions
eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh -config -mode=o compiler`
# Modify/override compiler settings # Modify/override compiler settings
switch ("$WM_COMPILER") switch ("$WM_COMPILER")
case Gcc70*: case Gcc70*:

View File

@ -13,14 +13,15 @@
# #
# File # File
# config.csh/example/prefs.csh # config.csh/example/prefs.csh
# - sourced by OpenFOAM-*/etc/cshrc
# #
# Description # Description
# Example of preset variables for the OpenFOAM configuration (C-Shell shell) # Example of preset variables for configuring OpenFOAM (C-shell)
#
# Copy to OpenFOAM-*/etc (or ~/.OpenFOAM) and it will be sourced by
# OpenFOAM-*/etc/cshrc
# #
# See also # See also
# 'foamEtcFile -help' or 'foamEtcFile -list' for information about the # 'foamEtcFile -help' or 'foamEtcFile -list' for the paths searched
# paths searched
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -19,7 +19,7 @@
# Settings for OpenFOAM # Settings for OpenFOAM
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
setenv WM_ARCH `uname -s` # System name setenv WM_ARCH `uname -s` # System name
set archOption=64 set archOption=64
if ($?WM_ARCH_OPTION) then if ($?WM_ARCH_OPTION) then
@ -28,7 +28,7 @@ endif
unsetenv WM_ARCH_OPTION # Compiling 32-bit on 64-bit system unsetenv WM_ARCH_OPTION # Compiling 32-bit on 64-bit system
setenv WM_COMPILER_ARCH # Host compiler type (when different than target) setenv WM_COMPILER_ARCH # Host compiler type (when different than target)
setenv WM_COMPILER_LIB_ARCH # Additional ending for lib directories setenv WM_COMPILER_LIB_ARCH # Ending for lib directories
if (! $?WM_COMPILE_OPTION ) setenv WM_COMPILE_OPTION if (! $?WM_COMPILE_OPTION ) setenv WM_COMPILE_OPTION
# Adjust according to system and architecture # Adjust according to system and architecture
@ -37,54 +37,46 @@ case Linux:
setenv WM_ARCH linux setenv WM_ARCH linux
switch (`uname -m`) switch (`uname -m`)
case i686: case x86_64:
if ( "$archOption" == "32" ) then
setenv WM_ARCH_OPTION 32 # Propagate?
setenv WM_COMPILER_ARCH 64 # 64-bit compiler, 32-bit target
else
setenv WM_ARCH linux64 # 64-bit compiler/target
setenv WM_COMPILER_LIB_ARCH 64 # Use lib64
endif
breaksw breaksw
case x86_64: case aarch64:
switch ("$archOption") setenv WM_ARCH linuxARM64
case 32: setenv WM_COMPILER_LIB_ARCH 64 # Use lib64
setenv WM_ARCH_OPTION 32 # Need to propagate the value breaksw
setenv WM_COMPILER_ARCH 64 # 64-bit compiler, 32-bit target
breaksw
case 64: case armv7l:
setenv WM_ARCH linux64 setenv WM_ARCH linuxARM7
setenv WM_COMPILER_LIB_ARCH 64 # Target with lib64 setenv WM_COMPILER_LIB_ARCH 32 # Use lib32
breaksw breaksw
default: case ppc64:
echo "Unknown WM_ARCH_OPTION '$archOption', should be 32|64" setenv WM_ARCH linuxPPC64
breaksw setenv WM_COMPILER_LIB_ARCH 64 # Use lib64
breaksw
endsw case ppc64le:
setenv WM_ARCH linuxPPC64le
setenv WM_COMPILER_LIB_ARCH 64 # Use lib64
breaksw
case i686:
setenv WM_ARCH linux
breaksw breaksw
case ia64: case ia64:
setenv WM_ARCH linuxIA64 setenv WM_ARCH linuxIA64
breaksw breaksw
case armv7l:
setenv WM_ARCH linuxARM7
setenv WM_COMPILER_LIB_ARCH 32
breaksw
case aarch64:
setenv WM_ARCH linuxARM64
setenv WM_COMPILER_LIB_ARCH 64
breaksw
case ppc64:
setenv WM_ARCH linuxPPC64
setenv WM_COMPILER_LIB_ARCH 64
breaksw
case ppc64le:
setenv WM_ARCH linuxPPC64le
setenv WM_COMPILER_LIB_ARCH 64
breaksw
default: default:
echo Unknown processor type `uname -m` for Linux echo "openfoam: (`uname -m`) - unknown Linux processor type"
breaksw breaksw
endsw endsw
@ -93,17 +85,17 @@ case Linux:
# Presume x86_64, with clang (not gcc) as system compiler # Presume x86_64, with clang (not gcc) as system compiler
case Darwin: case Darwin:
setenv WM_ARCH darwin64 setenv WM_ARCH darwin64
if ("$WM_COMPILER" == Gcc) setenv WM_COMPILER Clang if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Clang
echo "Darwin support is clang/llvm only" echo "openfoam: darwin support is clang/llvm only"
breaksw breaksw
# Presume x86_64, with mingw cross-compiled # Presume x86_64, with mingw cross-compiled
case MINGW*: case MINGW*:
case MSYS*: case MSYS*:
WM_ARCH=win64 WM_ARCH=win64
if ("$WM_COMPILER" == Gcc) setenv WM_COMPILER Mingw if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Mingw
setenv WM_COMPILER_LIB_ARCH 64 # Consistent with linux64Mingw setenv WM_COMPILER_LIB_ARCH 64 # Consistent with linux64Mingw
echo "Windows support (mingw64) is runtime only" echo "openfoam: windows support (mingw64) is runtime only"
;; ;;
case SunOS*: case SunOS*:
@ -115,7 +107,7 @@ default:
/bin/cat << UNSUPPORTED /bin/cat << UNSUPPORTED
=============================================================================== ===============================================================================
Operating system '$WM_ARCH' is unsupported by this OpenFOAM release. Operating system '$WM_ARCH' is unsupported by this OpenFOAM release.
For further assistance, please contact www.OpenFOAM.com For further assistance, please contact www.openfoam.com
=============================================================================== ===============================================================================
UNSUPPORTED UNSUPPORTED
breaksw breaksw
@ -238,10 +230,10 @@ case ThirdParty-Gcc*:
if (! $?gmp_version ) set gmp_version=gmp-system if (! $?gmp_version ) set gmp_version=gmp-system
if (! $?mpfr_version ) set mpfr_version=mpfr-system if (! $?mpfr_version ) set mpfr_version=mpfr-system
if (! $?mpc_version ) set mpc_version=mpc-system if (! $?mpc_version ) set mpc_version=mpc-system
set gccDir=$archDir/$gcc_version set gccDir="$archDir/$gcc_version"
set gmpDir=$archDir/$gmp_version set gmpDir="$archDir/$gmp_version"
set mpfrDir=$archDir/$mpfr_version set mpfrDir="$archDir/$mpfr_version"
set mpcDir=$archDir/$mpc_version set mpcDir="$archDir/$mpc_version"
# Check that the compiler directory can be found # Check that the compiler directory can be found
if ( ! -d "$gccDir" ) then if ( ! -d "$gccDir" ) then
@ -257,24 +249,24 @@ Cannot find '$WM_COMPILER' compiler installation
GCC_NOT_FOUND GCC_NOT_FOUND
endif endif
_foamAddMan $gccDir/man _foamAddMan "$gccDir"/man
_foamAddPath $gccDir/bin _foamAddPath "$gccDir"/bin
# Add ThirdParty compiler libraries to run-time environment # Add ThirdParty compiler libraries to run-time environment
_foamAddLib $gccDir/lib$WM_COMPILER_LIB_ARCH _foamAddLib "$gccDir/lib$WM_COMPILER_LIB_ARCH"
# Add gmp/mpfr/mpc libraries to run-time environment. # Add gmp/mpfr/mpc libraries to run-time environment.
# Require that they exist, automatically find lib64/ or lib/. # Require that they exist, automatically find lib64/ or lib/.
if ( "${gmpDir:t}" != "gmp-system" ) then if ( "${gmpDir:t}" != "gmp-system" ) then
_foamAddLibAuto $gmpDir _foamAddLibAuto "$gmpDir"
setenv GMP_ARCH_PATH $gmpDir # For non-system CGAL setenv GMP_ARCH_PATH "$gmpDir" # For non-system CGAL
endif endif
if ( "${mpfrDir:t}" != "mpfr-system" ) then if ( "${mpfrDir:t}" != "mpfr-system" ) then
_foamAddLibAuto $mpfrDir _foamAddLibAuto "$mpfrDir"
setenv MPFR_ARCH_PATH $mpfrDir # For non-system CGAL setenv MPFR_ARCH_PATH "$mpfrDir" # For non-system CGAL
endif endif
_foamAddLibAuto $mpcDir _foamAddLibAuto "$mpcDir"
if ($?FOAM_VERBOSE && $?prompt) then if ($?FOAM_VERBOSE && $?prompt) then
echo "Using ThirdParty compiler" echo "Using ThirdParty compiler"
@ -283,7 +275,7 @@ GCC_NOT_FOUND
breaksw breaksw
case ThirdParty-Clang*: case ThirdParty-Clang*:
set clangDir=$archDir/$clang_version set clangDir="$archDir/$clang_version"
# Check that the compiler directory can be found # Check that the compiler directory can be found
if ( ! -d "$clangDir" ) then if ( ! -d "$clangDir" ) then
@ -299,9 +291,9 @@ Cannot find '$WM_COMPILER' compiler installation
CLANG_NOT_FOUND CLANG_NOT_FOUND
endif endif
_foamAddMan $clangDir/man _foamAddMan "$clangDir"/share/man
_foamAddPath $clangDir/bin _foamAddPath "$clangDir"/bin
_foamAddLib $clangDir/lib # For things like libomp (openmp) etc _foamAddLib "$clangDir"/lib # For things like libomp (openmp) etc
if ($?FOAM_VERBOSE && $?prompt) then if ($?FOAM_VERBOSE && $?prompt) then
echo "Using ThirdParty compiler" echo "Using ThirdParty compiler"

View File

@ -40,8 +40,12 @@ ThirdParty)
mpfr_version="$default_mpfr_version" mpfr_version="$default_mpfr_version"
mpc_version="$default_mpc_version" mpc_version="$default_mpc_version"
# Clear any old values
unset gcc_version clang_version
case "$WM_COMPILER" in case "$WM_COMPILER" in
Gcc) gcc_version="$default_gcc_version" ;; Gcc) gcc_version="$default_gcc_version" ;;
Gcc102*) gcc_version=gcc-10.2.0 ;;
Gcc101*) gcc_version=gcc-10.1.0 ;; Gcc101*) gcc_version=gcc-10.1.0 ;;
Gcc93*) gcc_version=gcc-9.3.0 ;; Gcc93*) gcc_version=gcc-9.3.0 ;;
Gcc92*) gcc_version=gcc-9.2.0 ;; Gcc92*) gcc_version=gcc-9.2.0 ;;
@ -70,7 +74,8 @@ ThirdParty)
Gcc48*) gcc_version=gcc-4.8.5 ;; Gcc48*) gcc_version=gcc-4.8.5 ;;
Clang) clang_version="$default_clang_version" ;; Clang) clang_version="$default_clang_version" ;;
Clang100*) clang_version=llvm-10.0.0 ;; Clang110*) clang_version=llvm-11.0.0 ;;
Clang100*) clang_version=llvm-10.0.1 ;;
Clang90*) clang_version=llvm-9.0.1 ;; Clang90*) clang_version=llvm-9.0.1 ;;
Clang80*) clang_version=llvm-8.0.1 ;; Clang80*) clang_version=llvm-8.0.1 ;;
Clang71*) clang_version=llvm-7.1.0 ;; Clang71*) clang_version=llvm-7.1.0 ;;
@ -82,7 +87,14 @@ ThirdParty)
Clang38*) clang_version=llvm-3.8.1 ;; Clang38*) clang_version=llvm-3.8.1 ;;
Clang37*) clang_version=llvm-3.7.1 ;; Clang37*) clang_version=llvm-3.7.1 ;;
*) esac
_foamEtc -config prefs.compiler ## Optional adjustments
_foamEtc -config "compiler-$WM_COMPILER" ## Per-compiler override
# Trap errors
if [ -z "$gcc_version$clang_version" ]
then
/bin/cat << UNKNOWN_COMPILER 1>&2 /bin/cat << UNKNOWN_COMPILER 1>&2
=============================================================================== ===============================================================================
Warning in $WM_PROJECT_DIR/etc/config.sh/compiler: Warning in $WM_PROJECT_DIR/etc/config.sh/compiler:
@ -91,14 +103,11 @@ Unknown ThirdParty compiler type/version - '$WM_COMPILER'
Please check your settings Please check your settings
=============================================================================== ===============================================================================
UNKNOWN_COMPILER UNKNOWN_COMPILER
;; fi
esac
# Per-compiler overrides in "compiler-$WM_COMPILER" files
_foamEtc -config "compiler-$WM_COMPILER"
;; ;;
esac esac
unset default_gcc_version default_clang_version unset default_gcc_version default_clang_version
unset default_gmp_version default_mpfr_version default_mpc_version unset default_gmp_version default_mpfr_version default_mpc_version

View File

@ -12,10 +12,12 @@
# #
# File # File
# config.sh/example/compiler-Gcc92 # config.sh/example/compiler-Gcc92
# - sourced by OpenFOAM-*/etc/config.sh/compiler
# #
# Description # Description
# Example of fine tuning compiler settings with a hook # Example of tuning compiler settings with a hook (POSIX shell).
#
# Copy to etc/config.sh (or ~/.OpenFOAM/config.sh) and it will be
# sourced by OpenFOAM-*/etc/config.sh/compiler
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com # \\ / A nd | www.openfoam.com
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2018 OpenCFD Ltd. # Copyright (C) 2018-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
# config.sh/example/paraview # config.sh/example/paraview

View File

@ -6,26 +6,26 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017 OpenCFD Ltd. # Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# #
# File # File
# config.sh/example/compiler # config.sh/example/prefs.compiler
# - sourced by OpenFOAM-*/etc/config.sh/settings
# #
# Description # Description
# Older example of fine tuning compiler settings for OpenFOAM. # Example of tuning compiler settings with a hook (C-shell).
# #
# The preferred mechanism is now with a "compiler-$WM_COMPILER" file # Copy to etc/config.csh (or ~/.OpenFOAM/config.csh) and it will be
# sourced by OpenFOAM-*/etc/config.csh/compiler
#
# Note
# The preferred mechanism is often a "compiler-$WM_COMPILER" file
# in one of the etc/ directories. # in one of the etc/ directories.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Load the standard versions
eval $($WM_PROJECT_DIR/bin/foamEtcFile -sh -config -mode=o compiler)
# Modify/override compiler settings # Modify/override compiler settings
case "$WM_COMPILER" in case "$WM_COMPILER" in
Gcc70*) Gcc70*)

View File

@ -6,21 +6,22 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 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
# config.sh/example/prefs.sh # config.sh/example/prefs.sh
# - sourced by OpenFOAM-*/etc/bashrc
# #
# Description # Description
# Example of preset variables for the OpenFOAM configuration (POSIX shell) # Example of preset variables for configuring OpenFOAM (POSIX shell)
#
# Copy to OpenFOAM-*/etc (or ~/.OpenFOAM) and it will be sourced by
# OpenFOAM-*/etc/bashrc
# #
# See also # See also
# 'foamEtcFile -help' or 'foamEtcFile -list' for information about the # 'foamEtcFile -help' or 'foamEtcFile -list' for the paths searched
# paths searched
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -19,12 +19,12 @@
# Settings for OpenFOAM. # Settings for OpenFOAM.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
export WM_ARCH="$(uname -s)" # System name export WM_ARCH="$(uname -s)" # System name
archOption="${WM_ARCH_OPTION:-64}" archOption="${WM_ARCH_OPTION:-64}"
unset WM_ARCH_OPTION # Compiling 32-bit on 64-bit system unset WM_ARCH_OPTION # Compiling 32-bit on 64-bit system
unset WM_COMPILER_ARCH # Host compiler type (when different than target) unset WM_COMPILER_ARCH # Host compiler type (when different than target)
unset WM_COMPILER_LIB_ARCH # Additional ending for lib directories unset WM_COMPILER_LIB_ARCH # Ending for lib directories
# Adjust according to system and architecture # Adjust according to system and architecture
@ -33,51 +33,47 @@ Linux)
WM_ARCH=linux WM_ARCH=linux
case "$(uname -m)" in case "$(uname -m)" in
i686) x86_64)
if [ "$archOption" = 32 ]
then
export WM_ARCH_OPTION=32 # Propagate?
export WM_COMPILER_ARCH=64 # 64-bit compiler, 32-bit target
else
WM_ARCH=linux64 # 64-bit compiler/target
export WM_COMPILER_LIB_ARCH=64 # Use lib64
fi
;; ;;
x86_64) aarch64)
case "$archOption" in WM_ARCH=linuxARM64
32) export WM_COMPILER_LIB_ARCH=64 # Use lib64
export WM_ARCH_OPTION=32 # Need to propagate the value ;;
export WM_COMPILER_ARCH=64 # 64-bit compiler, 32-bit target
;; armv7l)
64) WM_ARCH=linuxARM7
WM_ARCH=linux64 export WM_COMPILER_LIB_ARCH=32 # Use lib32
export WM_COMPILER_LIB_ARCH=64 # Target with lib64 ;;
;;
*) ppc64)
echo "Unknown WM_ARCH_OPTION '$archOption', should be 32|64" 1>&2 WM_ARCH=linuxPPC64
;; export WM_COMPILER_LIB_ARCH=64 # Use lib64
esac ;;
ppc64le)
WM_ARCH=linuxPPC64le
export WM_COMPILER_LIB_ARCH=64 # Use lib64
;;
i686)
WM_ARCH=linux
;; ;;
ia64) ia64)
WM_ARCH=linuxIA64 WM_ARCH=linuxIA64
;; ;;
armv7l)
WM_ARCH=linuxARM7
export WM_COMPILER_LIB_ARCH=32
;;
aarch64)
WM_ARCH=linuxARM64
export WM_COMPILER_LIB_ARCH=64
;;
ppc64)
WM_ARCH=linuxPPC64
export WM_COMPILER_LIB_ARCH=64
;;
ppc64le)
WM_ARCH=linuxPPC64le
export WM_COMPILER_LIB_ARCH=64
;;
*) *)
echo Unknown processor type "$(uname -m)" for Linux 1>&2 echo "openfoam: ($(uname -m)) - unknown Linux processor type" 1>&2
;; ;;
esac esac
;; ;;
@ -86,7 +82,7 @@ Linux)
Darwin) Darwin)
WM_ARCH=darwin64 WM_ARCH=darwin64
[ "$WM_COMPILER" = Gcc ] && WM_COMPILER=Clang [ "$WM_COMPILER" = Gcc ] && WM_COMPILER=Clang
echo "Darwin support is clang/llvm only" 1>&2 echo "openfoam: darwin support is clang/llvm only" 1>&2
;; ;;
# Presume x86_64, with mingw cross-compiled # Presume x86_64, with mingw cross-compiled
@ -94,7 +90,7 @@ MINGW* | MSYS*)
WM_ARCH=win64 WM_ARCH=win64
[ "$WM_COMPILER" = Gcc ] && WM_COMPILER=Mingw [ "$WM_COMPILER" = Gcc ] && WM_COMPILER=Mingw
export WM_COMPILER_LIB_ARCH=64 # Consistent with linux64Mingw export WM_COMPILER_LIB_ARCH=64 # Consistent with linux64Mingw
echo "Windows support (mingw64) is runtime only" 1>&2 echo "openfoam: windows support (mingw64) is runtime only" 1>&2
;; ;;
SunOS*) SunOS*)
@ -106,7 +102,7 @@ SunOS*)
/bin/cat << UNSUPPORTED 1>&2 /bin/cat << UNSUPPORTED 1>&2
=============================================================================== ===============================================================================
Operating system '$WM_ARCH' is unsupported by this OpenFOAM release. Operating system '$WM_ARCH' is unsupported by this OpenFOAM release.
For further assistance, please contact www.OpenFOAM.com For further assistance, please contact www.openfoam.com
=============================================================================== ===============================================================================
UNSUPPORTED UNSUPPORTED
;; ;;
@ -210,7 +206,7 @@ export FOAM_RUN="$WM_PROJECT_USER_DIR/run"
# ~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~
# Default to system compiler # Default to system compiler
: ${WM_COMPILER_TYPE:=system}; export WM_COMPILER_TYPE : "${WM_COMPILER_TYPE:=system}"; export WM_COMPILER_TYPE
# Non-POSIX systems and cross-compiling # Non-POSIX systems and cross-compiling
case "$WM_COMPILER" in case "$WM_COMPILER" in
@ -232,10 +228,10 @@ archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH"
case "$WM_COMPILER_TYPE-$WM_COMPILER" in case "$WM_COMPILER_TYPE-$WM_COMPILER" in
ThirdParty-Gcc*) ThirdParty-Gcc*)
gccDir=$archDir/$gcc_version gccDir="$archDir/$gcc_version"
gmpDir=$archDir/${gmp_version:-gmp-system} gmpDir="$archDir/${gmp_version:-gmp-system}"
mpfrDir=$archDir/${mpfr_version:-mpfr-system} mpfrDir="$archDir/${mpfr_version:-mpfr-system}"
mpcDir=$archDir/${mpc_version:-mpc-system} mpcDir="$archDir/${mpc_version:-mpc-system}"
# Check that the compiler directory can be found # Check that the compiler directory can be found
[ -d "$gccDir" ] || /bin/cat << GCC_NOT_FOUND 1>&2 [ -d "$gccDir" ] || /bin/cat << GCC_NOT_FOUND 1>&2
@ -249,21 +245,21 @@ Cannot find '$WM_COMPILER' compiler installation
=============================================================================== ===============================================================================
GCC_NOT_FOUND GCC_NOT_FOUND
_foamAddMan $gccDir/man _foamAddMan "$gccDir"/man
_foamAddPath $gccDir/bin _foamAddPath "$gccDir"/bin
# Add ThirdParty compiler libraries to run-time environment # Add ThirdParty compiler libraries to run-time environment
_foamAddLib $gccDir/lib$WM_COMPILER_LIB_ARCH _foamAddLib "$gccDir/lib$WM_COMPILER_LIB_ARCH"
# Add gmp/mpfr/mpc libraries to run-time environment. # Add gmp/mpfr/mpc libraries to run-time environment.
# Require that they exist, automatically find lib64/ or lib/. # Require that they exist, automatically find lib64/ or lib/.
_foamAddLibAuto $gmpDir && \ _foamAddLibAuto "$gmpDir" && \
export GMP_ARCH_PATH=$gmpDir # For non-system CGAL export GMP_ARCH_PATH="$gmpDir" # For non-system CGAL
_foamAddLibAuto $mpfrDir && \ _foamAddLibAuto "$mpfrDir" && \
export MPFR_ARCH_PATH=$mpfrDir # For non-system CGAL export MPFR_ARCH_PATH="$mpfrDir" # For non-system CGAL
_foamAddLibAuto $mpcDir _foamAddLibAuto "$mpcDir"
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
@ -273,7 +269,7 @@ GCC_NOT_FOUND
;; ;;
ThirdParty-Clang*) ThirdParty-Clang*)
clangDir=$archDir/$clang_version clangDir="$archDir/$clang_version"
# Check that the compiler directory can be found # Check that the compiler directory can be found
[ -d "$clangDir" ] || /bin/cat << CLANG_NOT_FOUND 1>&2 [ -d "$clangDir" ] || /bin/cat << CLANG_NOT_FOUND 1>&2
@ -287,9 +283,9 @@ Cannot find '$WM_COMPILER' compiler installation
=============================================================================== ===============================================================================
CLANG_NOT_FOUND CLANG_NOT_FOUND
_foamAddMan $clangDir/share/man _foamAddMan "$clangDir"/share/man
_foamAddPath $clangDir/bin _foamAddPath "$clangDir"/bin
_foamAddLib $clangDir/lib # For things like libomp (openmp) etc _foamAddLib "$clangDir"/lib # For things like libomp (openmp) etc
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then