#!/store/bin/perl5 -w
#
# Author: Petter Reinholdtsen <pere@td.org.uit.no>
# Date:   1999-08-15
#
# Show which depending application is missing to link up the wanted app.

$treeinfo = "/store/etc/linktree.info";

open(INFO, "< $treeinfo") || die "Unable to open $treeinfo";
while (<INFO>) {
  next if /^#/;
  chomp;

  my ($appname, $mode, $rest) = m/^(\S+) (\S+) ?(.*)$/;
  $appmode{$appname} = $mode;
  $appdep{$appname} = "$rest" if ("dependson" eq $mode);
}
close(INFO);

for $app (@ARGV) {
  print "\n";
  print_app_info($app);
}

sub print_app_info {
  my $app = shift;
  if (exists $appmode{$app}) {
    if (exists $appdep{$app}) {
      foreach $dep (split(/ /, $appdep{$app})) {
	print_app_info($dep);
      }
      print "$app $appmode{$app} $appdep{$app}\n";
    } else {
      print "$app $appmode{$app}\n";
    }
  } else {
    print "$app unknown\n";
  }
}

