]> git.argeo.org Git - cc0/argeo-build.git/blob - osgi.mk
Close directory stream
[cc0/argeo-build.git] / osgi.mk
1 ARGEO_BUILD_BASE := $(dir $(lastword $(MAKEFILE_LIST)))
2 include $(ARGEO_BUILD_BASE)common.mk
3
4 # The following variables should be declared in the including Makefile:
5 # BUNDLES the space-separated list of bundles to build
6 # A2_CATEGORY the (single) a2 category the bundles will belong to
7
8 # The following environment variables can change the behaviour of the build
9 # SOURCE_BUNDLES sources will be packaged separately in Eclipse-compatible source bundles
10 # NO_MANIFEST_COPY generated MANIFESTs won't be copied to the source tree
11
12 # The following variables have default values which can be overriden
13 # DEP_CATEGORIES the a2 categories the compilation depends on
14 # JAVADOC_PACKAGES the space-separated list of packages for which javadoc will be generated
15 # NATIVE_PACKAGES the space-separated list of JNI packages (directories)
16 DEP_CATEGORIES ?=
17 JAVADOC_PACKAGES ?=
18 NATIVE_PACKAGES ?=
19
20 # We always use the latest version of the ECJ compiler
21 ECJ_JAR ?= $(firstword $(foreach base, $(A2_BASE), $(sort $(wildcard $(base)/org.argeo.tp.build/org.eclipse.jdt.core.compiler.batch.$(ECJ_MAJOR).*.jar))))
22 # Third-party libraries
23 LOGGER_JAR ?= $(firstword $(foreach base, $(A2_BASE), $(wildcard $(base)/log/syslogger/org.argeo.tp/org.argeo.tp.syslogger.$(SYSLOGGER_BRANCH).jar)))
24 BNDLIB_JAR ?= $(firstword $(foreach base, $(A2_BASE), $(wildcard $(base)/org.argeo.tp.build/biz.aQute.bndlib.$(BNDLIB_BRANCH).jar)))
25
26 # Internal variables
27 ARGEO_MAKE = $(JVM) -cp $(LOGGER_JAR):$(ECJ_JAR):$(BNDLIB_JAR) $(ARGEO_BUILD_BASE)src/org/argeo/build/Make.java
28 JAVADOC_SRCS = $(foreach bundle, $(BUNDLES), $(bundle)/src)
29 ifneq ($(NO_MANIFEST_COPY),true)
30 MANIFESTS = $(foreach bundle, $(BUNDLES), $(bundle)/META-INF/MANIFEST.MF)
31 endif
32 BUILD_BASE = $(SDK_BUILD_BASE)/$(shell basename $(SDK_SRC_BASE))
33 TARGET_BUNDLES = $(abspath $(foreach bundle, $(BUNDLES),$(A2_OUTPUT)/$(shell dirname $(bundle))/$(A2_CATEGORY)/$(shell basename $(bundle)).$(major).$(minor).jar))
34 TODOS = $(foreach bundle, $(BUNDLES),$(BUILD_BASE)/$(bundle)/to-build)
35 # Native
36 JNIDIRS=$(foreach package, $(NATIVE_PACKAGES), jni/$(package))
37
38 # Needed in order to be able to expand $$ variables
39 .SECONDEXPANSION:
40
41 osgi: $(BUILD_BASE)/built $(MANIFESTS)
42
43 # Actual build (compilation + bundle packaging)
44 $(BUILD_BASE)/built : BUNDLES_TO_BUILD = $(strip $(subst $(abspath $(BUILD_BASE))/,, $(subst to-build,, $?)))
45 $(BUILD_BASE)/built : $(TODOS)
46 @echo "| A2 category : $(A2_CATEGORY)"
47 @echo "| Bundles : $(BUNDLES_TO_BUILD)"
48 @echo "| Dependencies : $(DEP_CATEGORIES)"
49 @echo "| Compiler : $(notdir $(ECJ_JAR))"
50 @$(ARGEO_MAKE) \
51 all --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) \
52 --category $(A2_CATEGORY) --bundles $(BUNDLES_TO_BUILD)
53 @touch $(BUILD_BASE)/built
54
55 $(A2_OUTPUT)/%.$(major).$(minor).jar : $(BUILD_BASE)/$$(subst $(A2_CATEGORY)/,,$$*)/to-build
56 $(ARGEO_MAKE) \
57 all --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) \
58 --category $(A2_CATEGORY) --bundles $(subst $(A2_CATEGORY)/,,$*)
59
60 $(BUILD_BASE)/%/to-build : $$(shell find % -type f -not -path 'bin/*' -not -path '*/MANIFEST.MF' | sed 's/ /\\ /g')
61 @rm -rf $(dir $@)
62 @mkdir -p $(dir $@)
63 @touch $@
64
65 # Local manifests
66 %/META-INF/MANIFEST.MF : $(BUILD_BASE)/%/META-INF/MANIFEST.MF
67 ifneq ($(NO_MANIFEST_COPY),true)
68 @mkdir -p $*/META-INF
69 @cp $< $@
70 endif
71
72 clean-manifests :
73 @rm -rf $(foreach bundle, $(BUNDLES), $(bundle)/META-INF/MANIFEST.MF);
74
75 osgi-all: osgi jni-all
76
77 osgi-clean: jni-clean
78 rm -rf $(BUILD_BASE)
79
80 osgi-install: jni-install
81 $(ARGEO_MAKE) \
82 install --category $(A2_CATEGORY) --bundles $(BUNDLES) \
83 --target $(A2_INSTALL_TARGET) \
84 --os $(TARGET_OS) --target-native $(A2_NATIVE_INSTALL_TARGET)
85
86 osgi-uninstall: jni-uninstall
87 $(ARGEO_MAKE) \
88 uninstall --category $(A2_CATEGORY) --bundles $(BUNDLES) \
89 --target $(A2_INSTALL_TARGET) \
90 --os $(TARGET_OS) --target-native $(A2_NATIVE_INSTALL_TARGET)
91
92 jni-all:
93 $(foreach dir, $(JNIDIRS), $(MAKE) -C $(dir) all;)
94
95 jni-clean:
96 $(foreach dir, $(JNIDIRS), $(MAKE) -C $(dir) clean;)
97
98 jni-install:
99 $(foreach dir, $(JNIDIRS), $(MAKE) -C $(dir) install;)
100
101 jni-uninstall:
102 $(foreach dir, $(JNIDIRS), $(MAKE) -C $(dir) uninstall;)
103
104 # Javadoc generation
105 javadoc: $(BUILD_BASE)/built
106 $(JAVADOC) -noindex -quiet -Xmaxwarns 1 -d $(BUILD_BASE)/api --source-path $(subst $(space),$(pathsep),$(strip $(JAVADOC_SRCS))) -subpackages $(JAVADOC_PACKAGES)
107
108 .PHONY: osgi manifests javadoc osgi-all osgi-clean osgi-install osgi-uninstall jni-all jni-clean jni-install jni-uninstall