#!/usr/bin/env beesh

# BEE_VERSION qt5-5.15.2-1

# SRCURL[0]="https://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz"
SRCURL[0]="https://beehive.molgen.mpg.de/e1447db4f06c841d8947f0a6ce83a7b5/qt-everywhere-src-5.15.2.tar.xz"

PREFIX=/usr/local/qt5

BEE_BUILDTYPE=autotools

BMF=$(beegetopt --option j: -- ${BEE_MAKEFLAGS})
# export for build and install
export NINJAJOBS=${BMF/ -- */}

# build_in_sourcedir

###############################################################################
# NOTE:
# webengine is the new webkit (sigh). To obtain a 'lean and mean' qt toolkit,
# this is the way to dump all web related stuff.
# mee_extract_post() {
#     start_cmd rm -rf ${S}/qtweb*
# }

# At the time of building the system libevent is a complete mess. But it also makes
# sense to keep this in future builds.

mee_patch() {
    bee_patch "${@}"
    sed -e '/webengine-system-libevent/ s/=true\s*$/=false/' -i ${S}/qtwebengine/src/core/config/linux.pri
}

mee_configure() {
    MAKEFLAGS=${BEE_MAKEFLAGS} \
    start_cmd ${S}/configure \
        -prefix ${PREFIX} \
        -bindir ${BINDIR} \
        -libdir ${LIBDIR} \
        -plugindir ${LIBDIR}/plugins \
        -headerdir ${INCLUDEDIR} \
        -sysconfdir ${SYSCONFDIR} \
        -nomake examples \
        -opensource \
        -confirm-license \
        -no-strip \
        -no-pch \
        -verbose \
        -xcb \
        -qpa xcb \
        -opengl

}

mee_build() {
    start_cmd make ${BEE_MAKEFLAGS}
}

mee_install() {
    start_cmd make INSTALL_ROOT=${D} install
}