- print "build process. For more info please refer to:\n";
- print "\e[1;32mhttp://www.inspircd.org/wiki/Installation_From_Tarball\e[0m\n";
-}
-print "*** \e[1;32mRemember to edit your configuration files!!!\e[0m ***\n\n\n";
-if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
- print "\e[1;32mWARNING!\e[0m You are running OpenBSD but you are using the base gcc package\nrather than eg++. This compile will most likely fail, but i'm letting you\ngo ahead with it anyway, just in case i'm wrong :-)\n";
-}
-
-if ($config{GCCVER} < "3") {
- print <<FOO2;
-\e[1;32mWARNING!\e[0m You are attempting to compile InspIRCd on GCC 2.x!
-GCC 2.x series compilers only had partial (read as broken) C++ support, and
-your compile will most likely fail horribly! If you have any problems, do NOT
-report them to the bugtracker or forums without first upgrading your compiler
-to a newer 3.x or 4.x (or whatever is available currently) version.
-FOO2
-}
-
-################################################################################
-# HELPER FUNCTIONS #
-################################################################################
-sub getcache {
- # Retrieves the .config.cache file, and loads values into the main config hash.
- open(CACHE, ".config.cache") or return 0;
- while (<CACHE>) {
- chomp;
- # Ignore Blank lines, and comments..
- next if /^\s*$/;
- next if /^\s*#/;
- my ($key, $value) = split("=", $_, 2);
- $value =~ /^\"(.*)\"$/;
- # Do something with data here!
- $config{$key} = $1;
- }
- close(CACHE);
- return 1;
-}
-
-sub makecache {
- # Dump the contents of %config
- print "Writing \e[1;32mcache file\e[0m for future ./configures ...\n";
- open(FILEHANDLE, ">.config.cache");
- foreach my $key (keys %config) {
- print FILEHANDLE "$key=\"$config{$key}\"\n";
- }
- close(FILEHANDLE);
-}
-
-sub dir_check {
- my ($desc, $hash_key) = @_;
- my $complete = 0;
- while (!$complete) {
- print "In what directory $desc?\n";
- print "[\e[1;32m$config{$hash_key}\e[0m] -> ";
- chomp(my $var = <STDIN>);
- if ($var eq "") {
- $var = $config{$hash_key};
- }
- if ($var =~ /^\~\/(.+)$/) {
- # Convert it to a full path..
- $var = resolve_directory($ENV{HOME} . "/" . $1);
- }
- elsif ((($config{OSNAME} =~ /MINGW32/i) and ($var !~ /^[A-Z]{1}:\\.*/)) and (substr($var,0,1) ne "/"))
- {
- # Assume relative Path was given.. fill in the rest.
- $var = $this . "/$var";
- }
-
- $var = resolve_directory($var);
- if (! -e $var) {
- print "$var does not exist. Create it?\n[\e[1;32my\e[0m] ";
- chomp(my $tmp = <STDIN>);
- if (($tmp eq "") || ($tmp =~ /^y/i)) {
- # Attempt to Create the Dir..
- my $chk = eval {
- use File::Path ();
- File::Path::mkpath($var, 0, 0777);
- 1;
- };
- unless (defined($chk) && -d $var) {
- print "Unable to create directory. ($var)\n\n";
- # Restart Loop..
- next;
- }
- } else {
- # They said they don't want to create, and we can't install there.
- print "\n\n";
- next;
- }
- } else {
- if (!is_dir($var)) {
- # Target exists, but is not a directory.
- print "File $var exists, but is not a directory.\n\n";
- next;
- }
- }
- # Either Dir Exists, or was created fine.
- $config{$hash_key} = $var;
- $complete = 1;
- print "\n";
- }
-}
-
-our $SHARED = "";
-
-sub getosflags {
-
- # Beware: Linux sets it's own cflags below for some retarded reason
- $config{LDLIBS} = "-pthread -lstdc++";
- $config{FLAGS} = "-fPIC -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute -Wall $config{OPTIMISATI}";
- $config{DEVELOPER} = "-fPIC -Woverloaded-virtual -Wshadow -Wall -Wformat=2 -Wmissing-format-attribute -g";
- $SHARED = "-shared";
- $config{MAKEPROG} = "make";
-
- if ($config{OSNAME} =~ /darwin/i) {
- $config{FLAGS} = "-DDARWIN -frtti -fPIC -Wall $config{OPTIMISATI}";
- $SHARED = "-bundle -twolevel_namespace -undefined dynamic_lookup";
- $config{LDLIBS} = "-ldl -pthread -lstdc++";
- }
-
- if ($config{OSNAME} =~ /OpenBSD/i) {
- $config{MAKEPROG} = "gmake";
-# apparantly (Dagonet says) that this causes problems, so let's try without it.
-# $config{LDLIBS} = $config{LDLIBS} . " -lunwind";
- chomp(my $foo = `eg++ -dumpversion | cut -c 1`);
- # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
- # if theyre not running this, configure lets the build continue but they probably wont manage to
- # compile as this standard version is 2.95.3!
- if ($foo ne "") {
- $config{CC} = "eg++";
- chomp($config{GCCVER} = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change the compiler path
- chomp($config{GCCMINOR} = `eg++ -dumpversion | cut -c 3`);
- }
- return "OpenBSD";
- }
-
- if ($config{OSNAME} =~ /Linux/i) {
- $config{LDLIBS} = "-ldl -lstdc++ -pthread";
-# $config{FLAGS} = "-fPIC -Woverloaded-virtual -Wshadow -Wall $config{OPTIMISATI}";
- $config{FLAGS} .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
- $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
- $config{MAKEPROG} = "make";
- }
-
- if ($config{OSNAME} =~ /FreeBSD/i) {
- $config{FLAGS} .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
- $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
- }
-
- if ($config{OSNAME} =~ /SunOS/i or $config{OSNAME} =~ /solaris/i)
- {
- # solaris/sunos needs these
- # socket = bsd sockets api
- # nsl = dns stuff
- # rt = POSIX realtime extensions
- # resolv = inet_aton only (why isnt this in nsl?!)
- $config{MAKEPROG} = "gmake";
- $config{LDLIBS} .= " -lsocket -lnsl -lrt -lresolv -pthread";
- return "Solaris";
- }
-
- if($config{OSNAME} =~ /MINGW32/i)
- {
- # All code is position-independent on windows
- $config{FLAGS} =~ s/-fPIC //;
- return "MinGW";
- }
-
- return $config{OSNAME};
-}
-
-my ($mliflags, $mfrules, $mobjs, $mfcount) = ("", "", "", 0);
-
-sub writefiles {
- my($writeheader) = @_;
- my $se = "";
- # First File.. inspircd_config.h
- chomp(my $incos = `uname -n -s -r`);
- chomp(my $version = `sh src/version.sh`);
- chomp(my $revision2 = getrevision());
- if ($writeheader == 1)
- {
- print "Writing \e[1;32minspircd_config.h\e[0m\n";
- open(FILEHANDLE, ">include/inspircd_config.h");
- print FILEHANDLE <<EOF;
-/* Auto generated by configure, do not modify! */
-#ifndef __CONFIGURATION_AUTO__
-#define __CONFIGURATION_AUTO__
-
-/* this is for windows support. */
-#define CoreExport /**/
-#define DllExport /**/
-
-#define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
-#define MOD_PATH "$config{MODULE_DIR}"
-#define VERSION "$version"
-#define REVISION "$revision2"
-#define SOMAXCONN_S "$config{_SOMAXCONN}"
-#define OPTIMISATION $config{OPTIMITEMP}
-#define LIBRARYDIR "$config{LIBRARY_DIR}"
-#define SYSTEM "$incos"
-#define ENTRYPOINT int main(int argc, char** argv)
-
-EOF
-print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
-
- if ($config{OSNAME} =~ /SunOS/i) {
- print FILEHANDLE "#define IS_SOLARIS\n";
- }
- if ($config{OSNAME} =~ /MINGW32/i) {
- print FILEHANDLE "#define IS_MINGW\n";
- }
- if ($config{GCCVER} >= 3) {
- print FILEHANDLE "#define GCC3\n";
- }
- if (
- (($config{GCCVER} == 4) && ($config{GCCMINOR} >= 3))
- ||
- ($config{GCCVER} > 4)
- ) {
- print FILEHANDLE "#define HASHMAP_DEPRECATED\n";
- }
- if ($config{HAS_STRLCPY} eq "true") {
- print FILEHANDLE "#define HAS_STRLCPY\n";
- }
- if ($config{HAS_STDINT} eq "true") {
- print FILEHANDLE "#define HAS_STDINT\n";
- }
- if ($config{IPV6} =~ /y/i) {
- print FILEHANDLE "#define IPV6\n";
- }
- if ($config{SUPPORT_IP6LINKS} =~ /y/i) {
- print FILEHANDLE "#define SUPPORT_IP6LINKS\n";
- }
- my $use_hiperf = 0;
- if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
- print FILEHANDLE "#define USE_KQUEUE\n";
- $se = "socketengine_kqueue";
- $use_hiperf = 1;
- }
- if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
- print FILEHANDLE "#define USE_EPOLL\n";
- $se = "socketengine_epoll";
- $use_hiperf = 1;
- }
- if (($has_ports) && ($config{USE_PORTS} eq "y")) {
- print FILEHANDLE "#define USE_PORTS\n";
- $se = "socketengine_ports";
- $use_hiperf = 1;
- }
- # user didn't choose either epoll or select for their OS.
- # default them to USE_SELECT (ewwy puke puke)
- if (!$use_hiperf) {
- print "no hi-perf, " . $config{USE_POLL};
- if ($config{USE_POLL} eq "y")
- {
- print FILEHANDLE "#define USE_POLL\n";
- $se = "socketengine_poll";
- }
- else
- {
- print FILEHANDLE "#define USE_SELECT\n";
- $se = "socketengine_select";
- }
- }
- print FILEHANDLE "\n#include \"threadengines/threadengine_pthread.h\"\n\n#endif\n";
- close(FILEHANDLE);
- }
-
- if ($writeheader)
- {
- open(FILEHANDLE, ">include/inspircd_se_config.h");
- print FILEHANDLE <<EOF;
-/* Auto generated by configure, do not modify or commit to svn! */
-#ifndef __CONFIGURATION_SOCKETENGINE__
-#define __CONFIGURATION_SOCKETENGINE__
-
-#include "socketengines/$se.h"
-
-#endif
-EOF
- close(FILEHANDLE);
- }
-
-
- # Create a Modules List..
- my $modules = "";
- foreach my $i (@modlist)
- {
- $modules .= "m_".$i.".so ";
- }
- chomp($modules); # Remove Redundant whitespace..
-
- opendir(DIRHANDLE, "src/modules");
- foreach my $name2 (sort readdir(DIRHANDLE)) {
- if ($name2 =~ /^m_(.+?)$/) {
- if (defined(opendir(MDIRHANDLE, "src/modules/$name2"))) {
- closedir(MDIRHANDLE);
- $modules .= "$name2.so ";
- $uninstall_list = $uninstall_list . " -rm \$(MODULES)/$name2.so\n";
- }
- }
- }
- closedir(DIRHANDLE);
-
-
- # Write all .in files.
- my $tmp = "";
- my $file = "";
- my $exe = "inspircd";
-
- # Do this once here, and cache it in the .*.inc files,
- # rather than attempting to read src/version.sh from
- # compiled code -- we might not have the source to hand.
- # Fix for bug#177 by Brain.
-
- chomp($version = `sh ./src/version.sh`);
- chomp(my $revision = getrevision());
- $version = "$version(r$revision)";
-
- # We can actually parse any file starting with . and ending with .inc,
- # but right now we only parse .inspircd.inc to form './inspircd'
-
- print "Writing \e[1;32mMakefiles\e[0m\n";
- write_dynamic_modules_makefile();
- write_dynamic_makefile();
-
- opendir(DIRHANDLE, $this);
-
- foreach my $name (sort readdir(DIRHANDLE)) {
- if ($name =~ /^\.(.+)\.inc$/) {
- $file = $1;
-
- # Bug #353, omit this on non-darwin
- next if (($config{OSNAME} !~ /darwin/) && ($file eq "org.inspircd.plist"));
-
- # All .name.inc files need parsing!
- $tmp = "";
- open(FILEHANDLE, ".$file.inc") or die ("Can't open .$file.inc");
- while (<FILEHANDLE>) {
- $tmp .= $_;
- }
- close(FILEHANDLE);
-
- print "Writing \e[1;32m$file\e[0m ...\n";
- $tmp =~ s/\@CC\@/$config{CC}/ if defined $config{CC};
- $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/ if defined $config{MAKEPROG};
- $tmp =~ s/\@FLAGS\@/$config{FLAGS}/ if defined $config{FLAGS};
- $tmp =~ s/\@DEVELOPER\@/$config{DEVELOPER}/ if defined $config{DEVELOPER};
- $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/ if defined $config{LDLIBS};
- $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/ if defined $config{BASE_DIR};
- $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/ if defined $config{CONFIG_DIR};
- $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/ if defined $config{MODULE_DIR};
- $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/ if defined $config{BINARY_DIR};
- $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/ if defined $config{LIBRARY_DIR};
- $tmp =~ s/\@MODULES\@/$modules/ if defined $modules;
- $tmp =~ s/\@STARTSCRIPT\@/$config{STARTSCRIPT}/ if defined $config{STARTSCRIPT};
- $tmp =~ s/\@DESTINATION\@/$config{DESTINATION}/ if defined $config{DESTINATION};
- $tmp =~ s/\@EXTRA_DIR\@/$config{EXTRA_DIR}/ if defined $config{EXTRA_DIR};
- $tmp =~ s/\@EXECUTABLE\@/$exe/ if defined $exe;
- $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/ if defined $config{MAKEORDER};
- $tmp =~ s/\@VERSION\@/$version/ if defined $version;
- $tmp =~ s/\@INSTALL_LIST\@/$install_list/ if defined $install_list;
- $tmp =~ s/\@UNINSTALL_LIST\@/$uninstall_list/ if defined $uninstall_list;
-
- open(FILEHANDLE, ">$file") or die("Can't write to $file: $!\n");
- print FILEHANDLE $tmp;
- }
- }
- closedir(DIRHANDLE);
-
- # Make inspircd executable!
- chmod 0744, 'inspircd';
-}
-
-sub write_dynamic_modules_makefile {
- # Modules Makefile..
- print "Writing \e[1;32msrc/modules/Makefile\e[0m\n";
- open(FILEHANDLE, ">src/modules/Makefile");
-
-###
-# Module Makefile Header
-###
- print FILEHANDLE <<EOF;
-###################################################
-# Copyright 2002-2007 The InspIRCd Development Team
-# http://www.inspircd.org/wiki/index.php/Credits
-#
-# Thanks to Andrew Church <achurch\@achurch.org>
-# for assisting with making this work right.
-#
-# Automatically Generated by ./configure to add a
-# modules please run ./configure -modupdate
-###################################################
-
-all: \$(MODULES)
-
-EOF
-
-if ($config{OSNAME} =~ /darwin/) {
- print FILEHANDLE <<EOCHEESE;
-
-PICLDFLAGS = -twolevel_namespace -undefined dynamic_lookup -bundle
-
-EOCHEESE
-} else {
- print FILEHANDLE <<EOCHEESE;
-
-PICLDFLAGS = -fPIC -DPIC -shared
-
-EOCHEESE
-}
-
- ###
- # End Module Makefile Header
- ###
-
- # Create a Modules List..
- my $modules = "";
- my $cmflags = "";
- my $liflags = "";
- foreach my $i (@modlist) {
- ###
- # Write Entry to the MakeFile
- ###
- $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
- $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
- my $deps = getdependencies("src/modules/m_".$i.".cpp");
-
- #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
-
-
- if (nopedantic("src/modules/m_".$i.".cpp"))
- {
- print FILEHANDLE "
-m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps
- \@../../make/run-cc.pl \$(CC) -pipe -I../../include \$(NICEFLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp
-"
- }
- else
- {
- print FILEHANDLE "
-m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps
- \@../../make/run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp
-";
- }
- $install_list = $install_list . " install -m \$(INSTMODE) src/modules/m_$i.so \$(MODPATH)\n";
- $uninstall_list = $uninstall_list . " -rm \$(MODULES)/m_$i.so\n";
-###
- # End Write Entry to the MakeFile
- ###
- }
-
- opendir(DIRHANDLE, "src/modules");
- foreach my $name (sort readdir(DIRHANDLE)) {
- if ($name =~ /^m_(.+?)$/) {
- $mfrules = "";
- $mobjs = "";
- $mliflags = "";
- $mfcount = 0;
- # A module made of multiple files, in a dir, e.g. src/modules/m_spanningtree/
- if (defined(opendir(MDIRHANDLE, "src/modules/$name"))) {
- read_module_directory("src/modules/$name", $name);
- print "Composing Makefile rules for directory \e[1;32m$name\e[0m... (\e[1;32m$mfcount files found\e[0m)\n";
- print FILEHANDLE "$name.so: ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $mobjs\n";
- if ($config{IS_DARWIN} eq "YES") {
- print FILEHANDLE " \@../../make/run-cc.pl \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) $mliflags -bundle -o $name.so $mobjs\n";
- } else {
- print FILEHANDLE " \@../../make/run-cc.pl \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $mobjs\n";
- }
- print FILEHANDLE "\n$mfrules\n";
- closedir(MDIRHANDLE);
- $install_list = $install_list . " install -m \$(INSTMODE) src/modules/$name.so \$(MODPATH)\n";
- }
- }
- }
- closedir(DIRHANDLE);
-}
-
-sub read_module_directory {
- my ($dpath, $reldpath) = @_;
-
- if (opendir(MDIRHANDLE, $dpath) == 0) {
- return;
- }
-
- foreach my $fname (sort readdir(MDIRHANDLE)) {
- if ($fname =~ /\.cpp$/) {
- my $cmflags = getcompilerflags("$dpath/$fname");
- $mliflags = $mliflags . " " . getlinkerflags("$dpath/$fname");
- my $deps = getdependencies("$dpath/$fname");
- my $oname = $fname;
- $oname =~ s/\.cpp$/.o/g;
- $mfrules = $mfrules . "$reldpath/$oname: $reldpath/$fname ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps\n";
- $mfrules = $mfrules . " \@../../make/run-cc.pl \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $reldpath/$oname -c $reldpath/$fname\n\n";
- $mobjs = $mobjs . " $reldpath/$oname";
- $mfcount++;
- }
- elsif ((-d "$dpath/$fname") && !($fname eq ".") && !($fname eq "..")) {
- read_module_directory($dpath."/".$fname, $reldpath."/".$fname);
- }
- }
-}
-
-sub calcdeps($)
-{
- # Yes i know we could use gcc -M but it seems to ideneify a lot of 'deep'
- # dependencies which are not relevent in C++.
-
- my $file = $_[0];
-
- open (CPP, "<$file") or die("Can't open $file for reading!");
-
- my %dupe = ();
- my $retlist = "";
-
- foreach my $d (@ignoredeps)
- {
- $dupe{$d} = 1;
- }
-
- my $immutable = "";
- foreach my $dep (@immutabledeps)
- {
- $immutable = $immutable . "../include/$dep ";
- }
- $immutable =~ s/ $//g;
-
- while (defined(my $line = <CPP>))
- {
- chomp($line);
- if ($line =~ /#include "(.+\.h)"/)
- {
- if (!exists($dupe{$1}))
- {
- $retlist = $retlist . "../include/$1 ";
- $dupe{$1} = 1;
- }
- }
- }
- close CPP;
- return length($immutable) ? $immutable . " " . $retlist : $retlist;
-}
-
-sub write_dynamic_makefile
-{
- my $i = 0;
- my @cmdlist = ();
- my %existing_install_list = ();
- my %core_files_list = ();
-
- opendir(DIRHANDLE, "src/commands");
- foreach my $name (sort readdir(DIRHANDLE))
- {
- if ($name =~ /^cmd_(.+)\.cpp$/)
- {
- $cmdlist[$i++] = $1;
- $install_list = $install_list . " -install -m \$(INSTMODE) src/commands/cmd_" . $1 . ".so \$(LIBPATH)\n";
- $uninstall_list = $uninstall_list . " -rm \$(LIBPATH)/cmd_$1.so\n";
- }
- }
- closedir(DIRHANDLE);
-
- if (!$has_epoll)
- {
- $config{USE_EPOLL} = 0;
- }
- if (!$has_kqueue)
- {
- $config{USE_KQUEUE} = 0;
- }
- if (!$has_ports)
- {
- $config{USE_PORTS} = 0;
- }
-
- # 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 -export-dynamic
- $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) -export-dynamic -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 details.
- 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) -export-dynamic $SHARED -o cmd_$cmd.so cmd_$cmd.cpp
-
-ITEM
- }