buildhlp.mk 2.7 KB

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