mirror of
https://develop.openfoam.com/Development/ThirdParty-common.git
synced 2025-12-08 06:57:50 +00:00
174 lines
4.8 KiB
Bash
Executable File
174 lines
4.8 KiB
Bash
Executable File
#!/bin/sh
|
|
#------------------------------------------------------------------------------
|
|
# ========= |
|
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
# \\ / O peration |
|
|
# \\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
|
# \\/ M anipulation |
|
|
#------------------------------------------------------------------------------
|
|
# License
|
|
# This file is part of OpenFOAM.
|
|
#
|
|
# OpenFOAM is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
# for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Script
|
|
# makeFFTW
|
|
#
|
|
# Description
|
|
# Build script for FFTW
|
|
#
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Get FFTW versions
|
|
. $WM_PROJECT_DIR/etc/config.sh/functions
|
|
unset -f _foamAddPath _foamAddLib _foamAddMan # get settings only
|
|
|
|
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW)
|
|
|
|
fftwPACKAGE=${fftw_version:-fftw-system}
|
|
|
|
#------------------------------------------------------------------------------
|
|
# Run from third-party directory only
|
|
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
|
|
echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
|
|
echo " The environment variables are inconsistent with the installation."
|
|
echo " Check the OpenFOAM entries in your dot-files and source them."
|
|
exit 1
|
|
}
|
|
. etc/tools/ThirdPartyFunctions
|
|
#------------------------------------------------------------------------------
|
|
Script="${0##*/}"
|
|
|
|
usage() {
|
|
exec 1>&2
|
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
cat<<USAGE
|
|
|
|
usage: $Script [OPTION] [fftw-VERSION]
|
|
options:
|
|
-gcc Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
|
|
-help
|
|
|
|
* build FFTW with
|
|
${fftwPACKAGE:-'unspecified FFTW version'}
|
|
|
|
USAGE
|
|
exit 1
|
|
}
|
|
#------------------------------------------------------------------------------
|
|
|
|
# ensure configure gets the correct C/C++ compiler
|
|
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
|
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
|
|
|
# Parse options
|
|
while [ "$#" -gt 0 ]
|
|
do
|
|
case "$1" in
|
|
-h | -help)
|
|
usage
|
|
;;
|
|
'')
|
|
# discard empty arguments
|
|
;;
|
|
-gcc)
|
|
export CC=gcc # use gcc/g++
|
|
export CXX=g++
|
|
;;
|
|
fftw-[0-9]* | fftw_[0-9]* | fftw-system )
|
|
fftwPACKAGE="${1%%/}"
|
|
;;
|
|
*)
|
|
die "unknown option/argument: '$1'"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
[ -n "$fftwPACKAGE" ] || die "The fftw-VERSION was not specified"
|
|
|
|
# nothing to build
|
|
if _foamIsNone "$fftwPACKAGE"
|
|
then
|
|
echo "Using fftw-none (skip ThirdParty build of FFTW)"
|
|
exit 0
|
|
fi
|
|
|
|
if _foamIsSystem "$fftwPACKAGE"
|
|
then
|
|
echo "Using fftw-system (skip ThirdParty build of FFTW)"
|
|
exit 0
|
|
fi
|
|
|
|
#------------------------------------------------------------------------------
|
|
#
|
|
# Build FFTW
|
|
# For 64-bit
|
|
# - FFTW itself will normally build into 'lib64',
|
|
# but provide --libdir on configure to be 100% certain
|
|
# - Third-Party builds into 'lib64'
|
|
# - system is normally built into 'lib64'
|
|
#
|
|
# FFTW_SOURCE_DIR : location of the original sources
|
|
|
|
FFTW_ARCH_PATH=$installBASE/$fftwPACKAGE
|
|
FFTW_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$fftwPACKAGE
|
|
|
|
if [ -r "$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libfftw3.so" ]
|
|
then
|
|
echo "Already has FFTW shared library"
|
|
else
|
|
echo "Starting build: FFTW ($fftwPACKAGE)"
|
|
echo
|
|
|
|
(
|
|
# configuration options:
|
|
unset configOpt
|
|
|
|
# Single-precision needed?
|
|
if [ "${WM_PRECISION_OPTION}" = SP ]
|
|
then
|
|
configOpt="$configOpt --enable-single"
|
|
fi
|
|
|
|
# end of configuration options
|
|
# ----------------------------
|
|
buildDIR=$buildBASE/$fftwPACKAGE
|
|
|
|
cd $FFTW_SOURCE_DIR || exit 1
|
|
|
|
rm -rf $FFTW_ARCH_PATH
|
|
rm -rf $buildDIR
|
|
mkdir -p $buildDIR
|
|
cd $buildDIR
|
|
|
|
set -x
|
|
$FFTW_SOURCE_DIR/configure \
|
|
--prefix=$FFTW_ARCH_PATH \
|
|
--libdir=$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
|
|
--enable-shared --disable-static \
|
|
--disable-fortran \
|
|
$configOpt \
|
|
&& make -j $WM_NCOMPPROCS \
|
|
&& make install \
|
|
&& echo "Built $fftwPACKAGE"
|
|
) || {
|
|
echo "Error building: FFTW"
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
|
|
#------------------------------------------------------------------------------
|