-
Notifications
You must be signed in to change notification settings - Fork 7
/
configure
executable file
·244 lines (214 loc) · 7.05 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
#! /bin/sh
# If shipping a production release, these two variables should be changed
# to e.g.:
#
# converge_version=0.7
# converge_date=2006/01/04
converge_version=2.1
converge_date=2014-02-25
abs_top_srcdir=`pwd`
prefix=""
rpython_opt="jit"
while [ $# -ge 1 ]; do
case $1 in
--prefix=* ) prefix=`echo $1 | sed "s/--prefix=//g"`; shift;;
--opt=* ) rpython_opt=`echo $1 | sed "s/--opt=//g"`; shift;;
-h | --help ) echo "./configure [--opt=<optimisation level>] [--prefix=<install path>]" 1>&2;
exit 0;;
* ) echo "Unknown switch $1"; exit 1;;
esac
done
if [ "X$prefix" = "X" ]; then
prefix="/usr/local/"
fi
echo "Checking for prefix... $prefix"
echo -n "Checking for Python interpreter... "
which pypy 2> /dev/null > /dev/null
if [ $? -eq 0 ]; then
PYTHON=`which pypy`
elif [ $? -ne 0 ]; then
which python2 2> /dev/null > /dev/null
if [ $? -eq 0 ]; then
PYTHON=`which python2`
else
echo "not found."
exit 1
fi
fi
echo $PYTHON
echo -n "Checking for RPython... "
if [ "X$PYPY_SRC" != "X" ]; then
RPYTHON=$PYPY_SRC/rpython/bin/rpython
if [ ! -f $RPYTHON ]; then
RPYTHON=""
fi
fi
if [ "X$RPYTHON" = "X" ]; then
echo "not found (try setting \$PYPY_SRC to the root of the PyPy source distribution)."
exit 1
fi
echo $RPYTHON
operating_system=`uname -s`
machine_type=`uname -m`
if [ "$operating_system" = "Darwin" -a "$machine_type" = "i386" ]; then
# On modern Darwin machine it now seems that it's easier to build 64 bit
# binaries than 32 bit. Why? I don't know.
machine_type=x86_64
fi
case $operating_system in
CYGWIN_NT* | MINGW* )
EXEC_EXT=".exe"
DIR_SEP="\\";;
* )
DIR_SEP="/";;
esac
case $machine_type in
i386 | i686 )
bootstrap_dir="bootstrap/32bit_little_endian";;
amd64 | x86_64 )
bootstrap_dir="bootstrap/64bit_little_endian";;
*) echo Unknown machine type "$machine_type"; exit 1;;
esac
#
# install
#
echo -n "Checking for install... "
which install 2> /dev/null > /dev/null
if [ $? -eq 0 ]; then
INSTALL="`which install`"
else
INSTALL=$abs_top_srcdir/install-sh
fi
echo $INSTALL
#
# Find libpcre.a
#
echo -n "Checking for pcre-config... "
which pcre-config > /dev/null 2> /dev/null
if [ $? -ne 0 ]; then
echo "not found."
exit 1
fi
which pcre-config
echo -n "Checking for libpcre.a... "
libpcre_a=""
cnds=`pcre-config --libs | tr " " "\n" | grep "^-L" | sort -u | sed "s/^-L//"`
pcre_configp=`which pcre-config 2> /dev/null`
pcre_configd=`dirname $pcre_configp`
cnds="$cnds `dirname $pcre_configd`/lib"
if [ $operating_system = "Linux" ]; then
cnds="$cnds `ldconfig -v 2>/dev/null | grep -v ^$'\t'|sed s/://g`"
fi
for dir in $cnds; do
cnd=$dir/libpcre.a
if [ -f $cnd ]; then
libpcre_a=$cnd
break
fi
done
if [ "X$libpcre_a" = "X" ]; then
echo "not found."
exit 1
fi
echo $libpcre_a
libpcre_include_dirs=`pcre-config --cflags | tr " " "\n" | grep "^-I" | sed "s/-I//g" | tr "\n" " " | sed "s/ *$//g"`
libpcre_library_dirs=`pcre-config --libs | tr " " "\n" | grep "^-L" | sed "s/-L//g" | tr "\n" " " | sed "s/ *$//g"`
libpcre_libraries=`pcre-config --libs | tr " " "\n" | grep "^-l" | sed "s/-l//g" | tr "\n" " "`
libpcre_link_flags=`pcre-config --libs | tr " " "\n" | grep -v "^-[lL]" | tr "\n" " "`
#
# Find libxml2.a
#
echo -n "Checking for xml2-config... "
which xml2-config > /dev/null 2> /dev/null
if [ $? -ne 0 ]; then
echo "not found."
exit 1
fi
which xml2-config
echo -n "Checking for libxml2.a... "
libxml2_a=""
cnds=`xml2-config --libs | tr " " "\n" | grep "^-L" | sort -u | sed "s/^-L//"`
xml2_configp=`which xml2-config 2> /dev/null`
xml2_configd=`dirname $xml2_configp`
cnds="$cnds `dirname $xml2_configd`/lib"
if [ $operating_system = "Linux" ]; then
cnds="$cnds `ldconfig -v 2>/dev/null | grep -v ^$'\t'|sed s/://g`"
fi
for dir in $cnds ; do
cnd=$dir/libxml2.a
if [ -f $cnd ]; then
libxml2_a=$cnd
break
fi
done
if [ "X$libxml2_a" = "X" ]; then
echo "not found."
exit 1
fi
echo $libxml2_a
libxml2_include_dirs=`xml2-config --cflags | tr " " "\n" | grep "^-I" | sed "s/-I//g" | tr "\n" " " | sed "s/ *$//g"`
libxml2_library_dirs=`xml2-config --libs | tr " " "\n" | grep "^-L" | sed "s/-L//g" | tr "\n" " " | sed "s/ *$//g"`
libxml2_libraries=`xml2-config --libs | tr " " "\n" | grep "^-l" | sed "s/-l//g" | tr "\n" " "`
libxml2_link_flags=`xml2-config --libs | tr " " "\n" | grep -v "^-[lL]" | tr "\n" " "`
# Some Linux installations of libxml2 don't include -lz in --libs output, even
# when they should. As a gross hack around this problem, we add -lz to the list
# of libraries needed; sometimes this might not be necessary (depending on how
# libxml2 was compiled), but it generally won't do any harm.
echo $libxml2_libraries | tr " " "\n" | grep "^z$" 2> /dev/null > /dev/null
if [ $? -ne 0 ]; then
libxml2_libraries="$libxml2_libraries z"
fi
# Hack around the fact that --opt=jit on Linux currently uses
# --gcrootfinder=asmgcc which causes a crash with libXML2. Hopefully this hack
# can be removed sooner rather than later.
echo -n "Checking gcrootfinder... "
no_asmgcc_hack=""
case $operating_system in
Linux* )
if [ $rpython_opt = "jit" ]; then
no_asmgcc_hack="--gcrootfinder=shadowstack"
fi
esac
if [ "X$no_asmgcc_hack" = "X" ]; then
echo "using default"
else
echo $no_asmgcc_hack
fi
#
# Bootstrap compiler
#
echo -n "Copying bootstrap compiler... "
cp -p $bootstrap_dir/convergec.bootstrap compiler/convergec
cp -p $bootstrap_dir/convergel.bootstrap compiler/convergel
echo "done."
echo -n "Rewriting .in files... "
rewriter=`mktemp XXXXXXXXXX`
cat << EOF > $rewriter
import os, sys
sys.stdout.write(sys.argv[2] + " ")
sys.stdout.flush()
fin=file(sys.argv[1], "r")
d=fin.read(-1)
fin.close()
i = 3
while i < len(sys.argv):
d=d.replace(sys.argv[i], sys.argv[i + 1])
i+=2
rewrite=True
if os.path.exists(sys.argv[2]):
fout=file(sys.argv[2], "r")
dout=fout.read(-1)
fout.close()
if d==dout:
rewrite=False
if rewrite:
fout=file(sys.argv[2], "w")
fout.write(d)
fout.close()
EOF
for p_in in `find . -name "*.in"`; do
p=`echo $p_in | sed "s/.in$//g"`
$PYTHON $rewriter $p_in $p "@abs_top_srcdir@" "$abs_top_srcdir" "@PYTHON@" "$PYTHON" "@RPYTHON@" "$RPYTHON" "@RPYTHON_OPT@" "$rpython_opt" "@INSTALL@" "$INSTALL" "@prefix@" "$prefix" "@bindir@" "$prefix/bin" "@datadir@" "$prefix/share" "@libdir@" "$prefix/lib" "@INSTALL@" "$abs_top_srcdir/install.sh" "@CONVERGE_VERSION@" "$converge_version" "@CONVERGE_DATE@" "$converge_date" "@PLATFORM@" "$operating_system" "@EXEC_EXT@" "$exec_ext" "@DIR_SEP@" "$DIR_SEP" "@LIBPCRE_INCLUDE_DIRS@" "$libpcre_include_dirs" "@LIBPCRE_LIBRARY_DIRS@" "$libpcre_library_dirs" "@LIBPCRE_LIBRARIES@" "$libpcre_libraries" "@LIBPCRE_LINK_FLAGS@" "$libpcre_link_flags" "@LIBPCRE_A@" "$libpcre_a" "@LIBXML2_INCLUDE_DIRS@" "$libxml2_include_dirs" "@LIBXML2_LIBRARY_DIRS@" "$libxml2_library_dirs" "@LIBXML2_LIBRARIES@" "$libxml2_libraries" "@LIBXML2_LINK_FLAGS@" "$libxml2_link_flags" "@LIBXML2_A@" "$libxml2_a" "@NO_ASMGCC_HACK@" "$no_asmgcc_hack"
done
echo
rm -f $rewriter