taste-config.pl 3.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
#!/usr/bin/perl -w

use strict;
use File::Basename;
use Getopt::Long;

my $show_packages;
my $show_orchestrator_path;
my $show_buildsupport_path;
my $show_directives_path;
my $show_dmt_path;
my $show_prefix;
my $result;
my $tmp;
my @tmp;
my $prefix = "INSTALL_PREFIX";


$show_prefix            = 0;
$show_packages          = 0;
$show_orchestrator_path = 0;
$show_buildsupport_path = 0;
$show_directives_path   = 0;
$show_dmt_path          = 0;

$result = GetOptions ("prefix"       => \$show_prefix,
                      "orchestrator" => \$show_orchestrator_path,
                      "buildsupport" => \$show_buildsupport_path,
                      "directives"   => \$show_directives_path,
                      "dmt"          => \$show_dmt_path,
                      "packages"     => \$show_packages);


sub help
{
   print STDERR "Usage: $0 OPTIONS\n";
   print STDERR "Options are:\n";
   print STDERR "   --prefix        - output the TASTE installation prefix\n";
   print STDERR "   --packages      - output the list of installed TASTE packages\n";
   print STDERR "   --orchestrator  - output the list of PATH of the orchestrator\n";
   print STDERR "   --buildsupport  - output the list of PATH of buildsupport\n";
   print STDERR "   --dmt           - output the list of PATH of DMT tools\n";
   print STDERR "   --directives    - output the PATH of the directives file\n";
   exit 1;
}

sub find_dmt_path
{
   my $ret;
   my $tmp;

   $ret = "/foo/bar/i/want/a/hp/touchpad/";

   $tmp = `which asn1.exe`;
   chomp ($tmp);
   if (-x $tmp)
   {
      $tmp =~ s/\/[a-zA-Z0-9\.exe]+$//;
      $tmp =~ s/[a-zA-Z0-9]+$//;
      $ret = $tmp;
   }
   else
   {
      opendir (DIR , "/opt") or exit 1;

      @tmp = readdir (DIR);

      foreach (@tmp)
      {
         if ( (/^DMT-ToolsAndManual.*/) && (-f "/opt/$_/License.txt"))
         {
            $ret = "/opt/$_/";
         }
      }
      closedir (DIR);
   }

   return $ret if (-d $ret);
   return undef;
}

if ($show_prefix == 1)
{
   print "$prefix\n";
   exit 0;
}
elsif ($show_directives_path == 1)
{
   $tmp = $prefix . "/share/taste/TASTE-Directives.asn";
   if (-f $tmp)
   {
      print "$tmp\n";
      exit 0;
   }
   else
   {
      print "DIRECTIVES FILES NOT FOUND\n";
      exit 1;
   }
}
elsif ($show_buildsupport_path == 1)
{
   $tmp = $prefix . "/bin/buildsupport";
   if (-x $tmp)
   {
      print $tmp . "\n";
      exit 0;
   }
   else
   {
      print STDERR "NOT INSTALLED";
      exit 1;
   }
}
elsif ($show_orchestrator_path == 1)
{
   $tmp = $prefix . "/bin/assert-builder-ocarina.py";
   if (-x $tmp)
   {
      print $tmp . "\n";
      exit 0;
   }
   else
   {
      print STDERR "NOT INSTALLED";
      exit 1;
   }
}
elsif ($show_dmt_path == 1)
{
   $tmp = find_dmt_path ();
   if (defined ($tmp) && ( -d $tmp ))
   {
      print $tmp . "\n";
      exit 0;
   }
   else
   {
      print STDERR "DMT NOT INSTALLED\n";
      exit 1;
   }
}
elsif ($show_packages == 1)
{
   $tmp = find_dmt_path ();

   print "INSTALLED TASTE PACKAGES\n";
   print "   * Ocarina\n" if (-x "$prefix/bin/ocarina");
   print "   * Orchestrator\n" if (-x "$prefix/bin/assert-builder-ocarina.py");
   print "   * Buildsupport\n" if (-x "$prefix/bin/buildsupport");
   print "   * PolyORB-HI-C runtime\n" if (-d "$prefix/include/ocarina/runtime/polyorb-hi-c/");
   print "   * PolyORB-HI-Ada runtime\n" if (-d "$prefix/include/ocarina/runtime/polyorb-hi-ada/");
   print "   * TASTEGUI\n" if (-x "$prefix/bin/tastegui");
   print "\n";

   if (defined ($tmp) && ( -d $tmp) )
   {
      print "DMT TOOLS are installed in $tmp\n";
   }
   exit 0;
}
else
{
   help();
   exit 1;
}