Files
openfoam/etc/config.csh/settings
Mark Olesen 6c68c34e1a ENH: update handling of versioning and make control (issue #1010)
- Use the OPENFOAM define (eg, 1806, 1812), which normally corresponds
  to a major release, to define an API level. This remains consistent
  within a release cycle and means that it is possible to manage
  several sub-versions and continue to have a consistent lookup.

  The current API value is updated automatically during the build
  and cached as meta data for later use, even when the wmake/ directory
  is missing or OpenFOAM has not yet be initialized.

  The version information reported on program start or with -help
  usage adjusted to reflect this. The build tag from git now also
  carries the date as being more meaningful to trace than a hash
  value.

- Update etc/bashrc and etc/cshrc to obtain the project directory
  directly instead of via its prefix directory. The value obtained
  corresponds to an absolute path, from which the prefix directory
  can be obtained.

  The combination of these changes removes the reliance on any
  particular directory naming convention.
  For example,

     With an 1812 version (API level):

     WM_PROJECT_VERSION=myVersion

     installed as /some/path/somewhere/openfoam-mySandbox

  This makes the -prefix, -foamInstall, -projectVersion, -version
  values of foamEtcFiles, and similar entries for foamConfigurePaths
  superfluous.

  WM_PROJECT_INST_DIR is no longer required or used

ENH: improve handling and discovery of ThirdParty

- improve the flexibility and reusability of ThirdParty packs to cover
  various standard use cases:

    1. Unpacking initial release tar files with two parallel directories
       - OpenFOAM-v1812/
       - ThirdParty-v1812/

    2. With an adjusted OpenFOAM directory name, for whatever reason
       - OpenFOAM-v1812-myCustom/
       - openfoam-1812-other-info/

    3. Operating with/without ThirdParty directory

  To handle these use cases, the following discovery is used.

  Note PROJECT = the OpenFOAM directory `$WM_PROJECT_DIR`
       PREFIX = the parent directory
       VERSION = `$WM_PROJECT_VERSION`
       API = `$WM_PROJECT_API`, as per `foamEtcFiles -show-api`

   0. PROJECT/ThirdParty
      - for single-directory installations

   1. PREFIX/ThirdParty-VERSION
      - this corresponds to the traditional approach

   2. PREFIX/ThirdParty-vAPI
      - allows for an updated value of VERSION (eg, v1812-myCustom)
        without requiring a renamed ThirdParty. The API value
        would still be '1812' and the original ThirdParty-v1812/
        would be found.

   3. PREFIX/ThirdParty-API
      - this is the same as the previous example, but using an unadorned
        API value. This also makes sense if the chosen version name also
        uses the unadorned API value in its naming
        (eg, 1812-patch190131, 1812.19W03)

   4. PREFIX/ThirdParty-common
      - permits maximum reuse for various versions, but only for
        experienced user who are aware of potential version
        incompatibilities

   Directory existence is checked as is the presence of an Allwmake file
   or a platforms/ directory. This reduces the potential of false positive
   matches and limits the selection to directories that are either
   with sources (has the Allwmake file), or pre-compiled binaries (has
   the platforms/ directory).

   If none of the explored directories are found to be suitable,
   it reverts to using a PROJECT/ThirdParty dummy location since
   this is within the project source tree and can be trusted to
   have no negative side-effects.

ENH: add csh support to foamConfigurePaths

- this removes the previously experienced inconsistence in config file
  contents.

REMOVED: foamExec

- was previously used when switching versions and before the
  bashrc/cshrc discovery logic was added. It is now obsolete.
2018-12-02 18:25:57 +01:00

365 lines
11 KiB
Bash

#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# File
# etc/config.csh/settings
# - sourced by OpenFOAM-*/etc/cshrc
#
# Description
# Settings for OpenFOAM
#
#------------------------------------------------------------------------------
setenv WM_ARCH `uname -s` # System name
## if (! $?WM_OSTYPE ) setenv WM_OSTYPE POSIX # System type (POSIX is default)
# Default compiler = gcc/g++ and C++11
setenv WM_CC "gcc"
setenv WM_CXX "g++"
setenv WM_CFLAGS "-fPIC"
setenv WM_CXXFLAGS "-fPIC -std=c++11"
setenv WM_COMPILER_ARCH # Defined but empty
setenv WM_COMPILER_LIB_ARCH # Defined but empty: default for 32bit
unsetenv WM_LDFLAGS
# Adjust according to system and architecture
switch ($WM_ARCH)
case Linux:
setenv WM_ARCH linux
switch (`uname -m`)
case i686:
setenv WM_ARCH_OPTION 32
breaksw
case x86_64:
if (! $?WM_ARCH_OPTION ) setenv WM_ARCH_OPTION 64 # Default to 64-bit
switch ($WM_ARCH_OPTION)
case 32:
setenv WM_COMPILER_ARCH 64
setenv WM_CFLAGS "$WM_CFLAGS -m32"
setenv WM_CXXFLAGS "$WM_CXXFLAGS -m32"
setenv WM_LDFLAGS "-m32"
breaksw
case 64:
setenv WM_ARCH linux64
setenv WM_COMPILER_LIB_ARCH 64
setenv WM_CFLAGS "$WM_CFLAGS -m64"
setenv WM_CXXFLAGS "$WM_CXXFLAGS -m64"
setenv WM_LDFLAGS "-m64"
breaksw
default:
echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32|64"
breaksw
endsw
breaksw
case ia64:
setenv WM_ARCH linuxIA64
breaksw
case armv7l:
setenv WM_ARCH linuxARM7
setenv WM_ARCH_OPTION 32
setenv WM_COMPILER_LIB_ARCH 32
breaksw
case aarch64:
setenv WM_ARCH linuxARM64
setenv WM_ARCH_OPTION 64
setenv WM_COMPILER_LIB_ARCH 64
breaksw
case ppc64:
setenv WM_ARCH linuxPPC64
setenv WM_COMPILER_LIB_ARCH 64
setenv WM_CFLAGS "$WM_CFLAGS -m64"
setenv WM_CXXFLAGS "$WM_CXXFLAGS -m64"
setenv WM_LDFLAGS "-m64"
breaksw
case ppc64le:
setenv WM_ARCH linuxPPC64le
setenv WM_COMPILER_LIB_ARCH 64
setenv WM_CFLAGS "$WM_CFLAGS -m64"
setenv WM_CXXFLAGS "$WM_CXXFLAGS -m64"
setenv WM_LDFLAGS "-m64"
breaksw
default:
echo Unknown processor type `uname -m` for Linux
breaksw
endsw
breaksw
case Darwin: # Presumably x86_64
if (! $?WM_ARCH_OPTION ) setenv WM_ARCH_OPTION 64 # Default to 64-bit
setenv WM_ARCH darwin64
setenv WM_CFLAGS "$WM_CFLAGS -m64 -Ddarwin"
setenv WM_CXXFLAGS "$WM_CXXFLAGS -m64 -Ddarwin"
/bin/cat << INCOMPLETE
===============================================================================
Darwin support (clang only) is incomplete or untested in this OpenFOAM release.
For further assistance, please contact www.OpenFOAM.com
===============================================================================
INCOMPLETE
breaksw
case SunOS:
setenv WM_ARCH SunOS64
setenv WM_MPLIB FJMPI
setenv WM_COMPILER_LIB_ARCH 64
setenv WM_CFLAGS "$WM_CFLAGS -mabi=64"
setenv WM_CXXFLAGS "$WM_CXXFLAGS -mabi=64"
setenv WM_LDFLAGS "-mabi=64 -G0"
breaksw
default:
/bin/cat << UNSUPPORTED
===============================================================================
Operating system '$WM_ARCH' is unsupported by this OpenFOAM release.
For further assistance, please contact www.OpenFOAM.com
===============================================================================
UNSUPPORTED
breaksw
endsw
#------------------------------------------------------------------------------
# wmake configuration
setenv WM_DIR "$WM_PROJECT_DIR/wmake"
setenv WM_LABEL_OPTION "Int$WM_LABEL_SIZE"
setenv WM_OPTIONS "$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION$WM_COMPILE_OPTION"
# Base executables/libraries
setenv FOAM_APPBIN "$WM_PROJECT_DIR/platforms/$WM_OPTIONS/bin"
setenv FOAM_LIBBIN "$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib"
# Site-specific (group) files
# Default
set siteDir="$WM_PROJECT_DIR/site"
# User override
if ( $?WM_PROJECT_SITE ) then
set siteDir="$WM_PROJECT_SITE"
else
unsetenv WM_PROJECT_SITE
endif
# Shared site (group) executables/libraries
setenv FOAM_SITE_APPBIN "$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin"
setenv FOAM_SITE_LIBBIN "$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib"
# User executables/libraries
setenv FOAM_USER_APPBIN "$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin"
setenv FOAM_USER_LIBBIN "$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib"
# Prepend wmake to the path - not required for runtime-only environment
set foundDir="${WM_PROJECT_DIR}/wmake"
if ( $?WM_DIR ) then
if ( -d "${WM_DIR}" ) set foundDir="${WM_DIR}"
endif
if ( -d "$foundDir" ) then
setenv PATH "${foundDir}:${PATH}"
else
unsetenv WM_DIR
endif
# Prepend OpenFOAM scripts to the path
setenv PATH "${WM_PROJECT_DIR}/bin:${PATH}"
# Prepend site-specific scripts to path - only if they exist
if ( -d "$siteDir/bin" ) then # Generic
_foamAddPath "$siteDir/bin"
endif
if ( -d "$siteDir/$WM_PROJECT_API/bin" ) then # API-specific
_foamAddPath "$siteDir/$WM_PROJECT_API/bin"
endif
# OpenFOAM executables (user, group, standard)
_foamAddPath "${FOAM_USER_APPBIN}:${FOAM_SITE_APPBIN}:${FOAM_APPBIN}"
# Dummy versions of external libraries. To be found last in LD_LIBRARY_PATH
_foamAddLib "$FOAM_LIBBIN/dummy"
# External (ThirdParty) libraries. Also allowed to be unset
if ( -d "$WM_THIRD_PARTY_DIR" ) then
setenv FOAM_EXT_LIBBIN "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib"
_foamAddLib "$FOAM_EXT_LIBBIN"
else
unsetenv FOAM_EXT_LIBBIN
endif
# OpenFOAM libraries (user, group, standard)
_foamAddLib "${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN}"
#------------------------------------------------------------------------------
# Convenience
# ~~~~~~~~~~~
setenv FOAM_ETC "$WM_PROJECT_DIR/etc"
setenv FOAM_APP "$WM_PROJECT_DIR/applications"
setenv FOAM_SRC "$WM_PROJECT_DIR/src"
setenv FOAM_TUTORIALS "$WM_PROJECT_DIR/tutorials"
setenv FOAM_UTILITIES "$WM_PROJECT_DIR/applications/utilities"
setenv FOAM_SOLVERS "$WM_PROJECT_DIR/applications/solvers"
setenv FOAM_RUN "$WM_PROJECT_USER_DIR/run"
#------------------------------------------------------------------------------
# Compiler settings
# ~~~~~~~~~~~~~~~~~
# Default to system compiler
if (! $?WM_COMPILER_TYPE ) setenv WM_COMPILER_TYPE system
# Adjustments for non-gcc compilers
switch ("$WM_COMPILER")
case Clang*: # Clang compiler suite
setenv WM_CC 'clang'
setenv WM_CXX 'clang++'
breaksw
case Cray*: # Cray system compilers
setenv WM_CC 'cc'
setenv WM_CXX 'CC'
breaksw
case Icc*: # Intel compilers
setenv WM_CC 'icc'
setenv WM_CXX 'icpc'
breaksw
case Arm*: # Arm system compilers
setenv WM_CC 'armclang'
setenv WM_CXX 'armclang++'
breaksw
endsw
# Clear prior to sourcing
unset gcc_version gmp_version mpfr_version mpc_version clang_version
unsetenv GMP_ARCH_PATH MPFR_ARCH_PATH
# Load pre-defined compiler versions
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_foamEtc -config compiler
# ThirdParty base for compilers
set archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH"
switch ("$WM_COMPILER_TYPE-$WM_COMPILER")
case ThirdParty-Gcc*:
if (! $?gmp_version ) set gmp_version=gmp-system
if (! $?mpfr_version ) set mpfr_version=mpfr-system
if (! $?mpc_version ) set mpc_version=mpc-system
set gccDir=$archDir/$gcc_version
set gmpDir=$archDir/$gmp_version
set mpfrDir=$archDir/$mpfr_version
set mpcDir=$archDir/$mpc_version
# Check that the compiler directory can be found
if ( ! -d "$gccDir" ) then
/bin/cat << GCC_NOT_FOUND
===============================================================================
Warning in $WM_PROJECT_DIR/etc/config.csh/settings:
Cannot find '$WM_COMPILER' compiler installation
$gccDir
Either install this compiler version, or use the system compiler by setting
WM_COMPILER_TYPE to 'system' in \$WM_PROJECT_DIR/etc/cshrc.
===============================================================================
GCC_NOT_FOUND
endif
_foamAddMan $gccDir/man
_foamAddPath $gccDir/bin
# Add ThirdParty compiler libraries to run-time environment
_foamAddLib $gccDir/lib$WM_COMPILER_LIB_ARCH
# Add gmp/mpfr/mpc libraries to run-time environment.
# Require that they exist, automatically find lib64/ or lib/.
if ( "${gmpDir:t}" != "gmp-system" ) then
_foamAddLibAuto $gmpDir
setenv GMP_ARCH_PATH $gmpDir # For non-system CGAL
endif
if ( "${mpfrDir:t}" != "mpfr-system" ) then
_foamAddLibAuto $mpfrDir
setenv MPFR_ARCH_PATH $mpfrDir # For non-system CGAL
endif
_foamAddLibAuto $mpcDir
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using ThirdParty compiler"
echo " ${gccDir:t} (${gmpDir:t} ${mpfrDir:t} ${mpcDir:t})"
endif
breaksw
case ThirdParty-Clang*:
set clangDir=$archDir/$clang_version
# Check that the compiler directory can be found
if ( ! -d "$clangDir" ) then
/bin/cat << CLANG_NOT_FOUND
===============================================================================
Warning in $WM_PROJECT_DIR/etc/config.csh/settings:
Cannot find '$WM_COMPILER' compiler installation
$clangDir
Either install this compiler version, or use the system compiler by setting
WM_COMPILER_TYPE to 'system' in \$WM_PROJECT_DIR/etc/cshrc.
===============================================================================
CLANG_NOT_FOUND
endif
_foamAddMan $clangDir/man
_foamAddPath $clangDir/bin
_foamAddLib $clangDir/lib # For things like libomp (openmp) etc
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using ThirdParty compiler"
echo " ${clangDir:t}"
endif
breaksw
case system-*:
case ThirdParty-*:
# Using system compiler or other ThirdParty compiler
breaksw
default:
/bin/cat << UNKNOWN_TYPE
===============================================================================
Unknown WM_COMPILER_TYPE="$WM_COMPILER_TYPE" - treating as 'system'
Please check your settings
===============================================================================
UNKNOWN_TYPE
setenv WM_COMPILER_TYPE system
breaksw
endsw
# Cleanup
# ~~~~~~~
unset archDir siteDir foundDir
unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
unset clang_version clangDir
# Retain: _foamAddPath _foamAddLib _foamAddMan _foamAddLibAuto
#------------------------------------------------------------------------------