diff options
Diffstat (limited to 'make')
-rw-r--r-- | make/bsd-dep.mk | 13 | ||||
-rwxr-xr-x | make/calcdep.pl | 58 | ||||
-rw-r--r-- | make/gnu-dep.mk | 7 | ||||
-rw-r--r-- | make/gnu-real.mk | 11 |
4 files changed, 51 insertions, 38 deletions
diff --git a/make/bsd-dep.mk b/make/bsd-dep.mk index 4d2f8e1dc..2e816bdb4 100644 --- a/make/bsd-dep.mk +++ b/make/bsd-dep.mk @@ -1,10 +1,5 @@ -DFILES != perl -e 'print join " ", grep s/\.cpp/.d/, <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>' -DFILES += socketengines/$(SOCKETENGINE).d threadengines/threadengine_pthread.d +DFILES != perl -e 'print join " ", <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>' +DFILES += socketengines/$(SOCKETENGINE).cpp threadengines/threadengine_pthread.cpp -alldep: $(DFILES) - -.SUFFIXES: .d .cpp - -.cpp.d: - @../make/calcdep.pl $< - @echo -n . +alldep: + ../make/calcdep.pl $(DFILES) diff --git a/make/calcdep.pl b/make/calcdep.pl index bcbb7cbd0..92d2cc3e0 100755 --- a/make/calcdep.pl +++ b/make/calcdep.pl @@ -1,25 +1,47 @@ #!/usr/bin/perl use strict; -BEGIN { push @INC, '..'; } -use make::configure; +use warnings; -my $file = shift; +# This used to be a wrapper around cc -M; however, this is a very slow +# operation and we don't conditionally include our own files often enough +# to justify the full preprocesor invocation for all ~200 files. -$file =~ /(.*)\.cpp$/ or die "Cannot process $file"; -my $base = $1; +my %f2dep; -my $out = "$base.d"; +sub gendep; +sub gendep { + my $f = shift; + my $basedir = $f =~ m#(.*)/# ? $1 : '.'; + return $f2dep{$f} if exists $f2dep{$f}; + $f2dep{$f} = ''; + my %dep; + open my $in, '<', $f; + while (<$in>) { + if (/^\s*#\s*include\s*"([^"]+)"/) { + my $inc = $1; + for my $loc ("$basedir/$inc", "../include/$inc") { + next unless -e $loc; + $dep{$loc}++; + $dep{$_}++ for split / /, gendep $loc; + } + } + } + close $in; + $f2dep{$f} = join ' ', sort keys %dep; + $f2dep{$f}; +} -open IN, '<', $file or die "Could not read $file: $!"; -open OUT, '>', $out or die "Could not write $out: $!"; +for my $file (@ARGV) { + next unless $file =~ /cpp$/; + gendep $file; + my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp#; + my $cmd = "$path.$base.d"; + my $ext = $path eq 'modules/' || $path eq 'commands/' ? '.so' : '.o'; + my $out = "$path$base$ext"; -my $cc_deps = qx($ENV{CC} $ENV{FLAGS} -MM $file); -$cc_deps =~ s/.*?:\s*//; - -my $ext = $file =~ m#(modules|commands)/[^/]+$# ? '.so' : '.o'; -print OUT "$base$ext: $cc_deps"; -print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $base$ext\n"; -print OUT "$base.d: $cc_deps"; -print OUT "\t\@\$(VDEP_IN)\n"; -print OUT "\t../make/calcdep.pl $file\n"; -print OUT "\t\@\$(VDEP_OUT)\n"; + open OUT, '>', $cmd; + print OUT "$out: $file $f2dep{$file}\n"; + print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $out\n"; + print OUT "$cmd: $file $f2dep{$file}\n"; + print OUT "\t../make/calcdep.pl $file\n"; +} diff --git a/make/gnu-dep.mk b/make/gnu-dep.mk index f0ebb4d59..5cf0927da 100644 --- a/make/gnu-dep.mk +++ b/make/gnu-dep.mk @@ -1,3 +1,4 @@ -VDEP_OUT = echo -n . - -include ../make/gnu-real.mk +CFILES = $(shell perl -e 'print join " ", <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>') +CFILES += socketengines/$(SOCKETENGINE).cpp threadengines/threadengine_pthread.cpp +alldep: + @../make/calcdep.pl $(CFILES) diff --git a/make/gnu-real.mk b/make/gnu-real.mk index c868aa933..e0a8af68f 100644 --- a/make/gnu-real.mk +++ b/make/gnu-real.mk @@ -8,15 +8,10 @@ CORE_TARGS += modeclasses.a threadengines/threadengine_pthread.o CORE_TARGS += socketengines/$(SOCKETENGINE).o MOD_TARGS += modules/m_spanningtree.so -DFILES = $(patsubst %.cpp,%.d,$(wildcard *.cpp)) -DFILES += $(patsubst %.cpp,%.d,$(wildcard commands/*.cpp)) -DFILES += $(patsubst %.cpp,%.d,$(wildcard modes/*.cpp)) -DFILES += $(patsubst %.cpp,%.d,$(wildcard modules/*.cpp)) -DFILES += $(patsubst %.cpp,%.d,$(wildcard modules/m_spanningtree/*.cpp)) -DFILES += socketengines/$(SOCKETENGINE).d threadengines/threadengine_pthread.d +DFILES = $(shell perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>') +DFILES += socketengines/.$(SOCKETENGINE).d threadengines/.threadengine_pthread.d all: inspircd commands modules -alldep: $(DFILES) commands: $(CMD_TARGS) @@ -31,7 +26,7 @@ modules/m_spanningtree.so: $(SPANNINGTREE_TARGS) inspircd: $(CORE_TARGS) $(RUNCC) $(FLAGS) $(CORE_FLAGS) -o inspircd $(LDLIBS) $(CORE_TARGS) -%.d: %.cpp +.%.d: %.cpp @$(VDEP_IN) @../make/calcdep.pl $< @$(VDEP_OUT) |