#!/usr/bin/perl
#
#  gccross - Make GCC calls cross-compiler aware
#  Copyright (C) 2004  Raphael Bossek <bossekr@debian.org>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#  $Id: gccross,v 1.1 2004/07/22 20:30:06 yoush-guest Exp $

require "dpkg-cross.pl";

read_config();
setup();

$0 =~ /([^\/]+)$/;
$basename_ = $1;

if ($basename_ eq 'gccross') {
	exit 1;
}

if ($ENV{'GCCROSS_PREFIX'}) {
	push (@newARGV, $basename_);
	$basename_ = $ENV{'GCCROSS_PREFIX'};
}
for $arg_ (@ARGV) {
	# Convert standalone full path arguments, or full paths after -I and -L
	if ($arg_ =~ /^(-I|-L|)(\/.*)/) {
		push (@newARGV, $1 . convert_path($2));
	}
	else {
		push (@newARGV, $arg_);
	}
}

$ENV{'PATH'} = $compilerpath;
exec $basename_, @newARGV;
