#! /usr/local/bin/perl -w

use strict;
use File::Path;

select(STDOUT); $|=1;
select(STDERR); $|=1;

my $UH="./make/sethost.prl";
my $TOP = "..";

# Check that we have a host name
my $host = $ARGV[0];
unless($host){
  usage();
  exit(-1);
}

# Preparing

my @dirs = ("$TOP/bin/$host", "$TOP/lib/$host", "./bin/$host", "./lib/$host");
foreach(@dirs){
  mkpath([ $_ ], 1, 0755);
}
chdir($TOP);
system("perl $UH $host") && exit(-1);
system("make libs") && exit(-1);
system("make bins") && exit(-1);
chdir("./gfi");
system("make libs") && exit(-1);
system("make bins") && exit(-1);

exit(0);

sub usage {

  my $msg=<<_EOM_;
  
  USAGE: perl Buil.PL <host>
  
  Use one of the host keywords listed above.
  
_EOM_
  ;
  
  chdir($TOP);
  `perl $UH`;
  print STDERR $msg;
  
  return(1);
}


