# $Id$
# Maintainer: MediaArea.net SARL <info@mediaarea.net>

pkgname=('qctools' 'qcli')
pkgver=1.4.20260627
pkgrel=1
pkgdesc="QCTools (Quality Control Tools for Video Preservation)"
url="http://mediaarea.net"
license=('GPL')
source=(${pkgname}_${pkgver}-1.tar.gz)
md5sums=('00000000000000000000000000000000')
arch=('x86_64')

depends=('qt6-base' 'qt6-svg' 'qt6-multimedia' 'qt6-multimedia-ffmpeg' 'qt6-declarative' 'freetype2' 'harfbuzz' 'zlib' 'nasm')

build() {
    cd "${srcdir}/qctools/ffmpeg"
    ./configure --prefix="$(pwd)" --enable-gpl --enable-version3 --disable-autodetect --disable-programs --enable-static --disable-shared --disable-doc --disable-debug --enable-libfreetype --enable-libharfbuzz
    make

    cd "${srcdir}/qctools/qwt"
    patch -p1 < ../qctools/Project/BuildAllFromSource/qwt.patch
    export QWT_STATIC=1 QWT_NO_SVG=1 QWT_NO_OPENGL=1 QWT_NO_DESIGNER=1
    qmake6
    make

    cd "${srcdir}/qctools/qctools"
    chmod 644 History.txt
    chmod 644 License.html
    mkdir Project/QtCreator/build
    cd Project/QtCreator/build
    qmake6 -after LIBS+=-lharfbuzz LIBS+=-lfreetype ..
    make
}

package_qctools() {
    pkgdesc="${pkgdesc}"
    install -D -m 0755 "${srcdir}"/qctools/qctools/Project/QtCreator/build/qctools-gui/QCTools "${pkgdir}"/usr/bin/QCTools
    install -D -m 0644 "${srcdir}"/qctools/qctools/Source/Resource/Logo.png "${pkgdir}"/usr/share/icons/hicolor/256x256/apps/qctools.png
    install -D -m 0644 "${srcdir}"/qctools/qctools/Source/Resource/Logo.png "${pkgdir}"/usr/share/pixmaps/qctools.png
    install -D -m 0644 "${srcdir}"/qctools/qctools/Project/GNU/GUI/qctools.desktop "${pkgdir}"/usr/share/applications/qctools.desktop
    install -D -m 0644 "${srcdir}"/qctools/qctools/Project/GNU/GUI/qctools.kde3.desktop "${pkgdir}"/usr/share/apps/konqueror/servicemenus/qctools.desktop
    install -D -m 0644 "${srcdir}"/qctools/qctools/Project/GNU/GUI/qctools.kde4.desktop "${pkgdir}"/usr/share/kde4/services/ServiceMenus/qctools.desktop
    install -D -m 0644 "${srcdir}"/qctools/qctools/Project/GNU/GUI/qctools.kde4.desktop "${pkgdir}"/usr/share/kservices5/ServiceMenus/qctools.desktop
    install -D -m 0644 "${srcdir}"/qctools/qctools/Project/GNU/GUI/qctools.metainfo.xml "${pkgdir}"/usr/share/metainfo/qctools.metainfo.xml
}

package_qcli() {
    pkgdesc="${pkgdesc} (CLI)"
    install -D -m 0755 "${srcdir}"/qctools/qctools/Project/QtCreator/build/qctools-cli/qcli "${pkgdir}"/usr/bin/qcli
}
