1 ARGEO_BUILD_BASE
:= $(dir $(lastword
$(MAKEFILE_LIST
)))
2 include $(ARGEO_BUILD_BASE
)common.mk
4 # Common build routines to be included in Makefiles
6 # The following variables are found in the sdk.mk file which is generated by the configure script:
7 # SDK_SRC_BASE the base of the source code, typically the root of the cloned git repository
8 # SDK_BUILD_BASE the base of the output
9 # JAVA_HOME the base of the JDK used to build
10 A2_OUTPUT
= $(SDK_BUILD_BASE
)/a2
11 JVM ?
= $(JAVA_HOME
)/bin
/java
12 JAVADOC ?
= $(JAVA_HOME
)/bin
/javadoc
14 # The following variables should be declared in the including Makefile:
15 # BUNDLES the space-separated list of bundles to build
16 # A2_CATEGORY the (single) a2 category the bundles will belong to
18 # The following environment variables can change the behaviour of the build
19 # SOURCE_BUNDLES sources will be packaged separately in Eclipse-compatible source bundles
20 # NO_MANIFEST_COPY generated MANIFESTs won't be copied to the source tree
22 # The following variables have default values which can be overriden
23 # DEP_CATEGORIES the a2 categories the compilation depends on
24 # JAVADOC_PACKAGES the space-separated list of packages for which javadoc will be generated
25 # A2_BASE the space-separated directories where already built a2 categories can be found
28 A2_BASE ?
=/usr
/share
/a2
/usr
/local
/share
/a2
$(A2_OUTPUT
)
30 # We always use the latest version of the ECJ compiler
31 ECJ_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(sort $(wildcard $(base
)/org.argeo.tp.build
/org.eclipse.jdt.core.compiler.batch.
$(ECJ_MAJOR
).
*.jar
))))
32 # Third-party libraries
33 LOGGER_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(wildcard $(base
)/log
/syslogger
/org.argeo.tp
/org.argeo.tp.syslogger.
$(SYSLOGGER_BRANCH
).jar
)))
34 BNDLIB_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(wildcard $(base
)/org.argeo.tp.build
/biz.aQute.bndlib.
$(BNDLIB_BRANCH
).jar
)))
37 ARGEO_MAKE
= $(JVM
) -cp
$(LOGGER_JAR
):$(ECJ_JAR
):$(BNDLIB_JAR
) $(ARGEO_BUILD_BASE
)src
/org
/argeo
/build
/Make.java
38 JAVADOC_SRCS
= $(foreach bundle
, $(BUNDLES
), $(bundle
)/src
)
39 ifneq ($(NO_MANIFEST_COPY
),true
)
40 MANIFESTS
= $(foreach bundle
, $(BUNDLES
), $(bundle
)/META-INF
/MANIFEST.MF
)
42 BUILD_BASE
= $(SDK_BUILD_BASE
)/$(shell basename $(SDK_SRC_BASE
))
43 TARGET_BUNDLES
= $(abspath
$(foreach bundle
, $(BUNDLES
),$(A2_OUTPUT
)/$(shell dirname
$(bundle
))/$(A2_CATEGORY
)/$(shell basename $(bundle
)).
$(major
).
$(minor
).jar
))
44 TODOS
= $(foreach bundle
, $(BUNDLES
),$(BUILD_BASE
)/$(bundle
)/to-build
)
46 # Needed in order to be able to expand $$ variables
48 .PHONY
: osgi manifests javadoc
50 osgi
: $(BUILD_BASE
)/built
$(MANIFESTS
)
52 # Actual build (compilation + bundle packaging)
53 $(BUILD_BASE
)/built
: BUNDLES_TO_BUILD
= $(subst $(abspath
$(BUILD_BASE
))/,, $(subst to-build
,, $?
))
54 $(BUILD_BASE
)/built
: $(TODOS
)
56 all --a2-bases
$(A2_BASE
) --dep-categories
$(DEP_CATEGORIES
) \
57 --category
$(A2_CATEGORY
) --bundles
$(BUNDLES_TO_BUILD
)
58 @touch
$(BUILD_BASE
)/built
60 $(A2_OUTPUT
)/%.
$(major
).
$(minor
).jar
: $(BUILD_BASE
)/$$(subst $(A2_CATEGORY
)/,,$$*)/to-build
62 all --a2-bases
$(A2_BASE
) --dep-categories
$(DEP_CATEGORIES
) \
63 --category
$(A2_CATEGORY
) --bundles
$(subst $(A2_CATEGORY
)/,,$*)
65 $(BUILD_BASE
)/%/to-build
: $$(shell find
% -type f
-not
-path
'bin/*' -not
-path
'*/MANIFEST.MF' | sed
's/ /\\ /g')
71 %/META-INF
/MANIFEST.MF
: $(BUILD_BASE
)/%/META-INF
/MANIFEST.MF
72 ifneq ($(NO_MANIFEST_COPY
),true
)
78 @
rm -rf
$(foreach bundle
, $(BUNDLES
), $(bundle
)/META-INF
/MANIFEST.MF
);
82 install --category
$(A2_CATEGORY
) --bundles
$(BUNDLES
) \
83 --target
$(A2_INSTALL_TARGET
)
87 uninstall --category
$(A2_CATEGORY
) --bundles
$(BUNDLES
) \
88 --target
$(A2_INSTALL_TARGET
)
91 javadoc
: $(BUILD_BASE
)/built
92 $(JAVADOC
) -noindex
-quiet
-Xmaxwarns
1 -d
$(BUILD_BASE
)/api
--source-path
$(subst $(space
),$(pathsep
),$(strip $(JAVADOC_SRCS
))) -subpackages
$(JAVADOC_PACKAGES
)
94 # Make variables used to replace spaces by a separator, typically in order to generate classpaths
95 # for example: CLASSPATH = $(subst $(space),$(pathsep),$(strip $(JARS)))