1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils linux-mod linux-info systemd toolchain-funcs flag-o-matic autotools
8 DESCRIPTION="decode and send infra-red signals of many commonly used remote controls"
9 HOMEPAGE="http://www.lirc.org/"
13 if [[ "${PV/_pre/}" = "${PV}" ]]; then
14 SRC_URI="mirror://sourceforge/lirc/${MY_P}.tar.bz2"
16 SRC_URI="http://www.lirc.org/software/snapshots/${MY_P}.tar.bz2"
21 KEYWORDS="amd64 ppc ppc64 x86"
22 IUSE="debug doc hardware-carrier transmitter static-libs X"
24 S="${WORKDIR}/${MY_P}"
32 lirc_devices_alsa_usb? ( media-libs/alsa-lib )
33 lirc_devices_audio? ( >media-libs/portaudio-18 )
34 lirc_devices_irman? ( media-libs/libirman )"
36 # 2012-07-17, Ian Stakenvicius
37 # A helper script that scrapes out values for nearly all of the variables below
38 # from lirc's configure.ac is available at
39 # https://dev.gentoo.org/~axs/helper-for-lirc-iuse.sh
41 # This are drivers with names matching the
42 # parameter --with-driver=NAME
43 IUSE_LIRC_DEVICES_DIRECT="
44 all userspace accent act200l act220l
45 adaptec alsa_usb animax asusdh atilibusb
46 atiusb audio audio_alsa avermedia avermedia_vdomate
47 avermedia98 awlibusb bestbuy bestbuy2 breakoutbox
48 bte bw6130 caraca chronos commandir
49 cph06x creative creative_infracd
50 devinput digimatrix dsp dvico ea65 ene0100
51 exaudio flyvideo ftdi gvbctv5pci hauppauge
52 hauppauge_dvb hercules_smarttv_stereo i2cuser
53 igorplugusb iguanaIR imon imon_24g imon_knob
54 imon_lcd imon_pad imon_rsc irdeo irdeo_remote
55 irlink irman irreal it87 ite8709
56 knc_one kworld leadtek_0007 leadtek_0010
57 leadtek_pvr2000 livedrive_midi
58 livedrive_seq logitech macmini
59 mediafocusI mouseremote
60 mouseremote_ps2 mp3anywhere mplay nslu2
61 packard_bell parallel pcmak pcmak_usb
62 pctv pixelview_bt878 pixelview_pak
63 pixelview_pro provideo realmagic
64 remotemaster sa1100 samsung sasem sb0540 serial
65 silitek sir slinke streamzap tekram
66 tekram_bt829 tira ttusbir tuxbox tvbox udp uirt2
67 uirt2_raw usb_uirt_raw usbx wpc8769l zotac"
69 # drivers that need special handling and
70 # must have another name specified for
71 # parameter --with-driver=NAME
72 IUSE_LIRC_DEVICES_SPECIAL="
74 remote_wonder_plus xboxusb inputlirc"
76 IUSE_LIRC_DEVICES="${IUSE_LIRC_DEVICES_DIRECT} ${IUSE_LIRC_DEVICES_SPECIAL}"
78 # The following are lists which are used to provide ewarns on incompatibilities
81 #drivers that do not build kernel modules
82 NO_KMOD_BUILT_FOR_DEV="
83 accent bte creative creative_infracd devinput dsp ea65 exaudio
84 ftdi i2cuser irlink irreal livedrive_midi livedrive_seq logitech
85 mediafocusI mouseremote mouseremote_ps2 mp3anywhere mplay mplay2
86 pcmak pcmak_usb pctv realmagic remotemaster silitek tira tira_raw
87 tuxbox udp uirt2 uirt2_raw usb_uirt_raw usbx"
89 #drivers that build lirc_dev and so will conflict with kernel lirc_dev
90 LIRCDEV_BUILT_FOR_DEV="all
91 act200l act220l adaptec animax atiusb breakoutbox hauppauge
92 hauppauge_dvb hercules_smarttv_stereo igorplugusb imon imon_24g
93 imon_knob imon_lcd imon_pad imon_rsc irdeo irdeo_remote knc_one
94 leadtek_pvr2000 nslu2 packard_bell parallel pixelview_bt878
95 provideo sa1100 sasem serial sir tekram tekram_bt829 ttusbir
98 #lirc_gpio drivers, which cannot be supported on kernel >= 2.6.22
100 avermedia avermedia98 avermedia_vdomate bestbuy bestbuy2 chronos
101 cph03x cph06x flyvideo gvbctv5pci kworld leadtek_0007 leadtek_0010
102 pixelview_pak pixelview_pro"
104 #device-driver which use libusb
106 all atilibusb awlibusb sasem igorplugusb imon imon_lcd imon_pad
107 imon_rsc streamzap xboxusb irlink commandir"
109 for dev in ${LIBUSB_USED_BY_DEV}; do
110 DEPEND="${DEPEND} lirc_devices_${dev}? ( virtual/libusb:0 )"
113 # adding only compile-time depends
114 DEPEND="${RDEPEND} ${DEPEND}
115 virtual/linux-sources
116 lirc_devices_ftdi? ( dev-embedded/libftdi:0 )
117 lirc_devices_all? ( dev-embedded/libftdi:0 )"
119 # adding only run-time depends
121 lirc_devices_inputlirc? ( app-misc/inputlircd )
122 lirc_devices_iguanaIR? ( app-misc/iguanaIR )"
124 # add all devices to IUSE
125 # and ensure lirc_devices_all is not set alongside lirc_devices_*
126 REQUIRED_USE="lirc_devices_all? ("
127 for dev in ${IUSE_LIRC_DEVICES}; do
128 IUSE="${IUSE} lirc_devices_${dev}"
129 if [[ "${dev}" != "all" ]]; then
130 REQUIRED_USE="${REQUIRED_USE} !lirc_devices_${dev}"
133 REQUIRED_USE="${REQUIRED_USE} )"
137 local desc="device ${dev}"
138 if [[ -n "${2}" ]]; then
143 if kernel_is ge 2 6 22 && [[ " ${LIRC_GPIO_DEV} " == *" ${dev} "* ]]; then
144 eerror "${desc} uses lirc_gpio which fails with kernel 2.6.22 or above. Not building."
145 eerror "Use 'devinput' instead, or use 'userspace' along with in-kernel drivers"
148 : ${lirc_device_count:=0}
149 ((lirc_device_count++))
151 elog "Compiling support for ${desc}"
153 if [[ " ${LIRCDEV_BUILT_FOR_DEV} " == *" ${dev} "* ]] ; then
154 if linux_chkconfig_present LIRC ; then
155 ewarn "${desc} builds lirc_dev and CONFIG_LIRC is set in the kernel -- this may conflict."
157 if ! linux_chkconfig_present MODULE_UNLOAD ; then
158 ewarn "${desc} builds modules and CONFIG_MODULE_UNLOAD is unset in kernel."
159 ewarn "You will need MODULE_UNLOAD support in your kernel."
162 if [[ " ${NO_KMOD_BUILT_FOR_DEV} " == *" ${dev} "* ]] && ! linux_chkconfig_present IR_LIRC_CODEC ; then
163 ewarn "${desc} builds no kernel module and CONFIG_IR_LIRC_CODEC is unset in kernel."
166 if [[ ${lirc_device_count} -eq 2 ]] ; then
168 ewarn "LIRC_DEVICES has more than one entry."
169 ewarn "When selecting multiple devices for lirc to be supported,"
170 ewarn "it can not be guaranteed that the drivers play nice together."
171 ewarn "If this is not intended, then please adjust LIRC_DEVICES"
172 ewarn "and re-emerge."
176 MY_OPTS="${MY_OPTS} --with-driver=${dev}"
180 if [[ -n "${LIRC_OPTS}" ]] ; then
182 ewarn "LIRC_OPTS is deprecated from lirc-0.8.0-r1 on."
184 ewarn "Please use LIRC_DEVICES from now on."
185 ewarn "e.g. LIRC_DEVICES=\"serial sir\""
187 ewarn "Flags are now set per use-flags."
188 ewarn "e.g. transmitter, hardware-carrier"
191 local unsupported_opts=""
193 # test for allowed options for LIRC_OPTS
194 for opt in ${LIRC_OPTS}; do
196 --with-port=*|--with-irq=*|--with-timer=*|--with-tty=*)
197 MY_OPTS="${MY_OPTS} ${opt}"
200 unsupported_opts="${unsupported_opts} ${opt}"
204 if [[ -n ${unsupported_opts} ]]; then
205 eerror "These options are no longer allowed to be set"
206 eerror "with LIRC_OPTS: ${unsupported_opts}"
207 die "LIRC_OPTS is no longer supported, use LIRC_DEVICES."
215 # set default configure options
217 LIRC_DRIVER_DEVICE="/dev/lirc0"
219 if use lirc_devices_all; then
220 # compile in drivers for a lot of devices
221 add_device all "a lot of devices"
223 # compile in only requested drivers
225 for dev in ${IUSE_LIRC_DEVICES_DIRECT}; do
226 if use lirc_devices_${dev}; then
231 if use lirc_devices_remote_wonder_plus; then
232 add_device atiusb "device Remote Wonder Plus (atiusb-based)"
235 if use lirc_devices_serial_igor_cesko; then
236 add_device serial "serial with Igor Cesko design"
237 MY_OPTS="${MY_OPTS} --with-igor"
240 if use lirc_devices_imon_pad; then
241 ewarn "The imon_pad driver has incorporated the previous pad2keys patch"
242 ewarn "and removed the pad2keys_active option for the lirc_imon module"
243 ewarn "because it is always active."
244 ewarn "If you have an older imon VFD device, you may need to add the module"
245 ewarn "option display_type=1 to override autodetection and force VFD mode."
248 if use lirc_devices_xboxusb; then
249 add_device atiusb "device xboxusb"
252 if [[ "${MY_OPTS}" == "" ]]; then
253 if [[ "${PROFILE_ARCH}" == "xbox" ]]; then
254 # on xbox: use special driver
255 add_device atiusb "device xboxusb"
257 # no driver requested
259 elog "Compiling only the lirc-applications, but no drivers."
260 elog "Enable drivers with LIRC_DEVICES if you need them."
261 MY_OPTS="--with-driver=none"
266 use hardware-carrier && MY_OPTS="${MY_OPTS} --without-soft-carrier"
267 use transmitter && MY_OPTS="${MY_OPTS} --with-transmitter"
270 einfo "lirc-configure-opts: ${MY_OPTS}"
271 elog "Setting default lirc-device to ${LIRC_DRIVER_DEVICE}"
278 edos2unix contrib/lirc.rules
280 # Apply patches needed for some special device-types
281 use lirc_devices_audio || epatch "${FILESDIR}"/lirc-0.8.4-portaudio_check.patch
282 use lirc_devices_remote_wonder_plus && epatch "${FILESDIR}"/lirc-0.8.3_pre1-remotewonderplus.patch
284 # Apply fixes for kernel-2.6.39 and above
285 epatch "${FILESDIR}"/${P}-kernel-2.6.39-fixes.patch
286 # Slightly massaged upstream patch to fix kfifo issues >=2.6.38
288 epatch "${FILESDIR}"/${P}-atiusb_kfifo.patch
289 # Apply fixes for kernel-3.3 and above (bug 439538)
290 epatch "${FILESDIR}"/${P}-kernel-3.3.0-fixes.patch
291 # Apply fix for missing err() in usb.h for kernel 3.5+ (bug 444736)
292 epatch "${FILESDIR}"/${P}-kernel-3.5-err-fix.patch
293 # Apply fix for missing __devinit __devexit defines in kernel 3.8+ (bug 461532)
294 epatch "${FILESDIR}"/${P}-kernel-3.8-fixes.patch
295 # Add support for zotac remote, bug 342848
296 epatch "${FILESDIR}"/${P}-add-zotac-support.patch
298 epatch "${FILESDIR}"/${P}-fixed-font.patch
300 # Do not build drivers from the top-level Makefile
301 sed -i -e 's:\(SUBDIRS =\) drivers\(.*\):\1\2:' Makefile.am
303 # remove parallel driver on SMP systems
304 if linux_chkconfig_present SMP ; then
305 sed -i -e "s:lirc_parallel\.o::" drivers/lirc_parallel/Makefile.am
308 # Bug #187418 - only need this part for lirc_devices_all as others die in pkg_setup
309 if use lirc_devices_all && kernel_is ge 2 6 22 ; then
310 ewarn "Disabling lirc_gpio driver as it does no longer work Kernel 2.6.22+"
311 sed -i -e "s:lirc_gpio\.o::" drivers/lirc_gpio/Makefile.am
315 sed -i -e 's:CFLAGS="-O2:CFLAGS=""\n#CFLAGS="-O2:' configure.ac
317 # setting default device-node
319 for f in configure.ac acconfig.h; do
320 [[ -f "$f" ]] && sed -i -e '/#define LIRC_DRIVER_DEVICE/d' "$f"
322 echo "#define LIRC_DRIVER_DEVICE \"${LIRC_DRIVER_DEVICE}\"" >> acconfig.h
324 sed -e "s/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/" -i configure.ac || die # automake 1.13
330 --localstatedir=/var \
331 --with-syslog=LOG_DAEMON \
333 --with-kerneldir="${KV_DIR}" \
334 --with-moduledir="/lib/modules/${KV_FULL}/misc" \
335 $(use_enable debug) \
336 $(use_enable static-libs static) \
339 ABI="${KERNEL_ABI}" \
340 ARCH="$(tc-arch-kernel)"
344 # force non-parallel make, Bug 196134 (confirmed valid for 0.9.0-r2)
347 MODULE_NAMES="lirc(misc:${S}/drivers)"
349 linux-mod_src_compile
353 emake DESTDIR="${D}" install
354 emake -C drivers DESTDIR="${D}" install
356 newinitd "${FILESDIR}"/lircd-0.8.6-r2 lircd
357 newinitd "${FILESDIR}"/lircmd lircmd
358 newconfd "${FILESDIR}"/lircd.conf.4 lircd
360 insinto /etc/modprobe.d/
361 newins "${FILESDIR}"/modprobed.lirc lirc.conf
363 newinitd "${FILESDIR}"/irexec-initd-0.8.6-r2 irexec
364 newconfd "${FILESDIR}"/irexec-confd irexec
366 systemd_dounit "${FILESDIR}"/irexec.service
367 systemd_dounit "${FILESDIR}"/lirc.service
368 systemd_dounit "${FILESDIR}"/lircm.service
371 dohtml doc/html/*.html
372 insinto /usr/share/doc/${PF}/images
376 insinto /usr/share/lirc/remotes
380 if [[ -e "${D}"/etc/lirc/lircd.conf ]]; then
381 newdoc "${D}"/etc/lirc/lircd.conf lircd.conf.example
384 use static-libs || rm "${D}/usr/$(get_libdir)/liblirc_client.la"
388 linux-mod_pkg_preinst
390 local dir="${EROOT}/etc/modprobe.d"
391 if [[ -a "${dir}"/lirc && ! -a "${dir}"/lirc.conf ]]; then
392 elog "Renaming ${dir}/lirc to lirc.conf"
393 mv -f "${dir}/lirc" "${dir}/lirc.conf"
396 # copy the first file that can be found
397 if [[ -f "${EROOT}"/etc/lirc/lircd.conf ]]; then
398 cp "${EROOT}"/etc/lirc/lircd.conf "${T}"/lircd.conf
399 elif [[ -f "${EROOT}"/etc/lircd.conf ]]; then
400 cp "${EROOT}"/etc/lircd.conf "${T}"/lircd.conf
401 MOVE_OLD_LIRCD_CONF=1
402 elif [[ -f "${D}"/etc/lirc/lircd.conf ]]; then
403 cp "${D}"/etc/lirc/lircd.conf "${T}"/lircd.conf
406 # stop portage from touching the config file
407 if [[ -e "${D}"/etc/lirc/lircd.conf ]]; then
408 rm -f "${D}"/etc/lirc/lircd.conf
413 linux-mod_pkg_postinst
415 # copy config file to new location
416 # without portage knowing about it
417 # so it will not delete it on unmerge or ever touch it again
418 if [[ -e "${T}"/lircd.conf ]]; then
419 cp "${T}"/lircd.conf "${EROOT}"/etc/lirc/lircd.conf
420 if [[ "$MOVE_OLD_LIRCD_CONF" = "1" ]]; then
421 elog "Moved /etc/lircd.conf to /etc/lirc/lircd.conf"
422 rm -f "${EROOT}"/etc/lircd.conf
426 einfo "The new default location for lircd.conf is inside of"
427 einfo "/etc/lirc/ directory"