DESTDIR ?= JAR_DIR ?= /usr/share/java MAVEN_LOCAL_REPO ?= ~/.m2 ANT = ant EGREP = grep -E EXISTS = test -e FAIL = exit 1 FIND = find INSTALL = install PRINTF = printf RM = rm -f TOUCH = touch artifactId = jarjar-plugin version = 1.4 groupId = com.tonicsystems.jarjar dep_dir = $1 $(shell $(FIND) $1 2>/dev/null) findjar = $(firstword $(shell IFS=:; $(PRINTF) '%s\n' $$CLASSPATH | $(EGREP) '/$1(-[0-9.-]*)?\.jar$$') /notfound.jar) asm_jar = $(call findjar,asm) asm_commons_jar = $(call findjar,asm-commons) all: PHONY dist dist: $(call dep_dir,src maven) lib/asm-4.0.jar lib/asm-commons-4.0.jar $(RM) -r $@ build # javadoc doesn't work; hence using 'jar' instead of 'dist' $(ANT) jar mojo || { $(RM) -r $@ build; $(FAIL); } $(TOUCH) $@ lib/asm-4.0.jar: $(asm_jar) $(INSTALL) -Dm644 $< $@ lib/asm-commons-4.0.jar: $(asm_commons_jar) $(INSTALL) -Dm644 $< $@ dist/%.jar: dist $(EXISTS) $@ $(TOUCH) $@ dist/maven/pom.xml: dist $(EXISTS) $@ $(TOUCH) $@ install-base = $(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(groupId))/$(artifactId)/$(version)/$(artifactId)-$(version) install: PHONY $(install-base).pom $(install-base).jar $(DESTDIR)$(JAR_DIR)/jarjar-$(version).jar $(install-base).pom: dist/maven/pom.xml $(INSTALL) -Dm644 $< $@ $(install-base).jar: dist/jarjar-plugin-$(version).jar $(INSTALL) -Dm644 $< $@ $(DESTDIR)$(JAR_DIR)/jarjar-$(version).jar: dist/jarjar-$(version).jar $(INSTALL) -Dm644 $< $@ clean: PHONY $(RM) -r dist build lib/*.jar .PHONY: PHONY .DELETE_ON_ERROR: .SECONDARY: