#!/usr/bin/perl



$source = @ARGV[0];
if ($source eq "help" || $source eq "h"){
    print "ORXONOX checkout script for Tardis:\n usage:\n tardis-scratch-checkout.pl [branche]\n";
    exit;
  }
if ($source eq "") {
    $source = "trunk";
  }

$username = `whoami`;
chomp $username;


$URL = "https://svn.orxonox.net/orxonox/$source";
$destination = "/scratch/$username\/orxonox/$source";

  mkdir ("/scratch/$username");
  mkdir ("/scratch/$username\/orxonox");

  print("Checking out ORXONOX from '$URL' to '$destination'\n");


  open(SVN_CO, "svn co $URL $destination |");
  while(<SVN_CO>){
   print $_;
  }
  
  chdir("$destination");


  print "executing autogen.sh\n";
  open( AUTOGEN , "./autogen.sh |");
  while(<AUTOGEN>){
   print $_;
  }

  print "executing configure for tardis\n";
  open(CONFIGURE, "./configure --with-tardis |");
  while(<CONFIGURE>){
    printf $_;
  }
  
  print ("Executing make with opts -j3\n");
  open(MAKE, "make -j3|");
  while(<MAKE>) {
    print $_;
  }
  printf("Finished checking out '$URL' to '$destination'\n");

