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

github.setup        openturns optpp 007d946c950ec17291e735242b26787bb4885b20
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             20220920
revision            0
categories          math
maintainers         nomaintainer
license             LGPL
description         C++ library for non-linear optimization
long_description    OPT++ is a C++ library for non-linear optimization.

homepage            https://software.sandia.gov/opt++
checksums           rmd160  381d5c1b8f388fc8c2d9b83f1367c6862dc42765 \
                    sha256  43568f0f51f4329b3cedd5f27719d81a007271a1021637dc804fb59ac1d16423 \
                    size    1248308

# Failed to activate optpp: Image error: /opt/local/lib/libnewmat.a is being used by the active newmat port
# optpp uses its own copy of newmat: https://github.com/openturns/optpp
# Included and used by OPT++ is R.B. Davies's matrix package, newmat11, with some minor modifications required for the optimization package.
conflicts           newmat

compilers.choose    cc cxx
mpi.setup

patchfiles-append   patch-acx_blas.m4.diff

use_autoreconf      yes

configure.args-append \
                    --includedir=${prefix}/include/OPT++ \
                    --with-blas

configure.ldflags-append \
                    "-framework Accelerate"

# mpich variant stubbornly wants mpich-default, not yet enabled with gcc.
pre-configure {
    if {[mpi_variant_isset]} {
        configure.args-append \
                    --enable-mpi
        configure.env-append \
                    MPICC=${prefix}/bin/${mpi.cc} \
                    MPICXX=${prefix}/bin/${mpi.cxx} \
                    MPI_RUN_COMMAND=${prefix}/bin/${mpi.exec}
    }
}
