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

# memmem, filesystem
legacysupport.newest_darwin_requires_legacy 18
legacysupport.use_mp_libcxx yes

github.setup        hzeller timg 1.6.2 v
github.tarball_from archive
revision            0
categories          graphics

maintainers         {outoforder.cc:urkle @urkle} openmaintainer

description         Terminal Image and Video Viewer
long_description    A user-friendly terminal image viewer that uses graphic \
                    capabilities of terminals (Sixel, Kitty or iterm2), or 24-Bit \
                    color capabilities and unicode character blocks if these are not \
                    available.

license             GPL-2
homepage            https://timg.sh/

checksums           rmd160  c5af6d57a025d94458a7034fc3843a92f7567eec \
                    sha256  a5fb4443f55552d15a8b22b9ca4cb5874eb1a988d3b98fe31d61d19b2c7b9e56 \
                    size    1223894

installs_libs       no

depends_build-append \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:GraphicsMagick \
                    port:webp \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libexif \
                    port:ffmpeg7 \
                    port:libdeflate \
                    port:openslide \
                    path:lib/pkgconfig/poppler.pc:poppler

compiler.cxx_standard 2017

configure.pkg_config_path-append \
                    ${prefix}/libexec/ffmpeg7/lib/pkgconfig

configure.args-append \
                    -DWITH_OPENSLIDE_SUPPORT=ON \
                    -DTIMG_VERSION_FROM_GIT=OFF \
                    -DWITH_LIBSIXEL=OFF \
                    -DWITH_RSVG=OFF

variant librsvg description {Build with librsvg for best quality} {
    configure.args-replace \
                    -DWITH_RSVG=OFF \
                    -DWITH_RSVG=ON
    depends_lib-append \
                    path:lib/pkgconfig/librsvg-2.0.pc:librsvg \
                    path:lib/pkgconfig/cairo.pc:cairo
}

# https://trac.macports.org/ticket/71226
# https://github.com/hzeller/timg/issues/142
# timg requires a fresh librsvg, which is unbuildable on macOS <10.7
if {${os.platform} eq "darwin" && ${os.major} > 10} {
    default_variants +librsvg
}
