From facb1eb98f911b3e3811ad9cebaf221931ee9c7a Mon Sep 17 00:00:00 2001 From: danieldg Date: Tue, 1 Sep 2009 15:06:11 +0000 Subject: Replace special treatment of spanningtree module directory with a generic directory build This allows "make M=m_spanningtree" to work on a clean build tree It also allows for other complex modules to be created (i.e. m_services) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11567 e03df62e-2008-0410-955e-edbf42e46eb7 --- make/bsd-dep.mk | 2 +- make/bsd-real.mk | 13 +++++-------- make/calcdep.pl | 37 ++++++++++++++++++++++++++----------- make/gnu-dep.mk | 2 +- make/gnu-real.mk | 12 ++++++------ 5 files changed, 39 insertions(+), 27 deletions(-) (limited to 'make') diff --git a/make/bsd-dep.mk b/make/bsd-dep.mk index 2e816bdb4..b283284d0 100644 --- a/make/bsd-dep.mk +++ b/make/bsd-dep.mk @@ -1,4 +1,4 @@ -DFILES != perl -e 'print join " ", <*.cpp>, , , , ' +DFILES != perl -e 'print join " ", <*.cpp>, , , , ' DFILES += socketengines/$(SOCKETENGINE).cpp threadengines/threadengine_pthread.cpp alldep: diff --git a/make/bsd-real.mk b/make/bsd-real.mk index 12211e7cb..f12efd2b8 100644 --- a/make/bsd-real.mk +++ b/make/bsd-real.mk @@ -1,22 +1,19 @@ CORE_TARGS != perl -e 'print join " ", grep s/\.cpp/.o/, <*.cpp>, ' CMD_TARGS != perl -e 'print join " ", grep s/\.cpp/.so/, ' MOD_TARGS != perl -e 'print join " ", grep s/\.cpp/.so/, ' -SPANNINGTREE_TARGS != perl -e 'print join " ", grep s/\.cpp/.o/, ' +MDIR_TARGS != perl -e 'print join " ", grep s!/?$$!.so!, ' CORE_TARGS += socketengines/$(SOCKETENGINE).o threadengines/threadengine_pthread.o -MOD_TARGS += modules/m_spanningtree.so -DFILES != perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, , , , ' -DFILES += socketengines/.$(SOCKETENGINE).d threadengines/.threadengine_pthread.d +DFILES != perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, , , , ' +DFILES2 != perl -e 'print join " ", grep s!([^/]+)/?$$!.$$1.d!, ' +DFILES += $(DFILES2) socketengines/.$(SOCKETENGINE).d threadengines/.threadengine_pthread.d all: inspircd commands modules commands: $(CMD_TARGS) -modules: $(MOD_TARGS) - -modules/m_spanningtree.so: $(SPANNINGTREE_TARGS) - $(RUNCC) $(FLAGS) -shared -export-dynamic -o $@ $(SPANNINGTREE_TARGS) +modules: $(MOD_TARGS) $(MDIR_TARGS) inspircd: $(CORE_TARGS) $(RUNCC) $(FLAGS) $(CORE_FLAGS) -o inspircd $(LDLIBS) $(CORE_TARGS) diff --git a/make/calcdep.pl b/make/calcdep.pl index 92d2cc3e0..8d85e6463 100755 --- a/make/calcdep.pl +++ b/make/calcdep.pl @@ -32,16 +32,31 @@ sub gendep { } 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"; + if (-e $file && $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"; - 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"; + 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"; + } elsif (-d $file && $file =~ m#^(.*?)([^/]+)/?$#) { + my($path,$base) = ($1,$2); + my $cmd = "$path.$base.d"; + my $out = "$path$base.so"; + opendir DIR, $file; + my $ofiles = join ' ', grep s#(.*)\.cpp$#$path$base/$1.o#, readdir DIR; + closedir DIR; + open OUT, '>', $cmd; + print OUT "$out: $ofiles\n\t".'$(RUNCC) $(FLAGS) $(PICLDFLAGS) -o $@ ' + .$ofiles."\n"; + print OUT "$cmd: $file\n\t".'@../make/calcdep.pl '."$path$base\n"; + } else { + print "Cannot generate depencency for $file\n"; + exit 1; + } } diff --git a/make/gnu-dep.mk b/make/gnu-dep.mk index 5cf0927da..cd5b37078 100644 --- a/make/gnu-dep.mk +++ b/make/gnu-dep.mk @@ -1,4 +1,4 @@ -CFILES = $(shell perl -e 'print join " ", <*.cpp>, , , , ') +CFILES = $(shell perl -e 'print join " ", <*.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 f6d86eb00..28c5afa60 100644 --- a/make/gnu-real.mk +++ b/make/gnu-real.mk @@ -2,14 +2,14 @@ CORE_TARGS = $(patsubst %.cpp,%.o,$(wildcard *.cpp)) MODE_TARGS = $(patsubst %.cpp,%.o,$(wildcard modes/*.cpp)) CMD_TARGS = $(patsubst %.cpp,%.so,$(wildcard commands/*.cpp)) MOD_TARGS = $(patsubst %.cpp,%.so,$(wildcard modules/*.cpp)) -SPANNINGTREE_TARGS = $(patsubst %.cpp,%.o,$(wildcard modules/m_spanningtree/*.cpp)) CORE_TARGS += threadengines/threadengine_pthread.o CORE_TARGS += socketengines/$(SOCKETENGINE).o CORE_TARGS += $(MODE_TARGS) -MOD_TARGS += modules/m_spanningtree.so +MOD_TARGS += $(shell perl -e 'print join " ", grep s!([^/]+)/$$!$$1.so!, ') -DFILES = $(shell perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, , , , ') +DFILES = $(shell perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, , , , ') +DFILES += $(shell perl -e 'print join " ", grep s!([^/]+)/?$$!.$$1.d!, ') DFILES += socketengines/.$(SOCKETENGINE).d threadengines/.threadengine_pthread.d all: inspircd commands modules @@ -18,15 +18,15 @@ commands: $(CMD_TARGS) modules: $(MOD_TARGS) -modules/m_spanningtree.so: $(SPANNINGTREE_TARGS) - $(RUNCC) $(FLAGS) $(PICLDFLAGS) -o $@ $(SPANNINGTREE_TARGS) - inspircd: $(CORE_TARGS) $(RUNCC) $(FLAGS) $(CORE_FLAGS) -o $@ $(LDLIBS) $(CORE_TARGS) .%.d: %.cpp @../make/calcdep.pl $< +.%.d: % + @../make/calcdep.pl $< + .PHONY: all alldep commands modules -include $(DFILES) -- cgit v1.2.3