home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
gnu
/
emacs-18.59-src.lha
/
src
/
amiga
/
emacs-18.59
/
unix
/
mkmkf.perl
< prev
next >
Wrap
Text File
|
1993-09-29
|
1KB
|
73 lines
print "OBJS= ";
for ($i = $#ARGV; $i >= 0; $i--)
{
($objs[$i] = $ARGV[$i]) =~ s/\.\w*$/\.o/;
}
&colprint(6, " ", @objs);
print "\n\n";
if (-f "smakefile.base")
{
open(BASE, "smakefile.base");
print while (<BASE>);
close(BASE);
}
foreach $file (@ARGV)
{
$dest = $file;
$dest =~ s/\.\w*$/\.o/;
if ($file =~ /\.c$/)
{
printf("%s: %s", $dest, $file);
$colto = length($dest) + length($file) + 2;
# Search for included files
%seen = ();
&included($file, 0);
&colprint($colto, " ", keys(%seen));
print "\n";
}
else
{
printf("%s: %s\n\n", $dest, $file);
}
}
sub colprint
{
local($colto, $sep, @names) = @_;
$col = $colto;
$sl = length($sep);
foreach $name (@names)
{
$nl = length($name);
if ($col + $nl + $sl > 78)
{
print " \\\n", " " x $colto;
$col = $colto;
}
print $sep, $name;
$col += $sl + $nl;
}
}
sub included
{
local($file, $input) = @_;
$input++;
if (!open($input, $file))
{
print STDERR "Can't open $file: $!\n";
return;
}
while (<$input>)
{
if (/^#\s*include\s*"([^"]*)"/ && !$seen{$1} && -e $1)
{
$seen{$1} = 1;
&included($1, $input);
}
}
close($input);
}