edid-decode: new package
[buildroot-gz.git] / package / opencv3 / opencv3.mk
blob3ce78b5c03420b984940b9dea0dae9bfcfc08a21
1 ################################################################################
3 # opencv3
5 ################################################################################
7 OPENCV3_VERSION = 3.0.0
8 OPENCV3_SITE = $(call github,itseez,opencv,$(OPENCV3_VERSION))
9 OPENCV3_INSTALL_STAGING = YES
10 OPENCV3_LICENSE = BSD-3c
11 OPENCV3_LICENSE_FILES = LICENSE
13 # OpenCV component options
14 OPENCV3_CONF_OPTS += \
15 -DBUILD_DOCS=OFF \
16 -DBUILD_PERF_TESTS=$(if $(BR2_PACKAGE_OPENCV3_BUILD_PERF_TESTS),ON,OFF) \
17 -DBUILD_TESTS=$(if $(BR2_PACKAGE_OPENCV3_BUILD_TESTS),ON,OFF) \
18 -DBUILD_WITH_DEBUG_INFO=OFF
20 ifeq ($(BR2_PACKAGE_OPENCV3_BUILD_TESTS)$(BR2_PACKAGE_OPENCV3_BUILD_PERF_TESTS),)
21 OPENCV3_CONF_OPTS += -DINSTALL_TEST=OFF
22 else
23 OPENCV3_CONF_OPTS += -DINSTALL_TEST=ON
24 endif
26 # OpenCV build options
27 OPENCV3_CONF_OPTS += \
28 -DBUILD_WITH_STATIC_CRT=OFF \
29 -DENABLE_COVERAGE=OFF \
30 -DENABLE_FAST_MATH=ON \
31 -DENABLE_IMPL_COLLECTION=OFF \
32 -DENABLE_NOISY_WARNINGS=OFF \
33 -DENABLE_OMIT_FRAME_POINTER=ON \
34 -DENABLE_PRECOMPILED_HEADERS=OFF \
35 -DENABLE_PROFILING=OFF \
36 -DOPENCV3_WARNINGS_ARE_ERRORS=OFF
38 # OpenCV link options
39 OPENCV3_CONF_OPTS += \
40 -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF \
41 -DCMAKE_SKIP_RPATH=OFF \
42 -DCMAKE_USE_RELATIVE_PATHS=OFF
44 # OpenCV packaging options:
45 OPENCV3_CONF_OPTS += \
46 -DBUILD_PACKAGE=OFF \
47 -DENABLE_SOLUTION_FOLDERS=OFF \
48 -DINSTALL_CREATE_DISTRIB=OFF
50 # OpenCV module selection
51 # * Modules on:
52 # - core: if not set, opencv does not build anything
53 # - hal: core's dependency
54 # * Modules off:
55 # - android*: android stuff
56 # - apps: programs for training classifiers
57 # - java: java bindings
58 # - viz: missing VTK dependency
59 # - world: all-in-one module
61 # * Contrib modules from [1] are disabled:
62 # - opencv_contrib package is not available in Buildroot;
63 # - OPENCV3_EXTRA_MODULES_PATH is not set.
65 # [1] https://github.com/Itseez/opencv_contrib
66 OPENCV3_CONF_OPTS += \
67 -DBUILD_opencv_androidcamera=OFF \
68 -DBUILD_opencv_apps=OFF \
69 -DBUILD_opencv_calib3d=$(if $(BR2_PACKAGE_OPENCV3_LIB_CALIB3D),ON,OFF) \
70 -DBUILD_opencv_core=ON \
71 -DBUILD_opencv_features2d=$(if $(BR2_PACKAGE_OPENCV3_LIB_FEATURES2D),ON,OFF) \
72 -DBUILD_opencv_flann=$(if $(BR2_PACKAGE_OPENCV3_LIB_FLANN),ON,OFF) \
73 -DBUILD_opencv_hal=ON \
74 -DBUILD_opencv_highgui=$(if $(BR2_PACKAGE_OPENCV3_LIB_HIGHGUI),ON,OFF) \
75 -DBUILD_opencv_imgcodecs=$(if $(BR2_PACKAGE_OPENCV3_LIB_IMGCODECS),ON,OFF) \
76 -DBUILD_opencv_imgproc=$(if $(BR2_PACKAGE_OPENCV3_LIB_IMGPROC),ON,OFF) \
77 -DBUILD_opencv_java=OFF \
78 -DBUILD_opencv_ml=$(if $(BR2_PACKAGE_OPENCV3_LIB_ML),ON,OFF) \
79 -DBUILD_opencv_objdetect=$(if $(BR2_PACKAGE_OPENCV3_LIB_OBJDETECT),ON,OFF) \
80 -DBUILD_opencv_photo=$(if $(BR2_PACKAGE_OPENCV3_LIB_PHOTO),ON,OFF) \
81 -DBUILD_opencv_shape=$(if $(BR2_PACKAGE_OPENCV3_LIB_SHAPE),ON,OFF) \
82 -DBUILD_opencv_stitching=$(if $(BR2_PACKAGE_OPENCV3_LIB_STITCHING),ON,OFF) \
83 -DBUILD_opencv_superres=$(if $(BR2_PACKAGE_OPENCV3_LIB_SUPERRES),ON,OFF) \
84 -DBUILD_opencv_ts=$(if $(BR2_PACKAGE_OPENCV3_LIB_TS),ON,OFF) \
85 -DBUILD_opencv_video=$(if $(BR2_PACKAGE_OPENCV3_LIB_VIDEO),ON,OFF) \
86 -DBUILD_opencv_videoio=$(if $(BR2_PACKAGE_OPENCV3_LIB_VIDEOIO),ON,OFF) \
87 -DBUILD_opencv_videostab=$(if $(BR2_PACKAGE_OPENCV3_LIB_VIDEOSTAB),ON,OFF) \
88 -DBUILD_opencv_viz=OFF \
89 -DBUILD_opencv_world=OFF
91 # Hardware support options.
93 # * PowerPC support is turned off since its only effect is altering CFLAGS,
94 # adding '-mcpu=G3 -mtune=G5' to them, which is already handled by Buildroot.
95 # * fma3 and popcnt support is disabled because according to gcc manual [2], it
96 # is only available on x86_64 haswell, broadwell and knl architecture.
98 # [2] https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/x86-Options.html#x86-Options
99 OPENCV3_CONF_OPTS += \
100 -DENABLE_AVX=$(if $(BR2_X86_CPU_HAS_AVX),ON,OFF) \
101 -DENABLE_AVX2=$(if $(BR2_X86_CPU_HAS_AVX2),ON,OFF) \
102 -DENABLE_FMA3=OFF \
103 -DENABLE_POPCNT=OFF \
104 -DENABLE_POWERPC=OFF \
105 -DENABLE_SSE=$(if $(BR2_X86_CPU_HAS_SSE),ON,OFF) \
106 -DENABLE_SSE2=$(if $(BR2_X86_CPU_HAS_SSE2),ON,OFF) \
107 -DENABLE_SSE3=$(if $(BR2_X86_CPU_HAS_SSE3),ON,OFF) \
108 -DENABLE_SSE41=$(if $(BR2_X86_CPU_HAS_SSE4),ON,OFF) \
109 -DENABLE_SSE42=$(if $(BR2_X86_CPU_HAS_SSE42),ON,OFF) \
110 -DENABLE_SSSE3=$(if $(BR2_X86_CPU_HAS_SSSE3),ON,OFF)
112 # Cuda stuff
113 OPENCV3_CONF_OPTS += \
114 -DBUILD_CUDA_STUBS=OFF \
115 -DBUILD_opencv_cudaarithm=OFF \
116 -DBUILD_opencv_cudabgsegm=OFF \
117 -DBUILD_opencv_cudacodec=OFF \
118 -DBUILD_opencv_cudafeatures2d=OFF \
119 -DBUILD_opencv_cudafilters=OFF \
120 -DBUILD_opencv_cudaimgproc=OFF \
121 -DBUILD_opencv_cudalegacy=OFF \
122 -DBUILD_opencv_cudaobjdetect=OFF \
123 -DBUILD_opencv_cudaoptflow=OFF \
124 -DBUILD_opencv_cudastereo=OFF \
125 -DBUILD_opencv_cudawarping=OFF \
126 -DBUILD_opencv_cudev=OFF \
127 -DWITH_CUBLAS=OFF \
128 -DWITH_CUDA=OFF \
129 -DWITH_CUFFT=OFF
131 # NVidia stuff
132 OPENCV3_CONF_OPTS += -DWITH_NVCUVID=OFF
134 # AMD stuff
135 OPENCV3_CONF_OPTS += \
136 -DWITH_OPENCLAMDBLAS=OFF \
137 -DWITH_OPENCLAMDFFT=OFF
139 # Intel stuff
140 OPENCV3_CONF_OPTS += \
141 -DBUILD_WITH_DYNAMIC_IPP=OFF \
142 -DWITH_INTELPERC=OFF \
143 -DWITH_IPP=OFF \
144 -DWITH_IPP_A=OFF \
145 -DWITH_TBB=OFF
147 # Smartek stuff
148 OPENCV3_CONF_OPTS += -DWITH_GIGEAPI=OFF
150 # Prosilica stuff
151 OPENCV3_CONF_OPTS += -DWITH_PVAPI=OFF
153 # Ximea stuff
154 OPENCV3_CONF_OPTS += -DWITH_XIMEA=OFF
156 # Non-Linux support (Android options) must remain OFF:
157 OPENCV3_CONF_OPTS += \
158 -DANDROID=OFF \
159 -DBUILD_ANDROID_CAMERA_WRAPPER=OFF \
160 -DBUILD_ANDROID_EXAMPLES=OFF \
161 -DBUILD_ANDROID_SERVICE=OFF \
162 -DBUILD_FAT_JAVA_LIB=OFF \
163 -DINSTALL_ANDROID_EXAMPLES=OFF \
164 -DWITH_ANDROID_CAMERA=OFF
166 # Non-Linux support (Mac OSX options) must remain OFF:
167 OPENCV3_CONF_OPTS += \
168 -DWITH_AVFOUNDATION=OFF \
169 -DWITH_CARBON=OFF \
170 -DWITH_QUICKTIME=OFF
172 # Non-Linux support (Windows options) must remain OFF:
173 OPENCV3_CONF_OPTS += \
174 -DWITH_CSTRIPES=OFF \
175 -DWITH_DSHOW=OFF \
176 -DWITH_MSMF=OFF \
177 -DWITH_PTHREADS_PF=OFF \
178 -DWITH_VFW=OFF \
179 -DWITH_VIDEOINPUT=OFF \
180 -DWITH_WIN32UI=OFF
182 # Software/3rd-party support options:
183 # - disable all examples
184 OPENCV3_CONF_OPTS += \
185 -DBUILD_EXAMPLES=OFF \
186 -DBUILD_JASPER=OFF \
187 -DBUILD_JPEG=OFF \
188 -DBUILD_OPENEXR=OFF \
189 -DBUILD_PNG=OFF \
190 -DBUILD_TIFF=OFF \
191 -DBUILD_ZLIB=OFF \
192 -DINSTALL_C_EXAMPLES=OFF \
193 -DINSTALL_PYTHON_EXAMPLES=OFF \
194 -DINSTALL_TO_MANGLED_PATHS=OFF
196 # Disabled features (mostly because they are not available in Buildroot), but
197 # - eigen: OpenCV does not use it, not take any benefit from it.
198 OPENCV3_CONF_OPTS += \
199 -DWITH_1394=OFF \
200 -DWITH_CLP=OFF \
201 -DWITH_EIGEN=OFF \
202 -DWITH_GDAL=OFF \
203 -DWITH_GPHOTO2=OFF \
204 -DWITH_OPENCL=OFF \
205 -DWITH_OPENCL_SVM=OFF \
206 -DWITH_OPENEXR=OFF \
207 -DWITH_OPENGL=OFF \
208 -DWITH_OPENMP=OFF \
209 -DWITH_OPENNI2=OFF \
210 -DWITH_OPENNI=OFF \
211 -DWITH_UNICAP=OFF \
212 -DWITH_VTK=OFF \
213 -DWITH_WEBP=OFF \
214 -DWITH_XINE=OFF
216 OPENCV3_DEPENDENCIES += zlib
218 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_FFMPEG),y)
219 OPENCV3_CONF_OPTS += -DWITH_FFMPEG=ON
220 OPENCV3_DEPENDENCIES += ffmpeg bzip2
221 else
222 OPENCV3_CONF_OPTS += -DWITH_FFMPEG=OFF
223 endif
225 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_GSTREAMER),y)
226 OPENCV3_CONF_OPTS += -DWITH_GSTREAMER_0_10=ON
227 OPENCV3_DEPENDENCIES += gstreamer gst-plugins-base
228 else
229 OPENCV3_CONF_OPTS += -DWITH_GSTREAMER_0_10=OFF
230 endif
232 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_GSTREAMER1),y)
233 OPENCV3_CONF_OPTS += -DWITH_GSTREAMER=ON
234 OPENCV3_DEPENDENCIES += gstreamer1 gst1-plugins-base
235 else
236 OPENCV3_CONF_OPTS += -DWITH_GSTREAMER=OFF
237 endif
239 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_GTK)$(BR2_PACKAGE_OPENCV3_WITH_GTK3),)
240 OPENCV3_CONF_OPTS += -DWITH_GTK=OFF -DWITH_GTK_2_X=OFF
241 endif
243 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_GTK),y)
244 OPENCV3_CONF_OPTS += -DWITH_GTK=ON -DWITH_GTK_2_X=ON
245 OPENCV3_DEPENDENCIES += libgtk2
246 endif
248 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_GTK3),y)
249 OPENCV3_CONF_OPTS += -DWITH_GTK=ON -DWITH_GTK_2_X=OFF
250 OPENCV3_DEPENDENCIES += libgtk3
251 endif
253 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_JASPER),y)
254 OPENCV3_CONF_OPTS += -DWITH_JASPER=ON
255 OPENCV3_DEPENDENCIES += jasper
256 else
257 OPENCV3_CONF_OPTS += -DWITH_JASPER=OFF
258 endif
260 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_JPEG),y)
261 OPENCV3_CONF_OPTS += -DWITH_JPEG=ON
262 OPENCV3_DEPENDENCIES += jpeg
263 else
264 OPENCV3_CONF_OPTS += -DWITH_JPEG=OFF
265 endif
267 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_OPENGL),y)
268 OPENCV3_CONF_OPTS += -DWITH_OPENGL=ON
269 OPENCV3_DEPENDENCIES += libgl
270 else
271 OPENCV3_CONF_OPTS += -DWITH_OPENGL=OFF
272 endif
274 OPENCV3_CONF_OPTS += -DWITH_OPENMP=$(if $(BR2_GCC_ENABLE_OPENMP),ON,OFF)
276 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_PNG),y)
277 OPENCV3_CONF_OPTS += -DWITH_PNG=ON
278 OPENCV3_DEPENDENCIES += libpng
279 else
280 OPENCV3_CONF_OPTS += -DWITH_PNG=OFF
281 endif
283 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_QT)$(BR2_PACKAGE_OPENCV3_WITH_QT5),)
284 OPENCV3_CONF_OPTS += -DWITH_QT=OFF
285 endif
287 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_QT),y)
288 OPENCV3_CONF_OPTS += -DWITH_QT=4
289 OPENCV3_DEPENDENCIES += qt
290 endif
292 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_QT5),y)
293 OPENCV3_CONF_OPTS += -DWITH_QT=5
294 OPENCV3_DEPENDENCIES += qt5base
295 endif
297 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_TIFF),y)
298 OPENCV3_CONF_OPTS += -DWITH_TIFF=ON
299 OPENCV3_DEPENDENCIES += tiff
300 else
301 OPENCV3_CONF_OPTS += -DWITH_TIFF=OFF
302 endif
304 ifeq ($(BR2_PACKAGE_OPENCV3_WITH_V4L),y)
305 OPENCV3_CONF_OPTS += \
306 -DWITH_LIBV4L=$(if $(BR2_PACKAGE_LIBV4L),ON,OFF) \
307 -DWITH_V4L=ON
308 OPENCV3_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBV4L),libv4l)
309 else
310 OPENCV3_CONF_OPTS += -DWITH_V4L=OFF -DWITH_LIBV4L=OFF
311 endif
313 ifeq ($(BR2_PACKAGE_OPENCV3_LIB_PYTHON),y)
314 ifeq ($(BR2_PACKAGE_PYTHON),y)
315 OPENCV3_CONF_OPTS += \
316 -DBUILD_opencv_python2=ON \
317 -DBUILD_opencv_python3=OFF \
318 -DPYTHON2_EXECUTABLE=$(HOST_DIR)/usr/bin/python2 \
319 -DPYTHON2_INCLUDE_PATH=$(STAGING_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR) \
320 -DPYTHON2_LIBRARIES=$(STAGING_DIR)/usr/lib/libpython$(PYTHON_VERSION_MAJOR).so \
321 -DPYTHON2_NUMPY_INCLUDE_DIRS=$(STAGING_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages/numpy/core/include \
322 -DPYTHON2_PACKAGES_PATH=/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages \
323 -DPYTHON2_NUMPY_VERSION=$(PYTHON_NUMPY_VERSION)
324 OPENCV3_DEPENDENCIES += python
325 else
326 OPENCV3_CONF_OPTS += \
327 -DBUILD_opencv_python2=OFF \
328 -DBUILD_opencv_python3=ON \
329 -DPYTHON3_EXECUTABLE=$(HOST_DIR)/usr/bin/python3 \
330 -DPYTHON3_INCLUDE_PATH=$(STAGING_DIR)/usr/include/python$(PYTHON3_VERSION_MAJOR)m \
331 -DPYTHON3_LIBRARIES=$(STAGING_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)m.so \
332 -DPYTHON3_NUMPY_INCLUDE_DIRS=$(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/numpy/core/include \
333 -DPYTHON3_PACKAGES_PATH=/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages \
334 -DPYTHON3_NUMPY_VERSION=$(PYTHON_NUMPY_VERSION)
335 OPENCV3_DEPENDENCIES += python3
336 endif
337 OPENCV3_DEPENDENCIES += python-numpy
338 else
339 OPENCV3_CONF_OPTS += \
340 -DBUILD_opencv_python2=OFF \
341 -DBUILD_opencv_python3=OFF
342 endif
344 # Installation hooks:
345 define OPENCV3_CLEAN_INSTALL_DOC
346 $(RM) -fr $(TARGET_DIR)/usr/share/OpenCV/doc
347 endef
348 OPENCV3_POST_INSTALL_TARGET_HOOKS += OPENCV3_CLEAN_INSTALL_DOC
350 define OPENCV3_CLEAN_INSTALL_CMAKE
351 $(RM) -f $(TARGET_DIR)/usr/share/OpenCV/OpenCVConfig*.cmake
352 endef
353 OPENCV3_POST_INSTALL_TARGET_HOOKS += OPENCV3_CLEAN_INSTALL_CMAKE
355 ifneq ($(BR2_PACKAGE_OPENCV3_INSTALL_DATA),y)
356 define OPENCV3_CLEAN_INSTALL_DATA
357 $(RM) -fr $(TARGET_DIR)/usr/share/OpenCV/haarcascades \
358 $(TARGET_DIR)/usr/share/OpenCV/lbpcascades
359 endef
360 OPENCV3_POST_INSTALL_TARGET_HOOKS += OPENCV3_CLEAN_INSTALL_DATA
361 endif
363 $(eval $(cmake-package))