-
Notifications
You must be signed in to change notification settings - Fork 15
/
configure
executable file
·324 lines (267 loc) · 7.02 KB
/
configure
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#!/bin/bash
OUTPUT=config/make.config
show_help ()
{
echo "$0 options:"
echo "--compiler name Configures BOTS for given compiler"
echo " Supported compilers: GCC, Clang, ICC, SunStudio, PGI, XLC and Mercurium"
echo "--debug Enables debug flags"
echo "--warnings Force warnings to be reported as errors"
echo "--help Prints this help"
}
while [ "$#" -gt 0 ]; do
case $1 in
--debug) debug=yes
;;
--warnings) warnings=yes
;;
--compiler) shift; COMPILER=$1
;;
--help)
show_help
exit
;;
*) echo "Unknown option $1 (skipping)"
;;
esac
shift
done
GCC=`gcc -x c -c -fopenmp /dev/null -o /dev/null &>/dev/null && echo "yes"`
CLANG=`clang -x c -c -fopenmp /dev/null -o /dev/null &>/dev/null && echo "yes"`
MCC=`mcc --v &> /dev/null && echo "yes"`
ICC=`icc -v &> /dev/null && echo "yes"`
XLC=`xlc -qversion &> /dev/null && echo "yes"`
PGI=`pgcc &> /dev/null && echo "yes"`
SUN=`cc -xopenmp &> /dev/null && echo "yes"`
CLANG=`clang -v &> /dev/null && echo "yes"`
nc=0
if [ -z "$COMPILER" ]; then
if [ "$GCC" = "yes" ]; then
let nc=nc+1
COMPILERS[nc]="gcc"
fi
if [ "$CLANG" = "yes" ]; then
let nc=nc+1
COMPILERS[nc]="clang"
fi
if [ "$MCC" = "yes" ]; then
let nc=nc+1
COMPILERS[nc]="mcc"
fi
if [ "$ICC" = "yes" ]; then
let nc=nc+1
COMPILERS[nc]="icc"
fi
if [ "$XLC" = "yes" ]; then
let nc=nc+1
COMPILERS[nc]="xlc"
fi
if [ "$PGI" = "yes" ]; then
let nc=nc+1
COMPILERS[nc]="pgi"
fi
if [ "$SUN" = "yes" ]; then
let nc=nc+1
COMPILERS[nc]="sunstudio"
fi
if [ "$CLANG" = "yes" ]; then
let nc=nc+1
COMPILERS[nc]="clang"
fi
if [ "$nc" -gt "0" ]; then
echo "The following compilers are recognized: "
n=1
for comp in ${COMPILERS[*]}; do
echo " $n. $comp"
let n=n+1
done
echo -n "Choose one to use:"
read
COMPILER=${COMPILERS[$REPLY]}
else
echo "No suitable compiler was detected"
echo "An empty $OUTPUT will be generated"
fi
fi
[ "$debug" = "yes" ] && DEBUG=-DBOTS_DEBUG
[ "$warnings" = "yes" ] && WARNINGS=
if [ "$COMPILER" = "gcc" -a "$GCC" = "yes" ]; then
CC=gcc
CLINK=$CC
OMPC="$CC -fopenmp"
OMPLINK="$CC -fopenmp"
LABEL=gcc
[ "$debug" = "yes" ] && DEBUG=$DEBUG -g
[ "$warnings" = "yes" ] && WARNINGS="$WARNINGS -Wall -Werror"
OPT_FLAGS=-O3
CC_FLAGS="$DEBUG $WARNINGS"
OMPC_FLAGS="$DEBUG $WARNINGS"
CLINK_FLAGS=$DEBUG
OMPLINK_FLAGS=$DEBUG
fi
if [ "$COMPILER" = "clang" -a "$CLANG" = "yes" ]; then
CC=clang
CLINK=$CC
OMPC="$CC -fopenmp"
OMPLINK="$CC -fopenmp"
LABEL=clang
[ "$debug" = "yes" ] && DEBUG=$DEBUG -g
[ "$warnings" = "yes" ] && WARNINGS="$WARNINGS -Wall -Werror"
OPT_FLAGS=-O3
CC_FLAGS="$DEBUG $WARNINGS"
OMPC_FLAGS="$DEBUG $WARNINGS"
CLINK_FLAGS=$DEBUG
OMPLINK_FLAGS=$DEBUG
fi
if [ "$COMPILER" = "icc" -a "$ICC" = "yes" ]; then
CC=icc
CLINK=$CC
OMPC="$CC -openmp"
OMPLINK="$CC -openmp"
LABEL=icc
[ "$debug" = "yes" ] && DEBUG=$DEBUG -g
[ "$warnings" = "yes" ] && WARNINGS="$WARNINGS -Wall -Werror"
OPT_FLAGS=-O2
CC_FLAGS="$DEBUG $WARNINGS"
OMPC_FLAGS="$DEBUG $WARNINGS"
CLINK_FLAGS=$DEBUG
OMPLINK_FLAGS=$DEBUG
fi
if [ "$COMPILER" = "mcc" -a "$MCC" = "yes" ]; then
case $(uname -i) in
x86_64) extras="-m32"
;;
esac
CC="mcc $extras"
CLINK=$CC
OMPC=$CC
OMPLINK=$CC
LABEL=mcc
[ "$debug" = "yes" ] && DEBUG=$DEBUG -g
[ "$warnings" = "yes" ] && WARNINGS="$WARNINGS -Wall -Werror"
OPT_FLAGS=-O3
CC_FLAGS="$DEBUG $WARNINGS --no-openmp"
OMPC_FLAGS="$DEBUG $WARNINGS"
CLINK_FLAGS="$DEBUG --no-openmp"
OMPLINK_FLAGS=$DEBUG
OMPC_FINAL_FLAGS="--serialize"
ENABLE_OMPSS=yes
OMPSSC=mcc
OMPSSLINK=mcc
OMPSSC_FLAGS=--ompss
OMPSSLINK_FLAGS=--ompss
supports_final_clause=yes
fi
if [ "$COMPILER" = "xlc" -a "$XLC" = "yes" ]; then
CC=xlc_r
CLINK=$CC
OMPC="$CC -qsmp=omp"
OMPLINK=$OMPC
LABEL=xlc
[ "$debug" = "yes" ] && DEBUG=$DEBUG -g
[ "$warnings" = "yes" ] && WARNINGS="$WARNINGS -qflag=w:w -qhalt=w"
OPT_FLAGS=-O3
CC_FLAGS="$DEBUG $WARNINGS"
OMPC_FLAGS="-qthreaded $DEBUG $WARNINGS"
CLINK_FLAGS=$DEBUG
OMPLINK_FLAGS="-qthreaded $DEBUG"
fi
if [ "$COMPILER" = "pgi" -a "$PGI" = "yes" ]; then
CC=pgcc
CLINK=$CC
OMPC="$CC -mp -Minfo=mp"
OMPLINK=$OMPC
LABEL=pgi
[ "$debug" = "yes" ] && DEBUG="$DEBUG -g"
if [ "$warnings" = "yes" ]; then
echo "The pgi compiler doesn't support '--warnings' option (skipping it)"
echo "Press (Enter) to continue..."
read
fi
OPT_FLAGS=-fast
CC_FLAGS="$DEBUG $WARNINGS"
OMPC_FLAGS="$DEBUG $WARNINGS"
CLINK_FLAGS=$DEBUG
OMPLINK_FLAGS=$DEBUG
fi
if [ "$COMPILER" = "sunstudio" -a "$SUN" = "yes" ]; then
CC=cc
CLINK=$CC
OMPC="$CC -xopenmp"
OMPLINK=$OMPC
LABEL=suns
[ "$debug" = "yes" ] && DEBUG=$DEBUG -g
if [ "$warnings" = "yes" ]; then
echo "The sunstudio compiler doesn't support '--warnings' option (skipping it)"
echo "Press (Enter) to continue..."
read
fi
OPT_FLAGS=-fast
CC_FLAGS="$DEBUG $WARNINGS"
OMPC_FLAGS="$DEBUG $WARNINGS"
CLINK_FLAGS=$DEBUG
OMPLINK_FLAGS=$DEBUG
fi
if [ "$COMPILER" = "clang" -a "$CLANG" = "yes" ]; then
CC=clang
CLINK=$CC
OMPC="$CC -fopenmp"
OMPLINK="$CC -fopenmp"
LABEL=clang
[ "$debug" = "yes" ] && DEBUG=$DEBUG -g
[ "$warnings" = "yes" ] && WARNINGS="$WARNINGS -Wall -Werror"
OPT_FLAGS=-O3
CC_FLAGS="$DEBUG $WARNINGS"
OMPC_FLAGS="$DEBUG $WARNINGS"
CLINK_FLAGS=$DEBUG
OMPLINK_FLAGS=$DEBUG
fi
if [ -z "$CC" ]; then
echo "Wrong compiler configuration"
exit 1
fi
if [ "$debug" = "yes" ]; then
LABEL="$LABEL-debug"
fi
[ -f $OUTPUT ] && replacing_config=true
cat > $OUTPUT << EOF
#Automatically generated by configure
#compilers and linkers
#config name
LABEL=$LABEL
ENABLE_OMPSS=$ENABLE_OMPSS
#compilers
OMPSSC=$OMPSSC
OMPC=$OMPC
CC=$CC
OMPSSLINK=$OMPSSLINK
OMPLINK=$OMPLINK
CLINK=$CLINK
#compiler and linker flags
OPT_FLAGS=$OPT_FLAGS
CC_FLAGS=$CC_FLAGS
OMPC_FLAGS=$OMPC_FLAGS
OMPSSC_FLAGS=$OMPSSC_FLAGS
OMPC_FINAL_FLAGS=$OMPC_FINAL_FLAGS
OMPSSC_FINAL_FLAG=$OMPSSC_FINAL_FLAGS
CLINK_FLAGS=$CLINK_FLAGS
OMPLINK_FLAGS=$OMPLINK_FLAGS
OMPSSLINK_FLAGS=$OMPSSLINK_FLAGS
EOF
#check experimental features
[ "$supports_final_clause" ] && echo "USE_FINAL_CLAUSE=yes" >> $OUTPUT
echo "make.config generated"
if [ "$replacing_config" ]; then
echo "Configuration was changed. Cleaning up"
make clean
fi
[ -d bin ] || mkdir -p bin
if make -v | grep GNU &> /dev/null; then
echo "Run make to compile the benchmarks"
elif gmake -v | grep GNU &> /dev/null; then
echo "Run gmake to compile the benchmarks"
else
echo "I didn't find a GNU-compatible make. You'll need it to compile the benchmarks"
fi
echo "You can further refine your configuration in config/make.config"
echo "Use the scripts in the run directory to execute them"