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