app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / media-sound / csound / csound-9999.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python2_7 )
6
7 inherit java-pkg-opt-2 toolchain-funcs python-single-r1 cmake-utils
8
9 if [[ ${PV} == "9999" ]]; then
10         EGIT_REPO_URI="https://github.com/csound/csound.git"
11         inherit git-r3
12 else
13         DOC_P="Csound${PV}"
14         SRC_URI="https://github.com/csound/csound/archive/${PV}.tar.gz -> ${P}.tar.gz
15                 doc? (
16                         https://github.com/csound/csound/releases/download/${PV}/${DOC_P}_manual_pdf.zip
17                         https://github.com/csound/csound/releases/download/${PV}/${DOC_P}_manual_html.zip
18                 )"
19         KEYWORDS="~amd64 ~x86"
20 fi
21
22 DESCRIPTION="A sound design and signal processing system for composition and performance"
23 HOMEPAGE="https://csound.github.io/"
24
25 LICENSE="LGPL-2.1 doc? ( FDL-1.2+ )"
26 SLOT="0"
27 IUSE="+alsa beats chua csoundac curl +cxx debug doc double-precision dssi examples
28 fltk +fluidsynth +image jack java keyboard linear lua luajit nls osc openmp
29 portaudio portmidi pulseaudio python samples score static-libs stk tcl test
30 +threads +utils vim-syntax websocket"
31
32 IUSE_LANGS=" de en_US es es_CO fr it ro ru"
33 IUSE+="${IUSE_LANGS// / linguas_}"
34
35 REQUIRED_USE="
36         csoundac? ( || ( lua python ) )
37         java? ( cxx )
38         linear? ( double-precision )
39         lua? ( cxx )
40         python? ( ${PYTHON_REQUIRED_USE} cxx )
41 "
42
43 RDEPEND="
44         >=media-libs/libsndfile-1.0.16
45         media-libs/libsamplerate
46         alsa? ( media-libs/alsa-lib )
47         csoundac? (
48                 x11-libs/fltk:1[threads?]
49                 dev-cpp/eigen:3
50                 dev-libs/boost:=
51         )
52         curl? ( net-misc/curl )
53         dssi? (
54                 media-libs/dssi
55                 media-libs/ladspa-sdk
56         )
57         fluidsynth? ( media-sound/fluidsynth )
58         fltk? ( x11-libs/fltk:1[threads?] )
59         image? ( media-libs/libpng:0= )
60         jack? ( media-sound/jack-audio-connection-kit )
61         java? ( virtual/jdk:* )
62         keyboard? ( x11-libs/fltk:1[threads?] )
63         linear? ( sci-mathematics/gmm )
64         lua? (
65                 luajit? ( dev-lang/luajit:2 )
66                 !luajit? ( dev-lang/lua:0 )
67         )
68         osc? ( media-libs/liblo )
69         portaudio? ( media-libs/portaudio )
70         portmidi? ( media-libs/portmidi )
71         pulseaudio? ( media-sound/pulseaudio )
72         python? ( ${PYTHON_DEPS} )
73         stk? ( media-libs/stk )
74         tcl? (
75                 >=dev-lang/tcl-8.5:0=
76                 >=dev-lang/tk-8.5:0=
77         )
78         utils? ( !media-sound/snd )
79         websocket? ( net-libs/libwebsockets )
80 "
81 DEPEND="${RDEPEND}
82         sys-devel/flex
83         virtual/yacc
84         chua? ( dev-libs/boost )
85         csoundac? ( dev-lang/swig )
86         nls? ( sys-devel/gettext )
87         test? (
88                 dev-util/cunit
89                 ${PYTHON_DEPS}
90         )
91 "
92
93 if [[ ${PV} != "9999" ]]; then
94         DEPEND+="doc? ( app-arch/unzip )"
95 fi
96
97 # requires specific alsa settings
98 RESTRICT="test"
99
100 pkg_pretend() {
101         [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
102 }
103
104 pkg_setup() {
105         [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
106
107         if use python || use test ; then
108                 python-single-r1_pkg_setup
109         fi
110 }
111
112 src_prepare() {
113         cmake-utils_src_prepare
114
115         sed -e '/set(PLUGIN_INSTALL_DIR/s/-${APIVERSION}//' \
116                 -e '/-O3/d' \
117                 -i CMakeLists.txt || die
118
119         local lang
120         for lang in ${IUSE_LANGS} ; do
121                 if ! use linguas_${lang} ; then
122                         sed -i "/compile_po(${lang}/d" po/CMakeLists.txt || die
123                 fi
124         done
125 }
126
127 src_configure() {
128         local mycmakeargs=(
129                 -DUSE_ALSA=$(usex alsa)
130                 -DBUILD_CSBEATS=$(usex beats)
131                 -DBUILD_CHUA_OPCODES=$(usex chua)
132                 -DBUILD_CSOUND_AC=$(usex csoundac)
133                 -DBUILD_CSOUND_AC_LUA_INTERFACE=$(usex csoundac $(usex lua))
134                 -DBUILD_CSOUND_AC_PYTHON_INTERFACE=$(usex csoundac $(usex python))
135                 -DBUILD_CXX_INTERFACE=$(usex cxx)
136                 -DUSE_CURL=$(usex curl)
137                 -DNEW_PARSER_DEBUG=$(usex debug)
138                 -DUSE_DOUBLE=$(usex double-precision)
139                 -DBUILD_DSSI_OPCODES=$(usex dssi)
140                 -DBUILD_FLUID_OPCODES=$(usex fluidsynth)
141                 -DUSE_FLTK=$(usex fltk)
142                 -DBUILD_IMAGE_OPCODES=$(usex image)
143                 -DUSE_JACK=$(usex jack)
144                 -DBUILD_JACK_OPCODES=$(usex jack)
145                 -DBUILD_JAVA_INTERFACE=$(usex java)
146                 -DBUILD_VIRTUAL_KEYBOARD=$(usex keyboard)
147                 -DBUILD_LINEAR_ALGEBRA_OPCODES=$(usex linear)
148                 -DBUILD_LUA_OPCODES=$(usex lua)
149                 -DBUILD_LUA_INTERFACE=$(usex lua)
150                 -DUSE_GETTEXT=$(usex nls)
151                 -DBUILD_OSC_OPCODES=$(usex osc)
152                 -DUSE_OPEN_MP=$(usex openmp)
153                 -DUSE_PORTAUDIO=$(usex portaudio)
154                 -DUSE_PORTMIDI=$(usex portmidi)
155                 -DUSE_PULSEAUDIO=$(usex pulseaudio)
156                 -DBUILD_PYTHON_OPCODES=$(usex python)
157                 -DBUILD_PYTHON_INTERFACE=$(usex python)
158                 -DSCORE_PARSER=$(usex score)
159                 -DBUILD_STATIC_LIBRARY=$(usex static-libs)
160                 -DBUILD_STK_OPCODES=$(usex stk)
161                 -DBUILD_TESTS=$(usex test)
162                 -DBUILD_STATIC_LIBRARY=$(usex test)
163                 -DBUILD_TCLCSOUND=$(usex tcl)
164                 -DBUILD_MULTI_CORE=$(usex threads)
165                 -DBUILD_UTILITIES=$(usex utils)
166                 -DBUILD_WEBSOCKET_OPCODE=$(usex websocket)
167                 -DNEED_PORTTIME=OFF
168                 -DBUILD_RELEASE=ON
169         )
170
171         use python && mycmakeargs+=(
172                 -DPYTHON_MODULE_INSTALL_DIR="$(python_get_sitedir)"
173         )
174
175         [[ $(get_libdir) == "lib64" ]] && mycmakeargs+=(
176                 -DUSE_LIB64=ON
177         )
178
179         cmake-utils_src_configure
180 }
181
182 src_install() {
183         cmake-utils_src_install
184         dodoc -r Release_Notes/.
185
186         # generate env.d file
187         cat > "${T}"/62${PN} <<-_EOF_ || die
188                 OPCODEDIR$(usex double-precision 64 '')="${EPREFIX}/usr/$(get_libdir)/${PN}/plugins$(usex double-precision 64 '')"
189                 CSSTRNGS="${EPREFIX}/usr/share/locale"
190         _EOF_
191         if use stk ; then
192                 echo RAWWAVE_PATH=\"${EPREFIX}/usr/share/csound/rawwaves\" >> "${T}"/62${PN} || die
193         fi
194         doenvd "${T}"/62${PN}
195
196         if use examples ; then
197                 dodoc -r examples
198                 docompress -x /usr/share/doc/${PF}/examples
199         fi
200
201         use samples && dodoc -r samples
202
203         if use vim-syntax ; then
204                 insinto /usr/share/vim/vimfiles/syntax
205                 doins installer/misc/vim/csound_{csd,orc,sco}.vim
206                 insinto /usr/share/vim/vimfiles/plugin
207                 doins installer/misc/vim/csound.vim
208         fi
209
210         # rename extract to csound_extract (bug #247394)
211         mv "${ED%/}"/usr/bin/{,csound_}extract || die
212
213         use python && python_optimize
214
215         # install docs
216         if [[ ${PV} != "9999" ]] && use doc ; then
217                 dodoc "${WORKDIR}"/*.pdf
218                 dodoc -r "${WORKDIR}"/html
219         fi
220 }
221
222 pkg_postinst() {
223         if [[ -z ${REPLACING_VERSIONS} ]] ; then
224                 elog
225                 elog "The extract tool is now installed as csound_extract"
226                 elog "due to collisions with many other packages (bug #247394)."
227                 elog
228         fi
229 }