buildhlp.mk 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 ${PKG_SITES}),)
  4. ifeq ($(strip ${DISTFILES}),)
  5. DISTFILES:= ${PKG_NAME}-${PKG_VERSION}.tar.gz
  6. endif
  7. endif
  8. # This is where all package operation is done in
  9. WRKDIR?= ${WRKDIR_BASE}/w-${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}
  10. # This is where source code is extracted and patched
  11. WRKDIST?= ${WRKDIR}/${PKG_NAME}-${PKG_VERSION}
  12. # This is where the configure script is seeked (localed)
  13. WRKSRC?= ${WRKDIST}
  14. # This is where configure, make and make install (fake) run from
  15. WRKBUILD?= ${WRKSRC}
  16. # This is where make install (fake) writes to
  17. WRKINST?= ${WRKDIR}/fake-${CPU_ARCH}/root
  18. ifeq ($(strip ${NO_CHECKSUM}),)
  19. _CHECKSUM_COOKIE= ${WRKDIR}/.checksum_done
  20. else
  21. _CHECKSUM_COOKIE=
  22. endif
  23. post-extract:
  24. @mkdir -p ${PACKAGE_DIR}/.stamps
  25. ifeq ($(strip ${NO_DISTFILES}),1)
  26. ${WRKDIST}/.extract_done:
  27. rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
  28. @mkdir -p ${WRKDIR} ${WRKDIST}
  29. ${MAKE} do-extract
  30. @${MAKE} post-extract $(MAKE_TRACE)
  31. touch $@
  32. fetch refetch checksum do-extract:
  33. __use_generic_patch_target:=42
  34. else ifneq ($(strip ${DISTFILES}),)
  35. include ${TOPDIR}/mk/fetch.mk
  36. ${WRKDIST}/.extract_done: ${_CHECKSUM_COOKIE}
  37. ifeq (${_CHECKSUM_COOKIE},)
  38. rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
  39. endif
  40. ${EXTRACT_CMD}
  41. @${MAKE} post-extract $(MAKE_TRACE)
  42. touch $@
  43. __use_generic_patch_target:=42
  44. else ifeq ($(strip ${_IN_PACKAGE}),1)
  45. $(warning This package does not use the generic extraction and patch target; it's most likely to fail.)
  46. endif
  47. ifeq ($(strip ${__use_generic_patch_target}),42)
  48. post-patch:
  49. ${WRKDIST}/.prepared: ${WRKDIST}/.extract_done
  50. [ ! -d ./patches/${PKG_VERSION} ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches/${PKG_VERSION} \
  51. '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
  52. [ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
  53. '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
  54. [ ! -d ./src ] || (cd src; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
  55. $(MAKE_TRACE)
  56. @${MAKE} post-patch $(MAKE_TRACE)
  57. touch $@
  58. endif
  59. update-patches:
  60. @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
  61. @test ! -d ${WRKDIR}.orig
  62. ifeq ($(strip ${_IN_PACKAGE})$(strip ${_IN_CVTC}),1)
  63. @$(MAKE) -s V=0 patch WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
  64. else
  65. @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
  66. endif
  67. @# restore config.sub/config.guess
  68. @for i in $$(find ${WRKDIR} -name config.sub);do \
  69. if [ -f $$i.bak ];then \
  70. mv $$i.bak $$i; \
  71. fi;\
  72. done
  73. @for i in $$(find ${WRKDIR} -name config.guess);do \
  74. if [ -f $$i.bak ];then \
  75. mv $$i.bak $$i; \
  76. fi;\
  77. done
  78. @toedit=$$(WRKDIST='${WRKDIST}' CURDIR=$$(pwd) \
  79. PATCH_LIST='patch-* *.patch' WRKDIR1='${WRKDIR}' \
  80. ${BASH} ${TOPDIR}/scripts/update-patches); \
  81. if [[ -n $$toedit && $$toedit != FAIL ]]; then \
  82. echo -n 'edit patches: '; read i; \
  83. cd patches && $${VISUAL:-$${EDITOR:-vi}} $$toedit; \
  84. fi; \
  85. rm -rf ${WRKDIR}.orig; \
  86. [[ $$toedit != FAIL ]]
  87. .PHONY: update-patches