summaryrefslogtreecommitdiff
blob: 4e7786d85f6c70af9cc303ea79d55a6e0b67b2ec (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-misc/digitemp/digitemp-3.5.0-r1.ebuild,v 1.1 2010/07/19 00:25:42 hwoarang Exp $

inherit toolchain-funcs

DESCRIPTION="Temperature logging and reporting using Dallas Semiconductor's iButtons and 1-Wire protocol"
HOMEPAGE="http://www.digitemp.com/ http://www.ibutton.com/"
SRC_URI="http://www.digitemp.com/software/linux/${P}.tar.gz"

IUSE="ds9097 ds9097u ds2490"
SLOT="0"
LICENSE="GPL-2"
KEYWORDS="~amd64 ~x86"

DEPEND="ds2490? ( >=dev-libs/libusb-0.1.10a )"

targets() {
	# default is to compile to the ds9097u.
	if ! ( use ds9097 || use ds9097u || use ds2490 ); then
		echo ds9097u
	fi
	for target in ds9097 ds9097u ds2490; do
		if use ${target}; then
			echo ${target}
		fi
	done
}

src_compile() {
	sed -i -e "/^CFLAGS/s:-O2:${CFLAGS}:" \
		-e "/^LIBS/s:=:= ${LDFLAGS}:" Makefile
	# default is to compile to the ds9097u.
	if ! ( use ds9097 || use ds9097u || use ds2490 ); then
		ewarn "If you don't choose a component to install, we default to ds9097u"
	fi

	local targets=$(targets)

	for target in $targets; do
		emake clean
		emake CC="$(tc-getCC)" 	LOCK="no" ${target} || die "emake ${target} failed"
	done
}

src_install() {
	for target in $(echo $(targets) | tr '[:lower:]' '[:upper:]'); do
		dobin digitemp_${target} && \
		dosym digitemp_${target} /usr/bin/digitemp
	done

	if [[ $(targets|wc -l) -ge 1 ]]; then
		echo
		ewarn "/usr/bin/digitemp has been symlinked to /usr/bin/digitemp_${target}"
		ewarn "If you want to access the others, they are available at /usr/bin/digitemp_*"
		echo
	fi

	dodoc README FAQ TODO

	for example in perl python rrdb; do
		insinto "/usr/share/doc/${PF}/${example}_examples"
		doins ${example}/*
	done
}

pkg_postinst() {
	echo
	elog "Examples of using digitemp with python, perl, and rrdtool are"
	elog "located in /usr/share/doc/${PF}/"
	echo
}