All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit master 1/1] pkg-config: add --with-sysroot option for compiled in default sysroot setting
@ 2011-01-29 23:40 Peter Korsgaard
  2011-01-30 14:23 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Korsgaard @ 2011-01-29 23:40 UTC (permalink / raw)
  To: buildroot


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.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 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

diff --git a/package/Makefile.in b/package/Makefile.in
index 4e795f9..ef2c591 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -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)"
diff --git a/package/pkg-config/pkg-config-0.25-add-with-sysroot.patch b/package/pkg-config/pkg-config-0.25-add-with-sysroot.patch
new file mode 100644
index 0000000..0fdcd25
--- /dev/null
+++ b/package/pkg-config/pkg-config-0.25-add-with-sysroot.patch
@@ -0,0 +1,70 @@
+[PATCH] Add compiled in default sysroot
+
+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.
+
+Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
+---
+ Makefile.am  |    6 ++++++
+ configure.in |    6 ++++++
+ main.c       |    5 +++--
+ 3 files changed, 15 insertions(+), 2 deletions(-)
+
+Index: pkg-config-0.25/Makefile.am
+===================================================================
+--- pkg-config-0.25.orig/Makefile.am
++++ pkg-config-0.25/Makefile.am
+@@ -31,6 +31,12 @@ AM_CFLAGS=@WARN_CFLAGS@
+ INCLUDES=-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" $(included_glib_includes) \
+ 	$(popt_includes)
+ 
++if USE_SYSROOT
++INCLUDES += -DPKG_CONFIG_SYSROOT="\"$(sysroot)\""
++else
++INCLUDES += -DPKG_CONFIG_SYSROOT=NULL
++endif
++
+ pkg_config_SOURCES= \
+ 	pkg.h \
+ 	pkg.c \
+Index: pkg-config-0.25/configure.in
+===================================================================
+--- pkg-config-0.25.orig/configure.in
++++ pkg-config-0.25/configure.in
+@@ -32,6 +32,12 @@ fi
+ 
+ PKG_CONFIG_FIND_PC_PATH
+ 
++AC_ARG_WITH(sysroot,
++ [  --with-sysroot         Use sysroot <dir> by default ],
++ [ sysroot="$withval" ])
++
++AC_SUBST([sysroot])
++AM_CONDITIONAL(USE_SYSROOT, test "x$sysroot" != "x")
+ #
+ # Code taken from gtk+-2.0's configure.in.
+ #
+Index: pkg-config-0.25/main.c
+===================================================================
+--- pkg-config-0.25.orig/main.c
++++ pkg-config-0.25/main.c
+@@ -39,7 +39,7 @@
+ static int want_debug_spew = 0;
+ static int want_verbose_errors = 0;
+ static int want_stdout_errors = 0;
+-char *pcsysrootdir = NULL;
++char *pcsysrootdir = PKG_CONFIG_SYSROOT;
+ 
+ void
+ debug_spew (const char *format, ...)
+@@ -311,7 +311,8 @@ main (int argc, char **argv)
+       add_search_dirs(PKG_CONFIG_PC_PATH, G_SEARCHPATH_SEPARATOR_S);
+     }
+ 
+-  pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR");
++  if (getenv ("PKG_CONFIG_SYSROOT_DIR"))
++	  pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR");
+   if (pcsysrootdir)
+     {
+       define_global_variable ("pc_sysrootdir", pcsysrootdir);
diff --git a/package/pkg-config/pkg-config.mk b/package/pkg-config/pkg-config.mk
index 413853d..bb52db8 100644
--- a/package/pkg-config/pkg-config.mk
+++ b/package/pkg-config/pkg-config.mk
@@ -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))
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [git commit master 1/1] pkg-config: add --with-sysroot option for compiled in default sysroot setting
  2011-01-29 23:40 [Buildroot] [git commit master 1/1] pkg-config: add --with-sysroot option for compiled in default sysroot setting Peter Korsgaard
@ 2011-01-30 14:23 ` Thomas Petazzoni
  2011-01-30 19:02   ` Peter Korsgaard
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2011-01-30 14:23 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 30 Jan 2011 00:40:13 +0100
Peter Korsgaard <jacmet@sunsite.dk> 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
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [git commit master 1/1] pkg-config: add --with-sysroot option for compiled in default sysroot setting
  2011-01-30 14:23 ` Thomas Petazzoni
@ 2011-01-30 19:02   ` Peter Korsgaard
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2011-01-30 19:02 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

Hi,

 >> 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.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-30 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-29 23:40 [Buildroot] [git commit master 1/1] pkg-config: add --with-sysroot option for compiled in default sysroot setting Peter Korsgaard
2011-01-30 14:23 ` Thomas Petazzoni
2011-01-30 19:02   ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.