summaryrefslogtreecommitdiff
path: root/rules/asm2/Makefile
blob: 1e7a03b0792919e5ddadeaf7ad3334ec1284caf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
SYMLINK = ln -sf
TOUCH   = touch
ECHO    = echo

artifactIds := $(patsubst archive/%.xml,%,$(wildcard archive/asm*.xml))
version     := $(shell $(SED) -n 's/^product\.version\s\s*//p' build.properties)
groupId     := asm

findjar = $(firstword $(foreach path,$(subst :, ,$(CLASSPATH)),$(if $(findstring $1,$(path)),$(path))) /notfound.jar)
ow_util_ant_tasks_jar = $(call findjar,ow_util_ant_tasks)
bnd_jar = $(call findjar,biz.aQute.bnd)

all: PHONY output

output: $(shell $(FIND) src) .classpath | test/lib config/biz.aQute.bnd.jar
	$(RM) -r $@
	$(SED) -i '/^objectweb.ant.tasks.path/d' build.properties && \
	$(SED) -i '$$aobjectweb.ant.tasks.path $(ow_util_ant_tasks_jar)' build.properties && \
	$(ANT) jar && \
	( cd output/dist/lib && $(SYMLINK) all/* . ) || \
	{ $(RM) -r $@; $(FAIL); }
	$(TOUCH) $@

test/lib:
	$(MKDIRS) $@

config/biz.aQute.bnd.jar:
	$(MKDIRS) $(@D)
	$(SYMLINK) $(bnd_jar) $@

.classpath:
	{ $(ECHO) '<?xml version="1.0" encoding="UTF-8"?>'; $(ECHO) '<classpath></classpath>'; } > $@

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 target,$(install-targets),$(eval $(target): output/dist/lib/$(notdir $(target)) ; $$(INSTALL) -Dm644 $$< $$@))
$(addprefix output/dist/lib/,$(notdir $(install-targets))): output
	$(EXISTS) $@
	$(TOUCH) $@


clean: PHONY
	$(RM) -r output

.PHONY: PHONY
.DELETE_ON_ERROR:
.SECONDARY: