#! /usr/bin/perl -w
use strict;

my $command = "-felf";
my $f;

foreach (@ARGV) {
	if (/\.S$/) {
		$command = "gcc " . join(' ', @ARGV);
		last;
	} elsif (/\.s$/) {
		if ($command =~ s/(\w*)\.lo/\.libs\/\1\.o/)
		{
			$f = $1;
		}
		$command = "nasm $command $_";


	} elsif (/^-o$/ || /\.lo$/ || /\.o$/) {
		$command = "$command $_";
	} 
}
print "$command\n";
`$command`;
if ($f) {
	open (FH, ">$f.lo");
	print FH "# $f.lo - a libtool object file
# Generated by ltmain.sh - GNU libtool 1.5.0a (1.1220.2.25 2003/08/01 19:08:35)
# Debian: 49
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# Name of the PIC object.
";

	print FH "pic_object=";
	print FH "'.libs/$f.o'\n\n";
	print FH '# Name of the non-PIC object.
';
	print FH "non_pic_object=";
	print FH "'$f.o'";
	print FH "\n\n";
	close (FH);

}

