diff options
-rw-r--r-- | .Makefile.inc | 4 | ||||
-rw-r--r-- | make/bsd-dep.mk | 2 | ||||
-rw-r--r-- | make/bsd-real.mk | 13 | ||||
-rwxr-xr-x | make/calcdep.pl | 37 | ||||
-rw-r--r-- | make/gnu-dep.mk | 2 | ||||
-rw-r--r-- | make/gnu-real.mk | 12 |
6 files changed, 41 insertions, 29 deletions
diff --git a/.Makefile.inc b/.Makefile.inc index 00cb9c2ec..99cf6f6e2 100644 --- a/.Makefile.inc +++ b/.Makefile.inc @@ -90,8 +90,8 @@ allreal: $(HEADER) alldep @$(MAKEENV) $(MAKE) -C src -f ../make/$(MAKESTYLE)-real.mk all module: - @cd src; ../make/calcdep.pl modules/$(MODNAME).cpp - @$(MAKEENV) $(MAKE) -C src -f modules/.$(MODNAME).d modules/$(MODNAME).so + cd src; if [ -d modules/$(MODNAME) ]; then ../make/calcdep.pl modules/$(MODNAME) modules/$(MODNAME)/*.cpp; else ../make/calcdep.pl modules/$(MODNAME).cpp; fi + $(MAKEENV) $(MAKE) -C src -f ../make/$(MAKESTYLE)-real.mk modules/$(MODNAME).so debug: @${MAKE} D=1 all 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>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>' +DFILES != perl -e 'print join " ", <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_*/*.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>, <modes/*.cpp>' CMD_TARGS != perl -e 'print join " ", grep s/\.cpp/.so/, <commands/*.cpp>' MOD_TARGS != perl -e 'print join " ", grep s/\.cpp/.so/, <modules/*.cpp>' -SPANNINGTREE_TARGS != perl -e 'print join " ", grep s/\.cpp/.o/, <modules/m_spanningtree/*.cpp>' +MDIR_TARGS != perl -e 'print join " ", grep s!/?$$!.so!, <modules/m_*/>' 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>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>' -DFILES += socketengines/.$(SOCKETENGINE).d threadengines/.threadengine_pthread.d +DFILES != perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_*/*.cpp>' +DFILES2 != perl -e 'print join " ", grep s!([^/]+)/?$$!.$$1.d!, <modules/m_*/>' +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>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>') +CFILES = $(shell perl -e 'print join " ", <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_*/*.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!, <modules/m_*/>') -DFILES = $(shell perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>') +DFILES = $(shell perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_*/*.cpp>') +DFILES += $(shell perl -e 'print join " ", grep s!([^/]+)/?$$!.$$1.d!, <modules/m_*/>') 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) |