diff options
-rw-r--r-- | .Makefile.inc | 1 | ||||
-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 | ||||
-rw-r--r-- | src/modes/Makefile | 62 |
6 files changed, 52 insertions, 100 deletions
diff --git a/.Makefile.inc b/.Makefile.inc index e8bf232b9..1d816a57b 100644 --- a/.Makefile.inc +++ b/.Makefile.inc @@ -128,6 +128,7 @@ clean: @rm -f src/inspircd src/modes/modeclasses.a @rm -f src/*.so src/modules/*.so src/commands/*.so src/modules/*/*.so @rm -f src/*.o src/*/*.o src/modules/*/*.o + @rm -f src/.*.d src/*/.*.d src/modules/*/.*.d @echo Completed. modclean: 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) diff --git a/src/modes/Makefile b/src/modes/Makefile deleted file mode 100644 index d2f065d8f..000000000 --- a/src/modes/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -CXXFLAGS = ${FLAGS} - -all: - @echo "Don't run make here! Run it in the root directory" - false - -umode_w.o: umode_w.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c umode_w.cpp - -umode_o.o: umode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c umode_o.cpp - -umode_s.o: umode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c umode_s.cpp - -umode_i.o: umode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c umode_i.cpp - -cmode_v.o: cmode_v.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_v.cpp - -cmode_t.o: cmode_t.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_t.cpp - -cmode_s.o: cmode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_s.cpp - -cmode_p.o: cmode_p.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_p.cpp - -cmode_o.o: cmode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_o.cpp - -cmode_n.o: cmode_n.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_n.cpp - -cmode_m.o: cmode_m.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_m.cpp - -cmode_l.o: cmode_l.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_l.cpp - -cmode_k.o: cmode_k.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_k.cpp - -cmode_i.o: cmode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_i.cpp - -cmode_h.o: cmode_h.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_h.cpp - -cmode_b.o: cmode_b.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(RUNCC) $(FLAGS) -export-dynamic -c cmode_b.cpp - -modeclasses.a: umode_w.o umode_o.o umode_s.o umode_i.o cmode_v.o cmode_t.o cmode_s.o cmode_p.o cmode_o.o cmode_n.o cmode_m.o cmode_l.o cmode_k.o cmode_i.o cmode_h.o cmode_b.o - @-rm -rf modeclasses.a - @../../make/run-cc.pl ar crs modeclasses.a *.o - -clean: - @-rm *.o - @-rm modeclasses.a - |