5 # This used to be a wrapper around cc -M; however, this is a very slow
6 # operation and we don't conditionally include our own files often enough
7 # to justify the full preprocesor invocation for all ~200 files.
14 my $basedir = $f =~ m#(.*)/# ? $1 : '.';
15 return $f2dep{$f} if exists $f2dep{$f};
20 if (/^\s*#\s*include\s*"([^"]+)"/) {
22 for my $loc ("$basedir/$inc", "../include/$inc") {
25 $dep{$_}++ for split / /, gendep $loc;
30 $f2dep{$f} = join ' ', sort keys %dep;
34 for my $file (@ARGV) {
35 if (-e $file && $file =~ /cpp$/) {
37 my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp#;
38 my $cmd = "$path.$base.d";
39 my $ext = $path eq 'modules/' || $path eq 'commands/' ? '.so' : '.o';
40 my $out = "$path$base$ext";
43 print OUT "$out: $file $f2dep{$file}\n";
44 print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $out\n";
45 print OUT "$cmd: $file $f2dep{$file}\n";
46 print OUT "\t../make/calcdep.pl $file\n";
47 } elsif (-d $file && $file =~ m#^(.*?)([^/]+)/?$#) {
48 my($path,$base) = ($1,$2);
49 my $cmd = "$path.$base.d";
50 my $out = "$path$base.so";
52 my $ofiles = join ' ', grep s#(.*)\.cpp$#$path$base/$1.o#, readdir DIR;
55 print OUT "$out: $ofiles\n\t".'$(RUNCC) $(PICLDFLAGS) -o $@ '
57 print OUT "$cmd: $file\n\t".'@../make/calcdep.pl '."$path$base\n";
59 print "Cannot generate depencency for $file\n";