From 2d21b6182241ab16e27198e85c97e2e38e7ab2d9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 25 Jul 2014 12:04:53 -0400 Subject: Makefile: touch up --- Makefile | 33 +++++++++++++++++++++------------ 1 file 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: -- cgit v1.2.3