# Note: requires ruby and gperf if you have icu installed, which enables qtwebkit
# Note: depends on perl
# Note: depends on mesa
# Note: depends on libxcb
# Note: depends on xcb-util-keysyms
# Note: depends on xcb-util-wm
# Note: depends on xcb-util-image
# Note: depends on libXrender
# Note: depends on libxkbcommon
wget -c https://download.qt.io/official_releases/qt/5.8/5.8.0/single/qt-everywhere-opensource-src-5.8.0.tar.xz
tar -xJf qt-everywhere-opensource-src-5.8.0.tar.xz
cd qt-everywhere-opensource-src-5.8.0

rm -rf \
qtbase/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib \
qtbase/tests/auto/corelib/plugin/qpluginloader/elftest/*.so \
qtbase/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.debug \
gnuwin32 \
qtwebkit/Tools/vcbin \
qtwebkit/Tools/CygwinDownloader/cygwin-downloader.zip \
qtwebkit/Examples/NetscapeCoreAnimationPlugin/Composition.qtz \
qtwebkit/Source/WebKit/English.lproj/WebJavaScriptTextInputPanel.nib/keyedobjects.nib \
qtwebkit/Source/WebKit/mac/Panels/English.lproj/WebAuthenticationPanel.nib/keyedobjects.nib \
qtwebkit/WebKitLibraries/win/lib32 \
qtwebkit/WebKitLibraries/lib* \
qtwebkit/Tools/BuildSlaveSupport \
qtwebengine/src/3rdparty/chromium/third_party/openh264/src/autotest/performanceTest/ios \
qtwebengine/src/3rdparty/chromium/third_party/sfntly/src/cpp/ext/redist \
qtwebengine/src/3rdparty/chromium/third_party/skia/platform_tools/android/bin
find . '(' -name '*.pyd' -or -name '*.exe' -or -name '*.elf' -or -name '*.dll' -or -name '*.sys' ')' -delete
sed -i -e '/QT_BEGIN_NAMESPACE/i#define OPENSSL_NO_EC' qtbase/src/network/ssl/qsslcontext_openssl.cpp # Disable buggy code

# The yes is to agree to the GPL, which isn't relevant for building the software
echo yes | ./configure -prefix "/usr" -archdatadir "/usr/lib/qt" -datadir "/usr/share/qt" -examplesdir "/usr/share/qt/examples" -testsdir "/usr/share/qt/tests" -opensource
make # Doesn't mind -j#
make install