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 # Third-party libraries
31 LOGGER_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(wildcard $(base
)/log
/syslogger
/org.argeo.tp
/org.argeo.tp.syslogger.
$(SYSLOGGER_BRANCH
).jar
)))
32 ECJ_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(wildcard $(base
)/org.argeo.tp.build
/org.eclipse.jdt.core.compiler.batch.
$(ECJ_BRANCH
).jar
)))
33 BNDLIB_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(wildcard $(base
)/org.argeo.tp.build
/biz.aQute.bndlib.
$(BNDLIB_BRANCH
).jar
)))
36 ARGEO_MAKE
= $(JVM
) -cp
$(LOGGER_JAR
):$(ECJ_JAR
):$(BNDLIB_JAR
) $(ARGEO_BUILD_BASE
)src
/org
/argeo
/build
/Make.java
37 JAVADOC_SRCS
= $(foreach bundle
, $(BUNDLES
), $(bundle
)/src
)
38 ifneq ($(NO_MANIFEST_COPY
),true
)
39 MANIFESTS
= $(foreach bundle
, $(BUNDLES
), $(bundle
)/META-INF
/MANIFEST.MF
)
41 BUILD_BASE
= $(SDK_BUILD_BASE
)/$(shell basename $(SDK_SRC_BASE
))
42 TARGET_BUNDLES
= $(abspath
$(foreach bundle
, $(BUNDLES
),$(A2_OUTPUT
)/$(shell dirname
$(bundle
))/$(A2_CATEGORY
)/$(shell basename $(bundle
)).
$(major
).
$(minor
).jar
))
43 TODOS
= $(foreach bundle
, $(BUNDLES
),$(BUILD_BASE
)/$(bundle
)/to-build
)
45 # Needed in order to be able to expand $$ variables
47 .PHONY
: osgi manifests javadoc
49 osgi
: $(BUILD_BASE
)/built
$(MANIFESTS
)
51 # Actual build (compilation + bundle packaging)
52 $(BUILD_BASE
)/built
: BUNDLES_TO_BUILD
= $(subst $(abspath
$(BUILD_BASE
))/,, $(subst to-build
,, $?
))
53 $(BUILD_BASE
)/built
: $(TODOS
)
55 all --a2-bases
$(A2_BASE
) --dep-categories
$(DEP_CATEGORIES
) \
56 --category
$(A2_CATEGORY
) --bundles
$(BUNDLES_TO_BUILD
)
57 @touch
$(BUILD_BASE
)/built
59 $(A2_OUTPUT
)/%.
$(major
).
$(minor
).jar
: $(BUILD_BASE
)/$$(subst $(A2_CATEGORY
)/,,$$*)/to-build
61 all --a2-bases
$(A2_BASE
) --dep-categories
$(DEP_CATEGORIES
) \
62 --category
$(A2_CATEGORY
) --bundles
$(subst $(A2_CATEGORY
)/,,$*)
64 $(BUILD_BASE
)/%/to-build
: $$(shell find
% -type f
-not
-path
'bin/*' -not
-path
'*/MANIFEST.MF' | sed
's/ /\\ /g')
70 %/META-INF
/MANIFEST.MF
: $(BUILD_BASE
)/%/META-INF
/MANIFEST.MF
71 ifneq ($(NO_MANIFEST_COPY
),true
)
77 @
rm -rf
$(foreach bundle
, $(BUNDLES
), $(bundle
)/META-INF
/MANIFEST.MF
);
80 javadoc
: $(BUILD_BASE
)/built
81 $(JAVADOC
) -noindex
-quiet
-Xmaxwarns
1 -d
$(BUILD_BASE
)/api
--source-path
$(subst $(space
),$(pathsep
),$(strip $(JAVADOC_SRCS
))) -subpackages
$(JAVADOC_PACKAGES
)
83 # Make variables used to replace spaces by a separator, typically in order to generate classpaths
84 # for example: CLASSPATH = $(subst $(space),$(pathsep),$(strip $(JARS)))