ENH: split up internals of wmake/scripts/have_XXX functions

- adds some more flexibility
This commit is contained in:
Mark Olesen
2020-05-15 13:58:16 +02:00
committed by Andrew Heather
parent c156125669
commit f8ef85b72f
14 changed files with 679 additions and 480 deletions

View File

@ -21,7 +21,7 @@
# or config.sh/FFTW (when FFTW_ARCH_PATH is empty)
#
# Functions provided
# have_fftw, no_fftw, echo_fftw, query_fftw
# have_fftw, no_fftw, echo_fftw, query_fftw, search_fftw
#
# Variables set on success
# HAVE_FFTW
@ -34,7 +34,7 @@
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_fftw()
{
unset HAVE_FFTW FFTW_INC_DIR FFTW_LIB_DIR
@ -51,47 +51,19 @@ echo_fftw()
}
# Query settings
query_fftw()
{
local config="config.sh/FFTW"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query fftw "$FFTW_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "fftw=unknown"
fi
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR
have_fftw()
search_fftw()
{
local warn # warn="==> skip fftw"
local config="config.sh/FFTW"
local settings
# Setup - current environment if set
if [ -z "$FFTW_ARCH_PATH" ]
then
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
fi
# Expected location, include/library names
local prefix="$FFTW_ARCH_PATH"
local incName="fftw3.h"
local libName="libfftw3"
local prefix="${1:-system}"
local header library
# ----------------------------------
@ -136,7 +108,49 @@ have_fftw()
}
# Reset variables
# Output as per search_* function
have_fftw()
{
local warn # warn="==> skip fftw"
local config="config.sh/FFTW"
local file
# Setup - current environment if set
if [ -z "$FFTW_ARCH_PATH" ]
then
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
fi
search_fftw "$FFTW_ARCH_PATH"
}
# Query settings
query_fftw()
{
local config="config.sh/FFTW"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query fftw "$FFTW_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "fftw=unknown"
fi
}
#------------------------------------------------------------------------------
# Reset
no_fftw
# Test/query