#! /usr/bin/perl -w

# quick hack by Joerg Arndt (arndt (AT) jjj.de)
# version: 2000-October-22 (11h57)

#
# usage: fixdepend.pl 'obj-list-with-paths' < depend.mk > depend.fixed
# (followed by: mv depend.fixed depend.mk)
#

$objlst = $ARGV[0];

@objn= split(/ /,$objlst);
$n = scalar @objn;

foreach $t (@objn)
{
    if ( $n<=0 )  { goto therest; }
    $n--;

    @z = split( /\//, $t );
    $file = $z[-1];
    $qfile = quotemeta($file);

    while ( <STDIN> )
    {
        $line = $_;
        if ( $line =~ /($qfile:) *(.*)$/ )
        {
            print "$t: $2\n";
            goto endloop;
        }
        print;
    }

  die 'AARGH, cannot read STDIN';

  endloop: ;
}

therest:
while ( <STDIN> )  { print; }

exit 0;

##########################
##########################
