-
Notifications
You must be signed in to change notification settings - Fork 174
/
configure
executable file
·156 lines (137 loc) · 3.55 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
#!/bin/sh
warning()
{
printf "\033[1m\n" # bold
printf "$1"
printf "\033[0m\n\n" # end highlighting
}
fatal_error()
{
printf "\033[41m\033[93m\n" # yellow on red background
printf "$1"
printf "\033[0m\n" # end highlighting
}
findprog ()
{
sifs=$IFS
IFS=:
prog="no"
for dir in $PATH; do
if [ -x $dir/$1 -a ! -d $dir/$1 ] ; then
prog="$dir/$1"
break
fi
done
IFS=$sifs
}
findprog python
python=$prog
if test "$python" = "no"; then
findprog python3
python=$prog
fi
echo "checking for Python ... $python"
if test "$python" = "no"; then
fatal_error "Please install Python before proceeding: http://www.python.org"
exit 1
fi
python_v=$(python -V 2>&1 | awk '{print $2}')
is_python3=`python -c 'import sys; print("%i" % (sys.hexversion<0x03000000))'`
echo "checking Python version ... $python_v"
# Detect RSFROOT. Priority: (1) --prefix= ; (2) env. variable; (3) sys.prefix
# Also collect the list of all arguments other than --prefix= because this one
# generates an error when passed to "scons"
i=1
prefixparnum=-1
if test -n "$*"; then
for opt in "$@";
do
case "$opt" in
--prefix=*)
root=`echo $opt | sed 's/[-a-zA-Z0-9]*=//'`
prefixparnum=$i
break
;;
esac
i=`expr $i + 1`
done
fi
if test ! -n "$root"; then
root=${RSFROOT}
fi
if test ! -n "$root"; then
root="no"
fi
echo "checking for RSFROOT ... $root"
if test "$root" = "no"; then
root=`$python -c "import sys; print(sys.prefix)"`
warning "I am setting RSFROOT to $root"
fi
findprog scons
scons=$prog
echo "checking for SCons ... $scons"
if test "$scons" = "no"; then
here=`pwd`
cd scons
# if python version >3
if [ $is_python3 -eq 0 ]; then
archive=`ls [Ss][Cc]ons-4.*.tar.gz`
gunzip < $archive | tar xf - > /dev/null
dir=`ls -d [Ss][Cc]ons-4.* | grep '[^mz]$'`
cd $dir
export PYTHONUSERBASE="$root"
$python -m pip install . --user --no-warn-script-location > /dev/null
else
# if python version <3
archive=`ls [Ss][Cc]ons-3.*.tar.gz`
gunzip < $archive | tar xf - > /dev/null
dir=`ls -d [Ss][Cc]ons-3.* | grep '[^mz]$'`
cd $dir
$python setup.py install --prefix="$root" > /dev/null
fi
cd "$here"
scons="$root/bin/scons"
if test ! -x "$scons"; then
scons="failed"
fi
echo "Installing SCons ... $scons"
if test "$scons" = "failed"; then
fatal_error "Automatic SCons installation failed."
fatal_error "Please install SCons manually!"
exit 2
fi
# Workaround for SCons bug # 1488
if [ -d "$RSFROOT/lib64" ] && [ ! -d "$RSFROOT/lib" ]; then
ln -s $RSFROOT/lib64 $RSFROOT/lib
fi
fi
scons_v=`$scons -v 2>&1 | awk 'NR==2 {print $2}' | sed s/,//`
echo "checking SCons version ... $scons_v"
echo "Running RSFROOT=$root $scons $args config ..."
rm -rf env.*sh .scon* config.py
first=1
arglist=""
for i in "$@"
do
if test $first -ne $prefixparnum; then
arglist=""$arglist" \"\$"$first"\""
fi
first=`expr $first + 1`
done
echo "------------------------"
command1=`printf "$arglist config"`
command2="RSFROOT=$root $scons `printf "$command1"`"
eval $command2
echo "------------------------"
echo "Done with configuration."
chmod +x framework/setenv.py
M8R_PY_PATH=`RSFROOT=$root framework/setenv.py`
# echo $M8R_PY_PATH
if [ -n "$PYTHONPATH" ]; then
PYTHONPATH=$M8R_PY_PATH:${PYTHONPATH}
else
PYTHONPATH=$M8R_PY_PATH
fi
echo "SCONS = RSFROOT=$root PYTHONPATH=$PYTHONPATH $scons" > Makefile
cat Makefile.in >> Makefile
exit 0