# -*- 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             2024-10
github.setup        odin-lang odin ${ver} dev-
github.tarball_from archive
version             0.[string map {- .} ${ver}]
revision            0

categories          lang
license             BSD
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    18

depends_lib         port:llvm-${llvm_version}

checksums           rmd160  4b5a48343b6fdd18bc690056e7e7d65b87c02bf7 \
                    sha256  00e7a033129006fb339b5514955dc0d7fafa712919db9f32e1a6d5bededb8a19 \
                    size    135410967

patchfiles          patch-build.diff patch-raylib.diff

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

use_configure       no
configure.ldflags-append    -Wl,-rpath,${prefix}/libexec/llvm-${llvm_version}/lib

build.pre_args      release
build.env           ODIN_VERSION=dev-${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}
    delete \
        {*}[glob ${destroot}${prefix}/libexec/${name}/vendor/raylib/macos*/*.dylib]
    ln -s ../libexec/${name}/${name} ${destroot}${prefix}/bin
}
