pkg-waf.mk 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ################################################################################
  2. # WAF package infrastructure
  3. #
  4. # This file implements an infrastructure that eases development of package
  5. # .mk files for WAF packages. It should be used for all packages that use
  6. # WAF as their build system.
  7. #
  8. # See the Buildroot documentation for details on the usage of this
  9. # infrastructure
  10. #
  11. # In terms of implementation, this WAF infrastructure requires the .mk file
  12. # to only specify metadata information about the package: name, version,
  13. # download URL, etc.
  14. #
  15. # We still allow the package .mk file to override what the different steps
  16. # are doing, if needed. For example, if <PKG>_BUILD_CMDS is already defined,
  17. # it is used as the list of commands to perform to build the package,
  18. # instead of the default WAF behaviour. The package can also define some
  19. # post operation hooks.
  20. #
  21. ################################################################################
  22. ################################################################################
  23. # inner-waf-package -- defines how the configuration, compilation and
  24. # installation of a waf package should be done, implements a few hooks
  25. # to tune the build process for waf specifities and calls the generic
  26. # package infrastructure to generate the necessary make targets
  27. #
  28. # argument 1 is the lowercase package name
  29. # argument 2 is the uppercase package name, including a HOST_ prefix
  30. # for host packages
  31. # argument 3 is the uppercase package name, without the HOST_ prefix
  32. # for host packages
  33. # argument 4 is the type (target or host)
  34. ################################################################################
  35. define inner-waf-package
  36. # We need host-python3 to run waf
  37. $(2)_DEPENDENCIES += host-python3
  38. $(2)_NEEDS_EXTERNAL_WAF ?= NO
  39. # If the package does not have its own waf, use our own.
  40. ifeq ($$($(2)_NEEDS_EXTERNAL_WAF),YES)
  41. $(2)_DEPENDENCIES += host-waf
  42. $(2)_WAF = $$(HOST_DIR)/bin/waf
  43. else
  44. $(2)_WAF ?= ./waf
  45. endif
  46. $(2)_BUILD_OPTS ?=
  47. $(2)_INSTALL_STAGING_OPTS ?=
  48. $(2)_INSTALL_TARGET_OPTS ?=
  49. $(2)_WAF_OPTS ?=
  50. #
  51. # Configure step. Only define it if not already defined by the package
  52. # .mk file.
  53. #
  54. ifndef $(2)_CONFIGURE_CMDS
  55. define $(2)_CONFIGURE_CMDS
  56. cd $$($$(PKG)_SRCDIR) && \
  57. $$(TARGET_CONFIGURE_OPTS) \
  58. $$($(2)_CONF_ENV) \
  59. $$(HOST_DIR)/bin/python3 $$($(2)_WAF) configure \
  60. --prefix=/usr \
  61. --libdir=/usr/lib \
  62. $$($(2)_CONF_OPTS) \
  63. $$($(2)_WAF_OPTS)
  64. endef
  65. endif
  66. #
  67. # Build step. Only define it if not already defined by the package .mk
  68. # file.
  69. #
  70. ifndef $(2)_BUILD_CMDS
  71. define $(2)_BUILD_CMDS
  72. cd $$($$(PKG)_SRCDIR) && \
  73. $$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \
  74. build -j $$(PARALLEL_JOBS) $$($(2)_BUILD_OPTS) \
  75. $$($(2)_WAF_OPTS)
  76. endef
  77. endif
  78. #
  79. # Staging installation step. Only define it if not already defined by
  80. # the package .mk file.
  81. #
  82. ifndef $(2)_INSTALL_STAGING_CMDS
  83. define $(2)_INSTALL_STAGING_CMDS
  84. cd $$($$(PKG)_SRCDIR) && \
  85. $$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \
  86. install --destdir=$$(STAGING_DIR) \
  87. $$($(2)_INSTALL_STAGING_OPTS) \
  88. $$($(2)_WAF_OPTS)
  89. endef
  90. endif
  91. #
  92. # Target installation step. Only define it if not already defined by
  93. # the package .mk file.
  94. #
  95. ifndef $(2)_INSTALL_TARGET_CMDS
  96. define $(2)_INSTALL_TARGET_CMDS
  97. cd $$($$(PKG)_SRCDIR) && \
  98. $$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python3 $$($(2)_WAF) \
  99. install --destdir=$$(TARGET_DIR) \
  100. $$($(2)_INSTALL_TARGET_OPTS) \
  101. $$($(2)_WAF_OPTS)
  102. endef
  103. endif
  104. # Call the generic package infrastructure to generate the necessary
  105. # make targets
  106. $(call inner-generic-package,$(1),$(2),$(3),$(4))
  107. endef
  108. ################################################################################
  109. # waf-package -- the target generator macro for WAF packages
  110. ################################################################################
  111. waf-package = $(call inner-waf-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)