1 #!/bin/sh
   2 #
   3 # Wrapper script that calls the real pkg-config with the relocated
   4 # sysroot location
   5 #
   6 # Wrapper derived from raspberry crosstool and modified to take SYSROOT
   7 # env variable from outside instead of computing via gcc -print-sysroot,
   8 # which produces wrong output if called without CFLAGS which contain --sysroot
   9 # Computing with CFLAGS not used, as pkg-config, in general, should not rely 
  10 # on CC, CFLAGS, ...
  11 # However, we need to CC env defined to compute pkg-config-real executable.
  12 # CC could be not used, if this script placed in raspberry crosstool's bin/.
  13  
  14 set -e
  15 
  16 if [ ! $SYSROOT ] || [ ! $CC ]; then
  17         echo "No SYSROOT or CC env defined, exiting"
  18         exit 1
  19 fi
  20 
  21 GCC="$CC"
  22 MACHINE=`"$GCC" -dumpmachine`
  23 
  24 #GCC could contain version like xxx-gcc-4.8.3, assuming xxx is equal to machine name
  25 PKG_CONFIG_REAL=${GCC%$MACHINE-*}$MACHINE-pkg-config-real
  26 
  27 export PKG_CONFIG_DIR=
  28 export PKG_CONFIG_LIBDIR="${SYSROOT}/usr/lib/${MACHINE}/pkgconfig":"${SYSROOT}/usr/lib/pkgconfig":"${SYSROOT}/usr/share/pkgconfig"
  29 export PKG_CONFIG_SYSROOT_DIR="${SYSROOT}"
  30 
  31 exec $PKG_CONFIG_REAL "$@"