#!/bin/perl
#
# Usage: gen_mpkiller   [-m mpk_option_file] [-s seed] 
#			[-t template_file] [-o output_file]
#
# require 5.001;
require "getopts.pl";
# use English;

&Getopts('i:m:r:s:t:o:h');

chop($prog = `basename $PROGRAM_NAME`);
if ($opt_h) {
   printf("usage: $prog [-m file] [-s seed] [-t file] [-o file]\n");
   printf("	-m	options file (default: mpk_options)\n");
   printf("	-s	seed\n");
   printf("	-t	template file (default: mpk_template.s)\n");
   printf("	-o	output file (default: mpk_test.s)\n");
   exit;
}

$mpk_gen	  = "sbkiller/genSB.irix";
$mpk_options_file = $opt_m ? $opt_m : "mpk_options";
$mpk_template     = $opt_t ? $opt_t : "mpk_template.s";
$mpk_output       = $opt_o ? $opt_o : "mpk_test.s";

srand;
if ($opt_s) {
	$seed = $opt_s;
}
else {
	$seed = int(rand(2147483647));
}
open(MPK_OPTIONS_FILE, $mpk_options_file) || 
   die("$prog: Can't open $mpk_options_file for mpkiller options.\n");

# Concatenate all the options.
while (<MPK_OPTIONS_FILE>) {
	chop;
	$options = $options . " " . $_;
}
printf("Options file:  %s\n", $mpk_options_file);
printf("Template file: %s\n", $mpk_template);
printf("Test file:     %s\n", $mpk_output);
printf("Seed is %d\n", $seed);
system("$mpk_gen $options -a randomSeed=$seed -T $mpk_template > $mpk_output");

