1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_6 )
8 inherit check-reqs cmake-utils xdg-utils flag-o-matic xdg-utils \
9 pax-utils python-single-r1 toolchain-funcs eapi7-ver
11 DESCRIPTION="3D Creation/Animation/Publishing System"
12 HOMEPAGE="https://www.blender.org"
14 SRC_URI="https://download.blender.org/source/${P}.tar.gz"
16 # Blender can have letters in the version string,
17 # so strip off the letter if it exists.
18 MY_PV="$(ver_cut 1-2)"
21 LICENSE="|| ( GPL-2 BL )"
23 IUSE="+bullet +dds +elbeem +game-engine +openexr collada color-management \
24 cuda cycles debug doc ffmpeg fftw headless jack jemalloc jpeg2k \
25 llvm man ndof nls openal opencl openimageio openmp opensubdiv openvdb \
26 osl player sdl sndfile test tiff valgrind"
27 RESTRICT="!test? ( test )"
29 REQUIRED_USE="${PYTHON_REQUIRED_USE}
31 cycles? ( openexr tiff openimageio )
34 player? ( game-engine !headless )"
36 RDEPEND="${PYTHON_DEPS}
37 >=dev-libs/boost-1.62:=[nls?,threads(+)]
39 $(python_gen_cond_dep '
40 >=dev-python/numpy-1.10.1[${PYTHON_MULTI_USEDEP}]
41 dev-python/requests[${PYTHON_MULTI_USEDEP}]
46 media-libs/libsamplerate
52 collada? ( >=media-libs/opencollada-1.6.18:= )
53 color-management? ( media-libs/opencolorio )
54 cuda? ( dev-util/nvidia-cuda-toolkit:= )
55 ffmpeg? ( media-video/ffmpeg:=[x264,mp3,encode,theora,jpeg2k?] )
56 fftw? ( sci-libs/fftw:3.0= )
62 jack? ( virtual/jack )
63 jemalloc? ( dev-libs/jemalloc:= )
64 jpeg2k? ( media-libs/openjpeg:0 )
65 llvm? ( sys-devel/llvm:= )
70 nls? ( virtual/libiconv )
71 openal? ( media-libs/openal )
72 opencl? ( virtual/opencl )
73 openimageio? ( >=media-libs/openimageio-1.7.0 )
75 >=media-libs/ilmbase-2.2.0:=
76 >=media-libs/openexr-2.2.0:=
78 opensubdiv? ( >=media-libs/opensubdiv-3.3.0:=[cuda=,opencl=] )
80 media-gfx/openvdb[${PYTHON_SINGLE_USEDEP},-abi3-compat(-),abi4-compat(+)]
82 >=dev-libs/c-blosc-1.5.2
84 osl? ( media-libs/osl:= )
85 sdl? ( media-libs/libsdl2[sound,joystick] )
86 sndfile? ( media-libs/libsndfile )
87 tiff? ( media-libs/tiff:0 )
88 valgrind? ( dev-util/valgrind )"
91 >=dev-cpp/eigen-3.2.8:3
95 dev-python/sphinx[latex]
96 dev-texlive/texlive-bibtexextra
97 dev-texlive/texlive-fontsextra
98 dev-texlive/texlive-fontutils
99 dev-texlive/texlive-latex
100 dev-texlive/texlive-latexextra
102 nls? ( sys-devel/gettext )"
105 "${FILESDIR}/${PN}-fix-install-rules.patch"
106 "${FILESDIR}/${P}-gcc-8.patch"
107 "${FILESDIR}/${P}-ffmpeg-4-compat.patch"
108 "${FILESDIR}/${P}-fix-for-gcc9-new-openmp-data-sharing.patch"
111 blender_check_requirements() {
112 [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
115 CHECKREQS_DISK_BUILD="4G" check-reqs_pkg_pretend
120 blender_check_requirements
124 blender_check_requirements
125 python-single-r1_pkg_setup
129 cmake-utils_src_prepare
131 # we don't want static glew, but it's scattered across
132 # multiple files that differ from version to version
133 # !!!CHECK THIS SED ON EVERY VERSION BUMP!!!
135 while IFS="" read -d $'\0' -r file ; do
136 sed -i -e '/-DGLEW_STATIC/d' "${file}" || die
137 done < <(find . -type f -name "CMakeLists.txt")
139 # Disable MS Windows help generation. The variable doesn't do what it
141 sed -e "s|GENERATE_HTMLHELP = YES|GENERATE_HTMLHELP = NO|" \
142 -i doc/doxygen/Doxyfile || die
146 # FIX: forcing '-funsigned-char' fixes an anti-aliasing issue with menu
147 # shadows, see bug #276338 for reference
148 append-flags -funsigned-char
150 # Blender is compatible ABI 4 or less, so use ABI 4.
151 append-cppflags -DOPENVDB_ABI_VERSION_NUMBER=4
154 -DPYTHON_VERSION="${EPYTHON/python/}"
155 -DPYTHON_LIBRARY="$(python_get_library_path)"
156 -DPYTHON_INCLUDE_DIR="$(python_get_includedir)"
157 -DWITH_INSTALL_PORTABLE=OFF
158 -DWITH_PYTHON_INSTALL=OFF
159 -DWITH_PYTHON_INSTALL_NUMPY=OFF
160 -DWITH_STATIC_LIBS=OFF
161 -DWITH_SYSTEM_GLEW=ON
162 -DWITH_SYSTEM_OPENJPEG=ON
163 -DWITH_SYSTEM_EIGEN3=ON
168 -DWITH_BULLET=$(usex bullet)
169 -DWITH_CODEC_FFMPEG=$(usex ffmpeg)
170 -DWITH_CODEC_SNDFILE=$(usex sndfile)
171 -DWITH_CUDA=$(usex cuda)
172 -DWITH_CYCLES_DEVICE_CUDA=$(usex cuda TRUE FALSE)
173 -DWITH_CYCLES=$(usex cycles)
174 -DWITH_CYCLES_OSL=$(usex osl)
175 -DWITH_LLVM=$(usex llvm)
176 -DWITH_FFTW3=$(usex fftw)
177 -DWITH_GAMEENGINE=$(usex game-engine)
178 -DWITH_HEADLESS=$(usex headless)
179 -DWITH_X11=$(usex !headless)
180 -DWITH_IMAGE_DDS=$(usex dds)
181 -DWITH_IMAGE_OPENEXR=$(usex openexr)
182 -DWITH_IMAGE_OPENJPEG=$(usex jpeg2k)
183 -DWITH_IMAGE_TIFF=$(usex tiff)
184 -DWITH_INPUT_NDOF=$(usex ndof)
185 -DWITH_INTERNATIONAL=$(usex nls)
186 -DWITH_JACK=$(usex jack)
187 -DWITH_MOD_FLUID=$(usex elbeem)
188 -DWITH_MOD_OCEANSIM=$(usex fftw)
189 -DWITH_OPENAL=$(usex openal)
190 -DWITH_OPENCL=$(usex opencl)
191 -DWITH_OPENCOLORIO=$(usex color-management)
192 -DWITH_OPENCOLLADA=$(usex collada)
193 -DWITH_OPENIMAGEIO=$(usex openimageio)
194 -DWITH_OPENMP=$(usex openmp)
195 -DWITH_OPENSUBDIV=$(usex opensubdiv)
196 -DWITH_OPENVDB=$(usex openvdb)
197 -DWITH_OPENVDB_BLOSC=$(usex openvdb)
198 -DWITH_PLAYER=$(usex player)
199 -DWITH_SDL=$(usex sdl)
200 -DWITH_CXX_GUARDEDALLOC=$(usex debug)
201 -DWITH_ASSERT_ABORT=$(usex debug)
202 -DWITH_GTESTS=$(usex test)
203 -DWITH_DOC_MANPAGE=$(usex man)
204 -DWITH_MEM_JEMALLOC=$(usex jemalloc)
205 -DWITH_MEM_VALGRIND=$(usex valgrind)
207 cmake-utils_src_configure
211 cmake-utils_src_compile
214 # Workaround for binary drivers.
217 addpredict /dev/nvidiactl
219 einfo "Generating Blender C/C++ API docs ..."
220 cd "${CMAKE_USE_DIR}"/doc/doxygen || die
221 doxygen -u Doxyfile || die
222 doxygen || die "doxygen failed to build API docs."
224 cd "${CMAKE_USE_DIR}" || die
225 einfo "Generating (BPY) Blender Python API docs ..."
226 "${BUILD_DIR}"/bin/blender --background --python doc/python_api/sphinx_doc_gen.py -noaudio || die "sphinx failed."
228 cd "${CMAKE_USE_DIR}"/doc/python_api || die
229 sphinx-build sphinx-in BPY_API || die "sphinx failed."
235 einfo "Running Blender Unit Tests ..."
236 cd "${BUILD_DIR}"/bin/tests || die
245 # Pax mark blender for hardened support.
246 pax-mark m "${CMAKE_BUILD_DIR}"/bin/blender
249 docinto "html/API/python"
250 dodoc -r "${CMAKE_USE_DIR}"/doc/python_api/BPY_API/.
252 docinto "html/API/blender"
253 dodoc -r "${CMAKE_USE_DIR}"/doc/doxygen/html/.
256 cmake-utils_src_install
260 dodoc "${CMAKE_USE_DIR}"/release/text/readme.html
261 rm -r "${ED%/}"/usr/share/doc/blender || die
263 python_fix_shebang "${ED%/}/usr/bin/blender-thumbnailer.py"
264 python_optimize "${ED%/}/usr/share/blender/${MY_PV}/scripts"
269 elog "Blender uses python integration. As such, may have some"
270 elog "inherit risks with running unknown python scripts."
272 elog "It is recommended to change your blender temp directory"
273 elog "from /tmp to /home/user/tmp or another tmp file under your"
274 elog "home directory. This can be done by starting blender, then"
275 elog "dragging the main menu down do display all paths."
278 ewarn "This ebuild does not unbundle the massive amount of 3rd party"
279 ewarn "libraries which are shipped with blender. Note that"
280 ewarn "these have caused security issues in the past."
281 ewarn "If you are concerned about security, file a bug upstream:"
282 ewarn " https://developer.blender.org/"
284 xdg_icon_cache_update
285 xdg_mimeinfo_database_update
289 xdg_icon_cache_update
290 xdg_mimeinfo_database_update
293 ewarn "You may want to remove the following directory."
294 ewarn "~/.config/${PN}/${MY_PV}/cache/"
295 ewarn "It may contain extra render kernels not tracked by portage"