Home | History | Annotate | Download | only in templates
      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 
      4 USER_LOCAL_PATH:=$(LOCAL_PATH)
      5 
      6 USER_LOCAL_C_INCLUDES:=$(LOCAL_C_INCLUDES)
      7 USER_LOCAL_CFLAGS:=$(LOCAL_CFLAGS)
      8 USER_LOCAL_STATIC_LIBRARIES:=$(LOCAL_STATIC_LIBRARIES)
      9 USER_LOCAL_SHARED_LIBRARIES:=$(LOCAL_SHARED_LIBRARIES)
     10 USER_LOCAL_LDLIBS:=$(LOCAL_LDLIBS)
     11 
     12 LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir)))))
     13 
     14 OPENCV_TARGET_ARCH_ABI:=$(TARGET_ARCH_ABI)
     15 OPENCV_THIS_DIR:=$(patsubst $(LOCAL_PATH)\\%,%,$(patsubst $(LOCAL_PATH)/%,%,$(call my-dir)))
     16 OPENCV_MK_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
     17 OPENCV_LIBS_DIR:=@OPENCV_LIBS_DIR_CONFIGCMAKE@
     18 OPENCV_3RDPARTY_LIBS_DIR:=@OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE@
     19 OPENCV_BASEDIR:=@OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE@
     20 OPENCV_LOCAL_C_INCLUDES:=@OPENCV_INCLUDE_DIRS_CONFIGCMAKE@
     21 OPENCV_MODULES:=@OPENCV_MODULES_CONFIGMAKE@
     22 
     23 ifeq ($(OPENCV_LIB_TYPE),)
     24     OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
     25 endif
     26 
     27 ifeq ($(OPENCV_LIB_TYPE),SHARED)
     28     OPENCV_LIBS:=@OPENCV_LIBS_CONFIGMAKE@
     29     OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
     30 else
     31     OPENCV_LIBS:=$(OPENCV_MODULES)
     32     OPENCV_LIB_TYPE:=@OPENCV_STATIC_LIBTYPE_CONFIGMAKE@
     33 endif
     34 
     35 ifeq ($(OPENCV_LIB_TYPE),SHARED)
     36     OPENCV_3RDPARTY_COMPONENTS:=
     37     OPENCV_EXTRA_COMPONENTS:=
     38 else
     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
     55 endif
     56 
     57 ifeq ($(OPENCV_LIB_TYPE),SHARED)
     58     OPENCV_LIB_SUFFIX:=so
     59 else
     60     OPENCV_LIB_SUFFIX:=a
     61     OPENCV_INSTALL_MODULES:=on
     62 endif
     63 
     64 define 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)
     69 endef
     70 
     71 define 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)
     76 endef
     77 
     78 ifeq ($(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
     91 endif
     92 
     93 ifeq ($(OPENCV_LOCAL_CFLAGS),)
     94     OPENCV_LOCAL_CFLAGS := -fPIC -DANDROID -fsigned-char
     95 endif
     96 
     97 include $(CLEAR_VARS)
     98 
     99 LOCAL_C_INCLUDES:=$(USER_LOCAL_C_INCLUDES)
    100 LOCAL_CFLAGS:=$(USER_LOCAL_CFLAGS)
    101 LOCAL_STATIC_LIBRARIES:=$(USER_LOCAL_STATIC_LIBRARIES)
    102 LOCAL_SHARED_LIBRARIES:=$(USER_LOCAL_SHARED_LIBRARIES)
    103 LOCAL_LDLIBS:=$(USER_LOCAL_LDLIBS)
    104 
    105 LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
    106 LOCAL_CFLAGS     += $(OPENCV_LOCAL_CFLAGS)
    107 
    108 ifeq ($(OPENCV_INSTALL_MODULES),on)
    109     LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(foreach mod, $(OPENCV_LIBS), opencv_$(mod))
    110 else
    111     LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib))
    112 endif
    113 
    114 ifeq ($(OPENCV_LIB_TYPE),STATIC)
    115     LOCAL_STATIC_LIBRARIES += $(OPENCV_3RDPARTY_COMPONENTS)
    116 endif
    117 
    118 LOCAL_LDLIBS += $(foreach lib,$(OPENCV_EXTRA_COMPONENTS), -l$(lib))
    119 
    120 #restore the LOCAL_PATH
    121 LOCAL_PATH:=$(USER_LOCAL_PATH)
    122