Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #!/bin/bash |
michael@0 | 2 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
michael@0 | 3 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | # found in the LICENSE file. |
michael@0 | 5 | |
michael@0 | 6 | # This program wraps around pkg-config to generate the correct include and |
michael@0 | 7 | # library paths when cross-compiling using a sysroot. |
michael@0 | 8 | # The assumption is that the sysroot contains the .pc files in usr/lib/pkgconfig |
michael@0 | 9 | # and usr/share/pkgconfig (relative to the sysroot) and that they output paths |
michael@0 | 10 | # relative to some parent path of the sysroot. |
michael@0 | 11 | # This assumption is valid for a range of sysroots, in particular: a |
michael@0 | 12 | # LSB-compliant root filesystem mounted at the sysroot, and a board build |
michael@0 | 13 | # directory of a Chromium OS chroot. |
michael@0 | 14 | |
michael@0 | 15 | root="$1" |
michael@0 | 16 | shift |
michael@0 | 17 | target_arch="$1" |
michael@0 | 18 | shift |
michael@0 | 19 | |
michael@0 | 20 | if [ -z "$root" -o -z "$target_arch" ] |
michael@0 | 21 | then |
michael@0 | 22 | echo "usage: $0 /path/to/sysroot target_arch [pkg-config-arguments] package" >&2 |
michael@0 | 23 | exit 1 |
michael@0 | 24 | fi |
michael@0 | 25 | |
michael@0 | 26 | if [ "$target_arch" = "x64" ] |
michael@0 | 27 | then |
michael@0 | 28 | libpath="lib64" |
michael@0 | 29 | else |
michael@0 | 30 | libpath="lib" |
michael@0 | 31 | fi |
michael@0 | 32 | |
michael@0 | 33 | rewrite=`dirname $0`/rewrite_dirs.py |
michael@0 | 34 | package=${!#} |
michael@0 | 35 | |
michael@0 | 36 | config_path=$root/usr/$libpath/pkgconfig:$root/usr/share/pkgconfig |
michael@0 | 37 | set -e |
michael@0 | 38 | # Some sysroots, like the Chromium OS ones, may generate paths that are not |
michael@0 | 39 | # relative to the sysroot. For example, |
michael@0 | 40 | # /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths |
michael@0 | 41 | # relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of |
michael@0 | 42 | # relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). |
michael@0 | 43 | # To support this correctly, it's necessary to extract the prefix to strip from |
michael@0 | 44 | # pkg-config's |prefix| variable. |
michael@0 | 45 | prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | sed -e 's|/usr$||'` |
michael@0 | 46 | result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"` |
michael@0 | 47 | echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix" |