openfoam/wmake/scripts/have_fftw
Mark Olesen 5ba2cbc54f 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.
2020-02-24 16:00:16 +01:00

142 lines
3.2 KiB
Bash

#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_fftw
#
# Description
# Detection/setup of FFTW
#
# Requires
# FFTW_ARCH_PATH
#
# Functions provided
# have_fftw, no_fftw, echo_fftw, query_fftw
#
# Variables set on success
# HAVE_FFTW
# FFTW_ARCH_PATH
# FFTW_INC_DIR
# FFTW_LIB_DIR
#
#------------------------------------------------------------------------------
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
no_fftw()
{
unset HAVE_FFTW FFTW_INC_DIR FFTW_LIB_DIR
return 0
}
# Report
echo_fftw()
{
echo "fftw=${HAVE_FFTW:-false}"
echo "root=$FFTW_ARCH_PATH"
echo "include=$FFTW_INC_DIR"
echo "library=$FFTW_LIB_DIR"
}
# 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
}
# On success, return 0 and export variables
# -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR
have_fftw()
{
local prefix header library incName libName settings warn
# warn="==> skip fftw"
# Setup - from the current environment
# Expected location, include/library names
prefix="$FFTW_ARCH_PATH"
incName="fftw3.h"
libName="libfftw3"
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset prefix
fi
# ----------------------------------
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# OK
export HAVE_FFTW=true
export FFTW_ARCH_PATH="$prefix"
export FFTW_INC_DIR="${header%/*}" # Basename
export FFTW_LIB_DIR="${library%/*}" # Basename
}
# Reset variables
no_fftw
# Test/query
case "$1" in
-test)
have_fftw
echo_fftw
;;
-query)
query_fftw
;;
esac
#------------------------------------------------------------------------------