-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathprepare.sh
executable file
·261 lines (233 loc) · 6.49 KB
/
prepare.sh
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
#! /bin/bash
LIBYB_REPO="git://github.com/avakar/libyb.git"
LIBENJOY_REPO="git://github.com/Tasssadar/libenjoy.git"
GOT_PYTHON=0
GOT_QSCI=0
GOT_JOYSTICK=0
GOT_QTOPENGL=0
function CHECK_EXECUTABLE {
echo -n "Checking for $1..."
exec_path=$(which $1)
if [ -z $exec_path ] ; then
echo ""
echo ""
echo "$1 not found!"
exit 1
else
echo $exec_path
fi
}
function REPORT_GIT_FAIL {
echo ""
echo "git submodule resulted in following output:"
echo $1
echo ""
echo "That may not be actually an error, try to run this script once again"
exit 1
}
function CHECK_SUBMODULE {
IFS=$' '
parts=($1)
echo " Synchronizing ${parts[1]}..."
if [ ${#parts[@]} -eq 2 ] ; then
res=$(git submodule --quiet init "${parts[1]}" 2>&1)
if [ -n "$res" ] ; then
REPORT_GIT_FAIL "$res"
fi
fi
#res=$(git submodule update "${parts[1]}")
res=$(git submodule --quiet update "${parts[1]}" 2>&1)
if [ -n "$res" ] ; then
REPORT_GIT_FAIL "$res"
fi
unset $IFS
}
echo "Checking required executables..."
qmake_bin="qmake"
cpp_bin="c++"
# Handle qmake-qt4 only system
if [ -z "$(which $qmake_bin > /dev/null 2>&1)" ]; then qmake_bin="qmake-qt4"; fi
# Handle cpp only system
if [ -z "$(which $cpp_bin > /dev/null 2>&1)" ]; then cpp_bin="cpp"; fi;
CHECK_EXECUTABLE $qmake_bin
CHECK_EXECUTABLE pkg-config
CHECK_EXECUTABLE make
CHECK_EXECUTABLE cc
CHECK_EXECUTABLE $cpp_bin
echo ""
echo "Checking Qt libraries..."
qtLibs=( 'QtCore' 'QtGui' 'QtNetwork' 'QtScript' 'QtXml' 'QtUiTools' )
for lib in ${qtLibs[@]} ; do
echo -n "Checking for $lib..."
libver=$(pkg-config --modversion $lib --silence-errors)
if [ -z $libver ] ; then
echo "$lib not found!"
exit 1
else
if [ $(echo $libver | tr -d .) -lt 470 ] ; then
echo "too old ($libver, minimum is 4.7.0)"
exit 1
else
echo "ok ($libver)"
fi
fi
done
# Special QtOpenGL check
echo -n "Checking for QtOpenGL..."
libver=$(pkg-config --modversion QtOpenGL --silence-errors)
if [ -z $libver ] ; then
echo "not found, building without OpenGL"
GOT_QTOPENGL=0
else
if [ $(echo $libver | tr -d .) -lt 470 ] ; then
echo "too old ($libver, minimum is 4.7.0)"
GOT_QTOPENGL=0
else
echo "ok ($libver)"
echo ""
echo -n "Do you want to build parts that require OpenGL? [Y/n]: "
read use_qtopengl_user
echo ""
if [ -z $use_qtopengl_user ] || [ "$use_qtopengl_user" == "y" ] || [ "$use_qtopengl_user" == "Y" ] ; then
GOT_QTOPENGL=1
fi
fi
fi
echo ""
echo -n "Checking if this is a git repository..."
IS_GIT=$( ( [ -d ".git" ] && echo 0) || echo 1)
if [ $IS_GIT -eq 0 ] ; then
echo "yes"
else
echo "no"
fi
if [ $IS_GIT -eq 0 ] ; then
echo "Configuring submodules..."
IFS=$'\n'
for module in $(git submodule status) ; do
CHECK_SUBMODULE "$module"
done
unset $IFS
else
echo -n "Checking libyb..."
if [ -e "dep/libyb/libyb.pri" ] ; then
echo "ok"
else
echo "not found"
echo "Clone libyb repository ($LIBYB_REPO) into dep/libyb"
fi
echo -n "Checking libenjoy..."
if [ -e "dep/libenjoy/libenjoy.pri" ] ; then
echo "ok"
else
echo "not found"
echo "Clone libenjoy repository ($LIBENJOY_REPO) into dep/libenjoy"
fi
fi
# Check for python
echo ""
echo "Python support configuration"
REQ_PYTHON_VERSION=2.7
echo "Compatible python versions:"
echo " [1]: 2.5"
echo " [2]: 2.6"
echo " > [3]: 2.7"
echo " [4]: Do not build with python support"
echo -n "Enter your selection (1-4): "
read python_ver_user
case $python_ver_user in
"1")
REQ_PYTHON_VERSION=2.5
;;
"2")
REQ_PYTHON_VERSION=2.6
;;
"3")
REQ_PYTHON_VERSION=2.7
;;
"4")
REQ_PYTHON_VERSION=0
echo "Not using python"
;;
esac
if [ "$REQ_PYTHON_VERSION" != "0" ] ; then
echo -n "Checking for python $REQ_PYTHON_VERSION..."
pkg-config --exists python-$REQ_PYTHON_VERSION
if [ $? -eq 0 ] ; then
GOT_PYTHON=1
echo "ok"
else
echo "not found!"
GOT_PYTHON=0
fi
fi
# Check for editor
echo ""
echo "Code editor configuration"
echo -n "Do you want to use QScintilla2 editor? [Y/n]: "
read use_qsci_user
if [ -z $use_qsci_user ] || [ "$use_qsci_user" == "y" ] || [ "$use_qsci_user" == "Y" ]; then
echo -n "Use systemwide QScintilla2 library? [y/N]: "
read use_qsci_system
echo ""
if [ "$use_qsci_system" == "y" ] || [ "$use_qsci_system" == "Y" ]; then
echo -n "Checking for QScintilla dev files..."
cat > /tmp/test.cpp << EOF
#include <Qsci/qsciscintilla.h>
#include <Qsci/qscilexerjavascript.h>
#include <Qsci/qscilexerpython.h>
int main() { QsciScintilla *s = new QsciScintilla; delete s; return 0; }
EOF
$cpp_bin /tmp/test.cpp -o /tmp/test -I"$($qmake_bin -query QT_INSTALL_HEADERS)" -I"$($qmake_bin -query QT_INSTALL_HEADERS)/QtCore" -I"$($qmake_bin -query QT_INSTALL_HEADERS)/QtGui" -lqscintilla2 -lQtGui -lQtCore
if [ $? -eq 0 ] ; then
echo "ok"
rm /tmp/test.cpp
rm /tmp/test
GOT_QSCI=1
else
echo "failed"
echo "Install qscintilla devel files!"
rm /tmp/test.cpp
exit 1
fi
else
GOT_QSCI=2
echo "Using Lorris' QScintilla2 library"
fi
else
echo "Not using QScintilla"
fi
echo ""
echo -n "Do you want joystick support? [Y/n]: "
read use_joy_user
echo ""
if [ -z $use_joy_user ] || [ "$use_joy_user" == "y" ] || [ $use_joy_user == "Y" ] ; then
GOT_JOYSTICK=1
fi
# CONFIGURATION COMPLETE, GENERATE FILES
echo ""
echo -n "Generating config.pri.."
echo "" > config.pri
if [ $GOT_PYTHON -eq 1 ] ; then
echo "PYTHON_VERSION=$REQ_PYTHON_VERSION" >> config.pri
echo "CONFIG += python" >> config.pri
fi
if [ $GOT_QSCI -eq 1 ] ; then
echo "CONFIG += qsci_editor" >> config.pri
elif [ $GOT_QSCI -eq 2 ] ; then
echo "CONFIG += qsci_system" >> config.pri
fi
if [ $GOT_JOYSTICK -eq 1 ] ; then
echo "CONFIG += joystick" >> config.pri
fi
if [ $GOT_QTOPENGL -eq 1 ] ; then
echo "CONFIG += opengl" >> config.pri
fi
echo "done"
echo "Running qmake..."
$qmake_bin CONFIG+=release QMAKE_CXXFLAGS+="$CXXFLAGS" QMAKE_CFLAGS+="$CFLAGS" Lorris.pro
if [ $? -eq 0 ] ; then
echo ""
echo "Configuration succesfully completed. You can now run \"make\" to compile Lorris"
fi
exit 0