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*"([^"]+)"/) {
19 next if $inc eq 'inspircd_version.h' && $f eq '../include/inspircd.h';
21 for my $loc ("$basedir/$inc", "../include/$inc") {
25 $dep{$_}++ for split / /, gendep $loc;
27 if ($found == 0 && $inc ne 'inspircd_win32wrapper.h') {
28 print STDERR "WARNING: could not find header $inc for $f\n";
29 } elsif ($found > 1 && $basedir ne '../include') {
30 print STDERR "WARNING: ambiguous include $inc in $f\n";
35 $f2dep{$f} = join ' ', sort keys %dep;
42 my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp# or die "Bad file $file";
43 my $cmd = "$path.$base.d";
44 my $ext = $path eq 'modules/' || $path eq 'commands/' ? '.so' : '.o';
45 my $out = "$path$base$ext";
48 print OUT "$out: $file $f2dep{$file}\n";
49 print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $out\n";
50 print OUT "$cmd: $file $f2dep{$file}\n";
51 print OUT "\t../make/calcdep.pl -file $file\n";
56 if ($dir =~ m#^(.*?)([^/]+)/?$#) {
57 my($path,$base) = ($1,$2);
58 my $cmd = "$path.$base.d";
59 my $out = "$path$base.so";
61 my $ofiles = join ' ', grep s/(.*)\.cpp$/$path$base\/$1.o/, readdir DIR;
64 print OUT "$out: $ofiles\n\t".'$(RUNCC) $(PICLDFLAGS) -o $@ '
66 print OUT "$cmd: $dir\n\t".'@../make/calcdep.pl -file '."$path$base\n";
68 print STDERR "Cannot generate depencency for $dir\n";
73 my($all,$quiet, $file);
80 if (!$all && !defined $file) {
81 print "Use: $0 {-all|-file filename} [-quiet]\n";
91 print STDERR "Can't generate dependencies for $file\n";
95 my @files = (<*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_*/*.cpp>);
96 push @files, "socketengines/$ENV{SOCKETENGINE}.cpp", "threadengines/threadengine_pthread.cpp";
97 for my $file (@files) {
101 my @dirs = grep -d, <modules/m_*>;
102 for my $dir (@dirs) {
106 s#([^/]+)\.cpp#.$1.d# for @files;
107 s#([^/]+)/?$#.$1.d# for @dirs;
108 print join ' ', @files, @dirs;