# -*- 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           compilers 1.0
PortGroup           github 1.0
PortGroup           makefile 1.0

github.setup        modern-fortran stock-prices ce3054df2505eaa413c4e93b414c4c4714a9967d
version             2023.02.21
revision            0
categories          fortran finance
license             MIT
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Analyzing stock prices with Fortran arrays
long_description    {*}${description}. Companion code for Chapter 4 of Modern Fortran: Building Efficient Parallel Applications

checksums           rmd160  88f0acd02c48331743c05e02dbf83f3733d7d170 \
                    sha256  36435d50246aa7dfc913a5391dc1ed0f0d1cdbdae3da27982a8c4cf3d32402d5 \
                    size    1214416
github.tarball_from archive

patchfiles          patch-stock-datadir.diff

post-patch {
    reinplace -W ${worksrcpath}/src "s|@DATADIR@|${prefix}/share/${name}/data|" \
                    stock_crossover.f90 stock_gain.f90 stock_volatility.f90
}

compilers.setup     require_fortran
compiler.blacklist  *gcc-4.0 *gcc-4.2

build.target

# It fails to build in parallel.
use_parallel_build  no

set datadir ${prefix}/share/${name}

destroot {
    foreach bin {stock_crossover stock_gain stock_volatility} {
        copy ${worksrcpath}/${bin} ${destroot}${prefix}/bin
    }
    xinstall -d ${destroot}${datadir}/doc
    xinstall -m 0644 -W ${worksrcpath} LICENSE README.md ${destroot}${datadir}/doc
    copy ${worksrcpath}/data ${destroot}${datadir}
}

# See: https://github.com/modern-fortran/stock-prices/issues/8
notes "
At the moment ${name} is set to use local data on a few pre-defined stocks.\
Data-sets are places into $datadir/data in .csv format. You may update those manually.
"
