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

github.setup        tsduck tsduck 3.22-1953 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball

categories          multimedia
license             BSD
maintainers         {mit.edu:quentin @quentinmit} \
                    openmaintainer
description         MPEG Transport Stream Toolkit
long_description    MPEG Transport Stream Toolkit

homepage            https://tsduck.io/

checksums           sha1    cedc70686415a9062bee8c3b1f43af8ea74f2127 \
                    rmd160  5a7c0b73ab1b6aa9d88b9d6ecde9befb00747f0f \
                    sha256  ca4e0af170616eb7ea25b3555a2519b94b8443b3135a4681993b5ae54316f5d9 \
                    size    13567538

depends_build-append port:gsed

depends_lib-append  port:curl

patchfiles          disable-silent-rules.patch

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

# PCSC requires pcsc-lite
# SRT requires libsrt
# Neither of these are currently available in macports
# Makefile.tsduck sets -install_name @rpath/$(notdir $@) and
# -rpath @executable_path, which are not compatible with the installed
# layout in $prefix.
set args            "NOPCSC=true NOSRT=true CFLAGS_EXTRA='-Wno-unknown-warning-option -Wno-unknown-pragmas' CXXFLAGS_EXTRA='-Wno-unknown-warning-option -Wno-unknown-pragmas' LDFLAGS_EXTRA=-Wl,-rpath,@executable_path/../lib"

build.target        default
build.args          NOTEST=true ${args}

destroot.target     install install-devel
destroot.args       NOTEST=true ${args} "SYSROOT=${destroot}" "SYSPREFIX=${prefix}"
post-destroot {
    file mkdir ${destroot}${prefix}/share/doc/${name}
    copy ${worksrcpath}/doc/tsduck.pdf ${destroot}${prefix}/share/doc/${name}/tsduck.pdf
}

test.run        yes
test.args       ${args} LDFLAGS_EXTRA=-Wl,-rpath,@executable_path
