# $Id: Portfile 91621 2012-04-07 01:41:00Z ryandesign@macports.org $

PortSystem 1.0

name            lirc
version         0.8.3
revision        2
categories      sysutils net
license         GPL-2+
maintainers     ecronin openmaintainer
platforms       darwin
description     Linux Infrared Remote Control
long_description \
    LIRC is a package that allows you to decode and send infra-red \
    signals of many (but not all) commonly used remote controls.

homepage        http://www.lirc.org
master_sites    sourceforge
use_bzip2       yes
checksums       md5 8e78eeded7b31e5ad02e328970437c0f \
                sha1 4b5aec19fa9ee15bafaeb1f87c154a0d4e045dcc \
                rmd160 8948efc3e9dc34426ea32a3c63da63c0efa7dce2
livecheck.distname  LIRC

configure.args  --with-driver=udp --with-devdir=${prefix}/var/run \
                --sysconfdir=${prefix}/etc --localstatedir=${prefix}/var \
                --mandir=${prefix}/share/man

variant iguanaIR \
    description {Use IguanaIR USB device} {
    configure.args-delete   --with-driver=udp
    configure.args-append   --with-driver=iguanaIR
    depends_lib-append  port:iguanaIR
    patchfiles-append \
        patch-daemons-hw_iguanaIR.c.diff \
        patch-drivers-lirc.h.diff
}

post-destroot {
    xinstall -m 644 ${worksrcpath}/contrib/lircd.conf \
        ${destroot}${prefix}/etc/lircd.conf.sample
    xinstall -m 644 ${worksrcpath}/contrib/lircmd.conf \
        ${destroot}${prefix}/etc/lircmd.conf.sample
    xinstall -m 644 ${worksrcpath}/contrib/lircrc \
        ${destroot}${prefix}/etc/lircrc.sample
    xinstall -m 755 -d ${destroot}${prefix}/var/log
    destroot.keepdirs ${destroot}${prefix}/var/log
}

startupitem.create  yes
startupitem.start   \
    "#device=\"--connect=example.org:port\"  # remote lircd" \
    "#device=\"--driver=udp --device=port\"  # UDP listener" \
    "#device=\"--driver=iguanaIR --device=/tmp/iguanaIR/0 --nodaemon\"  # iguanaIR" \
    "${prefix}/sbin/lircd --permission=0666 \$\{device\}" \
    "\[ -r ${prefix}/etc/lircmd.conf \] && \\" \
    "\t${prefix}/sbin/lircmd"
startupitem.stop    \
    "killall -TERM lircd" \
    "killall -TERM lircmd"

notes "
After installing you must configure an IR device for lirc to use. Most\
hardware devices are not supported on Mac OS X (known exceptions: IguanaIR)\;\
network sources (remote lircd, HD Homerun, etc) are fully supported.

Please edit ${prefix}/etc/LaunchDaemons/org.macports.${name}/${name}.wrapper\
and specify a valid driver or remote lircd to connect to. Examples for\
network, UDP, and IguanaIR are commented out.

Any clients of lirc must be able to read and write the pipe at\
${prefix}/var/run/lircd
"
