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://0001-mplay-Fix-build-with-musl.patch \
17           file://lircd.service \
18           file://lircd.init \
19           file://lircexec.init \
20           file://lircd.conf \
21           file://lirc_options.conf \
22           file://lirc.tmpfiles \
23           file://0001-Makefile.am-do-not-clobber-PYTHONPATH-from-build-env.patch \
24           "
25SRC_URI[sha256sum] = "3d44ec8274881cf262f160805641f0827ffcc20ade0d85e7e6f3b90e0d3d222a"
26
27SYSTEMD_PACKAGES = "lirc lirc-exec"
28SYSTEMD_SERVICE:${PN} = "lircd.service lircmd.service lircd-setup.service lircd-uinput.service"
29SYSTEMD_SERVICE:${PN}-exec = "irexec.service"
30SYSTEMD_AUTO_ENABLE:lirc = "enable"
31SYSTEMD_AUTO_ENABLE:lirc-exec = "enable"
32
33inherit autotools pkgconfig systemd python3native setuptools3-base
34
35PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_unitdir}/system/,--without-systemdsystemunitdir,systemd"
36PACKAGECONFIG[x11] = "--with-x,--with-x=no,libx11,"
37
38PACKAGECONFIG ?= " \
39    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', ' systemd', '', d)} \
40    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', ' x11', '', d)} \
41"
42CACHED_CONFIGUREVARS = "HAVE_WORKING_POLL=yes"
43
44#EXTRA_OEMAKE = 'SUBDIRS="lib daemons tools"'
45
46# Ensure python-pkg/VERSION exists
47do_configure:append() {
48    cp ${S}/VERSION ${S}/python-pkg/
49}
50
51# Create PYTHON_TARBALL which LIRC needs for install-nodist_pkgdataDATA
52do_install:prepend() {
53    rm -rf ${WORKDIR}/${PN}-${PV}/python-pkg/dist/
54    mkdir ${WORKDIR}/${PN}-${PV}/python-pkg/dist/
55    tar --exclude='${WORKDIR}/${PN}-${PV}/python-pkg/*' -czf ${WORKDIR}/${PN}-${PV}/python-pkg/dist/${PN}-${PV}.tar.gz ${S}
56}
57
58# In code, path to python is a variable that is replaced with path to native version of it
59# during the configure stage, e.g ../recipe-sysroot-native/usr/bin/python3-native/python3.
60# Replace it with #!/usr/bin/env python3
61do_install:append() {
62    sed -i '1c#!/usr/bin/env python3' ${D}${bindir}/lirc-setup \
63                                      ${D}${PYTHON_SITEPACKAGES_DIR}/lirc-setup/lirc-setup \
64                                      ${D}${bindir}/irtext2udp \
65                                      ${D}${bindir}/lirc-init-db \
66                                      ${D}${bindir}/irdb-get \
67                                      ${D}${bindir}/pronto2lirc \
68                                      ${D}${sbindir}/lircd-setup
69
70    install -m 0755 -d ${D}${sysconfdir}
71    install -m 0755 -d ${D}${sysconfdir}/lirc
72    install -m 0644 ${WORKDIR}/lircd.conf ${D}${sysconfdir}/lirc/
73    install -m 0644 ${WORKDIR}/lirc_options.conf ${D}${sysconfdir}/lirc/
74    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
75        install -m 0755 -d ${D}${systemd_unitdir}/system ${D}${libdir}/tmpfiles.d
76        install -m 0644 ${WORKDIR}/lircd.service ${D}${systemd_unitdir}/system/
77        install -m 0755 ${WORKDIR}/lircexec.init ${D}${systemd_unitdir}/system/
78        install -m 0644 ${WORKDIR}/lirc.tmpfiles ${D}${libdir}/tmpfiles.d/lirc.conf
79    else
80        rm -rf ${D}/lib
81    fi
82    rm -rf ${D}${libdir}/lirc/plugins/*.la
83    rmdir ${D}/var/run/lirc ${D}/var/run
84    chown -R root:root ${D}${datadir}/lirc/contrib
85}
86
87PACKAGES =+ "${PN}-contrib ${PN}-exec ${PN}-plugins ${PN}-python"
88
89RDEPENDS:${PN} = "bash python3"
90RDEPENDS:${PN}-exec = "${PN}"
91RDEPENDS:${PN}-python = "python3-shell python3-pyyaml python3-datetime python3-netclient python3-stringold"
92
93RRECOMMENDS:${PN} = "${PN}-exec ${PN}-plugins"
94
95FILES:${PN}-plugins = "${libdir}/lirc/plugins/*.so ${datadir}/lirc/configs"
96FILES:${PN}-contrib = "${datadir}/lirc/contrib"
97FILES:${PN}-exec = "${bindir}/irexec ${sysconfdir}/lircexec ${systemd_unitdir}/system/irexec.service"
98FILES:${PN} += "${systemd_unitdir}/system/lircexec.init"
99FILES:${PN} += "${systemd_unitdir}/system/lircd.service"
100FILES:${PN} += "${systemd_unitdir}/system/lircd.socket"
101FILES:${PN} += "${libdir}/tmpfiles.d/lirc.conf"
102FILES:${PN}-dbg += "${libdir}/lirc/plugins/.debug"
103FILES:${PN}-python += "${bindir}/irdb-get ${bindir}/irtext2udp ${bindir}/lircd-setup ${bindir}/pronto2lirc ${libdir}/python*/site-packages"
104
105INITSCRIPT_PACKAGES = "lirc lirc-exec"
106INITSCRIPT_NAME:lirc-exec = "lircexec"
107INITSCRIPT_PARAMS:lirc-exec = "defaults 21"
108
109# this is for distributions that don't use udev
110pkg_postinst:${PN}:append() {
111    if [ ! -c $D/dev/lirc -a ! -f /sbin/udevd ]; then mknod $D/dev/lirc c 61 0; fi
112}
113
114SECURITY_CFLAGS = "${SECURITY_NO_PIE_CFLAGS}"
115