HOST_MESON_SED_LDFLAGS = $(if $(strip $(TARGET_LDFLAGS)),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
HOST_MESON_SED_CXXFLAGS = $(if $(strip $(TARGET_CXXFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CXXFLAGS)`)
-# Generate a Meson cross-compilation.conf suitable for use with the
-# SDK; also install the file as a template for users to add their
-# own flags if they need to.
-define HOST_MESON_INSTALL_CROSS_CONF
- mkdir -p $(HOST_DIR)/etc/meson
- sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
- -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
- -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
- -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
- -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)@PKG_TARGET_CFLAGS@%g" \
- -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)@PKG_TARGET_CFLAGS@%g" \
- -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)@PKG_TARGET_CFLAGS@%g" \
- -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
- $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
- > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
- sed -e "s%@PKG_TARGET_CFLAGS@%%g" \
- -e "s%@PKG_TARGET_LDFLAGS@%%g" \
- -e "s%@PKG_TARGET_CXXFLAGS@%%g" \
- $(HOST_DIR)/etc/meson/cross-compilation.conf.in \
- > $(HOST_DIR)/etc/meson/cross-compilation.conf
-endef
-
-TARGET_FINALIZE_HOOKS += HOST_MESON_INSTALL_CROSS_CONF
-
$(eval $(host-python-package))
meson-package = $(call inner-meson-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
host-meson-package = $(call inner-meson-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)
+
+################################################################################
+# Generation of the Meson cross-compilation.conf file
+################################################################################
+
+# Generate a Meson cross-compilation.conf suitable for use with the
+# SDK; also install the file as a template for users to add their
+# own flags if they need to.
+define PKG_MESON_INSTALL_CROSS_CONF
+ mkdir -p $(HOST_DIR)/etc/meson
+ sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
+ -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
+ -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
+ -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
+ -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)@PKG_TARGET_CFLAGS@%g" \
+ -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)@PKG_TARGET_CFLAGS@%g" \
+ -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)@PKG_TARGET_CFLAGS@%g" \
+ -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
+ $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
+ > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
+ sed -e "s%@PKG_TARGET_CFLAGS@%%g" \
+ -e "s%@PKG_TARGET_LDFLAGS@%%g" \
+ -e "s%@PKG_TARGET_CXXFLAGS@%%g" \
+ $(HOST_DIR)/etc/meson/cross-compilation.conf.in \
+ > $(HOST_DIR)/etc/meson/cross-compilation.conf
+endef
+
+TOOLCHAIN_POST_INSTALL_STAGING_HOOKS += HOST_MESON_INSTALL_CROSS_CONF
+TOOLCHAIN_INSTALL_STAGING = YES