summaryrefslogtreecommitdiff
blob: 7b716128fafbbb3abd7b90a948ae10202cfde110 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/xmms-plugin.eclass,v 1.8 2004/10/27 10:21:23 eradicator Exp $
#
# Jeremy Huddleston <eradicator@gentoo.org>
#
# Usage:
# The main purpose of this eclass is to simplify installing xmms plugins
# which for the various players that support the xmms API (mainly xmms and
# bmp, but this can be expanded to noxmms as well).
#
# The package is assumed to work by default with xmms.  If it will not work
# with BMP, then set NOBMP=1 in the ebuild.
#
# Source Code:
# You have multiple methods with which to specify how we get the source code
# for the patckages.
#
# (1) - Separate tarballs
# If your package provides separate tarballs for the xmms and bmp plugins,
# then specify them in the XMMS_SRC_URI and BMP_SRC_URI variables.
# XMMS_SRC_URI="xmms-plugin.tar.bz2"
# BMP_SRC_URI="bmp-plugin.tar.bz2"
# BASE_SRC_URI="common-stuff.tar.bz2"
#
# (2) - xmms->bmp patch
# If you have a patch to turn an xmms plugin into a bmp plugin, specify it
# in the variable XMMS2BMP_PATCH:
# XMMS2BMP_PATCH="${FILESDIR}/${P}-xmms2bmp.patch"
#
# (3) - automated
# The eclass will try to do some sedage to get the plugin to work with bmp.
#
# Common patches:
# If you have patches that need to apply to both xmms and bmp sources,
# Place them in the PATCHES variable:
# PATCHES="${FILESDIR}/${P}-gcc34.patch ${FILESDIR}/${P}-config.patch"
#
# Source Location:
# By default, we assume a ${S} of ${XMMS_S} or ${BMP_S} for the two packages.
# These default to ${XMMS_WORKDIR}/${P} or ${BMP_WORKDIR}/${P}.
# ${XMMS_WORKDIR} and ${BMP_WORKDIR}/${P} default to ${WORKDIR}/xmms and
# ${WORKDIR}/bmp.  You may override ${*_S}, but not the ${*_WORKDIR}.
#
# Documentation:
# Set the DOCS variable to contain the documentation to be dodocd:
# DOCS="ChangeLog AUTHORS README"
#
# Install:
# Set the XMMS_PLUGIN_INSTALL variable to control how src_install works
# 'einstall' - use 'einstall' to install
# 'destdir'  - use 'make DESTDIR="${D}" install || die' to install
# 'doexe' - use 'doexe' to install
# destdir is default
#
# The 'myins_xmms' and 'myins_bmp' variables are used to add extra arguments
# to the install line.  They are optional for einstall and destdir, but they're
# required for doexe.  For doexe, you need to specify the plugin type in the
# 'xmms_plugin_type' variable' and the location of the plugin in the 'myins_*'
# variable.
#

inherit eutils libtool gnuconfig

ECLASS=xmms-plugin
INHERITED="${INHERITED} ${ECLASS}"

if [ "${NOXMMS}" != "1" ]; then
	IUSE="${IUSE} xmms"
	DEPEND="${DEPEND}
		xmms? ( media-sound/xmms )"

	RDEPEND="${RDEPEND}
		 xmms? ( media-sound/xmms )"

	if [ -n "${BMP2XMMS_PATCH}" ]; then
		SRC_URI="${SRC_URI}
			 xmms? ( ${XMMS_SRC_URI} 
			         ${BMP_SRC_URI} )"
	elif [ -n "${XMMS_SRC_URI}" ]; then
		SRC_URI="${SRC_URI}
			 xmms? ( ${XMMS_SRC_URI} )"
	fi

	XMMS_WORKDIR="${WORKDIR}/xmms"
	if [ -z "${XMMS_S}" ]; then
		XMMS_S="${XMMS_WORKDIR}/${P}"
	fi
fi

if [ "${NOBMP}" != "1" ]; then
	IUSE="${IUSE} bmp"
	DEPEND="${DEPEND}
		bmp? ( >=media-sound/beep-media-player-0.9.7_rc2-r2 
		       dev-util/pkgconfig )"

	RDEPEND="${RDEPEND}
		bmp? ( >=media-sound/beep-media-player-0.9.7_rc2-r2 )"

	if [ -n "${XMMS2BMP_PATCH}" ]; then
		SRC_URI="${SRC_URI}
			 bmp? ( ${XMMS_SRC_URI} 
			         ${BMP_SRC_URI} )"
	elif [ -n "${BMP_SRC_URI}" ]; then
		SRC_URI="${SRC_URI}
			 bmp? ( ${BMP_SRC_URI} )"
	fi

	BMP_WORKDIR="${WORKDIR}/bmp"
	if [ -z "${BMP_S}" ]; then
		BMP_S="${BMP_WORKDIR}/${P}"
	fi
fi

SRC_URI="${BASE_SRC_URI} ${SRC_URI}"

# Set S to something which exists
S="${WORKDIR}"

xmms-plugin_src_unpack() {
	if do_xmms; then
		mkdir ${XMMS_WORKDIR}
		cd ${XMMS_WORKDIR}

		XMMS_A=""
		if [ -z "${BASE_SRC_URI}${XMMS_SRC_URI}${BMP_SRC_URI}" ]; then
			XMMS_A=${A}
		elif [ -n "${BMP2XMMS_PATCH}" ]; then
			for f in ${XMMS_SRC_URI} ${BMP_SRC_URI} ${BASE_SRC_URI}; do
				XMMS_A="${XMMS_A} `basename ${f}`"
			done
		else
			for f in ${XMMS_SRC_URI} ${BASE_SRC_URI}; do
				XMMS_A="${XMMS_A} `basename ${f}`"
			done
		fi
		
		unpack ${XMMS_A}

		cd ${XMMS_S}
		if [ -n "${PATCHES}" ]; then
			epatch ${PATCHES}
		fi
		if [ -n "${BMP2XMMS_PATCH}" ]; then
			epatch ${BMP2XMMS_PATCH}
		fi

		elibtoolize
		gnuconfig_update
	fi

	if do_bmp; then
		mkdir ${BMP_WORKDIR}
		cd ${BMP_WORKDIR}

		BMP_A=""
		if [ -z "${BASE_SRC_URI}${XMMS_SRC_URI}${BMP_SRC_URI}" ]; then
			BMP_A=${A}
		elif [ -n "${XMMS2BMP_PATCH}" ]; then
			for f in ${XMMS_SRC_URI} ${BMP_SRC_URI} ${BASE_SRC_URI}; do
				BMP_A="${BMP_A} `basename ${f}`"
			done
		else
			for f in ${BMP_SRC_URI} ${BASE_SRC_URI}; do
				BMP_A="${BMP_A} `basename ${f}`"
			done
		fi
		
		unpack ${BMP_A}

		cd ${BMP_S}
		if [ -n "${PATCHES}" ]; then
			epatch ${PATCHES}
		fi
		if [ -n "${XMMS2BMP_PATCH}" ]; then
			epatch ${XMMS2BMP_PATCH}
		elif [ -z "${BMP_SRC_URI}" ]; then
			xmms2bmp_automate
		fi

		elibtoolize
		gnuconfig_update
	fi
}

xmms-plugin_src_compile() {
	myconf="${myconf} --disable-static"

	if do_xmms; then
		cd ${XMMS_S}
		econf ${myconf} ${xmms_myconf} || die
		emake || die
	fi

	if do_bmp; then
		cd ${BMP_S}
		export FAKE_XMMS_VERSION=1.2.10
		econf ${myconf} ${bmp_myconf} || die
		emake || die
	fi
}

xmms-plugin_src_install() {
	if [ -z "${XMMS_PLUGIN_INSTALL}" ]; then
		XMMS_PLUGIN_INSTALL="destdir"
	fi

	case ${XMMS_PLUGIN_INSTALL} in
	einstall)
		if do_xmms; then
			cd ${XMMS_S}
			einstall ${myins_xmms}
		fi

		if do_bmp; then
			cd ${BMP_S}
			einstall ${myins_bmp}
		fi
	;;
	destdir)
		if do_xmms; then
			cd ${XMMS_S}
			make DESTDIR="${D}" ${myins_xmms} install || die
		fi

		if do_bmp; then
			cd ${BMP_S}
			make DESTDIR="${D}" ${myins_bmp} install || die
		fi
	;;
	doexe)
		if do_xmms; then
			xmms-config --${xmms_plugin_type}-plugin-dir >& /dev/null || die "Invalid xmms_plugin_type specified"
			cd ${XMMS_S}
			exeinto `xmms-config --${xmms_plugin_type}-plugin-dir`
			doexe ${myins_xmms} || die
		fi

		if do_bmp; then
			beep-config --${xmms_plugin_type}-plugin-dir >& /dev/null || die "Invalid xmms_plugin_type specified"
			cd ${BMP_S}
			exeinto `beep-config --${xmms_plugin_type}-plugin-dir`
			doexe ${myins_bmp} || die
		fi
	;;
	*)
		die "Invalid XMMS_PLUGIN_INSTALL specified: ${XMMS_PLUGIN_INSTALL}"
	;;
	esac

	if [ -n "${DOCS}" ]; then
		dodoc ${DOCS}
	fi
}

xmms2bmp_automate() {
	find . -name Makefile -o -name Makefile.in -o -name configure |
		xargs sed -i -e 's:xmms-config:beep-config:g' \
		             -e 's:libdir)/xmms:libdir)/bmp:g' \
		             -e 's:-lxmms:-lbeep:g'
}

do_xmms() {
	use xmms && [ "${NOXMMS}" != "1" ]
}

do_bmp() {
	use bmp && [ "${NOBMP}" != "1" ]
}

EXPORT_FUNCTIONS src_unpack src_compile src_install