ARGEO_BUILD_BASE := $(dir $(lastword $(MAKEFILE_LIST)))
-include $(ARGEO_BUILD_BASE)osgi.mk
+include $(ARGEO_BUILD_BASE)common.mk
+
+# The following variables should be declared in the including Makefile:
+# NATIVE_PACKAGE this native package name
+# A2_CATEGORY the (single) a2 category the bundles will belong to
+
+# The following variables have default values which can be overriden
+# DEP_NATIVE space-separated logical names of named depdencies
+# DEP_INCLUDES additional includes
+# DEP_LIBS additional native libraries
+DEP_NATIVE ?=
+DEP_INCLUDES ?= $(foreach dep, $(DEP_NATIVE), /usr/include/$(dep))
+DEP_LIBS ?= $(foreach dep, $(DEP_NATIVE), -l$(dep))
A2_NATIVE_CATEGORY=$(A2_OUTPUT)/lib/linux/$(shell uname -m)/$(A2_CATEGORY)
TARGET_EXEC := libJava_$(NATIVE_PACKAGE).so
-LDFLAGS = -shared -fPIC -Wl,-soname,$(TARGET_EXEC).$(MAJOR).$(MINOR) $(ADDITIONAL_LIBS)
-CFLAGS = -O3 -fPIC
+LDFLAGS ?= -shared -fPIC -Wl,-soname,$(TARGET_EXEC).$(MAJOR).$(MINOR) $(DEP_LIBS)
+CFLAGS ?= -O3 -fPIC
SRC_DIRS := .
BUILD_DIR := $(SDK_BUILD_BASE)/jni/$(NATIVE_PACKAGE)
# Include directories
-INC_DIRS := $(shell find $(SRC_DIRS) -type d) $(JAVA_HOME)/include $(JAVA_HOME)/include/linux $(ADDITIONAL_INCLUDES)
+INC_DIRS := $(shell find $(SRC_DIRS) -type d) $(JAVA_HOME)/include $(JAVA_HOME)/include/linux $(DEP_INCLUDES)
-.PHONY: clean all ide
all: $(A2_NATIVE_CATEGORY)/$(TARGET_EXEC)
clean:
+ $(RM) $(BUILD_DIR)/*.o
$(RM) $(A2_NATIVE_CATEGORY)/$(TARGET_EXEC)
+install:
+ $(INSTALL) $(A2_NATIVE_INSTALL_TARGET) $(A2_NATIVE_CATEGORY)/$(TARGET_EXEC)
+
+uninstall:
+ $(RM) $(A2_NATIVE_INSTALL_TARGET)/$(TARGET_EXEC)
+ @if [ -d $(A2_NATIVE_INSTALL_TARGET) ]; then find $(A2_NATIVE_INSTALL_TARGET) -empty -type d -delete; fi
+
# Sources
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s')
# Objects (example.cpp to ./org_example_core/example.cpp.o)
# Include the .d makefiles. (- pefix suppress errors if not found)
-include $(DEPS)
+
+.PHONY: clean all install uninstall