pkg-virtual.mk 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ################################################################################
  2. # Virtual package infrastructure
  3. #
  4. # This file implements an infrastructure that eases development of
  5. # package .mk files for virtual packages. It should be used for all
  6. # virtual packages.
  7. #
  8. # See the Buildroot documentation for details on the usage of this
  9. # infrastructure
  10. #
  11. # In terms of implementation, this virtual infrastructure requires
  12. # the .mk file to only call the 'virtual-package' macro.
  13. #
  14. ################################################################################
  15. ################################################################################
  16. # inner-virtual-package -- defines the dependency rules of the virtual
  17. # package against its provider.
  18. #
  19. # argument 1 is the lowercase package name
  20. # argument 2 is the uppercase package name, including a HOST_ prefix
  21. # for host packages
  22. # argument 3 is the uppercase package name, without the HOST_ prefix
  23. # for host packages
  24. # argument 4 is the type (target or host)
  25. ################################################################################
  26. # Note: putting this comment here rather than in the define block, otherwise
  27. # make would try to expand the $(error ...) in the comment, which is not
  28. # really what we want.
  29. # We need to use second-expansion for the $(error ...) call, below,
  30. # so it is not evaluated now, but as part of the generated make code.
  31. define inner-virtual-package
  32. # Ensure the virtual package has an implementation defined.
  33. ifeq ($$(BR2_PACKAGE_HAS_$(2)),y)
  34. ifeq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),)
  35. $$(error No implementation selected for virtual package $(1). Configuration error)
  36. endif
  37. endif
  38. # explicitly set these so we do not get confused by environment
  39. # variables with the same names.
  40. $(2)_VERSION =
  41. $(2)_SOURCE =
  42. $(2)_IS_VIRTUAL = YES
  43. # Add dependency against the provider
  44. # For a host package, there is no corresponding BR2_PACKAGE_PROVIDES_HOST_FOO,
  45. # so we need to compute it from the target variant.
  46. ifeq ($(4),target)
  47. $(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
  48. else
  49. ifeq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),)
  50. # Inherit from target package BR2_PACKAGE_PROVIDES_FOO
  51. $(2)_DEPENDENCIES += host-$$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(3)))
  52. else
  53. # BR2_PACKAGE_PROVIDES_HOST_<pkg> is explicitly defined
  54. $(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
  55. endif
  56. endif
  57. # Call the generic package infrastructure to generate the necessary
  58. # make targets
  59. $(call inner-generic-package,$(1),$(2),$(3),$(4))
  60. endef
  61. ################################################################################
  62. # virtual-package -- the target generator macro for virtual packages
  63. ################################################################################
  64. virtual-package = $(call inner-virtual-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
  65. host-virtual-package = $(call inner-virtual-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)