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