#!/bin/bash
#
# archexec - by Mike A. Harris <mharris@redhat.com>
#
# Copyright (c) 2004 Red Hat, Inc. All rights reserved. This copyrighted
# material is made available to anyone wishing to use, modify, copy, or 
# redistribute it subject to the terms and conditions of the GNU General 
# Public License version 2.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# Synopsis:
# archexec is a generic bash script which can be symlinked to, and when
# the symlink is executed, archexec appends the currently running
# canonical architecture name to the name of the symlink, and execs the
# new command.
#
# Example: ln -s archexec gccmakedep
#          ./gccmakedep
#
# The above example, will cause gccmakedep-<arch> to be ran when gccmakedep
# is executed, where "<arch>" is the architecture name returned by "uname -i"

COMMAND_ARCH="${0}-$(uname -i 2> /dev/null)"
if [ "$?" = 1 ] ; then
	echo "archexec: Error: uname does not support the -i option, aborting"  >&2
	exit 1
fi
if [ -x "${COMMAND_ARCH}" ] ; then
	exec "${COMMAND_ARCH}" "$@"
else
	echo "archexec: Error: ${COMMAND_ARCH} not found" >&2
	exit 1
fi
