diff mbox series

[v2,1/2] pkgconf: Add a host-pkg-config wrapper script.

Message ID 20200210155548.31928-1-nicolas.cavallari@green-communications.fr
State Rejected
Headers show
Series [v2,1/2] pkgconf: Add a host-pkg-config wrapper script. | expand

Commit Message

Nicolas Cavallari Feb. 10, 2020, 3:55 p.m. UTC
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.

Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>

--

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

Comments

Thomas Petazzoni April 12, 2020, 8:25 p.m. UTC | #1
Hello Nicolas,

On Mon, 10 Feb 2020 16:55:47 +0100
Nicolas Cavallari <nicolas.cavallari@green-communications.fr> wrote:

> 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.
> 
> Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
> 
> --
> 
> 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

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
diff mbox series

Patch

diff --git a/package/pkgconf/host-pkg-config b/package/pkgconf/host-pkg-config
new file mode 100644
index 0000000000..de23ce2737
--- /dev/null
+++ b/package/pkgconf/host-pkg-config
@@ -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 "$@"
diff --git a/package/pkgconf/pkgconf.mk b/package/pkgconf/pkgconf.mk
index 1851ecfca4..f3eb47931a 100644
--- a/package/pkgconf/pkgconf.mk
+++ b/package/pkgconf/pkgconf.mk
@@ -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,@STAGING_SUBDIR@,$(STAGING_SUBDIR),g' \
 		$(HOST_DIR)/bin/pkg-config
 endef