]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/calcdep.pl
Remove various broken/useless features from the build system.
[user/henk/code/inspircd.git] / make / calcdep.pl
index 45fdfc03c59d6bcffa5a38806473db7e7e228ab2..376d195739caeb3e354fa4fcf3b0972b60332bf9 100755 (executable)
@@ -1,4 +1,24 @@
 #!/usr/bin/env perl
+
+#
+# InspIRCd -- Internet Relay Chat Daemon
+#
+#   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+
+
 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>, <modes/*.cpp>, <socketengines/*.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 (<commands/*.cpp>) {
-               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 <<END;
 
@@ -95,11 +124,11 @@ bin/inspircd: $core_mk
 
 inspircd: bin/inspircd
 
-commands: $cmds
+coremods: $cmods
 
 modules: $mods
 
-.PHONY: all bad-target inspircd commands modules
+.PHONY: all bad-target inspircd coremods modules
 
 END
 }
@@ -120,14 +149,14 @@ all: inspircd
 
 END
        my(@deps, @srcs);
-       for my $file (<*.cpp>, <modes/*.cpp>, <socketengines/*.cpp>, <commands/*.cpp>,
+       for my $file (<*.cpp>, <modes/*.cpp>, <socketengines/*.cpp>, <coremods/*.cpp>, <coremods/core_*/*.cpp>,
                        <modules/*.cpp>, <modules/m_*/*.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 {