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

github.setup        qalculate libqalculate 5.4.0 v
github.tarball_from releases
revision            2

categories          math
maintainers         {gmail.com:jjstickel @jjstickel} {judaew @judaew} \
                    openmaintainer
license             GPL-2+

description \
                    libqalculate is math libary for expression evaluation \
                    with units, variables and functions support and CAS \
                    functionality.

long_description \
                    libqalculate is math libary for expression evaluation \
                    with units, variables and functions support and CAS \
                    functionality.  This library directly supports the \
                    GUI interface qalculate-gtk or qalculate-kde.

checksums           rmd160  bc2d186a320efb08a15c5f5abd23324d5097b5b2 \
                    sha256  1fe956877ff1bbb1f4b470c41cdf3d971cebbeda6a35e92282f0eea5193ac343 \
                    size    2720059

# autoreconf to reconfigure for intltool; use package's autogen script to avoid
# conflict with gettext
use_autoreconf      yes
autoreconf.cmd      ./autogen.sh
autoreconf.env      NOCONFIGURE=1

depends_build-append \
                    port:intltool \
                    port:autoconf \
                    port:automake \
                    path:bin/doxygen:doxygen \
                    port:gettext \
                    port:libtool \
                    path:bin/pkg-config:pkgconfig

depends_lib-append \
                    port:gmp \
                    port:mpfr \
                    port:libxml2 \
                    port:curl \
                    path:lib/pkgconfig/icu-uc.pc:icu \
                    port:gettext-runtime \
                    port:readline \
                    port:libiconv

# ICU requires C++17
compiler.cxx_standard 2017
configure.cxxflags-append -std=c++17

# https://github.com/Qalculate/libqalculate/issues/543
# https://trac.macports.org/ticket/63645
configure.args-append \
                    CXX_FOR_BUILD=${configure.cxx}

# error: variable length array of non-POD element type 'Number'
compiler.blacklist-append {clang < 802}

patch {
    reinplace "s|libtoolize|glibtoolize|g" ${worksrcpath}/autogen.sh
}

post-destroot {
    xinstall -d ${destroot}${prefix}/share/man/man1
    xinstall -m 640 ${worksrcpath}/man/qalc.1 \
        ${destroot}${prefix}/share/man/man1/
}

notes-append "Graphical plotting is enabled by installing gnuplot.\n"
