This repository has been archived by the owner on May 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·164 lines (145 loc) · 2.73 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
#!/bin/sh
findlib() {
lib=$1
arg=$2
for p in / /usr /usr/local $arg
do
if test -d $p/lib &&
find $p/lib -maxdepth 1 -name lib$lib\* |
grep '$' > /dev/null
then
echo $p
return
fi
done
echo "✗ could not find library $lib" 1>&2
}
if test -f config.mk
then
# Reload last configuration
. ./config.mk
fi
usage() {
cat << EOM
usage: ./configure [options]
Options:
-prefix PATH The installation prefix path
-prefix=PATH
-gmp PATH The directory containing the GMP library
-mpfr PATH The directory containing the MPFR library
-llvm-config CMD The name used to invoke llvm-config
-cxx CMD The C++ compiler to use (must support C++11)
-cc CMD The C compiler to use (must support C99)
-help Display this help message
EOM
exit 0
}
OUR_PREFIX=/usr
LLC=llvm-config
CXX=c++
CC=cc
while test $# -gt 0
do
arg=$1
shift
case $arg in
--prefix=*|-prefix=*)
OUR_PREFIX=${arg#*=}
;;
--prefix|-prefix)
test $# -gt 0 || usage
OUR_PREFIX=$1
shift
;;
--gmp|-gmp)
test $# -gt 0 || usage
GMP_PREFIX=$(dirname $1)
shift
;;
--mpfr|-mpfr)
test $# -gt 0 || usage
MPFR_PREFIX=$(dirname $1)
shift
;;
--llvm-config|-llvm-config)
test $# -gt 0 || usage
LLC=$1
shift
;;
--cc|-cc)
test $# -gt 0 || usage
CC=$1
shift
;;
--cxx|-cxx)
test $# -gt 0 || usage
CXX=$1
shift
;;
*)
usage
;;
esac
done
$CC -std=c99 -x c - 2> /dev/null << EOF
struct S {int i; char c[];};
int main() { return sizeof(struct S) - sizeof(int); }
EOF
test $? -eq 0 && ./a.out
can_c99=$?
rm -f ./a.out
if test $can_c99 -ne 0
then
echo "✗ $CC cannot compile C99 code" 1>&2
exit 1
fi
$CXX -std=c++11 -x c++ - 2> /dev/null << EOF
#include <functional>
int main() { auto f = [] { return 0; }; return f(); }
EOF
test $? -eq 0 && ./a.out
can_cxx11=$?
rm -f ./a.out
if test $can_cxx11 -ne 0
then
echo "✗ $CXX cannot compile C++11 code" 1>&2
exit 1
fi
if ! ( ocamlbuild -vnum; ) > /dev/null 2>&1
then
echo "✗ ocamlbuild cannot be run" 1>&2
exit 1
fi
if ! ( $LLC --version; ) > /dev/null 2>&1
then
LLC=
echo "✗ warning: llvm-config not found, llvm-reader will not be built"
fi
GMP_PREFIX=$(findlib gmp $GMP_PREFIX)
test -n "$GMP_PREFIX" || exit 1
MPFR_PREFIX=$(findlib mpfr $MPFR_PREFIX)
test -n "$MPFR_PREFIX" || exit 1
cat > config.mk << EOF
# Autogenerated by the configure script.
OUR_PREFIX=$OUR_PREFIX
GMP_PREFIX=$GMP_PREFIX
MPFR_PREFIX=$MPFR_PREFIX
CXX=$CXX
CC=$CC
LLC=$LLC
EOF
if test -z $LLC
then
buildllvm=no
else
buildllvm=yes
fi
cat << EOM
Configuration:
Installation prefix: $OUR_PREFIX
MPFR library in: $MPFR_PREFIX/lib
GMP library in: $GMP_PREFIX/lib
C++ compiler: $CXX
C compiler: $CC
Build llvm-reader: $buildllvm
EOM