app-laptop/pbbuttonsd: Fix patch names.
[gentoo.git] / app-laptop / pbbuttonsd / pbbuttonsd-0.8.1-r3.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 inherit autotools flag-o-matic eutils
5
6 DESCRIPTION="Handles power management and special keys on laptops"
7 HOMEPAGE="http://pbbuttons.berlios.de"
8 SRC_URI="mirror://sourceforge/pbbuttons/${P}.tar.gz"
9
10 LICENSE="GPL-2"
11 SLOT="0"
12 KEYWORDS="~amd64 ppc ~x86"
13 IUSE="acpi alsa debug doc ibam macbook oss"
14
15 DEPEND="macbook? (
16                         sys-libs/libsmbios
17                         sys-apps/pciutils
18                 )
19                 >=dev-libs/glib-2.6
20                 doc? ( app-doc/doxygen )"
21 RDEPEND="alsa? ( >=media-libs/alsa-lib-1.0 )
22                  >=dev-libs/glib-2.6"
23
24 src_unpack() {
25         unpack ${A}
26         cd "${S}"
27
28         epatch "${FILESDIR}/${PN}-0.8.1-pmcs.patch"
29         ### Don't link with g++ if we don't use ibam
30         if ! use ibam; then
31                 epatch "${FILESDIR}/${PN}-0.8.1-g++.patch"
32         fi
33         ### Fix macbook -lz issue
34         epatch "${FILESDIR}/${PN}-0.8.1-lz.patch"
35         epatch "${FILESDIR}/${PN}-0.8.1-lm.patch"
36         ### Fix new apple hid fnmode issue
37         epatch "${FILESDIR}/${PN}-0.8.1-fnmode.patch"
38         eautoconf
39 }
40
41 src_compile() {
42         # Fix crash bug on some systems
43         replace-flags -O? -O1
44
45         if use macbook; then
46                 laptop=macbook
47         elif use x86 || use amd64; then
48                 if use acpi; then
49                         laptop=acpi
50                 else
51                         laptop=i386
52                 fi
53         # Default to PowerBook
54         else
55                 laptop=powerbook
56         fi
57
58         econf laptop=$laptop \
59                 $(use_enable debug) \
60                 $(use_with doc doxygen_docs) \
61                 $(use_with alsa) \
62                 $(use_with oss) \
63                 $(use_with ibam) \
64                 || die "Sorry, failed to configure pbbuttonsd"
65
66         # Thanks to Stefan Bruda for this workaround
67         # Using -j1 fixes a parallel build issue with the docs
68         if use doc; then
69                 emake -j1 || die "Sorry, failed to compile pbbuttonsd"
70         else
71                 emake || die "Sorry, failed to compile pbbuttonsd"
72         fi
73 }
74
75 src_install() {
76         dodir /etc/power
77         use ibam && dodir /var/lib/ibam
78         make DESTDIR="${D}" install || die "failed to install"
79         newinitd "${FILESDIR}/pbbuttonsd.rc6" pbbuttonsd
80         dodoc README
81         use doc && dohtml -r doc/*
82
83         dodir /etc/power/resume.d
84         dodir /etc/power/suspend.d
85         dodir /etc/power/scripts.d
86         exeinto "/etc/power/scripts.d"
87         doexe "${FILESDIR}/wireless"
88         ln -s "${D}/etc/power/scripts.d/wireless" "${D}/etc/power/resume.d/wireless"
89 }
90
91 pkg_postinst() {
92         if [ -e /etc/pbbuttonsd.conf ]; then
93                 ewarn "The pbbuttonsd.cnf file replaces /etc/pbuttonsd.conf with a new"
94                 ewarn "file (/etc/pbbuttonsd.conf) and a new format.  Please check the"
95                 ewarn "manual page with 'man pbbuttonsd.cnf' for details."
96                 ewarn
97         fi
98
99         if use macbook; then
100                 ewarn "Macbook and Macbook Pro users should make sure to have applesmc"
101                 ewarn "loaded before starting pbbuttonsdm otherwise auto-adjustments"
102                 ewarn "will not work and pbbuttonsd may segfault."
103         fi
104
105         ewarn "Ensure that the evdev kernel module is loaded otherwise"
106         ewarn "pbbuttonsd won't work.  SysV IPC is also required."
107         ewarn
108         ewarn "If you need extra security, you can tell pbbuttonsd to only accept"
109         ewarn "input from one user.  You can set the userallowed option in"
110         ewarn "/etc/pbbuttonsd.cnf to limit access."
111         ewarn
112
113         if use ibam; then
114                 elog "To properly initialize the IBaM battery database, you will"
115                 elog "need to perform a full discharge/charge cycle.  For more"
116                 elog "details, please see the pbbuttonsd man page."
117                 elog
118         fi
119
120         elog "A script is now available to reset your wirless connection on resume."
121         elog "Simply uncomment the commented command and set the correct device to"
122         elog "use it.  You can find the script in /etc/power/resume.d/wireless"
123
124 }