#!/bin/bash
#
# Wrapper for gcc

# Add MESA SDK directories to the library load path

export LD_LIBRARY_PATH="${MESASDK_ROOT}/lib:${MESASDK_ROOT}/lib64:${LD_LIBRARY_PATH}"

# Add MESA SDK directories to the libary run path (unfortunately, this
# will get ignored if any -rpath arguments are passed to the linker)

export LD_RUN_PATH="${MESASDK_ROOT}/lib:${MESASDK_ROOT}/lib64:${LD_RUN_PATH}"

# Deal with Ubuntu multiarch

if `uname -a | grep -q Ubuntu`; then
   export LIBRARY_PATH="/usr/lib/x86_64-linux-gnu:${LIBRARY_PATH}"
   FLAGS="${FLAGS} -I/usr/include/x86_64-linux-gnu"
fi

# Launch gcc

eval $0.exec ${FLAGS} $(printf '%q ' "$@")
exit $?
