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

github.setup        tldr-pages tldr-cpp-client 1.6.1 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0

categories          sysutils
license             MIT
maintainers         {khindenburg @kurthindenburg} openmaintainer

description         tldr c client - simplified and community-driven man pages
long_description    The TLDR pages are a community effort to simplify \
                    the beloved man pages with practical examples.

homepage            https://tldr.sh

checksums           rmd160  95e5f16ca2822734f154d02e1cd17d0a5911f12b \
                    sha256  961217d163d5b93cef1f3c5090e2dfe039c7857aa5c9d905768063827a2ce8d2 \
                    size    25279

patchfiles          patch-Makefile.diff

# /opt/local/include/zip.h: error: wrong number of arguments specified for ‘deprecated’ attribute
compiler.blacklist-append \
                    *gcc-4.0 *gcc-4.2

use_configure       no

variant universal   {}

depends_build-append \
                    path:bin/pkg-config:pkgconfig
depends_lib-append \
                    port:curl \
                    port:libzip

build.env-append    CC=${configure.cc} \
                    LD=${configure.cc} \
                    "CFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                    "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"

destroot.args       PREFIX=${destroot}${prefix}

post-destroot {
    set docdir ${prefix}/share/${subport}
    set compldir ${prefix}/share/${subport}/autocomplete
    xinstall -d ${destroot}${docdir}
    xinstall -d ${destroot}${compldir}
    xinstall -m 644 -W ${worksrcpath} \
        LICENSE \
        README.md \
        ${destroot}${docdir}
    xinstall -m 644 {*}[glob ${worksrcpath}/autocomplete/*] \
        ${destroot}${compldir}
}

notes "
To install the autocompletion, source the complete script from the shell's rc:
echo \"source ${prefix}/share/${name}/autocomplete/complete.bash\" >> ~/.bashrc
echo \"source ${prefix}/share/${name}/autocomplete/complete.zsh\" >> ~/.zshrc
"
