]> git.argeo.org Git - cc0/argeo-build.git/blob - osgi.mk
227ec17133b0ca24abc1d63b7c9c8179e6154aad
[cc0/argeo-build.git] / osgi.mk
1 include common.mk
2 #
3 # Common build routines to be included in Makefiles
4 #
5 # The following variables are found in the sdk.mk file which is generated by the configure script:
6 # SDK_SRC_BASE the base of the source code, typically the root of the cloned git repository
7 # SDK_BUILD_BASE the base of the output
8 # JAVA_HOME the base of the JDK used to build
9 A2_OUTPUT = $(SDK_BUILD_BASE)/a2
10 JVM ?= $(JAVA_HOME)/bin/java
11 JAVADOC ?= $(JAVA_HOME)/bin/javadoc
12
13 # The following variables should be declared in the Makefile:
14 # BUNDLES the space-separated list of bundles to be built
15 # A2_CATEGORY the (single) a2 category the bundles will belong to
16 #
17 # The following variables have default values which can be overriden in the Makefile
18 # DEP_CATEGORIES the a2 categories the compilation depends on
19 # JAVADOC_PACKAGES the space-separated list of packages for which javadoc will be generated
20 # A2_BASE the space-separated directories where already built a2 categories can be found
21 DEP_CATEGORIES ?=
22 JAVADOC_PACKAGES ?=
23 A2_BASE ?= $(A2_OUTPUT)
24
25 #LOGGER_JAR ?= $(A2_BASE)/org.argeo.tp/org.argeo.tp.syslogger.2.3.jar
26 ECJ_JAR ?= $(A2_BASE)/org.argeo.tp.sdk/org.eclipse.jdt.core.compiler.batch.3.32.jar
27 BNDLIB_JAR ?= $(A2_BASE)/org.argeo.tp.sdk/biz.aQute.bndlib.5.3.jar
28 ARGEO_MAKE = $(JVM) -cp $(LOGGER_JAR):$(ECJ_JAR):$(BNDLIB_JAR) $(SDK_SRC_BASE)/sdk/argeo-build/src/org/argeo/build/Make.java
29
30 JAVADOC_SRCS = $(foreach bundle, $(BUNDLES), $(bundle)/src)
31
32 BUILD_BASE = $(SDK_BUILD_BASE)/$(shell basename $(SDK_SRC_BASE))
33
34 TARGET_BUNDLES = $(abspath $(foreach bundle, $(BUNDLES),$(A2_OUTPUT)/$(shell dirname $(bundle))/$(A2_CATEGORY)/$(shell basename $(bundle)).$(major).$(minor).jar))
35 TODOS = $(foreach bundle, $(BUNDLES),$(BUILD_BASE)/$(bundle)/to-build)
36
37 ## Needed in order to be able to expand $$ variables
38 .SECONDEXPANSION:
39 .PHONY: osgi manifests javadoc
40
41 osgi: $(BUILD_BASE)/built
42
43 javadoc: $(BUILD_BASE)/built
44 $(JAVADOC) -quiet -Xmaxwarns 1 -d $(BUILD_BASE)/api --source-path $(subst $(space),$(pathsep),$(strip $(JAVADOC_SRCS))) -subpackages $(JAVADOC_PACKAGES)
45
46 # Actual build (compilation + bundle packaging)
47 $(BUILD_BASE)/built : BUNDLES_TO_BUILD = $(subst $(abspath $(BUILD_BASE))/,, $(subst to-build,, $?))
48 $(BUILD_BASE)/built : find-build-tp $(TODOS)
49 $(JVM) -cp $(LOGGER_JAR):$(ECJ_JAR):$(BNDLIB_JAR) $(SDK_SRC_BASE)/sdk/argeo-build/src/org/argeo/build/Make.java \
50 all --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) --category $(A2_CATEGORY) --bundles $(BUNDLES_TO_BUILD)
51 touch $(BUILD_BASE)/built
52
53 #$(A2_OUTPUT)/%.$(major).$(minor).jar : $(BUILD_BASE)/$$(subst $(A2_CATEGORY)/,,$$*)/to-build
54 # $(ARGEO_MAKE) all --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) --category $(A2_CATEGORY) --bundles $(subst $(A2_CATEGORY)/,,$*)
55
56 $(BUILD_BASE)/%/to-build : $$(shell find % -type f -not -path 'bin/*' -not -path '*/MANIFEST.MF' | sed 's/ /\\ /g')
57 @rm -rf $(dir $@)
58 @mkdir -p $(dir $@)
59 @touch $@
60
61 # Local manifests
62 manifests : osgi
63 @mkdir -p $(foreach bundle, $(BUNDLES), $(bundle)/META-INF/);
64 @$(foreach bundle, $(BUNDLES), cp -v $(BUILD_BASE)/$(bundle)/META-INF/MANIFEST.MF $(bundle)/META-INF/MANIFEST.MF;)
65
66 # Make variables used to replace spaces by a separator, typically in order to generate classpaths
67 # for example: CLASSPATH = $(subst $(space),$(pathsep),$(strip $(JARS)))
68 null :=
69 space := $(null) #
70 pathsep := :