summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-07-25 12:04:53 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-07-25 12:04:53 -0400
commit2d21b6182241ab16e27198e85c97e2e38e7ab2d9 (patch)
tree5bf14939116449d192520ea99c93eb119f9f8320 /Makefile
parent142f953376310fc413a8dce623f017be907d8dda (diff)
Makefile: touch up
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile33
1 files changed, 21 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 2c1a28b..eda6e82 100644
--- a/Makefile
+++ b/Makefile
@@ -69,6 +69,7 @@ extract: PHONY $(foreach package,$(packages),build/extract/$(shell utils/spec2fi
# possibilities. `svn` doesn't have this issue, because, unlike `git`
# and `tar`, its `extra` component is present in `build/download`.
+# git
build/extract/git/%: # magic foreach loop
gitref='$(shell utils/file2extra 'git/$*'|cut -d/ -f1)' && \
gitdir=build/extract/'$(shell utils/file2base 'git/$*')'/$${gitref} && \
@@ -81,24 +82,31 @@ build/extract/git/%: # magic foreach loop
} || { $(RM) -r "$$gitdir"; $(FAIL); }
$(TOUCH) '$@'
+# svn
build/extract/svn/%: build/download/svn/%
$(RM) -r '$@'
$(MKDIRS) '$(@D)'
- $(CP) -a '$<' '$@'
+ $(CP) -a '$<' '$@' || { $(RM) -r '$@'; $(FAIL); }
$(TOUCH) '$@'
-basedir=build/extract/$(shell utils/file2base 'tar/$*')
+# tar
+_tar_basedir=build/extract/$(shell utils/file2base 'tar/$*')
build/extract/tar/%: # magic foreach loop
- $(RM) -r '$(basedir)' && \
+ $(RM) -r '$(_tar_basedir)' && \
{ \
- $(MKDIRS) '$(basedir)' && \
- ( cd '$(basedir)' && $(TAR) -m $(if $(filter $(basedir),$(tarbombs)),,--strip-components 1) -xf '$(top)/$<' ); \
- } || { $(RM) -r '$(basedir)'; $(FAIL); }
-
-$(foreach package,$(packages),$(if $(filter-out svn|%,$($(package))),$(eval \
- build/extract/$(shell utils/spec2file '$($(package))'): \
- build/download/$(shell utils/file2base "$$(utils/spec2file '$($(package))')") \
-)))
+ $(MKDIRS) '$(_tar_basedir)' && \
+ ( cd '$(_tar_basedir)' && $(TAR) -m $(if $(filter $(_tar_basedir),$(tarbombs)),,--strip-components 1) -xf '$(top)/$<' ); \
+ } || { $(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))')") \
+ ) \
+ ) \
+ )
# place (patch) ################################################################
@@ -108,7 +116,7 @@ $(addprefix build/workdir/,$(packages)): \
build/workdir/%:
$(RM) -r '$@'
$(MKDIRS) '$(@D)'
- $(CP) -a '$<' '$@'
+ $(CP) -a '$<' '$@' || { $(RM) -r '$@'; $(FAIL); }
cd '$@' && \
for patch in $(sort $(wildcard $(top)/rules/$*/*.patch)); do \
$(PATCH) -p1 < $$patch || { $(RM) -r '$@'; $(FAIL); }; \
@@ -165,3 +173,4 @@ distclean: PHONY
.PHONY: RECURSIVE PHONY
.DELETE_ON_ERROR:
+.SECONDARY: