buildhlp.mk 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. shellescape='$(subst ','\'',$(1))'
  4. shellexport=$(1)=$(call shellescape,${$(1)})
  5. ifneq ($(strip ${PKG_SITES}),)
  6. ifeq ($(strip ${DISTFILES}),)
  7. DISTFILES:= ${PKG_NAME}-${PKG_VERSION}.tar.xz
  8. endif
  9. endif
  10. # This is where all package operation is done in
  11. WRKDIR?= ${WRKDIR_BASE}/w-${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}
  12. # This is where source code is extracted and patched
  13. WRKDIST?= ${WRKDIR}/${PKG_NAME}-${PKG_VERSION}
  14. # This is where the configure script is seeked (localed)
  15. WRKSRC?= ${WRKDIST}
  16. # This is where configure, make and make install (fake) run from
  17. WRKBUILD?= ${WRKSRC}
  18. # This is where make install (fake) writes to
  19. WRKINST?= ${WRKDIR}/fake-${ADK_TARGET_CPU_ARCH}/root
  20. ifeq ($(strip ${PKG_NOCHECKSUM}),)
  21. _CHECKSUM_COOKIE= ${WRKDIR}/.checksum_done
  22. else
  23. _CHECKSUM_COOKIE=
  24. endif
  25. post-extract:
  26. ifeq ($(strip ${NO_DISTFILES}),1)
  27. ${WRKDIST}/.extract_done:
  28. rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
  29. @mkdir -p ${WRKDIR} ${WRKDIST}
  30. ${MAKE} do-extract
  31. @${MAKE} post-extract $(MAKE_TRACE)
  32. touch $@
  33. fetch refetch checksum do-extract:
  34. __use_generic_patch_target:=42
  35. else ifneq ($(strip ${DISTFILES}),)
  36. include ${ADK_TOPDIR}/mk/fetch.mk
  37. ${WRKDIST}/.extract_done: ${_CHECKSUM_COOKIE}
  38. ifeq (${_CHECKSUM_COOKIE},)
  39. rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
  40. endif
  41. ifeq ($(EXTRACT_OVERRIDE),1)
  42. ${MAKE} do-extract
  43. else
  44. ${EXTRACT_CMD}
  45. endif
  46. @${MAKE} post-extract $(MAKE_TRACE)
  47. touch $@
  48. __use_generic_patch_target:=42
  49. else
  50. include ${ADK_TOPDIR}/mk/fetch.mk
  51. ${WRKDIST}/.extract_done: ${_CHECKSUM_COOKIE}
  52. $(MAKE) fetch
  53. ifeq (${_CHECKSUM_COOKIE},)
  54. rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
  55. endif
  56. ifeq ($(EXTRACT_OVERRIDE),1)
  57. ${MAKE} do-extract
  58. else
  59. ${EXTRACT_CMD}
  60. endif
  61. @${MAKE} post-extract $(MAKE_TRACE)
  62. touch $@
  63. endif
  64. ifeq ($(strip ${__use_generic_patch_target}),42)
  65. post-patch:
  66. ${WRKDIST}/.prepared: ${WRKDIST}/.extract_done
  67. @# find any reject files and delete them
  68. @find $(WRKDIST)/ -name \*.rej -delete
  69. [ ! -d ./patches/${PKG_VERSION} ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches/${PKG_VERSION} \
  70. '{patch-!(*.orig),*.patch,*.${ADK_TARGET_ARCH},*.${ADK_TARGET_LIBC}}' $(MAKE_TRACE)
  71. [ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
  72. '{patch-!(*.orig),*.patch,*.${ADK_TARGET_ARCH},*.${ADK_TARGET_LIBC}}' $(MAKE_TRACE)
  73. [ ! -d ./src ] || (cd src; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
  74. $(MAKE_TRACE)
  75. @${MAKE} post-patch $(MAKE_TRACE)
  76. @# always use latest config.sub/config.guess from OpenADK scripts directory
  77. @cd ${WRKDIST}; \
  78. for i in $$(find . -name config.sub);do \
  79. if [ -f $$i ]; then \
  80. ${CP} ${SCRIPT_DIR}/config.sub $$i; \
  81. fi; \
  82. done; \
  83. for i in $$(find . -name config.guess);do \
  84. if [ -f $$i ]; then \
  85. ${CP} ${SCRIPT_DIR}/config.guess $$i; \
  86. fi; \
  87. done;
  88. touch $@
  89. endif
  90. update-patches host-update-patches:
  91. ifneq (${ADK_UPDATE_PATCHES_GIT},)
  92. PATH='${HOST_PATH}' ${BASH} $(SCRIPT_DIR)/update-patches-git "${WRKDIST}"
  93. else
  94. @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
  95. @test ! -d ${WRKDIR}.orig
  96. ifeq ($(strip ${_IN_PACKAGE})$(strip ${_IN_CVTC}),1)
  97. @$(MAKE) -s V=0 patch WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: PKG_NOCHECKSUM=1
  98. else
  99. @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PREVENT_PATCH=: PKG_NOCHECKSUM=1
  100. endif
  101. @-test ! -r ${WRKDIR}/.autoreconf_done || \
  102. (wrkdist=$(WRKDIST) dir=$${wrkdist#$(WRKDIR)}; \
  103. cd ${WRKDIR}.orig$${dir}; \
  104. env ${AUTOTOOL_ENV} autoreconf -if > /dev/null 2>&1; \
  105. rm -rf ${WRKDIR}.orig$${dir}/autom4te.cache ) $(MAKE_TRACE)
  106. @# restore config.sub/config.guess
  107. @WRKDIST=$(call shellescape,${WRKDIST}) \
  108. WRKDIR1=$(call shellescape,${WRKDIR}) \
  109. PATH=$(call shellescape,${HOST_PATH}) \
  110. $(call shellexport,DIFF_IGNOREFILES) \
  111. mksh ${ADK_TOPDIR}/scripts/update-patches2
  112. endif
  113. .PHONY: update-patches host-update-patches