3 # C Cross Referencing & Documentation tool. Version 1.5.
5 # A Perl script to produce a neat output for makefile dependencies.
7 # Written by Andrew M. Bishop
9 # This file Copyright 1999,2003 Andrew M. Bishop
10 # It may be distributed under the GNU Public License, version 2, or
11 # any higher version. See section COPYING of the GNU Public license
12 # for conditions under which this file may be redistributed.
21 # The C pre-processor arguments (-D, -I).
29 # Parse the command line arguments
34 print
"Usage: make_depend filename1.h [filename2.h ...]\n";
35 print
" filename1.c filename2.c\n";
36 print
" [-Ddefine] [-Udefine] [-Iinclude]\n";
45 push
(@cfiles
,$_) if(m
/\.c$
/);
46 push
(@hfiles
,$_) if(m
/\.h$
/);
50 $cpp_args.
=" '".
$_.
"'";
55 die
"Error: no source files specified\n" if($#cfiles==-1);
56 die
"Error: no header files specified\n" if($#hfiles==-1);
62 @cfiles
=sort(@cfiles
);
65 foreach
$cfile (@cfiles
)
67 $longest=length
($cfile) if(length
($cfile)>$longest);
70 foreach
$cfile (@cfiles
)
72 %inc_headers
=&GetFileHeaders
($cfile);
77 printf("%-".
$longest.
"s : %-".
$longest.
"s",$ofile,$cfile);
79 foreach
$hfile (@hfiles
)
81 if($inc_headers{$hfile})
87 print
" ".
" "x
(length
($hfile));
96 # Get the included headers from an existing file.
103 local($depends,$header)=("");
107 open
(IN
,"gcc -MM $file $cpp_args|") || die
"Cannot run 'gcc -MM $file $cpp_args'\n";
116 $depends =~ s
/\\?
\n//g
;
118 foreach
$header (split(/ +/,$depends))