adding 7.0.12 release
[shuber-gentoo-overlay.git] / media-gfx / blender / blender-2.54_beta.ebuild
1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/media-gfx/blender/blender-2.49b.ebuild,v 1.3 2010/05/31 15:02:53 arfrever Exp $
4
5 EAPI=2
6 #NEED_PYTHON="3.1"
7 PYTHON_DEPEND="3:3.1"
8 inherit eutils python versionator flag-o-matic toolchain-funcs
9
10
11 IUSE="+game-engine player +elbeem +openexr ffmpeg jpeg2k openal openmp \
12 +dds debug doc fftw jack apidoc sndfile lcms tweak-mode sdl sse \
13 redcode +zlib iconv"
14
15 LANGS="en ar bg ca cs de el es fi fr hr it ja ko nl pl pt_BR ro ru sr sv uk zh_CN"
16 for X in ${LANGS} ; do
17 IUSE="${IUSE} linguas_${X}"
18 done
19
20
21 DESCRIPTION="3D Creation/Animation/Publishing System"
22 HOMEPAGE="http://www.blender.org/"
23 MY_P=${P//_/-}
24 SRC_URI="http://download.blender.org/source/${MY_P}.tar.gz"
25
26
27 SLOT="2.5"
28 LICENSE="|| ( GPL-2 BL )"
29 KEYWORDS="~amd64 ~x86"
30
31 RDEPEND="media-libs/jpeg
32 media-libs/libpng
33 x11-libs/libXi
34 x11-libs/libX11
35 media-libs/tiff
36 media-libs/libsamplerate
37 virtual/opengl
38 >=media-libs/freetype-2.0
39 virtual/libintl
40 media-libs/glew
41 dev-cpp/eigen:2
42 >=sci-physics/bullet-2.76
43 iconv? ( virtual/libiconv )
44 zlib? ( sys-libs/zlib )
45 sdl? ( media-libs/libsdl[audio,joystick] )
46 openexr? ( media-libs/openexr )
47 ffmpeg? (
48 >=media-video/ffmpeg-0.5[x264,xvid,mp3,encode,theora]
49 jpeg2k? ( >=media-video/ffmpeg-0.5[x264,xvid,mp3,encode,theora,jpeg2k] )
50 )
51 openal? ( >=media-libs/openal-1.6.372 )
52 fftw? ( sci-libs/fftw:3.0 )
53 jack? ( media-sound/jack-audio-connection-kit )
54 sndfile? ( media-libs/libsndfile )
55 lcms? ( media-libs/lcms )"
56
57 DEPEND=">=dev-util/scons-0.98
58 apidoc? (
59 dev-python/sphinx
60 >=app-doc/doxygen-1.5.7[-nodot]
61 )
62 x11-base/xorg-server
63 ${RDEPEND}"
64
65 # configure internationalization only if LINGUAS have more
66 # languages than 'en', otherwise must be disabled
67 if [[ ${LINGUAS} != "en" && -n ${LINGUAS} ]]; then
68 DEPEND="${DEPEND}
69 sys-devel/gettext"
70 fi
71
72 S="${WORKDIR}/${MY_P}"
73
74 blend_with() {
75 local UWORD="$2"
76 [ -z "${UWORD}" ] && UWORD="$1"
77 if useq $1; then
78 echo "WITH_BF_${UWORD}=1" | tr '[:lower:]' '[:upper:]' \
79 >> "${S}"/user-config.py
80 else
81 echo "WITH_BF_${UWORD}=0" | tr '[:lower:]' '[:upper:]' \
82 >> "${S}"/user-config.py
83 fi
84 }
85
86 pkg_setup() {
87 enable_openmp=0
88 if use openmp; then
89 if tc-has-openmp; then
90 enable_openmp=1
91 else
92 ewarn "You are using gcc built without 'openmp' USE."
93 ewarn "Switch CXX to an OpenMP capable compiler."
94 die "Need openmp"
95 fi
96 fi
97 }
98
99 src_prepare() {
100
101 epatch "${FILESDIR}"/${PN}-${SLOT}-desktop.patch
102 epatch "${FILESDIR}"/${PN}-${SLOT}-doxygen.patch
103
104 # TODO: write a proper Makefile to replace the borked bmake script
105 epatch "${FILESDIR}"/${PN}-${SLOT}-bmake.patch
106
107 # OpenJPEG
108 einfo "Removing bundled OpenJPEG ..."
109 rm -r extern/libopenjpeg
110
111 # Glew
112 einfo "Removing bundled Glew ..."
113 rm -r extern/glew
114 epatch "${FILESDIR}"/${PN}-${SLOT}-glew.patch
115
116 # Eigen2
117 einfo "Removing bundled Eigen2 ..."
118 rm -r extern/Eigen2
119 epatch "${FILESDIR}"/${PN}-${SLOT}-eigen.patch
120 }
121
122 src_configure() {
123
124 # add system openjpeg into Scons build options.
125 cat <<- EOF >> "${S}"/user-config.py
126 BF_OPENJPEG="/usr"
127 BF_OPENJPEG_INC="/usr/include"
128 BF_OPENJPEG_LIB="openjpeg"
129 EOF
130
131 # FIX: littlecms includes path aren't specified
132 if use lcms; then
133 cat <<- EOF >> "${S}"/user-config.py
134 BF_LCMS_INC="/usr/include/"
135 BF_LCMS_LIB="lcms"
136 BF_LCMS_LIBPATH="/usr/lib/"
137 EOF
138 fi
139
140 #add iconv into Scons build options.
141 if use !elibc_glibc && use !elibc_uclibc && use iconv; then
142 cat <<- EOF >> "${S}"/user-config.py
143 WITH_BF_ICONV=1
144 BF_ICONV="/usr"
145 EOF
146 fi
147
148 # configure internationalization only if LINGUAS have more
149 # languages than 'en', otherwise must be disabled
150 [[ -z ${LINGUAS} ]] || [[ ${LINGUAS} == "en" ]] && echo "WITH_BF_INTERNATIONAL=0" >> "${S}"/user-config.py
151
152 # configure Elbeem fluid system
153 use elbeem || echo "BF_NO_ELBEEM=1" >> "${S}"/user-config.py
154
155 # configure Tweak Mode
156 use tweak-mode && echo "BF_TWEAK_MODE=1" >> "${S}"/user-config.py
157
158 # FIX: Game Engine module needs to be active to build the Blender Player
159 if ! use game-engine && use player; then
160 elog "Forcing Game Engine [+game-engine] as required by Blender Player [+player]"
161 echo "WITH_BF_GAMEENGINE=1" >> "${S}"/user-config.py
162 else
163 blend_with game-engine gameengine
164 fi
165
166 # set CFLAGS used in /etc/make.conf correctly
167 echo "CFLAGS=[`for i in ${CFLAGS[@]}; do printf "%s \'$i"\',; done`] " \
168 | sed -e "s:,]: ]:" >> "${S}"/user-config.py
169
170 # set CXXFLAGS used in /etc/make.conf correctly
171 local FILTERED_CXXFLAGS="`for i in ${CXXFLAGS[@]}; do printf "%s \'$i"\',; done`"
172 echo "CXXFLAGS=[${FILTERED_CXXFLAGS}]" | sed -e "s:,]: ]:" >> "${S}"/user-config.py
173 echo "BGE_CXXFLAGS=[${FILTERED_CXXFLAGS}]" | sed -e "s:,]: ]:" >> "${S}"/user-config.py
174
175 # reset general options passed to the C/C++ compilers (useless hardcoded flags)
176 # FIX: forcing '-funsigned-char' fixes an anti-aliasing issue with menu
177 # shadows, see bug #276338 for reference
178 echo "CCFLAGS= ['-funsigned-char', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']" >> "${S}"/user-config.py
179
180 # set LDFLAGS used in /etc/make.conf correctly
181 local FILTERED_LDFLAGS="`for i in ${LDFLAGS[@]}; do printf "%s \'$i"\',; done`"
182 echo "LINKFLAGS=[${FILTERED_LDFLAGS}]" | sed -e "s:,]: ]:" >> "${S}"/user-config.py
183 echo "PLATFORM_LINKFLAGS=[${FILTERED_LDFLAGS}]" | sed -e "s:,]: ]:" >> "${S}"/user-config.py
184
185 # reset REL_* variables (useless hardcoded flags)
186 cat <<- EOF >> "${S}"/user-config.py
187 REL_CFLAGS=[]
188 REL_CXXFLAGS=[]
189 REL_CCFLAGS=[]
190 EOF
191
192 # reset warning flags (useless for NON blender developers)
193 cat <<- EOF >> "${S}"/user-config.py
194 C_WARN =[ '-w', '-g0' ]
195 CC_WARN =[ '-w', '-g0' ]
196 CXX_WARN=[ '-w', '-g0' ]
197 EOF
198
199 # detecting -j value from MAKEOPTS
200 local NUMJOBS="$( echo "${MAKEOPTS}" | sed -ne 's,.*-j\([[:digit:]]\+\).*,\1,p' )"
201 [[ -z "${NUMJOBS}" ]] && NUMJOBS=1 # resetting to -j1 for empty MAKEOPTS
202
203 # generic settings which differ from the defaults from linux2-config.py
204 cat <<- EOF >> "${S}"/user-config.py
205 BF_OPENGL_LIB='GL GLU X11 Xi GLEW'
206 BF_INSTALLDIR="../install"
207 WITHOUT_BF_PYTHON_INSTALL=1
208 BF_PYTHON="/usr"
209 BF_BUILDINFO=0
210 BF_QUIET=1
211 BF_NUMJOBS=${NUMJOBS}
212 BF_LINE_OVERWRITE=0
213 WITH_BF_FHS=1
214 WITH_BF_BINRELOC=0
215 WITH_BF_STATICOPENGL=0
216 WITH_BF_OPENMP=${enable_openmp}
217 EOF
218
219 # configure WITH_BF* Scons build options
220 for arg in \
221 'sdl' \
222 'apidoc docs' \
223 'lcms' \
224 'jack' \
225 'sndfile' \
226 'openexr' \
227 'dds' \
228 'fftw fftw3' \
229 'jpeg2k openjpeg' \
230 'openal'\
231 'ffmpeg' \
232 'ffmpeg ogg' \
233 'player' \
234 'collada' \
235 'sse rayoptimization' \
236 'redcode' \
237 'zlib' \
238 'verse' ; do
239 blend_with ${arg}
240 done
241
242 # enable debugging/testing support
243 use debug && echo "BF_DEBUG=1" >> "${S}"/user-config.py
244 use test && echo "BF_UNIT_TEST=1" >> "${S}"/user-config.py
245 }
246
247 src_compile() {
248 scons || die \
249 '!!! Please add "${S}/scons.config" when filing bugs reports \
250 to bugs.gentoo.org'
251
252 einfo "Building plugins ..."
253 cd "${WORKDIR}"/install/plugins/ \
254 || die "dir ${WORKDIR}/install/plugins/ does not exists"
255 chmod 755 bmake
256
257 # FIX: plugins are built without respecting user's LDFLAGS
258 emake \
259 CFLAGS="${CFLAGS} -fPIC" \
260 LDFLAGS="$(raw-ldflags) -Bshareable" \
261 > /dev/null \
262 || die "plugins compilation failed"
263 }
264
265 src_install() {
266 # creating binary wrapper
267 cat <<- EOF >> "${WORKDIR}/install/blender-${SLOT}"
268 #!/bin/sh
269
270 # stop this script if the local blender path is a symlink
271 if [ -L \${HOME}/.blender ]; then
272 echo "Detected a symbolic link for \${HOME}/.blender"
273 echo "Sorry, to avoid dangerous situations, the Blender binary can"
274 echo "not be started until you have removed the symbolic link:"
275 echo " # rm -i \${HOME}/.blender"
276 exit 1
277 fi
278
279 export BLENDER_SYSTEM_SCRIPTS="/usr/share/blender/${SLOT}/scripts"
280 export BLENDER_SYSTEM_DATAFILES="/usr/share/blender/${SLOT}/datafiles"
281 exec /usr/bin/blender-bin-${SLOT}
282 EOF
283
284 # install binaries
285 exeinto /usr/bin/
286 mv "${WORKDIR}/install/blender" "${WORKDIR}/install/blender-bin-${SLOT}"
287 doexe "${WORKDIR}/install/blender-bin-${SLOT}"
288 doexe "${WORKDIR}/install/blender-${SLOT}"
289 if use player; then
290 mv "${WORKDIR}"/install/blenderplayer \
291 "${WORKDIR}/install/blenderplayer-${SLOT}"
292 doexe "${WORKDIR}"/install/blenderplayer
293 fi
294
295 # install plugins
296 exeinto /usr/share/${PN}/${SLOT}/textures
297 doexe "${WORKDIR}"/install/plugins/texture/*.so
298 exeinto /usr/share/${PN}/${SLOT}/sequences
299 doexe "${WORKDIR}"/install/plugins/sequence/*.so
300 insinto /usr/include/${PN}/${SLOT}
301 doins "${WORKDIR}"/install/plugins/include/*.h
302 rm -r "${WORKDIR}"/install/plugins || die
303
304
305
306 # install desktop file
307 insinto /usr/share/pixmaps
308 cp release/freedesktop/icons/scalable/blender.svg \
309 release/freedesktop/icons/scalable/blender-${SLOT}.svg
310 doins release/freedesktop/icons/scalable/blender-${SLOT}.svg
311 insinto /usr/share/applications
312 cp release/freedesktop/blender.desktop \
313 release/freedesktop/blender-${SLOT}.desktop
314 doins release/freedesktop/blender-${SLOT}.desktop
315
316 # install docs
317 use doc && dodoc release/text/BlenderQuickStart.pdf
318 if use apidoc; then
319
320 einfo "Generating (BGE) Blender Game Engine API docs ..."
321 docinto "API/BGE_API"
322 dohtml -r "${WORKDIR}"/install/share/${PN}/${SLOT}/doc/*
323 rm -r "${WORKDIR}"/install/share/${PN}/${SLOT}/doc
324
325 einfo "Generating Blender C/C++ API docs ..."
326 pushd "${S}"/doc > /dev/null
327 doxygen -u Doxyfile
328 doxygen || die "doxygen failed to build API docs."
329 docinto "API/blender"
330 dohtml -r html/*
331 popd > /dev/null
332 fi
333
334 # final cleanup
335 rm -r "${WORKDIR}"/install/{Python-license.txt,icons,GPL-license.txt,copyright.txt}
336
337 # installing blender
338 insinto /usr/share/${PN}/${SLOT}
339 doins -r "${WORKDIR}"/install/2.54/*
340 doins release/VERSION
341
342 # FIX: making all python scripts readable only by group 'users',
343 # so nobody can modify scripts apart root user, but python
344 # cache (*.pyc) can be written and shared across the users.
345 chown root:users -R "${D}/usr/share/${PN}/${SLOT}/scripts" || die
346 chmod 750 -R "${D}/usr/share/${PN}/${SLOT}/scripts" || die
347
348 }
349
350 pkg_preinst(){
351 if [ -h "${ROOT}/usr/$(get_libdir)/blender/plugins/include" ];
352 then
353 rm -f "${ROOT}"/usr/$(get_libdir)/blender/plugins/include
354 fi
355 }
356
357 pkg_postinst(){
358 echo
359 elog "Blender uses python integration. As such, may have some"
360 elog "inherit risks with running unknown python scripting."
361 elog
362 elog "It is recommended to change your blender temp directory"
363 elog "from /tmp to /home/user/tmp or another tmp file under your"
364 elog "home directory. This can be done by starting blender, then"
365 elog "dragging the main menu down do display all paths."
366 elog
367 elog "Blender has its own internal rendering engine but you"
368 elog "can export to external renderers for image computation"
369 elog "like: YafRay[1], sunflow[2], PovRay[3] and luxrender[4]"
370 elog
371 elog "If you need one of them just emerge it:"
372 elog " [1] emerge -av media-gfx/yafray"
373 elog " [2] emerge -av media-gfx/sunflow"
374 elog " [3] emerge -av media-gfx/povray"
375 elog " [4] emerge -av media-gfx/luxrender"
376 elog
377 elog "When setting the Blender paths with the User Preferences"
378 elog "dialog box, remember to NOT declare your home's paths as:"
379 elog "~/.blender, but as: /home/user/.blender; in other words,"
380 elog "DO NOT USE the tilde inside the paths, as Blender is not"
381 elog "able to handle it, ignoring your customizations."
382
383 }