# -*- coding: utf-8; mode: tcl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- vim:fenc=utf-8:ft=tcl:et:sw=2:ts=2:sts=2

PortSystem              1.0
PortGroup               sourcehut 1.0

name                    uxn
sourcehut.setup         rabbits uxn f2e858273890abcffe7451b0566669e610036f49
version                 20250907
revision                0

categories              emulators
license                 MIT
maintainers             nomaintainer

description             An assembler and emulator for the Uxn \
                        stack-machine, written in ANSI C.
long_description        Uxn is a virtual machine with 32 instructions. \
                        This one-page computer is capable of hosting small \
                        applications, programmable in a unique language. It \
                        was designed with an implementation-first mindset \
                        with a focus on creating portable tools and games.

homepage                https://100r.co/site/uxn.html

checksums               rmd160  b8d932e0f6df8bc6b6037eaf537ee38391700e1e \
                        sha256  3124a864bc61fe2e51bd19bcd6f6349871fc37600e8ad2cd3ec481b0331ee900 \
                        size    280273

depends_lib             port:libsdl2

patchfiles              patch-uxn-build.diff

use_configure           no

# gcc-4.2 fails to build it, because does not support required flag.
# gcc13 builds it normally though. No reason to blacklist all *gcc*.
compiler.blacklist-append \
                        *gcc-4.* {clang < 500}
configure.cflags-append -std=c89 -Wno-typedef-redefinition \
                        -D_C99_SOURCE -D_DARWIN_BETTER_REALPATH

build.cmd               ${worksrcpath}/build.sh
build.args              --no-run
build.env               CC=${configure.cc} \
                        "CFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                        "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"

destroot {
    set demos_dir       ${destroot}${prefix}/share/examples/${name}/demos
    set doc_dir         ${destroot}${prefix}/share/doc/${name}

    xinstall -d -m 0755 ${demos_dir} ${doc_dir}
    xinstall -m 0644 {*}[glob ${worksrcpath}/projects/examples/demos/*.tal] ${demos_dir}
    xinstall -m 0644 -W ${worksrcpath} LICENSE README.md ${doc_dir}
    xinstall -m 0755 ${build.dir}/bin/uxnasm ${build.dir}/bin/uxncli ${build.dir}/bin/uxnemu \
                ${destroot}${prefix}/bin
}

notes "
To get started, see ${prefix}/share/doc/${name}/README.md and
${prefix}/share/examples/${name}/demos/.
"

livecheck.type          none
