dev-util/qbs: version bump
[gentoo.git] / eclass / mythtv-plugins.eclass
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: mythtv-plugins.eclass
6 # @MAINTAINER:
7 # Doug Goldstein <cardoe@gentoo.org>
8 # @AUTHOR:
9 # Doug Goldstein <cardoe@gentoo.org>
10 # @BLURB: Installs MythTV plugins along with patches from the release-${PV}-fixes branch
11
12 # NOTE: YOU MUST INHERIT EITHER qt3 or qt4 IN YOUR PLUGIN!
13
14 inherit mythtv multilib versionator
15
16 # Extra configure options to pass to econf
17 MTVCONF=${MTVCONF:=""}
18
19 SLOT="0"
20 IUSE="${IUSE} debug mmx"
21
22 if [[ -z $MYTHTV_NODEPS ]] ; then
23 RDEPEND="${RDEPEND}
24                 =media-tv/mythtv-${MY_PV}*"
25 DEPEND="${DEPEND}
26                 =media-tv/mythtv-${MY_PV}*
27                 >=sys-apps/sed-4"
28 fi
29
30 # bug 240325
31 RESTRICT="strip"
32
33 mythtv-plugins_pkg_setup() {
34         # List of available plugins (needs to include ALL of them in the tarball)
35         MYTHPLUGINS="mythbrowser mythcontrols mythdvd mythflix mythgallery"
36         MYTHPLUGINS="${MYTHPLUGINS} mythgame mythmusic mythnews mythphone"
37         MYTHPLUGINS="${MYTHPLUGINS} mythvideo mythweather mythweb"
38
39         if version_is_at_least "0.20" ; then
40                 MYTHPLUGINS="${MYTHPLUGINS} mytharchive"
41         fi
42
43         if version_is_at_least "0.21_beta" ; then
44                 MYTHPLUGINS="${MYTHPLUGINS} mythzoneminder mythmovies"
45                 MYTHPLUGINS="${MYTHPLUGINS/mythdvd/}"
46         fi
47
48         if version_is_at_least "0.22_beta" ; then
49                 MYTHPLUGINS="${MYTHPLUGINS/mythcontrols/}"
50                 MYTHPLUGINS="${MYTHPLUGINS/mythphone/}"
51         fi
52
53         if version_is_at_least "0.23_beta" ; then
54                 MYTHPLUGINS="${MYTHPLUGINS/mythflix/}"
55                 MYTHPLUGINS="${MYTHPLUGINS} mythnetvision"
56         fi
57 }
58
59 mythtv-plugins_src_prepare() {
60         sed -e 's!PREFIX = /usr/local!PREFIX = /usr!' \
61         -i 'settings.pro' || die "fixing PREFIX to /usr failed"
62
63         sed -e "s!QMAKE_CXXFLAGS_RELEASE = -O3 -march=pentiumpro -fomit-frame-pointer!QMAKE_CXXFLAGS_RELEASE = ${CXXFLAGS}!" \
64         -i 'settings.pro' || die "Fixing QMake's CXXFLAGS failed"
65
66         sed -e "s!QMAKE_CFLAGS_RELEASE = \$\${QMAKE_CXXFLAGS_RELEASE}!QMAKE_CFLAGS_RELEASE = ${CFLAGS}!" \
67         -i 'settings.pro' || die "Fixing Qmake's CFLAGS failed"
68
69         find "${S}" -name '*.pro' -exec sed -i \
70                 -e "s:\$\${PREFIX}/lib/:\$\${PREFIX}/$(get_libdir)/:g" \
71                 -e "s:\$\${PREFIX}/lib$:\$\${PREFIX}/$(get_libdir):g" \
72         {} \;
73 }
74
75 mythtv-plugins_src_configure() {
76         cd "${S}"
77
78         if use debug; then
79                 sed -e 's!CONFIG += release!CONFIG += debug!' \
80                 -i 'settings.pro' || die "switching to debug build failed"
81         fi
82
83 #       if ( use x86 && ! use mmx ) || ! use amd64 ; then
84         if ( ! use mmx ); then
85                 sed -e 's!DEFINES += HAVE_MMX!DEFINES -= HAVE_MMX!' \
86                 -i 'settings.pro' || die "disabling MMX failed"
87         fi
88
89         local myconf=""
90
91         if has ${PN} ${MYTHPLUGINS} ; then
92                 for x in ${MYTHPLUGINS} ; do
93                         if [[ ${PN} == ${x} ]] ; then
94                                 myconf="${myconf} --enable-${x}"
95                         else
96                                 myconf="${myconf} --disable-${x}"
97                         fi
98                 done
99         else
100                 die "Package ${PN} is unsupported"
101         fi
102
103         chmod +x configure
104         econf ${myconf} ${MTVCONF}
105 }
106
107 mythtv-plugins_src_compile() {
108         if version_is_at_least "0.22" ; then
109                 eqmake4 mythplugins.pro || die "eqmake4 failed"
110         else
111                 eqmake3 mythplugins.pro || die "eqmake3 failed"
112         fi
113         emake || die "make failed to compile"
114 }
115
116 mythtv-plugins_src_install() {
117         if has ${PN} ${MYTHPLUGINS} ; then
118                 cd "${S}"/${PN}
119         else
120                 die "Package ${PN} is unsupported"
121         fi
122
123         einstall INSTALL_ROOT="${D}"
124         for doc in AUTHORS COPYING FAQ UPGRADING ChangeLog README; do
125                 test -e "${doc}" && dodoc ${doc}
126         done
127 }
128
129 EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile src_install