ENH: streamline handling of static/dynamic libs in detection scripts

This commit is contained in:
Mark Olesen
2019-04-29 10:04:44 +02:00
committed by Andrew Heather
parent beefee48d4
commit 897528da1a
17 changed files with 341 additions and 436 deletions

View File

@ -6,13 +6,13 @@ cd ${0%/*} || exit 1 # Run from this directory
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Only build when the OpenFOAM libccm adaptor already exists # Only build when the OpenFOAM libccm adaptor already exists
if [ -f $FOAM_LIBBIN/libccm$extLibso ] if findLibrary "$FOAM_LIBBIN/libccm" > /dev/null
then then
echo "==> build optional ccm conversion components" echo "==> build optional ccm conversion components"
wmake $targetType ccmToFoam wmake $targetType ccmToFoam
wmake $targetType foamToCcm wmake $targetType foamToCcm
else else
echo "==> skip optional ccm conversion components (no libccm$extLibso)" echo "==> skip optional ccm conversion components (no libccm)"
fi fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -8,20 +8,17 @@ cd ${0%/*} || exit 1 # Run from this directory
unset COMP_FLAGS LINK_FLAGS unset COMP_FLAGS LINK_FLAGS
if [ -f $FOAM_LIBBIN/libSloanRenumber$extLibso ] if findLibrary "$FOAM_LIBBIN/libSloanRenumber" > /dev/null
then then
echo " found libSloanRenumber -- enabling sloan renumbering support." echo " found libSloanRenumber -- enabling sloan renumbering support."
export LINK_FLAGS="$LINK_FLAGS -lSloanRenumber" export LINK_FLAGS="$LINK_FLAGS -lSloanRenumber"
fi fi
if [ -f $FOAM_LIBBIN/libzoltanRenumber$extLibso ] if findLibrary "$FOAM_LIBBIN/libzoltanRenumber" > /dev/null && have_zoltan
then then
if have_zoltan echo " found libzoltanRenumber -- enabling zoltan renumbering support."
then export COMP_FLAGS="$COMP_FLAGS -DHAVE_ZOLTAN"
echo " found libzoltanRenumber -- enabling zoltan renumbering support." export LINK_FLAGS="$LINK_FLAGS -lzoltanRenumber -L$ZOLTAN_LIB_DIR -lzoltan"
export COMP_FLAGS="$COMP_FLAGS -DHAVE_ZOLTAN"
export LINK_FLAGS="$LINK_FLAGS -lzoltanRenumber -L$ZOLTAN_LIB_DIR -lzoltan"
fi
fi fi
wmake $targetType wmake $targetType

View File

@ -54,7 +54,7 @@ echo_adios2()
# -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR # -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR
have_adios2() have_adios2()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
# warn="==> skip adios2" # warn="==> skip adios2"
# Setup # Setup
@ -66,12 +66,10 @@ have_adios2()
return 2 return 2
fi fi
# Location # Expected location, include/library names
prefix="$ADIOS2_ARCH_PATH" prefix="$ADIOS2_ARCH_PATH"
incName="adios2.h"
# Header/library names libName="libadios2"
header="adios2.h"
library="libadios2$extLibso"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -80,40 +78,34 @@ have_adios2()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
# OK # OK
export HAVE_ADIOS2=true export HAVE_ADIOS2=true
export ADIOS2_ARCH_PATH="$prefix" export ADIOS2_ARCH_PATH="$prefix"

View File

@ -54,17 +54,15 @@ echo_boost()
# -> HAVE_BOOST, BOOST_INC_DIR, BOOST_LIB_DIR # -> HAVE_BOOST, BOOST_INC_DIR, BOOST_LIB_DIR
have_boost() have_boost()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
# warn="==> skip boost" # warn="==> skip boost"
# Setup - from the current environment # Setup - from the current environment
# Location # Expected location, include/library names
prefix="$BOOST_ARCH_PATH" prefix="$BOOST_ARCH_PATH"
incName="boost/version.hpp"
# Header/library names libName="libboost_system"
header="boost/version.hpp"
library="libboost_system$extLibso"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -73,40 +71,33 @@ have_boost()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
header="${header%/*}" # Strip one-level (include/boost/...) header="${header%/*}" # Strip one-level (include/boost/...)

View File

@ -53,10 +53,10 @@ echo_ccmio()
# -> HAVE_CCMIO, CCMIO_INC_DIR, CCMIO_LIB_DIR # -> HAVE_CCMIO, CCMIO_INC_DIR, CCMIO_LIB_DIR
have_ccmio() have_ccmio()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
warn="==> skip ccmio" warn="==> skip ccmio"
# Setup # Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio) if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
then then
. "$settings" . "$settings"
@ -65,13 +65,11 @@ have_ccmio()
return 2 return 2
fi fi
# Location # Expected location, include/library names
prefix="$CCMIO_ARCH_PATH"
# Header/library names.
# Link with static libccmio only (fewer issues) # Link with static libccmio only (fewer issues)
header="libccmio/ccmio.h" prefix="$CCMIO_ARCH_PATH"
static="libccmio$extLiba" incName="libccmio/ccmio.h"
libName="libccmio.a"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -80,30 +78,29 @@ have_ccmio()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
# The libccmio uses int32_t. # The libccmio uses int32_t.
# The OpenFOAM adapter thus requires additional work for 64-bit labels. # The OpenFOAM adapter thus requires additional work for 64-bit labels.

View File

@ -54,17 +54,15 @@ echo_cgal()
# -> HAVE_CGAL, CGAL_INC_DIR, CGAL_LIB_DIR # -> HAVE_CGAL, CGAL_INC_DIR, CGAL_LIB_DIR
have_cgal() have_cgal()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
# warn="==> skip cgal" # warn="==> skip cgal"
# Setup - from the current environment # Setup - from the current environment
# Location # Expected location, include/library names
prefix="$CGAL_ARCH_PATH" prefix="$CGAL_ARCH_PATH"
incName="CGAL/version.h"
# Header/library names libName="libCGAL"
header="CGAL/version.h"
library="libCGAL$extLibso"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -73,40 +71,34 @@ have_cgal()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
header="${header%/*}" # Strip one-level (include/CGAL/...) header="${header%/*}" # Strip one-level (include/CGAL/...)
# OK # OK

View File

@ -54,18 +54,15 @@ echo_fftw()
# -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR # -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR
have_fftw() have_fftw()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
# warn="==> skip fftw" # warn="==> skip fftw"
# Setup - from the current environment # Setup - from the current environment
# Location # Expected location, include/library names
prefix="$FFTW_ARCH_PATH" prefix="$FFTW_ARCH_PATH"
incName="fftw3.h"
# Header/library names libName="libfftw3"
header="fftw3.h"
library="libfftw3$extLibso"
static="libfftw3$extLiba"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -74,42 +71,34 @@ have_fftw()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
# OK # OK
export HAVE_FFTW=true export HAVE_FFTW=true
export FFTW_ARCH_PATH="$prefix" export FFTW_ARCH_PATH="$prefix"

View File

@ -54,7 +54,7 @@ echo_hypre()
# -> HAVE_HYPRE, HYPRE_INC_DIR, HYPRE_LIB_DIR # -> HAVE_HYPRE, HYPRE_INC_DIR, HYPRE_LIB_DIR
have_hypre() have_hypre()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
warn="==> skip hypre" warn="==> skip hypre"
# Setup - prefer current environment value? (TDB) # Setup - prefer current environment value? (TDB)
@ -69,12 +69,10 @@ have_hypre()
fi fi
fi fi
# Location # Expected location, include/library names
prefix="$HYPRE_ARCH_PATH" prefix="$HYPRE_ARCH_PATH"
incName="HYPRE.h"
# Header/library names libName="libHYPRE"
header="HYPRE.h"
library="libHYPRE$extLibso"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -83,40 +81,33 @@ have_hypre()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
# OK # OK
export HAVE_HYPRE=true export HAVE_HYPRE=true

View File

@ -55,7 +55,7 @@ echo_kahip()
# -> HAVE_KAHIP, KAHIP_ARCH_PATH, KAHIP_INC_DIR, KAHIP_LIB_DIR # -> HAVE_KAHIP, KAHIP_ARCH_PATH, KAHIP_INC_DIR, KAHIP_LIB_DIR
have_kahip() have_kahip()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
warn="==> skip kahip" warn="==> skip kahip"
# Setup # Setup
@ -67,13 +67,10 @@ have_kahip()
return 1 return 1
fi fi
# Location # Expected location, include/library names
prefix="$KAHIP_ARCH_PATH" prefix="$KAHIP_ARCH_PATH"
incName="kaHIP_interface.h"
# Header/library names libName="libkahip"
header="kaHIP_interface.h"
library="libkahip$extLibso"
static="libkahip$extLiba"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -82,42 +79,33 @@ have_kahip()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
# kahip itself is 32-bit int, but our interface itself handles some # kahip itself is 32-bit int, but our interface itself handles some
# 64-bit conversion (mesh size). # 64-bit conversion (mesh size).

View File

@ -55,7 +55,7 @@ echo_metis()
# -> HAVE_METIS, METIS_ARCH_PATH, METIS_INC_DIR, METIS_LIB_DIR # -> HAVE_METIS, METIS_ARCH_PATH, METIS_INC_DIR, METIS_LIB_DIR
have_metis() have_metis()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
warn="==> skip metis" warn="==> skip metis"
# Setup # Setup
@ -67,13 +67,10 @@ have_metis()
return 2 return 2
fi fi
# Location # Expected location, include/library names
prefix="$METIS_ARCH_PATH" prefix="$METIS_ARCH_PATH"
incName="metis.h"
# Header/library names libName="libmetis"
header="metis.h"
library="libmetis$extLibso"
static="libmetis$extLiba"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -82,42 +79,33 @@ have_metis()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
local good label local good label

View File

@ -55,7 +55,7 @@ echo_mgridgen()
# -> HAVE_MGRIDGEN, MGRIDGEN_ARCH_PATH, MGRIDGEN_INC_DIR, MGRIDGEN_LIB_DIR # -> HAVE_MGRIDGEN, MGRIDGEN_ARCH_PATH, MGRIDGEN_INC_DIR, MGRIDGEN_LIB_DIR
have_mgridgen() have_mgridgen()
{ {
local prefix header library static settings warn local prefix header library incName libName libName2 settings warn
warn="==> skip mgridgen" warn="==> skip mgridgen"
# Setup # Setup
@ -67,13 +67,11 @@ have_mgridgen()
return 2 return 2
fi fi
# Location # Expected location, include/library names
prefix="$MGRIDGEN_ARCH_PATH" prefix="$MGRIDGEN_ARCH_PATH"
incName="mgridgen.h"
# Header/library names libName="libMGridGen"
header="mgridgen.h" libName2="libmgrid"
library="libMGridGen$extLibso"
static="libmgrid$extLiba"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -82,42 +80,36 @@ have_mgridgen()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName $libName2)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
#silent# [ -n "$warn" ] && echo "$warn (no header)" #silent# [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib/$libName2" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName2" \
) || {
#silent# [ -n "$warn" ] && echo "$warn (no library)" #silent# [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
local good label scalar local good label scalar
# Ensure consistent sizes with OpenFOAM and mgridgen header # Ensure consistent sizes with OpenFOAM and mgridgen header

View File

@ -54,7 +54,7 @@ echo_petsc()
# -> HAVE_PETSC, PETSC_INC_DIR, PETSC_LIB_DIR # -> HAVE_PETSC, PETSC_INC_DIR, PETSC_LIB_DIR
have_petsc() have_petsc()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
warn="==> skip petsc" warn="==> skip petsc"
# Setup - prefer current environment value? (TDB) # Setup - prefer current environment value? (TDB)
@ -69,12 +69,10 @@ have_petsc()
fi fi
fi fi
# Location # Expected location, include/library names
prefix="$PETSC_ARCH_PATH" prefix="$PETSC_ARCH_PATH"
incName="petsc.h"
# Header/library names libName="libpetsc"
header="petsc.h"
library="libpetsc$extLibso"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -83,40 +81,34 @@ have_petsc()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
# TODO: check size of petsc integer vs label # TODO: check size of petsc integer vs label
# OK # OK

View File

@ -52,15 +52,13 @@ echo_readline()
# -> HAVE_LIBREADLINE, READLINE_INC_DIR, READLINE_LIB_DIR # -> HAVE_LIBREADLINE, READLINE_INC_DIR, READLINE_LIB_DIR
have_readline() have_readline()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
# warn="==> skip readline" # warn="==> skip readline"
# Location # Expected location, include/library names
prefix=system prefix=system
incName="readline/readline.h"
# Header/library names libName="libreadline"
header="readline/readline.h"
library="libreadline$extLibso"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -69,39 +67,34 @@ have_readline()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
header="${header%/*}" # Strip one-level (include/readline/...) header="${header%/*}" # Strip one-level (include/readline/...)
# OK # OK

View File

@ -61,7 +61,7 @@ echo_scotch()
# -> HAVE_SCOTCH, SCOTCH_ARCH_PATH, SCOTCH_INC_DIR, SCOTCH_LIB_DIR # -> HAVE_SCOTCH, SCOTCH_ARCH_PATH, SCOTCH_INC_DIR, SCOTCH_LIB_DIR
have_scotch() have_scotch()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
warn="==> skip scotch" warn="==> skip scotch"
# Setup # Setup
@ -73,13 +73,10 @@ have_scotch()
return 2 return 2
fi fi
# Location # Expected location, include/library names
prefix="$SCOTCH_ARCH_PATH" prefix="$SCOTCH_ARCH_PATH"
incName="scotch.h"
# Header/library names libName="libscotch"
header="scotch.h"
library="libscotch$extLibso"
static="libscotch$extLiba"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -88,50 +85,39 @@ have_scotch()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr
header=$(findFirstFile \ header=$(findFirstFile \
"/usr/local/include/scotch/$header" \ "/usr/local/include/scotch/$incName" \
"/usr/local/include/$header" \ "/usr/local/include/$incName" \
"/usr/include/scotch/$header" \ "/usr/include/scotch/$incName" \
"/usr/include/$header" \ "/usr/include/$incName" \
)
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
) )
prefix=$(sysPrefix "$header")
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
local good label local good label
# Ensure consistent sizes between OpenFOAM and scotch header # Ensure consistent sizes between OpenFOAM and scotch header
@ -189,7 +175,7 @@ have_scotch()
# -> HAVE_PTSCOTCH, PTSCOTCH_ARCH_PATH, PTSCOTCH_INC_DIR, PTSCOTCH_LIB_DIR # -> HAVE_PTSCOTCH, PTSCOTCH_ARCH_PATH, PTSCOTCH_INC_DIR, PTSCOTCH_LIB_DIR
have_ptscotch() have_ptscotch()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
warn="==> skip ptscotch" warn="==> skip ptscotch"
if [ "$HAVE_SCOTCH" != true ] if [ "$HAVE_SCOTCH" != true ]
@ -201,13 +187,10 @@ have_ptscotch()
# Reuse old settings # Reuse old settings
[ -n "$PTSCOTCH_ARCH_PATH" ] || PTSCOTCH_ARCH_PATH="$SCOTCH_ARCH_PATH" [ -n "$PTSCOTCH_ARCH_PATH" ] || PTSCOTCH_ARCH_PATH="$SCOTCH_ARCH_PATH"
# Location # Expected location, include/library names
prefix="$PTSCOTCH_ARCH_PATH" prefix="$PTSCOTCH_ARCH_PATH"
incName="ptscotch.h"
# Header/library names libName="libptscotch"
header="ptscotch.h"
library="libptscotch$extLibso"
static="libptscotch$extLiba"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -217,55 +200,44 @@ have_ptscotch()
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile \ header=$(findFirstFile \
"$prefix/include/$FOAM_MPI/$header" \ "$prefix/include/$FOAM_MPI/$incName" \
"$prefix/include/$header" "$prefix/include/$incName"
) )
library="$(findExtLib $FOAM_MPI/$libName $libName)"
library=$(findFirstFile \
"$(thirdExtLib $FOAM_MPI/$library)" \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr prefix=/usr
header=$(findFirstFile \ header=$(findFirstFile \
"/usr/local/include/ptscotch/$header" \ "/usr/local/include/ptscotch/$incName" \
"/usr/local/include/scotch/$header" \ "/usr/local/include/scotch/$incName" \
"/usr/local/include/$header" \ "/usr/local/include/$incName" \
"/usr/include/ptscotch/$header" \ "/usr/include/ptscotch/$incName" \
"/usr/include/scotch/$header" \ "/usr/include/scotch/$incName" \
"/usr/include/$header" \ "/usr/include/$incName" \
) )
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
# OK # OK
echo "ptscotch - $prefix" echo "ptscotch - $prefix"
export HAVE_PTSCOTCH=true export HAVE_PTSCOTCH=true

View File

@ -54,7 +54,7 @@ echo_zoltan()
# -> HAVE_ZOLTAN, ZOLTAN_INC_DIR, ZOLTAN_LIB_DIR # -> HAVE_ZOLTAN, ZOLTAN_INC_DIR, ZOLTAN_LIB_DIR
have_zoltan() have_zoltan()
{ {
local prefix header library static settings warn local prefix header library incName libName settings warn
# warn="==> skip zoltan" # warn="==> skip zoltan"
# Setup # Setup
@ -66,13 +66,10 @@ have_zoltan()
return 2 return 2
fi fi
# Location # Expected location, include/library names
prefix="$ZOLTAN_ARCH_PATH" prefix="$ZOLTAN_ARCH_PATH"
incName="zoltan.h"
# Header/library names libName="libzoltan"
header="zoltan.h"
library="libzoltan$extLibso"
static="libzoltan$extLiba"
# ---------------------------------- # ----------------------------------
if isNone "$prefix" if isNone "$prefix"
@ -81,42 +78,34 @@ have_zoltan()
return 1 return 1
elif hasAbsdir "$prefix" elif hasAbsdir "$prefix"
then then
header=$(findFirstFile "$prefix/include/$header") header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
elif isSystem "$prefix" elif isSystem "$prefix"
then then
prefix=/usr header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") prefix=$(sysPrefix "$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
else else
unset prefix header library unset prefix
fi fi
# ---------------------------------- # ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# Library found? # Library
[ -n "$library" ] || { [ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)" [ -n "$warn" ] && echo "$warn (no library)"
return 2 return 2
} }
# ----------------------------------
# OK # OK
export HAVE_ZOLTAN=true export HAVE_ZOLTAN=true
export ZOLTAN_ARCH_PATH="$prefix" export ZOLTAN_ARCH_PATH="$prefix"

View File

@ -135,7 +135,7 @@ have_pvplugin_support()
return 1 return 1
} }
# Header/library names # Include/library names
header="pqServerManagerModel.h" header="pqServerManagerModel.h"
if [ -n "$ParaView_DIR" ] if [ -n "$ParaView_DIR" ]
@ -173,13 +173,16 @@ have_pvplugin_support()
) )
fi fi
# ----------------------------------
# Header found? # Header
[ -n "$header" ] || { [ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)" [ -n "$warn" ] && echo "$warn (no header)"
return 2 return 2
} }
# ----------------------------------
# OK # OK
export HAVE_PVPLUGIN_SUPPORT=true export HAVE_PVPLUGIN_SUPPORT=true
export FOAM_PV_PLUGIN_LIBBIN="$targetDir" export FOAM_PV_PLUGIN_LIBBIN="$targetDir"

View File

@ -16,16 +16,14 @@
# General system helper functions # General system helper functions
# #
# Functions provided # Functions provided
# isDarwin # isNone, isSystem, isAbsdir, hasAbsdir
# isNone # isDarwin, isWindows
# isSystem
# isAbsdir, hasAbsdir
# findFirstFile # findFirstFile
# thirdExtLib # findLibrary
# findExtLib
# #
# Variables provided # Internal variables used
# extLiba # extLibraries
# extLibso
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -34,37 +32,30 @@ then
# Load once, but do not rely on this variable elsewhere # Load once, but do not rely on this variable elsewhere
WMAKE_SCRIPTS_SYSFUNCTIONS=loaded WMAKE_SCRIPTS_SYSFUNCTIONS=loaded
# Static library extension (default=".a") # True if OS is Darwin.
extLiba=".a"
# Shared library extension (default=".so")
extLibso=".so"
# Adjustments
case "$(uname -s 2>/dev/null)" in
Darwin)
extLibso=".dylib"
;;
*)
## Other. Eg, extLibso=".dll" or extLibso=".dll.a"
;;
esac
# True if target OS is Darwin.
# Uses cached value from libso extension
isDarwin() isDarwin()
{ {
test "$extLibso" = ".dylib" test Darwin = "$(uname -s 2>/dev/null)"
} }
# True if target OS is Windows # True if target OS is Windows
# Uses cached value from libso extension # Uses cached value from libso extension
isWindows() isWindows()
{ {
test "$extLibso" = ".dll" || "$extLibso" = ".dll.a" test MSwindows = "$WM_OSTYPE"
} }
# Static, dynamic library extensions
extLibraries=".a .so"
if isDarwin
then
extLibraries=".a .dylib"
elif isWindows
then
extLibraries=".a .dll .dll.a" # including cross-compiling
fi
# True if '$1' begins with '/' # True if '$1' begins with '/'
isAbsdir() isAbsdir()
@ -98,41 +89,89 @@ then
} }
# Check for the existence of any of the files # Return system prefix (/usr, /usr/local, ...) based on hint provided
# Eg,
# sysPrefix "/usr/local/include/fftw3.h" -> "/usr/local"
#
# Without a hint, echoes "/usr"
sysPrefix()
{
case "$1" in
/usr/local/*)
echo "/usr/local"
;;
*)
echo "/usr"
;;
esac
}
# Check existence of any of the files
# On success, echoes the file found and returns 0, otherwise returns 2 # On success, echoes the file found and returns 0, otherwise returns 2
findFirstFile() findFirstFile()
{ {
local file local file
for file for file
do do
if [ -f "$file" -a -r "$file" ] if [ -f "$file" ] && [ -r "$file" ]
then then
echo "$file" echo "$file" # Found
return 0 return 0
fi fi
done done
return 2 return 2
} }
# Check for existence of file in FOAM_EXT_LIBBIN,
# but not if either file or FOAM_EXT_LIBBIN are empty or # Check existence of library with ending '.a', '.so' ...
# if the FOAM_EXT_LIBBIN is not located in the ThirdParty directory
# #
# On success, echoes the resolved file and returns 0, otherwise returns 2 # On success, echoes the resolved file and returns 0, otherwise returns 2
thirdExtLib() findLibrary()
{ {
local file="$FOAM_EXT_LIBBIN/$1" local file ext
if [ -n "$1" ] && \ for file
[ -n "$FOAM_EXT_LIBBIN" ] && \ do
[ -n "$WM_THIRD_PARTY_DIR" ] && \ [ -n "$file" ] || continue
[ -f "$file" -a -r "$file" ] && \ for ext in '' $extLibraries
[ "${FOAM_EXT_LIBBIN#$WM_THIRD_PARTY_DIR}" != "$FOAM_EXT_LIBBIN" ] do
if [ -f "$file$ext" ] && [ -r "$file$ext" ]
then
echo "$file$ext" # Found
return 0
fi
done
done
return 2
}
# Check existence of library in FOAM_EXT_LIBBIN, but conditional
# on FOAM_EXT_LIBBIN being located in the ThirdParty directory
#
# On success, echoes the resolved file and returns 0, otherwise returns 2
findExtLib()
{
local file
if [ -n "$FOAM_EXT_LIBBIN" ] && \
[ -n "$WM_THIRD_PARTY_DIR" ] && \
[ "${FOAM_EXT_LIBBIN#$WM_THIRD_PARTY_DIR}" != "$FOAM_EXT_LIBBIN" ]
then then
echo "$file" for file
else do
return 2 if file="$(findLibrary "$FOAM_EXT_LIBBIN/$file")"
then
echo "$file"
return 0
fi
done
fi fi
return 2
} }
fi fi