blender-2.78-r1.ebuild 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. PYTHON_COMPAT=( python3_5 )
  5. inherit check-reqs cmake-utils fdo-mime flag-o-matic gnome2-utils \
  6. pax-utils python-single-r1 toolchain-funcs versionator
  7. DESCRIPTION="3D Creation/Animation/Publishing System"
  8. HOMEPAGE="http://www.blender.org"
  9. SRC_URI="http://download.blender.org/source/${P}.tar.gz"
  10. # Blender can have letters in the version string,
  11. # so strip of the letter if it exists.
  12. MY_PV="$(get_version_component_range 1-2)"
  13. SLOT="0"
  14. LICENSE="|| ( GPL-2 BL )"
  15. KEYWORDS="~amd64 ~x86"
  16. IUSE="+boost +bullet +dds +elbeem +game-engine +openexr collada colorio \
  17. cuda cycles debug doc ffmpeg fftw headless jack jemalloc jpeg2k libav \
  18. llvm man ndof nls openal openimageio openmp opensubdiv openvdb \
  19. player sdl sndfile test tiff valgrind"
  20. # OpenCL and nVidia performance is rubbish with Blender
  21. # If you have nVidia, use CUDA.
  22. REQUIRED_USE="${PYTHON_REQUIRED_USE}
  23. player? ( game-engine !headless )
  24. cuda? ( cycles )
  25. cycles? ( boost openexr tiff openimageio )
  26. colorio? ( boost )
  27. openvdb? ( boost )
  28. opensubdiv? ( cuda )
  29. nls? ( boost )
  30. openal? ( boost )
  31. game-engine? ( boost )
  32. ?? ( ffmpeg libav )"
  33. # Since not using OpenCL with nVidia, depend on ATI binary
  34. # blobs as Cycles with OpenCL does not work with any open
  35. # source drivers.
  36. RDEPEND="${PYTHON_DEPS}
  37. dev-libs/lzo:2
  38. >=dev-python/numpy-1.10.1[${PYTHON_USEDEP}]
  39. dev-python/requests[${PYTHON_USEDEP}]
  40. media-libs/freetype
  41. media-libs/glew:*
  42. media-libs/libpng:0=
  43. media-libs/libsamplerate
  44. sys-libs/zlib
  45. virtual/glu
  46. virtual/jpeg:0=
  47. virtual/libintl
  48. virtual/opengl
  49. boost? ( >=dev-libs/boost-1.62:=[nls?,threads(+)] )
  50. collada? ( >=media-libs/opencollada-1.6.18:= )
  51. colorio? ( >=media-libs/opencolorio-1.0.9-r2 )
  52. cuda? ( dev-util/nvidia-cuda-toolkit:= )
  53. ffmpeg? ( media-video/ffmpeg:=[x264,mp3,encode,theora,jpeg2k?] )
  54. libav? ( >=media-video/libav-11.3:=[x264,mp3,encode,theora,jpeg2k?] )
  55. fftw? ( sci-libs/fftw:3.0= )
  56. !headless? (
  57. x11-libs/libX11
  58. x11-libs/libXi
  59. x11-libs/libXxf86vm
  60. )
  61. jack? ( media-sound/jack-audio-connection-kit )
  62. jemalloc? ( dev-libs/jemalloc:= )
  63. jpeg2k? ( media-libs/openjpeg:0 )
  64. llvm? ( sys-devel/llvm )
  65. ndof? (
  66. app-misc/spacenavd
  67. dev-libs/libspnav
  68. )
  69. nls? ( virtual/libiconv )
  70. openal? ( media-libs/openal )
  71. openimageio? ( >=media-libs/openimageio-1.6.9 )
  72. openexr? (
  73. >=media-libs/ilmbase-2.2.0:=
  74. >=media-libs/openexr-2.2.0:=
  75. )
  76. opensubdiv? ( media-libs/opensubdiv[cuda=] )
  77. openvdb? (
  78. media-gfx/openvdb[${PYTHON_USEDEP},abi3-compat(+),openvdb-compression(+)]
  79. dev-cpp/tbb
  80. >=dev-libs/c-blosc-1.5.2
  81. )
  82. sdl? ( media-libs/libsdl2[sound,joystick] )
  83. sndfile? ( media-libs/libsndfile )
  84. tiff? ( media-libs/tiff:0 )
  85. valgrind? ( dev-util/valgrind )"
  86. DEPEND="${RDEPEND}
  87. >=dev-cpp/eigen-3.2.8:3
  88. nls? ( sys-devel/gettext )
  89. doc? (
  90. app-doc/doxygen[-nodot(-),dot(+),latex]
  91. dev-python/sphinx[latex]
  92. )"
  93. PATCHES=( "${FILESDIR}"/${P}-C++11-build-fix.patch
  94. "${FILESDIR}"/${PN}-fix-install-rules.patch
  95. "${FILESDIR}"/${P}-eigen-3.3.1.patch )
  96. blender_check_requirements() {
  97. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  98. if use doc; then
  99. CHECKREQS_DISK_BUILD="4G" check-reqs_pkg_pretend
  100. fi
  101. }
  102. pkg_pretend() {
  103. blender_check_requirements
  104. }
  105. pkg_setup() {
  106. blender_check_requirements
  107. python-single-r1_pkg_setup
  108. }
  109. src_prepare() {
  110. default
  111. # we don't want static glew, but it's scattered across
  112. # multiple files that differ from version to version
  113. # !!!CHECK THIS SED ON EVERY VERSION BUMP!!!
  114. local file
  115. while IFS="" read -d $'\0' -r file ; do
  116. sed -i -e '/-DGLEW_STATIC/d' "${file}" || die
  117. done < <(find . -type f -name "CMakeLists.txt")
  118. # Disable MS Windows help generation. The variable doesn't do what it
  119. # it sounds like.
  120. sed -e "s|GENERATE_HTMLHELP = YES|GENERATE_HTMLHELP = NO|" \
  121. -i doc/doxygen/Doxyfile || die
  122. }
  123. src_configure() {
  124. # FIX: forcing '-funsigned-char' fixes an anti-aliasing issue with menu
  125. # shadows, see bug #276338 for reference
  126. append-flags -funsigned-char
  127. append-lfs-flags
  128. append-cppflags -DOPENVDB_3_ABI_COMPATIBLE
  129. local mycmakeargs=(
  130. -DPYTHON_VERSION="${EPYTHON/python/}"
  131. -DPYTHON_LIBRARY="$(python_get_library_path)"
  132. -DPYTHON_INCLUDE_DIR="$(python_get_includedir)"
  133. -DWITH_INSTALL_PORTABLE=OFF
  134. -DWITH_PYTHON_INSTALL=OFF
  135. -DWITH_PYTHON_INSTALL_NUMPY=OFF
  136. -DWITH_STATIC_LIBS=OFF
  137. -DWITH_SYSTEM_GLEW=ON
  138. -DWITH_SYSTEM_OPENJPEG=ON
  139. -DWITH_SYSTEM_EIGEN3=ON
  140. -DWITH_SYSTEM_LZO=ON
  141. -DWITH_C11=ON
  142. -DWITH_CXX11=ON
  143. -DWITH_BOOST=$(usex boost)
  144. -DWITH_BULLET=$(usex bullet)
  145. -DWITH_CODEC_FFMPEG=$(usex ffmpeg)
  146. -DWITH_CODEC_SNDFILE=$(usex sndfile)
  147. -DWITH_CUDA=$(usex cuda)
  148. -DWITH_CYCLES_DEVICE_CUDA=$(usex cuda TRUE FALSE)
  149. -DWITH_CYCLES=$(usex cycles)
  150. -DWITH_CYCLES_OSL=OFF
  151. -DWITH_LLVM=$(usex llvm)
  152. -DWITH_FFTW3=$(usex fftw)
  153. -DWITH_GAMEENGINE=$(usex game-engine)
  154. -DWITH_HEADLESS=$(usex headless)
  155. -DWITH_X11=$(usex !headless)
  156. -DWITH_IMAGE_DDS=$(usex dds)
  157. -DWITH_IMAGE_OPENEXR=$(usex openexr)
  158. -DWITH_IMAGE_OPENJPEG=$(usex jpeg2k)
  159. -DWITH_IMAGE_TIFF=$(usex tiff)
  160. -DWITH_INPUT_NDOF=$(usex ndof)
  161. -DWITH_INTERNATIONAL=$(usex nls)
  162. -DWITH_JACK=$(usex jack)
  163. -DWITH_MOD_FLUID=$(usex elbeem)
  164. -DWITH_MOD_OCEANSIM=$(usex fftw)
  165. -DWITH_OPENAL=$(usex openal)
  166. -DWITH_OPENCL=OFF
  167. -DWITH_CYCLES_DEVICE_OPENCL=OFF
  168. -DWITH_OPENCOLORIO=$(usex colorio)
  169. -DWITH_OPENCOLLADA=$(usex collada)
  170. -DWITH_OPENIMAGEIO=$(usex openimageio)
  171. -DWITH_OPENMP=$(usex openmp)
  172. -DWITH_OPENSUBDIV=$(usex opensubdiv)
  173. -DWITH_OPENVDB=$(usex openvdb)
  174. -DWITH_OPENVDB_BLOSC=$(usex openvdb)
  175. -DWITH_PLAYER=$(usex player)
  176. -DWITH_SDL=$(usex sdl)
  177. -DWITH_CXX_GUARDEDALLOC=$(usex debug)
  178. -DWITH_ASSERT_ABORT=$(usex debug)
  179. -DWITH_GTESTS=$(usex test)
  180. -DWITH_DOC_MANPAGE=$(usex man)
  181. -DWITH_MEM_JEMALLOC=$(usex jemalloc)
  182. -DWITH_MEM_VALGRIND=$(usex valgrind)
  183. )
  184. cmake-utils_src_configure
  185. }
  186. src_compile() {
  187. cmake-utils_src_compile
  188. if use doc; then
  189. # Workaround for binary drivers.
  190. addpredict /dev/ati
  191. addpredict /dev/nvidiactl
  192. einfo "Generating Blender C/C++ API docs ..."
  193. cd "${CMAKE_USE_DIR}"/doc/doxygen || die
  194. doxygen -u Doxyfile || die
  195. doxygen || die "doxygen failed to build API docs."
  196. cd "${CMAKE_USE_DIR}" || die
  197. einfo "Generating (BPY) Blender Python API docs ..."
  198. "${BUILD_DIR}"/bin/blender --background --python doc/python_api/sphinx_doc_gen.py -noaudio || die "sphinx failed."
  199. cd "${CMAKE_USE_DIR}"/doc/python_api || die
  200. sphinx-build sphinx-in BPY_API || die "sphinx failed."
  201. fi
  202. }
  203. src_test() {
  204. if use test; then
  205. einfo "Running Blender Unit Tests ..."
  206. cd "${BUILD_DIR}"/bin/tests || die
  207. local f
  208. for f in *_test; do
  209. ./"${f}" || die
  210. done
  211. fi
  212. }
  213. src_install() {
  214. # Pax mark blender for hardened support.
  215. pax-mark m "${CMAKE_BUILD_DIR}"/bin/blender
  216. if use doc; then
  217. docinto "html/API/python"
  218. dodoc -r "${CMAKE_USE_DIR}"/doc/python_api/BPY_API/.
  219. docinto "html/API/blender"
  220. dodoc -r "${CMAKE_USE_DIR}"/doc/doxygen/html/.
  221. fi
  222. cmake-utils_src_install
  223. # fix doc installdir
  224. docinto "html"
  225. dodoc "${CMAKE_USE_DIR}"/release/text/readme.html
  226. rm -r "${ED%/}"/usr/share/doc/blender || die
  227. python_fix_shebang "${ED%/}/usr/bin/blender-thumbnailer.py"
  228. python_optimize "${ED%/}/usr/share/blender/${MY_PV}/scripts"
  229. }
  230. pkg_preinst() {
  231. gnome2_icon_savelist
  232. }
  233. pkg_postinst() {
  234. elog
  235. elog "Blender uses python integration. As such, may have some"
  236. elog "inherit risks with running unknown python scripts."
  237. elog
  238. elog "It is recommended to change your blender temp directory"
  239. elog "from /tmp to /home/user/tmp or another tmp file under your"
  240. elog "home directory. This can be done by starting blender, then"
  241. elog "dragging the main menu down do display all paths."
  242. elog
  243. ewarn
  244. ewarn "This ebuild does not unbundle the massive amount of 3rd party"
  245. ewarn "libraries which are shipped with blender. Note that"
  246. ewarn "these have caused security issues in the past."
  247. ewarn "If you are concerned about security, file a bug upstream:"
  248. ewarn " https://developer.blender.org/"
  249. ewarn
  250. gnome2_icon_cache_update
  251. fdo-mime_desktop_database_update
  252. }
  253. pkg_postrm() {
  254. gnome2_icon_cache_update
  255. fdo-mime_desktop_database_update
  256. ewarn ""
  257. ewarn "You may want to remove the following directory."
  258. ewarn "~/.config/${PN}/${MY_PV}/cache/"
  259. ewarn "It may contain extra render kernels not tracked by portage"
  260. ewarn ""
  261. }