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

PortSystem          1.0
PortGroup           qmake5 1.0

name                qcustomplot
categories          graphics science
license             GPL-3
maintainers         {ra1nb0w @ra1nb0w} openmaintainer
description         QCustomPlot is an easy to use plotting widget for Qt
long_description    ${description}
homepage            https://www.qcustomplot.com

version             2.1.1
checksums           rmd160  60b833693034a08a95cf69a00f0f25b5ff3de99e \
                    sha256  7d6a886993708c07d986065d517ac7e9f3ab067b25acd3d0442eec203d9e448c \
                    size    3762848
revision            0
master_sites        ${homepage}/release/${version}fixed/
distname            QCustomPlot

compiler.cxx_standard 2011

patchfiles-append \
    qcustomplot.pro.patch

post-patch {
    reinplace s|@@VERSION@@|${version}|g ${worksrcpath}/qcustomplot.pro
}

destroot {
    system "install_name_tool -id ${prefix}/lib/libqcustomplot.${version}.dylib ${worksrcpath}/libqcustomplot.${version}.dylib"
    system "install_name_tool -id ${prefix}/lib/libqcustomplotd.${version}.dylib ${worksrcpath}/libqcustomplotd.${version}.dylib"
    xinstall -m 644 -W ${worksrcpath} qcustomplot.h ${destroot}${prefix}/include
    xinstall -m 755 {*}[glob -directory ${worksrcpath} libqcustomplot.${version}.dylib libqcustomplotd.${version}.dylib] \
        ${destroot}${prefix}/lib

    set major [lindex [split ${version} .] 0]
    set major_minor [join [lrange [split ${version} .] 0 1] .]
    foreach link [list libqcustomplot.${major}.dylib libqcustomplot.${major_minor}.dylib libqcustomplot.dylib] {
        ln -s ${prefix}/lib/libqcustomplot.${version}.dylib  ${destroot}${prefix}/lib/${link}
    }
    foreach link [list libqcustomplotd.${major}.dylib libqcustomplotd.${major_minor}.dylib libqcustomplotd.dylib] {
        ln -s ${prefix}/lib/libqcustomplotd.${version}.dylib  ${destroot}${prefix}/lib/${link}
    }
}

livecheck.type      regex
livecheck.url       ${homepage}/index.php/download
livecheck.regex     {/release/([0-9.]+)(fixed)?/QCustomPlot\.tar\.gz}
