# -*- 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               cmake 1.1
PortGroup               github 1.0

github.setup            lfortran lfortran 0.20.3 v
revision                0
categories              lang fortran
maintainers             {@barracuda156 gmail.com:vital.had} openmaintainer
license                 BSD
description             Modern open-source interactive Fortran compiler
long_description        LFortran is a modern open-source interactive Fortran compiler built on top of LLVM. \
                        It can execute user’s code interactively to allow exploratory work \
                        (much like Python, MATLAB or Julia) as well as compile to binaries \
                        with the goal to run user’s code on modern architectures such as multi-core CPUs and GPUs.
homepage                https://lfortran.org

# Build system is a bit handicapped.
fetch.type              git
cmake.out_of_source     no

set port_libfmt         libfmt10
cmake.module_path-append \
                        ${prefix}/lib/${port_libfmt}/cmake

# TODO: add a conditional variant with support for LLVM for aarch64 and x86.
depends_build-append    port:bash \
                        port:bison \
                        port:re2c
depends_lib-append      path:lib/pkgconfig/RapidJSON.pc:rapidjson \
                        port:zlib \
                        port:${port_libfmt}

set py_ver              3.11
set py_ver_nodot        [string map {. {}} ${py_ver}]
depends_lib-append      port:python${py_ver_nodot}

configure.python        ${prefix}/bin/python${py_ver}

post-patch {
    reinplace "s|python src|${configure.python} src|g" ${worksrcpath}/build0.sh
    reinplace "s|/usr/bin/env python|${configure.python}|" ${worksrcpath}/run_tests.py
}

compiler.cxx_standard   2017

configure.args-append   -DLFORTRAN_BUILD_ALL=YES \
                        -DLFORTRAN_STATIC_BIN=NO \
                        -DWITH_FMT=YES \
                        -DWITH_JSON=YES \
                        -DWITH_LLVM=NO \
                        -DWITH_RUNTIME_LIBRARY=YES \
                        -DWITH_ZLIB=YES

cmake.build_type        Release
