-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·249 lines (217 loc) · 4.44 KB
/
configure
File metadata and controls
executable file
·249 lines (217 loc) · 4.44 KB
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/bin/bash
set -e
shopt -s extglob
modes="debug|release"
scheds="ser|pthread|omp|tbb|cobra"
comms="off|mpi"
asyncs="off|mpi3"
function usage {
echo "Usage: $0 [--with-cc=<cmd>] [--with-cxx=<cmd>] [--mode=$modes] [--sched=$scheds] [--comm=$comms] [--async=$asyncs] [--mpi=<pkg>] [--pkg-dir=<dir>] [--no-inst] [--with-range]" 2>&1
}
function use_err {
echo $1 1>&2
usage
exit 1
}
# Early check
BASE="$(dirname "$0")"
pkgcfg="$(which pkg-config)" || true
if ! [ -x "$pkgcfg" ]; then
echo "Could not find pkg-config" 1>&2
exit 1
fi
# Default options
cc=gcc
cxx=g++
mode=debug
sched=ser
comm=mpi
mpi=ompi-c
async=off
inst=1
range=
# Parse arguments
CONFIG="$0 $@"
while [ $# != 0 ]; do
case $1 in
--with-cc=*)
cc="${1#*=}"
;;
--with-cxx=*)
cxx="${1#*=}"
;;
--mode=*)
mode=${1#*=}
[[ $mode == @($modes) ]] || use_err "Invalid mode: $mode"
;;
--sched=*)
sched=${1#*=}
[[ $sched == @($scheds) ]] || use_err "Invalid scheduler: $sched"
;;
--comm=*)
comm=${1#*=}
[[ $comm == @($comms) ]] || use_err "Invalid scheduler: $sched"
;;
--mpi=*)
mpi=${1#*=}
;;
--async=*)
async=${1#*=}
[[ $async == @($asyncs) ]] || use_err "Invalid async: $async"
;;
--pkg-dir=*)
dir=${1#*=}
cp $dir/*.pc .
;;
--no-inst)
inst=
;;
--with-range)
range=1
;;
-h|--help)
usage
exit 0
;;
-*)
use_err "Unrecognized option: $1"
;;
*)
use_err "This command takes no open arguments"
;;
esac
shift
done
# Interpret options
pub_pkgs=""
pri_pkgs=""
pub_cflags=""
pub_libs=""
pri_ldflags="-O2 -fstrict-aliasing"
pri_cflags="-O2 -fstrict-aliasing -Wall -Wextra -Wfatal-errors -Winline -I. -I$BASE/include"
case $mode in
release)
pri_cflags="$pri_cflags -DNDEBUG"
;;
debug)
pri_cflags="$pri_cflags -g"
;;
esac
case $comm in
mpi)
pri_cflags="$pri_cflags -DSHARK_MPI_COMM"
pri_pkgs="$pri_pkgs $mpi"
;;
off)
pri_cflags="$pri_cflags -DSHARK_NO_COMM"
;;
esac
case $sched in
ser)
pub_cflags="$pub_cflags -DSHARK_SER_SCHED"
;;
pthread)
pub_cflags="$pub_cflags -pthread -DSHARK_PTHREAD_SCHED"
pub_libs="$pub_libs -lpthread"
;;
omp)
pub_cflags="$pub_cflags -fopenmp -DSHARK_OMP_SCHED"
pub_libs="$pub_libs -fopenmp"
;;
tbb)
pub_cflags="$pub_cflags -DSHARK_TBB_SCHED"
pub_pkgs="$pub_pkgs tbb"
;;
cobra)
pub_cflags="$pub_cflags -DSHARK_COBRA_SCHED"
pub_pkgs="$pub_pkgs cobra"
;;
esac
case $async in
mpi3)
if [ $comm != mpi ]; then
echo "async=mpi3 requires comm=mpi" 1>&2
exit 1
fi
pub_cflags="$pub_cflags -DSHARK_MPI_ASYNC"
;;
esac
if [ -n "$range" ]; then
pub_cflags="$pub_cflags -DSHARK_RANGE"
fi
# Determine version
VER=$(awk '$1 == "#define" && $2 == "SHARK_VERSION" { print $3 }' "$BASE/include/shark/version.hpp")
echo "Configuring Shark version $VER..."
# Verify options
echo -n "Checking CC... "
if v=$($cc --version 2>/dev/null); then
echo "${v%%$'\n'*}"
else
echo "failed"
exit 1
fi
echo -n "Checking CXX... "
if v=$($cxx --version 2>/dev/null); then
echo "${v%%$'\n'*}"
else
echo "failed"
exit 1
fi
echo -n "Checking basic C++0x support... "
if echo 'auto f = [](){};' | $cxx -c -std=c++0x -o cpp0x.o -x c++ - && rm cpp0x.o; then
echo "ok"
else
echo "failed"
exit 1
fi
echo -n "Checking standard library... "
if echo '#include <type_traits>' | $cxx -E -std=c++0x -x c++ - | grep '^#.*tr1_impl/type_traits' >/dev/null; then
echo "libstdc++ tr1_impl workaround"
pub_cflags="$pub_cflags -DSHARK_GLIBCXX_TR1IMPL"
else
echo "ok"
fi
export PKG_CONFIG_PATH=".:$PKG_CONFIG_PATH"
for pkg in $pri_pkgs $pub_pkgs; do
echo -n "Checking $pkg... "
if ! $pkgcfg --modversion $pkg 2>/dev/null; then
echo failed
exit 1
fi
done
echo "Creating subdirs..."
mkdir -p src solvers bpmf tests
echo "Writing Makefile..."
cat > Makefile <<END
CC=$cc
CXX=$cxx
LDFLAGS:=$pri_ldflags
CFLAGS:=$pri_cflags $pub_cflags $($pkgcfg --cflags $pri_pkgs $pub_pkgs)
LDLIBS:=$pri_libs $pub_libs $($pkgcfg --libs --static $pri_pkgs $pub_pkgs)
ROOT=$BASE
include \$(ROOT)/Makefile.common
END
echo "Writing shark.pc..."
cat > shark.pc <<END
includedir=$(cd $BASE && pwd)/include
libdir=$(pwd)
Name: shark
Description: Scalable Hybrid Array Kit
Version: $VER
Requires: $pub_pkgs
Requires.private: $pri_pkgs
Cflags: -I\${includedir} $pub_cflags
Libs: $pub_libs -L\${libdir} -lshark
Libs.private: $pri_libs
END
if [ -n "$inst" ]; then
for f in types inst_dim inst_dimtype; do
echo "Creating $f..."
cp "$BASE/$f.tmpl" "$f"
done
fi
echo "Writing config.log..."
cat > config.log <<END
$CONFIG
$(date)
END