#!/usr/bin/env perl

use strict;
use warnings;
use File::Copy qw(move);
use Cwd;

my $ViperPath = cwd();

#*** Get the version number for this update.

open(FILE,"<$ViperPath/latest.version") or die 
     "$0:Could not read $ViperPath/latest.version\n";
     my $LatestVersion = readline *FILE; chomp $LatestVersion;
     close FILE;

#*** Build the run_viper program.

chdir('Code') or die "$!";

system( 'gmake run_viper' );

chdir('..') or die "$!";

#*** Update the installed.version and update.log files.

unlink( 'Updates/installed.version' );
unlink( 'Updates/update.log' );

move( 'latest.version', 'Updates/installed.version' );
move( 'update.log', 'Updates/update.log' );

#*** Clean up.

unlink( "$LatestVersion.zip" );
unlink( "install_$LatestVersion.pl" );
