-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeFFTW
executable file
·205 lines (181 loc) · 5.63 KB
/
makeFFTW
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2016-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# makeFFTW
#
# Description
# Build script for FFTW
#
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
#------------------------------------------------------------------------------
# Dynamic library ending (default is .so)
[ "$(uname -s)" = Darwin ] && EXT_SO=.dylib || EXT_SO=.so
# Short-circuit test for an installation
if [ "$1" = "-test" ]
then
[ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
dir="${2%/}" # <- *_ARCH_PATH
[ -d "$dir/include" ] || exit 2
package="fftw"
libName="libfftw3"
for lib in \
"$dir/lib/$libName$EXT_SO" \
"$dir/lib$WM_COMPILER_LIB_ARCH/$libName$EXT_SO" \
;
do
if [ -r "$lib" ]
then
echo " $package include: $dir/include"
echo " $package library: ${lib%/*}"
exit 0
fi
done
exit 2
fi
#------------------------------------------------------------------------------
# Run from third-party directory only
cd "${0%/*}" || exit
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
echo " Check your OpenFOAM environment and installation"
exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
# FFTW version from OpenFOAM etc/config.sh file:
_foamConfig FFTW
fftwPACKAGE="${fftw_version:-fftw-system}"
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTION] [fftw-VERSION] [-- configure-options]
options:
-force Force compilation, even if include/library already exists
-gcc Force use of gcc/g++
-help
* build FFTW with
${fftwPACKAGE:-'unspecified FFTW version'}
USAGE
showDownloadHint FFTW
exit 1
}
#------------------------------------------------------------------------------
exportCompiler # Compiler info for CMake/configure
unset optForce
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
'') ;; # Ignore empty
--) break;; # Extra configure options (leave on $@ for later detection)
-h | -help) usage ;;
-gcc) useGcc ;;
-force) optForce=true ;;
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
elif _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 : installation directory
FFTW_SOURCE_DIR="$sourceBASE/$fftwPACKAGE"
FFTW_ARCH_PATH="$installBASE/$fftwPACKAGE"
if [ -z "$optForce" ] \
&& {
[ -r "$FFTW_ARCH_PATH/lib/libfftw3$EXT_SO" ] \
|| [ -r "$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libfftw3$EXT_SO" ] \
|| [ -r "$FFTW_ARCH_PATH/bin/libfftw3-3$EXT_SO" ] # Windows
}
then
echo "FFTW already built : $FFTW_ARCH_PATH"
else
echo "Starting build: FFTW ($fftwPACKAGE)"
echo
(
# Configuration options:
unset configOpt
# Compiler-specific adjustments
case "$WM_COMPILER" in
(Mingw*)
# Cross-compiling
# See http://www.fftw.org/install/windows.html
configOpt="
--host=x86_64-w64-mingw32
--with-our-malloc
--enable-threads --with-combined-threads
--enable-sse2
--with-incoming-stack-boundary=2
"
;;
esac
# Additional configure options
if [ "$1" = "--" ]
then
shift
configOpt="$configOpt $@"
fi
# End of configuration options
# ----------------------------
buildDIR="$buildBASE/$fftwPACKAGE"
cd "$FFTW_SOURCE_DIR" || exit
export GIT_DIR="$PWD/.git" # Mask seeing our own git-repo
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 \
&& set +x \
&& make -j $WM_NCOMPPROCS \
&& make install \
&& echo "Built $fftwPACKAGE" \
&& pkgconfigAdjust "$FFTW_ARCH_PATH"
) || {
echo "Error building: FFTW"
exit 1
}
fi
#------------------------------------------------------------------------------