app-laptop/pbbuttonsd: Fix patch names.
[gentoo.git] / app-laptop / pbbuttonsd / pbbuttonsd-0.8.1-r4.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         ### Add kernel 2.6.x stuff for 3.x as well
39         epatch "${FILESDIR}/${PN}-0.8.1-laptopmode.sh.patch"
40         epatch "${FILESDIR}/${PN}-0.8.1-cpufreq.patch"
41
42         eautoconf
43 }
44
45 src_compile() {
46         # Fix crash bug on some systems
47         replace-flags -O? -O1
48
49         if use macbook; then
50                 laptop=macbook
51         elif use x86 || use amd64; then
52                 if use acpi; then
53                         laptop=acpi
54                 else
55                         laptop=i386
56                 fi
57         # Default to PowerBook
58         else
59                 laptop=powerbook
60         fi
61
62         econf laptop=$laptop \
63                 $(use_enable debug) \
64                 $(use_with doc doxygen_docs) \
65                 $(use_with alsa) \
66                 $(use_with oss) \
67                 $(use_with ibam) \
68                 || die "Sorry, failed to configure pbbuttonsd"
69
70         # Thanks to Stefan Bruda for this workaround
71         # Using -j1 fixes a parallel build issue with the docs
72         if use doc; then
73                 emake -j1 || die "Sorry, failed to compile pbbuttonsd"
74         else
75                 emake || die "Sorry, failed to compile pbbuttonsd"
76         fi
77 }
78
79 src_install() {
80         dodir /etc/power
81         use ibam && dodir /var/lib/ibam
82         make DESTDIR="${D}" install || die "failed to install"
83         newinitd "${FILESDIR}/pbbuttonsd.rc6" pbbuttonsd
84         dodoc README
85         use doc && dohtml -r doc/*
86
87         dodir /etc/power/resume.d
88         dodir /etc/power/suspend.d
89         dodir /etc/power/scripts.d
90         exeinto "/etc/power/scripts.d"
91         doexe "${FILESDIR}/wireless"
92         ln -s "${D}/etc/power/scripts.d/wireless" "${D}/etc/power/resume.d/wireless"
93 }
94
95 pkg_postinst() {
96         if [ -e /etc/pbbuttonsd.conf ]; then
97                 ewarn "The pbbuttonsd.cnf file replaces /etc/pbuttonsd.conf with a new"
98                 ewarn "file (/etc/pbbuttonsd.conf) and a new format.  Please check the"
99                 ewarn "manual page with 'man pbbuttonsd.cnf' for details."
100                 ewarn
101         fi
102
103         if use macbook; then
104                 ewarn "Macbook and Macbook Pro users should make sure to have applesmc"
105                 ewarn "loaded before starting pbbuttonsdm otherwise auto-adjustments"
106                 ewarn "will not work and pbbuttonsd may segfault."
107         fi
108
109         ewarn "Ensure that the evdev kernel module is loaded otherwise"
110         ewarn "pbbuttonsd won't work.  SysV IPC is also required."
111         ewarn
112         ewarn "If you need extra security, you can tell pbbuttonsd to only accept"
113         ewarn "input from one user.  You can set the userallowed option in"
114         ewarn "/etc/pbbuttonsd.cnf to limit access."
115         ewarn
116
117         if use ibam; then
118                 elog "To properly initialize the IBaM battery database, you will"
119                 elog "need to perform a full discharge/charge cycle.  For more"
120                 elog "details, please see the pbbuttonsd man page."
121                 elog
122         fi
123
124         elog "A script is now available to reset your wirless connection on resume."
125         elog "Simply uncomment the commented command and set the correct device to"
126         elog "use it.  You can find the script in /etc/power/resume.d/wireless"
127
128 }