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

# Only for wrappers:
legacysupport.newest_darwin_requires_legacy 0

# The last non-rusty release.
# TODO: see if something is worth backporting from upstream.
name                newsboat
version             2.13
revision            2
categories          net www
license             MIT
maintainers         nomaintainer
description         Fork of Newsbeuter, an RSS/Atom feed reader for the text console
long_description    Newsboat is ${description}. The only difference is that \
                    Newsboat is actively maintained while Newsbeuter isn't.
homepage            https://newsboat.org
master_sites        ${homepage}/releases/${version}/

use_xz              yes

checksums           rmd160  3c6d62fef4221bc6aecb9685f1530ed074454f38 \
                    sha256  c73613b4f08c875bae2c4e7828e67291e7599e9cabed528089f8378f520b335e \
                    size 460076

depends_build       port:asciidoc \
                    port:docbook-xsl-nons \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig

depends_lib         port:curl \
                    port:gettext-runtime \
                    port:json-c \
                    port:libxml2 \
                    port:ncurses \
                    port:sqlite3 \
                    port:stfl

# newsboat(34100) malloc: *** error for object 0x100d1c3f8: Non-aligned pointer being freed
legacysupport.redirect_bins ${name}

compiler.cxx_standard   2011

post-extract {
    # Fix permissions
    fs-traverse f ${worksrcpath} {
        if {[file isdirectory ${f}]} {
            file attributes ${f} -permissions o+rx
        } else {
            file attributes ${f} -permissions o+r
        }
    }
}

patchfiles          patch-Makefile.diff \
                    patch-config.sh.diff

# https://github.com/newsboat/newsboat/commit/db70049f436a965767e8a1273389e1be92e946fa
patchfiles-append   db70049f436a965767e8a1273389e1be92e946fa.patch

configure.cmd       ./config.sh

# universal variant needs to be defined for [get_canonical_archflags] to work
variant universal   {}

build.args-append   prefix=${prefix} \
                    CXX=${configure.cxx}
build.target-append doc
build.env-append    CXXFLAGS=${configure.cxxflags} [get_canonical_archflags cxx] \
                    LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]
destroot.args-append \
                    prefix=${prefix} \
                    CXX=${configure.cxx}

post-destroot {
    xinstall -d ${destroot}${prefix}/share/${name}
    copy ${worksrcpath}/contrib ${destroot}${prefix}/share/${name}/contrib
}

livecheck.type      none
