-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfigure
executable file
·145 lines (113 loc) · 2.4 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
#!/usr/bin/env bash
MAKEFILE_CFG=Makefile.config
REQUIRE_RUNTIME=1
### for error reporting on failures
FAILURE_MSG=
### for the Makefile.config
SUBDIRS=(extern assign)
PREFIX=$PWD
usage() {
cat <<EOF
$0 [OPTIONS]
OPTIONS:
--prefix PATH Set the install PREFIX
--require-runtime Make the configure step fail if the runtime dependencies cannot be found
EOF
}
fail() {
FAILURE_MSG="$@"
return 1
}
die() {
local ecode=$1
shift
local msg="$@ $FAILURE_MSG"
FAILURE_MSG=
echo $msg
exit $ecode
}
set-args() {
local args=($@)
local opt=
local val=
while [ ! -z $1 ]; do
opt="$1"
shift
case $opt in
--prefix)
val="$1"; shift
test ! -z "$val" || return 1
PREFIX="$val";;
--require-runtime)
REQUIRE_RUNTIME=0
;;
*)
usage; exit 1;;
esac
done
}
makefile-cfg-array() {
local name=$1
local array="${name}[@]"
echo "$name = ${!array}"
}
makefile-cfg-var() {
local name=$1
local val=
eval val=\$$name
echo "$name = $val"
}
check-clib() {
local desc="$1"; shift
local include="$1"; shift
local libs="$@"
local tmpfile=$(mktemp /tmp/awe-configure.XXX)
trap "rm -f '$tmpfile'" RETURN EXIT
local include_stmt=
test -z "$include" || include_stmt="#include \"$include\""
printf "Checking for $libs..."
build="gcc -xc $libs -o $tmpfile -"
prog=$(cat <<EOF
$include_stmt
int main (void) { return 0; }
EOF
)
printf "$prog" | $build >/dev/null 2>&1
ecode=$?
if test ! $ecode -eq 0; then
echo cannot find $desc FAIL
# echo "PROGRAM"
# echo "========================================"
# echo "$prog"
# echo "========================================"
# echo "Build command: $build"
return 1
else
echo OK
return 0
fi
}
get-python-version() {
python -c 'import sys;v=sys.version_info;major=v[0];minor=v[1];print("%s.%s" % (major,minor))'
}
check-python-version() {
printf "Checking for compatible python installation..."
pv=$(get-python-version)
for v in 2.6 2.7 3.4; do
test $pv == $v && echo OK && return 0
done
echo FAIL
return 1
}
check-build-depends() {
echo "=================================================="
echo "Checking build dependencies"
check-clib xdrfile xdrfile/xdrfile.h -lxdrfile
check-clib gsl gsl/gsl_matrix.h -lgsl -lgslcblas
check-python-version
}
set-args $@ || die 1
rm -f $MAKEFILE_CFG
check-build-depends || die 2
makefile-cfg-array SUBDIRS >>$MAKEFILE_CFG
makefile-cfg-var PREFIX >>$MAKEFILE_CFG