1DESCRIPTION = "LIRC is a package that allows you to decode and send infra-red signals of many commonly used remote controls."
2DESCRIPTION:append:lirc = " This package contains the lirc daemon, libraries and tools."
3DESCRIPTION:append:lirc-exec = " This package contains a daemon that runs programs on IR signals."
4DESCRIPTION:append:lirc-remotes = " This package contains some config files for remotes."
5DESCRIPTION:append:lirc-nslu2example = " This package contains a working config for RC5 remotes and a modified NSLU2."
6HOMEPAGE = "http://www.lirc.org"
7SECTION = "console/network"
8LICENSE = "GPL-2.0-only"
9DEPENDS = "libxslt-native alsa-lib libftdi libusb1 libusb-compat jack portaudio-v19 python3-pyyaml python3-setuptools-native"
10
11LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
12
13SRC_URI = "http://prdownloads.sourceforge.net/lirc/lirc-${PV}.tar.bz2 \
14    file://0001-Fix-build-on-32bit-arches-with-64bit-time_t.patch \
15    file://fix_build_errors.patch \
16    file://lircd.service \
17    file://lircd.init \
18    file://lircexec.init \
19    file://lircd.conf \
20    file://lirc_options.conf \
21    file://lirc.tmpfiles \
22"
23SRC_URI[md5sum] = "86c3f8e4efaba10571addb8313d1e040"
24SRC_URI[sha256sum] = "8b753c60df2a7f5dcda2db72c38e448ca300c3b4f6000c1501fcb0bd5df414f2"
25
26SYSTEMD_PACKAGES = "lirc lirc-exec"
27SYSTEMD_SERVICE:${PN} = "lircd.service lircmd.service lircd-setup.service lircd-uinput.service"
28SYSTEMD_SERVICE:${PN}-exec = "irexec.service"
29SYSTEMD_AUTO_ENABLE:lirc = "enable"
30SYSTEMD_AUTO_ENABLE:lirc-exec = "enable"
31
32inherit autotools pkgconfig systemd python3native setuptools3-base
33
34PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_unitdir}/system/,--without-systemdsystemunitdir,systemd"
35PACKAGECONFIG[x11] = "--with-x,--with-x=no,libx11,"
36
37PACKAGECONFIG ?= " \
38    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', ' systemd', '', d)} \
39    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', ' x11', '', d)} \
40"
41CACHED_CONFIGUREVARS = "HAVE_WORKING_POLL=yes"
42
43#EXTRA_OEMAKE = 'SUBDIRS="lib daemons tools"'
44
45# Ensure python-pkg/VERSION exists
46do_configure:append() {
47    cp ${S}/VERSION ${S}/python-pkg/
48}
49
50# Create PYTHON_TARBALL which LIRC needs for install-nodist_pkgdataDATA
51do_install:prepend() {
52    rm -rf ${WORKDIR}/${PN}-${PV}/python-pkg/dist/
53    mkdir ${WORKDIR}/${PN}-${PV}/python-pkg/dist/
54    tar --exclude='${WORKDIR}/${PN}-${PV}/python-pkg/*' -czf ${WORKDIR}/${PN}-${PV}/python-pkg/dist/${PN}-${PV}.tar.gz ${S}
55}
56
57# In code, path to python is a variable that is replaced with path to native version of it
58# during the configure stage, e.g ../recipe-sysroot-native/usr/bin/python3-native/python3.
59# Replace it with #!/usr/bin/env python3
60do_install:append() {
61    sed -i '1c#!/usr/bin/env python3' ${D}${bindir}/lirc-setup \
62                                      ${D}${PYTHON_SITEPACKAGES_DIR}/lirc-setup/lirc-setup \
63                                      ${D}${bindir}/irtext2udp \
64                                      ${D}${bindir}/lirc-init-db \
65                                      ${D}${bindir}/irdb-get \
66                                      ${D}${bindir}/pronto2lirc \
67                                      ${D}${sbindir}/lircd-setup
68
69    install -m 0755 -d ${D}${sysconfdir}
70    install -m 0755 -d ${D}${sysconfdir}/lirc
71    install -m 0644 ${WORKDIR}/lircd.conf ${D}${sysconfdir}/lirc/
72    install -m 0644 ${WORKDIR}/lirc_options.conf ${D}${sysconfdir}/lirc/
73    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
74        install -m 0755 -d ${D}${systemd_unitdir}/system ${D}${libdir}/tmpfiles.d
75        install -m 0644 ${WORKDIR}/lircd.service ${D}${systemd_unitdir}/system/
76        install -m 0755 ${WORKDIR}/lircexec.init ${D}${systemd_unitdir}/system/
77        install -m 0644 ${WORKDIR}/lirc.tmpfiles ${D}${libdir}/tmpfiles.d/lirc.conf
78    else
79        rm -rf ${D}/lib
80    fi
81    rm -rf ${D}${libdir}/lirc/plugins/*.la
82    rmdir ${D}/var/run/lirc ${D}/var/run
83    chown -R root:root ${D}${datadir}/lirc/contrib
84}
85
86PACKAGES =+ "${PN}-contrib ${PN}-exec ${PN}-plugins ${PN}-python"
87
88RDEPENDS:${PN} = "bash python3"
89RDEPENDS:${PN}-exec = "${PN}"
90RDEPENDS:${PN}-python = "python3-shell python3-pyyaml python3-datetime python3-netclient python3-stringold"
91
92RRECOMMENDS:${PN} = "${PN}-exec ${PN}-plugins"
93
94FILES:${PN}-plugins = "${libdir}/lirc/plugins/*.so ${datadir}/lirc/configs"
95FILES:${PN}-contrib = "${datadir}/lirc/contrib"
96FILES:${PN}-exec = "${bindir}/irexec ${sysconfdir}/lircexec ${systemd_unitdir}/system/irexec.service"
97FILES:${PN} += "${systemd_unitdir}/system/lircexec.init"
98FILES:${PN} += "${systemd_unitdir}/system/lircd.service"
99FILES:${PN} += "${systemd_unitdir}/system/lircd.socket"
100FILES:${PN} += "${libdir}/tmpfiles.d/lirc.conf"
101FILES:${PN}-dbg += "${libdir}/lirc/plugins/.debug"
102FILES:${PN}-python += "${bindir}/irdb-get ${bindir}/irtext2udp ${bindir}/lircd-setup ${bindir}/pronto2lirc ${libdir}/python*/site-packages"
103
104INITSCRIPT_PACKAGES = "lirc lirc-exec"
105INITSCRIPT_NAME:lirc-exec = "lircexec"
106INITSCRIPT_PARAMS:lirc-exec = "defaults 21"
107
108# this is for distributions that don't use udev
109pkg_postinst:${PN}:append() {
110    if [ ! -c $D/dev/lirc -a ! -f /sbin/udevd ]; then mknod $D/dev/lirc c 61 0; fi
111}
112
113SECURITY_CFLAGS = "${SECURITY_NO_PIE_CFLAGS}"
114