-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbuildall
416 lines (350 loc) · 13.2 KB
/
buildall
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
#!/usr/bin/env bash
#
# The BSD 3-Clause License. http://www.opensource.org/licenses/BSD-3-Clause
#
# This file is part of 'Qt-builds' project.
# Copyright (c) 2013 by Alexpux (alexpux@gmail.com)
# All rights reserved.
#
# Project: Qt-builds ( https://github.com/Alexpux/Qt-builds )
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the distribution.
# - Neither the name of the 'Qt-builds' nor the names of its contributors may
# be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# **************************************************************************
export TERM=cygwin
export MSYSTEM=MINGW32
export LC_ALL=en_US.UTF-8
unset SHELL
QT_BUILDS_VERSION="Qt-builds-0.5.0"
BUG_URL=https://github.com/Alexpux/Qt-builds
ORIGINAL_PATH=$PATH
pushd $SYSTEMROOT > /dev/null
WIN_SYS=`pwd`
popd > /dev/null
WINDOWS_PART_PATH=$WIN_SYS/system32:$WIN_SYS
MSYS_PART_PATH=.:/usr/local/bin:/bin
export PATH=$MSYS_PART_PATH:$WINDOWS_PART_PATH
[[ $(env | grep PROCESSOR_ARCHITECTURE) =~ AMD64 || $(env | grep PROCESSOR_ARCHITEW6432) =~ AMD64 ]] && {
IS_64BIT_HOST=yes
} || {
IS_64BIT_HOST=no
}
# directories
TOP_DIR=`pwd`
PREFIX_TOP=/c/QtSDK
PATCH_DIR=${TOP_DIR}/patches
PACKAGE_DIR=${TOP_DIR}/packages
PROG_DIR=${TOP_DIR}/progs
SCENARIOS=${TOP_DIR}/scenarios
ROOT_DIR=${TOP_DIR}/work
# DirectX SDK installation and logviewer paths
[[ $IS_64BIT_HOST == yes ]] && {
DXSDK_DIR="C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/"
LOGVIEWER="c:/progra~2/notepad++/notepad++.exe"
} || {
DXSDK_DIR="C:/Program Files/Microsoft DirectX SDK (June 2010)/"
LOGVIEWER="c:/progra~1/notepad++/notepad++.exe"
}
[[ -d "$DXSDK_DIR" ]] || echo "WARNING: You need installed DirectX SDK for building Qt5..."
[[ -f "$LOGVIEWER" ]] || LOGVIEWER="/c/Windows/system32/notepad.exe"
SHOW_LOG_ON_ERROR=yes
# MinGW toolchain links
# setup toolchain details
GCC_VERSION=4.8.1
REV_VERSION=rev5
ROOT_URL=http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases
# threads=posix
URL_MINGW32_POSIX=${ROOT_URL}/${GCC_VERSION}/32-bit/threads-posix/dwarf/x32-${GCC_VERSION}-release-posix-dwarf-${REV_VERSION}.7z
URL_MINGW64_POSIX=${ROOT_URL}/${GCC_VERSION}/64-bit/threads-posix/seh/x64-${GCC_VERSION}-release-posix-seh-${REV_VERSION}.7z
TOOLCHAINS_DIR_POSIX=${TOP_DIR}/toolchains_posix
# threads=win32
URL_MINGW32_WIN32=${ROOT_URL}/${GCC_VERSION}/32-bit/threads-win32/dwarf/x32-${GCC_VERSION}-release-win32-dwarf-${REV_VERSION}.7z
URL_MINGW64_WIN32=${ROOT_URL}/${GCC_VERSION}/64-bit/threads-win32/seh/x64-${GCC_VERSION}-release-win32-seh-${REV_VERSION}.7z
TOOLCHAINS_DIR_WIN32=${TOP_DIR}/toolchains_win32
# By default use posix toolchains
TOOLCHAINS_DIR=${TOOLCHAINS_DIR_POSIX}
URL_MINGW32=${URL_MINGW32_POSIX}
URL_MINGW64=${URL_MINGW64_POSIX}
# Use system installed toolchains
USER_DEFINED_TOOLCHAINS=no
# Update sources from repositories
UPDATE_SOURCES=no
# MinGW-builds contain prebuilded python in opt subdirectory.
# Does we use msys-python, mingw-builds python or build python yourself.
USE_PYTHON=msys
# Build and use Ruby
BUILD_RUBY=no
# Build and use Perl
BUILD_PERL=yes
# Build Qt-Creator
BUILD_QTCREATOR=yes
# Build some extra libraries
BUILD_EXTRA_STUFF=no
BUILD_OSG=no
BUILD_COIN3D=no
# Build Flags
MAKE_OPTS="-j3"
STATIC_LINK_FLAGS="--enable-static --disable-shared"
SHARED_LINK_FLAGS="--enable-shared --disable-static"
# How to link dependencies
LNKDEPS=$SHARED_LINK_FLAGS
STATIC_DEPS=no
STATIC_SUFFIX=""
STATIC_LD=""
# Default Qt version to build
QT_VERSION="5.1.1"
#Use different folders for building Qt with different opengl options
QTDIR_PREFIX="angle"
# Qt5 git branch to build
QT_GIT_BRANCH="stable"
# Build Qt5 with "-opengl desktop"
USE_OPENGL_DESKTOP=no
RUN_ARGS="$@"
[[ $# == 1 && $1 == --help || $[ $# == 0 ] == 1 ]] && {
echo "usage:"
echo " ./${0##*/} <i686|x86_64> [OPTIONS]"
echo " help:"
echo " --buildroot=<path> - specifies the build root directory"
echo " Default is $ROOT_DIR/work"
echo " --install-top - specifies the top installation directory"
echo " Default is $PREFIX_TOP"
echo " --toolchains-dir=<path> - specifies directory where installed Mingw 32-bit and 64-bit toolchains"
echo " You must have mingw32 and mingw64 directories there"
echo " --update-sources - try update sources from repositories"
echo " --opengl-desktop - build Qt with opengl=desktop (for Qt-5.x only)"
echo " --qt-version=<version> - specifies the Qt version to build"
echo " Default Qt version is $QT_VERSION"
echo " --qt-git-branch=<branch> - Specify what Qt git branch to clone when building Qt from git"
echo " Default branch is - $QT_GIT_BRANCH"
echo " --build-python - specifies to the script to build Python and use it when building Qt"
echo " --toolchain-python - specifies to the script to use Python from mingw-builds toolchain"
echo " --build-ruby - specifies to the script to build Ruby and use it when building Qt"
echo " By default using MSYS2 Ruby"
echo " --make-jobs=<x> - specifies number of jobs for make command (-jx)"
echo " Default is 3"
echo " --no-qtcreator - disable building Qt-Creator"
echo " --static-qt - build Qt to static libraries"
echo " --extra-stuff - build extra libraries"
echo " --osg - build OpenSceneGraph"
echo " --coin3d - build Coin3D"
echo " --version - print the version of the Qt-builds scripts"
echo " Available Qt versions:"
echo " 4.8.4, 4.8.5, 5.0.0, 5.0.1, 5.0.2, 5.1.0, 5.1.1, git"
exit 0
}
export INSTALL=/bin/install
source helpers_functions.sh
[[ -d /mingw ]] && {
die "please remove \"/mingw\" directory. terminate."
}
[[ -n $(which "gcc.exe" 2>/dev/null) || \
-n $(which "i686-pc-mingw32-gcc.exe" 2>/dev/null) || \
-n $(which "i686-w64-mingw32-gcc.exe" 2>/dev/null) || \
-n $(which "x86_64-w64-mingw32-gcc.exe" 2>/dev/null) \
]] && {
die "remove from PATH any existing MinGW directory. terminate."
}
while [[ $# > 0 ]]; do
case $1 in
--buildroot=*)
ROOT_DIR=${1/--buildroot=/}
ROOT_DIR=${ROOT_DIR//:/:\/}
ROOT_DIR=${ROOT_DIR//\/\//\/}
mkdir -p ${ROOT_DIR} || die "Incorrect directory ${ROOT_DIR}"
pushd ${ROOT_DIR} > /dev/null
ROOT_DIR=`pwd`
popd > /dev/null
;;
--install-top=*)
PREFIX_TOP=${1/--install-top=/}
PREFIX_TOP=${PREFIX_TOP//:/:\/}
PREFIX_TOP=${PREFIX_TOP//\/\//\/}
mkdir -p ${PREFIX_TOP} || die "Incorrect directory ${PREFIX_TOP}"
pushd ${PREFIX_TOP} > /dev/null
PREFIX_TOP=`pwd`
popd > /dev/null
;;
--toolchains-dir=*)
TOOLCHAINS_DIR=${1/--toolchains-dir=/}
TOOLCHAINS_DIR=${TOOLCHAINS_DIR//:/:\/}
TOOLCHAINS_DIR=${TOOLCHAINS_DIR//\/\//\/}
mkdir -p ${TOOLCHAINS_DIR} || die "Incorrect directory ${TOOLCHAINS_DIR}"
pushd ${TOOLCHAINS_DIR} > /dev/null
TOOLCHAINS_DIR=`pwd`
popd > /dev/null
USER_DEFINED_TOOLCHAINS=yes
;;
--update-sources) UPDATE_SOURCES=yes ;;
--opengl-desktop)
USE_OPENGL_DESKTOP=yes
QTDIR_PREFIX="opengl"
;;
--qt-version=*) QT_VERSION=${1/--qt-version=/} ;;
--qt-git-branch=*) QT_GIT_BRANCH=${1/--qt-git-branch=/} ;;
--version) echo $QT_BUILDS_VERSION; exit 0 ;;
--build-python) USE_PYTHON=self ;;
--toolchain-python) USE_PYTHON=toolchain ;;
--build-ruby) BUILD_RUBY=yes ;;
--make-jobs=*) MAKE_OPTS=${1/--make-jobs=/} ;;
--no-qtcreator) BUILD_QTCREATOR=no ;;
--static-qt)
export lt_cv_deplibs_check_method='pass_all'
LNKDEPS=$STATIC_LINK_FLAGS
USE_OPENGL_DESKTOP=yes
BUILD_QTCREATOR=no
BUILD_QDESKTOPCOMPONENTS=no
STATIC_DEPS=yes
STATIC_SUFFIX="-s"
STATIC_LD="-static-libstdc++ -static-libgcc"
# For static building prefer to use toolchains with threads=win32
# to avoid dependency from libwinpthread-1.dll
[[ $USER_DEFINED_TOOLCHAINS == no ]] && {
TOOLCHAINS_DIR=${TOOLCHAINS_DIR_WIN32}
}
URL_MINGW32=${URL_MINGW32_WIN32}
URL_MINGW64=${URL_MINGW64_WIN32}
;;
--extra-stuff) BUILD_EXTRA_STUFF=yes ;;
--osg)
BUILD_EXTRA_STUFF=yes
BUILD_OSG=yes
;;
--coin3d)
BUILD_EXTRA_STUFF=yes
BUILD_COIN3D=yes
;;
i686)
[[ ${BUILD_ARCHITECTURES[@]} =~ i686 ]] && { shift; continue; }
BUILD_ARCHITECTURES=( ${BUILD_ARCHITECTURES[@]} i686 )
;;
x86_64)
[[ ${BUILD_ARCHITECTURES[@]} =~ x86_64 ]] && { shift; continue; }
BUILD_ARCHITECTURES=( ${BUILD_ARCHITECTURES[@]} x86_64 )
;;
*)
echo "bad command line: \"$1\""
die "terminate."
;;
esac
shift
done
SRC_DIR=${ROOT_DIR}/src
MARKERS_DIR=${ROOT_DIR}/markers
UNPACK_DIR=${ROOT_DIR}/unpack
mkdir -p $SRC_DIR $MARKERS_DIR $TOOLCHAINS_DIR $UNPACK_DIR
[[ ${#BUILD_ARCHITECTURES[@]} > 2 || ${#BUILD_ARCHITECTURES[@]} == 0 || \
${BUILD_ARCHITECTURES[0]} == ${BUILD_ARCHITECTURES[1]} ]] && {
die "error in build architectures(${BUILD_ARCHITECTURES[@]}). terminate."
}
[[ $IS_64BIT_HOST == no && ${BUILD_ARCHITECTURES[@]} =~ x86_64 ]] && {
die "you can't build 64-bit programs using 32-bit OS. terminate."
}
[[ ! -f $SCENARIOS/qt-${QT_VERSION}.sh ]] && {
die "Can't find script to build version $QT_VERSION of Qt."
}
i686_HOST_MINGW_PATH=${TOOLCHAINS_DIR}/mingw32
x86_64_HOST_MINGW_PATH=${TOOLCHAINS_DIR}/mingw64
[[ $USER_DEFINED_TOOLCHAINS == no ]] && {
toolchains_prepare
}
[[ ! -d $i686_HOST_MINGW_PATH || ! -d $x86_64_HOST_MINGW_PATH ]] && {
die "Host toolchains is not installed. Terminate!"
}
[[ $USE_PYTHON == msys ]] && {
command -v "python" > /dev/null 2>&1 || { USE_PYTHON=self; }
}
[[ $BUILD_RUBY == no ]] && {
command -v "ruby" > /dev/null 2>&1 || { BUILD_RUBY=yes; }
}
source versions.sh
source package_order.sh
for ARCHITECTURE in ${BUILD_ARCHITECTURES[@]}; do
PREFIX=${PREFIX_TOP}/prerequisites-${ARCHITECTURE}${STATIC_SUFFIX}
[[ $QT_VERSION == git ]] && {
QTVER=${QT_VERSION}${STATIC_SUFFIX}-${QT_GIT_BRANCH}
QTVER=${QTVER//debug/deb}
QTVER=${QTVER//release/rel}
} || {
QTVER=${QT_VERSION}${STATIC_SUFFIX}
}
QTDIR=${PREFIX_TOP}/Qt-${QTVER}-${ARCHITECTURE}-${QTDIR_PREFIX}
BUILD_DIR=${ROOT_DIR}/build-$ARCHITECTURE${STATIC_SUFFIX}
LOG_DIR=${ROOT_DIR}/logs-$ARCHITECTURE${STATIC_SUFFIX}
[[ $ARCHITECTURE == i686 ]] && {
HOST=i686-w64-mingw32
BUILD=i686-w64-mingw32
TARGET=i686-w64-mingw32
OPTIM="-march=i686 -mtune=core2"
[[ ! -f $i686_HOST_MINGW_PATH/bin/gcc.exe ]] && {
die "gcc.exe is not exists in the \"$i686_HOST_MINGW_PATH/bin\" directory. terminate."
}
MINGWHOME=$i686_HOST_MINGW_PATH
} || {
HOST=x86_64-w64-mingw32
BUILD=x86_64-w64-mingw32
TARGET=x86_64-w64-mingw32
OPTIM="-march=nocona -mtune=core2"
[[ ! -f $x86_64_HOST_MINGW_PATH/bin/gcc.exe ]] && {
die "gcc.exe is not exists in the \"$x86_64_HOST_MINGW_PATH/bin\" directory. terminate."
}
MINGWHOME=$x86_64_HOST_MINGW_PATH
}
pushd $MINGWHOME > /dev/null
MINGWHOME_WIN=`pwd -W`
popd > /dev/null
mkdir -p $BUILD_DIR $QTDIR $LOG_DIR $PREFIX
pushd ${PREFIX} > /dev/null
export PREFIX_WIN=`pwd -W`
popd > /dev/null
MINGW_PART_PATH=$PREFIX/bin:$QTDIR/bin:$MINGWHOME/bin
[[ $USE_PYTHON == toolchain ]] && {
MINGW_PYTHON2_PREFIX=$MINGWHOME/opt
MINGW_PYTHON2_PREFIX_W=$MINGWHOME_WIN/opt
export PYTHONHOME=$MINGW_PYTHON2_PREFIX_W
MINGW_PART_PATH=$MINGW_PART_PATH:$MINGW_PYTHON2_PREFIX/bin
}
export PATH=$MINGW_PART_PATH:$PATH
HOST_CFLAGS="$OPTIM -pipe -O2"
HOST_CXXFLAGS="${HOST_CFLAGS}"
HOST_CPPFLAGS="-I${PREFIX}/include" #-I$PYTHONHOME/include
HOST_LDFLAGS="$STATIC_LD -pipe -s -L${PREFIX}/lib" #-L$PYTHONHOME/lib/python2.7/config
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${QTDIR}/lib/pkgconfig"
pushd ${QTDIR} > /dev/null
export QTDIR_WIN=`pwd -W`
popd > /dev/null
echo "-> Start building"
for sub in ${PACKAGES[@]}; do
echo -e "-> \E[32;40m$sub\E[37;40m"
[[ ! -f $SCENARIOS/$sub.sh ]] && {
die "script for subtarget \"$sub\" is not exists. terminate."
}
source ${SCENARIOS}/${sub}.sh
src_download
src_unpack
src_patch
src_configure
pkg_build
pkg_install
done
done