2000-01-10 06:22:05 +00:00
|
|
|
#!/usr/local/bin/perl -w
|
|
|
|
# Clean the dependency list in a makefile of standard includes...
|
|
|
|
# Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
while(<STDIN>) {
|
|
|
|
print;
|
|
|
|
last if /^# DO NOT DELETE THIS LINE/;
|
|
|
|
}
|
|
|
|
|
|
|
|
my %files;
|
|
|
|
|
2003-01-28 21:43:22 +00:00
|
|
|
my $thisfile="";
|
2000-01-10 06:22:05 +00:00
|
|
|
while(<STDIN>) {
|
2003-01-28 21:43:22 +00:00
|
|
|
my ($dummy, $file,$deps)=/^((.*):)? (.*)$/;
|
|
|
|
my $origfile="";
|
|
|
|
$thisfile=$file if defined $file;
|
2000-01-10 06:22:05 +00:00
|
|
|
next if !defined $deps;
|
2003-01-28 21:43:22 +00:00
|
|
|
$origfile=$thisfile;
|
|
|
|
$origfile=~s/\.o$/.c/;
|
2000-01-10 06:22:05 +00:00
|
|
|
my @deps=split ' ',$deps;
|
2001-05-20 03:07:21 +00:00
|
|
|
@deps=grep(!/^\//,@deps);
|
|
|
|
@deps=grep(!/^\\$/,@deps);
|
2003-01-28 21:43:22 +00:00
|
|
|
@deps=grep(!/^$origfile$/,@deps);
|
|
|
|
# pull out the kludged kerberos header (if present).
|
|
|
|
@deps=grep(!/^[.\/]+\/krb5.h/,@deps);
|
|
|
|
push @{$files{$thisfile}},@deps;
|
2000-01-10 06:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
my $file;
|
|
|
|
foreach $file (sort keys %files) {
|
|
|
|
my $len=0;
|
|
|
|
my $dep;
|
2003-01-28 21:43:22 +00:00
|
|
|
my $origfile=$file;
|
|
|
|
$origfile=~s/\.o$/.c/;
|
|
|
|
$file=~s/^\.\///;
|
|
|
|
push @{$files{$file}},$origfile;
|
|
|
|
my $prevdep="";
|
2000-01-10 06:22:05 +00:00
|
|
|
foreach $dep (sort @{$files{$file}}) {
|
2003-01-28 21:43:22 +00:00
|
|
|
$dep=~s/^\.\///;
|
|
|
|
next if $prevdep eq $dep; # to exterminate duplicates...
|
|
|
|
$prevdep = $dep;
|
2000-01-10 06:22:05 +00:00
|
|
|
$len=0 if $len+length($dep)+1 >= 80;
|
|
|
|
if($len == 0) {
|
|
|
|
print "\n$file:";
|
|
|
|
$len=length($file)+1;
|
|
|
|
}
|
|
|
|
print " $dep";
|
|
|
|
$len+=length($dep)+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\n";
|