summaryrefslogtreecommitdiffstats
path: root/scripts/pkg-config-wrapper
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2006-12-19 13:01:20 +0000
committerMarc Kleine-Budde <mkl@pengutronix.de>2006-12-19 13:01:20 +0000
commit93545e03f814ffb41e4d8afcd538761d88877d41 (patch)
tree97a46f5f3fefb62cd08497d3954378de5bc78879 /scripts/pkg-config-wrapper
parentef3dbf0c96f007e54cf0c087394358ce9ab1c1de (diff)
downloadptxdist-93545e03f814ffb41e4d8afcd538761d88877d41.tar.gz
ptxdist-93545e03f814ffb41e4d8afcd538761d88877d41.tar.xz
* 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
Diffstat (limited to 'scripts/pkg-config-wrapper')
-rwxr-xr-xscripts/pkg-config-wrapper64
1 files changed, 45 insertions, 19 deletions
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