-# Thierry - when called from within the build, PWD is /build
-SOURCEFILES := $(main.FILE)
-
-$(main.FILE): #FORCE
- @if [ ! -e "$@" ] ; then echo "$(CURL) $(main.URL)" ; $(CURL) $(main.URL) ; fi
- @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
- @if test "$$(sha1sum $@ | awk '{print $$1}')" != "$(main.SHA1SUM)" ; then \
- echo "sha1sum of the downloaded $@ does not match the one from 'sources' file" ; \
- echo "Local copy: $$(sha1sum $@)" ; \
- echo "In sources: $(main.SHA1SUM)" ; \
- exit 1 ; \
+##############################
+define download_target
+$(1): $($(1))
+.PHONY: $(1)
+$($(1)):
+ @if [ ! -e "$($(1))" ] ; then \
+ { echo Using primary; echo "$(WEBFETCH) $($(1)-URL1)" ; $(WEBFETCH) $($(1)-URL1) ; } || \
+ { echo Using secondary; echo "$(WEBFETCH) $($(1)-URL2)" ; $(WEBFETCH) $($(1)-URL2) ; } ; fi
+ @if [ ! -e "$($(1))" ] ; then echo "Could not download source file: $($(1)) does not exist" ; exit 1 ; fi
+ @if test "$$$$($(SHA1SUM) $($(1)) | awk '{print $$$$1}')" != "$($(1)-SHA1SUM)" ; then \
+ echo "sha1sum of the downloaded $($(1)) does not match the one from 'Makefile'" ; \
+ echo "Local copy: $$$$($(SHA1SUM) $($(1)))" ; \
+ echo "In Makefile: $($(1)-SHA1SUM)" ; \
+ false ; \