summaryrefslogtreecommitdiff
blob: 31d1caa7dc24a9416d4f6bed96df73e5a6ea63b0 (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/vdr-plugin.eclass,v 1.1 2005/07/23 15:11:25 zzam Exp $
#
# Author:
#   Matthias Schwarzott <zzam@gentoo.org>

# vdr-plugin.eclass
#
#   eclass to create ebuilds for vdr plugins
#

# Example ebuild (vdr-femon):
#
#	inherit vdr-plugin
#	IUSE=""
#	SLOT="0"
#	DESCRIPTION="vdr Plugin: DVB Frontend Status Monitor (signal strengt/noise)"
#	HOMEPAGE="http://www.saunalahti.fi/~rahrenbe/vdr/femon/"
#	SRC_URI="http://www.saunalahti.fi/~rahrenbe/vdr/femon/files/${P}.tgz"
#	LICENSE="GPL-2"
#	KEYWORDS="~x86"
#	DEPEND=">=media-video/vdr-1.3.27"
#
# 


inherit eutils flag-o-matic

# Name of the plugin stripped from all vdrplugin-, vdr- and -cvs pre- and postfixes
VDRPLUGIN="${PN/#vdrplugin-/}"
VDRPLUGIN="${PN/#vdr-/}"
VDRPLUGIN="${VDRPLUGIN/%-cvs/}"

DESCRIPTION="vdr Plugin: ${VDRPLUGIN} (based on vdr-plugin.eclass)"

# works in most cases
S="${WORKDIR}/${VDRPLUGIN}-${PV}"

# depend on headers for DVB-driver
RDEPEND=""
DEPEND="|| (
		>=sys-kernel/linux-headers-2.6.11-r2
		media-tv/linuxtv-dvb
	)"

# Where should the plugins live in the filesystem
VDR_PLUGIN_DIR="/usr/lib/vdr/plugins"

# Pathes to includes
VDR_INCLUDE_DIR="/usr/include"
DVB_INCLUDE_DIR="/usr/include"

vdr-plugin_pkg_setup() {
	# -fPIC is needed for shared objects on some platforms (amd64 and others)
	append-flags -fPIC

	VDRVERSION=$(awk -F'"' '/VDRVERSION/ {print $2}' /usr/include/vdr/config.h)
	einfo "Building ${PF} against vdr-${VDRVERSION}"
}

vdr-plugin_src_unpack() {
	[ -z "$1" ] && vdr-plugin_src_unpack unpack patchmakefile

	while [ "$1" ]; do

		case "$1" in
		unpack)
			unpack ${A}
			;;
		patchmakefile)
			cd ${S}

			ebegin "Patching Makefile"
			sed -i Makefile \
				-e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
				-e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
				-e "s:^LIBDIR.*$:LIBDIR = ${S}:" \
				-e "s:^TMPDIR.*$:TMPDIR = ${T}:" \
				-e 's:^CXXFLAGS:#CXXFLAGS:' \
				-e 's:-I$(VDRDIR)/include:-I$(VDRDIR):' \
				-e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \
				-e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):' \
				-e 's:$(VDRDIR)/\(config.h\|Make.config\):$(VDRDIR)/vdr/\1:'
			eend $?
			;;
		esac

		shift
	done
}

vdr-plugin_src_compile() {
	cd ${S}

	emake ${VDRPLUGIN_MAKE_TARGET:-all} || die "emake failed"
}

vdr-plugin_src_install() {
	cd ${S}

	insinto "${VDR_PLUGIN_DIR}"
	doins libvdr-*.so.*
	dodoc README* HISTORY CHANGELOG
}

vdr-plugin_pkg_postinst() {
	einfo
	einfo "The vdr plugin ${VDRPLUGIN} has now been installed,"
	einfo "to activate it you have to add it to /etc/conf.d/vdr."
	einfo
}

EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst