Skip to contentSkip to conversation

pkg-config: add --with-sysroot option for compiled in default sysroot setting

PATCH New Peter Korsgaard 3 participants 3 messages Jan 29, 2011 – Jan 30, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pkg-config: add --with-sysroot option for compiled in default sysroot setting

commit: http://git.buildroot.net/buildroot/commit/?id=50bda85e88fa10be32733dd0334aea93519bc915
branch: http://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Similar to the --with-pc-path option. It works just like the existing PKG_CONFIG_SYSROOT_DIR environment variable, but compiled in. The environment variable overrides this default setting if set.

This way we don't need to pass PKG_CONFIG_SYSROOT_DIR in the environment when building for the target, and it is easier to reuse pkg-config outside BR (E.G. for the SDK) without having to setup special environment variables.

---
 package/Makefile.in                                |    3 +-
 .../pkg-config-0.25-add-with-sysroot.patch         |   70 ++++++++++++++++++++
 package/pkg-config/pkg-config.mk                   |    3 +
 3 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 package/pkg-config/pkg-config-0.25-add-with-sysroot.patch
package/Makefile.in +1 -2
index 4e795f9..ef2c591 100644
@@ -218,9 +218,7 @@ TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
 		CXXFLAGS="$(TARGET_CXXFLAGS)" \
 		LDFLAGS="$(TARGET_LDFLAGS)" \
 		FCFLAGS="$(TARGET_FCFLAGS)" \
-		PKG_CONFIG_SYSROOT_DIR="$(STAGING_DIR)" \
 		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
-		PKG_CONFIG_PATH="$(STAGING_DIR)/usr/lib/pkgconfig:$(PKG_CONFIG_PATH)" \
 		PERLLIB="$(HOST_DIR)/usr/lib/perl" \
 		STAGING_DIR="$(STAGING_DIR)"
 
@@ -242,6 +240,7 @@ HOST_CONFIGURE_OPTS=PATH=$(HOST_PATH) \
 		PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
 		PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
 		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
+		PKG_CONFIG_SYSROOT_DIR="/" \
 		PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig" \
 		PERLLIB="$(HOST_DIR)/usr/lib/perl" \
 		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)"
package/pkg-config/pkg-config-0.25-add-with-sysroot.patch new file +70 -0

70 lines not on this page · raw message

package/pkg-config/pkg-config.mk +3 -0
index 413853d..bb52db8 100644
@@ -13,8 +13,11 @@ PKG_CONFIG_CONF_OPT = --with-installed-glib
 
 HOST_PKG_CONFIG_CONF_OPT = \
 		--with-pc-path="$(STAGING_DIR)/usr/lib/pkgconfig" \
+		--with-sysroot="$(STAGING_DIR)" \
 		--disable-static
 
+HOST_PKG_CONFIG_AUTORECONF = YES
+
 $(eval $(call AUTOTARGETS,package,pkg-config))
 $(eval $(call AUTOTARGETS,package,pkg-config,host))
 
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 pkg-config: add --with-sysroot option for compiled in default sysroot setting

Hello,

Quoted 8 lines · On Sun, 30 Jan 2011 00:40:13 +0100 Peter Korsgaard <[email protected]> wrote:

Similar to the --with-pc-path option. It works just like the existing PKG_CONFIG_SYSROOT_DIR environment variable, but compiled in. The environment variable overrides this default setting if set.

This way we don't need to pass PKG_CONFIG_SYSROOT_DIR in the environment when building for the target, and it is easier to reuse pkg-config outside BR (E.G. for the SDK) without having to setup special environment variables.

I am not a big fan of this: we compile a single pkg-config to handle both target and host packages. So I don't see why this pkg-config should be specifically configured to handle packages and not for host packages. I know it was already configured specifically for target packages with --with-pc-path, but I wasn't a fan of this.

I think I'd prefer if we didn't pass any --with-sysroot nor --with-pc-path, and instead use the proper environment variables all the time. Or either build two pkg-config, one for host packages, one for target packages.

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw

PATCH 1/1 pkg-config: add --with-sysroot option for compiled in default sysroot setting

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 8 lines
Quoted 8 lines

Similar to the --with-pc-path option. It works just like the existing PKG_CONFIG_SYSROOT_DIR environment variable, but compiled in. The environment variable overrides this default setting if set.

This way we don't need to pass PKG_CONFIG_SYSROOT_DIR in the environment when building for the target, and it is easier to reuse pkg-config outside BR (E.G. for the SDK) without having to setup special environment variables.

Thomas> I am not a big fan of this: we compile a single pkg-config to handle Thomas> both target and host packages. So I don't see why this pkg-config Thomas> should be specifically configured to handle packages and not for host Thomas> packages. I know it was already configured specifically for target Thomas> packages with --with-pc-path, but I wasn't a fan of this.

Well, lets look at the situation (I know you probably know all of this, but might be interesting for others). Like you say, we need pkg-config both for target packages and host packages (+ possibly to run on the target). We cannot just rely on pkg-config being available on the host, as until very recently sysroot support was broken (and for some things, like --variable it still is).

So we need to build it. For the 2 use cases we need:

- target: sysroot set to staging, look for .pc files in staging/usr/lib/pkgconfig

- host: no sysroot, look for .pc files in host/usr/lib/pkgconfig

We could build 2 different versions, but it's simpler to use the same binary (faster to build, AUTOTARGETS can only build 1 host version). This is not really a problem as you can set sysroot (PKG_CONFIG_SYSROOT_DIR) and pkgconfig dir (PKG_CONFIG_LIBDIR) at runtime through environment variable.

The situation before this commit was a bit of a mix. We configured pkg-config with prefix=hosr/usr, but changed the default pkgconfig dir to staging/usr/lib/pkconfig. This combination is not really useful as you'll need to set environment variables for both use cases.

Now, the 2 usecases are imho not of the same importance. We build a lot more packages for the target than for the host (the host ones are just the ones needed to be able to build for the target), and people using the buildroot toolchain outside BR are typically only interested in building for the target - So I think it makes sense to optimize for this usecase - Hence the change to use the staging sysroot by default.

So with this change pkg-config works for target packages without setting any environment variables, which is bound to lead to less bugs (E.G. see the recent change to dnsmasq.mk), and for host packages we have to pass PKG_CONFIG_SYSROOT_DIR in addition to PKG_CONFIG_LIBDIR that we're already passing.

Signature · 1 line
Bye, Peter Korsgaard