summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-07-25 13:14:13 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-07-25 13:14:13 -0400
commit51b5a4b1150234fe8b0040bcab68f51bcd224db0 (patch)
treeaa712008f3b0a3d04f5d329d0680b4c8962f3d4e /Makefile
parent2d21b6182241ab16e27198e85c97e2e38e7ab2d9 (diff)
Makefile: Pull $(shell) operations into $(call) macros.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile63
1 files changed, 39 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index eda6e82..91c5dc4 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,21 @@ WGET = wget
all: package
+# utilities ####################################################################
+
+# 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')")
+name2base = $(call spec2base,$($1))
+name2file = $(shell utils/spec2file '$($1)')
+file2url = $(shell utils/file2url '$1')
+file2base = $(shell utils/file2base '$1')
+file2extra = $(shell utils/file2extra '$1')
+
+dep_dir = $1 $(shell $(FIND) $1 2>/dev/null)
+dep_optdir = $(shell $(FIND) $1 2>/dev/null)
+
# configuration ################################################################
packages := $(filter-out _%,$(shell $(SED) "s/[\# ].*//" conf/sources.mk))
@@ -25,42 +40,42 @@ 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/$(shell utils/file2base "$$(utils/spec2file '$(spec)')"))
+tarbombs := $(foreach spec,$(_tarbombs),build/extract/$(call spec2base,$(spec)))
# download #####################################################################
-download: PHONY $(foreach package,$(packages),build/download/$(shell utils/spec2file '$($(package))'))
+download: PHONY $(foreach package,$(packages),build/download/$(call name2file,$(package)))
build/download/git/%: .tokens/network
if [ -d '$@' ]; then \
cd '$@' && $(GIT) fetch --all -p; \
else \
- $(MKDIRS) '$(@D)' && $(GIT) clone --mirror '$(shell utils/file2url 'git/$*')' '$@'; \
+ $(MKDIRS) '$(@D)' && $(GIT) clone --mirror '$(call file2url,git/$*)' '$@'; \
fi
$(TOUCH) '$@'
build/download/svn/%: .tokens/network
- if ! [ -d '$(shell utils/file2base 'svn/$*')' ]; then \
+ if ! [ -d '$(call file2base,svn/$*)' ]; then \
$(RM) -r '$@' && \
$(MKDIRS) build/download/svn && \
$(SVN) checkout --depth=empty \
- '$(shell utils/file2url 'svn/$*')' \
- build/download/'$(shell utils/file2base 'svn/$*')' && \
- cd build/download/'$(shell utils/file2base 'svn/$*')'; \
+ '$(call file2url,svn/$*)' \
+ build/download/'$(call file2base,svn/$*)' && \
+ cd build/download/'$(call file2base,svn/$*)'; \
else \
- cd build/download/'$(shell utils/file2base 'svn/$*')' && \
+ cd build/download/'$(call file2base,svn/$*)' && \
$(SVN) update; \
fi && \
- $(SVN) update --parents '$(shell utils/file2extra 'svn/$*')'
+ $(SVN) update --parents '$(call file2extra,svn/$*)'
$(EXISTS) '$@'
$(TOUCH) '$@'
build/download/tar/%: .tokens/network
$(MKDIRS) '$(@D)'
- $(WGET) -c -O '$@' '$(shell utils/file2url 'tar/$*')'
+ $(WGET) -c -O '$@' '$(call file2url,tar/$*)'
$(TOUCH) '$@'
# extract ######################################################################
-extract: PHONY $(foreach package,$(packages),build/extract/$(shell utils/spec2file '$($(package))'))
+extract: PHONY $(foreach package,$(packages),build/extract/$(call name2file,$(package)))
# 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
@@ -71,12 +86,12 @@ extract: PHONY $(foreach package,$(packages),build/extract/$(shell utils/spec2fi
# git
build/extract/git/%: # magic foreach loop
- gitref='$(shell utils/file2extra 'git/$*'|cut -d/ -f1)' && \
- gitdir=build/extract/'$(shell utils/file2base 'git/$*')'/$${gitref} && \
+ gitref='$(firstword $(subst /, ,$(call file2extra,git/$*)))' && \
+ gitdir=build/extract/'$(call file2base,git/$*)'/$${gitref} && \
$(RM) -r "$$gitdir" && \
{ \
$(MKDIRS) "$$(dirname "$$gitdir")" && \
- $(GIT) clone build/download/'$(shell utils/file2base 'git/$*')' "$$gitdir" && \
+ $(GIT) clone build/download/'$(call file2base,git/$*)' "$$gitdir" && \
( cd "$$gitdir" && $(GIT) checkout "$$gitref" ) && \
$(EXISTS) '$@'; \
} || { $(RM) -r "$$gitdir"; $(FAIL); }
@@ -90,7 +105,7 @@ build/extract/svn/%: build/download/svn/%
$(TOUCH) '$@'
# tar
-_tar_basedir=build/extract/$(shell utils/file2base 'tar/$*')
+_tar_basedir=build/extract/$(call file2base,tar/$*)
build/extract/tar/%: # magic foreach loop
$(RM) -r '$(_tar_basedir)' && \
{ \
@@ -99,13 +114,13 @@ build/extract/tar/%: # magic foreach loop
} || { $(RM) -r '$(_tar_basedir)'; $(FAIL); }
# magic foreach loop
-$(foreach package,$(packages), \
- $(if $(foreach s,git tar,$(filter $s|%,$($(package)))), \
- $(eval \
- build/extract/$(shell utils/spec2file '$($(package))'): \
- build/download/$(shell utils/file2base "$$(utils/spec2file '$($(package))')") \
- ) \
- ) \
+$(foreach package,$(packages), \
+ $(if $(foreach s,git tar,$(filter $s|%,$($(package)))), \
+ $(eval \
+ build/extract/$(call name2file,$(package)): \
+ build/download/$(call name2base,$(package)) \
+ ) \
+ ) \
)
# place (patch) ################################################################
@@ -130,8 +145,8 @@ build/workdir/%:
# beteen `build/compile` and `build/extract`.
$(foreach package,$(packages),$(eval \
build/workdir/$(package): \
- build/extract/$(shell utils/spec2file '$($(package))') \
- $(shell $(FIND) rules/$(package) 2>/dev/null) \
+ build/extract/$(call name2file,$(package)) \
+ $(call dep_optdir,rules/$(package)) \
))
# package ######################################################################