# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           qt4 1.0

set proj_name       qtsingleapplication
name                ${proj_name}-qt4
github.setup        qtproject qt-solutions 777e95ba69952f11eaec0adfb0cb987fabcdecb3
version             2022.10.24
revision            0
categories          devel aqua
license             LGPL-2.1
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Qt Solutions Component: Single Application
long_description    The QtSingleApplication component provides support \
                    for applications that can be only started once per user.

checksums           rmd160  c3d7d6e23df54a38071005000981be50dd357343 \
                    sha256  4ae03c300a5e45ea9ff534414d1c5f9405df4da04d5df9e9b8a1cd5b83331f62 \
                    size    1371791
github.tarball_from archive

worksrcdir          ${worksrcpath}/${proj_name}

# https://github.com/qtproject/qt-solutions/pull/23
patchfiles          0001-qtsingleapplication-unbreak-build-with-Qt4.patch

configure.pre_args
configure.args      -library

pre-build {
    system -W ${worksrcpath} "${qt_qmake_cmd}"
}

destroot {
    xinstall -d ${destroot}${qt_dir}
    move ${worksrcpath}/lib ${destroot}${qt_libs_dir}
    set libname libQtSolutions_SingleApplication
    system -W ${destroot}${qt_libs_dir} "install_name_tool -id \
        ${qt_libs_dir}/${libname}-head.1.0.0.dylib ${libname}-head.1.0.0.dylib"
    system -W ${destroot}${qt_libs_dir} "install_name_tool -id \
        ${qt_libs_dir}/${libname}-head_debug.1.0.0.dylib ${libname}-head_debug.1.0.0.dylib"
    ln -s ${qt_libs_dir}/${libname}-head.1.0.0.dylib \
        ${destroot}${qt_libs_dir}/libQtSingleApplication.dylib
    set incdir  ${qt_dir}/include/QtSingleApplication
    xinstall -d ${destroot}${incdir}
    xinstall -m 0644 -W ${worksrcpath}/src QtLockedFile QtSingleApplication \
        ${destroot}${incdir}/
    fs-traverse h ${worksrcpath}/src {
        if {[file isfile ${h}] && [file extension ${h}] == ".h"} {
            copy ${h} ${destroot}${incdir}/
        }
    }
}
