OLD | NEW |
1 #!/bin/sh | 1 #!/bin/bash |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 # This program wraps around pkg-config to generate the correct include and |
| 7 # library paths when cross-compiling using a sysroot. |
| 8 # The assumption is that the sysroot contains the .pc files in usr/lib/pkgconfig |
| 9 # and usr/share/pkgconfig (relative to the sysroot) and that they output paths |
| 10 # relative to some parent path of the sysroot. |
| 11 # This assumption is valid for a range of sysroots, in particular: a |
| 12 # LSB-compliant root filesystem mounted at the sysroot, and a board build |
| 13 # directory of a Chromium OS chroot. |
2 | 14 |
3 root="$1" | 15 root="$1" |
4 if [ -z "$root" ] | 16 if [ -z "$root" ] |
5 then | 17 then |
6 echo "usage: $0 /path/to/sysroot [pkg-config-arguments]" >&2 | 18 echo "usage: $0 /path/to/sysroot [pkg-config-arguments] package" >&2 |
7 exit 1 | 19 exit 1 |
8 fi | 20 fi |
9 | 21 |
10 rewrite=`dirname $0`/rewrite_dirs.py | 22 rewrite=`dirname $0`/rewrite_dirs.py |
| 23 package=${!#} |
11 | 24 |
12 shift | 25 shift |
13 config_path=$root/usr/lib/pkgconfig:$root/usr/share/pkgconfig | 26 config_path=$root/usr/lib/pkgconfig:$root/usr/share/pkgconfig |
14 set -e | 27 set -e |
15 result=`PKG_CONFIG_PATH=$config_path pkg-config --define-variable=prefix=/usr "$
@"` | 28 # Some sysroots, like the Chromium OS ones, may generate paths that are not |
16 echo "$result"| $rewrite $root | 29 # relative to the sysroot. For example, |
| 30 # /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths |
| 31 # relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of |
| 32 # relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). |
| 33 # To support this correctly, it's necessary to extract the prefix to strip from |
| 34 # pkg-config's |prefix| variable. |
| 35 prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | s
ed -e 's|/usr$||'` |
| 36 result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"` |
| 37 echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix" |
OLD | NEW |