From: Mathieu Baudier Date: Wed, 6 Mar 2024 07:56:10 +0000 (+0100) Subject: Factorise common variables X-Git-Tag: v2.3.10~40 X-Git-Url: https://git.argeo.org/?p=cc0%2Fargeo-build.git;a=commitdiff_plain;h=7d19aef426a026deea2b2f41d2b5f87bce948798 Factorise common variables --- diff --git a/common.mk b/common.mk index 041e699..025ac54 100644 --- 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 db0cecc..2bbcf44 100644 --- 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 6e57706..ad77233 100644 --- 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 diff --git a/repackage.mk b/repackage.mk index 3461a25..54b6d65 100644 --- a/repackage.mk +++ b/repackage.mk @@ -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