x265-2.2.ebuild 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit cmake-utils multilib-minimal multilib multibuild flag-o-matic
  5. if [[ ${PV} = 9999* ]]; then
  6. inherit mercurial
  7. EHG_REPO_URI="https://bitbucket.org/multicoreware/x265"
  8. else
  9. SRC_URI="
  10. https://bitbucket.org/multicoreware/x265/downloads/${PN}_${PV}.tar.gz
  11. http://ftp.videolan.org/pub/videolan/x265/${PN}_${PV}.tar.gz"
  12. KEYWORDS="amd64 arm hppa ppc ppc64 x86"
  13. fi
  14. DESCRIPTION="Library for encoding video streams into the H.265/HEVC format"
  15. HOMEPAGE="http://x265.org/"
  16. LICENSE="GPL-2"
  17. # subslot = libx265 soname
  18. SLOT="0/102"
  19. IUSE="+10bit +12bit neon numa pic power8 test"
  20. ASM_DEPEND=">=dev-lang/yasm-1.2.0"
  21. RDEPEND="numa? ( >=sys-process/numactl-2.0.10-r1[${MULTILIB_USEDEP}] )"
  22. DEPEND="${RDEPEND}
  23. abi_x86_32? ( ${ASM_DEPEND} )
  24. abi_x86_64? ( ${ASM_DEPEND} )"
  25. PATCHES=( "${FILESDIR}/arm.patch" "${FILESDIR}/neon.patch" "${FILESDIR}/ppc64.patch" )
  26. src_unpack() {
  27. if [[ ${PV} = 9999* ]]; then
  28. mercurial_src_unpack
  29. # Can't set it at global scope due to mercurial.eclass limitations...
  30. export S=${WORKDIR}/${P}/source
  31. else
  32. unpack ${A}
  33. export S="$(echo "${WORKDIR}/${PN}_"*"/source")"
  34. fi
  35. }
  36. # By default, the library and the encoder is configured for only one output bit
  37. # depth. Meaning, one has to rebuild libx265 if (s)he wants to produce HEVC
  38. # files with a different bit depth, which is annoying. However, upstream
  39. # supports proper namespacing for 8bits, 10bits & 12bits HEVC and linking all
  40. # that together so that the resulting library can produce all three of them
  41. # instead of only one.
  42. # The API requires the bit depth parameter, so that libx265 can then chose which
  43. # variant of the encoder to use.
  44. # To achieve this, we have to build one (static) library for each non-main
  45. # variant, and link it into the main library.
  46. # Upstream documents using the 8bit variant as main library, hence we do not
  47. # allow disabling it: "main" *MUST* come last in the following list.
  48. x265_get_variants() {
  49. local variants=""
  50. use 12bit && variants+="main12 "
  51. use 10bit && variants+="main10 "
  52. variants+="main"
  53. echo "${variants}"
  54. }
  55. x265_variant_src_configure() {
  56. mkdir -p "${BUILD_DIR}" || die
  57. pushd "${BUILD_DIR}" >/dev/null || die
  58. local mycmakeargs=( "${myabicmakeargs[@]}" )
  59. case "${MULTIBUILD_VARIANT}" in
  60. "main12")
  61. mycmakeargs+=(
  62. -DHIGH_BIT_DEPTH=ON
  63. -DEXPORT_C_API=OFF
  64. -DENABLE_SHARED=OFF
  65. -DENABLE_CLI=OFF
  66. -DMAIN12=ON
  67. )
  68. if [[ ${ABI} = x86 ]] ; then
  69. mycmakeargs+=( -DENABLE_ASSEMBLY=OFF )
  70. fi
  71. if [[ ${ABI} = arm ]] ; then
  72. # 589674
  73. mycmakeargs+=( -DENABLE_ASSEMBLY=OFF )
  74. fi
  75. if [[ ${ABI} = ppc64 ]] ; then
  76. # https://bugs.gentoo.org/show_bug.cgi?id=607802#c5
  77. mycmakeargs+=( -DENABLE_ASSEMBLY=OFF -DENABLE_ALTIVEC=OFF )
  78. fi
  79. ;;
  80. "main10")
  81. mycmakeargs+=(
  82. -DHIGH_BIT_DEPTH=ON
  83. -DEXPORT_C_API=OFF
  84. -DENABLE_SHARED=OFF
  85. -DENABLE_CLI=OFF
  86. )
  87. if [[ ${ABI} = x86 ]] ; then
  88. mycmakeargs+=( -DENABLE_ASSEMBLY=OFF )
  89. fi
  90. if [[ ${ABI} = arm ]] ; then
  91. # 589674
  92. mycmakeargs+=( -DENABLE_ASSEMBLY=OFF )
  93. fi
  94. if [[ ${ABI} = ppc64 ]] ; then
  95. # https://bugs.gentoo.org/show_bug.cgi?id=607802#c5
  96. mycmakeargs+=( -DENABLE_ASSEMBLY=OFF -DENABLE_ALTIVEC=OFF )
  97. fi
  98. ;;
  99. "main")
  100. if (( "${#MULTIBUILD_VARIANTS[@]}" > 1 )) ; then
  101. local myvariants=( "${MULTIBUILD_VARIANTS[@]}" )
  102. unset myvariants[${#MULTIBUILD_VARIANTS[@]}-1]
  103. local liblist=""
  104. for v in "${myvariants[@]}" ; do
  105. ln -s "${BUILD_DIR%-*}-${v}/libx265.a" "libx265_${v}.a" || die
  106. liblist+="libx265_${v}.a;"
  107. done
  108. mycmakeargs+=(
  109. -DEXTRA_LIB="${liblist}"
  110. -DEXTRA_LINK_FLAGS=-L.
  111. -DLINKED_10BIT=$(usex 10bit)
  112. -DLINKED_12BIT=$(usex 12bit)
  113. )
  114. fi
  115. ;;
  116. *)
  117. die "Unknown variant: ${MULTIBUILD_VARIANT}";;
  118. esac
  119. cmake-utils_src_configure
  120. popd >/dev/null || die
  121. }
  122. multilib_src_configure() {
  123. append-cflags -fPIC
  124. append-cxxflags -fPIC
  125. local myabicmakeargs=(
  126. $(cmake-utils_use_enable test TESTS)
  127. $(multilib_is_native_abi || echo "-DENABLE_CLI=OFF")
  128. -DENABLE_LIBNUMA=$(usex numa ON OFF)
  129. -DCPU_POWER8=$(usex power8 ON OFF)
  130. -DENABLE_ALTIVEC=$(usex power8 ON OFF)
  131. -DLIB_INSTALL_DIR="$(get_libdir)"
  132. )
  133. if [[ ${ABI} = x86 ]] ; then
  134. # Bug #528202
  135. if use pic ; then
  136. ewarn "PIC has been requested but x86 asm is not PIC-safe, disabling it."
  137. myabicmakeargs+=( -DENABLE_ASSEMBLY=OFF )
  138. fi
  139. elif [[ ${ABI} = x32 ]] ; then
  140. # bug #510890
  141. myabicmakeargs+=( -DENABLE_ASSEMBLY=OFF )
  142. elif [[ ${ABI} = arm ]] ; then
  143. myabicmakeargs+=( -DENABLE_ASSEMBLY=$(usex pic OFF $(usex neon ON OFF)) )
  144. use neon && use pic && ewarn "PIC has been requested but arm neon asm is not PIC-safe, disabling it."
  145. fi
  146. local MULTIBUILD_VARIANTS=( $(x265_get_variants) )
  147. multibuild_foreach_variant x265_variant_src_configure
  148. }
  149. multilib_src_compile() {
  150. local MULTIBUILD_VARIANTS=( $(x265_get_variants) )
  151. multibuild_foreach_variant cmake-utils_src_compile
  152. }
  153. x265_variant_src_test() {
  154. if [ -x "${BUILD_DIR}/test/TestBench" ] ; then
  155. "${BUILD_DIR}/test/TestBench" || die
  156. else
  157. einfo "Unit tests check only assembly."
  158. einfo "You do not seem to have any for ABI=${ABI}, x265 variant=${MULTIBUILD_VARIANT}"
  159. einfo "Skipping tests."
  160. fi
  161. }
  162. multilib_src_test() {
  163. local MULTIBUILD_VARIANTS=( $(x265_get_variants) )
  164. multibuild_foreach_variant x265_variant_src_test
  165. }
  166. multilib_src_install() {
  167. # Install only "main" variant since the others are already linked into it.
  168. local MULTIBUILD_VARIANTS=( "main" )
  169. multibuild_foreach_variant cmake-utils_src_install
  170. }
  171. multilib_src_install_all() {
  172. dodoc -r "${S}/../doc/"*
  173. }