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