flanner@prls.UUCP (Philip D. Flanner III) (03/06/89)
Someone recently asked for a program to generate make dependencies for
fortran. Here's what I use -- it handles c or fortran.
There are two files, one is a csh script (`mkdep') and one an awk script
(`mkdep.awk'). Invoke mkdep like so:
% mkdep *.f
and a dependency list appears on stdout.
Notes: You need to change the awk script file name in mkdep.
You can substitute `fgrep' for `match'.
mkdep
------------------------------------------
#!/bin/csh
#
#--- Make include dependencies
#
if ($#argv == 0) exit(0)
if ($1:e == f) then
match ' include' $argv | sed -e "s/include[ ]*'//;s/'//;s/f:/o:/" |\
sort -u +0 -1 +1 -2 | awk -f /b/flanner/Bin/mkdep.awk
else
match '#include' $argv | sed -e 's/#include[ ]*"//;s/"//;s/c:/o:/' \
-e '/</d' | sort -u +0 -1 +1 -2 | awk -f /b/flanner/Bin/mkdep.awk
endif
------------------------------------------
mkdep.awk
------------------------------------------
BEGIN {
source = "none";
includ = "none";
line = "#\n#---\tInclude file dependencies\n#";
}
{
if (source != $1)
{
source = $1;
print line;
if (length($1) < 8)
line = $1 "\t\t" $2
else
line = $1 "\t" $2;
}
else
line = line " " $2;
}
END {
print line;
}
------------------------------------------
Phil Flanner --- ...!pyramid!prls!flanner or ...!philabs!prls!flanner