-
- # formerly generated below this foreach, now it's not! magic.
- my $all_core = "";
-
- foreach my $dir (("src","src/commands","src/modes","src/socketengines","src/modules"))
- {
- print "Scanning \e[1;32m$dir\e[0m for core files ";
- opendir(DIRHANDLE, $dir);
- foreach my $name (sort readdir(DIRHANDLE))
- {
- if ($name =~ /\.cpp$/)
- {
- open (CPP, "<$dir/$name") or die("Can't open $dir/$name to scan it! oh bugger");
- print ".";
- while (defined(my $line = <CPP>))
- {
- chomp($line);
- if ($line =~ /\/\* \$Core \*\//i)
- {
- my $sname = $name;
- $sname =~ s/\.cpp$/.o/;
-
- # append it to list to be built
- $all_core = $all_core . $sname . " ";
- $filelist{$name} = $sname;
-
- # mark it as a core file, so it won't get shared object cflags
- if (!exists($core_files_list{$name}))
- {
- $core_files_list{$name} = 1;
- }
- }
- elsif ($line =~ /\/\* \$ExtraDeps: (.*?) \*\//i)
- {
- $specialdeps{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraObjects: (.*?) \*\//i)
- {
- $extraobjects{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraBuild: (.*?) \*\//i)
- {
- $extrabuildlines{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraSources: (.*?) \*\//i)
- {
- $extrasources{$name} = $1;
- }
- elsif ($line =~ /\/\* \$If: (\w+) \*\//i)
- {
- if (defined $config{$1})
- {
- if (($config{$1} !~ /y/i) and ($config{$1} ne "1"))
- {
- # Skip to 'endif'
- while (defined($line = <CPP>))
- {
- chomp($line);
- die ("\$If buildsystem instruction within another \$If in file $dir/$name") if ($line =~ /\/\* \$If: (\w+) \*\//i);
- last if ($line =~ /\/\* \$EndIf \*\//i);
- }
- }
- }
- }
- elsif ($line =~ /\/\* \$Install: (.*?) \*\//i)
- {
- if (!exists($existing_install_list{$1}))
- {
- $existing_install_list{$1} = 1;
- my $idir = (split(' ',$1))[1];
- my $ifile = (split(' ',$1))[0];
- $install_list = $install_list . " -install -m \$(INSTMODE) $1\n";
- $ifile =~ s/.*\///g;
- $uninstall_list = $uninstall_list . " -rm $idir/$ifile\n";
- }
- }
- elsif ($line =~ /\/\* \$CopyInstall: (.*?) \*\//i)
- {
- if (!exists($existing_install_list{$1}))
- {
- $existing_install_list{$1} = 1;
- my $idir = (split(' ',$1))[1];
- my $ifile = (split(' ',$1))[0];
- $install_list = $install_list . " -cp $1\n";
- $ifile =~ s/.*\///g;
- $uninstall_list = $uninstall_list . " -rm $idir/$ifile\n";
- }
- }
- }
- close CPP;
- }
- }
- closedir(DIRHANDLE);
- print " done!\n";
- }
-
- # modes need to be compiled in too
- $all_core = $all_core . "modes/modeclasses.a";
-
- my $freebsd4libs = (defined $config{CRAQ} ? $config{CRAQ} : "");
-
- my $libraryext = "";
- my $binary_rule = "";
-
- if ($config{IS_DARWIN} eq "YES")
- {
- $libraryext = "dylib";
- $binary_rule = " \@../make/run-cc.pl \$(CC) -pipe -I../include \$(FLAGS) -c inspircd.cpp\n \@../make/run-cc.pl \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o "
- }
- else
- {
- $libraryext = "so";
- $binary_rule = " \@../make/run-cc.pl \$(CC) -pipe -I../include \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) ";
- }
-
- open(FH,">src/Makefile") or die("Could not write src/Makefile");
- print FH <<EOM;
-
-CC = im a cheezeball
-CXXFLAGS = -I../include \${FLAGS}
-CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
-RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
-
-EOM
-
- my $buildstring = "";
- my $deps = "";
-
- foreach my $cpp (sort keys %filelist)
- {
- my $objs = $cpp;
- my $rawcpp = $cpp;
- $objs =~ s/\.cpp$/.o/;
- if (exists($extraobjects{$cpp}))
- {
- $objs = $objs . " " . $extraobjects{$cpp};
- $all_core = $all_core . " " . $extraobjects{$cpp};
- }
- if (exists($extrasources{$cpp}))
- {
- $rawcpp = $rawcpp . " " . $extrasources{$cpp};
- }
-
- $deps = calcdeps("src/$cpp");
- if (exists($extrasources{$cpp}))
- {
- foreach my $seperate (sort split(' ',$extrasources{$cpp}))
- {
- my $d = calcdeps("src/$extrasources{$cpp}") . " ";
- if ($d ne "")
- {
- $deps = $deps . $d . " ";
- }
- }
- }
- $buildstring = $buildstring . $objs . ": $cpp $deps ". (defined($specialdeps{$cpp}) ? $specialdeps{$cpp} : "") . "\n";
-
- if (exists($core_files_list{$cpp}))
- {
- # core files are statically linked into the binary and do not require $SHARED shared libs switches
- $buildstring = $buildstring . " \@../make/run-cc.pl \$(CC) -pipe -I../include \$(FLAGS) -c $rawcpp\n";
- }
- else
- {
- $buildstring = $buildstring . " \@../make/run-cc.pl \$(CC) -pipe -I../include \$(FLAGS) $SHARED -c $rawcpp\n";
- }
-
- if (exists($extrabuildlines{$cpp}))
- {
- $buildstring = $buildstring . " " . $extrabuildlines{$cpp} . "\n";
- }
- }
-
- print FH "all: inspircd moo\n\n\n";
-
- $deps = calcdeps("src/inspircd.cpp");
- print FH "inspircd: inspircd.cpp $deps $all_core\n";
- print FH "$binary_rule $all_core\n\n";
-
- print FH $buildstring;
- print FH "moo:\n \@\${MAKE} -C \"commands\" DIRNAME=\"src/commands\" CC=\"\$(CC)\" \$(MAKEARGS)\n\n";
-
- # close main makefile
- close(FH);
-
- my $cmdobjs = "";
- # generate a list of .so
- foreach my $cmd (@cmdlist) {
- $cmdobjs = $cmdobjs . "cmd_$cmd.so ";
- }
-
- # and now reopen the commands makefile
- open(FH,">src/commands/Makefile") or die("Could not write src/commands/Makefile");
- print FH <<ITEM;
-CC = i am cornholio
-CXXFLAGS = -I../../include \${FLAGS}
-
-all: $cmdobjs
-
-
-ITEM
-
- # now print the command file detail
- foreach my $cmd (@cmdlist) {
- print FH <<ITEM;
-cmd_$cmd.so: cmd_$cmd.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/commands/cmd_$cmd.h
- \@../../make/run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) $SHARED -o cmd_$cmd.so cmd_$cmd.cpp
-
-ITEM
- }