pkg-qmake.mk 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. ################################################################################
  2. # QMake package infrastructure
  3. #
  4. # This file implements an infrastructure that eases development of package
  5. # .mk files for QMake packages. It should be used for all packages that use
  6. # Qmake 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 QMake 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 QMake behaviour. The package can also define some
  19. # post operation hooks.
  20. #
  21. ################################################################################
  22. ################################################################################
  23. # inner-qmake-package -- defines how the configuration, compilation and
  24. # installation of a qmake package should be done, implements a few hooks
  25. # to tune the build process for qmake 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. ################################################################################
  32. define inner-qmake-package
  33. $(2)_CONF_ENV ?=
  34. $(2)_CONF_OPTS ?=
  35. $(2)_MAKE_ENV ?=
  36. $(2)_MAKE_OPTS ?=
  37. $(2)_INSTALL_STAGING_OPTS ?= install
  38. $(2)_INSTALL_TARGET_OPTS ?= $$($(2)_INSTALL_STAGING_OPTS)
  39. ifneq ($(1),qt5base)
  40. $(2)_DEPENDENCIES += qt5base
  41. endif
  42. #
  43. # Configure step. Only define it if not already defined by the package
  44. # .mk file.
  45. #
  46. ifndef $(2)_CONFIGURE_CMDS
  47. define $(2)_CONFIGURE_CMDS
  48. $$(QT5_QT_CONF_FIXUP)
  49. cd $$($(2)_BUILDDIR) && \
  50. $$(TARGET_MAKE_ENV) $$($(2)_CONF_ENV) $$(QT5_QMAKE) $$($(2)_CONF_OPTS)
  51. endef
  52. endif
  53. #
  54. # Build step. Only define it if not already defined by the package .mk
  55. # file.
  56. #
  57. ifndef $(2)_BUILD_CMDS
  58. define $(2)_BUILD_CMDS
  59. $$(TARGET_MAKE_ENV) $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_BUILDDIR) $$($(2)_MAKE_OPTS)
  60. endef
  61. endif
  62. #
  63. # Staging installation step. Only define it if not already defined by
  64. # the package .mk file.
  65. #
  66. ifndef $(2)_INSTALL_STAGING_CMDS
  67. define $(2)_INSTALL_STAGING_CMDS
  68. $$(TARGET_MAKE_ENV) $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_BUILDDIR) $$($(2)_INSTALL_STAGING_OPTS)
  69. endef
  70. endif
  71. #
  72. # Target installation step. Only define it if not already defined by
  73. # the package .mk file.
  74. #
  75. # Unfortunately we can't use INSTALL_ROOT to directly install to TARGET_DIR
  76. # because in a crosscompile setup, the qmake generated install destinations
  77. # are prefixed with the hardcoded sysroot (=STAGING_DIR) and hostprefix
  78. # (=HOST_DIR).
  79. # Instead we set INSTALL_ROOT, which comes before the install path, to a
  80. # temporary folder inside the build directory and effectively install to
  81. # $(@D)/tmp-target-install/$(STAGING_DIR) and $(@D)/tmp-target-install/$(HOST_DIR).
  82. # We subsequently rsync only the files from the temporary staging dir and that
  83. # way exclude files for the build host from target.
  84. #
  85. ifndef $(2)_INSTALL_TARGET_CMDS
  86. define $(2)_INSTALL_TARGET_CMDS
  87. $$(TARGET_MAKE_ENV) $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_BUILDDIR) INSTALL_ROOT=$$($(2)_BUILDDIR)tmp-target-install $$($(2)_INSTALL_TARGET_OPTS)
  88. rsync -arv $$($(2)_BUILDDIR)tmp-target-install$$(STAGING_DIR)/ $$(TARGET_DIR)/
  89. endef
  90. endif
  91. # Call the generic package infrastructure to generate the necessary
  92. # make targets
  93. $(call inner-generic-package,$(1),$(2),$(3),$(4))
  94. endef
  95. ################################################################################
  96. # qmake-package -- the target generator macro for QMake packages
  97. ################################################################################
  98. qmake-package = $(call inner-qmake-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)