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