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 4USER_LOCAL_PATH:=$(LOCAL_PATH) 5 6USER_LOCAL_C_INCLUDES:=$(LOCAL_C_INCLUDES) 7USER_LOCAL_CFLAGS:=$(LOCAL_CFLAGS) 8USER_LOCAL_STATIC_LIBRARIES:=$(LOCAL_STATIC_LIBRARIES) 9USER_LOCAL_SHARED_LIBRARIES:=$(LOCAL_SHARED_LIBRARIES) 10USER_LOCAL_LDLIBS:=$(LOCAL_LDLIBS) 11 12LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir))))) 13 14OPENCV_TARGET_ARCH_ABI:=$(TARGET_ARCH_ABI) 15OPENCV_THIS_DIR:=$(patsubst $(LOCAL_PATH)\\%,%,$(patsubst $(LOCAL_PATH)/%,%,$(call my-dir))) 16OPENCV_MK_DIR:=$(dir $(lastword $(MAKEFILE_LIST))) 17OPENCV_LIBS_DIR:=@OPENCV_LIBS_DIR_CONFIGCMAKE@ 18OPENCV_3RDPARTY_LIBS_DIR:=@OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE@ 19OPENCV_BASEDIR:=@OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE@ 20OPENCV_LOCAL_C_INCLUDES:=@OPENCV_INCLUDE_DIRS_CONFIGCMAKE@ 21OPENCV_MODULES:=@OPENCV_MODULES_CONFIGMAKE@ 22 23ifeq ($(OPENCV_LIB_TYPE),) 24 OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@ 25endif 26 27ifeq ($(OPENCV_LIB_TYPE),SHARED) 28 OPENCV_LIBS:=@OPENCV_LIBS_CONFIGMAKE@ 29 OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@ 30else 31 OPENCV_LIBS:=$(OPENCV_MODULES) 32 OPENCV_LIB_TYPE:=@OPENCV_STATIC_LIBTYPE_CONFIGMAKE@ 33endif 34 35ifeq ($(OPENCV_LIB_TYPE),SHARED) 36 OPENCV_3RDPARTY_COMPONENTS:= 37 OPENCV_EXTRA_COMPONENTS:= 38else 39 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 40 OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@ 41 OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@ 42 endif 43 ifeq ($(TARGET_ARCH_ABI),x86) 44 OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@ 45 OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@ 46 endif 47 ifeq ($(TARGET_ARCH_ABI),armeabi) 48 OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB@ 49 OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@ 50 endif 51 ifeq ($(TARGET_ARCH_ABI),mips) 52 OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@ 53 OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@ 54 endif 55endif 56 57ifeq ($(OPENCV_LIB_TYPE),SHARED) 58 OPENCV_LIB_SUFFIX:=so 59else 60 OPENCV_LIB_SUFFIX:=a 61 OPENCV_INSTALL_MODULES:=on 62endif 63 64define add_opencv_module 65 include $(CLEAR_VARS) 66 LOCAL_MODULE:=opencv_$1 67 LOCAL_SRC_FILES:=$(OPENCV_LIBS_DIR)/libopencv_$1.$(OPENCV_LIB_SUFFIX) 68 include $(PREBUILT_$(OPENCV_LIB_TYPE)_LIBRARY) 69endef 70 71define add_opencv_3rdparty_component 72 include $(CLEAR_VARS) 73 LOCAL_MODULE:=$1 74 LOCAL_SRC_FILES:=$(OPENCV_3RDPARTY_LIBS_DIR)/lib$1.a 75 include $(PREBUILT_STATIC_LIBRARY) 76endef 77 78ifeq ($(OPENCV_MK_$(OPENCV_TARGET_ARCH_ABI)_ALREADY_INCLUDED),) 79 ifeq ($(OPENCV_INSTALL_MODULES),on) 80 $(foreach module,$(OPENCV_LIBS),$(eval $(call add_opencv_module,$(module)))) 81 endif 82 83 $(foreach module,$(OPENCV_3RDPARTY_COMPONENTS),$(eval $(call add_opencv_3rdparty_component,$(module)))) 84 85 ifneq ($(OPENCV_BASEDIR),) 86 OPENCV_LOCAL_C_INCLUDES += $(foreach mod, $(OPENCV_MODULES), $(OPENCV_BASEDIR)/modules/$(mod)/include) 87 endif 88 89 #turn off module installation to prevent their redefinition 90 OPENCV_MK_$(OPENCV_TARGET_ARCH_ABI)_ALREADY_INCLUDED:=on 91endif 92 93ifeq ($(OPENCV_LOCAL_CFLAGS),) 94 OPENCV_LOCAL_CFLAGS := -fPIC -DANDROID -fsigned-char 95endif 96 97include $(CLEAR_VARS) 98 99LOCAL_C_INCLUDES:=$(USER_LOCAL_C_INCLUDES) 100LOCAL_CFLAGS:=$(USER_LOCAL_CFLAGS) 101LOCAL_STATIC_LIBRARIES:=$(USER_LOCAL_STATIC_LIBRARIES) 102LOCAL_SHARED_LIBRARIES:=$(USER_LOCAL_SHARED_LIBRARIES) 103LOCAL_LDLIBS:=$(USER_LOCAL_LDLIBS) 104 105LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES) 106LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS) 107 108ifeq ($(OPENCV_INSTALL_MODULES),on) 109 LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(foreach mod, $(OPENCV_LIBS), opencv_$(mod)) 110else 111 LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib)) 112endif 113 114ifeq ($(OPENCV_LIB_TYPE),STATIC) 115 LOCAL_STATIC_LIBRARIES += $(OPENCV_3RDPARTY_COMPONENTS) 116endif 117 118LOCAL_LDLIBS += $(foreach lib,$(OPENCV_EXTRA_COMPONENTS), -l$(lib)) 119 120#restore the LOCAL_PATH 121LOCAL_PATH:=$(USER_LOCAL_PATH) 122