OpenCV.mk.in 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # In order to compile your application under cygwin
  2. # you might need to define NDK_USE_CYGPATH=1 before calling the ndk-build
  3. USER_LOCAL_PATH:=$(LOCAL_PATH)
  4. USER_LOCAL_C_INCLUDES:=$(LOCAL_C_INCLUDES)
  5. USER_LOCAL_CFLAGS:=$(LOCAL_CFLAGS)
  6. USER_LOCAL_STATIC_LIBRARIES:=$(LOCAL_STATIC_LIBRARIES)
  7. USER_LOCAL_SHARED_LIBRARIES:=$(LOCAL_SHARED_LIBRARIES)
  8. USER_LOCAL_LDLIBS:=$(LOCAL_LDLIBS)
  9. LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir)))))
  10. OPENCV_TARGET_ARCH_ABI:=$(TARGET_ARCH_ABI)
  11. OPENCV_THIS_DIR:=$(patsubst $(LOCAL_PATH)\\%,%,$(patsubst $(LOCAL_PATH)/%,%,$(call my-dir)))
  12. OPENCV_MK_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
  13. OPENCV_3RDPARTY_LIBS_DIR:=@OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE@
  14. OPENCV_BASEDIR:=@OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE@
  15. OPENCV_LOCAL_C_INCLUDES:=@OPENCV_INCLUDE_DIRS_CONFIGCMAKE@
  16. OPENCV_MODULES:=@OPENCV_MODULES_CONFIGMAKE@
  17. OPENCV_SUB_MK:=$(call my-dir)/OpenCV-$(TARGET_ARCH_ABI).mk
  18. ifeq ($(OPENCV_LIB_TYPE),)
  19. OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
  20. endif
  21. ifeq ($(OPENCV_LIB_TYPE),SHARED)
  22. OPENCV_LIBS:=@OPENCV_LIBS_CONFIGMAKE@
  23. OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
  24. else
  25. OPENCV_LIBS:=$(OPENCV_MODULES)
  26. OPENCV_LIB_TYPE:=@OPENCV_STATIC_LIBTYPE_CONFIGMAKE@
  27. endif
  28. ifeq ($(OPENCV_LIB_TYPE),SHARED)
  29. OPENCV_3RDPARTY_COMPONENTS:=
  30. OPENCV_EXTRA_COMPONENTS:=
  31. else
  32. include $(OPENCV_SUB_MK)
  33. endif
  34. ifeq ($(OPENCV_LIB_TYPE),SHARED)
  35. OPENCV_LIBS_DIR:=@OPENCV_LIBS_DIR_CONFIGCMAKE@
  36. OPENCV_LIB_SUFFIX:=so
  37. else
  38. OPENCV_LIBS_DIR:=@OPENCV_LIBS_ARCHIVE_DIR_CONFIGCMAKE@
  39. OPENCV_LIB_SUFFIX:=a
  40. OPENCV_INSTALL_MODULES:=on
  41. endif
  42. define add_opencv_module
  43. include $(CLEAR_VARS)
  44. LOCAL_MODULE:=opencv_$1
  45. LOCAL_SRC_FILES:=$(OPENCV_LIBS_DIR)/libopencv_$1.$(OPENCV_LIB_SUFFIX)
  46. include $(PREBUILT_$(OPENCV_LIB_TYPE)_LIBRARY)
  47. endef
  48. define add_opencv_3rdparty_component
  49. include $(CLEAR_VARS)
  50. LOCAL_MODULE:=$1
  51. LOCAL_SRC_FILES:=$(OPENCV_3RDPARTY_LIBS_DIR)/lib$1.a
  52. include $(PREBUILT_STATIC_LIBRARY)
  53. endef
  54. ifeq ($(OPENCV_MK_$(OPENCV_TARGET_ARCH_ABI)_ALREADY_INCLUDED),)
  55. ifeq ($(OPENCV_INSTALL_MODULES),on)
  56. $(foreach module,$(OPENCV_LIBS),$(eval $(call add_opencv_module,$(module))))
  57. endif
  58. $(foreach module,$(OPENCV_3RDPARTY_COMPONENTS),$(eval $(call add_opencv_3rdparty_component,$(module))))
  59. ifneq ($(OPENCV_BASEDIR),)
  60. OPENCV_LOCAL_C_INCLUDES += $(foreach mod, $(OPENCV_MODULES), $(OPENCV_BASEDIR)/modules/$(mod)/include)
  61. endif
  62. #turn off module installation to prevent their redefinition
  63. OPENCV_MK_$(OPENCV_TARGET_ARCH_ABI)_ALREADY_INCLUDED:=on
  64. endif
  65. ifeq ($(OPENCV_LOCAL_CFLAGS),)
  66. OPENCV_LOCAL_CFLAGS := -fPIC -DANDROID -fsigned-char
  67. endif
  68. include $(CLEAR_VARS)
  69. LOCAL_C_INCLUDES:=$(USER_LOCAL_C_INCLUDES)
  70. LOCAL_CFLAGS:=$(USER_LOCAL_CFLAGS)
  71. LOCAL_STATIC_LIBRARIES:=$(USER_LOCAL_STATIC_LIBRARIES)
  72. LOCAL_SHARED_LIBRARIES:=$(USER_LOCAL_SHARED_LIBRARIES)
  73. LOCAL_LDLIBS:=$(USER_LOCAL_LDLIBS)
  74. # Details: #10229
  75. ifeq ($(OPENCV_SKIP_ANDROID_IPP_FIX_1),)
  76. LOCAL_LDFLAGS += -Wl,--exclude-libs,libippicv.a
  77. LOCAL_LDFLAGS += -Wl,--exclude-libs,libippiw.a
  78. else
  79. ifeq ($(OPENCV_SKIP_ANDROID_IPP_FIX_2),)
  80. LOCAL_LDFLAGS += -Wl,-Bsymbolic
  81. endif
  82. endif
  83. LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
  84. LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS)
  85. ifeq ($(OPENCV_INSTALL_MODULES),on)
  86. LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(foreach mod, $(OPENCV_LIBS), opencv_$(mod))
  87. else
  88. $(call __ndk_info,OpenCV: You should ignore warning about 'non-system libraries in linker flags' and 'opencv_java' library.)
  89. $(call __ndk_info, 'OPENCV_INSTALL_MODULES:=on' can be used to build APK with included OpenCV binaries)
  90. LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib))
  91. endif
  92. ifeq ($(OPENCV_LIB_TYPE),STATIC)
  93. LOCAL_STATIC_LIBRARIES += $(OPENCV_3RDPARTY_COMPONENTS)
  94. endif
  95. LOCAL_LDLIBS += $(foreach lib,$(OPENCV_EXTRA_COMPONENTS), -l$(lib))
  96. #restore the LOCAL_PATH
  97. LOCAL_PATH:=$(USER_LOCAL_PATH)