pkgconf: Add a host-pkg-config wrapper script.
PATCH v2 1/2 pkgconf: Add a host-pkg-config wrapper script.
The host-pkg-config wrapper script replicate the configuration present in HOST_MAKE_ENV, with the exception of PKG_CONFIG_LIBDIR whose default is already equal to what we want.
This wrapper script can be used with build systems that recognise the difference between a host dependency and a target dependency.
--
HOST_MAKE_ENV could be modified to use host-pkg-config, but since we cannot guarantee that every host package will use the PKG_CONFIG environment variable (instead of e.g. finding pkg-config in $PATH), the other PKG_CONFIG_* variables probably need to be kept as well, so it wouldn't be useful to use it there.
--- package/pkgconf/host-pkg-config | 8 ++++++++ package/pkgconf/pkgconf.mk | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 package/pkgconf/host-pkg-config
package/pkgconf/host-pkg-config new file +8 -0
@@ -0,0 +1,8 @@ +#!/bin/sh +PKGCONFDIR=$(dirname $0) + +# Default PKG_CONFIG_LIBDIR is HOST_DIR/lib/pkgconfig:HOST_DIR/share/pkgconfig +PKG_CONFIG_SYSROOT_DIR="/" \ + exec ${PKGCONFDIR}/pkgconf \ + --keep-system-cflags \ + --keep-system-libs "$@"
package/pkgconf/pkgconf.mk +3 -0
@@ -11,6 +11,7 @@ PKGCONF_LICENSE = pkgconf license PKGCONF_LICENSE_FILES = COPYING PKG_CONFIG_HOST_BINARY = $(HOST_DIR)/bin/pkg-config +HOST_PKG_CONFIG_HOST_BINARY = $(HOST_DIR)/bin/host-pkg-config define PKGCONF_LINK_PKGCONFIG ln -sf pkgconf $(TARGET_DIR)/usr/bin/pkg-config
@@ -19,6 +20,8 @@ endef define HOST_PKGCONF_INSTALL_WRAPPER $(INSTALL) -m 0755 -D package/pkgconf/pkg-config.in \ $(HOST_DIR)/bin/pkg-config + $(INSTALL) -m 0755 -D package/pkgconf/host-pkg-config \ + $(HOST_DIR)/bin/host-pkg-config $(SED) 's, at STAGING_SUBDIR@,$(STAGING_SUBDIR),g' \ $(HOST_DIR)/bin/pkg-config endef
Signature · 1 line
2.25.0
PATCH v2 2/2 package/pkg-meson: use host-pkg-config to find host libraries.
meson makes a distinction between 'native' (i.e. host) dependencies and 'host' (i.e. target) dependencies and can use a different pkg-config binary for each case.
Currently, pkg-meson only pass the target pkg-config and meson automatically guesses the host pkg-config by searching PATH, which finds host/bin/pkg-config, which is the target pkg-config wrapper script.
As a result, meson uses the target pkg-config to find host dependencies, with possibly incorrect results.
This patch causes meson to use host/bin/host-pkg-config directly to find host dependencies, using the apparently recommended method[1] of specifing the PKG_CONFIG environment variable.
[1] https://github.com/mesonbuild/meson/issues/1849
--
I tested that the following packages still compile:
- libglib2
- gst1-plugins-bad
- gst1-plugins-base
- gst1-plugins-good
- gst1-plugins-ugly
- gstreamer1
- libdrm
- mesa3d
--- package/pkg-meson.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
package/pkg-meson.mk +2 -1
@@ -81,7 +81,8 @@ define $(2)_CONFIGURE_CMDS ) \ package/meson/cross-compilation.conf.in \ > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf - PATH=$$(BR_PATH) $$($$(PKG)_CONF_ENV) $$(MESON) \ + PATH=$$(BR_PATH) PKG_CONFIG=$$(HOST_PKG_CONFIG_HOST_BINARY) \ + $$($$(PKG)_CONF_ENV) $$(MESON) \ --prefix=/usr \ --libdir=lib \ --default-library=$(if $(BR2_STATIC_LIBS),static,shared) \
Signature · 1 line
2.25.0
PATCH v2 1/2 pkgconf: Add a host-pkg-config wrapper script.
In reply to Nicolas CavallariHello Nicolas,
Quoted 16 lines · On Mon, 10 Feb 2020 16:55:47 +0100 Nicolas Cavallari…
The host-pkg-config wrapper script replicate the configuration present in
HOST_MAKE_ENV, with the exception ofPKG_CONFIG_LIBDIRwhose default is already equal to what we want.This wrapper script can be used with build systems that recognise the difference between a host dependency and a target dependency.
Signed-off-by Nicolas Cavallari <[email protected]>--
HOST_MAKE_ENVcould be modified to use host-pkg-config, but since we cannot guarantee that every host package will use thePKG_CONFIGenvironment variable (instead of e.g. finding pkg-config in $PATH), the other PKG_CONFIG_* variables probably need to be kept as well, so it wouldn't be useful to use it there.
Quoted 5 lines
--- package/pkgconf/host-pkg-config | 8 ++++++++ package/pkgconf/pkgconf.mk | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 package/pkgconf/host-pkg-config
I believe this series is no longer needed, since 4e0bc29993376613d200e892d491e31ea5a49622 was merged.
In addition, your series was not completely fixing the problem. Indeed with your series, target packages built with meson would use the cross pkg-config, while host packages built with meson would use the "native" pkg-config.
But there is one case that your series doesn't handle: some target packages do internally build a host tool, which requires some external libraries that are detected by pkg-config. Meson has the correct logic to handle that, and pass the right pkg-config arguments. But your solution would not allow to support such situations, while the solution implemented in 4e0bc29993376613d200e892d491e31ea5a49622 does.
Of course, if you still an issue in the meson pkg-config handling, please let us know.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com