pkgconfig: add -native script that uses the native sysroot instead of target
PATCH 1/1 pkgconfig: add -native script that uses the native sysroot instead of target
pkg-config-native is useful when building a package for the target that needs to compile a build-time tool, to avoid having to hard-code many paths.
--- meta/recipes-devtools/pkgconfig/pkgconfig.inc | 10 ++++++++++ .../pkgconfig/pkgconfig/pkg-config-native.in | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 meta/recipes-devtools/pkgconfig/pkgconfig/pkg-config-native.in
meta/recipes-devtools/pkgconfig/pkgconfig.inc +10 -0
@@ -15,6 +15,7 @@ DEPENDS_class-nativesdk = "" SRC_URI = "http://pkgconfig.freedesktop.org/releases/pkg-config-${PV}.tar.gz \ file://autofoo.patch \ file://glibconfig-sysdefs.h \ + file://pkg-config-native.in \ file://disable-legacy.patch" S = "${WORKDIR}/pkg-config-${PV}/"
@@ -43,3 +44,12 @@ FILES_${PN} += "${datadir}/aclocal/pkg.m4" # will end up requiring 'pkgconfig(pkg-config)'. Allow this behavior by # specifying an appropriate provide. RPROVIDES_${PN} += "pkgconfig(pkg-config) (= ${PV})" + +# Install a pkg-config-native wrapper that will use the native sysroot instead +# of the MACHINE sysroot, for using pkg-config when building native tools. +do_install_append_class-native () { + sed -e "s|@PATH_NATIVE@|${PKG_CONFIG_PATH}|" \ + -e "s|@LIBDIR_NATIVE@|${PKG_CONFIG_LIBDIR}|" \ + < ${WORKDIR}/pkg-config-native.in > ${B}/pkg-config-native + install -m755 ${B}/pkg-config-native ${D}${bindir}/pkg-config-native +}
meta/recipes-devtools/pkgconfig/pkgconfig/pkg-config-native.in new file +7 -0
@@ -0,0 +1,7 @@ +#! /bin/sh + +PKG_CONFIG_PATH="@PATH_NATIVE@" +PKG_CONFIG_LIBDIR="@LIBDIR_NATIVE@" +unset PKG_CONFIG_SYSROOT_DIR + +pkg-config "$@"
Signature · 1 line
1.7.10.4
Ross Burton <[email protected]>
Quoted 2 lines · writes:
pkg-config-native is useful when building a package for the target that needs to compile a build-time tool, to avoid having to hard-code many paths.
how will you call this wrapper when e.g. makefile contains:
| foo_CFLAGS = $(shell pkg-config --cflags foo)
?
A more powerful approach might be to install it as 'pkg-config' under ${STAGING_BINDIR_NATIVE}/pkg-config-native/ and prepend this dir to $PATH when executing the makefile above.
meta/recipes-devtools/pkgconfig/pkgconfig/pkg-config-native.in line 7
Quoted 10 lines
meta/recipes-devtools/pkgconfig/pkgconfig/pkg-config-native.in new file +7
-0@@ -0,0 +1,7 @@ +#! /bin/sh + +PKG_CONFIG_PATH="@PATH_NATIVE@" +PKG_CONFIG_LIBDIR="@LIBDIR_NATIVE@" +unset PKG_CONFIG_SYSROOT_DIR + +pkg-config "$@"
1. last 'pkg-config' should be called with 'exec'
2. it depends on too much assumptions (e.g. that PKG_CONFIG_PATH and _LIBDIR are already exported.
I would write it:
| #! /bin/sh | exec env -u PKG_CONFIG_SYSROOT_DIR \ | PKG_CONFIG_PATH="@PATH_NATIVE@" \ | PKG_CONFIG_LIBDIR="@LIBDIR_NATIVE@" \ | pkg-config "$@"
Enrico
Quoted 3 lines · Enrico Scholz
how will you call this wrapper when e.g. makefile contains:
|
foo_CFLAGS= $(shell pkg-config --cflags foo)
You use PKG_CONFIG_FOR_BUILD, along with CC_FOR_BUILD etc.
Quoted 3 lines
A more powerful approach might be to install it as 'pkg-config' under ${STAGING_BINDIR_NATIVE}/pkg-config-native/ and prepend this dir to $PATH when executing the makefile above.
This is for when cross-compiling a package that needs a native tool, and building that tool is easiest with pkg-config. The pkg-config binaries *need* to have different names.
Concrete example: I've a patch to GTK+3 which uses PKG_CONFIG_FOR_BUILD to find a host gdk-pixbuf so it can build a native gtk-update-icon-cache instead of depending on gtk+3-native. This pkg-config needs a different name as otherwise it would be used instead of the cross-pkg-config.
Ross