forked from tranter/raspberry-pi-qt-builds
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild-qt.sh
executable file
·331 lines (305 loc) · 6.69 KB
/
build-qt.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#!/bin/sh
#
# Download and build Qt for desktop
#
# Usage: build-qt.sh [-h] [-n] -[<n>]
# Options:
#
# -h Help
# -n No-execute, just show commands
# -<n> Perform build step <n>, where <n> is:
#
# 0 - download
# 1 - extract source
# 2 - configure
# 3 - build
# 4 - install
# 5 - build docs
# 6 - install docs
# 7 - remove source
# 8 - make tar file of build
# 9 - remove install
# Qt version to build
VERSION_MAJOR=5
VERSION_MINOR=15
VERSION_PATCH=2
# Set if needed for a beta or RC version, e.g. "-beta4"
# Leave empty for release.
VERSION_SUFFIX=
# Build type, "full" or "minimal"
#BUILD_TYPE="full"
BUILD_TYPE="minimal"
# Number of parallel jobs to run
PAR=4
# Stop on error
set -e
# Build directory
BUILD_DIR=${HOME}/qtbuild
# Parse command line options
while getopts "hn0123456789" opt; do
case $opt in
h)
echo "usage: $0 [-h] [-n] -[<n>]"
echo ""
echo "Options:"
echo " -h Help"
echo " -n No-execute, just show commands"
echo " -<n> Perform only build step <n>, where <n> is:"
echo " 0 - download"
echo " 1 - extract source"
echo " 2 - configure"
echo " 3 - build"
echo " 4 - install"
echo " 5 - build docs"
echo " 6 - install docs"
echo " 7 - remove source"
echo " 8 - make tar file of build"
echo " 9 - remove install"
exit
;;
n)
no_exec=1
;;
0)
step_0=1
;;
1)
step_1=1
;;
2)
step_2=1
;;
3)
step_3=1
;;
4)
step_4=1
;;
5)
step_5=1
;;
6)
step_6=1
;;
7)
step_7=1
;;
8)
step_8=1
;;
9)
step_9=1
;;
\?)
exit
;;
esac
done
# If no build steps were specified, enable them all.
if [ -z "$step_0$step_1$step_2$step_3$step_4$step_5$step_6$step_7$step_8$step_9" ]
then
step_0=1
step_1=1
step_2=1
step_3=1
step_4=1
# step_5=1
# step_6=1
step_7=1
step_8=1
step_9=1
fi
# Generate name of archive file
VER2="${VERSION_MAJOR}.${VERSION_MINOR}"
VER3="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
SOURCE="qt-everywhere-src-${VER3}${VERSION_SUFFIX}.tar.xz"
# Releases prior to Qt 5.10.0 use this format:
#SOURCE="qt-everywhere-opensource-src-${VER3}${VERSION_SUFFIX}.tar.xz"
# Name of source directory
DIR=${BUILD_DIR}/`basename ${SOURCE} .tar.xz`
# Name of created build archive file
if [ ${BUILD_TYPE} = "full" ]
then
BUILD="Qt${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-rpi-bin-full.tgz"
elif [ ${BUILD_TYPE} = "minimal" ]
then
BUILD="Qt${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-rpi-bin-minimal.tgz"
else
echo "Unknown build type: ${BUILD_TYPE}"
exit 1
fi
echo "*** Building Qt ${VER3}${VERSION_SUFFIX} (${BUILD_TYPE})"
if [ ! -d "${BUILD_DIR}" ]
then
if [ -n "$no_exec" ]
then
echo mkdir -p "${BUILD_DIR}"
else
mkdir -p "${BUILD_DIR}"
fi
fi
if [ -n "$no_exec" ]
then
echo cd ${BUILD_DIR}
else
cd ${BUILD_DIR}
fi
# Download source if needed.
if [ -n "$step_0" ]
then
if [ -f "${SOURCE}" ]
then
echo "*** Source found, not downloading it"
else
echo "*** Downloading source"
if [ -n "$no_exec" ]
then
echo wget http://download.qt.io/official_releases/qt/${VER2}/${VER3}/single/${SOURCE}
else
wget http://download.qt.io/official_releases/qt/${VER2}/${VER3}/single/${SOURCE}
fi
fi
fi
# Check that a build was not already extracted
if [ -n "$step_1" ]
then
if [ -d ${DIR} ]
then
echo "A build already exists in ${DIR}"
echo "Remove it before doing a build."
if [ -z "$no_exec" ]
then
exit 1
fi
fi
# Extract source
echo "*** Extracting source"
if [ -n "$no_exec" ]
then
echo tar xJf ${SOURCE}
echo cd ${DIR}
else
tar xJf ${SOURCE}
cd ${DIR}
fi
fi
# Configure
if [ -n "$step_2" ]
then
echo "*** Configuring"
if [ ${BUILD_TYPE} = "minimal" ]
then
if [ -n "$no_exec" ]
then
echo cd ${DIR}
echo ./configure -opensource -confirm-license -skip qtwebengine -skip qtlocation -nomake examples -nomake tests -no-assimp
else
cd ${DIR}
./configure -opensource -confirm-license -skip qtwebengine -skip qtlocation -nomake examples -nomake tests -no-assimp
fi
else
if [ -n "$no_exec" ]
then
echo cd ${DIR}
echo ./configure -opensource -confirm-license -skip qtwebengine -skip qtlocation -no-assimp
else
cd ${DIR}
./configure -opensource -confirm-license -skip qtwebengine -skip qtlocation -no-assimp
fi
fi
fi
# Build
if [ -n "$step_3" ]
then
echo "*** Building"
if [ -n "$no_exec" ]
then
echo cd ${DIR}
echo make -s -j${PAR}
else
cd ${DIR}
make -s -j${PAR}
fi
fi
# Install
if [ -n "$step_4" ]
then
echo "*** Installing"
if [ -n "$no_exec" ]
then
echo cd ${DIR}
echo sudo make -s install
else
cd ${DIR}
sudo make -s install
fi
fi
# Build docs
if [ -n "$step_5" ]
then
if [ ${BUILD_TYPE} = "full" ]
then
echo "*** Building docs"
if [ -n "$no_exec" ]
then
echo cd ${DIR}
echo make -s -j${PAR} docs
else
cd ${DIR}
make -s -j${PAR} docs
fi
fi
fi
# Install docs
if [ -n "$step_6" ]
then
if [ ${BUILD_TYPE} = "full" ]
then
echo "*** Installing docs"
if [ -n "$no_exec" ]
then
echo cd ${DIR}
echo sudo make -s install_docs
else
cd ${DIR}
sudo make -s install_docs
fi
fi
fi
# Remove source
if [ -n "$step_7" ]
then
echo "*** Removing source"
if [ -n "$no_exec" ]
then
echo rm -rf ${DIR}
else
rm -rf ${DIR}
fi
fi
# Make tar file of build
if [ -n "$step_8" ]
then
echo "*** Making tar file of build"
if [ -n "$no_exec" ]
then
echo cd ${DIR}/..
echo tar czf ${BUILD} /usr/local/Qt-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
else
cd ${DIR}/..
tar czf ${BUILD} /usr/local/Qt-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
fi
fi
# Remove install
if [ -n "$step_9" ]
then
echo "*** Removing install"
if [ -n "$no_exec" ]
then
echo sudo rm -rf /usr/local/Qt-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
else
sudo rm -rf /usr/local/Qt-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
fi
fi
# Done.
echo "*** Done, build is in ${BUILD}"