Factorise common variables
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 6 Mar 2024 07:56:10 +0000 (08:56 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 6 Mar 2024 07:56:10 +0000 (08:56 +0100)
common.mk
jni.mk
osgi.mk
repackage.mk

index 041e699d78f411a8d17ea1bc4ef8ce8e503baaea..025ac54ae8a96d19d057fa3c005d9136d7ff0c0b 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -6,6 +6,18 @@ ECJ_MAJOR=3
 BNDLIB_BRANCH=5.3
 SYSLOGGER_BRANCH=$(build-major).$(build-minor)
 
+# The following variables are found in the sdk.mk file which is generated by the configure script:
+# SDK_SRC_BASE         the base of the source code, typically the root of the cloned git repository
+# SDK_BUILD_BASE       the base of the output
+# JAVA_HOME                    the base of the JDK used to build
+A2_OUTPUT = $(SDK_BUILD_BASE)/a2
+JVM ?= $(JAVA_HOME)/bin/java
+JAVADOC ?= $(JAVA_HOME)/bin/javadoc
+
+# The following variables have default values which can be overriden
+# A2_BASE                      the space-separated directories where already built a2 categories can be found
+A2_BASE ?=$(A2_OUTPUT) /usr/local/share/a2 /usr/share/a2
+
 # GNU defaults
 prefix ?= /usr/local
 datarootdir ?= $(prefix)/share
diff --git a/jni.mk b/jni.mk
index db0cecc81fe4f8027b0078fafaf6a0abece86bd6..2bbcf44ab732104599f0b34a961a0284795ab89c 100644 (file)
--- a/jni.mk
+++ b/jni.mk
@@ -1,11 +1,23 @@
 ARGEO_BUILD_BASE := $(dir $(lastword $(MAKEFILE_LIST)))
 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
+# ADDITIONAL_INC       additional includes
+# ADDITIONAL_LIBS      additional native libraries
+DEP_NATIVE ?=
+ADDITIONAL_INC ?= $(foreach dep, $(DEP_NATIVE), /usr/include/$(dep))
+ADDITIONAL_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) $(ADDITIONAL_LIBS)
+CFLAGS ?= -O3 -fPIC
 
 SRC_DIRS := . 
 
@@ -15,7 +27,7 @@ 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 $(ADDITIONAL_INC)
 
 all: $(A2_NATIVE_CATEGORY)/$(TARGET_EXEC)
 
diff --git a/osgi.mk b/osgi.mk
index 6e57706314c641fd3b1e7786cad12acd8bbf2fdd..ad772336afe5df5a0914fb52f66827f1d31da38d 100644 (file)
--- a/osgi.mk
+++ b/osgi.mk
@@ -1,15 +1,5 @@
 ARGEO_BUILD_BASE := $(dir $(lastword $(MAKEFILE_LIST)))
 include $(ARGEO_BUILD_BASE)common.mk
-#
-# Common build routines to be included in Makefiles
-#
-# The following variables are found in the sdk.mk file which is generated by the configure script:
-# SDK_SRC_BASE         the base of the source code, typically the root of the cloned git repository
-# SDK_BUILD_BASE       the base of the output
-# JAVA_HOME                    the base of the JDK used to build
-A2_OUTPUT = $(SDK_BUILD_BASE)/a2
-JVM ?= $(JAVA_HOME)/bin/java
-JAVADOC ?= $(JAVA_HOME)/bin/javadoc
 
 # The following variables should be declared in the including Makefile:
 # BUNDLES                      the space-separated list of bundles to build
@@ -22,16 +12,16 @@ JAVADOC ?= $(JAVA_HOME)/bin/javadoc
 # The following variables have default values which can be overriden
 # DEP_CATEGORIES       the a2 categories the compilation depends on
 # JAVADOC_PACKAGES     the space-separated list of packages for which javadoc will be generated
-# A2_BASE                      the space-separated directories where already built a2 categories can be found
+# NATIVE_PACKAGES   the space-separated list of JNI packages (directories)
 DEP_CATEGORIES ?=
 JAVADOC_PACKAGES ?=
-A2_BASE ?=/usr/share/a2 /usr/local/share/a2 $(A2_OUTPUT)
+NATIVE_PACKAGES ?=
 
 # We always use the latest version of the ECJ compiler
-ECJ_JAR ?= $(lastword $(foreach base, $(A2_BASE), $(sort $(wildcard $(base)/org.argeo.tp.build/org.eclipse.jdt.core.compiler.batch.$(ECJ_MAJOR).*.jar))))
+ECJ_JAR ?= $(firstword $(foreach base, $(A2_BASE), $(sort $(wildcard $(base)/org.argeo.tp.build/org.eclipse.jdt.core.compiler.batch.$(ECJ_MAJOR).*.jar))))
 # Third-party libraries
-LOGGER_JAR ?= $(lastword $(foreach base, $(A2_BASE), $(wildcard $(base)/log/syslogger/org.argeo.tp/org.argeo.tp.syslogger.$(SYSLOGGER_BRANCH).jar)))
-BNDLIB_JAR ?= $(lastword $(foreach base, $(A2_BASE), $(wildcard $(base)/org.argeo.tp.build/biz.aQute.bndlib.$(BNDLIB_BRANCH).jar)))
+LOGGER_JAR ?= $(firstword $(foreach base, $(A2_BASE), $(wildcard $(base)/log/syslogger/org.argeo.tp/org.argeo.tp.syslogger.$(SYSLOGGER_BRANCH).jar)))
+BNDLIB_JAR ?= $(firstword $(foreach base, $(A2_BASE), $(wildcard $(base)/org.argeo.tp.build/biz.aQute.bndlib.$(BNDLIB_BRANCH).jar)))
 
 # Internal variables
 ARGEO_MAKE = $(JVM) -cp $(LOGGER_JAR):$(ECJ_JAR):$(BNDLIB_JAR) $(ARGEO_BUILD_BASE)src/org/argeo/build/Make.java
index 3461a25370cea0eb600b6104f417318197945eae..54b6d65cf7e272c253681baff5814da460d79c2c 100644 (file)
@@ -1,25 +1,14 @@
 ARGEO_BUILD_BASE := $(dir $(lastword $(MAKEFILE_LIST)))
 include $(ARGEO_BUILD_BASE)common.mk
-#
-# Common repackage routines to be included in Makefiles
-#
-# The following variables are found in the sdk.mk file which is generated by the configure script:
-# SDK_SRC_BASE         the base of the source code, typically the root of the cloned git repository
-# SDK_BUILD_BASE       the base of the output
-# JAVA_HOME                    the base of the JDK used to build
-A2_OUTPUT = $(SDK_BUILD_BASE)/a2
-JVM ?= $(JAVA_HOME)/bin/java
 
 # The following variables should be declared in the including Makefile:
 # CATEGORIES           the space-separated list of categories to repackage
 
-# The following variables have default values which can be overriden
-# A2_BASE                      the space-separated directories where already built a2 categories can be found
 A2_BASE ?=/usr/share/a2 /usr/local/share/a2 $(A2_OUTPUT)
 
 # Third-party libraries
-LOGGER_JAR ?= $(lastword $(foreach base, $(A2_BASE), $(wildcard $(base)/log/syslogger/org.argeo.tp/org.argeo.tp.syslogger.$(SYSLOGGER_BRANCH).jar)))
-BNDLIB_JAR ?= $(lastword $(foreach base, $(A2_BASE), $(wildcard $(base)/org.argeo.tp.build/biz.aQute.bndlib.$(BNDLIB_BRANCH).jar)))
+LOGGER_JAR ?= $(firstword $(foreach base, $(A2_BASE), $(wildcard $(base)/log/syslogger/org.argeo.tp/org.argeo.tp.syslogger.$(SYSLOGGER_BRANCH).jar)))
+BNDLIB_JAR ?= $(firstword $(foreach base, $(A2_BASE), $(wildcard $(base)/org.argeo.tp.build/biz.aQute.bndlib.$(BNDLIB_BRANCH).jar)))
 
 # Internal variables
 ARGEO_REPACKAGE = $(JVM) -cp $(LOGGER_JAR):$(BNDLIB_JAR) $(ARGEO_BUILD_BASE)src/org/argeo/build/Repackage.java