# -*- 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           qmake5  1.0
PortGroup           boost   1.0

name                LibreCAD
subport             LibreCAD-devel {}

homepage            https://librecad.org

description         LibreCAD is a free Open Source CAD application.

long_description    LibreCAD is a free Open Source CAD application for \
                    Windows, Apple and Linux. Support and documentation is \
                    free from our large, dedicated community of users, \
                    contributors and developers. You, too, can also get \
                    involved!


categories          cad
license             GPL-2+
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

# Needed for Boost
compiler.thread_local_storage \
                    yes

qt5.depends_component qtsvg qttranslations qttools

if {${subport} eq "${name}"} {

    conflicts           LibreCAD-devel
    github.setup        LibreCAD LibreCAD 2.2.0.2
    github.tarball_from archive
    revision            0
    checksums           rmd160  2092675c79c2da85ba66319f08c3c0f017aa4da8 \
                        sha256  fcb888a550f1f515ef6a2f7af2dd02605dd5c6da8a23f6c3a52479f8532ac109 \
                        size    13645528

    boost.version       1.81

    post-extract {
        reinplace "s|lrelease|${qt_bins_dir}/lrelease|g" scripts/postprocess-osx.sh
    }

} elseif {${subport} eq "${name}-devel"} {

    conflicts           LibreCAD
    github.setup        LibreCAD LibreCAD 2.2.1_alpha
    github.tarball_from archive
    revision            0

    boost.version       1.81

    checksums           rmd160  85605cb0cf0b082b8939911460603ba0d7b59712 \
                        sha256  ac91396da5823e5b58efacbbeed6bf5f669477df7a6755615a8f9290d9cd3a9d \
                        size    13840866
}

# the default destructor cannot be created in all cases
# see https://marc.info/?l=pkgsrc-changes&m=150505264620416&w=2
patchfiles-append   patch-librecad-add-default-destructor-rsimage.diff

if {${os.platform} eq "darwin" && ${os.major} < 10} {
    known_fail          yes
    pre-fetch {
        ui_error "${name} ${version} requires an OS supporting qt5 to function."
        return -code error "incompatible OS X version"
    }
}

depends_lib-append  port:freetype \
                    port:libxmlxx2

compiler.cxx_standard   2011

configure.args-append CONFIG+=\"build_muparser\"

destroot {
    # to make a self-contained application for deployment, the following command can be uncommented
    # system -W ${worksrcpath} "${qt_bins_dir}/macdeployqt LibreCAD.app"

    copy ${worksrcpath}/LibreCAD.app ${destroot}${applications_dir}
}

github.livecheck.regex \
                    {([0-9.]+)}
