# -*- 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

conflicts           LibreCAD-devel
github.setup        LibreCAD LibreCAD 2.2.1.5 v
github.tarball_from archive
revision            0
checksums           rmd160  ae3c498308b9cbef3e0470ac9c42ab9c84c86488 \
                    sha256  703f6e6701b7ee47769b6def271fa025ef32e31ee193e2ba69a2c47fff8da459 \
                    size    20192101

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

# Needed for Boost
compiler.thread_local_storage \
                    yes

boost.version       1.88

# 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"
    }
}

qt5.depends_component \
                    qtsvg qttranslations qttools

depends_lib-append  port:freetype \
                    port:libxmlxx2

compiler.cxx_standard \
                    2011

configure.args-append \
                    CONFIG+=\"build_muparser\"
# stop muparser port headers from shadowing the bundled headers
configure.cppflags-prepend \
                    -I${worksrcpath}/libraries/muparser/include

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

    system -W ${worksrcpath} "/usr/bin/codesign --sign - ${name}.app"
    copy ${worksrcpath}/${name}.app ${destroot}${applications_dir}
}

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