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}"
20 DESCRIPTION="3D Creation/Animation/Publishing System"
21 HOMEPAGE="http://www.blender.org"
24 SRC_URI="http://download.blender.org/source/${MY_P}.tar.gz"
27 LICENSE="|| ( GPL-2 BL )"
30 RDEPEND="media-libs/jpeg
35 media-libs/libsamplerate
37 >=media-libs/freetype-2.0
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 )
47 >=media-video/ffmpeg-0.5[x264,xvid,mp3,encode,theora]
48 jpeg2k? ( >=media-video/ffmpeg-0.5[x264,xvid,mp3,encode,theora,jpeg2k] )
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 )"
56 DEPEND=">=dev-util/scons-0.98
59 >=app-doc/doxygen-1.5.7[-nodot]
64 # configure internationalization only if LINGUAS have more
65 # languages than 'en', otherwise must be disabled
66 if [[ ${LINGUAS} != "en" && -n ${LINGUAS} ]]; then
71 S="${WORKDIR}/${MY_P}"
75 [ -z "${UWORD}" ] && UWORD="$1"
77 echo "WITH_BF_${UWORD}=1" | tr '[:lower:]' '[:upper:]' \
78 >> "${S}"/user-config.py
80 echo "WITH_BF_${UWORD}=0" | tr '[:lower:]' '[:upper:]' \
81 >> "${S}"/user-config.py
88 if tc-has-openmp; then
91 ewarn "You are using gcc built without 'openmp' USE."
92 ewarn "Switch CXX to an OpenMP capable compiler."
99 epatch "${FILESDIR}"/${PN}-${SLOT}-desktop.patch
100 epatch "${FILESDIR}"/${PN}-${SLOT}-doxygen.patch
102 # TODO: write a proper Makefile to replace the borked bmake script
103 epatch "${FILESDIR}"/${PN}-${SLOT}-bmake.patch
106 einfo "Removing bundled OpenJPEG ..."
107 rm -r extern/libopenjpeg
110 einfo "Removing bundled Glew ..."
112 epatch "${FILESDIR}"/${PN}-${SLOT}-glew.patch
115 einfo "Removing bundled Eigen2 ..."
117 epatch "${FILESDIR}"/${PN}-${SLOT}-eigen.patch
121 # add system openjpeg into Scons build options.
122 cat <<- EOF >> "${S}"/user-config.py
124 BF_OPENJPEG_INC="/usr/include"
125 BF_OPENJPEG_LIB="openjpeg"
128 # FIX: littlecms includes path aren't specified
130 cat <<- EOF >> "${S}"/user-config.py
131 BF_LCMS_INC="/usr/include/"
133 BF_LCMS_LIBPATH="/usr/lib/"
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
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
149 # configure Elbeem fluid system
150 use elbeem || echo "BF_NO_ELBEEM=1" >> "${S}"/user-config.py
152 # configure Tweak Mode
153 use tweak-mode && echo "BF_TWEAK_MODE=1" >> "${S}"/user-config.py
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
160 blend_with game-engine gameengine
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
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
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
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
182 # reset REL_* variables (useless hardcoded flags)
183 cat <<- EOF >> "${S}"/user-config.py
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' ]
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
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
208 BF_NUMJOBS=${NUMJOBS}
212 WITH_BF_STATICOPENGL=0
213 WITH_BF_OPENMP=${enable_openmp}
216 # configure WITH_BF* Scons build options
232 'sse rayoptimization' \
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
246 '!!! Please add "${S}/scons.config" when filing bugs reports \
249 einfo "Building plugins ..."
250 cd "${WORKDIR}/install/${MY_PV}/plugins/" \
251 || die "dir ${WORKDIR}/install/plugins/ do not exists"
254 # FIX: plugins are built without respecting user's LDFLAGS
256 CFLAGS="${CFLAGS} -fPIC" \
257 LDFLAGS="$(raw-ldflags) -Bshareable" \
259 || die "plugins compilation failed"
263 # creating binary wrapper
264 cat <<- EOF >> "${WORKDIR}/install/blender-${SLOT}"
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"
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}
283 mv "${WORKDIR}/install/blender" "${WORKDIR}/install/blender-bin-${SLOT}"
284 doexe "${WORKDIR}/install/blender-bin-${SLOT}"
285 doexe "${WORKDIR}/install/blender-${SLOT}"
287 mv "${WORKDIR}"/install/blenderplayer \
288 "${WORKDIR}/install/blenderplayer-${SLOT}"
289 doexe "${WORKDIR}"/install/blenderplayer
293 PLUGINDIR="${WORKDIR}/install/${MY_PV}/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
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
316 use doc && dodoc release/text/BlenderQuickStart.pdf
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
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/${MY_PV}/*
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
350 if [ -h "${ROOT}/usr/$(get_libdir)/blender/plugins/include" ];
352 rm -r "${ROOT}"/usr/$(get_libdir)/blender/plugins/include
358 elog "Blender uses python integration. As such, may have some"
359 elog "inherit risks with running unknown python scripting."
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."
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]"
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"
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."