From 93545e03f814ffb41e4d8afcd538761d88877d41 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Tue, 19 Dec 2006 13:01:20 +0000 Subject: * pkg-config-wrapper: added handling for --variable git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-trunk@6528 33e552b5-05e3-0310-8538-816dae2090ed --- scripts/pkg-config-wrapper | 64 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 19 deletions(-) (limited to 'scripts/pkg-config-wrapper') diff --git a/scripts/pkg-config-wrapper b/scripts/pkg-config-wrapper index dc3a20364..a61596ad7 100755 --- a/scripts/pkg-config-wrapper +++ b/scripts/pkg-config-wrapper @@ -1,24 +1,50 @@ -#!/bin/sh +#!/bin/bash PKGCONFIG=/usr/bin/pkg-config -if [ \! "$SYSROOT" ]; then - echo >&2 - echo >&2 - echo "pkg-config: missing \$SYSROOT environment variable" >&2 - echo >&2 - echo >&2 - exit 2 -fi +check_pipe_status() { + for i in "${PIPESTATUS[@]}"; do + if test $i -ne 0; then + exit $i + fi + done +} -if [ ! "$PKG_CONFIG_LIBDIR" ]; then - export PKG_CONFIG_LIBDIR=$SYSROOT/lib/pkgconfig:$SYSROOT/usr/lib/pkgconfig +if test -z "${SYSROOT}"; then + ( + echo + echo + echo "pkg-config: missing \$SYSROOT environment variable" + echo + echo + ) >2 + exit 1 fi -export PKG_CONFIG_LIBDIR +export PKG_CONFIG_LIBDIR=${SYSROOT}/lib/pkgconfig:${SYSROOT}/usr/lib/pkgconfig export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 +found_var=false +for ((i = 1; i <= ${#}; i++)); do + case "${!i}" in + --variable*) + found_var=true + ;; + *) + ;; + esac +done + + +if ${found_var}; then +# +# if someone asks for a variable, if it looks like a path (starting with /) +# prefix it with sysroot +# + ${PKGCONFIG} "${@}" | + sed -e "s~^/~${SYSROOT}/~" +else # # 1) protect already given sysroot # 2) add sysroot symbol to all absolute paths @@ -26,11 +52,11 @@ export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 # 4) libtool isn't correctly DESTDIR/SYSROOT aware, it replaces -lfoo by # paths leading to host libraries; using -Wl,-lfoo seems to work. # + ${PKGCONFIG} "${@}" | + sed -e "s~\-L/*${SYSROOT}/*~-L=/~g; s~\-I/*${SYSROOT}/*~-I=/~g;" \ + -e "s~\-L/~-L=/~g; s~\-I/~-I=/~g;" \ + -e "s~\-L\=~-L${SYSROOT}~g; s~\-I\=~-I${SYSROOT}~g;" \ + -e "s~[\t ]\-l~ -Wl,-l~g;" +fi -OUTPUT=`$PKGCONFIG $*` || exit $? - -echo -n $OUTPUT | - sed -e "s~\-L/*$SYSROOT/*~-L=/~g; s~\-I/*$SYSROOT/*~-I=/~g;" \ - -e "s~\-L/~-L=/~g; s~\-I/~-I=/~g;" \ - -e "s~\-L\=~-L$SYSROOT~g; s~\-I\=~-I$SYSROOT~g;" \ - -e "s~[\t ]\-l~ -Wl,-l~g;" +check_pipe_status -- cgit v1.2.3