5 HASH_TOOL ?= $(SHA512SUM)
6 else ifneq ($(SHA256),)
8 HASH_TOOL ?= $(SHA256SUM)
16 ifeq ($(NATIVE_OS), osx)
17 HASH_TOOL = $(SHASUM) -a $(shell echo $(HASH_TYPE) | sed 's/^sha//')
21 # non-depends builds might not set this, use defaults
24 HASH_TOOL_FLAGS = -c --status
27 HASH_SUM = $($(shell echo $(HASH_TYPE) | tr '[:lower:]' '[:upper:]'))
29 .PHONY: $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE)
30 all: $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE)
32 $(TARBALLS_LOCATION)/$(ARCHIVE):
33 cd $(TARBALLS_LOCATION); $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE)
35 $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE): $(TARBALLS_LOCATION)/$(ARCHIVE)
36 ifeq ($(HASH_FOUND),no)
37 cd $(TARBALLS_LOCATION); $(HASH_TOOL) $(ARCHIVE) > $(ARCHIVE).$(HASH_TYPE)
38 $(HASH_TYPE)=$$(cat $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE) | cut -d ' ' -f 1) && \
39 sed $(SED_FLAG) -e "s/#SHA512#/SHA512=$${sha512}/" -e "s/#SHA256#/SHA256=$${sha256}/" Makefile
41 ifeq ($(HASH_FOUND),yes)
42 # we really need 2 spaces between sha hash and file name!
43 # if the hash sum doesn't match we retry up to 3 times, add verbose curl output for diagnostics on retries
44 # if we fail 3 times, cleanup anything downloaded (eg bad tar)
45 @cd $(TARBALLS_LOCATION); echo "$(HASH_SUM) $(ARCHIVE)" > $(ARCHIVE).$(HASH_TYPE) && $(HASH_TOOL) $(HASH_TOOL_FLAGS) $(ARCHIVE).$(HASH_TYPE) \
47 echo "Error: failed to verify hash sum of $(ARCHIVE), expected type: $(HASH_TYPE) value $(HASH_SUM), retrying.." ;\
49 while [ $$tries -le 3 ]; do \
50 echo "download $(ARCHIVE) retry $$tries" ;\
51 rm $(TARBALLS_LOCATION)/$(ARCHIVE) ;\
53 $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) -v $(BASE_URL)/$(ARCHIVE) ;\
54 $(HASH_TOOL) $(HASH_TOOL_FLAGS) $(ARCHIVE).$(HASH_TYPE) && exit 0 || tries=$$((tries + 1)) ;\
56 rm $(TARBALLS_LOCATION)/$(ARCHIVE) ;\