#!/usr/bin/perl
# ptc_gsiz      *** included shell script
#
# @(#)ptc_gsiz  6.1.2  1995-09-20
#
# Included in shmlink and shmprelink.
# Create gsize.c
#
use Env;

unlink "allsiz";

if ( $SHRGLOB ) {
	open(FILE_IN, "<gsize") || die "Can't open gsize: $!"; # gsize created by vmake
	open(FILE_OUT, ">allsize") || die "Can't open allsize: $!";
	print FILE_OUT <FILE_IN>;
	close(FILE_IN); close(FILE_OUT);
} else {
	$OUTFILE =~ /(.*)\.[fqso]$/, $BASE = $1 ne "" ? $1 : $OUTFILE;
    print "$TOOL/pgm/vmake -nU $BASE\n";
	open(PIPE_IN, "$TOOLSHELL $TOOL/bin/imf.pl -nU $BASE |") || die "Can't open pipe $TOOL/pgm/vmake -nU $BASE: $!";
	while (<PIPE_IN>) {
		chomp;
		if ( /^v[a-z][a-z]\d\d/i ) {
			next if /^v..00/;
			s/debug//;
			/^(v\w\w\d\d\d?)\s+(fast|quick|slow)/;
			local($output) = "../../$2/gsize/$1.gsz";
			push @tmplist, $output unless /[ca]\.gsz/ ;
		}
	}
	close(PIPE_IN);
    foreach $i ( @tmplist ) {

        if ( -f $i ) {
			open(FILE_IN, "<$i") || die "Can't open $i: $!";
			open(FILE_OUT, ">>allsize") || die "Can't open allsize: $!";
			print FILE_OUT <FILE_IN>;
			close(FILE_IN); close(FILE_OUT);
        } else { warn "Warning : $i not found\n" }
    }
}

system("$TOOL/Posix/sort -u allsiz > gsize.siz");
system("$TOOL/pgm/ptc_ginit gsize.siz > gsize.c") == 0
	or die "Error while executing \"$TOOL/pgm/ptc_ginit gsize.siz > gsize.c\"\n".
	"message: $!\n";


