From 3a186342c975a8bbd3f588d180a55e381b31883c Mon Sep 17 00:00:00 2001 From: danieldg Date: Thu, 17 Sep 2009 03:04:27 +0000 Subject: Remove .*.d dependency garbage, and use a dedicated build directory git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11738 e03df62e-2008-0410-955e-edbf42e46eb7 --- make/bsd-real.mk | 22 ------- make/calcdep.pl | 178 +++++++++++++++++++++++++++++++------------------------ make/gnu-real.mk | 23 ------- 3 files changed, 102 insertions(+), 121 deletions(-) delete mode 100644 make/bsd-real.mk delete mode 100644 make/gnu-real.mk (limited to 'make') diff --git a/make/bsd-real.mk b/make/bsd-real.mk deleted file mode 100644 index 13cb2cce8..000000000 --- a/make/bsd-real.mk +++ /dev/null @@ -1,22 +0,0 @@ -VPATH = $(SOURCEPATH)/src -CORE_TARGS != perl -e 'chdir "$$ENV{SOURCEPATH}/src"; print join " ", grep s/\.cpp/.o/, <*.cpp>, ' -CMD_TARGS != perl -e 'chdir "$$ENV{SOURCEPATH}/src"; print join " ", grep s/\.cpp/.so/, ' -MOD_TARGS != perl -e 'chdir "$$ENV{SOURCEPATH}/src"; print join " ", grep s/\.cpp/.so/, ' -MDIR_TARGS != perl -e 'chdir "$$ENV{SOURCEPATH}/src"; print join " ", grep s!/?$$!.so!, grep -d, ' - -CORE_TARGS += socketengines/$(SOCKETENGINE).o threadengines/threadengine_pthread.o - -DFILES != perl $(SOURCEPATH)/make/calcdep.pl -all - -all: inspircd commands modules - -commands: $(CMD_TARGS) - -modules: $(MOD_TARGS) $(MDIR_TARGS) - -inspircd: $(CORE_TARGS) - $(RUNCC) -o $@ $(CORELDFLAGS) $(LDLIBS) $^ - -.for FILE in $(DFILES) -.include "$(FILE)" -.endfor diff --git a/make/calcdep.pl b/make/calcdep.pl index 261b6ec18..1a65f836b 100755 --- a/make/calcdep.pl +++ b/make/calcdep.pl @@ -3,16 +3,90 @@ use strict; use warnings; use Getopt::Long; -my $basesrc = "$ENV{SOURCEPATH}/src"; -my $baseinc = "$ENV{SOURCEPATH}/include"; -my $baseout = `pwd`; -chomp $baseout; -chdir $basesrc; +sub find_output($); +sub gendep($); +sub dep_cpp($$); +sub dep_dir($); +sub run(); my %f2dep; -sub gendep; -sub gendep { +run; +exit 0; + +sub run() { + my $build = $ENV{BUILDPATH}; + mkdir $build; + chdir $build or die "Could not open build directory: $!"; + mkdir 'bin'; + mkdir 'obj'; + mkdir 'modules'; + symlink "$ENV{SOURCEPATH}/include", 'include'; + $build = `pwd`; + chomp $build; + open MAKE, '>real.mk' or die "Could not write real.mk: $!"; + chdir "$ENV{SOURCEPATH}/src"; + + print MAKE <, , "socketengines/$ENV{SOCKETENGINE}.cpp", "threadengines/threadengine_pthread.cpp") { + my $out = find_output $file; + dep_cpp $file, $out; + push @core_deps, $out; + } + + my @modlist; + for my $file (, ) { + my $out = find_output $file; + dep_cpp $file, $out; + push @modlist, $out; + } + + opendir my $moddir, 'modules'; + for my $dir (readdir $moddir) { + next unless $dir =~ /^m_/ && -d "modules/$dir"; + mkdir "$build/obj/$dir"; + dep_dir "modules/$dir"; + push @modlist, "modules/$dir.so"; + } + + my $core_mk = join ' ', @core_deps; + my $mods = join ' ', @modlist; + print MAKE <) { if (/^\s*#\s*include\s*"([^"]+)"/) { my $inc = $1; - next if $inc eq 'inspircd_version.h' && $f eq $baseinc.'/inspircd.h'; + next if $inc eq 'inspircd_version.h' && $f eq '../include/inspircd.h'; my $found = 0; - for my $loc ("$basedir/$inc", "$baseinc/$inc") { + for my $loc ("$basedir/$inc", "../include/$inc") { next unless -e $loc; $found++; - $dep{$loc}++; $dep{$_}++ for split / /, gendep $loc; + $loc =~ s#^\.\./##; + $dep{$loc}++; } if ($found == 0 && $inc ne 'inspircd_win32wrapper.h') { print STDERR "WARNING: could not find header $inc for $f\n"; - } elsif ($found > 1 && $basedir ne $baseinc) { + } elsif ($found > 1 && $basedir ne '../include') { print STDERR "WARNING: ambiguous include $inc in $f\n"; } } @@ -47,75 +122,26 @@ sub gendep { $f2dep{$f}; } -sub dep_cpp { - my($file, $dfile) = @_; +sub dep_cpp($$) { + my($file, $out) = @_; gendep $file; - my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp# or die "Bad file $file"; - my $ext = $path eq 'modules/' || $path eq 'commands/' ? '.so' : '.o'; - my $out = "$path$base$ext"; - $dfile = "$baseout/$path.$base.d" unless defined $dfile; - open OUT, '>', "$dfile" or die "Could not write $dfile: $!"; - print OUT "$out: $file $f2dep{$file}\n"; - print OUT "\t@\$(SOURCEPATH)/make/unit-cc.pl \$(VERBOSE) \$< $out\n"; + print MAKE "$out: $file $f2dep{$file}\n"; + print MAKE "\t@\$(SOURCEPATH)/make/unit-cc.pl \$(VERBOSE) \$< \$\@\n"; } -sub dep_dir { - my($dir, $dfile) = @_; - if ($dir =~ m#^(.*?)([^/]+)/?$#) { - my($path,$base) = ($1,$2); - my $out = "$path$base.so"; - $dfile = "$baseout/$path.$base.d" unless defined $dfile; - opendir DIR, "$basesrc/$dir"; - my $ofiles = join ' ', grep s/(.*)\.cpp$/$path$base\/$1.o/, readdir DIR; - closedir DIR; - open OUT, '>', "$dfile" or die "Could not write $dfile: $!"; - print OUT "$out: $ofiles\n\t\$(RUNCC) \$(PICLDFLAGS) -o \$\@ \$^\n"; - close OUT; - } else { - print STDERR "Cannot generate depencency for $dir\n"; - exit 1; +sub dep_dir($) { + my($dir) = @_; + my @ofiles; + opendir DIR, $dir; + for my $file (readdir DIR) { + next unless $file =~ /(.*)\.cpp$/; + my $ofile = find_output "$dir/$file"; + dep_cpp "$dir/$file", $ofile; + push @ofiles, $ofile; } + closedir DIR; + my $ofiles = join ' ', @ofiles; + print MAKE "$dir.so: $ofiles\n\t\$(RUNCC) \$(PICLDFLAGS) -o \$\@ \$^\n"; } -my($all,$quiet, $file); -GetOptions( - 'all' => \$all, - 'quiet' => \$quiet, - 'file=s' => \$file, -); - -if (!$all && !defined $file) { - print "Use: $0 {-all|-file src dest} [-quiet]\n"; - exit 1; -} - -if (defined $file) { - my $dfile = shift or die "Syntax: -file "; - $dfile = "$baseout/$dfile" unless $dfile =~ m#^/#; - if (-f $file) { - dep_cpp $file, $dfile; - } elsif (-d $file) { - dep_dir $file, $dfile; - } else { - print STDERR "Can't generate dependencies for $file\n"; - exit 1; - } -} else { - my @files = (<*.cpp>, , , , ); - push @files, "socketengines/$ENV{SOCKETENGINE}.cpp", "threadengines/threadengine_pthread.cpp"; - my @dirs = grep -d, ; - mkdir "$baseout/$_" for qw(commands modes modules socketengines threadengines), @dirs; - - for my $file (@files) { - dep_cpp $file; - } - - for my $dir (@dirs) { - dep_dir $dir; - } - - s#([^/]+)\.cpp#.$1.d# for @files; - s#([^/]+)/?$#.$1.d# for @dirs; - print join ' ', @files, @dirs; -} diff --git a/make/gnu-real.mk b/make/gnu-real.mk deleted file mode 100644 index 338a5112d..000000000 --- a/make/gnu-real.mk +++ /dev/null @@ -1,23 +0,0 @@ -SRC = $(SOURCEPATH)/src -VPATH = $(SRC) -CORE_TARGS = $(patsubst $(SRC)/%.cpp,%.o,$(wildcard $(SRC)/*.cpp $(SRC)/modes/*.cpp)) -CMD_TARGS = $(patsubst $(SRC)/%.cpp,%.so,$(wildcard $(SRC)/commands/*.cpp)) -MOD_TARGS = $(patsubst $(SRC)/%.cpp,%.so,$(wildcard $(SRC)/modules/*.cpp)) - -CORE_TARGS += socketengines/$(SOCKETENGINE).o threadengines/threadengine_pthread.o -MOD_TARGS += $(shell perl -e 'chdir "$$ENV{SOURCEPATH}/src"; print join " ", grep s!/?$$!.so!, grep -d, ') - -DFILES = $(shell perl $(SOURCEPATH)/make/calcdep.pl -all) - -all: inspircd commands modules - -commands: $(CMD_TARGS) - -modules: $(MOD_TARGS) - -inspircd: $(CORE_TARGS) - $(RUNCC) -o $@ $(CORELDFLAGS) $(LDLIBS) $^ - -.PHONY: all alldep commands modules - --include $(DFILES) -- cgit v1.2.3