diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2014-07-25 14:22:27 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2014-07-25 14:22:27 -0400 |
commit | 78e658c8774c5009d9ff601fb6ac9a66810790b6 (patch) | |
tree | 3fb3343293e46876356094894e0f88128f3f52be /Makefile | |
parent | 51b5a4b1150234fe8b0040bcab68f51bcd224db0 (diff) |
Makefile: avoid shelling out inside of a loop. Also fix a 'download:' bug.
- This should speed up Makefile parse times
- This is still not avoided for the "magic foreach loop".
- The bug in 'download:' is that it was always using the 'file'; for git
and tar, it needs the 'base'.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -23,12 +23,18 @@ all: package # spec = type|url|extra # file ~= type/url/extra # but with 'url' mangled # base ~= type/url # but with 'url' mangled -spec2base = $(shell utils/file2base "$$(utils/spec2file '$1')") + +name2file = $(call spec2file,$($1)) name2base = $(call spec2base,$($1)) -name2file = $(shell utils/spec2file '$($1)') -file2url = $(shell utils/file2url '$1') -file2base = $(shell utils/file2base '$1') -file2extra = $(shell utils/file2extra '$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')) + +specs_for = $(strip $(foreach t,$1,$(filter $t|%,$(if $2,$2,$(specs))))) dep_dir = $1 $(shell $(FIND) $1 2>/dev/null) dep_optdir = $(shell $(FIND) $1 2>/dev/null) @@ -40,11 +46,16 @@ include conf/sources.mk include conf/dependencies.mk export MAVEN_LOCAL_REPO := $(shell $(CAT) conf/maven.local.repo.txt) export JAR_DIR := $(shell $(CAT) conf/jardir.txt) -tarbombs := $(foreach spec,$(_tarbombs),build/extract/$(call spec2base,$(spec))) + +specs := $(foreach package,$(packages),$($(package))) +tarbombs := $(addprefix build/extract/,$(call spec2base,$(_tarbombs))) # download ##################################################################### -download: PHONY $(foreach package,$(packages),build/download/$(call name2file,$(package))) +download: PHONY \ + $(addprefix build/download/, \ + $(call spec2base,$(call specs_for,git tar)) \ + $(call spec2file,$(call specs_for,svn)) ) build/download/git/%: .tokens/network if [ -d '$@' ]; then \ @@ -75,7 +86,7 @@ build/download/tar/%: .tokens/network # extract ###################################################################### -extract: PHONY $(foreach package,$(packages),build/extract/$(call name2file,$(package))) +extract: PHONY $(addprefix build/extract,$(call spec2file,$(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 @@ -115,7 +126,7 @@ build/extract/tar/%: # magic foreach loop # magic foreach loop $(foreach package,$(packages), \ - $(if $(foreach s,git tar,$(filter $s|%,$($(package)))), \ + $(if $(call specs_for,git tar,$($(package))), \ $(eval \ build/extract/$(call name2file,$(package)): \ build/download/$(call name2base,$(package)) \ |