#!/bin/bash
#
# This is a script which runs tools set up for the Steam runtime

if [ -z "${STEAM_RUNTIME_ROOT}" ]; then
    echo "Missing development environment variables, did you run shell.sh?"
    exit 1
fi

case "${STEAM_RUNTIME_TARGET_ARCH}" in
i386)
    CROSSTOOL_LIBPATH="i386-linux-gnu"
    ;;
amd64)
    CROSSTOOL_LIBPATH="x86_64-linux-gnu"
    ;;
*)
    echo "Unknown target architecture: ${STEAM_RUNTIME_TARGET_ARCH}"
    exit 1
    ;;
esac

PKG_CONFIG_PATH="${STEAM_RUNTIME_ROOT}/usr/lib/${CROSSTOOL_LIBPATH}/pkgconfig:${STEAM_RUNTIME_ROOT}/usr/lib/pkgconfig:${STEAM_RUNTIME_ROOT}/usr/share/pkgconfig"
export PKG_CONFIG_PATH

# Run the tool...
result=$(/usr/bin/pkg-config "$@")
status=$?
if [ "$result" != "" ]; then
    echo "$result" | sed -e "s,-I/,-I${STEAM_RUNTIME_ROOT}/,g" -e "s,-L/,-L${STEAM_RUNTIME_ROOT}/,g" 
fi
exit $status

# vi: ts=4 sw=4 expandtab
