blob: fc73c751276f37485a47a3241c81de60d02b49fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/lm_sensors/lm_sensors-2.8.7.ebuild,v 1.4 2005/03/01 20:11:55 eradicator Exp $
inherit flag-o-matic eutils toolchain-funcs multilib
MYI2C="${WORKDIR}/i2c-headers"
DESCRIPTION="Hardware Sensors Monitoring by lm_sensors"
SRC_URI="http://www.lm-sensors.nu/archive/${P}.tar.gz"
HOMEPAGE="http://www2.lm-sensors.nu/~lm78"
SLOT="${KV}"
KEYWORDS="-ppc -sparc x86 amd64"
IUSE="rrdtool"
LICENSE="GPL-2"
DEPEND=">=sys-apps/i2c-${PV}
rrdtool? ( net-analyzer/rrdtool )"
src_unpack() {
unpack ${A} || die
cd ${S} || die
epatch ${FILESDIR}/lm_sensors-2.8.7-sensors-detect-gentoo.diff > /dev/null || die
# Get the right I2C includes without dropping the kernel includes
mkdir -p ${MYI2C}/linux
cp /usr/include/linux/i2c* ${MYI2C}/linux/
# Add sensord to the make targets if the rrdtool USE flag is on...
use rrdtool && sed -i -e 's:# PROG_EXTRA:PROG_EXTRA:' Makefile
}
src_compile() {
echo
einfo "This ebuild assumes your /usr/src/linux kernel is the one you"
einfo "used to build i2c-2.8.7."
einfo
einfo "For 2.5+ series kernels, use the support already in the kernel"
einfo "under 'Character devices' -> 'I2C support' and then merge this"
einfo "ebuild."
einfo
einfo "To cross-compile, 'export LINUX=\"/lib/modules/<version>/build\"'"
einfo "or symlink /usr/src/linux to another kernel."
echo
UserModeOnly=false
if [ "$LINUX" != "" ]; then
einfo "Cross-compiling using:- $LINUX"
LINUX=`echo $LINUX | sed 's/build\//build/'`
KV=`cut -d\ -f3 ${LINUX}/include/linux/version.h | grep \" | sed -e 's/"//' -e 's/"//'`
if [ "${KV}" == "" ]; then
die "Could not get kernel version; make sure ${LINUX}/include/linux/version.h is there!"
fi
else
LINUX='/usr/src/linux'
check_KV || die "Cannot find kernel in /usr/src/linux!"
einfo "Using kernel in /usr/src/linux/:- ${KV}"
fi
if [ `echo ${KV} | grep 2\.[56]\.` ]; then
einfo "You are using a 2.5 / 2.6 series kernel; only building utilities..."
UserModeOnly=true
else
einfo "You are using a `echo ${KV} | cut -d. -f-2` series kernel; building everything..."
fi
if [ "${KV}" != "${SLOT}" ]; then
echo
ewarn "WARNING:- Specified and running kernels do not match!"
ewarn "WARNING:- This package will be slotted as ${SLOT}!"
fi
if [ ! -e ${MYI2C}/linux/i2c.h ]; then
cp $LINUX/include/linux/i2c* ${MYI2C}/linux || die "No I2C Includes! Install I2C!"
fi
echo; einfo "You may safely ignore any errors from compilation"
einfo "that contain 'No such file' references."
echo
# Please _don't_ use filter-flags -fPIC on apps that need it!
# [ amd64, hppa, ia64, etc... ]
# Danny van Dyk <kugelfang@gentoo.org> 2004/05/28
case "${ARCH}" in
"amd64")
filter-flags -fstack-protector
;;
*)
filter-flags -fPIC -fstack-protector
;;
esac
cd ${S}
emake clean
if [ ${UserModeOnly} == true ]; then
emake CC=$(tc-getCC) I2C_HEADERS=${MYI2C} user || die "Could not compile user-mode utilities!"
else
emake CC=$(tc-getCC) I2C_HEADERS=${MYI2C} LINUX=$LINUX || die "lm_sensors requires the source of a compatible kernel version in /usr/src/linux or specified in \$LINUX and >=i2c-2.8.1 support built as modules. Make sure that I2C >=2.8.1 is on your system before filing a bug."
fi
}
src_install() {
dodir /usr/bin
dodir /usr/sbin
if [ ${UserModeOnly} == true ]; then
emake DESTDIR=${D} LIBDIR=/usr/$(get_libdir) PREFIX=/usr MANDIR=/usr/share/man user_install || die "Install failed!"
else
emake LINUX=$LINUX DESTDIR=${D} LIBDIR=/usr/$(get_libdir) PREFIX=/usr MANDIR=/usr/share/man install || die "Install failed!"
fi
rm ${D}/var -Rf
exeinto /etc/init.d
newexe ${FILESDIR}/rc lm_sensors
dodoc BACKGROUND BUGS CHANGES CONTRIBUTORS COPYING INSTALL QUICKSTART \
README* TODO
[ -e ${ROOT}/usr/include/linux/i2c-dev.h -a -e ${D}/usr/include/linux/i2c-dev.h ] && rm ${D}/usr/include/linux/i2c-dev.h
cp -a doc/* ${D}/usr/share/doc/${PF}
}
pkg_postinst() {
[ -x /usr/sbin/update-modules ] && /usr/sbin/update-modules
echo
einfo
einfo "The lm_sensors hardware sensors package has been installed."
einfo
einfo "It is recommended that you read the lm_sensors documentation."
einfo "To enable lm_sensors you will need to compile i2c support in"
einfo "your kernel as a module and run /usr/sbin/sensors-detect to"
einfo "detect the hardware in your system."
einfo
einfo "Be warned, the probing of hardware in your system performed by"
einfo "sensors-detect could freeze your system. Also do not use"
einfo "lm_sensors on certain laptop models from IBM. See the lm_sensors"
einfo "documentation and website for more information."
einfo
einfo "IMPORTANT: When you merge this package it installs kernel modules"
einfo "that can only be used with the specific kernel version whose"
einfo "source is located in /usr/src/linux. If you upgrade to a new"
einfo "kernel, you will need to remerge the lm_sensors package to build"
einfo "new kernel modules."
einfo
echo
}
|