1
0

fetch.mk 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. (md5sum ${FULLDISTFILES}; echo exit) | while read sum name; do \
  32. if [[ $$sum = exit ]]; then \
  33. [[ $$OK = n ]] && echo >&2 "==> No distfile found!" || :; \
  34. [[ $$OK = 1 ]] || exit 1; \
  35. break; \
  36. fi; \
  37. if [[ $$sum = "$(strip ${PKG_MD5SUM})" ]]; then \
  38. [[ $$OK = 0 ]] || OK=1; \
  39. continue; \
  40. fi; \
  41. echo >&2 "==> Checksum mismatch for $${name##*/} (MD5)"; \
  42. echo >&2 ":---> should be '$(strip ${PKG_MD5SUM})'"; \
  43. echo >&2 ":---> really is '$$sum'"; \
  44. OK=0; \
  45. done
  46. mkdir -p ${WRKDIR}
  47. touch ${_CHECKSUM_COOKIE}
  48. endif
  49. # GNU make's poor excuse for loops
  50. define FETCH_template
  51. $(1):
  52. @fullname='$(1)'; \
  53. subname=$$$${fullname##$${DISTDIR}/}; \
  54. filename=$$$${fullname##*/}; \
  55. i='$${LOCAL_DISTDIR}'; \
  56. if [[ -n $$$$i && -e $$$$i/$$$$subname ]]; then \
  57. cd "$$$$i"; \
  58. echo pax -rw "$$$$subname" '$${DISTDIR}/'; \
  59. exec pax -rw "$$$$subname" '$${DISTDIR}/'; \
  60. fi; \
  61. mkdir -p "$$$${fullname%%/$$$$filename}"; \
  62. cd "$$$${fullname%%/$$$$filename}"; \
  63. for site in $${PKG_SITES} $${MASTER_SITE_BACKUP}; do \
  64. : echo "$${FETCH_CMD} $$$$site$$$$filename"; \
  65. rm -f "$$$$filename"; \
  66. if $${FETCH_CMD} $$$$site$$$$filename; then \
  67. : check the size here; \
  68. [[ ! -e $$$$filename ]] || exit 0; \
  69. fi; \
  70. done; \
  71. exit 1
  72. endef
  73. $(foreach distfile,${FULLDISTFILES},$(eval $(call FETCH_template,$(distfile))))