#!/usr/bin/perl -w

use strict;

my $obj = shift;
my $src = shift;
my $inc = shift;

my @srcd = ();
my @incd = ();
print("# Automatically generated by processdeps.pl\n");
while (<>) {
	if (/^(\S+?)\.o:/) {
		print( map " \$($src)$_", @srcd );
		print( map " \$($inc)$_", @incd );
		print("\n\$($obj)/$1\.\$o\E:");
		@srcd = ();
		@incd = ();
	}
	push @srcd, /$src(\/\S+)/og;
	push @incd, /$inc(\/\S+)/og;
}
print( map " \$($src)$_", @srcd );
print( map " \$($inc)$_", @incd );
print("\n");
