diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-06-03 19:46:25 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-06-03 21:41:08 -0400 |
commit | 663c2228be4cf1335cfa2ff358d41d8a61e57f21 (patch) | |
tree | ffd1e82643b3c9db3902272625cd9b7dbde1ccf6 | |
parent | 46cc24b1b6a0472ddab62179ed268f6d13deae19 (diff) |
Clean up some variable names, generalize the extra makefile logic
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | rules/atinject-javax.inject/Makefile | 28 | ||||
-rw-r--r-- | rules/generic/Makefile | 46 | ||||
-rw-r--r-- | rules/guava/Makefile | 2 | ||||
-rw-r--r-- | rules/guava/sourceDirectory.mk | 1 | ||||
-rw-r--r-- | rules/jsr305/Makefile | 14 | ||||
-rw-r--r-- | rules/plexus-build-api/version.mk (renamed from rules/plexus-build-api/subdir-deps.mk) | 0 |
7 files changed, 47 insertions, 50 deletions
@@ -117,15 +117,13 @@ deps2classpath = $(shell echo $(abspath $(call deps2jars,$1)) | tr ' ' :) $(addprefix build/packages/,$(package_specific)): \ build/packages/%: RECURSIVE build/workdir/% rules/%/Makefile - CLASSPATH='$(call deps2classpath,$^)' \ - $(if $(wildcard rules/$*/subdir-deps.mk),subdir_deps='$(abspath rules/$*/subdir-deps.mk)') \ + CLASSPATH='$(call deps2classpath,$^)' extra_makefiles='$(abspath $(wildcard rules/$*/*.mk))' \ $(MAKE) -C build/workdir/$* -f '$(top)/rules/$*/Makefile' install DESTDIR='$(top)/$@' mkdir -p build/packages/all && lndir -silent '$(top)/$@' build/packages/all $(addprefix build/packages/,$(package_generic)): \ build/packages/%: RECURSIVE build/workdir/% rules/generic/Makefile - CLASSPATH='$(call deps2classpath,$^)' \ - $(if $(wildcard rules/$*/subdir-deps.mk),subdir_deps='$(abspath rules/$*/subdir-deps.mk)') \ + CLASSPATH='$(call deps2classpath,$^)' extra_makefiles='$(abspath $(wildcard rules/$*/*.mk))' \ $(MAKE) -C build/workdir/$* -f '$(top)/rules/generic/Makefile' install DESTDIR='$(top)/$@' mkdir -p build/packages/all && lndir -silent '$(top)/$@' build/packages/all diff --git a/rules/atinject-javax.inject/Makefile b/rules/atinject-javax.inject/Makefile index 2ee9767..5738f78 100644 --- a/rules/atinject-javax.inject/Makefile +++ b/rules/atinject-javax.inject/Makefile @@ -1,34 +1,32 @@ DESTDIR ?= MAVEN_LOCAL_REPO ?= ~/.m2 -XMLSTARLET = xml -RM = rm -f -MKDIRS = mkdir -p -INSTALL = install FIND = find +INSTALL = install +RM = rm -f SED = sed +XMLSTARLET = xml -artifact := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:artifactId -n pom.xml) +artifactId := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:artifactId -n pom.xml) version := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:version -n pom.xml) -group := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:groupId -n pom.xml) +groupId := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:groupId -n pom.xml) all: PHONY build -build: $(shell $(FIND) src tck) +build: $(shell $(FIND) src) $(SED) -e 's/VERSION=.*/VERSION=$(version)/' -e /tck/d -e /junit/d build.sh | $(SHELL) || { $(RM) -r build; exit 1; } -build/maven/%: build -mvndir = $(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(group))/$(artifact)/$(version) +install-dir = $(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(groupId))/$(artifactId)/$(version) +install-targets = $(addprefix $(install-dir)/$(artifactId)-$(version),.pom .jar -sources.jar -javadoc.jar) +install: PHONY $(install-targets) -install: PHONY build \ - $(addprefix $(mvndir)/$(artifact)-$(version),.pom .jar -sources.jar -javadoc.jar) - - $(addprefix $(mvndir)/$(artifact)-$(version),.jar -sources.jar -javadoc.jar): \ -$(mvndir)/%: build/maven/% +$(filter-out %.pom,$(install-targets)): $(install-dir)/%: build/maven/% $(INSTALL) -Dm644 $< $@ -$(mvndir)/$(artifact)-$(version).pom: build/maven/pom.xml +$(install-dir)/$(artifactId)-$(version).pom: build/maven/pom.xml $(INSTALL) -Dm644 $< $@ +$(addprefix build/maven/,$(notdir $(filter-out %.pom,$(install-targets)) pom.xml)): build/maven/%: build + clean: PHONY $(RM) -r build diff --git a/rules/generic/Makefile b/rules/generic/Makefile index e059ce7..89e2afc 100644 --- a/rules/generic/Makefile +++ b/rules/generic/Makefile @@ -15,15 +15,15 @@ JAR = jar CP = cp # Detect information from POMs -artifact := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:artifactId -n pom.xml) -version := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:version -n -c /_:project/_:parent/_:version pom.xml) $(version)) -group := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:groupId -n -c /_:project/_:parent/_:groupId pom.xml)) -srcdir := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:build/_:sourceDirectory -n pom.xml) $(srcdir) src/main/java) -subdirs := $(patsubst %/pom.xml,%,$(wildcard */pom.xml)) -targets := pom $(if $(wildcard src/main/ $(srcdir)),jar) +artifactId := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:artifactId -n pom.xml) +version := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:version -n -c /_:project/_:parent/_:version pom.xml) $(version)) +groupId := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:groupId -n -c /_:project/_:parent/_:groupId pom.xml)) +sourceDirectory := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:build/_:sourceDirectory -n pom.xml) $(sourceDirectory) src/main/java) -subdir_deps ?= -$(if $(subdir_deps),$(eval include $(subdir_deps))) +subdirs = $(patsubst %/pom.xml,%,$(wildcard */pom.xml)) +targets = pom $(if $(wildcard src/main/ $(sourceDirectory)),jar) + +$(if $(extra_makefiles),$(eval include $(extra_makefiles))) ################################################################################ @@ -33,50 +33,50 @@ dep_optdir = $(shell $(FIND) $1 2>/dev/null) # all all: PHONY \ - $(addprefix target/$(artifact)-$(version).,$(targets)) \ + $(addprefix target/$(artifactId)-$(version).,$(targets)) \ $(addsuffix /all,$(subdirs)) -target/$(artifact)-$(version).pom: pom.xml +target/$(artifactId)-$(version).pom: pom.xml $(INSTALL) -Dm644 $< $@ -target/$(artifact)-$(version).jar: %.jar: % +target/$(artifactId)-$(version).jar: %.jar: % $(JAR) -cf $@ -C $< . -target/$(artifact)-$(version): %: \ - target/META-INF/maven/$(group)/$(artifact)/pom.properties \ - target/META-INF/maven/$(group)/$(artifact)/pom.xml \ +target/$(artifactId)-$(version): %: \ + target/META-INF/maven/$(groupId)/$(artifactId)/pom.properties \ + target/META-INF/maven/$(groupId)/$(artifactId)/pom.xml \ $(call dep_dir,target/classes) \ $(call dep_optdir,src/main/resources) $(RM) -r $@ $(MKDIRS) $@ $(CP) -r target/META-INF $(wildcard target/classes/* src/main/resources/*) $@ -target/META-INF/maven/$(group)/$(artifact)/pom.xml: pom.xml +target/META-INF/maven/$(groupId)/$(artifactId)/pom.xml: pom.xml install -Dm644 $< $@ # That is almost the default date format for locale=C, but the DOM is # 0-padded instead of space-padded. -target/META-INF/maven/$(group)/$(artifact)/pom.properties: pom.xml +target/META-INF/maven/$(groupId)/$(artifactId)/pom.properties: pom.xml $(MKDIRS) $(@D) printf '%s\n' \ '#Generated by Make' \ "#$$(LC_ALL=C date '+%a %b %d %H:%M:%S %Z %Y')" \ 'version=$(version)' \ - 'groupId=$(group)' \ - 'artifactId=$(artifact)' \ + 'groupId=$(groupId)' \ + 'artifactId=$(artifactId)' \ > $@ -target/classes: $(call dep_optdir,$(srcdir)) +target/classes: $(call dep_optdir,$(sourceDirectory)) $(MKDIRS) $@ - $(if $^,$(FIND) $(srcdir) -name '*.java' -exec $(JAVAC) -d $@ {} + || { $(RM) -r $@; exit 1; }) + $(if $^,$(FIND) $(sourceDirectory) -name '*.java' -exec $(JAVAC) -d $@ {} + || { $(RM) -r $@; exit 1; }) # install install: PHONY \ - $(addprefix $(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(group))/$(artifact)/$(version)/$(artifact)-$(version).,$(targets)) \ + $(addprefix $(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(groupId))/$(artifactId)/$(version)/$(artifactId)-$(version).,$(targets)) \ $(addsuffix /install,$(subdirs)) -$(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(group))/$(artifact)/$(version)/%: target/% +$(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(groupId))/$(artifactId)/$(version)/%: target/% $(INSTALL) -Dm644 $< $@ # clean @@ -91,7 +91,7 @@ deps2classpath = $(shell echo $(abspath $(call deps2jars,$1)) $(CLASSPATH) | tr define recurse-rule $1/%: PHONY $(addsuffix /all,$($1_deps)) - CLASSPATH='$$(call deps2classpath,$$^)' srcdir='$$(srcdir)' version='$$(version)' $$(MAKE) -C '$1' -f '$$(abspath $$(firstword $$(MAKEFILE_LIST)))' '$$*' + CLASSPATH='$$(call deps2classpath,$$^)' sourceDirectory='$$(sourceDirectory)' version='$$(version)' $$(MAKE) -C '$1' -f '$$(abspath $$(firstword $$(MAKEFILE_LIST)))' '$$*' endef $(foreach subdir,$(subdirs),$(eval $(call recurse-rule,$(subdir)))) diff --git a/rules/guava/Makefile b/rules/guava/Makefile deleted file mode 100644 index cb70ed9..0000000 --- a/rules/guava/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -srcdir = src -include $(dir $(lastword $(MAKEFILE_LIST)))/../generic/Makefile diff --git a/rules/guava/sourceDirectory.mk b/rules/guava/sourceDirectory.mk new file mode 100644 index 0000000..4470673 --- /dev/null +++ b/rules/guava/sourceDirectory.mk @@ -0,0 +1 @@ +sourceDirectory = src diff --git a/rules/jsr305/Makefile b/rules/jsr305/Makefile index ca5b6d2..f6b1c86 100644 --- a/rules/jsr305/Makefile +++ b/rules/jsr305/Makefile @@ -2,10 +2,9 @@ DESTDIR ?= JAR_DIR ?= /usr/share/java ANT = ant -RM = rm -f -MKDIRS = mkdir -p -INSTALL = install FIND = find +INSTALL = install +RM = rm -f all: PHONY build @@ -13,12 +12,15 @@ build: src $(shell $(FIND) src) $(ANT) jars || { $(RM) -r build; exit 1; } build/%: build -installdir = $(DESTDIR)$(JAR_DIR)/jsr305 -install: PHONY build $(addprefix $(installdir)/jsr305,.jar -pure.jar -src.jar) +install-dir = $(DESTDIR)$(JAR_DIR)/jsr305 +install-targets = $(addprefix $(install-dir)/jsr305,.jar -pure.jar -src.jar) +install: PHONY $(install-targets) -$(installdir)/%: build/% +$(install-targets): $(install-dir)/%: build/% $(INSTALL) -Dm644 $< $@ +$(patsubst $(install-dir)/%,build/%,$(install-targets)): build/%: build + clean: PHONY $(RM) -r build diff --git a/rules/plexus-build-api/subdir-deps.mk b/rules/plexus-build-api/version.mk index b625d2f..b625d2f 100644 --- a/rules/plexus-build-api/subdir-deps.mk +++ b/rules/plexus-build-api/version.mk |