OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # This program wraps around pkg-config to generate the correct include and | 6 # This program wraps around pkg-config to generate the correct include and |
7 # library paths when cross-compiling using a sysroot. | 7 # library paths when cross-compiling using a sysroot. |
8 # The assumption is that the sysroot contains the .pc files in usr/lib/pkgconfig | 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 | 9 # and usr/share/pkgconfig (relative to the sysroot) and that they output paths |
10 # relative to some parent path of the sysroot. | 10 # relative to some parent path of the sysroot. |
(...skipping 10 matching lines...) Expand all Loading... |
21 shift | 21 shift |
22 libpath="$1" | 22 libpath="$1" |
23 shift | 23 shift |
24 | 24 |
25 if [ -z "$root" -o -z "$target_arch" ] | 25 if [ -z "$root" -o -z "$target_arch" ] |
26 then | 26 then |
27 echo "usage: $0 /path/to/sysroot target_arch libdir [pkg-config-arguments] pac
kage" >&2 | 27 echo "usage: $0 /path/to/sysroot target_arch libdir [pkg-config-arguments] pac
kage" >&2 |
28 exit 1 | 28 exit 1 |
29 fi | 29 fi |
30 | 30 |
31 if [ "$target_arch" = "x64" ] | |
32 then | |
33 : ${libpath:="lib64"} | |
34 else | |
35 : ${libpath:="lib"} | |
36 fi | |
37 | |
38 rewrite=`dirname $0`/rewrite_dirs.py | 31 rewrite=`dirname $0`/rewrite_dirs.py |
39 package=${!#} | 32 package=${!#} |
40 | 33 |
41 config_path=$root/usr/$libpath/pkgconfig:$root/usr/share/pkgconfig | 34 config_path=$root/usr/$libpath/pkgconfig:$root/usr/share/pkgconfig |
42 | 35 |
43 # prepend any paths specified by the environment | 36 # prepend any paths specified by the environment |
44 if [ -n "$PKG_CONFIG_PATH" ] | 37 if [ -n "$PKG_CONFIG_PATH" ] |
45 then | 38 then |
46 config_path="$PKG_CONFIG_PATH:$config_path" | 39 config_path="$PKG_CONFIG_PATH:$config_path" |
47 fi | 40 fi |
48 | 41 |
49 set -e | 42 set -e |
50 # Some sysroots, like the Chromium OS ones, may generate paths that are not | 43 # Some sysroots, like the Chromium OS ones, may generate paths that are not |
51 # relative to the sysroot. For example, | 44 # relative to the sysroot. For example, |
52 # /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths | 45 # /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths |
53 # relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of | 46 # relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of |
54 # relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). | 47 # relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). |
55 # To support this correctly, it's necessary to extract the prefix to strip from | 48 # To support this correctly, it's necessary to extract the prefix to strip from |
56 # pkg-config's |prefix| variable. | 49 # pkg-config's |prefix| variable. |
57 prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | s
ed -e 's|/usr$||'` | 50 prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | s
ed -e 's|/usr$||'` |
58 result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"` | 51 result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"` |
59 echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix" | 52 echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix" |
OLD | NEW |