Here is a patch adding support to pkgconfig for using
<triplet>-pkgconfig commands to specify which architecture path should
be searched for libraries.

This is achieved with a simple wrapper to set PKG_CONFIG_LIBDIR and
call pkg-config. Does that wrapper look OK? It's not very clever, but
I don't think it needs to be. 

To use this functionality a symlink to the wrapper must be created
with a suitable name, such as
arm-linux-gnueabi-pkg-config
It's not totally obvious which package should provide this:

pkg-config could ship a set of symlinks, one for all official
architectures, but that's not very useful for nearly all users, and
limits the set of cross-options provided somewhat arbitrarily (things
like avr32-pkg-config would also be useful alongside an avr32
cross-toolchain). A more sensible place to put them is either in the
cross-toolchain packages (which we don't yet have in Debian), or in
dpkg-cross as a catch-all for cross-building support.

The advantage of putting a symlink in a cross-toolchain package is
that then it just installs one for the target it supports, so no
decision is needed about what set of symlinks to create.

I have a patch to create symlinks for valid architectures in the
pkg-config rules file. Also attached by way of an example as it's
slightly tricky to make work (dpkg-architecture needs -f when run
under dh8 to DTRT in this case). It can also be done trivially in a
postinst but then it's much less obvious where they came from (dpkg -S
won't know). 

This discussion of symlinks get back to the discussion of how best to
implement this functionality. Would it be better done as proposed
here:
http://www.freedesktop.org/wiki/Software/pkg-config/CrossCompileProposal
(i.e using pkg-config --host <triplet>
And implemented here:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=217902#28

This mechanism has the advantage that it supports all possible targets
without having to create special symlinks. It has the major
disadvantage that it won't work until the source is autoreconfed to
add the necessary support to the package's configure script.

This report realtes to Ubuntu bug:
https://bugs.launchpad.net/ubuntu/+source/pkg-config/+bug/771567
And the related change to create symlink:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults-armel-cross/+bug/605189
(That pair implment the wraper in pkg-config and a symlink for armel
in the gcc-defaults-armel-cross package. Installing both makes
cross-pkg-config 'just work' for armel). 

So, should we start using this <triplet>-pkg-config functionality
because it already works? Or should we implement --host and autoreconf
all packages which use this functionality, or should we support both? 

If we support the <triplet>-pkg-config functionality then where should
the symlinks come from? pkg-config itself (providing  which arches?),
dpkg-cross, some cross-toolchain package (which?), a new
pkg-config-cross package?

Direction welcome.

Wookey
-- 
Principal hats:  Linaro, Emdebian, Wookware, Balloonboard, ARM
http://wookware.org/
diff -urN pkg-config-0.25/debian/changelog pkg-config-0.25.patched/debian/changelog
diff -urN pkg-config-0.25/debian/install pkg-config-0.25.patched/debian/install
--- pkg-config-0.25/debian/install	1970-01-01 00:00:00.000000000 +0000
+++ pkg-config-0.25.patched/debian/install	2011-04-27 00:38:43.404669001 +0000
@@ -0,0 +1 @@
+debian/pkg-config-crosswrapper usr/lib/pkgconfig
\ No newline at end of file
diff -urN pkg-config-0.25/debian/pkg-config-crosswrapper pkg-config-0.25.patched/debian/pkg-config-crosswrapper
--- pkg-config-0.25/debian/pkg-config-crosswrapper	1970-01-01 00:00:00.000000000 +0000
+++ pkg-config-0.25.patched/debian/pkg-config-crosswrapper	2011-04-21 17:51:47.667284963 +0000
@@ -0,0 +1,6 @@
+#!/bin/sh
+# pkg-config wrapper for cross-building
+# Sets pkg-config search path to target arch path only.
+
+triplet=`basename $0 | sed -e 's:-pkg-config::'`
+PKG_CONFIG_LIBDIR=/usr/${triplet}/lib/pkgconfig pkg-config $@
#! /usr/bin/make -f

DEB_HOST_MULTIARCH      := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

pkgdir := `pwd`/debian/sash

%:
        dh $@

override_dh_auto_configure:
        ./configure --prefix=/usr --with-installed-glib \
                --with-installed-popt \
                --mandir=\$${prefix}/share/man \
                --infodir=\$${prefix}/share/info --disable-shared \
                
--with-pc-path=/usr/local/lib/$(DEB_HOST_MULTIARCH)/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
 \

override_dh_auto_clean:
        [ ! -f Makefile ] || $(MAKE) distclean DIST_SUBDIRS="popt check"


override_dh_install:
        dh_install
        for arch in armel ia64 i386 kfreebsd-i386 kfreebsd-amd64 m68k mips 
mipsel s390 sparc; do \
          triplet=`dpkg-architecture -f -a$${arch} -qDEB_HOST_GNU_TYPE` 2> 
/dev/null; \
          dh_link usr/bin/pkg-config-crosswrapper 
usr/bin/$${triplet}-pkg-config; \
        done

Reply via email to