#!/usr/bin/perl

%ALL = ();

if (0)
{
  open(INF, "Makefile") || die("Cannot read Makefile");
  while(<INF>)
  {
    chomp;
    if (s#^GCJOBJS\s*\+\=\s*lib/##s)
    {
      $ALL{$_} = 1;
    }
  }
  close(INF);
}


open(INF, $ARGV[0]) || die("Cannot read $ARGV[0]");
while(<INF>)
{
  chomp;
  if (m#/libgcj.a\(([^\)]+)\)#s)
  {
    $_ = $1;
    if (!defined($ALL{$_}))
    {
      $ALL{$_} = 1;
      #print "$_\n";
      print "GCJOBJS += lib/$_\n";
    }
  }
}
close(INF);
