buildhlp.mk 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/${PKG_VERSION} ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches/${PKG_VERSION} \
  50. '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
  51. [ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
  52. '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
  53. [ ! -d ./src ] || (cd src; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
  54. $(MAKE_TRACE)
  55. @${MAKE} post-patch $(MAKE_TRACE)
  56. touch $@
  57. endif
  58. update-patches:
  59. @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
  60. @test ! -d ${WRKDIR}.orig
  61. ifeq ($(strip ${_IN_PACKAGE})$(strip ${_IN_CVTC}),1)
  62. @$(MAKE) -s V=0 patch WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
  63. else
  64. @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: NO_CHECKSUM=1
  65. endif
  66. @# restore config.sub/config.guess
  67. @for i in $$(find ${WRKDIR} -name config.sub);do \
  68. if [ -f $$i.bak ];then \
  69. mv $$i.bak $$i; \
  70. fi;\
  71. done
  72. @for i in $$(find ${WRKDIR} -name config.guess);do \
  73. if [ -f $$i.bak ];then \
  74. mv $$i.bak $$i; \
  75. fi;\
  76. done
  77. @toedit=$$(WRKDIST='${WRKDIST}' CURDIR=$$(pwd) \
  78. PATCH_LIST='patch-* *.patch' WRKDIR1='${WRKDIR}' \
  79. ${BASH} ${TOPDIR}/scripts/update-patches); \
  80. if [[ -n $$toedit && $$toedit != FAIL ]]; then \
  81. echo -n 'edit patches: '; read i; \
  82. cd patches && $${VISUAL:-$${EDITOR:-vi}} $$toedit; \
  83. fi; \
  84. rm -rf ${WRKDIR}.orig; \
  85. [[ $$toedit != FAIL ]]
  86. .PHONY: update-patches