media/webrtc/trunk/build/linux/pkg-config-wrapper

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/trunk/build/linux/pkg-config-wrapper	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +#!/bin/bash
     1.5 +# Copyright (c) 2012 The Chromium Authors. All rights reserved.
     1.6 +# Use of this source code is governed by a BSD-style license that can be
     1.7 +# found in the LICENSE file.
     1.8 +
     1.9 +# This program wraps around pkg-config to generate the correct include and
    1.10 +# library paths when cross-compiling using a sysroot.
    1.11 +# The assumption is that the sysroot contains the .pc files in usr/lib/pkgconfig
    1.12 +# and usr/share/pkgconfig (relative to the sysroot) and that they output paths
    1.13 +# relative to some parent path of the sysroot.
    1.14 +# This assumption is valid for a range of sysroots, in particular: a
    1.15 +# LSB-compliant root filesystem mounted at the sysroot, and a board build
    1.16 +# directory of a Chromium OS chroot.
    1.17 +
    1.18 +root="$1"
    1.19 +shift
    1.20 +target_arch="$1"
    1.21 +shift
    1.22 +
    1.23 +if [ -z "$root" -o -z "$target_arch" ]
    1.24 +then
    1.25 +  echo "usage: $0 /path/to/sysroot target_arch [pkg-config-arguments] package" >&2
    1.26 +  exit 1
    1.27 +fi
    1.28 +
    1.29 +if [ "$target_arch" = "x64" ]
    1.30 +then
    1.31 +  libpath="lib64"
    1.32 +else
    1.33 +  libpath="lib"
    1.34 +fi
    1.35 +
    1.36 +rewrite=`dirname $0`/rewrite_dirs.py
    1.37 +package=${!#}
    1.38 +
    1.39 +config_path=$root/usr/$libpath/pkgconfig:$root/usr/share/pkgconfig
    1.40 +set -e
    1.41 +# Some sysroots, like the Chromium OS ones, may generate paths that are not
    1.42 +# relative to the sysroot. For example,
    1.43 +# /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths
    1.44 +# relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of
    1.45 +# relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr).
    1.46 +# To support this correctly, it's necessary to extract the prefix to strip from
    1.47 +# pkg-config's |prefix| variable.
    1.48 +prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | sed -e 's|/usr$||'`
    1.49 +result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"`
    1.50 +echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix"

mercurial