CONFIG: improve config files for Darwin (#1667), BSD-csh syntax (#1668)

- use Clang instead of Gcc for Darwin since this is its system
  compiler. The user can force use of Gcc by using Gcc92 etc.

- make etc/cshrc sed check more robust.

- replace tcsh (${%var}) syntax with ("${var}" != "")

[Fixes and ideas from Alexey Matveichev]

CONFIG: do not source the gperftools environment by default

- this is now an used feature, but can be re-enabled by advanced users
  if required.
This commit is contained in:
Mark Olesen 2020-04-08 10:37:21 +02:00
parent 3fd91c9084
commit f01ad2f187
13 changed files with 50 additions and 34 deletions

View File

@ -27,7 +27,14 @@ alias _foamClean 'eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=\!*`'
# Prepend PATH, MANPATH, LD_LIBRARY_PATH
alias _foamAddPath 'setenv PATH \!*\:${PATH}'
alias _foamAddMan 'setenv MANPATH \!*\:${MANPATH}'
alias _foamAddLib 'setenv LD_LIBRARY_PATH \!*\:${LD_LIBRARY_PATH}'
# Special treatment for Darwin
# - DYLD_LIBRARY_PATH instead of LD_LIBRARY_PATH
if (`uname -s` == "Darwin") then
alias _foamAddLib 'setenv DYLD_LIBRARY_PATH \!*\:${DYLD_LIBRARY_PATH}'
else
alias _foamAddLib 'setenv LD_LIBRARY_PATH \!*\:${LD_LIBRARY_PATH}'
endif
# Prefix to LD_LIBRARY_PATH with additional checking
# $1 = base directory for 'lib' or 'lib64'
@ -59,6 +66,7 @@ unsetenv FFTW_ARCH_PATH
unsetenv GPERFTOOLS_ARCH_PATH
unsetenv GMP_ARCH_PATH
unsetenv MPFR_ARCH_PATH
unsetenv LLVM_ARCH_PATH
unsetenv MESA_ARCH_PATH
unsetenv METIS_ARCH_PATH
unsetenv SCOTCH_ARCH_PATH

View File

@ -6,11 +6,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2019 OpenCFD Ltd.
# Copyright (C) 2016-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# config.csh/paraview
@ -65,7 +64,7 @@ if (! $?WM_COMPILER_LIB_ARCH ) setenv WM_COMPILER_LIB_ARCH
# Compiler-specific location for ThirdParty installations
set archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean PATH and LD_LIBRARY_PATH
# Clean path and library path
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-"`
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=LD_LIBRARY_PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt-"`
@ -106,13 +105,12 @@ case "none":
case "system":
# Obtain major.minor from `paraview --version`
set pv_api=`paraview --version | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
set pv_api=`paraview --version | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
if ( "${%pv_api}" ) then
setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api"
else
if ("${pv_api}" == "") then
unsetenv ParaView_DIR PV_PLUGIN_PATH
else
setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api"
endif
if ($?FOAM_VERBOSE && $?prompt) then
@ -138,9 +136,8 @@ default:
breaksw
case [0-9]*:
# Extract API from VERSION
set pv_api=`echo "$ParaView_VERSION" | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
# Extract API from VERSION.
set pv_api=`echo "$ParaView_VERSION" | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
breaksw
endsw

View File

@ -90,8 +90,9 @@ case Linux:
endsw
breaksw
case Darwin: # Presumably x86_64
case Darwin: # Presume x86_64, with clang (not gcc) as system compiler
setenv WM_ARCH darwin64
if ("$WM_COMPILER" == Gcc) setenv WM_COMPILER Clang
echo "Darwin support is clang/llvm only"
breaksw
@ -168,7 +169,7 @@ 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
# Dummy versions of external libraries. To be found last in library path
_foamAddLib "$FOAM_LIBBIN/dummy"
# External (ThirdParty) libraries. Also allowed to be unset

View File

@ -67,7 +67,7 @@ foreach foamDir (\
endif
end
if ( "${%foundDir}" ) then
if ("${foundDir}" == true) then
_foamEcho "Using $WM_THIRD_PARTY_DIR"
else
# Dummy fallback value
@ -141,9 +141,9 @@ endif
# Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Prevent local variables from shadowing setenv variables
unset PATH MANPATH LD_LIBRARY_PATH
if (! $?LD_LIBRARY_PATH ) setenv LD_LIBRARY_PATH
unset PATH MANPATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH
if (! $?MANPATH ) setenv MANPATH
if (! $?LD_LIBRARY_PATH ) setenv LD_LIBRARY_PATH
_foamClean PATH "$foamOldDirs"
_foamClean MANPATH "$foamOldDirs"
@ -185,6 +185,15 @@ if ( $?MANPATH ) then
setenv MANPATH "${MANPATH}:"
endif
if ($?LD_LIBRARY_PATH) then
if ("${LD_LIBRARY_PATH}" == "") unsetenv LD_LIBRARY_PATH
endif
# Darwin
if ($?DYLD_LIBRARY_PATH) then
if ("${DYLD_LIBRARY_PATH}" == "") unsetenv DYLD_LIBRARY_PATH
endif
# Cleanup temporary information
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -23,7 +23,7 @@
unset foamClean
if ( $?WM_PROJECT_DIR ) then
set foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
set foamClean="$WM_PROJECT_DIR/bin/foamCleanPath"
if ( ! -f "$foamClean" || ! -x "$foamClean" ) unset foamClean
endif
@ -141,6 +141,7 @@ unsetenv FFTW_ARCH_PATH
unsetenv GPERFTOOLS_ARCH_PATH
unsetenv GMP_ARCH_PATH
unsetenv MPFR_ARCH_PATH
unsetenv LLVM_ARCH_PATH
unsetenv MESA_ARCH_PATH
unsetenv METIS_ARCH_PATH
unsetenv SCOTCH_ARCH_PATH
@ -155,12 +156,12 @@ if ( $?foamClean ) then
if ($?LD_LIBRARY_PATH) then
eval `$foamClean -csh-env=LD_LIBRARY_PATH "$foamOldDirs"`
if ( ${%LD_LIBRARY_PATH} == 0 ) unsetenv LD_LIBRARY_PATH
if ("${LD_LIBRARY_PATH}" == "") unsetenv LD_LIBRARY_PATH
endif
if ($?MANPATH) then
eval `$foamClean -csh-env=MANPATH "$foamOldDirs"`
if ( ${%MANPATH} == 0 ) unsetenv MANPATH
if ("${MANPATH}" == "") unsetenv MANPATH
endif
endif

View File

@ -212,6 +212,7 @@ then
unset GPERFTOOLS_ARCH_PATH
unset GMP_ARCH_PATH
unset MPFR_ARCH_PATH
unset LLVM_ARCH_PATH
unset MESA_ARCH_PATH
unset METIS_ARCH_PATH
unset SCOTCH_ARCH_PATH

View File

@ -9,12 +9,11 @@
# Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/gperftools
# - sourced by OpenFOAM-*/etc/bashrc
# Not normally sourced by OpenFOAM-*/etc/bashrc
#
# Description
# Setup file for GPERFTOOLS binaries/libraries.

View File

@ -64,7 +64,7 @@ pv_api=auto # Either auto or pair of (major.minor) digits
# Compiler-specific location for ThirdParty installations
archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean PATH and LD_LIBRARY_PATH
# Clean path and library path
eval \
"$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \
$ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-)"

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/paraview-system
@ -26,7 +25,7 @@
# Compiler-specific location for ThirdParty installations
archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean PATH and LD_LIBRARY_PATH
# Clean path and library path
eval \
"$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \
$ParaView_DIR $archDir/ParaView-)"

View File

@ -82,8 +82,9 @@ Linux)
esac
;;
Darwin) # Presumably x86_64
Darwin) # Presume x86_64, with clang (not gcc) as system compiler
WM_ARCH=darwin64
[ "$WM_COMPILER" = Gcc ] && WM_COMPILER=Clang
echo "Darwin support is clang/llvm only" 1>&2
;;
@ -165,7 +166,7 @@ fi
# 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
# Dummy versions of external libraries. To be found last in library path
_foamAddLib "$FOAM_LIBBIN/dummy"
# External (ThirdParty) libraries. Also allowed to be unset

View File

@ -147,7 +147,6 @@ _foamEtc -config settings
_foamEtc -config mpi
_foamEtc -config paraview -- "$@" # Pass through for evaluation
_foamEtc -config vtk
_foamEtc -config gperftools
_foamEtc -config adios2
_foamEtc -config CGAL
_foamEtc -config scotch

View File

@ -137,6 +137,7 @@ unset FFTW_ARCH_PATH
unset GPERFTOOLS_ARCH_PATH
unset GMP_ARCH_PATH
unset MPFR_ARCH_PATH
unset LLVM_ARCH_PATH
unset MESA_ARCH_PATH
unset KAHIP_ARCH_PATH
unset METIS_ARCH_PATH

View File

@ -105,9 +105,9 @@ setenv WM_PROJECT OpenFOAM
# later on in this file.
# --
# If the directory naming does not match WM_PROJECT, need to change here
# Important! No line continuation in the lsof evaluation (#1668)
set projectName="$WM_PROJECT"
set projectDir=`lsof +p $$ |& \
sed -ne 's@^[^/]*@@;\@/'"$projectName"'[^/]*/etc/cshrc@{s@/etc/cshrc.*@@p; q}'`
set projectDir=`lsof +p $$ |& sed -ne 's#^[^/]*##;\@/'"$projectName"'[^/]*/etc/cshrc@{s#/etc/cshrc.*##p;q; }'`
# set projectDir="$HOME/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
# set projectDir="/opt/openfoam/OpenFOAM-$WM_PROJECT_VERSION"