18 my $build = $ENV{BUILDPATH};
20 chdir $build or die "Could not open build directory: $!";
24 symlink "$ENV{SOURCEPATH}/include", 'include';
26 open MAKE, '>real.mk' or die "Could not write real.mk: $!";
27 chdir "$ENV{SOURCEPATH}/src";
31 # Autogenerated by calcdep
32 VPATH = \$(SOURCEPATH)/src
34 all: bin/inspircd modules
38 for my $file (<*.cpp>, <modes/*.cpp>, "socketengines/$ENV{SOCKETENGINE}.cpp", "threadengines/threadengine_pthread.cpp") {
39 my $out = find_output $file;
41 push @core_deps, $out;
45 for my $file (<commands/*.cpp>) {
46 my $out = find_output $file;
51 opendir my $moddir, 'modules';
52 for my $file (readdir $moddir) {
53 next if $file =~ /^\./;
54 if (-e "modules/extra/$file" && !-l "modules/$file") {
56 print "Replacing symlink for $file found in modules/extra\n";
57 rename "modules/$file", "modules/$file~";
58 symlink "extra/$file", "modules/$file";
60 if ($file =~ /^m_/ && -d "modules/$file" && dep_dir "modules/$file") {
61 mkdir "$build/obj/$file";
62 push @modlist, "modules/$file.so";
64 if ($file =~ /^m_.*\.cpp$/) {
65 my $out = find_output "modules/$file";
66 dep_cpp "modules/$file", $out;
71 my $core_mk = join ' ', @core_deps;
72 my $mods = join ' ', @modlist;
75 bin/inspircd: $core_mk
76 \$(RUNCC) -o \$\@ \$(CORELDFLAGS) \$(LDLIBS) \$^
78 inspircd: bin/inspircd
81 .PHONY: inspircd modules
88 my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp# or die "Bad file $file";
89 if ($path eq 'modules/' || $path eq 'commands/') {
90 return "modules/$base.so";
91 } elsif ($path eq '' || $path eq 'modes/' || $path =~ /^[a-z]+engines\/$/) {
93 } elsif ($path =~ m#modules/(m_.*)/#) {
94 return "obj/$1/$base.o";
96 die "Can't determine output for $file";
102 my $basedir = $f =~ m#(.*)/# ? $1 : '.';
103 return $f2dep{$f} if exists $f2dep{$f};
106 my $link = readlink $f;
108 $link = "$basedir/$link" unless $link =~ m#^/#;
111 open my $in, '<', $f or die "Could not read $f";
113 if (/^\s*#\s*include\s*"([^"]+)"/) {
115 next if $inc eq 'inspircd_version.h' && $f eq '../include/inspircd.h';
117 for my $loc ("$basedir/$inc", "../include/$inc") {
120 $dep{$_}++ for split / /, gendep $loc;
124 if ($found == 0 && $inc ne 'inspircd_win32wrapper.h') {
125 print STDERR "WARNING: could not find header $inc for $f\n";
126 } elsif ($found > 1 && $basedir ne '../include') {
127 print STDERR "WARNING: ambiguous include $inc in $f\n";
132 $f2dep{$f} = join ' ', sort keys %dep;
137 my($file, $out) = @_;
140 print MAKE "$out: $file $f2dep{$file}\n";
141 print MAKE "\t@\$(SOURCEPATH)/make/unit-cc.pl \$(VERBOSE) \$< \$\@\n";
148 for my $file (readdir DIR) {
149 next unless $file =~ /(.*)\.cpp$/;
150 my $ofile = find_output "$dir/$file";
151 dep_cpp "$dir/$file", $ofile;
152 push @ofiles, $ofile;
156 my $ofiles = join ' ', @ofiles;
157 print MAKE "$dir.so: $ofiles\n\t\$(RUNCC) \$(PICLDFLAGS) -o \$\@ \$^\n";