#! /usr/pkg/gnu/bin/perl

#	check the command line input, arg should be file.mas

require "getopts.pl";		# including this to handle the command
				# line args

&USAGE if $#ARGV < 0;

&Getopts('i:f:p:vc');

$infile = $opt_f;
$mcc_path = $opt_p;
$verbose = $opt_v;
$include_path = $opt_i;
$clean = $opt_c;

&USAGE if ($infile eq "");
&USAGE if ($mcc_path eq "");

$executable = $c_source = $source = $infile;

substr($c_source,-3) = '';
$c_source .= "c";

substr($executable,-4) = '';

$lib = $mcc_path . '/lib/libms.a';
exit (22) if (system "gcc -o $executable mas_hooks.c $lib -I$include_path");
$mas = $mcc_path . '/lib/Mas';
system "$mas $executable";
# $ret =  system "$mas $executable";
# exit (23) if system "$mas $executable";
if ($clean) {
    exit (24) if system ("rm mas_hooks.c");
}

sub USAGE {
    print STDERR  "usage: $0 -f infile -p path [-v]\n\t\t-v\tverbose\n";
    print STDERR "Bye.\n";
    exit (21);
}
