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

github.setup        dankamongmen notcurses 3.0.16 v
github.tarball_from archive
revision            1

categories          devel
license             Apache-2
maintainers         {linux.com:nickblack @dankamongmen} openmaintainer

description         blingful tuis and character graphics
long_description    Notcurses facilitates the creation of modern TUI programs, making \
                    full use of Unicode and 24-bit TrueColor. Its API is similar \
                    to that of NCURSES, but extends that with z-buffering, rendering \
                    of images and video using ffmpeg, alpha blending, widgets, palette \
                    fades, resize awareness, and multithreading support.

homepage            https://notcurses.com

master_sites-append ${github.homepage}/releases/download/${github.tag_prefix}${version}/:doc
distfiles-append    ${name}-doc-${version}${extract.suffix}:doc

checksums           ${distname}${extract.suffix} \
                    rmd160  63d55acabef1c175a610ab70a36d40d95e7a5927 \
                    sha256  e893c507eab2183b6c598a8071f2a695efa9e4de4b7f7819a457d4b579bacf05 \
                    size    10160662 \
                    ${name}-doc-${version}${extract.suffix} \
                    rmd160  0f48c4161192497a8524605187c078ab2d5bf5d1 \
                    sha256  30e761ec0b93748d708da3567be5580cb0d43069e02a8db32efe23584e6f33da \
                    size    155099

# The source distfile has an enclosing directory but the doc distfile doesn't.
extract.mkdir       yes

post-extract {
    # Rearrange so both source and doc are top-level dirs under workpath.
    move ${worksrcpath} ${workpath}/${name}-doc-${version}
    move ${workpath}/${name}-doc-${version}/${worksrcdir} ${worksrcpath}
}

patchfiles          libunistring-1.4.patch

# requires clock_gettime()
legacysupport.newest_darwin_requires_legacy 15

compiler.c_standard 2017
compiler.cxx_standard \
                    2017

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

depends_lib-append  path:lib/libavcodec.dylib:ffmpeg \
                    port:libunistring \
                    port:libdeflate \
                    port:ncurses

configure.args-append \
                    -DUSE_PANDOC=OFF

post-destroot {
    set notcurses-doc ${workpath}/${name}-doc-${version}
    xinstall -m 0644 {*}[glob ${notcurses-doc}/*.1] \
        ${destroot}${prefix}/share/man/man1
    xinstall -m 0644 {*}[glob ${notcurses-doc}/*.3] \
        ${destroot}${prefix}/share/man/man3
}

# dyld: Library not loaded: @rpath/libnotcurses++.3.dylib
configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF

test.run            yes
