X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Fcalcdep.pl;h=376d195739caeb3e354fa4fcf3b0972b60332bf9;hb=2803ae5d75e610fb821b7fdb3771777d62ac9fd3;hp=45fdfc03c59d6bcffa5a38806473db7e7e228ab2;hpb=df347edbdbb6d1d0f81795214674da8a4007850a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/calcdep.pl b/make/calcdep.pl index 45fdfc03c..376d19573 100755 --- a/make/calcdep.pl +++ b/make/calcdep.pl @@ -1,4 +1,24 @@ #!/usr/bin/env perl + +# +# InspIRCd -- Internet Relay Chat Daemon +# +# Copyright (C) 2009-2010 Daniel De Graaf +# +# This file is part of InspIRCd. InspIRCd is free software: you can +# redistribute it and/or modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation, version 2. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + use strict; use warnings; use POSIX qw(getcwd); @@ -7,7 +27,7 @@ sub find_output; sub gendep($); sub dep_cpp($$$); sub dep_so($); -sub dep_dir($); +sub dep_dir($$); sub run(); my %f2dep; @@ -19,11 +39,12 @@ sub run() { my $build = $ENV{BUILDPATH}; mkdir $build; chdir $build or die "Could not open build directory: $!"; + unlink 'include'; symlink "$ENV{SOURCEPATH}/include", 'include'; mkdir $_ for qw/bin modules obj/; # BSD make has a horribly annoying bug resulting in an extra chdir of the make process # Create symlinks to work around it - symlink "../$_", "obj/$_" for qw/bin modules obj/; + symlink "../$_", "obj/$_" for qw/bin coremods modules obj/; $build = getcwd(); open MAKE, '>real.mk' or die "Could not write real.mk: $!"; @@ -50,20 +71,28 @@ bad-target: \@echo "in order to set the correct environment variables" \@exit 1 -all: inspircd commands modules +all: inspircd coremods modules END - my(@core_deps, @cmdlist, @modlist); + my(@core_deps, @cmodlist, @modlist); for my $file (<*.cpp>, , , "threadengines/threadengine_pthread.cpp") { my $out = find_output $file; dep_cpp $file, $out, 'gen-o'; - next if $file =~ m#^socketengines/# && $file ne "socketengines/$ENV{SOCKETENGINE}.cpp"; + next if $file =~ m#^socketengines/# && $file ne "socketengines/socketengine_$ENV{SOCKETENGINE}.cpp"; push @core_deps, $out; } - for my $file () { - my $out = dep_so $file; - push @cmdlist, $out; + opendir my $coremoddir, 'coremods'; + for my $file (sort readdir $coremoddir) { + next if $file =~ /^\./; + if ($file =~ /^core_/ && -d "coremods/$file" && dep_dir "coremods/$file", "modules/$file") { + mkdir "$build/obj/$file"; + push @cmodlist, "modules/$file.so"; + } + if ($file =~ /^core_.*\.cpp$/) { + my $out = dep_so "coremods/$file"; + push @cmodlist, $out; + } } opendir my $moddir, 'modules'; @@ -75,7 +104,7 @@ END rename "modules/$file", "modules/$file~"; symlink "extra/$file", "modules/$file"; } - if ($file =~ /^m_/ && -d "modules/$file" && dep_dir "modules/$file") { + if ($file =~ /^m_/ && -d "modules/$file" && dep_dir "modules/$file", "modules/$file") { mkdir "$build/obj/$file"; push @modlist, "modules/$file.so"; } @@ -86,7 +115,7 @@ END } my $core_mk = join ' ', @core_deps; - my $cmds = join ' ', @cmdlist; + my $cmods = join ' ', @cmodlist; my $mods = join ' ', @modlist; print MAKE <, , , , + for my $file (<*.cpp>, , , , , , , "threadengines/threadengine_pthread.cpp") { my $out = find_output $file, 1; if ($out =~ m#obj/([^/]+)/[^/]+.o$#) { mkdir "$ENV{BUILDPATH}/obj/$1"; } dep_cpp $file, $out, 'gen-o'; - next if $file =~ m#^socketengines/# && $file ne "socketengines/$ENV{SOCKETENGINE}.cpp"; + next if $file =~ m#^socketengines/# && $file ne "socketengines/socketengine_$ENV{SOCKETENGINE}.cpp"; push @deps, $out; push @srcs, $file; } @@ -152,11 +181,11 @@ END sub find_output { my($file, $static) = @_; my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp# or die "Bad file $file"; - if ($path eq 'modules/' || $path eq 'commands/') { + if ($path eq 'modules/' || $path eq 'coremods/') { return $static ? "obj/$base.o" : "modules/$base.so"; } elsif ($path eq '' || $path eq 'modes/' || $path =~ /^[a-z]+engines\/$/) { return "obj/$base.o"; - } elsif ($path =~ m#modules/(m_.*)/#) { + } elsif ($path =~ m#modules/(m_.*)/# || $path =~ m#coremods/(core_.*)/#) { return "obj/$1/$base.o"; } else { die "Can't determine output for $file"; @@ -178,7 +207,7 @@ sub gendep($) { while (<$in>) { if (/^\s*#\s*include\s*"([^"]+)"/) { my $inc = $1; - next if $inc eq 'inspircd_version.h' && $f eq '../include/inspircd.h'; + next if $inc eq 'config.h' && $f eq '../include/inspircd.h'; my $found = 0; for my $loc ("$basedir/$inc", "../include/$inc") { next unless -e $loc; @@ -204,26 +233,19 @@ sub dep_cpp($$$) { gendep $file; print MAKE "$out: $file $f2dep{$file}\n"; - print MAKE "\t@\$(SOURCEPATH)/make/unit-cc.pl $type\$(VERBOSE) \$\@ \$< \$>\n"; + print MAKE "\t@\$(SOURCEPATH)/make/unit-cc.pl $type\$(VERBOSE) \$\@ \$(SOURCEPATH)/src/$file \$>\n"; } sub dep_so($) { my($file) = @_; my $out = find_output $file; - my $split = find_output $file, 1; - if ($ENV{SPLIT_CC}) { - dep_cpp $file, $split, 'gen-o'; - print MAKE "$out: $split\n"; - print MAKE "\t@\$(SOURCEPATH)/make/unit-cc.pl link-so\$(VERBOSE) \$\@ \$< \$>\n"; - } else { - dep_cpp $file, $out, 'gen-so'; - } + dep_cpp $file, $out, 'gen-so'; return $out; } -sub dep_dir($) { - my($dir) = @_; +sub dep_dir($$) { + my($dir, $outdir) = @_; my @ofiles; opendir DIR, $dir; for my $file (sort readdir DIR) { @@ -235,7 +257,7 @@ sub dep_dir($) { closedir DIR; if (@ofiles) { my $ofiles = join ' ', @ofiles; - print MAKE "$dir.so: $ofiles\n"; + print MAKE "$outdir.so: $ofiles\n"; print MAKE "\t@\$(SOURCEPATH)/make/unit-cc.pl link-dir\$(VERBOSE) \$\@ \$^ \$>\n"; return 1; } else {