package-version-override.mk 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # remember the provided package version
  2. PKG_VERSION_ORGINAL:=$(PKG_VERSION)
  3. # in case that another version is provided, overwrite the original
  4. ifeq ($(CONFIG_$(PKG_NAME)_USE_CUSTOM_VERSION),y)
  5. PKG_VERSION:=$(call qstrip,$(CONFIG_$(PKG_NAME)_CUSTOM_VERSION))
  6. PKG_SOURCE:=$(subst $(PKG_VERSION_ORGINAL),$(PKG_VERSION),$(PKG_SOURCE))
  7. PKG_MD5SUM:=
  8. endif
  9. # package specific configuration
  10. # if includeded the package version can be overwritten within the .config file (instead of changing the package specific Makefile)
  11. define Package/$(PKG_NAME)/override_version
  12. menu "overwrite package version"
  13. depends on PACKAGE_$(PKG_NAME)
  14. config $(PKG_NAME)_USE_CUSTOM_VERSION
  15. depends on PACKAGE_$(PKG_NAME)
  16. bool "Use custom package version"
  17. default n
  18. config $(PKG_NAME)_CUSTOM_VERSION
  19. depends on $(PKG_NAME)_USE_CUSTOM_VERSION
  20. string "$(PKG_BASE_NAME) version as string (default version: $(PKG_VERSION_ORGINAL))"
  21. default "$(PKG_VERSION_ORGINAL)"
  22. endmenu
  23. endef
  24. # in case that an customer source path is provided, set the acc. default variable
  25. ifeq ($(CONFIG_$(PKG_NAME)_USE_CUSTOM_SOURCE_DIR),y)
  26. PKG_DEFAULT_CUSTOM_SOURCE_DIR:= $(call qstrip,$(CONFIG_$(PKG_NAME)_CUSTOM_SOURCE_DIR))
  27. endif
  28. # package specific configuration
  29. # if includeded the package source path can be overwritten within the .config file (instead of changing the package specific Makefile)
  30. # instead of using a source ball (eg tar.gz) the specified path will point to the location of the sources
  31. define Package/$(PKG_NAME)/override_source_path
  32. menu "custom source directory"
  33. depends on PACKAGE_$(PKG_NAME)
  34. config $(PKG_NAME)_USE_CUSTOM_SOURCE_DIR
  35. depends on PACKAGE_$(PKG_NAME)
  36. bool "Use custom source directory"
  37. default n
  38. config $(PKG_NAME)_CUSTOM_SOURCE_DIR
  39. depends on $(PKG_NAME)_USE_CUSTOM_SOURCE_DIR
  40. string "Custom source directory"
  41. default "$(PKG_DEFAULT_CUSTOM_SOURCE_DIR)"
  42. endmenu
  43. endef
  44. # default:
  45. # include both configurations as long this file is included before package.mk
  46. # in case that you're defining your own onfiguration within the package Makefile just include the stuff by yourself
  47. define Package/$(PKG_NAME)/config
  48. $(call Package/$(PKG_NAME)/override_version)
  49. $(call Package/$(PKG_NAME)/override_source_path)
  50. endef
  51. # hook for custom source path
  52. # in case that the specified path is valid a link to the PKG_SOURCE_DIR is created
  53. # otherwise the make is stopped
  54. define prepare_custom_source_directory
  55. if [ -d $(CONFIG_$(PKG_NAME)_CUSTOM_SOURCE_DIR) ]; then \
  56. rm -Rf $(PKG_BUILD_DIR); \
  57. echo "Preparing Custom Source Directory link: $(CONFIG_$(PKG_NAME)_CUSTOM_SOURCE_DIR)"; \
  58. ln -snf $(CONFIG_$(PKG_NAME)_CUSTOM_SOURCE_DIR) $(PKG_BUILD_DIR); \
  59. else \
  60. echo "Custom Source Directory $(CONFIG_$(PKG_NAME)_CUSTOM_SOURCE_DIR) is invalid"; \
  61. false; \
  62. fi
  63. endef