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