diff options
Diffstat (limited to 'rules/janino/Makefile')
-rw-r--r-- | rules/janino/Makefile | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/rules/janino/Makefile b/rules/janino/Makefile new file mode 100644 index 0000000..042e6f3 --- /dev/null +++ b/rules/janino/Makefile @@ -0,0 +1,54 @@ +DESTDIR ?= +MAVEN_LOCAL_REPO ?= ~/.m2 + +ANT = ant +EXISTS = test -e +FAIL = exit 1 +FIND = find +INSTALL = install +MKDIRS = mkdir -p +RM = rm -f +SED = sed +TOUCH = touch +XMLSTARLET = xml + +pom_get = $(shell $(XMLSTARLET) sel -T -t $(foreach xpath,$1, -v '$(subst /,/_:,$(xpath))' -n) janino-dist/poms/$(artifactId).pom) + +version := $(shell $(SED) -n 's/^version\s*=\s*//p' janino-dist/build.properties) +artifactIds := $(patsubst janino-dist/poms/%.pom,%,$(wildcard janino-dist/poms/*.pom)) +groupId = $(firstword $(call pom_get,/project/groupId /project/parent/groupId)) + +findjar = $(firstword $(foreach path,$(subst :, ,$(CLASSPATH)),$(if $(findstring $1,$(path)),$(path))) /notfound.jar) +ant_jar = $(call findjar,ant) + +all: PHONY $(foreach a,$(artifactIds),janino-dist/build/$a.jar .poms/$a-$(version).jar) + +ignore = .poms build mirror +janino-dist/build: $(shell $(FIND) . -mindepth 1 $(foreach d,$(ignore),-name $d -prune -o) -name '* *' -prune -o -print) + $(SED) -ri 's|^(ant\.jar\s*=).*|\1 $(ant_jar)|' janino-dist/build.properties && \ + cd janino-dist && $(ANT) || { $(RM) -r $@; $(FAIL); } + $(TOUCH) $@ +janino-dist/build/%.jar: janino-dist/build + $(EXISTS) $@ || { $(RM) -r $<; $(FAIL); } + $(TOUCH) $@ + +.poms/%-$(version).pom: janino-dist/poms/%.pom + $(MKDIRS) $(@D) + $(SED) 's|@VERSION@|$(version)|' < $< > $@ + +install-base = $(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(groupId))/$(artifactId)/$(version)/$(artifactId)-$(version) +install-jars = $(foreach artifactId,$(filter-out %-parent,$(artifactIds)),$(install-base).jar) +install-poms = $(foreach artifactId, $(artifactIds) ,$(install-base).pom) +install-targets = $(install-jars) $(install-poms) +install: PHONY $(install-targets) + +$(foreach artifactId,$(artifactIds), \ + $(eval $(install-base).jar: janino-dist/build/$(artifactId).jar ; $$(INSTALL) -Dm644 $$< $$@) \ + $(eval $(install-base).pom: .poms/$(artifactId)-$(version).pom ; $$(INSTALL) -Dm644 $$< $$@) ) + +clean: PHONY + $(RM) -r .poms janino-dist/build + +.PHONY: PHONY +.DELETE_ON_ERROR: +.SECONDARY: |