]> Pileus Git - ~andy/sunrise/blob - media-libs/portmidi/portmidi-217.ebuild
f5eaf44bcd6c26df6d4a83aa4f97abcbf4329f54
[~andy/sunrise] / media-libs / portmidi / portmidi-217.ebuild
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI=3
6
7 inherit cmake-utils eutils multilib java-pkg-opt-2 distutils
8
9 DESCRIPTION="A library for real time MIDI input and output"
10 HOMEPAGE="http://portmedia.sourceforge.net/"
11 SRC_URI="mirror://sourceforge/portmedia/${PN}-src-${PV}.zip"
12
13 LICENSE="MIT"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="debug java python test-programs"
17
18 PYTHON_DEPEND="python? 2:2.6"
19
20 CDEPEND="media-libs/alsa-lib"
21 RDEPEND="${CDEPEND}
22         java? ( >=virtual/jre-1.6 )"
23 DEPEND="${CDEPEND}
24         java? ( >=virtual/jdk-1.6 )
25         python? ( >=dev-python/cython-0.12.1 )
26         app-arch/unzip"
27 # build of docs not working
28 #       doc? ( app-doc/doxygen
29 #                  virtual/latex-base )"
30
31 S="${WORKDIR}/${PN}"
32
33 # Bug #3295129 reported upstream
34 CMAKE_IN_SOURCE_BUILD=1
35
36 # seems to be needed, if the default "Gentoo" is used there will be
37 # problems. f.e. no midi devices in pmdefaults, maybe even no midi devices at
38 # all.
39 CMAKE_BUILD_TYPE=$(use debug && echo Debug || echo Release)
40
41 src_prepare() {
42         # with this patch the java installation directories can be specified and
43         # allows java to be enabled/disabled
44         epatch "${FILESDIR}/${P}-cmake-libdir-java-opts.patch"
45
46         # find the header and our compiled libs in the distutils setup.py
47         epatch "${FILESDIR}/${P}-python-setup.py.patch"
48
49         if use java ; then
50                 # this stuff fixes up the pmdefaults wrapper for locations where
51                 # Gentoo prefers to keep jars, it also specifies a library directory
52                 cat > pm_java/pmdefaults/pmdefaults <<-EOF
53                         #!/bin/sh
54                         java -Djava.library.path=/usr/$(get_libdir)/ \\
55                                 -jar "${EPREFIX}/usr/share/${PN}/lib/pmdefaults.jar"
56                 EOF
57                 [ "$?" -neq "0" ] && die "cat pmdefaults failed"
58         fi
59 }
60
61 src_configure() {
62         local mycmakeargs=(
63                 $(cmake-utils_use java PORTMIDI_ENABLE_JAVA)
64
65                 # this seems to be needed. if not set there will be a sandbox
66                 # violation. if set to ./ the java parts will not build.
67                 # one may end up with a blob named Gentoo, Debug or Release. hmmm
68                 -DCMAKE_CACHEFILE_DIR="${S}/build"
69         )
70
71         # java stuff, the portmidi wiki says JAVA_JVM_LIBRARY needs to be specified
72         if use java ; then
73                 # search for libjvm.so in JAVA_HOME to set JAVA_JVM_LIBRARY
74                 local javalib=`find "${JAVA_HOME}" -name "libjvm.so" | head -n 1`
75
76                 mycmakeargs+=(-DJAVA_JVM_LIBRARY="${javalib}"
77                         # tell cmake where to install the jar, this requires the cmake
78                         # patch, can be a relative path from CMAKE_INSTALL_PREFIX or
79                         # absolute.
80                         -DJAR_INSTALL_DIR="${EPREFIX}/usr/share/${PN}/lib"
81                 )
82         fi
83
84         cmake-utils_src_configure
85 }
86
87 src_compile() {
88         # parallel make is broken when java is enabled so force -j1 :(
89         cmake-utils_src_compile $(use java && echo "-j1")
90
91         # python modules
92         if use python ; then
93                 pushd pm_python || die "pushd python failed"
94                 # hack. will error out if these files are not found
95                 touch CHANGES.txt TODO.txt
96                 distutils_src_compile
97                 popd
98         fi
99
100         # make the docs (NOT WORKING)
101         #if use doc ; then
102         #       doxygen || die "doxygen failed"
103         #       pushd latex || die "pushd latex failed"
104         #               VARTEXFONTS="${T}/fonts" make ${MAKEOPTS} || die "make doc failed"
105         #       popd
106         #fi
107 }
108
109 src_install() {
110         cmake-utils_src_install
111
112         dodoc CHANGELOG.txt README.txt pm_linux/README_LINUX.txt || die "dodoc failed"
113
114         # install the python modules
115         if use python ; then
116                 pushd pm_python || die "pushd pm_python failed"
117                 distutils_src_install
118                 popd
119         fi
120
121         # a desktop entry and icon for the pmdefaults java configuration gui
122         if use java ; then
123                 newdoc pm_java/README.txt README_JAVA.txt || die "newdoc failed"
124                 doicon pm_java/pmdefaults/pmdefaults-icon.png || die "doicon failed"
125                 make_desktop_entry pmdefaults Pmdefaults pmdefaults-icon \
126                         "AudioVideo;Audio;Midi;"
127         fi
128
129         # some portmidi test apps
130         if use test-programs ; then
131                 # maybe a better location can be used
132                 exeinto /usr/$(get_libdir)/${PN}
133                 local app
134                 for app in latency midiclock midithread \
135                                 midithru mm qtest sysex test ; do
136                         doexe ${S}"/build/${CMAKE_BUILD_TYPE}/${app}" \
137                         || die "doins test programs failed"
138                 done
139         fi
140 }
141
142 pkg_postinst() {
143         # prevent distutils_pkg_postinst from being called autmatically if 
144         # python is disabled
145         use python && distutils_pkg_postinst
146 }
147
148 pkg_postrm() {
149         # prevent distutils_pkg_postrm from being called autmatically if 
150         # python is disabled
151         use python && distutils_pkg_postrm
152 }