From: Mathieu Baudier Date: Wed, 29 Mar 2023 07:53:09 +0000 (+0200) Subject: Improve JNI build X-Git-Tag: v2.3.9~1 X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-slc.git;a=commitdiff_plain;h=0758b6c2bf0d391845f5a41ed5671d77e6fcadab Improve JNI build --- diff --git a/Makefile b/Makefile index 3a7dc5d61..9b71e7c01 100644 --- a/Makefile +++ b/Makefile @@ -67,5 +67,7 @@ tool-server: osgi graalvm-custom org.argeo.tool.server.ArgeoServer \ argeo +native-deps-debian: + sudo apt install uuid-dev include $(SDK_SRC_BASE)/sdk/argeo-build/osgi.mk \ No newline at end of file diff --git a/jni/Makefile b/jni/Makefile index de2b84c19..e0b2ed4bb 100644 --- a/jni/Makefile +++ b/jni/Makefile @@ -5,10 +5,10 @@ JNIDIRS = org_argeo_api_uuid_libuuid .PHONY: clean all all: - $(foreach dir, $(JNIDIRS), $(MAKE) -C $(dir);) + $(foreach dir, $(JNIDIRS), $(MAKE) -C $(dir) all;) clean: - rm -rf $(BUILD_DIR) $(SDK_BUILD_BASE)/jni + $(foreach dir, $(JNIDIRS), $(MAKE) -C $(dir) clean;) diff --git a/jni/jni.mk b/jni/jni.mk index 40dde4469..e4d7bdec9 100644 --- a/jni/jni.mk +++ b/jni/jni.mk @@ -1,3 +1,6 @@ +include $(SDK_SRC_BASE)/sdk/argeo-build/osgi.mk + +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) @@ -15,7 +18,10 @@ INC_DIRS := $(shell find $(SRC_DIRS) -type d) $(JAVA_HOME)/include $(JAVA_HOME)/ .PHONY: clean all ide -all: $(SDK_BUILD_BASE)/jni/$(TARGET_EXEC) +all: $(A2_NATIVE_CATEGORY)/$(TARGET_EXEC) + +clean: + $(RM) $(A2_NATIVE_CATEGORY)/$(TARGET_EXEC) # Find all the C and C++ files we want to compile # Note the single quotes around the * expressions. Make will incorrectly expand these otherwise. @@ -37,7 +43,8 @@ INC_FLAGS := $(addprefix -I,$(INC_DIRS)) CPPFLAGS := $(INC_FLAGS) -MMD -MP # The final build step. -$(SDK_BUILD_BASE)/jni/$(TARGET_EXEC): $(OBJS) +$(A2_NATIVE_CATEGORY)/$(TARGET_EXEC): $(OBJS) + mkdir -p $(A2_NATIVE_CATEGORY) $(CC) $(OBJS) -o $@ $(LDFLAGS) # Build step for C source diff --git a/jni/org_argeo_api_uuid_libuuid/Makefile b/jni/org_argeo_api_uuid_libuuid/Makefile index cfeb1db55..2e98253b8 100644 --- a/jni/org_argeo_api_uuid_libuuid/Makefile +++ b/jni/org_argeo_api_uuid_libuuid/Makefile @@ -1,3 +1,5 @@ +A2_CATEGORY = org.argeo.slc + NATIVE_PACKAGE := org_argeo_api_uuid_libuuid ADDITIONAL_INCLUDES = /usr/include/uuid