-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-linux.sh
executable file
·366 lines (312 loc) · 8.81 KB
/
build-linux.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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#!/usr/bin/env bash
set -xeuo pipefail
cd "$(dirname -- "$0")"
. versions
ROOTDIR="$(pwd)"
SHADOWDIR="$ROOTDIR/shadow"
DISTDIR="$ROOTDIR/dist"
if [[ $OSTYPE =~ ^darwin ]]
then
OSX=1
else
OSX=
fi
if [[ $OSX ]]
then
NPROC="$(sysctl -n hw.activecpu)"
export LLVM_INSTALL_DIR=/usr/local/opt/llvm
else
NPROC="$(nproc)"
export LLVM_INSTALL_DIR="/usr/lib/llvm-8"
fi
export QT_INSTALL_HEADERS="$DISTDIR/include"
export PATH="$DISTDIR/bin:$LLVM_INSTALL_DIR/bin${PATH:+:$PATH}"
if [[ $OSX ]]
then
export DYLD_FALLBACK_LIBRARY_PATH="$DISTDIR/lib:$LLVM_INSTALL_DIR/lib${DYLD_FALLBACK_LIBRARY_PATH:+:$DYLD_FALLBACK_LIBRARY_PATH}"
else
export LD_LIBRARY_PATH="$DISTDIR/lib:$LLVM_INSTALL_DIR/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi
export PKG_CONFIG_PATH="$DISTDIR/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export CMAKE_PREFIX_PATH="$ROOTDIR${CMAKE_PREFIX_PATH:+:$CMAKE_PREFIX_PATH}"
function doBootstrap {
if [[ $OSX ]]
then
brew install pkg-config llvm xz zstd freetype > /dev/null
else
PACKAGES=(
git
build-essential
python
python3
pkg-config
libclang-8-dev
cmake
libfontconfig1-dev
libwayland-dev
libwayland-egl1-mesa
libegl1-mesa-dev
mesa-common-dev
libssl-dev
libxkbcommon-dev
chrpath
)
INSTALLED="$(dpkg -s "${PACKAGES[@]}" 2>/dev/null | grep -Pio '^Status:.*\binstalled\b' | wc -l)" || true
NEEDED=${#PACKAGES[@]}
if [[ $INSTALLED != $NEEDED ]]
then
if [[ -t 1 ]]
then
YFLAG=""
else
YFLAG="-y"
export DEBIAN_FRONTEND=noninteractive
fi
if [[ $EUID != 0 ]]
then
sudo apt update $YFLAG > /dev/null
sudo apt install $YFLAG "${PACKAGES[@]}" > /dev/null
else
apt update $YFLAG > /dev/null
apt install $YFLAG "${PACKAGES[@]}" > /dev/null
fi
fi
fi
}
function doInit {
PATCHFILES=(qtbase qtdeclarative)
for PATCHFILENAME in "${PATCHFILES[@]}"
do
PATCHFILE="$ROOTDIR/$PATCHFILENAME.patch"
if [[ ! -f $PATCHFILE ]]
then
echo "$PATCHFILE not found"
exit -1
fi
done
rm -rf qt5
git clone https://code.qt.io/qt/qt5.git > /dev/null
pushd qt5
git checkout "$QT5_BUILD_QT" > /dev/null
MODULE_SUBSET=qtbase,qtcharts,qtdeclarative,qtquickcontrols,qtquickcontrols2,qtgraphicaleffects,qttools,qttranslations
./init-repository --module-subset="$MODULE_SUBSET" > /dev/null
for PATCHFILENAME in "${PATCHFILES[@]}"
do
pushd $PATCHFILENAME
git apply "$ROOTDIR/$PATCHFILENAME.patch"
popd
done
popd
}
function doConfigure {
rm -rf "$SHADOWDIR"
mkdir -p "$SHADOWDIR"
pushd "$SHADOWDIR"
ARGS=(
-release
-silent
-prefix "$DISTDIR"
-opensource
-confirm-license
-reduce-exports
-make libs
-make tools
-no-glib
-no-icu
-opengl desktop
-system-zlib \
-qt-doubleconversion
-qt-pcre
-qt-harfbuzz
-qt-libjpeg
-qt-libpng
-qt-sqlite
-pkg-config
)
if [[ -z $OSX ]]
then
ARGS+=(
-reduce-relocations
-fontconfig
-system-freetype
-openssl
)
fi
"$ROOTDIR/qt5/configure" "${ARGS[@]}"
popd
}
function doBuild {
pushd "$SHADOWDIR"
make -j"$NPROC" &> /dev/null || make
rm -rf "$DISTDIR"
make install &> /dev/null || make install
popd
cat > "$DISTDIR/bin/qt.conf" << EOF
[Paths]
Prefix=..
EOF
}
function doDocs {
pushd "$SHADOWDIR"
make -j"$NPROC" docs &> /dev/null || make docs
make install_qch_docs &> /dev/null || make install_qch_docs
popd
}
function doLibs {
#
# QuaZip
#
rm -rf quazip
git clone https://github.com/stachenov/quazip.git > /dev/null
pushd quazip/quazip
git checkout "$QT5_BUILD_QUAZIP" > /dev/null
if [[ $OSX ]]
then
qmake PREFIX="$DISTDIR" QMAKE_LFLAGS+="-lz"
else
qmake PREFIX="$DISTDIR"
fi
make -j"$NPROC" &> /dev/null || make
make install &> /dev/null || make install
popd
if [[ -z $OSX ]]
then
#
# QtDBusExtended
#
#rm -rf qtdbusextended
#git clone https://github.com/nemomobile/qtdbusextended.git > /dev/null
#pushd qtdbusextended
# git checkout "$QT5_BUILD_QTDBUSEXTENDED" > /dev/null
# qmake
# make -j"$NPROC" &> /dev/null || make
# make install &> /dev/null || make install
#popd
#
# QtMPRIS
#
rm -rf qtmpris
git clone https://git.merproject.org/mer-core/qtmpris.git > /dev/null
pushd qtmpris
git checkout "$QT5_BUILD_QTMPRIS" > /dev/null
qmake
make -j"$NPROC" &> /dev/null || make
make install &> /dev/null || make
popd
#
# ECM
#
rm -rf extra-cmake-modules
git clone https://github.com/KDE/extra-cmake-modules.git > /dev/null
pushd extra-cmake-modules
git checkout "$QT5_BUILD_KDECMAKEEXTRAMODULES" > /dev/null
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX="$DISTDIR" ..
make -j"$NPROC" &> /dev/null || make
make install &> /dev/null || make install
popd
#
# KSyntaxHighlighting
#
rm -rf syntax-highlighting
git clone https://github.com/KDE/syntax-highlighting.git > /dev/null
pushd syntax-highlighting
git checkout "$QT5_BUILD_KSYNTAXHIGHLIGHTING" > /dev/null
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX="$DISTDIR" .. > /dev/null
make -j"$NPROC" &> /dev/null || make
make install &> /dev/null || make install
popd
cp -a "$DISTDIR/lib/x86_64-linux-gnu/." "$DISTDIR/lib/"
rm -rf "$DISTDIR/lib/x86_64-linux-gnu/"
fi
}
function doQbs {
rm -rf qbs
git clone https://code.qt.io/qbs/qbs.git > /dev/null
pushd qbs
git checkout "$QT5_BUILD_QBS" > /dev/null
git submodule update --init > /dev/null
qmake
make -j"$NPROC" &> /dev/null || make
if [[ $OSX ]]
then
SED_INPLACE_OPTS=( -i "" )
else
SED_INPLACE_OPTS=( -i )
fi
find . -name 'Makefile*' -type f -exec sed "${SED_INPLACE_OPTS[@]}" -e 's/$(INSTALL_ROOT)\/usr\/local\//$(INSTALL_ROOT)\//g' {} +
make install INSTALL_ROOT="$DISTDIR" &> /dev/null || make install INSTALL_ROOT="$DISTDIR"
find . -name 'Makefile*' -type f -exec sed "${SED_INPLACE_OPTS[@]}" -e 's/$(INSTALL_ROOT)\/share\/doc\//$(INSTALL_ROOT)\/doc\//g' {} +
make qch_docs install_inst_qch_docs INSTALL_ROOT="$DISTDIR" &> /dev/null || make qch_docs install_inst_qch_docs INSTALL_ROOT="$DISTDIR"
if [[ $OSX ]]
then
install_name_tool -add_rpath "@executable_path/../../lib" "$DISTDIR/libexec/qbs/qbs_processlauncher"
fi
cat > "$DISTDIR/libexec/qbs/qt.conf" << EOF
[Paths]
Prefix=../..
EOF
popd
}
function doPatch {
./relpc.py "$DISTDIR"
if [[ -z $OSX ]]
then
find "$DISTDIR/lib" -iname '*.so*' -type f |
while read LIBPATH
do
RELDIR="$(realpath --relative-to="$(dirname "$LIBPATH")" "$DISTDIR/lib")"
if [[ $RELDIR == "." ]]
then
NEW_RPATH='$ORIGIN'
else
NEW_RPATH='$ORIGIN/'"$RELDIR"
fi
chrpath -r "$NEW_RPATH" "$LIBPATH" || true
done
fi
}
function doArchive {
mkdir archive
pushd archive
mv ../dist qt5
if [[ $OSX ]]
then
OS_NAME=osx
else
OS_NAME=linux
fi
ARCH="$(uname -m)"
tar -cf - qt5 | xz -9e -c - > "qt5-$QT5_BUILD_QT-$OS_NAME-$ARCH.tar.xz"
popd
}
case "${1:-}" in
bootstrap) doBootstrap ;;
init) doInit ;;
configure) doConfigure ;;
build) doBuild ;;
docs) doDocs ;;
libs) doLibs ;;
qbs) doQbs ;;
patch) doPatch ;;
archive) doArchive ;;
all)
doBootstrap
doInit
doConfigure
doBuild
doDocs
doLibs
doQbs
doPatch
doArchive
;;
*)
echo "specify a valid task (bootstrap, init, configure, build, docs, libs, qbs, patch, archive, all) as a first argument"
exit -1
;;
esac
echo "DONE!"