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

github.setup        Pulse-Eight libcec 7.1.1 libcec-
github.tarball_from archive
revision            0
checksums           rmd160  8c20170c3b1ccc81b26e2be418f5c7f91a12f915 \
                    sha256  7f7da95a4c1e7160d42ca37a3ac80cf6f389b317e14816949e0fa5e2edf4cc64 \
                    size    365046

categories          multimedia
license             {GPL-2+ OpenSSLException}
maintainers         nomaintainer
description         USB CEC Adapter communication Library
long_description    libCEC, in combination with the right hardware, permits control of \
                    other devices with the TV remote control via existing HDMI cabling
homepage            https://libcec.pulse-eight.com

compiler.cxx_standard  2011

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

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]
set python_prefix   ${frameworks_dir}/Python.framework/Versions/${py_ver}
set python_pkgd     ${python_prefix}/lib/python${py_ver}/site-packages

depends_lib         port:ncurses \
                    port:p8-platform \
                    port:python314 \
                    port:xorg-libX11 \
                    port:xorg-libXrandr

configure.args-append   -DPYTHON_USE_VERSION=3

if {[string match *gcc* ${configure.compiler}]} {
    # USB.h: error: too many '#pragma options align=reset'
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50909
    PortGroup       legacysupport 1.1

}

post-destroot {
    # install the Python files to the correct location
    xinstall -d ${destroot}${python_pkgd}
    move {*}[glob ${destroot}${prefix}/lib/python${py_ver}/site-packages/*] \
        ${destroot}${python_pkgd}

    reinplace "s|/usr/bin/python3|${prefix}/bin/python${py_ver}|g" \
        ${destroot}${prefix}/bin/pyCecClient

    reinplace "s|from cec import cec|import cec|g" \
        ${destroot}${prefix}/bin/pyCecClient

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}

    xinstall -m 0644 -W ${worksrcpath} \
        AUTHORS \
        debian/changelog.in \
        README.md \
        LICENSE.md \
        ${destroot}${docdir}
}
