diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2014-07-25 16:18:55 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2014-07-25 16:18:55 -0400 |
commit | d90ded5641d3964e34fca8bb093a83fb64658ee2 (patch) | |
tree | 98b5b2e37be21b899acd12920a7af42c12387cd0 /Makefile | |
parent | 78e658c8774c5009d9ff601fb6ac9a66810790b6 (diff) |
Generalize the utils to make the target an argument.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 68 |
1 files changed, 31 insertions, 37 deletions
@@ -20,19 +20,13 @@ all: package # utilities #################################################################### -# spec = type|url|extra -# file ~= type/url/extra # but with 'url' mangled -# base ~= type/url # but with 'url' mangled - -name2file = $(call spec2file,$($1)) -name2base = $(call spec2base,$($1)) - -spec2file = $(shell utils/spec2file $(foreach a,$1,'$a') ) -spec2base = $(shell utils/file2base $$(utils/spec2file $(foreach a,$1,'$a'))) - -file2url = $(shell utils/file2url $(foreach a,$1,'$a')) -file2base = $(shell utils/file2base $(foreach a,$1,'$a')) -file2extra = $(shell utils/file2extra $(foreach a,$1,'$a')) +# murl = "mangled url" +# spec = type|url|extra +# file = type/murl/extra +# base = type/murl +name2 = $(call spec2,$1,$(foreach package,$2,$($(package)))) +spec2 = $(shell utils/spec2 $1 $(foreach a,$2,'$a')) +file2 = $(shell utils/file2 $1 $(foreach a,$2,'$a')) specs_for = $(strip $(foreach t,$1,$(filter $t|%,$(if $2,$2,$(specs))))) @@ -48,45 +42,45 @@ export MAVEN_LOCAL_REPO := $(shell $(CAT) conf/maven.local.repo.txt) export JAR_DIR := $(shell $(CAT) conf/jardir.txt) specs := $(foreach package,$(packages),$($(package))) -tarbombs := $(addprefix build/extract/,$(call spec2base,$(_tarbombs))) +tarbombs := $(addprefix build/extract/,$(call spec2,base,$(_tarbombs))) # download ##################################################################### download: PHONY \ $(addprefix build/download/, \ - $(call spec2base,$(call specs_for,git tar)) \ - $(call spec2file,$(call specs_for,svn)) ) + $(call spec2,base,$(call specs_for,git tar)) \ + $(call spec2,file,$(call specs_for,svn)) ) build/download/git/%: .tokens/network if [ -d '$@' ]; then \ cd '$@' && $(GIT) fetch --all -p; \ else \ - $(MKDIRS) '$(@D)' && $(GIT) clone --mirror '$(call file2url,git/$*)' '$@'; \ + $(MKDIRS) '$(@D)' && $(GIT) clone --mirror '$(call file2,url,git/$*)' '$@'; \ fi $(TOUCH) '$@' build/download/svn/%: .tokens/network - if ! [ -d '$(call file2base,svn/$*)' ]; then \ + if ! [ -d '$(call file2,base,svn/$*)' ]; then \ $(RM) -r '$@' && \ $(MKDIRS) build/download/svn && \ $(SVN) checkout --depth=empty \ - '$(call file2url,svn/$*)' \ - build/download/'$(call file2base,svn/$*)' && \ - cd build/download/'$(call file2base,svn/$*)'; \ + '$(call file2,url ,svn/$*)' \ + build/download/'$(call file2,base,svn/$*)' && \ + cd build/download/'$(call file2,base,svn/$*)'; \ else \ - cd build/download/'$(call file2base,svn/$*)' && \ + cd build/download/'$(call file2,base,svn/$*)' && \ $(SVN) update; \ fi && \ - $(SVN) update --parents '$(call file2extra,svn/$*)' + $(SVN) update --parents '$(call file2,extra,svn/$*)' $(EXISTS) '$@' $(TOUCH) '$@' build/download/tar/%: .tokens/network $(MKDIRS) '$(@D)' - $(WGET) -c -O '$@' '$(call file2url,tar/$*)' + $(WGET) -c -O '$@' '$(call file2,url,tar/$*)' $(TOUCH) '$@' # extract ###################################################################### -extract: PHONY $(addprefix build/extract,$(call spec2file,$(specs))) +extract: PHONY $(addprefix build/extract,$(call spec2,file,$(specs))) # This is a little gross because to get the dependencies right for # `git` and `tar`, we need to do a bit more complex processing of @@ -97,12 +91,12 @@ extract: PHONY $(addprefix build/extract,$(call spec2file,$(specs))) # git build/extract/git/%: # magic foreach loop - gitref='$(firstword $(subst /, ,$(call file2extra,git/$*)))' && \ - gitdir=build/extract/'$(call file2base,git/$*)'/$${gitref} && \ + gitref='$(firstword $(subst /, ,$(call file2,extra,git/$*)))' && \ + gitdir=build/extract/'$(call file2,base,git/$*)'/$${gitref} && \ $(RM) -r "$$gitdir" && \ { \ $(MKDIRS) "$$(dirname "$$gitdir")" && \ - $(GIT) clone build/download/'$(call file2base,git/$*)' "$$gitdir" && \ + $(GIT) clone build/download/'$(call file2,base,git/$*)' "$$gitdir" && \ ( cd "$$gitdir" && $(GIT) checkout "$$gitref" ) && \ $(EXISTS) '$@'; \ } || { $(RM) -r "$$gitdir"; $(FAIL); } @@ -116,7 +110,7 @@ build/extract/svn/%: build/download/svn/% $(TOUCH) '$@' # tar -_tar_basedir=build/extract/$(call file2base,tar/$*) +_tar_basedir=build/extract/$(call file2,base,tar/$*) build/extract/tar/%: # magic foreach loop $(RM) -r '$(_tar_basedir)' && \ { \ @@ -125,13 +119,13 @@ build/extract/tar/%: # magic foreach loop } || { $(RM) -r '$(_tar_basedir)'; $(FAIL); } # magic foreach loop -$(foreach package,$(packages), \ - $(if $(call specs_for,git tar,$($(package))), \ - $(eval \ - build/extract/$(call name2file,$(package)): \ - build/download/$(call name2base,$(package)) \ - ) \ - ) \ +$(foreach package,$(packages), \ + $(if $(call specs_for,git tar,$($(package))), \ + $(eval \ + build/extract/$(call name2,file,$(package)): \ + build/download/$(call name2,base,$(package)) \ + ) \ + ) \ ) # place (patch) ################################################################ @@ -156,7 +150,7 @@ build/workdir/%: # beteen `build/compile` and `build/extract`. $(foreach package,$(packages),$(eval \ build/workdir/$(package): \ - build/extract/$(call name2file,$(package)) \ + build/extract/$(call name2,file,$(package)) \ $(call dep_optdir,rules/$(package)) \ )) |