From 050c2cf253e27847f50eec29c5502904b112437b Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 5 Mar 2014 16:28:29 +0100 Subject: Integrate coremods into the build system --- make/calcdep.pl | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'make/calcdep.pl') diff --git a/make/calcdep.pl b/make/calcdep.pl index 26be367f5..b0c6941b7 100755 --- a/make/calcdep.pl +++ b/make/calcdep.pl @@ -27,7 +27,7 @@ sub find_output; sub gendep($); sub dep_cpp($$$); sub dep_so($); -sub dep_dir($); +sub dep_dir($$); sub run(); my %f2dep; @@ -44,7 +44,7 @@ sub run() { 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: $!"; @@ -71,10 +71,10 @@ 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'; @@ -82,9 +82,17 @@ END 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'; @@ -96,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"; } @@ -107,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$#) { @@ -173,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"; @@ -243,8 +251,8 @@ sub dep_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) { @@ -256,7 +264,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 { -- cgit v1.2.3