mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
CONFIG: improve prefix matching for system libraries (#1607)
- missed detection of system libraries when installed with multiarch paths like /usr/lib/x86_64-linux-gnu CONFIG: improve handling of group/user config files (#928) - changed bashrc handling of FOAM_CONFIG_NOUSER to use FOAM_CONFIG_MODE instead. Propagate into foamEtcFile to make this a stickier control. This change allows better control, but also enables cluster installations to define their own value within the OpenFOAM prefs.sh file to prevent users accidentally mis-configuring things if necessary. - remove undocumented handling of an (a)ll mode in foamEtcFile to avoid potential pitfalls. - add support for FOAM_CONFIG_ETC handling. This allows injection of an extra search layer when finding project etc files ENH: improvements to foamConfigurePaths (#928) - handle FOAM_CONFIG_ETC implicitly, or explicitly with the new -etc option. STYLE: more explicit wording in foamConfigurePaths usage (#1602) - document that an absolute path (eg, -scotch-path) overrides/ignores the equivalent ThirdParty setting (eg, -scotch) - longer options -system-compiler and -third-compiler for -system and -third, respectively. Clearer as to their purpose. - adjust the location sanity check to look for META-INFO directory.
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
# Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
@ -21,12 +21,18 @@
|
||||
# isNone, isSystem, isAbsdir, hasAbsdir
|
||||
# isDarwin, isWindows
|
||||
# findFirstFile
|
||||
# findSystemInclude
|
||||
# findLibrary
|
||||
# findExtLib
|
||||
#
|
||||
# Internal variables used
|
||||
# extLibraries
|
||||
#
|
||||
# External variables used
|
||||
# WM_OSTYPE (is set for Windows)
|
||||
# WM_COMPILER_LIB_ARCH
|
||||
# DEB_TARGET_MULTIARCH
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$WMAKE_SCRIPTS_SYSFUNCTIONS" ]
|
||||
@ -34,14 +40,19 @@ then
|
||||
# Load once, but do not rely on this variable elsewhere
|
||||
WMAKE_SCRIPTS_SYSFUNCTIONS=loaded
|
||||
|
||||
# Handle Debian multi-arch, ignore missing/bad dpkg-architecture.
|
||||
if [ -z "$DEB_TARGET_MULTIARCH" ]
|
||||
then
|
||||
DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)
|
||||
fi
|
||||
|
||||
# True if OS is Darwin.
|
||||
isDarwin()
|
||||
{
|
||||
test Darwin = "$(uname -s 2>/dev/null)"
|
||||
test Darwin = "$(uname -s 2>/dev/null || true)"
|
||||
}
|
||||
|
||||
# True if target OS is Windows
|
||||
# Uses cached value from libso extension
|
||||
isWindows()
|
||||
{
|
||||
test MSwindows = "$WM_OSTYPE"
|
||||
@ -58,7 +69,6 @@ then
|
||||
extLibraries=".a .dll .dll.a" # including cross-compiling
|
||||
fi
|
||||
|
||||
|
||||
# True if '$1' begins with '/'
|
||||
isAbsdir()
|
||||
{
|
||||
@ -126,27 +136,114 @@ then
|
||||
return 2
|
||||
}
|
||||
|
||||
# Check system /usr/local/include /usr/include paths
|
||||
#
|
||||
# On success, echoes the resolved file and returns 0, otherwise returns 2
|
||||
#
|
||||
# Specify -name=incName to search for
|
||||
#
|
||||
findSystemInclude()
|
||||
{
|
||||
local searchName
|
||||
|
||||
case "$1" in
|
||||
-name=*)
|
||||
searchName="${1#*=}"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$searchName" ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
||||
findFirstFile \
|
||||
"/usr/local/include/$searchName" \
|
||||
"/usr/include/$searchName" \
|
||||
;
|
||||
}
|
||||
|
||||
# Check existence of library with ending '.a', '.so' ...
|
||||
#
|
||||
# On success, echoes the resolved file and returns 0, otherwise returns 2
|
||||
#
|
||||
# This function has two modes of operation.
|
||||
#
|
||||
# 1) Automated search.
|
||||
# Specify -prefix=dirName -name=libName and search for
|
||||
# (lib, lib64, lib/x86_64..) etc.
|
||||
#
|
||||
# 2) Directed search.
|
||||
# specify the fully qualified names to search on the parameter list
|
||||
#
|
||||
findLibrary()
|
||||
{
|
||||
local prefixDir searchDir searchName
|
||||
local file ext
|
||||
|
||||
for file
|
||||
searchDir=true
|
||||
|
||||
while [ "$searchDir" = true ] && [ "$#" -gt 0 ]
|
||||
do
|
||||
[ -n "$file" ] || continue
|
||||
for ext in '' $extLibraries
|
||||
do
|
||||
if [ -f "$file$ext" ] && [ -r "$file$ext" ]
|
||||
then
|
||||
echo "$file$ext" # Found
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
case "$1" in
|
||||
-prefix=*)
|
||||
prefixDir="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
|
||||
-name=*)
|
||||
searchName="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
|
||||
(*)
|
||||
unset searchDir
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "$searchName" ]
|
||||
then
|
||||
# Automated search
|
||||
# Eg, lib/ lib64/, lib/x86_64-linux-gnu
|
||||
|
||||
: "${prefixDir:=/usr}" # A reasonable default
|
||||
[ -d "$prefixDir" ] || return 2
|
||||
|
||||
for searchDir in \
|
||||
lib \
|
||||
"${WM_COMPILER_LIB_ARCH:+lib}$WM_COMPILER_LIB_ARCH" \
|
||||
"${DEB_TARGET_MULTIARCH:+lib/}${DEB_TARGET_MULTIARCH}" \
|
||||
;
|
||||
do
|
||||
for ext in '' $extLibraries
|
||||
do
|
||||
file="$prefixDir/$searchDir/$searchName$ext"
|
||||
if [ -f "$file" ] && [ -r "$file" ]
|
||||
then
|
||||
echo "$file" # Found
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
else
|
||||
# Directed search
|
||||
|
||||
for file
|
||||
do
|
||||
[ -n "$file" ] || continue
|
||||
for ext in '' $extLibraries
|
||||
do
|
||||
if [ -f "$file$ext" ] && [ -r "$file$ext" ]
|
||||
then
|
||||
echo "$file$ext" # Found
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
return 2
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user