# -*- 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.17 v
revision            0
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

github.tarball_from archive
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  ac4b6c920df0d0f57c4f7318ca7149985877cb0b \
                    sha256  b0fbe824984fe25b5a16770dbd00b85d44db5d09cc35bd881b95335d0db53128 \
                    size    10160707 \
                    ${name}-doc-${version}${extract.suffix} \
                    rmd160  2cfb0a0b779281adf73a399c027e292ef0e62a88 \
                    sha256  29d89996602aa69a96ea694a07cf0568886078c838c8e5d09e2e4517969808f8 \
                    size    190303

# 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-append   patch-ppc.diff

# requires clock_gettime()
legacysupport.newest_darwin_requires_legacy 15

compiler.c_standard 2017
compiler.cxx_standard \
                    2017

set ffmpeg_ver      7

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

depends_lib-append  port:ffmpeg${ffmpeg_ver} \
                    port:libdeflate \
                    port:libunistring \
                    port:ncurses

configure.pkg_config_path-prepend \
                    ${prefix}/libexec/ffmpeg${ffmpeg_ver}/lib/pkgconfig

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
