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

# ssize_t
legacysupport.newest_darwin_requires_legacy 10

github.setup        szatmary libcaption 0.7
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            1

categories          multimedia
license             MIT
maintainers         @jasonliu-- openmaintainer

description         free, open-source CEA-608/-708 closed-caption \
                    encoder/decoder
long_description    ${name} is a library written in C to aid in the \
                    creating and parsing of closed caption data. To \
                    maintain consistency across platforms, ${name} \
                    aims to implement a subset of EIA-608, CEA-708 as \
                    supported by the Apple iOS platform.

checksums           rmd160  bf5971f889ec0430bc8330140d6b08c25a790b2f \
                    sha256  6b0f2d1172ea38facc24d0ca5608bdf1ec1839745c88a0acba93a48106d4f4c1 \
                    size    140039

# ld: duplicate symbol _caption_frame_timestamp in
# ../libcaption.a(srt.c.o) and CMakeFiles/scc2srt.dir/scc2srt.c.o
compiler.blacklist-append   *gcc-4.0 *gcc-4.2

configure.args-append       -DBUILD_EXAMPLES=OFF \
                            -DBUILD_SHARED_LIBS=ON

variant re2c description {Use re2c to generate eia608.c} {
    depends_build-append    port:re2c
    configure.args-append   -DENABLE_RE2C=ON
}

variant examples description {Build examples} {
    configure.args-replace  -DBUILD_EXAMPLES=OFF \
                            -DBUILD_EXAMPLES=ON
}

variant docs description {Build documentation} {
    depends_build-append    path:bin/doxygen:doxygen \
                            path:bin/dot:graphviz

    post-patch {
        reinplace {s/\(add_custom_target.doc\)/\1 ALL/} \
            ${worksrcpath}/CMakeLists.txt
    }
    post-destroot {
        set docdir ${prefix}/share/doc/${name}
        xinstall -d ${destroot}$docdir
        copy {*}[glob ${worksrcpath}/docs/*] ${destroot}$docdir/
    }
}

default_variants    +re2c +examples +docs
