|
|
|
@ -1,28 +1,31 @@ |
|
|
|
|
#Re-usable Makefile template for
|
|
|
|
|
#android-ndk + swig projects
|
|
|
|
|
#author: Ethan Rublee
|
|
|
|
|
#date: summer 2010
|
|
|
|
|
|
|
|
|
|
# The path to the NDK, requires crystax version r-4 for now, due to support
|
|
|
|
|
#for the standard library
|
|
|
|
|
ifndef ANDROID_NDK_BASE |
|
|
|
|
ANDROID_NDK_BASE = $(HOME)/android-ndk-r4-crystax
|
|
|
|
|
$(info default ndk location set ANDROID_NDK_BASE = $(ANDROID_NDK_BASE)) |
|
|
|
|
# for the standard library
|
|
|
|
|
|
|
|
|
|
# load environment from local make file
|
|
|
|
|
LOCAL_ENV_MK=local.env.mk
|
|
|
|
|
ifneq "$(wildcard $(LOCAL_ENV_MK))" "" |
|
|
|
|
include $(LOCAL_ENV_MK) |
|
|
|
|
else |
|
|
|
|
$(shell cp sample.$(LOCAL_ENV_MK) $(LOCAL_ENV_MK)) |
|
|
|
|
$(info ERROR local environement not setup! try:) |
|
|
|
|
$(info gedit $(LOCAL_ENV_MK)) |
|
|
|
|
$(error Please setup the $(LOCAL_ENV_MK) - the default was just created') |
|
|
|
|
endif |
|
|
|
|
|
|
|
|
|
#define OPENCV_ROOT when calling this makefile
|
|
|
|
|
#OPENCV_ROOT = $(ANDROID_NDK_BASE)/apps/opencv
|
|
|
|
|
ifndef OPENCV_ROOT |
|
|
|
|
$(error Please define OPENCV_ROOT with something like the command \
|
|
|
|
|
make OPENCV_ROOT=<opencv>)
|
|
|
|
|
ifndef ARM_TARGETS |
|
|
|
|
ARM_TARGETS="armeabi armeabi-v7a"
|
|
|
|
|
endif |
|
|
|
|
ANDROID_NDK_BASE = $(ANDROID_NDK_ROOT)
|
|
|
|
|
|
|
|
|
|
$(info OPENCV_CONFIG = $(OPENCV_CONFIG)) |
|
|
|
|
|
|
|
|
|
ifndef PROJECT_PATH |
|
|
|
|
$(info PROJECT_PATH defaulting to this directory) |
|
|
|
|
PROJECT_PATH=.
|
|
|
|
|
endif |
|
|
|
|
|
|
|
|
|
$(info OPENCV_ROOT = $(OPENCV_ROOT)) |
|
|
|
|
android_jni=../../android-jni/jni
|
|
|
|
|
|
|
|
|
|
# The name of the native library
|
|
|
|
|
LIBNAME = libfoobar.so
|
|
|
|
@ -42,46 +45,43 @@ SWIG_BASE = foobar |
|
|
|
|
#swig interface files are in jni/*.i
|
|
|
|
|
SWIG_JAVA_OUT = $(wildcard $(SWIG_JAVA_DIR)/*.java)
|
|
|
|
|
SWIG_IS = $(wildcard jni/*.i)
|
|
|
|
|
#the main swig file that includes others
|
|
|
|
|
SWIG_MAIN = jni/foobar.i
|
|
|
|
|
SWIG_C_DIR = jni/gen
|
|
|
|
|
SWIG_C_OUT = $(SWIG_C_DIR)/foo_swig.cpp
|
|
|
|
|
|
|
|
|
|
#the directory where the jni sources are
|
|
|
|
|
C_DIR = jni
|
|
|
|
|
# Find all the C++ sources in the native folder
|
|
|
|
|
SOURCES = $(wildcard jni/*.cpp)
|
|
|
|
|
HEADERS = $(wildcard jni/*.h)
|
|
|
|
|
|
|
|
|
|
#directory where to put generated files
|
|
|
|
|
#relative to the C_DIR
|
|
|
|
|
GEN_DIR = gen
|
|
|
|
|
ANDROID_MKS = $(wildcard jni/*.mk)
|
|
|
|
|
|
|
|
|
|
#the c swig is generated and put into the jni/gen folder
|
|
|
|
|
SWIG_C_DIR = $(C_DIR)/$(GEN_DIR)
|
|
|
|
|
|
|
|
|
|
#this file - jin/gen/foobar_swig.cpp must be included in the Android.mk
|
|
|
|
|
#for it to be built!
|
|
|
|
|
SWIG_C_OUT = $(SWIG_C_DIR)/$(SWIG_BASE)_swig.cpp
|
|
|
|
|
BUILD_DEFS=OPENCV_CONFIG=$(OPENCV_CONFIG) \
|
|
|
|
|
PROJECT_PATH=$(PROJECT_PATH) \
|
|
|
|
|
V=$(V) \
|
|
|
|
|
$(NDK_FLAGS) \
|
|
|
|
|
ARM_TARGETS=$(ARM_TARGETS) \
|
|
|
|
|
SWIG_C_OUT=$(SWIG_C_OUT)
|
|
|
|
|
|
|
|
|
|
# The real native library stripped of symbols
|
|
|
|
|
LIB = libs/armeabi-v7a/$(LIBNAME) libs/armeabi/$(LIBNAME)
|
|
|
|
|
|
|
|
|
|
# Find all the C++ sources in the native folder
|
|
|
|
|
SOURCES = $(wildcard jni/*.cpp)
|
|
|
|
|
HEADERS = $(wildcard jni/*.h)
|
|
|
|
|
|
|
|
|
|
ANDROID_MKS = $(wildcard jni/*.mk)
|
|
|
|
|
|
|
|
|
|
#this gets called by the make command
|
|
|
|
|
all: $(LIB) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#calls the ndk-build script, passing it OPENCV_ROOT and OPENCV_LIBS_DIR
|
|
|
|
|
$(LIB): $(SWIG_C_OUT) $(SOURCES) $(HEADERS) $(ANDROID_MKS) |
|
|
|
|
$(ANDROID_NDK_BASE)/ndk-build OPENCV_ROOT=$(OPENCV_ROOT) \
|
|
|
|
|
OPENCV_LIBS_DIR=$(OPENCV_LIBS_DIR) PROJECT_PATH=$(PROJECT_PATH) SWIG_C_OUT=$(GEN_DIR)/$(SWIG_BASE)_swig.cpp V=$(V) $(NDK_FLAGS)
|
|
|
|
|
$(ANDROID_NDK_BASE)/ndk-build $(BUILD_DEFS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#this creates the swig wrappers
|
|
|
|
|
#-I$(OPENCV_ROOT)/android/jni is an additional swig include path
|
|
|
|
|
$(SWIG_C_OUT): $(SWIG_IS) |
|
|
|
|
make clean-swig &&\
|
|
|
|
|
mkdir -p $(SWIG_C_DIR) &&\
|
|
|
|
|
mkdir -p $(SWIG_JAVA_DIR) &&\
|
|
|
|
|
swig -java -c++ -I$(OPENCV_ROOT)/android/jni -package "$(SWIG_JAVA_PACKAGE)" \
|
|
|
|
|
swig -java -c++ -I$(android_jni) -package "$(SWIG_JAVA_PACKAGE)" \
|
|
|
|
|
-outdir $(SWIG_JAVA_DIR) \
|
|
|
|
|
-o $(SWIG_C_OUT) $(SWIG_MAIN)
|
|
|
|
|
|
|
|
|
@ -95,4 +95,6 @@ clean-swig: |
|
|
|
|
|
|
|
|
|
#does clean-swig and then uses the ndk-build clean
|
|
|
|
|
clean: clean-swig |
|
|
|
|
$(ANDROID_NDK_BASE)/ndk-build clean V=$(V) $(NDK_FLAGS)
|
|
|
|
|
$(ANDROID_NDK_BASE)/ndk-build clean $(BUILD_DEFS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|