summaryrefslogtreecommitdiffstats
path: root/release-tools/mkqt5bld.py
blob: de60a350e2d37e11638a2160932188296386d6ed (plain)
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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
#!/usr/bin/env python
###############################################
#
# Copyright (C) 2012 Digia Plc
# For any questions to Digia, please use contact form at http://qt.digia.com
#
# $QT_BEGIN_LICENSE:LGPL$
# GNU Lesser General Public License Usage
# This file may be used under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation and
# appearing in the file LICENSE.LGPL included in the packaging of this
# file. Please review the following information to ensure the GNU Lesser
# General Public License version 2.1 requirements will be met:
# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#
# GNU General Public License Usage
# Alternatively, this file may be used under the terms of the GNU General
# Public License version 3.0 as published by the Free Software Foundation
# and appearing in the file LICENSE.GPL included in the packaging of this
# file. Please review the following information to ensure the GNU General
# Public License version 3.0 requirements will be met:
# http://www.gnu.org/copyleft/gpl.html.
#
# $QT_END_LICENSE$
#
# If you have questions regarding the use of this file, please use
# contact form at http://qt.digia.com
#
###############################################

import os
import re
import shutil
import subprocess
from subprocess import PIPE, STDOUT
import sys
import urllib
import fileinput
import bldinstallercommon
import patch_qmake_qt_key

SCRIPT_ROOT_DIR                     = os.getcwd()
WORK_DIR_NAME                       = 'qt5_workdir'
WORK_DIR                            = SCRIPT_ROOT_DIR + os.sep + WORK_DIR_NAME
QT_SRC_PACKAGE_URL                  = ''
QT_PACKAGE_SAVE_AS_TEMP             = ''
QT_SOURCE_DIR                       = WORK_DIR + os.sep + 'w'
MAKE_INSTALL_ROOT_DIR               = WORK_DIR + os.sep + 'qt5_install_root' #main dir for submodule installations
CONFIGURE_CMD                       = ''
MAKE_CMD                            = ''
MAKE_THREAD_COUNT                   = '8' # some initial default value
MAKE_INSTALL_CMD                    = ''
MODULE_ARCHIVE_DIR_NAME             = 'module_archives'
MODULE_ARCHIVE_DIR                  = SCRIPT_ROOT_DIR + os.sep + MODULE_ARCHIVE_DIR_NAME
MAIN_INSTALL_DIR_NAME               = 'main_install'
SUBMODULE_INSTALL_BASE_DIR_NAME     = "submodule_install_"

QT5_MODULES_LIST                    = [ 'qt3d', 'qlalr', 'qtactiveqt', 'qtbase',     \
                                        'qtconnectivity', 'qtdeclarative', 'qtdoc', \
                                        'qtdocgallery', 'qtfeedback', 'qtgraphicaleffects', \
                                        'qtimageformats', 'qtjsondb', 'qtjsbackend', \
                                        'qtlocation', 'qtmultimedia', 'qtphonon', 'qtpim', \
                                        'qtqa', 'qtquick1', 'qtrepotools', 'qtscript', \
                                        'qtsensors', 'qtsvg', 'qtsystems', 'qttools', \
                                        'qttranslations', 'qtwayland', 'webkit', \
                                        'qtwebkit-examples-and-demos', 'qtxmlpatterns']

CONFIGURE_OPTIONS                   = '-opensource -nomake tests -confirm-license' #-make examples
DEVEL_MODE                          = 0
FORCE_MAKE                          = 0
RUN_RPATH                           = False
ORIGINAL_QMAKE_QT_PRFXPATH          = ''
BUILD_WEBKIT                        = True
BUILD_TRANSLATIONS                  = False
PADDING                             = "______________________________PADDING______________________________"


###############################
# function
###############################
def print_wrap(text):
    print 'QT5BLD: ' + text


###############################
# function
###############################
def init_mkqt5bld():
    global CONFIGURE_CMD
    global CONFIGURE_OPTIONS
    global MAKE_CMD
    global MAKE_INSTALL_CMD
    global SUBMODULE_INSTALL_BASE_DIR_NAME
    global MAKE_INSTALL_ROOT_DIR

    print_wrap('---------------- Initializing build --------------------------------')
    if bldinstallercommon.is_linux_platform():          #linux
        CONFIGURE_CMD = './'
        CONFIGURE_OPTIONS += ' -no-gtkstyle'
    elif bldinstallercommon.is_mac_platform():          #mac
        CONFIGURE_CMD = './'
        #CONFIGURE_OPTIONS += ' -make libs -no-pch' <- not sure if these are needed,
        #Added -developer-build to get the sources built, should be removed later..?
        CONFIGURE_OPTIONS = '-developer-build -opensource -confirm-license -nomake tests -platform macx-clang -prefix $PWD/qtbase'

    #Add padding to original rpaths to make sure that original rpath is longer than the new
    if bldinstallercommon.is_linux_platform() or bldinstallercommon.is_solaris_platform():
        CONFIGURE_OPTIONS += ' -R ' + PADDING

    CONFIGURE_CMD += 'configure'

    # make cmd
    if MAKE_CMD == '':  #if not given in commandline param, use nmake or make according to the os
        if bldinstallercommon.is_win_platform():        #win
            MAKE_CMD = 'nmake /l /s'
            MAKE_INSTALL_CMD = 'nmake /l /s install'
        elif bldinstallercommon.is_linux_platform():    #linux
            MAKE_CMD = 'make -s'
            MAKE_INSTALL_CMD = 'make -s install'
        elif bldinstallercommon.is_mac_platform():      #mac
            MAKE_CMD = 'make -s'
            MAKE_INSTALL_CMD = 'make -s install'

    if FORCE_MAKE == 1:
        if bldinstallercommon.is_linux_platform() or bldinstallercommon.is_mac_platform():    #linux&mac
            MAKE_CMD = MAKE_CMD + ' -i'
            MAKE_INSTALL_CMD = MAKE_INSTALL_CMD + ' -i'

    #remove old working dirs
    if os.path.exists(WORK_DIR):
        print_wrap('    Removing old work dir ' + WORK_DIR)
        bldinstallercommon.remove_tree(WORK_DIR)
    if os.path.exists(MODULE_ARCHIVE_DIR):
        print_wrap('    Removing old module archive dir ' + MODULE_ARCHIVE_DIR)
        bldinstallercommon.remove_tree(MODULE_ARCHIVE_DIR)

    print_wrap('    Using ' + MAKE_CMD + ' for making and ' + MAKE_INSTALL_CMD + ' for installing')
    print_wrap('    Qt configure command set to: ' + CONFIGURE_CMD + ' ' + CONFIGURE_OPTIONS)
    print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
def fetch_src_package():
    global QT_PACKAGE_SAVE_AS_TEMP
    QT_PACKAGE_SAVE_AS_TEMP = os.path.normpath(WORK_DIR + os.sep + os.path.basename(QT_SRC_PACKAGE_URL))
    print_wrap('---------------- Fetching Qt src package ---------------------------')
    # check first if package on local file system
    if not os.path.isfile(QT_PACKAGE_SAVE_AS_TEMP):
        if not bldinstallercommon.is_content_url_valid(QT_SRC_PACKAGE_URL):
            print_wrap('*** Qt src package url: [' + QT_SRC_PACKAGE_URL + '] is invalid! Abort!')
            sys.exit(-1)
        print_wrap('     Downloading:        ' + QT_SRC_PACKAGE_URL)
        print_wrap('            into:        ' + QT_PACKAGE_SAVE_AS_TEMP)
        # start download
        urllib.urlretrieve(QT_SRC_PACKAGE_URL, QT_PACKAGE_SAVE_AS_TEMP, reporthook=bldinstallercommon.dlProgress)
    else:
        print_wrap('Found local package, using that: ' + QT_PACKAGE_SAVE_AS_TEMP)
    print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
def extract_src_package():
    global QT_SOURCE_DIR
    global CONFIGURE_CMD
    print_wrap('---------------- Extracting source package -------------------------')
    if os.path.exists(QT_SOURCE_DIR):
        print_wrap('Source dir ' + QT_SOURCE_DIR + ' already exists, using that (not re-extracting the archive!)')
    else:
        print_wrap('Extracting source package: ' + QT_PACKAGE_SAVE_AS_TEMP)
        print_wrap('Into:                      ' + QT_SOURCE_DIR)
        bldinstallercommon.create_dirs(QT_SOURCE_DIR)
        bldinstallercommon.extract_file(QT_PACKAGE_SAVE_AS_TEMP, QT_SOURCE_DIR)

    l = os.listdir(QT_SOURCE_DIR)
    items = len(l)
    if items == 1:
        print_wrap('    Replacing qt-everywhere-xxx-src-5.0.0 with shorter path names')
        shorter_dir_path = QT_SOURCE_DIR + os.sep + 's'
        os.rename(QT_SOURCE_DIR + os.sep + l[0], shorter_dir_path)
        print_wrap('    Old source dir: ' + QT_SOURCE_DIR)
        QT_SOURCE_DIR = shorter_dir_path
        print_wrap('    New source dir: ' + QT_SOURCE_DIR)
        #CONFIGURE_CMD = QT_SOURCE_DIR + os.sep + CONFIGURE_CMD   #is this needed in shadow build?
    else:
        print_wrap('*** Unsupported directory structure!!!')
        sys.exit(-1)

    #remove not working dirs
    if not BUILD_TRANSLATIONS:
        if os.path.exists(QT_SOURCE_DIR + os.sep + 'qttranslations'):
            print_wrap('    Removing qttranslations')
            bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qttranslations')
    if not BUILD_WEBKIT:
        if os.path.exists(QT_SOURCE_DIR + os.sep + 'qtwebkit'):
            print_wrap('    Removing qtwebkit')
            bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qtwebkit')
        if os.path.exists(QT_SOURCE_DIR + os.sep + 'qtwebkit-examples-and-demos'):
            print_wrap('    Removing qtwebkit-examples-and-demos')
            bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qtwebkit-examples-and-demos')

    print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
def build_qt():
    global QT5_MODULES_LIST
    # configure
    print_wrap('---------------- Configuring Qt ------------------------------------')
    cmd_args = CONFIGURE_CMD + ' ' + CONFIGURE_OPTIONS
    print_wrap('    Configure line: ' + cmd_args)
    bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, True)
    # build
    print_wrap('---------------- Building Qt ---------------------------------------')
    #create list of modules in default make order
    regex = re.compile('^make_first:.*') #search line starting with 'make_default:'
    submodule_list = []
    modules_found = 0
    if os.path.exists(QT_SOURCE_DIR + os.sep + 'Makefile'):
        print_wrap('    Generating ordered list of submodules from main Makefile')
        makefile = open(QT_SOURCE_DIR + os.sep + 'Makefile', 'r')
        for line in makefile:
            lines = regex.findall(line)
            for make_def_line in lines:
                #print_wrap(make_def_line)
                make_def_list = make_def_line.split(' ')
                #TODO: check if there is more than one line in Makefile
                #change 'module-qtbase-make_first' to 'qtbase'
                for item in make_def_list:
                    if item.startswith('module-'):
                        submodule_name = item[7:]   #7 <- module-
                        index = submodule_name.index('-make_first')
                        submodule_list.append(submodule_name[:index])
                        modules_found = 1

        if modules_found == 1:
            QT5_MODULES_LIST = submodule_list
            print_wrap('    Modules list updated, modules list is now in default build order.')
        else:
            print_wrap('    Warning! Could not extract module build order from ' + QT_SOURCE_DIR + os.sep + 'Makefile. Using default (non-ordered) list.')
    else:
        print_wrap('*** Error! Main Makefile not found. Build failed!')
        sys.exit(-1)
    #remove if old dir exists
    if os.path.exists(MAKE_INSTALL_ROOT_DIR):
        shutil.rmtree(MAKE_INSTALL_ROOT_DIR)
    #create install dirs
    bldinstallercommon.create_dirs(MAKE_INSTALL_ROOT_DIR)
    #main level make
    cmd_args = MAKE_CMD
    if bldinstallercommon.is_linux_platform():
        cmd_args += ' -j' + MAKE_THREAD_COUNT
    print_wrap('    Running make on root level')
    bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, True)
    print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
def patch_rpaths():
    if RUN_RPATH:
        if (bldinstallercommon.is_linux_platform() or bldinstallercommon.is_solaris_platform()):
            print_wrap('---------------- Patching RPaths -----------------------------------')
            bldinstallercommon.handle_component_rpath(QT_SOURCE_DIR, 'lib')
            print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
def install_qt():
    print_wrap('---------------- Installing Qt -------------------------------------')
    #main level make install
    cmd_args = ''
    if bldinstallercommon.is_linux_platform():
        cmd_args = 'sudo '
    cmd_args += MAKE_INSTALL_CMD
    print_wrap('    Running main level make install')
    bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, True)
    #main level install with install root
    #main level make install
    cmd_args = ''
    install_root_path = MAKE_INSTALL_ROOT_DIR + os.sep + MAIN_INSTALL_DIR_NAME
    if bldinstallercommon.is_linux_platform():
        cmd_args = 'sudo '
    if bldinstallercommon.is_win_platform():
        install_root_path = install_root_path[3:]
        print_wrap('    On Windows, use install root path: ' + install_root_path)
    cmd_args += MAKE_INSTALL_CMD + ' INSTALL_ROOT=' + install_root_path
    print_wrap('    Running main level make install with install root ' + install_root_path)
    bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, True)
#end - main level install with install root

    #make install for each module with INSTALL_ROOT
    print_wrap('    Install modules to INSTALL_ROOT')
    for module_name in QT5_MODULES_LIST:
        if module_name == 'qtwebkit' and not BUILD_WEBKIT:
            print_wrap('    > > > > > > NOT installing qtwebkit < < < < < < < <')
        elif module_name == 'qtwebkit-examples-and-demos' and not BUILD_WEBKIT:
            print_wrap('    > > > > > > NOT installing qtwebkit-examples-and-demos < < < < < < < <')
        elif module_name == 'qttranslations' and not BUILD_TRANSLATIONS:
            print_wrap('    > > > > > > NOT installing qttranslations < < < < < < < <')
        else:
            install_root_path = MAKE_INSTALL_ROOT_DIR + os.sep + SUBMODULE_INSTALL_BASE_DIR_NAME + module_name
            if bldinstallercommon.is_win_platform():
                install_root_path = install_root_path[3:]
                print_wrap('    Using install root path: ' + install_root_path)
            submodule_dir_name = QT_SOURCE_DIR + os.sep + module_name
            cmd_args = ''
            if bldinstallercommon.is_linux_platform():
                cmd_args = 'sudo '
            cmd_args += MAKE_INSTALL_CMD + ' ' + 'INSTALL_ROOT=' + install_root_path
            print_wrap('    Installing module: ' + module_name)
            print_wrap('          -> cmd args: ' + cmd_args)
            print_wrap('                -> in: ' + submodule_dir_name)
            bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), submodule_dir_name, True)
    print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
def save_original_qt_prfxpath():
    print_wrap('---------------- Saving original qt_prfxpath -----------------------')
    global ORIGINAL_QMAKE_QT_PRFXPATH
    qmake_executable_path = bldinstallercommon.locate_executable(QT_SOURCE_DIR, 'qmake' + bldinstallercommon.get_executable_suffix())
    if not qmake_executable_path:
        print_wrap('*** Error! qmake executable not found? Looks like the build has failed in previous step? Aborting..')
        sys.exit(-1)
    ORIGINAL_QMAKE_QT_PRFXPATH = patch_qmake_qt_key.fetch_key(os.path.normpath(qmake_executable_path), 'qt_prfxpath')
    print_wrap(' ===> Original qt_prfxpath: ' + ORIGINAL_QMAKE_QT_PRFXPATH)
    if not ORIGINAL_QMAKE_QT_PRFXPATH:
        print_wrap('*** Could not find original qt_prfxpath from qmake executable?!')
        print_wrap('*** Abort!')
        sys.exit(-1)
    print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
#def restore_qt_prfxpath():
#    print_wrap('---------------- Restoring original qt_prfxpath --------------------')
#    qmake_executable_path = bldinstallercommon.locate_executable(MAKE_INSTALL_ROOT_DIR, 'qmake' + bldinstallercommon.get_executable_suffix())
#    print_wrap(' ===> Patching: ' + qmake_executable_path)
#    patch_qmake_qt_key.replace_key(qmake_executable_path, 'qt_prfxpath', ORIGINAL_QMAKE_QT_PRFXPATH)
#    print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
def replace_build_paths(path_to_checked):
    print_wrap('---------------- Replacing build paths -----------------------------')
    for root, dirs, files in os.walk(path_to_checked):
        for name in files:
            if name.endswith('.prl') or name.endswith('.la') or name.endswith('.pc') or name.endswith('.pri'):
                path = os.path.join(root, name)
                print_wrap('---> Replacing build path in: ' + path)
                print_wrap('--->         String to match: ' + QT_SOURCE_DIR)
                print_wrap('--->             Replacement: ' + ORIGINAL_QMAKE_QT_PRFXPATH)
                for line in fileinput.FileInput(path,inplace=1):
                   line = line.replace(QT_SOURCE_DIR, ORIGINAL_QMAKE_QT_PRFXPATH)
    print_wrap('--------------------------------------------------------------------')


###############################
# function
###############################
def clean_up(install_dir):
    print_wrap('---------------- Cleaning unnecessary files from ' + install_dir + '----------')
    file_list = ['Makefile', '.o', '.moc', '.pro', '.pri', '.init-repository', '.cpp', '.h', '.gitignore', '.qmlproject']
    for root, dirs, files in os.walk(install_dir):
        for name in files:
            if name in file_list:
                path = os.path.join(root, name)
                print_wrap('    ---> Deleting file: ' + name)
                os.remove(path)

    #TODO: At the moment, it seems that installing to default location is necessary
    #to be able to install to INSTALL_ROOT, so remove here the installation from default location
    if bldinstallercommon.is_linux_platform() or bldinstallercommon.is_mac_platform():
        default_install_dir = '/usr/local/Qt-5.0.0'
        if os.path.exists(default_install_dir):
            print_wrap('    Removing /usr/local/Qt-5.0.0 on mac/linux..')
            bldinstallercommon.remove_tree(default_install_dir)

    # on windows remove redundant .dll files from \lib
    if bldinstallercommon.is_win_platform():
        # each submodule first
        for sub_dir in QT5_MODULES_LIST:
            base_path = MAKE_INSTALL_ROOT_DIR + os.sep + SUBMODULE_INSTALL_BASE_DIR_NAME + sub_dir
            lib_path = bldinstallercommon.locate_directory(base_path, 'lib')
            if lib_path:
                bldinstallercommon.delete_files_by_type_recursive(lib_path, '\\.dll')
            else:
                print_wrap('*** Warning! Unable to locate \\lib directory under: ' + base_path)
        # then the full install
        base_path_full_install = MAKE_INSTALL_ROOT_DIR + os.sep + MAIN_INSTALL_DIR_NAME
        if os.path.exists(base_path_full_install):
            full_install_lib_path = bldinstallercommon.locate_directory(base_path_full_install, 'lib')
            if full_install_lib_path:
                bldinstallercommon.delete_files_by_type_recursive(full_install_lib_path, '\\.dll')
            else:
                print_wrap('*** Warning! Unable to locate \\lib directory under: ' + full_install_lib_path)
    print_wrap('--------------------------------------------------------------------')



###############################
# function
###############################
def archive_submodules():
    print_wrap('---------------- Archiving submodules ------------------------------')
    bldinstallercommon.create_dirs(MODULE_ARCHIVE_DIR)
    # submodules
    for sub_dir in QT5_MODULES_LIST:
        print_wrap('---------- Archiving ' + sub_dir)
        if os.path.exists(MAKE_INSTALL_ROOT_DIR + os.sep + SUBMODULE_INSTALL_BASE_DIR_NAME + sub_dir):
            cmd_args = '7z a ' + MODULE_ARCHIVE_DIR + os.sep + sub_dir + '.7z ' + SUBMODULE_INSTALL_BASE_DIR_NAME + sub_dir
            bldinstallercommon.do_execute_sub_process_get_std_out(cmd_args.split(' '), MAKE_INSTALL_ROOT_DIR, True, True)
        else:
            print_wrap(MAKE_INSTALL_ROOT_DIR + os.sep + SUBMODULE_INSTALL_BASE_DIR_NAME + sub_dir + ' DIRECTORY NOT FOUND\n      -> ' + sub_dir + ' not archived!')
    # one chunk
    if os.path.exists(MAKE_INSTALL_ROOT_DIR + os.sep + MAIN_INSTALL_DIR_NAME):
        print_wrap('    Archiving all modules to archive qt5_all.7z')
        cmd_args = '7z a ' + MODULE_ARCHIVE_DIR + os.sep + 'qt5_all' + '.7z ' + MAIN_INSTALL_DIR_NAME
        bldinstallercommon.do_execute_sub_process_get_std_out(cmd_args.split(' '), MAKE_INSTALL_ROOT_DIR, True, True)
    print_wrap('---------------------------------------------------------------------')


###############################
# function
###############################
def print_help():
    print_wrap('*** Error! Insufficient arguments given!')
    print_wrap('')
    print_wrap('Example: python -u mkqt5bld.py src_url=qt-everywhere-opensource-src-5.0.0.zip force_make [make_cmd=mingw32-make]')
    print_wrap('')
    print_wrap('Available options:')
    print_wrap('')
    print_wrap('  src_url=[url where to fetch src package]')
    print_wrap('  devel_mode')
    print_wrap('  use_prefix=[prefix used for configure options]')
    print_wrap('  force_make')
    print_wrap('  patch_rpath=yes/no')
    print_wrap('  make_cmd=[custom make tool]')
    print_wrap('  make_thread_count=[number of threads]')
    print_wrap('  build_webkit=yes/no')
    print_wrap('')


###############################
# function
###############################
def parse_cmd_line():
    global CONFIGURE_OPTIONS
    global QT_SRC_PACKAGE_URL
    global DEVEL_MODE
    global FORCE_MAKE
    global RUN_RPATH
    global MAKE_CMD
    global MAKE_THREAD_COUNT
    global MAKE_INSTALL_CMD
    global BUILD_WEBKIT

    print_wrap('---------------- Parsing commandline arguments ---------------------')
    arg_count = len(sys.argv)
    if arg_count < 2:
        print_help()
        sys.exit(-1)
    #Parse command line options
    for item in sys.argv[1:]:
        #url for the sources
        if item.find('src_url') >= 0:
            values = item.split('=')
            QT_SRC_PACKAGE_URL = values[1]
            print_wrap('        Qt source dir set to: ' + QT_SRC_PACKAGE_URL)
        #is using development mode
        if item.find('devel_mode') >= 0:
            DEVEL_MODE = 1
            CONFIGURE_OPTIONS += ' -nomake examples'
            print_wrap('        devel mode set to true.')
        #prefix for configure
        if item.find('use_prefix') >= 0:
            values = item.split('=')
            CONFIGURE_OPTIONS += ' -prefix ' + values[1]
            print_wrap('        -prefix added to configure line.')
        #set force make (-i option for make)
        if item.find('force_make') >= 0:
            FORCE_MAKE = 1
            print_wrap('        using force make (ignoring errors).')
        #set to run rpath
        if item.find('patch_rpath') >= 0:
            RUN_RPATH = True
            print_wrap('        enabling RPath patching.')
        #set make command, if not set make/nmake is used
        if item.find('make_cmd') >= 0:
            values = item.split('=')
            if values[1] != '':
                MAKE_CMD = values[1]
                MAKE_INSTALL_CMD = values[1] + ' install'
            print_wrap('        using command: ' + MAKE_CMD + ' for making and ' + MAKE_INSTALL_CMD + ' for installing')
        #how many threads to be used for building
        if item.find('make_thread_count') >= 0:
            values = item.split('=')
            if values[1] != '':
                MAKE_THREAD_COUNT = values[1]
            print_wrap('        threads used for building: ' + MAKE_THREAD_COUNT)
        # do we build webkit?
        if item.find('build_webkit') >= 0:
            values = item.split('=')
            if values[1] != '':
                if values[1] == 'yes' or values[1] == 'true':
                    BUILD_WEBKIT = True
                else:
                    BUILD_WEBKIT = False
            print_wrap('        build webkit: ' + values[1])

    print_wrap('---------------------------------------------------------------------')
    return True


###############################
# function
###############################
def main():
    # init
    bldinstallercommon.init_common_module(SCRIPT_ROOT_DIR)
    # parse cmd line
    parse_cmd_line()
    # init
    init_mkqt5bld()
    # create work dir
    bldinstallercommon.create_dirs(WORK_DIR)
    # fetch src package (or create?)
    fetch_src_package()
    # extract src package
    extract_src_package()
    # build
    build_qt()
    # save original qt_prfxpath in qmake executable
    save_original_qt_prfxpath()
    # install
    install_qt()
    # patch rpaths
    #patch_rpaths()
    # restore qt_prfxpath in qmake executable
    #restore_qt_prfxpath()
    #cleanup files that are not needed in binary packages
    clean_up(MAKE_INSTALL_ROOT_DIR)
    # replace build directory paths in installed files
    replace_build_paths(MAKE_INSTALL_ROOT_DIR)
    # archive each submodule
    archive_submodules()

###############################
# function
###############################
main()