3 # Common build routines to be included in Makefiles
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
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
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
23 A2_BASE ?
= $(A2_OUTPUT
)
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
30 JAVADOC_SRCS
= $(foreach bundle
, $(BUNDLES
), $(bundle
)/src
)
32 BUILD_BASE
= $(SDK_BUILD_BASE
)/$(shell basename $(SDK_SRC_BASE
))
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
)
37 ## Needed in order to be able to expand $$ variables
39 .PHONY
: osgi manifests javadoc
41 osgi
: $(BUILD_BASE
)/built
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
)
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
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)/,,$*)
56 $(BUILD_BASE
)/%/to-build
: $$(shell find
% -type f
-not
-path
'bin/*' -not
-path
'*/MANIFEST.MF' | sed
's/ /\\ /g')
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
;)
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)))