#!/bin/sh
#
# run-avr-gcc-XXX
#
# Prep-end a particular bin directory to PATH, which contains executables
# avr-gcc version XXX, but without the -XXX suffix in their name.
#
# Copyright (C) 2011 by Volker Kuhlmann
#               http://volker.top.geek.nz/contact.html
# All rights reserved.
# Released under the terms of the GNU General Public License (GPL) Version 2.
# See http://www.gnu.org/ for details.
#
# Volker Kuhlmann
#   14 Nov 2011  Created.
#   15 Nov 2011  Added help.
#

VERSION="1.1, 15 Nov 2011"
AUTHOR="Volker Kuhlmann"
COPYRIGHT="Copyright (C) 2011"

# Root of bin directory for this particular gcc version.
root="/opt/cross/avr/lib64/gcc/avr/4.6.2"

Help() {
    echo "
Usage: `basename ${0}` [OPTIONS] CMD [ARGS...]
Version $VERSION
$COPYRIGHT by $AUTHOR

Prepend '$root'
to PATH and run CMD with arguments ARGS.

OPTIONS:
  -h|--help   Show help.
  --version   Show version.
"
}

Version() {
    echo "`basename ${0}` version $VERSION
$COPYRIGHT by $AUTHOR"
}

case "$1" in
    --help|-h)
    	Help
	;;
    --version)
    	Version
	;;
    *)
    	PATH="$root/bin:$PATH"
    	export PATH

    	exec "$@"
	;;
esac
