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 $
8 inherit eutils python versionator flag-o-matic toolchain-funcs
11 IUSE="+game-engine player +elbeem +openexr ffmpeg jpeg2k openal openmp \
12 +dds debug doc fftw jack apidoc sndfile lcms tweak-mode sdl sse \
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}"
21 DESCRIPTION="3D Creation/Animation/Publishing System"
22 HOMEPAGE="http://www.blender.org/"
24 SRC_URI="http://download.blender.org/source/${MY_P}.tar.gz"
28 LICENSE="|| ( GPL-2 BL )"
29 KEYWORDS="~amd64 ~x86"
31 RDEPEND="media-libs/jpeg
36 media-libs/libsamplerate
38 >=media-libs/freetype-2.0
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 )
48 >=media-video/ffmpeg-0.5[x264,xvid,mp3,encode,theora]
49 jpeg2k? ( >=media-video/ffmpeg-0.5[x264,xvid,mp3,encode,theora,jpeg2k] )
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 )"
57 DEPEND=">=dev-util/scons-0.98
60 >=app-doc/doxygen-1.5.7[-nodot]
65 # configure internationalization only if LINGUAS have more
66 # languages than 'en', otherwise must be disabled
67 if [[ ${LINGUAS} != "en" && -n ${LINGUAS} ]]; then
72 S="${WORKDIR}/${MY_P}"
76 [ -z "${UWORD}" ] && UWORD="$1"
78 echo "WITH_BF_${UWORD}=1" | tr '[:lower:]' '[:upper:]' \
79 >> "${S}"/user-config.py
81 echo "WITH_BF_${UWORD}=0" | tr '[:lower:]' '[:upper:]' \
82 >> "${S}"/user-config.py
89 if tc-has-openmp; then
92 ewarn "You are using gcc built without 'openmp' USE."
93 ewarn "Switch CXX to an OpenMP capable compiler."
101 epatch "${FILESDIR}"/${PN}-${SLOT}-desktop.patch
102 epatch "${FILESDIR}"/${PN}-${SLOT}-doxygen.patch
104 # TODO: write a proper Makefile to replace the borked bmake script
105 epatch "${FILESDIR}"/${PN}-${SLOT}-bmake.patch
108 einfo "Removing bundled OpenJPEG ..."
109 rm -r extern/libopenjpeg
112 einfo "Removing bundled Glew ..."
114 epatch "${FILESDIR}"/${PN}-${SLOT}-glew.patch
117 einfo "Removing bundled Eigen2 ..."
119 epatch "${FILESDIR}"/${PN}-${SLOT}-eigen.patch
124 # add system openjpeg into Scons build options.
125 cat <<- EOF >> "${S}"/user-config.py
127 BF_OPENJPEG_INC="/usr/include"
128 BF_OPENJPEG_LIB="openjpeg"
131 # FIX: littlecms includes path aren't specified
133 cat <<- EOF >> "${S}"/user-config.py
134 BF_LCMS_INC="/usr/include/"
136 BF_LCMS_LIBPATH="/usr/lib/"
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
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
152 # configure Elbeem fluid system
153 use elbeem || echo "BF_NO_ELBEEM=1" >> "${S}"/user-config.py
155 # configure Tweak Mode
156 use tweak-mode && echo "BF_TWEAK_MODE=1" >> "${S}"/user-config.py
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
163 blend_with game-engine gameengine
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
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
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
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
185 # reset REL_* variables (useless hardcoded flags)
186 cat <<- EOF >> "${S}"/user-config.py
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' ]
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
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
211 BF_NUMJOBS=${NUMJOBS}
215 WITH_BF_STATICOPENGL=0
216 WITH_BF_OPENMP=${enable_openmp}
219 # configure WITH_BF* Scons build options
235 'sse rayoptimization' \
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
249 '!!! Please add "${S}/scons.config" when filing bugs reports \
252 einfo "Building plugins ..."
253 cd "${WORKDIR}"/install/plugins/ \
254 || die "dir ${WORKDIR}/install/plugins/ does not exists"
257 # FIX: plugins are built without respecting user's LDFLAGS
259 CFLAGS="${CFLAGS} -fPIC" \
260 LDFLAGS="$(raw-ldflags) -Bshareable" \
262 || die "plugins compilation failed"
266 # creating binary wrapper
267 cat <<- EOF >> "${WORKDIR}/install/blender-${SLOT}"
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"
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}
286 mv "${WORKDIR}/install/blender" "${WORKDIR}/install/blender-bin-${SLOT}"
287 doexe "${WORKDIR}/install/blender-bin-${SLOT}"
288 doexe "${WORKDIR}/install/blender-${SLOT}"
290 mv "${WORKDIR}"/install/blenderplayer \
291 "${WORKDIR}/install/blenderplayer-${SLOT}"
292 doexe "${WORKDIR}"/install/blenderplayer
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
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
317 use doc && dodoc release/text/BlenderQuickStart.pdf
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
325 einfo "Generating Blender C/C++ API docs ..."
326 pushd "${S}"/doc > /dev/null
328 doxygen || die "doxygen failed to build API docs."
329 docinto "API/blender"
335 rm -r "${WORKDIR}"/install/{Python-license.txt,icons,GPL-license.txt,copyright.txt}
338 insinto /usr/share/${PN}/${SLOT}
339 doins -r "${WORKDIR}"/install/2.54/*
340 doins release/VERSION
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
351 if [ -h "${ROOT}/usr/$(get_libdir)/blender/plugins/include" ];
353 rm -f "${ROOT}"/usr/$(get_libdir)/blender/plugins/include
359 elog "Blender uses python integration. As such, may have some"
360 elog "inherit risks with running unknown python scripting."
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."
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]"
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"
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."