11 my $basedir = $f =~ m#(.*)/# ? $1 : '.';
12 return $f2dep{$f} if exists $f2dep{$f};
15 my $link = readlink $f;
17 $link = "$basedir/$link" unless $link =~ m#^/#;
20 open my $in, '<', $f or die "Could not read $f";
22 if (/^\s*#\s*include\s*"([^"]+)"/) {
24 next if $inc eq 'inspircd_version.h' && $f eq '../include/inspircd.h';
26 for my $loc ("$basedir/$inc", "../include/$inc") {
30 $dep{$_}++ for split / /, gendep $loc;
32 if ($found == 0 && $inc ne 'inspircd_win32wrapper.h') {
33 print STDERR "WARNING: could not find header $inc for $f\n";
34 } elsif ($found > 1 && $basedir ne '../include') {
35 print STDERR "WARNING: ambiguous include $inc in $f\n";
40 $f2dep{$f} = join ' ', sort keys %dep;
47 my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp# or die "Bad file $file";
48 my $cmd = "$path.$base.d";
49 my $ext = $path eq 'modules/' || $path eq 'commands/' ? '.so' : '.o';
50 my $out = "$path$base$ext";
53 print OUT "$out: $file $f2dep{$file}\n";
54 print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $out\n";
55 print OUT "$cmd: $file $f2dep{$file}\n";
56 print OUT "\t../make/calcdep.pl -file $file\n";
61 if ($dir =~ m#^(.*?)([^/]+)/?$#) {
62 my($path,$base) = ($1,$2);
63 my $cmd = "$path.$base.d";
64 my $out = "$path$base.so";
66 my $ofiles = join ' ', grep s/(.*)\.cpp$/$path$base\/$1.o/, readdir DIR;
69 print OUT "$out: $ofiles\n\t".'$(RUNCC) $(PICLDFLAGS) -o $@ '
71 print OUT "$cmd: $dir\n\t".'@../make/calcdep.pl -file '."$path$base\n";
73 print STDERR "Cannot generate depencency for $dir\n";
78 my($all,$quiet, $file);
85 if (!$all && !defined $file) {
86 print "Use: $0 {-all|-file filename} [-quiet]\n";
96 print STDERR "Can't generate dependencies for $file\n";
100 my @files = (<*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_*/*.cpp>);
101 push @files, "socketengines/$ENV{SOCKETENGINE}.cpp", "threadengines/threadengine_pthread.cpp";
102 for my $file (@files) {
106 my @dirs = grep -d, <modules/m_*>;
107 for my $dir (@dirs) {
111 s#([^/]+)\.cpp#.$1.d# for @files;
112 s#([^/]+)/?$#.$1.d# for @dirs;
113 print join ' ', @files, @dirs;