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

set ver             2026-07a
github.setup        odin-lang odin ${ver} dev-
github.tarball_from archive
version             0.[string map {- .} ${ver}]
revision            0

categories          lang
license             zlib
maintainers         {makr @mohd-akram} openmaintainer

description         Odin programming language

long_description    Odin is a general-purpose programming language with \
                    distinct typing, built for high performance, modern \
                    systems, and built-in data-oriented data types.

homepage            https://odin-lang.org/

set llvm_version    22

depends_lib         port:llvm-${llvm_version} \
                    port:libiconv

checksums           rmd160  0cb7834e9485c0c0b3617d3af225581d347a86ce \
                    sha256  8f4f02fd9a3426b441cd0dfbe0aca1b95fd93c95d86940fcb4417ef6044c83cd \
                    size    149542086

patchfiles          patch-build.diff patch-raylib.diff

# odin only needs c++14 but llvm needs c++17
compiler.cxx_standard   2017

use_configure       no

build.pre_args      release
build.env           GIT_DATE=${ver} \
                    LLVM_CONFIG=llvm-config-mp-${llvm_version} \
                    CXX=${configure.cxx} \
                    CXXFLAGS=${configure.cxxflags} \
                    CPPFLAGS=${configure.cppflags} \
                    LDFLAGS=${configure.ldflags}

destroot {
    xinstall -d ${destroot}${prefix}/libexec/${name}
    copy ${worksrcpath}/${name} ${worksrcpath}/base ${worksrcpath}/core \
        ${worksrcpath}/vendor ${destroot}${prefix}/libexec/${name}
    fs-traverse f ${destroot}${prefix}/libexec/${name}/vendor {
        if {[regexp {\.(dll|lib|so(\.[0-9]+)*|dylib)$} ${f}]} {
            delete ${f}
        }
    }
    if {${os.platform} ne "linux"} {
        delete \
            {*}[glob ${destroot}${prefix}/libexec/${name}/vendor/lua/*/linux/*.a] \
            {*}[glob ${destroot}${prefix}/libexec/${name}/vendor/raylib/linux/*.a]
    }
    ln -s ../libexec/${name}/${name} ${destroot}${prefix}/bin
}
