]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Fix indentation
[user/henk/code/inspircd.git] / configure
index 0b27e2f17fdb8a668bd4446f0a06c4aefaa526e4..7897aec2d66f2af2e1044fb137e477f828217473 100755 (executable)
--- a/configure
+++ b/configure
@@ -12,7 +12,7 @@
 #
 ###################################################
 
-require 5.6.0;
+require 5.8.0;
 use Socket;
 use Cwd;
 use Getopt::Long;
@@ -484,14 +484,14 @@ if ($has_epoll) {
                                if ($line =~ /GNU C Library .* version (.*?) /)
                                {
                                        $libcv = $1;
-                                       $libcv =~  /([0-9\.\-])+/;
+                                       $libcv =~  /(\d+\.\d+)/;
                                        $libcv = $1;
                                }
                                elsif ($line =~ /Compiled on a Linux (.*?\..*?)\.* system/)
                                {
                                        $kernelv = $1;
                                        # Fix for some retarded libc builds, strip off >> and << etc.
-                                       $kernelv =~ /([0-9\.\-])+/;
+                                       $kernelv =~ /(\d+\.\d+)/;
                                        $kernelv = $1;
                                }
                        }
@@ -549,6 +549,36 @@ if (($config{HAS_OPENSSL}) && (($config{HAS_OPENSSL} >= 0.8) || ($config{HAS_OPE
        $config{HAS_OPENSSL} = "n";
 }
 
+printf "Checking if you are running an ancient, unsupported OS... ";
+if ($config{OSNAME} =~ /FreeBSD/i)
+{
+       $version = `uname -r`;
+       if ($version =~ /^4\./)
+       {
+               $foundit = `ls -l /usr/local/lib/libgnugetopt* | wc -l`;
+               if ($foundit > 0)
+               {
+                       # ICKY ICKY ICK, FREEBSD 4.x! GET AN UPGRADE!
+                       $config{CRAQ} = "-L/usr/local/lib -lgnugetopt -DHAVE_DECL_GETOPT=1";
+                       print "yes\n";
+               }
+               else
+               {
+                       print "\n\nERROR: You require libgnugetopt (from ports or packages) to build InspIRCd on FreeBSD 4.11.\n";
+               }
+       }
+       else
+       {
+               $config{CRAQ} = " ";
+               print "no ($version)\n";
+       }
+}
+else
+{
+       $config{CRAQ} = " ";
+       print "no ($config{OSNAME})\n";
+}
+
 ################################################################################
 #                        BEGIN INTERACTIVE PART                              #
 ################################################################################
@@ -930,6 +960,7 @@ sub getosflags {
 
        if ($config{OSNAME} =~ /OpenBSD/i) {
                $config{MAKEPROG} = "gmake";
+               $config{LDLIBS} = $config{LDLIBS} . " -lunwind";
                chomp($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
@@ -1199,6 +1230,21 @@ sub write_dynamic_modules_makefile {
 all: \$(MODULES)
 
 EOF
+
+if ($config{OSNAME} =~ /darwin/) {
+               print FILEHANDLE <<EOCHEESE;
+
+PICLDFLAGS = -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) -bundle
+
+EOCHEESE
+} else {
+               print FILEHANDLE <<EOCHEESE;
+
+PICLDFLAGS = -fPIC -DPIC -shared \$(FLAGS)
+
+EOCHEESE
+}
+
        ###
        # End Module Makefile Header
        ###
@@ -1221,20 +1267,8 @@ EOF
        
                print FILEHANDLE <<EOCHEESE;
 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
-       \$(CC) -pipe -I../../include \$(FLAGS) $cmflags -export-dynamic -c m_$i.cpp
-EOCHEESE
-
-if ($config{OSNAME} =~ /darwin/) {
-               print FILEHANDLE <<EOCHEESE;
-       \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) -bundle $liflags -o m_$i.so m_$i.o
-
-EOCHEESE
-} else {
-               print FILEHANDLE <<EOCHEESE;
-       \$(CC) -pipe \$(FLAGS) -shared $liflags -o m_$i.so m_$i.o
-
+       \$(CC) -pipe -I../../include \$(FLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp
 EOCHEESE
-}
                $crud = $crud . "       install -m \$(INSTMODE) m_$i.so \$(MODPATH)\n";
 ###
                # End Write Entry to the MakeFile
@@ -1244,34 +1278,21 @@ EOCHEESE
        opendir(DIRHANDLE, "src/modules");
        foreach $name (sort readdir(DIRHANDLE)) {
                if ($name =~ /^m_(.+?)$/) {
-                       $crapola = "";
-                       $crap3 = "";
+                       $mfrules = "";
+                       $mobjs = "";
                        $mliflags = "";
+                       $mfcount = 0;
                        # A module made of multiple files, in a dir, e.g. src/modules/m_spanningtree/
                        if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
-                               my $i = 0;
-                               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"; 
-                               foreach $fname (sort readdir(MDIRHANDLE)) {
-                                       if ($fname =~ /\.cpp$/) {
-                                               $cmflags = getcompilerflags("src/modules/$name/$fname");
-                                               $mliflags = $mliflags . " " . getlinkerflags("src/modules/$name/$fname");
-                                               $deps = getdependencies("src/modules/$name/$fname");
-                                               $oname = $fname;
-                                               $oname =~ s/\.cpp$/.o/g;
-                                               print FILEHANDLE " $name/$oname";
-                                               $crapola = $crapola .  "$name/$oname: $name/$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";
-                                               $crapola = $crapola .  "        \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $name/$oname -c $name/$fname\n\n";
-                                               $crap3 = $crap3 . " $name/$oname";
-                                               $i++;
-                                       }
-                               }
-                               print "Composing Makefile rules for directory \033[1;32m$name\033[0m... (\033[1;32m$i files found\033[0m)\n";
+                               read_module_directory("src/modules/$name", $name);
+                               print "Composing Makefile rules for directory \033[1;32m$name\033[0m... (\033[1;32m$mfcount files found\033[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 "\n    \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) -bundle -o $name.so $crap3\n"; 
+                                       print FILEHANDLE "      \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) $mliflags -bundle -o $name.so $mobjs\n"; 
                                } else {
-                                       print FILEHANDLE "\n    \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $crap3\n";
+                                       print FILEHANDLE "      \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $mobjs\n";
                                }
-                               print FILEHANDLE "\n$crapola\n";
+                               print FILEHANDLE "\n$mfrules\n";
                                closedir(MDIRHANDLE);
                                $crud = $crud . "       install -m \$(INSTMODE) $name.so \$(MODPATH)\n";
                        }
@@ -1282,6 +1303,31 @@ EOCHEESE
        print FILEHANDLE "modinst:\n    \@echo \"Installing modules...\"\n" . $crud;
 }
 
+sub read_module_directory {
+       my ($dpath, $reldpath) = @_;
+       
+       if (opendir(MDIRHANDLE, $dpath) == 0) {
+               return;
+       }
+       
+       foreach $fname (sort readdir(MDIRHANDLE)) {
+               if ($fname =~ /\.cpp$/) {
+                       $cmflags = getcompilerflags("$dpath/$fname");
+                       $mliflags = $mliflags . " " . getlinkerflags("$dpath/$fname");
+                       $deps = getdependencies("$dpath/$fname");
+                       $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 .  "        \$(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 write_dynamic_makefile {
 
        my $i = 0;
@@ -1312,6 +1358,8 @@ sub write_dynamic_makefile {
                $se = "socketengine_ports";
        }
 
+       $freebsd4libs = $config{CRAQ};
+
        open(FH,">src/Makefile") or die("Could not write src/Makefile");
        print FH <<EOM;
 ###################################################
@@ -1447,7 +1495,7 @@ EOM
 all: libIRCDtimer.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so libIRCDsnomasks.so libIRCDserver.so libIRCDfilelogger.so inspircd
 
 inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/socket.h libIRCDtimer.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDsnomasks.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so libIRCDserver.so libIRCDfilelogger.so
-       \$(CC) -pipe -I../include -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDhash.so libIRCDsocket.so libIRCDsocketengine.so libIRCDuserprocess.so libIRCDcull_list.so libIRCDcommand_parse.so libIRCDtimer.so libIRCDsnomasks.so libIRCDserver.so libIRCDfilelogger.so
+       \$(CC) -pipe -I../include -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDhash.so libIRCDsocket.so libIRCDsocketengine.so libIRCDuserprocess.so libIRCDcull_list.so libIRCDcommand_parse.so libIRCDtimer.so libIRCDsnomasks.so libIRCDserver.so libIRCDfilelogger.so
 
 libIRCDsocketengine.so: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
        \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp $se.cpp