cross-compile and pkgconfig

Enrico Weigelt weigelt at metux.de
Fri Sep 16 06:04:24 PDT 2005


* malet jean-luc <jean.luc.malet at coframi-grenoble.com> schrieb:

Hi,
> in my mind : crosscompiling
> usually you do a
> ./configure --prefix=/usr
> make
> export DESTDIR=/path/to/embedded/FS
> make install
> 
> this insure that all libtool and pkgconfig contain the right value (so 
> that you can boot on the target and compile new package fine) but the 
> issue is that querying the pkg-config about flags returns.... Host 
> directory.... which means that everything will fail awfully....

For clean crosscompiling you should use a sysroot'ed toolchain.
(crosstool is your friend for creating one).

You can adjust pkg-config's search pathes (PKG_CONFIG_LIBDIR,
PKG_CONFIG_PATH). And of you probly have to filter the output of 
pkg-config to add the sysroot prefix.
See attached script - you can use it as pkg-config frontend by 
setting the PKG_CONFIG variable (most packges should understand that)

<snip>
> so I think that a good behaviour is to getenv(DESTDIR)
> and to change prefix to DESTDIR/prefix when outputing result....

No, that's a very bad way. $DESTDIR is *NOT* the place where we 
have to take everything from - it's the place where the freshly 
built package goes to. I personally use $SYSROOT instead.


cu
-- 
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux IT service

  phone:     +49 36207 519931         www:       http://www.metux.de/
  fax:       +49 36207 519932         email:     contact at metux.de
  cellphone: +49 174 7066481
---------------------------------------------------------------------
 -- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops --
---------------------------------------------------------------------
-------------- next part --------------
#!/bin/bash

CMD=/usr/bin/pkg-config

if [ ! "$SYSROOT" ]; then
    echo "pkg-config-filter: missing \$SYSROOT environment variable"
    exit 2
fi

#if [ ! "$PKG_CONFIG_LIBDIR" ]; then
#    export PKG_CONFIG_LIBDIR=$SYSROOT/usr/pkgconfig/
#fi

export PKG_CONFIG_LIBDIR
export PKG_CONFIG_PATH

if $CMD $* |
    sed -e "s~\-L/*$SYSROOT/*~-L=/~g; s~\-I/*$SYSROOT/*~-I=/~g;" | # protect already given sysroot 
    sed -e "s~\-L/~-L=/~g; s~\-I/~-I=/~g;" | # add sysroot symbol to all absolute pathes
    sed -e "s~\-L\=~-L$SYSROOT~g; s~\-I\=~-I$SYSROOT~g;" # replace sysroot sign to sysroot path
then    
    echo "PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR" >&2
    echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >&2
    echo "OKAY" >&2;
    exit 0;
else
    echo "pkg-config failed!" >&2 
    exit 1
fi


More information about the pkg-config mailing list