# Qt
readonly TMP=/tmp/qt-setup
mkdir --parents "$TMP"
readonly QT5_VERSION=5.15.17
readonly QT5_PREFIX=/opt/Qt/$QT5_VERSION/gcc_64
readonly QT5_TMP=$TMP/Qt5
sudo apt --yes build-dep qtbase5-dev
mkdir --parents "$QT5_TMP"
cd "$QT5_TMP"
git clone --branch v"$QT5_VERSION"-lts-lgpl --single-branch https://github.com/qt/qtbase
cd qtbase
sed -i "0,/#ifdef __cplusplus/!b;//a# include <limits>" src/corelib/global/qglobal.h
sed -i "s|^\([[:space:]]*\)out\.d_func()->fileEngine->syncToDisk();|\1d->fileEngine->syncToDisk();|" src/corelib/io/qfile.cpp
./configure -prefix "$QT5_PREFIX" -xcb -opensource -confirm-license -nomake tests -nomake examples
make --jobs="$(nproc)"
sudo make install
cd ..
git clone --branch v"$QT5_VERSION"-lts-lgpl --single-branch https://github.com/qt/qtserialport
cd qtserialport
"$QT5_PREFIX"/bin/qmake
make --jobs="$(nproc)"
sudo make install
cd ..
git clone --branch v"$QT5_VERSION"-lts-lgpl --single-branch https://github.com/qt/qtsvg
cd qtsvg
"$QT5_PREFIX"/bin/qmake
make --jobs="$(nproc)"
sudo make install
# Qt Creator
readonly QTCREATOR_VERSION=14.0.1
readonly QTCREATOR_TMP=$TMP/QtCreator
mkdir --parents "$QTCREATOR_TMP"
wget "https://github.com/qt-creator/qt-creator/releases/download/v${QTCREATOR_VERSION}/qtcreator-linux-x64-${QTCREATOR_VERSION}.deb" --directory-prefix="$QTCREATOR_TMP"
sudo apt --yes install "$(realpath "$QTCREATOR_TMP/qtcreator-linux-x64-${QTCREATOR_VERSION}".deb)"
mkdir --parents ~/.local/bin/
cp -r /opt/qt-creator/share/ ~/.local/
ln -fs /opt/qt-creator/bin/qtcreator ~/.local/bin/
sudo cp /opt/qt-creator/lib/Qt/lib/libicu* "$QT5_PREFIX"/lib/
rm -rf "$TMP"