11 my $basedir = $f =~ m#(.*)/# ? $1 : '.';
12 return $f2dep{$f} if exists $f2dep{$f};
15 open my $in, '<', $f or die "Could not read $f";
17 if (/^\s*#\s*include\s*"([^"]+)"/) {
20 for my $loc ("$basedir/$inc", "../include/$inc") {
24 $dep{$_}++ for split / /, gendep $loc;
26 if ($found == 0 && $inc ne 'inspircd_win32wrapper.h') {
27 print STDERR "WARNING: could not find header $inc for $f\n";
28 } elsif ($found > 1 && $basedir ne '../include') {
29 print STDERR "WARNING: ambiguous include $inc in $f\n";
34 $f2dep{$f} = join ' ', sort keys %dep;
41 my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp# or die "Bad file $file";
42 my $cmd = "$path.$base.d";
43 my $ext = $path eq 'modules/' || $path eq 'commands/' ? '.so' : '.o';
44 my $out = "$path$base$ext";
47 print OUT "$out: $file $f2dep{$file}\n";
48 print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $out\n";
49 print OUT "$cmd: $file $f2dep{$file}\n";
50 print OUT "\t../make/calcdep.pl -file $file\n";
55 if ($dir =~ m#^(.*?)([^/]+)/?$#) {
56 my($path,$base) = ($1,$2);
57 my $cmd = "$path.$base.d";
58 my $out = "$path$base.so";
60 my $ofiles = join ' ', grep s/(.*)\.cpp$/$path$base\/$1.o/, readdir DIR;
63 print OUT "$out: $ofiles\n\t".'$(RUNCC) $(PICLDFLAGS) -o $@ '
65 print OUT "$cmd: $dir\n\t".'@../make/calcdep.pl -file '."$path$base\n";
67 print STDERR "Cannot generate depencency for $dir\n";
72 my($all,$quiet, $file);
79 if (!$all && !defined $file) {
80 print "Use: $0 {-all|-file filename} [-quiet]\n";
90 print STDERR "Can't generate dependencies for $file\n";
94 my @files = (<*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_*/*.cpp>);
95 push @files, "socketengines/$ENV{SOCKETENGINE}.cpp", "threadengines/threadengine_pthread.cpp";
96 for my $file (@files) {
100 my @dirs = grep -d, <modules/m_*>;
101 for my $dir (@dirs) {
105 s#([^/]+)\.cpp#.$1.d# for @files;
106 s#([^/]+)/?$#.$1.d# for @dirs;
107 print join ' ', @files, @dirs;