pkg-qmake.mk 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. # Hook to sync Qt headers
  24. #
  25. define QT_HEADERS_SYNC_HOOK
  26. $(Q)cd $($(PKG)_BUILDDIR) && $(HOST_DIR)/bin/syncqt.pl -version $(QT5_VERSION)
  27. endef
  28. ################################################################################
  29. # inner-qmake-package -- defines how the configuration, compilation and
  30. # installation of a qmake package should be done, implements a few hooks
  31. # to tune the build process for qmake specifities and calls the generic
  32. # package infrastructure to generate the necessary make targets
  33. #
  34. # argument 1 is the lowercase package name
  35. # argument 2 is the uppercase package name, including a HOST_ prefix
  36. # for host packages
  37. ################################################################################
  38. define inner-qmake-package
  39. $(2)_CONF_ENV ?=
  40. $(2)_CONF_OPTS ?=
  41. $(2)_MAKE_ENV ?=
  42. $(2)_MAKE_OPTS ?=
  43. $(2)_INSTALL_STAGING_OPTS ?= install
  44. $(2)_INSTALL_TARGET_OPTS ?= $$($(2)_INSTALL_STAGING_OPTS)
  45. ifneq ($(1),qt5base)
  46. $(2)_DEPENDENCIES += qt5base
  47. endif
  48. ifeq ($$($(2)_SYNC_QT_HEADERS),YES)
  49. $(2)_DEPENDENCIES += host-perl
  50. $(2)_PRE_CONFIGURE_HOOKS += QT_HEADERS_SYNC_HOOK
  51. endif
  52. #
  53. # Configure step. Only define it if not already defined by the package
  54. # .mk file.
  55. #
  56. ifndef $(2)_CONFIGURE_CMDS
  57. define $(2)_CONFIGURE_CMDS
  58. $$(QT5_QT_CONF_FIXUP)
  59. cd $$($(2)_BUILDDIR) && \
  60. $$(TARGET_MAKE_ENV) $$($(2)_CONF_ENV) $$(QT5_QMAKE) $$($(2)_CONF_OPTS)
  61. endef
  62. endif
  63. #
  64. # Build step. Only define it if not already defined by the package .mk
  65. # file.
  66. #
  67. ifndef $(2)_BUILD_CMDS
  68. define $(2)_BUILD_CMDS
  69. $$(TARGET_MAKE_ENV) $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_BUILDDIR) $$($(2)_MAKE_OPTS)
  70. endef
  71. endif
  72. #
  73. # Staging installation step. Only define it if not already defined by
  74. # the package .mk file.
  75. #
  76. ifndef $(2)_INSTALL_STAGING_CMDS
  77. define $(2)_INSTALL_STAGING_CMDS
  78. $$(TARGET_MAKE_ENV) $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_BUILDDIR) $$($(2)_INSTALL_STAGING_OPTS)
  79. endef
  80. endif
  81. #
  82. # Target installation step. Only define it if not already defined by
  83. # the package .mk file.
  84. #
  85. # Unfortunately we can't use INSTALL_ROOT to directly install to TARGET_DIR
  86. # because in a crosscompile setup, the qmake generated install destinations
  87. # are prefixed with the hardcoded sysroot (=STAGING_DIR) and hostprefix
  88. # (=HOST_DIR).
  89. # Instead we set INSTALL_ROOT, which comes before the install path, to a
  90. # temporary folder inside the build directory and effectively install to
  91. # $(@D)/tmp-target-install/$(STAGING_DIR) and $(@D)/tmp-target-install/$(HOST_DIR).
  92. # We subsequently rsync only the files from the temporary staging dir and that
  93. # way exclude files for the build host from target.
  94. #
  95. ifndef $(2)_INSTALL_TARGET_CMDS
  96. define $(2)_INSTALL_TARGET_CMDS
  97. $$(TARGET_MAKE_ENV) $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_BUILDDIR) INSTALL_ROOT=$$($(2)_BUILDDIR)tmp-target-install $$($(2)_INSTALL_TARGET_OPTS)
  98. rsync -arv $$($(2)_BUILDDIR)tmp-target-install$$(STAGING_DIR)/ $$(TARGET_DIR)/
  99. endef
  100. endif
  101. # Call the generic package infrastructure to generate the necessary
  102. # make targets
  103. $(call inner-generic-package,$(1),$(2),$(3),$(4))
  104. endef
  105. ################################################################################
  106. # qmake-package -- the target generator macro for QMake packages
  107. ################################################################################
  108. qmake-package = $(call inner-qmake-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)