Chromium Code Reviews| Index: build/linux/pkg-config-wrapper |
| diff --git a/build/linux/pkg-config-wrapper b/build/linux/pkg-config-wrapper |
| index d94b99747d58f4f0e96cc5e47156ec74611e705a..0746c072fbae808d7035da118f3fb4ca28967785 100755 |
| --- a/build/linux/pkg-config-wrapper |
| +++ b/build/linux/pkg-config-wrapper |
| @@ -1,16 +1,25 @@ |
| -#!/bin/sh |
| +#!/bin/bash |
|
Evan Martin
2010/11/18 22:19:00
Can you add some comments at the top of this expla
piman
2010/11/18 23:05:29
Done.
|
| root="$1" |
| if [ -z "$root" ] |
| then |
| - echo "usage: $0 /path/to/sysroot [pkg-config-arguments]" >&2 |
| + echo "usage: $0 /path/to/sysroot [pkg-config-arguments] package" >&2 |
| exit 1 |
| fi |
| rewrite=`dirname $0`/rewrite_dirs.py |
| +package=${!#} |
| shift |
| config_path=$root/usr/lib/pkgconfig:$root/usr/share/pkgconfig |
| set -e |
| -result=`PKG_CONFIG_PATH=$config_path pkg-config --define-variable=prefix=/usr "$@"` |
| -echo "$result"| $rewrite $root |
| +# Some sysroots, like the Chromium OS ones, may generate paths that are not |
| +# relative to the sysroot. For example, |
| +# /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths |
| +# relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of |
| +# relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). |
| +# To support this correctly, it's necessary to extract the prefix to strip from |
| +# pkg-config's |prefix| variable. |
| +prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | sed -e 's|/usr$||'` |
| +result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"` |
| +echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix" |