1
0

fetch.mk 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. ifneq ($(strip ${DIST_SUBDIR}),)
  4. FULLDISTDIR?= ${DISTDIR}/${DIST_SUBDIR}
  5. else
  6. FULLDISTDIR?= ${DISTDIR}
  7. endif
  8. FULLDISTFILES= $(patsubst %,${FULLDISTDIR}/%,${DISTFILES})
  9. FETCH_STYLE?= auto
  10. #pre-fetch:
  11. do-fetch:
  12. #post-fetch:
  13. fetch:
  14. # @${MAKE} pre-fetch
  15. ifneq ($(filter auto,${FETCH_STYLE}),)
  16. ${MAKE} ${FULLDISTFILES}
  17. else
  18. ${MAKE} do-fetch
  19. endif
  20. # @${MAKE} post-fetch
  21. refetch:
  22. -rm -f ${FULLDISTFILES}
  23. ${MAKE} fetch
  24. # XXX for now
  25. _CHECKSUM_COOKIE?= ${WRKDIR}/.checksum_done
  26. checksum: ${_CHECKSUM_COOKIE}
  27. ifeq ($(strip ${NO_CHECKSUM}),)
  28. ${_CHECKSUM_COOKIE}: ${FULLDISTFILES}
  29. -rm -rf ${WRKDIR}
  30. @OK=n; \
  31. allsums="$(strip ${PKG_MD5SUM})"; \
  32. (md5sum ${FULLDISTFILES}; echo exit) | while read sum name; do \
  33. if [[ $$sum = exit ]]; then \
  34. [[ $$OK = n ]] && echo >&2 "==> No distfile found!" || :; \
  35. [[ $$OK = 1 ]] || exit 1; \
  36. break; \
  37. fi; \
  38. cursum="$${allsums%% *}"; \
  39. allsums="$${allsums#* }"; \
  40. if [[ $$sum = "$$cursum" ]]; then \
  41. [[ $$OK = 0 ]] || OK=1; \
  42. continue; \
  43. fi; \
  44. echo >&2 "==> Checksum mismatch for $${name##*/} (MD5)"; \
  45. echo >&2 ":---> should be '$$cursum'"; \
  46. echo >&2 ":---> really is '$$sum'"; \
  47. OK=0; \
  48. done
  49. mkdir -p ${WRKDIR}
  50. touch ${_CHECKSUM_COOKIE}
  51. endif
  52. # GNU make's poor excuse for loops
  53. define FETCH_template
  54. $(1):
  55. @fullname='$(1)'; \
  56. filename=$$$${fullname##*/}; \
  57. mkdir -p "$$$${fullname%%/$$$$filename}"; \
  58. cd "$$$${fullname%%/$$$$filename}"; \
  59. for site in $${PKG_SITES} $${MASTER_SITE_BACKUP}; do \
  60. : echo "$${FETCH_CMD} $$$$site$$$$filename"; \
  61. rm -f "$$$$filename"; \
  62. if $${FETCH_CMD} $$$$site$$$$filename; then \
  63. : check the size here; \
  64. [[ ! -e $$$$filename ]] || exit 0; \
  65. fi; \
  66. done; \
  67. exit 1
  68. endef
  69. $(foreach distfile,${FULLDISTFILES},$(eval $(call FETCH_template,$(distfile))))