#!/sw/bin/perl
##
##  PORTING.upd -- Update the PORTING file
##  Copyright (c) 1998,1999 Ralf S. Engelschall, All Rights Reserved. 
##

$file = '';
open(FP, "<PORTING");
while (<FP>) {
    if (m|^\s+Currently there are.*|) {
        $file .= $_;
        $file .= "\n";
        last;
    }
    $file .= $_;
}
close(FP);

$file1 = '';
$file2 = '';

%OV = ();

$n = 0;
open(PL, "<PORTING.L");
while (<PL>) {
    next if (m|^\s*$|);
    next if (m|^\s*#.*$|);

    @L = split(/ : /, $_);
    @L2 = ();
    foreach $l (@L) {
        $l =~ s|^\s+||;
        $l =~ s|\s+$||;
        push(@L2, $l);
    }
    @L = @L2;

	$OV{$L[0]} = [] if (not defined($OV{$L[0]}));
	push(@{$OV{$L[0]}}, "WML $L[0], $L[3], Perl $L[1], $L[2]");

    $file2 .= "  Website META Language : $L[0]\n";
    $file2 .= "  Platform              : $L[3]\n";
    $file2 .= "  Build User            : $L[4]\n";
    $file2 .= "  Build Date            : $L[5]\n";
    $file2 .= "  Perl 5 Interpreter    : $L[1]\n";
    $file2 .= "  ANSI C Compiler       : $L[2]\n";
    $x = $L[6];
    $x =~ s|\s+--|\n                          --|sg;
    $file2 .= "  Autoconf Options      : $x\n";
    $file2 .= "\n";
	$n++;
}
close(PL);
$file =~ s|(Currently there are )\d+|$1$n|sg;

foreach $v (sort(keys(%OV))) {
	foreach $l (@{$OV{$v}}) {
	    $file1 .= "  $l\n";
	}
}

$file .= $file1 . 
		 "\n" . 
		 "  Detailed Platform Porting List:\n\n" .
		 $file2;

open(FP, ">PORTING");
print FP $file;
close(FP);

##EOF##
