1 SELF_DIR
:= $(dir $(lastword
$(MAKEFILE_LIST
)))
2 include $(SELF_DIR
)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 Makefile:
15 # BUNDLES the space-separated list of bundles to be built
16 # A2_CATEGORY the (single) a2 category the bundles will belong to
18 # The following variables have default values which can be overriden in the Makefile
19 # DEP_CATEGORIES the a2 categories the compilation depends on
20 # JAVADOC_PACKAGES the space-separated list of packages for which javadoc will be generated
21 # A2_BASE the space-separated directories where already built a2 categories can be found
24 A2_BASE ?
= $(A2_OUTPUT
)
26 LOGGER_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(wildcard $(base
)/org.argeo.tp
/org.argeo.tp.syslogger.
$(SYSLOGGER_BRANCH
).jar
)))
27 ECJ_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(wildcard $(base
)/org.argeo.tp.sdk
/org.eclipse.jdt.core.compiler.batch.
$(ECJ_BRANCH
).jar
)))
28 #ECJ_JAR ?= $(A2_BASE)/org.argeo.tp.sdk/org.eclipse.jdt.core.compiler.batch.3.32.jar
29 BNDLIB_JAR ?
= $(lastword
$(foreach base
, $(A2_BASE
), $(wildcard $(base
)/org.argeo.tp.sdk
/biz.aQute.bndlib.
$(BNDLIB_BRANCH
).jar
)))
30 #BNDLIB_JAR ?= $(A2_BASE)/org.argeo.tp.sdk/biz.aQute.bndlib.5.3.jar
31 ARGEO_MAKE
= $(JVM
) -cp
$(LOGGER_JAR
):$(ECJ_JAR
):$(BNDLIB_JAR
) $(SDK_SRC_BASE
)/sdk
/argeo-build
/src
/org
/argeo
/build
/Make.java
33 JAVADOC_SRCS
= $(foreach bundle
, $(BUNDLES
), $(bundle
)/src
)
35 BUILD_BASE
= $(SDK_BUILD_BASE
)/$(shell basename $(SDK_SRC_BASE
))
37 TARGET_BUNDLES
= $(abspath
$(foreach bundle
, $(BUNDLES
),$(A2_OUTPUT
)/$(shell dirname
$(bundle
))/$(A2_CATEGORY
)/$(shell basename $(bundle
)).
$(major
).
$(minor
).jar
))
38 TODOS
= $(foreach bundle
, $(BUNDLES
),$(BUILD_BASE
)/$(bundle
)/to-build
)
40 ## Needed in order to be able to expand $$ variables
42 .PHONY
: osgi manifests javadoc
44 osgi
: $(BUILD_BASE
)/built
46 javadoc
: $(BUILD_BASE
)/built
47 $(JAVADOC
) -quiet
-Xmaxwarns
1 -d
$(BUILD_BASE
)/api
--source-path
$(subst $(space
),$(pathsep
),$(strip $(JAVADOC_SRCS
))) -subpackages
$(JAVADOC_PACKAGES
)
49 # Actual build (compilation + bundle packaging)
50 $(BUILD_BASE
)/built
: BUNDLES_TO_BUILD
= $(subst $(abspath
$(BUILD_BASE
))/,, $(subst to-build
,, $?
))
51 $(BUILD_BASE
)/built
: $(TODOS
)
52 $(JVM
) -cp
$(LOGGER_JAR
):$(ECJ_JAR
):$(BNDLIB_JAR
) $(SDK_SRC_BASE
)/sdk
/argeo-build
/src
/org
/argeo
/build
/Make.java \
53 all --a2-bases
$(A2_BASE
) --dep-categories
$(DEP_CATEGORIES
) --category
$(A2_CATEGORY
) --bundles
$(BUNDLES_TO_BUILD
)
54 touch
$(BUILD_BASE
)/built
56 #$(A2_OUTPUT)/%.$(major).$(minor).jar : $(BUILD_BASE)/$$(subst $(A2_CATEGORY)/,,$$*)/to-build
57 # $(ARGEO_MAKE) all --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) --category $(A2_CATEGORY) --bundles $(subst $(A2_CATEGORY)/,,$*)
59 $(BUILD_BASE
)/%/to-build
: $$(shell find
% -type f
-not
-path
'bin/*' -not
-path
'*/MANIFEST.MF' | sed
's/ /\\ /g')
66 @mkdir
-p
$(foreach bundle
, $(BUNDLES
), $(bundle
)/META-INF
/);
67 @
$(foreach bundle
, $(BUNDLES
), cp
-v
$(BUILD_BASE
)/$(bundle
)/META-INF
/MANIFEST.MF
$(bundle
)/META-INF
/MANIFEST.MF
;)
69 # Make variables used to replace spaces by a separator, typically in order to generate classpaths
70 # for example: CLASSPATH = $(subst $(space),$(pathsep),$(strip $(JARS)))