-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·284 lines (265 loc) · 8.25 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
#!/bin/sh -f
# show_help exit_code
show_help() {
cat << EOF
usage: configure [options]
Options:
--help show this help and exit
--prefix=DIR installation prefix
--bindir=DIR use DIR instead of PREFIX/bin for executables
--libdir=DIR use DIR instead of PREFIX/lib for libraries
--incdir=DIR use DIR instead of PREFIX/include for headers
--docdir=DIR use DIR instead of PREFIX/share/doc/mdwf for docs
--with-qmp=DIR use DIR/bin/qmp-config to query QMP configuration
--with-gsl=DIR use DIR/bin/gsl-config to query GSL configuration
--with-atlas=DIR use ATLAS implementation of BLAS in DIR/lib
--target=TARGET build target architecture, see below
Target architectures:
cee-32 K&R C on a 32-bit target
cee-64 K&R C on a 64-bit target
c99-32 ISO/IEC 9899 (aka C99) on a 32-bit target
c99-64 ISO/IEC 9899 (aka C99) on a 64-bit target
bgl/xlc BG/L or BG/P with IBM XLC compiler
bgq/xlc BG/Q with IBM XLC compiler
Environment variables:
CC C compiler to use
CFLAGS Flags to pass to the compiler
COPTS Options for the compiler
LD Link editor to use
LDFLAGS Flags to pass to the linker
LIBS Extra libraries to use
AR Library archiver
RANLIB Library indexing tool
EOF
exit $1
}
# show_error arg ...
show_error() {
echo "**** Configure error: $*" 1>&2
exit 1
}
# configuration variables
prefix=
bindir=
libdir=
incdir=
docdir=
# defaults
default_prefix=/usr/local
# rest is relative to prefix by default
bindir_loc=bin
libdir_loc=lib
incdir_loc=include
docdir_loc=share/doc/mdwf
default_cc=gcc
default_cflags=""
default_copts="-Wall"
default_ld=gcc
default_ldflags=""
default_ar=ar
default_ranlib="echo RANLIB"
# process_args arg ...
process_args() {
while [ $# -ne 0 ]; do
case "$1" in
--help) show_help 0 ;;
--prefix=*) prefix=`echo "$1" | sed -e 's/--prefix=//'` ;;
--bindir=*) bindir=`echo "$1" | sed -e 's/--bindir=//'` ;;
--libdir=*) libdir=`echo "$1" | sed -e 's/--libdir=//'` ;;
--incdir=*) incdir=`echo "$1" | sed -e 's/--incdir=//'` ;;
--docdir=*) docdir=`echo "$1" | sed -e 's/--docdir=//'` ;;
--with-qmp=*) qmp=`echo "$1" | sed -e 's/--with-qmp=//'` ;;
--with-gsl=*) gsl=`echo "$1" | sed -e 's/--with-gsl=//'` ;;
--with-atlas=*) atlas=`echo "$1" | sed -e 's/--with-atlas=//'` ;;
# handle other CBLAS implementations here
--target=*) target=`echo "$1" | sed -e 's/--target=//'` ;;
*) show_error "Unknown argument $1" ;;
esac
shift
done
}
# speciate_target
speciate_target() {
case "$target" in
cee-32)
limpdir=cee-32
default_cc="gcc -std=c99 -m32"
default_cflags=""
default_copts="-Wall -O3"
default_ld="gcc -std=c99 -m32"
default_ldflags=""
default_libs=""
default_ar="ar"
default_ranlib="ranlib"
;;
c99-32)
limpdir=c99-32
default_cc="gcc -std=c99 -m32"
default_cflags=""
default_copts="-Wall -O3"
default_ld="gcc -std=c99 -m32"
default_ldflags=""
default_libs=""
default_ar="ar"
default_ranlib="ranlib"
;;
cee-64)
limpdir=cee-64
default_cc="gcc -std=c99 -m64"
default_cflags=""
default_copts="-Wall -O3"
default_ld="gcc -std=c99 -m64"
default_ldflags=""
default_libs=""
default_ar="ar"
default_ranlib="ranlib"
;;
c99-64)
limpdir=c99-64
default_cc="gcc -std=c99 -m64"
default_cflags=""
default_copts="-Wall -O3"
default_ld="gcc -std=c99 -m64"
default_ldflags=""
default_libs=""
default_ar="ar"
default_ranlib="ranlib"
;;
bgl/xlc)
limpdir=bgl-xlc
default_cc="blrts_c99"
default_cflags=""
default_copts="-O3 -qarch=440d -qstrict"
default_ld="blrts_c99"
default_ldflags=""
default_libs=""
default_ar="powerpc-bgl-blrts-gnu-ar"
default_ranlib="powerpc-bgl-blrts-gnu-ranlib"
;;
bgp/xlc)
limpdir=bgl-xlc
default_cc="bgc99"
default_cflags=""
default_copts="-O3 -qarch=450d -qstrict"
default_ld="bgc99"
default_ldflags=""
default_libs=""
default_ar="ar"
default_ranlib="ranlib"
;;
bgq/xlc)
limpdir=bgq-xlc
default_cc="bgc99"
default_cflags=""
default_copts="-O3 -qstrict -qmaxmem=-1"
default_ld="bgc99"
default_ldflags=""
default_libs=""
default_ar="powerpc64-bgq-linux-ar"
default_ranlib="powerpc64-bgq-linux-ranlib"
;;
*) show_error "Unsupported target $target" ;;
esac
}
# normalize
normalize() {
prefix=${prefix:-$default_prefix}
bindir=${bindir:-$prefix/$bindir_loc}
libdir=${libdir:-$prefix/$libdir_loc}
incdir=${incdir:-$prefix/$incdir_loc}
docdir=${docdir:-$prefix/$docdir_loc}
# target speciation
speciate_target
# flags and defaults
cc="${CC:-$default_cc}"
cflags="${CFLAGS:-$default_cflags}"
copts="${COPTS:-$default_copts}"
default_ld="${cc:-$default_ld}"
ld="${LD:-$default_ld}"
ldflags="${LDFLAGS:-$default_ldflags}"
libs="${LIBS}"
ar="${AR:-$default_ar}"
ranlib="${RANLIB:-$default_ranlib}"
[ -z "$target" ] && show_error "No target specified"
[ -z "$qmp" ] && show_error "QMP must be explicitly specified"
[ -x $qmp/bin/qmp-config ] || show_error "No qmp-config found in $qmp"
qmp_cflags=`$qmp/bin/qmp-config --cflags`
qmp_ldflags=`$qmp/bin/qmp-config --ldflags`
qmp_libs=`$qmp/bin/qmp-config --libs`
# optimized CBLAS library
if [ ! -z "$atlas" ] ; then
cblas_libs="-L$atlas/lib -lcblas"
fi
[ -x $gsl/bin/gsl-config ] || show_error "No gsl-config found in $gsl"
gsl_cflags="-DHAVE_GSL `$gsl/bin/gsl-config --cflags`"
if [ -z "$cblas_libs" ] ; then
gsl_libs=`$gsl/bin/gsl-config --libs`
else
gsl_libs=`$gsl/bin/gsl-config --libs-without-cblas`
fi
}
# show_config
show_config() {
echo "MDWF configuration summary:"
echo "====================================="
echo "prefix $prefix"
echo "binaries directory $bindir"
echo "libraries directory $libdir"
echo "headers directory $incdir"
echo "doc directory $docdir"
echo "C compiler $cc"
echo "Compiler flags $cflags"
echo "Compiler options $copts"
echo "Link editor $ld"
echo "Linking flags $ldflags"
echo "Extra libraries $libs"
echo "Archiver $ar"
echo "Ranlib $ranlib"
echo "QMP location $qmp"
echo "GSL location $gsl"
# optimized CBLAS
[ -z "$atlas" ] || echo "ATLAS location $atlas"
echo "Build target $target"
echo "====================================="
}
# build_config input output
build() {
sed < $1 \
-e "s|@bindir@|$bindir|g" \
-e "s|@libdir@|$libdir|g" \
-e "s|@incdir@|$incdir|g" \
-e "s|@docdir@|$docdir|g" \
-e "s|@cc@|$cc|g" \
-e "s|@cflags@|$cflags|g" \
-e "s|@copts@|$copts|g" \
-e "s|@ld@|$ld|g" \
-e "s|@ldflags@|$ldflags|g" \
-e "s|@libs@|$libs|g" \
-e "s|@ar@|$ar|g" \
-e "s|@ranlib@|$ranlib|g" \
-e "s|@qmp@|$qmp|g" \
-e "s|@qmp_cflags@|$qmp_cflags|g" \
-e "s|@qmp_ldflags@|$qmp_ldflags|g" \
-e "s|@qmp_libs@|$qmp_libs|g" \
-e "s|@target@|$target|g" \
-e "s|@limpdir@|$limpdir|g" \
| sed -e "s|@gsl@|$gsl|g" \
-e "s|@gsl_cflags@|$gsl_cflags|g" \
-e "s|@gsl_libs@|$gsl_libs|g" \
-e "s|@cblas_libs@|$cblas_libs|g" \
> $2 \
|| show_error "Could not generate $2"
}
######
if [ $# -eq 0 ]; then
show_help 1
fi
process_args $*
normalize
build mdwf-config.in mdwf-config
chmod +x mdwf-config
build Makefile.in Makefile
build target.in target
build samples/Makefile.in samples/Makefile
show_config
show_config > config.log