buildhlp.mk 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. ifeq ($(strip ${NO_DISTFILES}),1)
  25. ${WRKDIST}/.extract_done:
  26. rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
  27. mkdir -p ${WRKDIR} ${WRKDIST}
  28. ${MAKE} do-extract
  29. @${MAKE} post-extract
  30. touch $@
  31. fetch refetch checksum do-extract:
  32. __use_generic_patch_target:=42
  33. else ifneq ($(strip ${DISTFILES}),)
  34. include ${TOPDIR}/mk/fetch.mk
  35. ${WRKDIST}/.extract_done: ${_CHECKSUM_COOKIE}
  36. ifeq (${_CHECKSUM_COOKIE},)
  37. rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
  38. endif
  39. ${EXTRACT_CMD}
  40. @${MAKE} post-extract
  41. touch $@
  42. __use_generic_patch_target:=42
  43. else ifeq ($(strip ${_IN_PACKAGE}),1)
  44. $(warning This package does not use the generic extraction and patch target; it's most likely to fail.)
  45. endif
  46. ifeq ($(strip ${__use_generic_patch_target}),42)
  47. post-patch:
  48. ${WRKDIST}/.prepared: ${WRKDIST}/.extract_done
  49. [ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
  50. '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
  51. [ ! -d ./extra ] || (cd extra; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
  52. $(MAKE_TRACE)
  53. @${MAKE} post-patch $(MAKE_TRACE)
  54. touch $@
  55. endif
  56. update-patches:
  57. @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
  58. @test ! -d ${WRKDIR}.orig
  59. ifeq ($(strip ${_IN_PACKAGE})$(strip ${_IN_CVTC}),1)
  60. @$(MAKE) -s V=0 patch WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
  61. else
  62. @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
  63. endif
  64. @# restore config.sub/config.guess
  65. @for i in $$(find ${WRKDIR} -name config.sub);do \
  66. if [ -f $$i.bak ];then \
  67. mv $$i.bak $$i; \
  68. fi;\
  69. done
  70. @for i in $$(find ${WRKDIR} -name config.guess);do \
  71. if [ -f $$i.bak ];then \
  72. mv $$i.bak $$i; \
  73. fi;\
  74. done
  75. @toedit=$$(WRKDIST='${WRKDIST}' CURDIR=$$(pwd) \
  76. PATCH_LIST='patch-* *.patch' WRKDIR1='${WRKDIR}' \
  77. ${BASH} ${TOPDIR}/scripts/update-patches); \
  78. if [[ -n $$toedit && $$toedit != FAIL ]]; then \
  79. echo -n 'edit patches: '; read i; \
  80. cd patches && $${VISUAL:-$${EDITOR:-vi}} $$toedit; \
  81. fi; \
  82. rm -rf ${WRKDIR}.orig; \
  83. [[ $$toedit != FAIL ]]
  84. .PHONY: update-patches