#!/bin/sh

QT_VERSION=5.13.0

./genode_qt5_configure

make -j32

# qtbase

cd qtbase/src/3rdparty/pcre2                 && ../../../../create_generated_inc qt5_pcre2                    && cp qt5_pcre2_generated.inc ../../../..                    && cd ../../../..
cd qtbase/src/corelib                        && ../../../create_generated_inc qt5_core                        && cp qt5_core_generated.inc ../../..                        && cd ../../..
cd qtbase/src/gui                            && ../../../create_generated_inc qt5_gui                         && cp qt5_gui_generated.inc ../../..                         && cd ../../..
cd qtbase/src/network                        && ../../../create_generated_inc qt5_network                     && cp qt5_network_generated.inc ../../..                     && cd ../../..
cd qtbase/src/opengl                         && ../../../create_generated_inc qt5_opengl                      && cp qt5_opengl_generated.inc ../../..                      && cd ../../..
cd qtbase/src/printsupport                   && ../../../create_generated_inc qt5_printsupport                && cp qt5_printsupport_generated.inc ../../..                && cd ../../..
cd qtbase/src/sql                            && ../../../create_generated_inc qt5_sql                         && cp qt5_sql_generated.inc ../../..                         && cd ../../..
cd qtbase/src/testlib                        && ../../../create_generated_inc qt5_test                        && cp qt5_test_generated.inc ../../..                        && cd ../../..
cd qtbase/src/widgets                        && ../../../create_generated_inc qt5_widgets                     && cp qt5_widgets_generated.inc ../../..                     && cd ../../..
cd qtbase/src/xml                            && ../../../create_generated_inc qt5_xml                         && cp qt5_xml_generated.inc ../../..                         && cd ../../..

cd qttools/src/designer/src/uitools          && ../../../../../create_generated_inc qt5_ui_tools              && cp qt5_ui_tools_generated.inc ../../../../..              && cd ../../../../..

cd qtdeclarative/src/qml                     && ../../../create_generated_inc qt5_qml                         && cp qt5_qml_generated.inc ../../..                         && cd ../../..
cd qtdeclarative/src/quick                   && ../../../create_generated_inc qt5_quick                       && cp qt5_quick_generated.inc ../../..                       && cd ../../..
cd qtdeclarative/src/imports/qtquick2        && ../../../../create_generated_inc qt5_qtquick2plugin           && cp qt5_qtquick2plugin_generated.inc ../../../..           && cd ../../../..
cd qtdeclarative/src/imports/folderlistmodel && ../../../../create_generated_inc qt5_qmlfolderlistmodelplugin && cp qt5_qmlfolderlistmodelplugin_generated.inc ../../../.. && cd ../../../..
cd qtdeclarative/src/imports/layouts         && ../../../../create_generated_inc qt5_qquicklayoutsplugin      && cp qt5_qquicklayoutsplugin_generated.inc ../../../..      && cd ../../../..
cd qtdeclarative/src/imports/window          && ../../../../create_generated_inc qt5_windowplugin             && cp qt5_windowplugin_generated.inc ../../../..             && cd ../../../..


cd qtsvg/src/svg                             && ../../../create_generated_inc qt5_svg                         && cp qt5_svg_generated.inc ../../..                         && cd ../../..

cd qtvirtualkeyboard/src/virtualkeyboard     && ../../../create_generated_inc qt5_virtualkeyboard               && cp qt5_virtualkeyboard_generated.inc ../../..               && cd ../../..
cd qtvirtualkeyboard/src/plugin              && ../../../create_generated_inc qt5_qtvirtualkeyboardplugin       && cp qt5_qtvirtualkeyboardplugin_generated.inc ../../..       && cd ../../..
cd qtvirtualkeyboard/src/styles              && ../../../create_generated_inc qt5_qtvirtualkeyboardstylesplugin && cp qt5_qtvirtualkeyboardstylesplugin_generated.inc ../../.. && cd ../../..

# qtwebkit

make -C qtwebkit/Source/JavaScriptCore -f Makefile.JavaScriptCore sub-DerivedSources-pri > JavaScriptCore.log
cd qtwebkit/Source/JavaScriptCore
../../../qtbase/bin/qmake ../../../../qt-everywhere-src-${QT_VERSION}/qtwebkit/Source/JavaScriptCore/Target.pri -o Makefile
                                                ../../../create_generated_inc qt5_jscore                      && cp qt5_jscore_generated.inc ../../..                      && cd ../../..
cd qtwebkit/Source/WTF
ln -sf Makefile.WTF Makefile                 && ../../../create_generated_inc qt5_wtf                         && cp qt5_wtf_generated.inc ../../..                         && cd ../../..

make -C qtwebkit/Source/ThirdParty/ANGLE -f Makefile.ANGLE sub-DerivedSources-pri > ANGLE.log
cd qtwebkit/Source/ThirdParty/ANGLE
../../../../qtbase/bin/qmake ../../../../../qt-everywhere-src-${QT_VERSION}/qtwebkit/Source/ThirdParty/ANGLE/Target.pri -o Makefile
                                                ../../../../create_generated_inc qt5_angle                    && cp qt5_angle_generated.inc ../../../..                    && cd ../../../..

make -C qtwebkit/Source/WebCore -f Makefile.WebCore sub-DerivedSources-pri > WebCore.log
cd qtwebkit/Source/WebCore
../../../qtbase/bin/qmake ../../../../qt-everywhere-src-${QT_VERSION}/qtwebkit/Source/WebCore/Target.pri -o Makefile
                                                ../../../create_generated_inc qt5_webcore                     && cp qt5_webcore_generated.inc ../../..                     && cd ../../..
cd qtwebkit/Source/WebKit
ln -sf Makefile.WebKit1 Makefile             && ../../../create_generated_inc qt5_webkit                      && cp qt5_webkit_generated.inc ../../..                      && cd ../../..

cd qtwebkit/Source
ln -sf Makefile.widgetsapi Makefile          && ../../create_generated_inc qt5_webkitwidgets                  && cp qt5_webkitwidgets_generated.inc ../..                  && cd ../..
