# -*- 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
PortGroup           legacysupport 1.1
PortGroup           openssl 1.0

legacysupport.newest_darwin_requires_legacy 10

github.setup        barracuda156 shigoku 0.2.3
revision            0
categories          www multimedia anime
license             GPL-3+
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         TUI anime browser/player with added support for manga
long_description    ${name} is a portable terminal UI for browsing anime \
                    via AniList/MAL, resolving streams through pluggable providers \
                    and playing them in mpv/mplayer — with Kitty-/sixel-graphics cover \
                    art, SQLite-backed resume/watch history and truecolor rendering. \
                    ${name}-manga is a TUI manga browser with SDL-based reader.

checksums           rmd160  737101af47f205ca769072a3e7b1971c1d766c31 \
                    sha256  778544eed458b5ad81431f70c145ff102457da0f9a440d70bb8fb87aadb00366 \
                    size    3631871
github.tarball_from archive

installs_libs       no

depends_build-append \
                    port:nlohmann-json \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:curl \
                    port:libarchive \
                    port:libsdl2 \
                    port:sqlite3 \
                    port:webp

# fzf++ used with CLI. Prefer C++ implementation to minimize dependencies.
depends_run-append  port:curl-impersonate \
                    path:bin/fzf:fzfpp \
                    path:bin/mpv:mpv

compiler.cxx_standard   2023

configure.args-append \
                    -DCMAKE_BUILD_TYPE=Release \
                    -DSHIGOKU_BUILD_TESTS=OFF \
                    -DSHIGOKU_SYSTEM_DOCTEST=OFF \
                    -DSHIGOKU_SYSTEM_NLOHMANN_JSON=ON \
                    -DSHIGOKU_SYSTEM_STB=OFF \
                    -DSHIGOKU_SYSTEM_TL_EXPECTED=OFF \
                    -DSHIGOKU_WERROR=OFF \
                    -DWITH_MUPDF=OFF \
                    -DWITH_TUI=ON \
                    -DWITH_VIEWER=ON

variant js description "Use JS runtime for providers needing it" {
    depends_run-append \
                    path:bin/node:nodejs22
}

variant pdf description "Support pdf/epub viewing" {
    depends_lib-append \
                    port:mupdf
    configure.args-replace \
                    -DWITH_MUPDF=OFF -DWITH_MUPDF=ON
}

default_variants    +pdf

if {${os.platform} ne "darwin" || ${os.major} >= 19} {
    default_variants-append +js
}

notes "
It is recommended to use a terminal emulator with support for images (kitty/iterm/sixel),
such as bobcat, contour, foot, iTerm2, mlterm etc.
"

platform powerpc {
    if [variant_isset js] {
        known_fail  yes
        pre-fetch {
            ui_error "MacPorts does not support PowerPC in NodeJS ports."
            ui_error "You may find nodejs22 port for ppc at https\://github.com/macos-powerpc/powerpc-ports."
            return -code error "Unsupported platform"
        }
    }
}
