diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-12-18T15·40+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-12-18T15·40+0100 |
commit | 259086de841d155f7951c2cc50f799a4631aa512 (patch) | |
tree | 898b47170571c93bf8a153bcb618360b45c8ece1 /mk | |
parent | 99ed25accfd968003d3b0d294720828a1348ce47 (diff) |
Add support for building JARs from Java sources
Diffstat (limited to 'mk')
-rw-r--r-- | mk/jars.mk | 29 | ||||
-rw-r--r-- | mk/lib.mk | 11 |
2 files changed, 39 insertions, 1 deletions
diff --git a/mk/jars.mk b/mk/jars.mk new file mode 100644 index 000000000000..5d459c0a9d70 --- /dev/null +++ b/mk/jars.mk @@ -0,0 +1,29 @@ +define build-jar = + $(1)_NAME ?= $(1) + + _d := $$(strip $$($(1)_DIR)) + + $(1)_PATH := $$(_d)/$$($(1)_NAME).jar + + $(1)_TMPDIR := $$(_d)/.$$($(1)_NAME).jar.tmp + + $$($(1)_PATH): $$($(1)_SOURCES) + @rm -rf $$($(1)_TMPDIR) + @mkdir -p $$($(1)_TMPDIR) + $(QUIET) javac $(GLOBAL_JAVACFLAGS) $$($(1)_JAVACFLAGS) -d $$($(1)_TMPDIR) $$($(1)_SOURCES) + $(QUIET) jar cf $$($(1)_PATH) -C $$($(1)_TMPDIR) . + @rm -rf $$($(1)_TMPDIR) + + $(1)_INSTALL_DIR ?= $$(libdir)/java + + $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).jar + + $$(eval $$(call install-file-as, $$($(1)_PATH), $$($(1)_INSTALL_PATH), 0644)) + + install: $$($(1)_INSTALL_PATH) + + jars_list += $$($(1)_PATH) + + clean_files += $$($(1)_PATH) + +endef diff --git a/mk/lib.mk b/mk/lib.mk index 1d2f05162812..2d8ceef55f3e 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -37,6 +37,7 @@ BUILD_DEBUG ?= 1 ifeq ($(BUILD_DEBUG), 1) GLOBAL_CFLAGS += -g GLOBAL_CXXFLAGS += -g + GLOBAL_JAVACFLAGS += -g endif @@ -50,6 +51,7 @@ include mk/dist.mk include mk/install.mk include mk/libraries.mk include mk/programs.mk +include mk/jars.mk include mk/patterns.mk include mk/templates.mk include mk/tests.mk @@ -67,6 +69,7 @@ $(foreach mf, $(SUBS), $(eval $(call include-sub-makefile, $(mf)))) # Instantiate stuff. $(foreach lib, $(LIBS), $(eval $(call build-library,$(lib)))) $(foreach prog, $(PROGRAMS), $(eval $(call build-program,$(prog)))) +$(foreach jar, $(JARS), $(eval $(call build-jar,$(jar)))) $(foreach script, $(bin_SCRIPTS), $(eval $(call install-program-in,$(script),$(bindir)))) $(foreach script, $(bin_SCRIPTS), $(eval programs_list += $(script))) $(foreach script, $(noinst_SCRIPTS), $(eval programs_list += $(script))) @@ -74,7 +77,7 @@ $(foreach template, $(template_files), $(eval $(call instantiate-template,$(temp $(foreach test, $(INSTALL_TESTS), $(eval $(call run-install-test,$(test)))) -all: $(programs_list) $(libs_list) +all: $(programs_list) $(libs_list) $(jars_list) help: @@ -99,3 +102,9 @@ ifdef libs_list @echo "" @for i in $(libs_list); do echo " $$i"; done endif +ifdef jars_list + @echo "" + @echo "The following JARs can be built:" + @echo "" + @for i in $(jars_list); do echo " $$i"; done +endif |