Commit 897528da authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

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

parent beefee48
......@@ -6,13 +6,13 @@ cd ${0%/*} || exit 1 # Run from this directory
#------------------------------------------------------------------------------
# Only build when the OpenFOAM libccm adaptor already exists
if [ -f $FOAM_LIBBIN/libccm$extLibso ]
if findLibrary "$FOAM_LIBBIN/libccm" > /dev/null
then
echo "==> build optional ccm conversion components"
wmake $targetType ccmToFoam
wmake $targetType foamToCcm
else
echo "==> skip optional ccm conversion components (no libccm$extLibso)"
echo "==> skip optional ccm conversion components (no libccm)"
fi
#------------------------------------------------------------------------------
......@@ -8,20 +8,17 @@ cd ${0%/*} || exit 1 # Run from this directory
unset COMP_FLAGS LINK_FLAGS
if [ -f $FOAM_LIBBIN/libSloanRenumber$extLibso ]
if findLibrary "$FOAM_LIBBIN/libSloanRenumber" > /dev/null
then
echo " found libSloanRenumber -- enabling sloan renumbering support."
echo " found libSloanRenumber -- enabling sloan renumbering support."
export LINK_FLAGS="$LINK_FLAGS -lSloanRenumber"
fi
if [ -f $FOAM_LIBBIN/libzoltanRenumber$extLibso ]
if findLibrary "$FOAM_LIBBIN/libzoltanRenumber" > /dev/null && have_zoltan
then
if have_zoltan
then
echo " found libzoltanRenumber -- enabling zoltan renumbering support."
export COMP_FLAGS="$COMP_FLAGS -DHAVE_ZOLTAN"
export LINK_FLAGS="$LINK_FLAGS -lzoltanRenumber -L$ZOLTAN_LIB_DIR -lzoltan"
fi
echo " found libzoltanRenumber -- enabling zoltan renumbering support."
export COMP_FLAGS="$COMP_FLAGS -DHAVE_ZOLTAN"
export LINK_FLAGS="$LINK_FLAGS -lzoltanRenumber -L$ZOLTAN_LIB_DIR -lzoltan"
fi
wmake $targetType
......
......@@ -54,7 +54,7 @@ echo_adios2()
# -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR
have_adios2()
{
local prefix header library static settings warn
local prefix header library incName libName settings warn
# warn="==> skip adios2"
# Setup
......@@ -66,12 +66,10 @@ have_adios2()
return 2
fi
# Location
# Expected location, include/library names
prefix="$ADIOS2_ARCH_PATH"
# Header/library names
header="adios2.h"
library="libadios2$extLibso"
incName="adios2.h"
libName="libadios2"
# ----------------------------------
if isNone "$prefix"
......@@ -80,40 +78,34 @@ have_adios2()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$header")
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
elif isSystem "$prefix"
then
prefix=/usr
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
prefix=$(sysPrefix "$header")
else
unset prefix header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
# Library
[ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# OK
export HAVE_ADIOS2=true
export ADIOS2_ARCH_PATH="$prefix"
......
......@@ -54,17 +54,15 @@ echo_boost()
# -> HAVE_BOOST, BOOST_INC_DIR, BOOST_LIB_DIR
have_boost()
{
local prefix header library static settings warn
local prefix header library incName libName settings warn
# warn="==> skip boost"
# Setup - from the current environment
# Location
# Expected location, include/library names
prefix="$BOOST_ARCH_PATH"
# Header/library names
header="boost/version.hpp"
library="libboost_system$extLibso"
incName="boost/version.hpp"
libName="libboost_system"
# ----------------------------------
if isNone "$prefix"
......@@ -73,40 +71,33 @@ have_boost()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$header")
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
elif isSystem "$prefix"
then
prefix=/usr
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
prefix=$(sysPrefix "$header")
else
unset prefix header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
# Library
[ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
header="${header%/*}" # Strip one-level (include/boost/...)
......
......@@ -53,10 +53,10 @@ echo_ccmio()
# -> HAVE_CCMIO, CCMIO_INC_DIR, CCMIO_LIB_DIR
have_ccmio()
{
local prefix header library static settings warn
local prefix header library incName libName settings warn
warn="==> skip ccmio"
# Setup
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
then
. "$settings"
......@@ -65,13 +65,11 @@ have_ccmio()
return 2
fi
# Location
prefix="$CCMIO_ARCH_PATH"
# Header/library names.
# Expected location, include/library names
# Link with static libccmio only (fewer issues)
header="libccmio/ccmio.h"
static="libccmio$extLiba"
prefix="$CCMIO_ARCH_PATH"
incName="libccmio/ccmio.h"
libName="libccmio.a"
# ----------------------------------
if isNone "$prefix"
......@@ -80,30 +78,29 @@ have_ccmio()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$header")
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
)
header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
else
unset prefix header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
# Library
[ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# The libccmio uses int32_t.
# The OpenFOAM adapter thus requires additional work for 64-bit labels.
......
......@@ -54,17 +54,15 @@ echo_cgal()
# -> HAVE_CGAL, CGAL_INC_DIR, CGAL_LIB_DIR
have_cgal()
{
local prefix header library static settings warn
local prefix header library incName libName settings warn
# warn="==> skip cgal"
# Setup - from the current environment
# Location
# Expected location, include/library names
prefix="$CGAL_ARCH_PATH"
# Header/library names
header="CGAL/version.h"
library="libCGAL$extLibso"
incName="CGAL/version.h"
libName="libCGAL"
# ----------------------------------
if isNone "$prefix"
......@@ -73,40 +71,34 @@ have_cgal()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$header")
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
elif isSystem "$prefix"
then
prefix=/usr
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
prefix=$(sysPrefix "$header")
else
unset prefix header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
# Library
[ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
header="${header%/*}" # Strip one-level (include/CGAL/...)
# OK
......
......@@ -54,18 +54,15 @@ echo_fftw()
# -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR
have_fftw()
{
local prefix header library static settings warn
local prefix header library incName libName settings warn
# warn="==> skip fftw"
# Setup - from the current environment
# Location
# Expected location, include/library names
prefix="$FFTW_ARCH_PATH"
# Header/library names
header="fftw3.h"
library="libfftw3$extLibso"
static="libfftw3$extLiba"
incName="fftw3.h"
libName="libfftw3"
# ----------------------------------
if isNone "$prefix"
......@@ -74,42 +71,34 @@ have_fftw()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$header")
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
elif isSystem "$prefix"
then
prefix=/usr
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
prefix=$(sysPrefix "$header")
else
unset prefix header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
# Library
[ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# OK
export HAVE_FFTW=true
export FFTW_ARCH_PATH="$prefix"
......
......@@ -54,7 +54,7 @@ echo_hypre()
# -> HAVE_HYPRE, HYPRE_INC_DIR, HYPRE_LIB_DIR
have_hypre()
{
local prefix header library static settings warn
local prefix header library incName libName settings warn
warn="==> skip hypre"
# Setup - prefer current environment value? (TDB)
......@@ -69,12 +69,10 @@ have_hypre()
fi
fi
# Location
# Expected location, include/library names
prefix="$HYPRE_ARCH_PATH"
# Header/library names
header="HYPRE.h"
library="libHYPRE$extLibso"
incName="HYPRE.h"
libName="libHYPRE"
# ----------------------------------
if isNone "$prefix"
......@@ -83,40 +81,33 @@ have_hypre()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$header")
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
elif isSystem "$prefix"
then
prefix=/usr
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
prefix=$(sysPrefix "$header")
else
unset prefix header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
# Library
[ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# OK
export HAVE_HYPRE=true
......
......@@ -55,7 +55,7 @@ echo_kahip()
# -> HAVE_KAHIP, KAHIP_ARCH_PATH, KAHIP_INC_DIR, KAHIP_LIB_DIR
have_kahip()
{
local prefix header library static settings warn
local prefix header library incName libName settings warn
warn="==> skip kahip"
# Setup
......@@ -67,13 +67,10 @@ have_kahip()
return 1
fi
# Location
# Expected location, include/library names
prefix="$KAHIP_ARCH_PATH"
# Header/library names
header="kaHIP_interface.h"
library="libkahip$extLibso"
static="libkahip$extLiba"
incName="kaHIP_interface.h"
libName="libkahip"
# ----------------------------------
if isNone "$prefix"
......@@ -82,42 +79,33 @@ have_kahip()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$header")
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
elif isSystem "$prefix"
then
prefix=/usr
header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header")
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
library=$(findFirstFile \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName")
prefix=$(sysPrefix "$header")
else
unset prefix header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
# Library
[ -n "$library" ] || library=$(findLibrary \
"$prefix/lib/$libName" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \
) || {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# kahip itself is 32-bit int, but our interface itself handles some
# 64-bit conversion (mesh size).
......
......@@ -55,7 +55,7 @@ echo_metis()
# -> HAVE_METIS, METIS_ARCH_PATH, METIS_INC_DIR, METIS_LIB_DIR
have_metis()
{
local prefix header library static settings warn
local prefix header library incName libName settings warn
warn="==> skip metis"
# Setup
......@@ -67,13 +67,10 @@ have_metis()
return 2
fi
# Location
# Expected location, include/library names
prefix="$METIS_ARCH_PATH"
# Header/library names
header="metis.h"
library="libmetis$extLibso"
static="libmetis$extLiba"
incName="metis.h"
libName="libmetis"
# ----------------------------------
if isNone "$prefix"
......@@ -82,42 +79,33 @@ have_metis()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$header")
library=$(findFirstFile \
"$(thirdExtLib $library)" \
"$prefix/lib/$static" \
"$prefix/lib/$library" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \
"$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \
)
header=$(findFirstFile "$prefix/include/$incName")
library="$(findExtLib $libName)"
elif isSystem "$prefix"
then
prefix=/usr
<