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

R.setup             cran roigrp highs 1.12.0-2
revision            1
categories-append   math
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             GPL-2+
description         HiGHS optimization solver
long_description    R interface to HiGHS, an optimization solver for solving mixed integer optimization \
                    problems with quadratic or linear objective and linear constraints.
homepage            https://gitlab.com/roigrp/solver/highs
checksums           rmd160  56249c8887ef6a9a008cd6f269e7dddf515a78f0 \
                    sha256  d96885393424400cc4b3e86716b392d32e69b185ea3b0e0bef969dc2863f4693 \
                    size    1489296

depends_build-append \
                    path:bin/cmake:cmake \
                    port:bash \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:HiGHS \
                    port:R-checkmate \
                    port:R-Rcpp

patchfiles          patch-use-Macports-highs.diff
post-patch {
    reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/configure
}

if {[string match *gcc* ${configure.compiler}]} {
    # To avoid multiplying patches, just apply this for gcc cases.
    # Notice, this assumes libstdc++ with older C++ ABI.
    patchfiles-append \
                    patch-gcc-builds.diff
} else {
    # Clang gets upset about non-existing path here, drop it:
    patchfiles-append \
                    patch-fix-paths.diff
}

# There are no specific tests atm.
depends_test-append port:R-tinytest

test.run            yes
