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

github.setup            Cantera cantera 2.5.1 v
revision                4
checksums               rmd160  e26fa93268a8e1108de31140cf6382c5014a4bf4 \
                        sha256  59f673cec686bc9b1eeccc1b1c9158a3978a3abe7491d00e8b355908c1c3be0a \
                        size    2492422

categories              science
maintainers             {thomasfiala.de:macports @thomasfiala} openmaintainer
license                 BSD

description             Cantera software package
long_description        Cantera is a suite of object-oriented software tools for \
                        problems involving chemical kinetics, thermodynamics, \
                        and/or transport processes. \
                        Fortran support is disabled by install using MacPorts.

homepage                https://cantera.org
github.tarball_from     archive

python.default_version  310

boost.depends_type      build

set port_libfmt         libfmt8

depends_build-append    port:gtest \
                        port:py${python.version}-pythran \
                        port:py${python.version}-setuptools \
                        port:scons

depends_lib-append      path:share/pkgconfig/eigen3.pc:eigen3 \
                        port:${port_libfmt} \
                        port:py${python.version}-cython \
                        port:py${python.version}-numpy \
                        port:yaml-cpp

depends_run-append      port:py${python.version}-ruamel-yaml

use_configure           no
universal_variant       no

# Needed for libfmt
compiler.cxx_standard   2011
compiler.thread_local_storage yes

# The SConstruct needs pkg_resources from setuptools so have scons run
# with the same python we're already using so that we can declare a
# dependency on that python's setuptools port.
build.cmd               ${python.bin} ${prefix}/bin/scons
build.target            build
build.args              prefix=${prefix} \
                        CC=${configure.cc} \
                        CXX=${configure.cxx} \
                        boost_inc_dir=[boost::include_dir] \
                        f90_interface=n \
                        googletest=system \
                        python_cmd=${python.bin} \
                        python_package=full \
                        python_prefix=${python.prefix} \
                        renamed_shared_libraries=n \
                        system_fmt=y \
                        system_eigen=y \
                        system_yamlcpp=y \
                        extra_inc_dirs=${prefix}/include/eigen3:${prefix}/include/${port_libfmt}:${prefix}/include \
                        extra_lib_dirs=${prefix}/lib/${port_libfmt}:${prefix}/lib

post-build {
    # It would be better to fix the build system to use the -install_name flag
    # when building the dylib, but since I don't know where in the build system
    # to do that...
    set old build/lib/libcantera.${version}.dylib
    set new ${prefix}/lib/libcantera.dylib
    system "install_name_tool -id ${new} ${worksrcpath}/${old}"
    system "install_name_tool -change ${old} ${new} ${worksrcpath}/build/python/cantera/_cantera.cpython-${python.version}-darwin.so"
}

destroot.cmd            ${build.cmd}
destroot.target         install
destroot.args           {*}${build.args}
destroot.destdir        stage_dir=${destroot}

notes "
Cantera C++ demos are installed in:
${prefix}/share/cantera/samples
Cantera python demos are installed in:
${python.pkgd}/cantera/examples
Cantera data files are installed in:
${prefix}/share/cantera/data

Try running the following in python${python.branch} to find the equilibrium\
composition of a stoichiometric methane/air mixture at 1000 K and 1 atm:

>>> import cantera as ct
>>> g = ct.Solution('gri30.xml')
>>> g.TPX = 1000, ct.one_atm, 'CH4:1, O2:2, N2:8'
>>> g.equilibrate('TP')
>>> g()
"

variant sundials description {Build with sundials support} {
    set sundials_ver        5
    set sundials_base       ${prefix}/libexec/sundials${sundials_ver}
    set sundials_include    ${sundials_base}/include
    set sundials_lib        ${sundials_base}/lib

    depends_lib-append      port:sundials${sundials_ver}

    build.args-append       system_sundials=y \
                            sundials_include=${sundials_include} \
                            sundials_libdir=${sundials_lib}
}

default_variants    +sundials

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