opencv-2.4.13.ebuild 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit toolchain-funcs cmake-utils python-single-r1 java-pkg-opt-2 java-ant-2
  6. DESCRIPTION="A collection of algorithms and sample code for various computer vision problems"
  7. HOMEPAGE="http://opencv.org"
  8. SRC_URI="https://github.com/Itseez/opencv/archive/${PV}.zip -> ${P}.zip"
  9. LICENSE="BSD"
  10. SLOT="0/2.4"
  11. KEYWORDS="amd64 ~arm ~ppc ~ppc64 x86 ~amd64-linux"
  12. IUSE="cuda +eigen examples ffmpeg gstreamer gtk ieee1394 ipp jpeg jpeg2k libav opencl openexr opengl openmp pch png +python qt4 qt5 testprograms threads tiff v4l vtk xine"
  13. REQUIRED_USE="
  14. python? ( ${PYTHON_REQUIRED_USE} )
  15. ?? ( qt4 qt5 )
  16. "
  17. # The following logic is intrinsic in the build system, but we do not enforce
  18. # it on the useflags since this just blocks emerging pointlessly:
  19. # gtk? ( !qt4 )
  20. # opengl? ( || ( gtk qt4 ) )
  21. # openmp? ( !threads )
  22. RDEPEND="
  23. app-arch/bzip2
  24. sys-libs/zlib
  25. cuda? ( >=dev-util/nvidia-cuda-toolkit-5.5 )
  26. ffmpeg? (
  27. libav? ( media-video/libav:0= )
  28. !libav? ( media-video/ffmpeg:0= )
  29. )
  30. gstreamer? (
  31. media-libs/gstreamer:1.0
  32. media-libs/gst-plugins-base:1.0
  33. )
  34. gtk? (
  35. dev-libs/glib:2
  36. x11-libs/gtk+:2
  37. opengl? ( x11-libs/gtkglext )
  38. )
  39. java? ( >=virtual/jre-1.6:* )
  40. jpeg? ( virtual/jpeg:0 )
  41. jpeg2k? ( media-libs/jasper:= )
  42. ieee1394? (
  43. media-libs/libdc1394
  44. sys-libs/libraw1394
  45. )
  46. ipp? ( sci-libs/ipp )
  47. opencl? ( virtual/opencl )
  48. openexr? ( media-libs/openexr )
  49. opengl? ( virtual/opengl virtual/glu )
  50. png? ( media-libs/libpng:0= )
  51. python? ( ${PYTHON_DEPS} dev-python/numpy[${PYTHON_USEDEP}] )
  52. qt4? (
  53. dev-qt/qtgui:4
  54. dev-qt/qttest:4
  55. opengl? ( dev-qt/qtopengl:4 )
  56. )
  57. qt5? (
  58. dev-qt/qtgui:5
  59. dev-qt/qttest:5
  60. dev-qt/qtconcurrent:5
  61. opengl? ( dev-qt/qtopengl:5 )
  62. )
  63. threads? ( dev-cpp/tbb )
  64. tiff? ( media-libs/tiff:0 )
  65. v4l? ( >=media-libs/libv4l-0.8.3 )
  66. vtk? ( sci-libs/vtk[rendering] )
  67. xine? ( media-libs/xine-lib )
  68. "
  69. DEPEND="${RDEPEND}
  70. virtual/pkgconfig
  71. eigen? ( dev-cpp/eigen:3 )
  72. java? ( >=virtual/jdk-1.6 )
  73. "
  74. PATCHES=(
  75. "${FILESDIR}/${PN}-2.3.1a-libav-0.7.patch"
  76. "${FILESDIR}/${PN}-2.4.3-gcc47.patch"
  77. "${FILESDIR}/${PN}-2.4.2-cflags.patch"
  78. "${FILESDIR}/${PN}-2.4.8-javamagic.patch"
  79. "${FILESDIR}/${PN}-2.4.9-cuda-pkg-config.patch"
  80. "${FILESDIR}/${PN}-3.0.0-gles.patch"
  81. )
  82. #"${FILESDIR}/${P}-git-autodetect.patch
  83. pkg_setup() {
  84. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  85. use python && python-single-r1_pkg_setup
  86. java-pkg-opt-2_pkg_setup
  87. }
  88. src_prepare() {
  89. cmake-utils_src_prepare
  90. # remove bundled stuff
  91. rm -rf 3rdparty || die "Removing 3rd party components failed"
  92. sed -i \
  93. -e '/add_subdirectory(3rdparty)/ d' \
  94. CMakeLists.txt || die
  95. java-pkg-opt-2_src_prepare
  96. }
  97. src_configure() {
  98. JAVA_ANT_ENCODING="iso-8859-1"
  99. # set encoding so even this cmake build will pick it up.
  100. export ANT_OPTS+=" -Dfile.encoding=iso-8859-1"
  101. java-ant-2_src_configure
  102. # please dont sort here, order is the same as in CMakeLists.txt
  103. local mycmakeargs=(
  104. # the optinal dependency libraries
  105. -DWITH_1394=$(usex ieee1394)
  106. -DWITH_AVFOUNDATION=OFF
  107. -DWITH_VTK=$(usex vtk)
  108. -DWITH_EIGEN=$(usex eigen)
  109. -DWITH_VFW=OFF
  110. -DWITH_FFMPEG=$(usex ffmpeg)
  111. -DWITH_GSTREAMER=$(usex gstreamer)
  112. -DWITH_GSTREAMER_0_10=OFF
  113. -DWITH_GTK=$(usex gtk)
  114. -DWITH_IMAGEIO=OFF
  115. -DWITH_IPP=$(usex ipp)
  116. -DWITH_JASPER=$(usex jpeg2k)
  117. -DWITH_JPEG=$(usex jpeg)
  118. -DWITH_OPENEXR=$(usex openexr)
  119. -DWITH_OPENGL=$(usex opengl)
  120. -DWITH_OPENCL=$(usex opencl)
  121. -DWITH_OPENNI=OFF
  122. -DWITH_PNG=$(usex png)
  123. -DWITH_PVAPI=OFF
  124. -DWITH_GIGEAPI=OFF
  125. -DWITH_WIN32UI=OFF
  126. -DWITH_QUICKTIME=OFF
  127. -DWITH_TBB=$(usex threads)
  128. -DWITH_OPENMP=$(usex openmp)
  129. -DWITH_CSTRIPES=OFF
  130. -DWITH_TIFF=$(usex tiff)
  131. -DWITH_UNICAP=OFF
  132. -DWITH_V4L=$(usex v4l)
  133. -DWITH_LIBV4L=$(usex v4l)
  134. -DWITH_DSHOW=ON
  135. -DWITH_MSMF=OFF
  136. -DWITH_XIMEA=OFF
  137. -DWITH_XINE=$(usex xine)
  138. -DWITH_OPENCL=$(usex opencl)
  139. -DWITH_OPENCLAMDFFT=$(usex opencl)
  140. -DWITH_OPENCLAMDBLAS=$(usex opencl)
  141. -DWITH_INTELPERC=OFF
  142. -DWITH_JAVA=$(usex java)
  143. # the build components
  144. -DBUILD_SHARED_LIBS=ON
  145. -DBUILD_ANDROID_EXAMPLES=OFF
  146. -DBUILD_DOCS=OFF #too much dark magic in cmakelists
  147. -DBUILD_EXAMPLES=$(usex examples)
  148. -DBUILD_PERF_TESTS=OFF
  149. -DBUILD_TESTS=$(usex testprograms)
  150. # install examples
  151. -DINSTALL_C_EXAMPLES=$(usex examples)
  152. -DINSTALL_TESTS=$(usex testprograms)
  153. # build options
  154. -DENABLE_PRECOMPILED_HEADERS=$(usex pch)
  155. -DENABLE_SOLUTION_FOLDERS=OFF
  156. -DENABLE_PROFILING=OFF
  157. -DENABLE_COVERAGE=OFF
  158. -DENABLE_OMIT_FRAME_POINTER=OFF
  159. -DENABLE_FAST_MATH=OFF #
  160. -DENABLE_SSE=OFF # these options do nothing but
  161. -DENABLE_SSE2=OFF # add params to CFLAGS
  162. -DENABLE_SSE3=OFF
  163. -DENABLE_SSSE3=OFF
  164. -DENABLE_SSE41=OFF
  165. -DENABLE_SSE42=OFF
  166. -DOPENCV_EXTRA_FLAGS_RELEASE="" # black magic
  167. )
  168. if use qt4; then
  169. mycmakeargs+=( -DWITH_QT=4 )
  170. elif use qt5; then
  171. mycmakeargs+=( -DWITH_QT=5 )
  172. else
  173. mycmakeargs+=( -DWITH_QT=OFF )
  174. fi
  175. if use cuda; then
  176. if [[ "$(gcc-version)" > "4.8" ]]; then
  177. # bug 577410
  178. # #error -- unsupported GNU version! gcc 4.9 and up are not supported!
  179. ewarn "CUDA and >=sys-devel/gcc-4.9 do not play well together. Disabling CUDA support."
  180. mycmakeargs+=( -DWITH_CUDA=OFF )
  181. mycmakeargs+=( -DWITH_CUBLAS=OFF )
  182. mycmakeargs+=( -DWITH_CUFFT=OFF )
  183. else
  184. mycmakeargs+=( -DWITH_CUDA=ON )
  185. mycmakeargs+=( -DWITH_CUBLAS=ON )
  186. mycmakeargs+=( -DWITH_CUFFT=ON )
  187. mycmakeargs+=( -DCUDA_NPP_LIBRARY_ROOT_DIR=/opt/cuda )
  188. fi
  189. else
  190. mycmakeargs+=( -DWITH_CUDA=OFF )
  191. mycmakeargs+=( -DWITH_CUBLAS=OFF )
  192. mycmakeargs+=( -DWITH_CUFFT=OFF )
  193. fi
  194. if use examples && use python; then
  195. mycmakeargs+=( -DINSTALL_PYTHON_EXAMPLES=ON )
  196. else
  197. mycmakeargs+=( -DINSTALL_PYTHON_EXAMPLES=OFF )
  198. fi
  199. # things we want to be hard off or not yet figured out
  200. mycmakeargs+=(
  201. -DOPENCV_BUILD_3RDPARTY_LIBS=OFF
  202. -DBUILD_PACKAGE=OFF
  203. )
  204. # things we want to be hard enabled not worth useflag
  205. mycmakeargs+=(
  206. -DCMAKE_SKIP_RPATH=ON
  207. -DOPENCV_DOC_INSTALL_PATH=
  208. )
  209. # workaround for bug 413429
  210. tc-export CC CXX
  211. cmake-utils_src_configure
  212. }