X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=configure;h=a13f59c8135372c9a246135c0b989e4ff5ca4353;hb=e7310ca2f66d2e267efc62deca53a8b534bdd0eb;hp=1104d4209347ca34ea2d313c782050d129901255;hpb=6d461e285b5ee58599dbb034d30f08615056482e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/configure b/configure index 1104d4209..a13f59c81 100755 --- a/configure +++ b/configure @@ -12,7 +12,7 @@ # ################################################### -require 5.6.0; +require 5.8.0; use Socket; use Cwd; use Getopt::Long; @@ -23,6 +23,67 @@ use make::configure; use make::gnutlscert; use make::opensslcert; +############################################################################################### +# +# EDITABLE VARIABLES +# +############################################################################################### + +# If you wish to ignore a dependency throughout the entire core, add it here. + +my @ignoredeps = ( + "inspircd_win32wrapper.h", # windows has its own configure program +); + +# If you wish for all files in the entire core to have a given dependency, insert it here. +# You should keep this to an absolute minimum to avoid rebuilds that are not neccessary. + +my @immutabledeps = ( + "inspircd_config.h", # auto re-generated by configure + "inspircd.h", +); + +############################################################################################### +# +# NON-EDITABLE VARIABLES +# +############################################################################################### + +# List of commands that make up 'make install' and 'make deinstall' + +my $install_list = ""; +my $uninstall_list = ""; + +# This is a list of all files in the core. Each cpp file is mapped to a shared object file, +# whos file extension is omitted (these can vary from system to system). Auto detected by +# scanning the src/*.cpp files for files containing /* $Core: */ identifiers. + +my %filelist = (); + +# If you wish for a file to have special dependencies in the makefile, add an entry here. +# Auto populated by /* $ExtraDeps: */ instruction + +my %specialdeps = (); + +# If you wish for a file to have extra make lines (in between the compile and link steps) +# then insert them here. +# Auto populated by /* $ExtraBuild: */ instruction + +my %extrabuildlines = (); + +# If you wish for a file to be linked against extra objects or arctives, insert them here. +# Auto populated by /* $ExtraObjects: */ instruction + +my %extraobjects = (); + +# If you wish to compile extra cpp sources into an object, define them here. +# NOTE: Certain cpp files such as the socket engines have a value auto calculated +# for this table so that their derived class is built. +# Auto populated by /* $ExtraSources: */ instruction + +my %extrasources = (); + + GetOptions ( 'enable-gnutls' => \$opt_use_gnutls, 'rebuild' => \$opt_rebuild, @@ -37,6 +98,7 @@ GetOptions ( 'disable-ports' => \$opt_noports, 'disable-epoll' => \$opt_noepoll, 'disable-kqueue' => \$opt_nokqueue, + 'disable-rpath' => \$opt_disablerpath, 'enable-ipv6' => \$opt_ipv6, 'enable-remote-ipv6' => \$opt_ipv6links, 'disable-remote-ipv6' => \$opt_noipv6links, @@ -217,22 +279,21 @@ if (defined $opt_noipv6links) { $config{SUPPORT_IP6LINKS} = "n"; } -$config{STATIC_LINK} = "no"; # are doing static modules? chomp($config{MAX_CLIENT_T} = `sh -c \"ulimit -n\"`); # FD Limit chomp($config{MAX_DESCRIPTORS} = `sh -c \"ulimit -n\"`); # Hard FD Limit chomp($config{GCCVER} = `g++ -dumpversion | cut -c 1`); # Major GCC Version $config{_SOMAXCONN} = SOMAXCONN; # Max connections in accept queue $config{OSNAME} = $^O; # Operating System Name -$config{IS_DARWIN} = "NO"; # Is OSX? -$config{STARTSCRIPT} = "inspircd"; # start script? -$config{DESTINATION} = "BASE"; # Is target path. -$config{EXTRA_DIR} = ""; # Is empty. +$config{IS_DARWIN} = "NO"; # Is OSX? +$config{STARTSCRIPT} = "inspircd"; # start script? +$config{DESTINATION} = "BASE"; # Is target path. +$config{EXTRA_DIR} = ""; # Is empty. if ($config{OSNAME} =~ /darwin/i) { $config{IS_DARWIN} = "YES"; - $config{STARTSCRIPT} = "org.inspircd.plist"; # start script for OSX. - $config{DESTINATION} = "LAUNCHDPATH"; # Is OSX target. - $config{EXTRA_DIR} = " launchd_dir"; # Is OSX specific path. + $config{STARTSCRIPT} = "org.inspircd.plist"; # start script for OSX. + $config{DESTINATION} = "LAUNCHDPATH"; # Is OSX target. + $config{EXTRA_DIR} = " launchd_dir"; # Is OSX specific path. } $config{CC} = "g++"; # C++ compiler if (defined $opt_cc) @@ -242,7 +303,6 @@ if (defined $opt_cc) $exec = $config{CC} . " -dumpversion | cut -c 1"; chomp($config{GCCVER} = `$exec`); # Major GCC Version $config{MAKEORDER} = "ircd mods"; # build order -$config{STATICLIBS} = ""; # library archive path $config{MAX_IDENT} = "12"; # max ident size $config{MAX_QUIT} = "255"; # max quit message size $config{MAX_TOPIC} = "307"; # max topic size @@ -283,15 +343,6 @@ if ($config{GCCVER} eq "") { exit; } -# Minihack! Convert Cygwin to 'Cyg-Static' so i can -# Keep my dynamic module experiments here for later -# consideration! - -if ($config{OSNAME} =~ /CYGWIN/i) -{ - $config{OSNAME} = "CYG-STATIC"; -} - if (!$config{MAX_CLIENT_T}) { $config{MAX_CLIENT_T} = 1024; # Set a reasonable 'Default' $fd_scan_fail = "true"; # Used Later @@ -302,7 +353,7 @@ getmodules(); sub clean { - system("rm -rf .config.cache"); + unlink(".config.cache"); } sub update @@ -318,7 +369,7 @@ sub update exit 0; } else { # We've Loaded the cache file and all our variables.. - print "Updating Files..\n"; + print "Updating files...\n"; getosflags(); if ($opt_disable_debug == 1) { @@ -355,7 +406,7 @@ sub modupdate exit 0; } else { # We've Loaded the cache file and all our variables.. - print "Updating Files..\n"; + print "Updating files...\n"; getosflags(); $has_epoll = $config{HAS_EPOLL}; $has_ports = $config{HAS_PORTS}; @@ -397,7 +448,7 @@ sub svnupdate print "Running non-interactive configure...\n" unless $interactive; print "Checking for cache from previous configure... "; -print ((getcache() eq "true") ? "found\n" : "not found\n"); +print ((!getcache()) ? "not found\n" : "found\n"); print "Checking operating system version... "; print getosflags() . "\n"; @@ -474,6 +525,51 @@ if ($has_epoll) { if (($kernel =~ /^2\.0\./) || ($kernel =~ /^2\.2\./) || ($kernel =~ /^2\.4\./)) { $has_epoll = 0; } + else + { + # Suggestion from nenolod, weed out odd systems which have glibc built + # against 2.4 kernels (ick) + my $kernel_arch = `uname -p`; + chomp($kernel_arch); + $libcv = 0.0; + $kernelv = 0.0; + if ($kernel_arch =~ /x86_64/) { + open (FH,"/lib64/libc.so.6|") or $has_epoll = 0; + } + else { + open (FH,"/lib/libc.so.6|") or $has_epoll = 0; + } + if ($has_epoll) + { + while (chomp($line = )) + { + if ($line =~ /GNU C Library .* version (.*?) /) + { + $libcv = $1; + $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 =~ /(\d+\.\d+)/; + $kernelv = $1; + } + } + close FH; + if ($libcv < 2.3) + { + $has_epoll = 0; + printf "libc too old: $libcv... "; + } + if ($kernelv < 2.6) + { + $has_epoll = 0; + printf "libc built against older kernel $kernelv... "; + } + } + } } print "yes\n" if $has_epoll == 1; print "no\n" if $has_epoll == 0; @@ -494,15 +590,11 @@ if ($has_ports) { print "yes\n" if $has_ports == 1; print "no\n" if $has_ports == 0; -if (($config{OSNAME} =~ /CYGWIN/) || ($config{OSNAME} eq "CYG-STATIC")) { - $config{HAS_STRLCPY} = "true"; -} - $config{HAS_EPOLL} = $has_epoll; $config{HAS_KQUEUE} = $has_kqueue; printf "Checking for libgnutls... "; -if (($config{HAS_GNUTLS}) && (($config{HAS_GNUTLS} >= 1.2) || ($config{HAS_GNUTLS} eq "y"))) { +if (($config{HAS_GNUTLS}) || ($config{HAS_GNUTLS} eq "y")) { print "yes\n"; $config{HAS_GNUTLS} = "y"; } else { @@ -511,7 +603,7 @@ if (($config{HAS_GNUTLS}) && (($config{HAS_GNUTLS} >= 1.2) || ($config{HAS_GNUTL } printf "Checking for openssl... "; -if (($config{HAS_OPENSSL}) && (($config{HAS_OPENSSL} >= 0.8) || ($config{HAS_OPENSSL} eq "y"))) { +if (($config{HAS_OPENSSL}) || ($config{HAS_OPENSSL} eq "y")) { print "yes\n"; $config{HAS_OPENSSL} = "y"; } else { @@ -519,6 +611,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 # ################################################################################ @@ -713,14 +835,14 @@ if ($config{USE_GNUTLS} eq "y") { * few times and get that HD going :) Then answer the * * Questions which follow. If you are unsure, just hit enter * *************************************************************\n\n"; - make_gnutls_cert() or $failed = 1; - if (!$failed) { + $failed = make_gnutls_cert(); + if ($failed) { + print "\n\033[1;32mCertificate generation failed!\033[0m\n\n"; + } else { print "\nCertificate generation complete, copying to config directory... "; system("mv key.pem $config{CONFIG_DIR}/key.pem"); system("mv cert.pem $config{CONFIG_DIR}/cert.pem"); print "Done.\n\n"; - } else { - print "\n\033[1;32mCertificate generation failed!\033[0m\n\n"; } } else { @@ -753,7 +875,7 @@ if ($config{USE_GNUTLS} eq "y") { print "SSL Certificates Not found, Generating.. \n\n ************************************************************* * Generating the certificates may take some time, go grab a * -* coffee, or something. * +* coffee, or something. * *************************************************************\n\n"; make_openssl_cert(); print "\nCertificate generation complete, copying to config directory... "; @@ -806,7 +928,7 @@ FOO2 ################################################################################ sub getcache { # Retrieves the .config.cache file, and loads values into the main config hash. - open(CACHE, ".config.cache") or return undef; + open(CACHE, ".config.cache") or return 0; while () { chomp; # Ignore Blank lines, and comments.. @@ -818,7 +940,7 @@ sub getcache { $config{$key} = $1; } close(CONFIG); - return "true"; + return 1; } sub makecache { @@ -887,19 +1009,20 @@ sub dir_check { sub getosflags { $config{LDLIBS} = "-lstdc++"; - $config{FLAGS} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}"; - $config{DEVELOPER} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated -g"; - $SHARED = "-Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared"; + $config{FLAGS} = "-fPIC -Wall -pedantic $config{OPTIMISATI}"; + $config{DEVELOPER} = "-fPIC -Wall -pedantic -g"; + $SHARED = "-Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared" unless defined $opt_disablerpath; $config{MAKEPROG} = "make"; if ($config{OSNAME} =~ /darwin/i) { - $config{FLAGS} = "-DDARWIN -frtti -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}"; + $config{FLAGS} = "-DDARWIN -frtti -fPIC -Wall -pedantic $config{OPTIMISATI}"; $SHARED = "-bundle -twolevel_namespace -undefined dynamic_lookup"; $config{LDLIBS} = "-ldl -lstdc++"; } 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 @@ -913,25 +1036,10 @@ sub getosflags { if ($config{OSNAME} =~ /Linux/i) { $config{LDLIBS} = "-ldl -lstdc++"; - $config{FLAGS} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}"; + $config{FLAGS} = "-fPIC -Wall -pedantic $config{OPTIMISATI}"; $config{FLAGS} .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS}); $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS}); $config{MAKEPROG} = "make"; - if ($config{OSNAME} =~ /CYGWIN/) { - $config{FLAGS} = "-fno-strict-aliasing -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}"; - $config{LDLIBS} = ""; - $config{MAKEPROG} = "/usr/bin/make"; - $config{MAKEORDER} = "ircd mods"; - return "Cygwin"; - } elsif ($config{OSNAME} eq "CYG-STATIC") { - $config{FLAGS} = "-fno-strict-aliasing -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}"; - $config{LDLIBS} = ""; - $config{MAKEPROG} = "/usr/bin/make"; - $config{MAKEORDER} = "mods ircd"; - $config{STATICLIBS} = "modules/mods.a"; - $config{STATIC_LINK} = "yes"; - return "Cygwin-Static"; - } } if ($config{OSNAME} =~ /FreeBSD/i) { @@ -1008,19 +1116,9 @@ print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n"; if ($config{OSNAME} =~ /SunOS/i) { print FILEHANDLE "#define IS_SOLARIS\n"; } - if ($config{OSNAME} =~ /CYGWIN/i) { - print FILEHANDLE "#define IS_CYGWIN\n"; - print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE 1024\n#endif\n"; - } if ($config{OSNAME} =~ /MINGW32/i) { print FILEHANDLE "#define IS_MINGW\n"; } - if ($config{OSNAME} =~ /CYG-STATIC/i) { - print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE 1024\n#endif\n"; - } - if ($config{STATIC_LINK} eq "yes") { - print FILEHANDLE "#define STATIC_LINK\n"; - } if ($config{GCCVER} >= 3) { print FILEHANDLE "#define GCC3\n"; } @@ -1070,7 +1168,7 @@ print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n"; #ifndef __CONFIGURATION_SOCKETENGINE__ #define __CONFIGURATION_SOCKETENGINE__ -#include "$se.h" +#include "socketengines/$se.h" #endif EOF @@ -1082,12 +1180,7 @@ EOF my $modules = ""; foreach $i (@modlist) { - if ($config{STATIC_LINK} eq "yes") { - $modules .= "m_".$i.".o "; - } - else { - $modules .= "m_".$i.".so "; - } + $modules .= "m_".$i.".so "; } chomp($modules); # Remove Redundant whitespace.. @@ -1097,6 +1190,7 @@ EOF if (opendir(MDIRHANDLE, "src/modules/$name") != 0) { closedir(MDIRHANDLE); $modules .= "$name.so "; + $uninstall_list = $uninstall_list . " -rm \$(MODULES)/$name.so\n"; } } } @@ -1108,12 +1202,6 @@ EOF my $file = ""; my $exe = "inspircd"; - if ($config{OSNAME} =~ /CYGWIN/i) { - $exe = "inspircd.exe"; - } - - opendir(DIRHANDLE, $this); - # 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. @@ -1123,25 +1211,31 @@ EOF chomp(my $revision = getrevision()); $version = "$version(r$revision)"; - my $LIBEXT = "so"; - if ($config{IS_DARWIN} eq "YES") - { - $LIBEXT = "dylib"; - } # 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 \033[1;32mMakefiles\033[0m\n"; + write_dynamic_modules_makefile(); + write_dynamic_makefile(); + + opendir(DIRHANDLE, $this); + foreach $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"); + open(FILEHANDLE, ".$file.inc") or die ("Can't open .$file.inc"); while () { $tmp .= $_; } close(FILEHANDLE); + print "Writing \033[1;32m$file\033[0m ...\n"; $tmp =~ s/\@CC\@/$config{CC}/; $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/; $tmp =~ s/\@FLAGS\@/$config{FLAGS}/; @@ -1152,17 +1246,16 @@ EOF $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/; $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/; $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/; - $tmp =~ s/\@LIBRARY_EXT\@/$LIBEXT/; $tmp =~ s/\@MODULES\@/$modules/; $tmp =~ s/\@STARTSCRIPT\@/$config{STARTSCRIPT}/; $tmp =~ s/\@DESTINATION\@/$config{DESTINATION}/; $tmp =~ s/\@EXTRA_DIR\@/$config{EXTRA_DIR}/; $tmp =~ s/\@EXECUTABLE\@/$exe/; $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/; - $tmp =~ s/\@STATICLIBS\@/$config{STATICLIBS}/; $tmp =~ s/\@VERSION\@/$version/; + $tmp =~ s/\@INSTALL_LIST\@/$install_list/; + $tmp =~ s/\@UNINSTALL_LIST\@/$uninstall_list/; - print "Writing \033[1;32m$file\033[0m\n"; open(FILEHANDLE, ">$file"); print FILEHANDLE $tmp; } @@ -1171,150 +1264,46 @@ EOF # Make inspircd executable! chmod 0744, 'inspircd'; - - if ($config{STATIC_LINK} eq "yes") { - print "Writing static-build \033[1;32msrc/Makefile\033[0m\n"; - write_static_makefile(); - write_static_modules_makefile(); - } elsif ($config{OSNAME} =~ /CYGWIN/i) { - print "Writing cygwin-build \033[1;32msrc/Makefile\033[0m\n"; - write_static_makefile(); - write_dynamic_modules_makefile(); - } else { - print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n"; - write_dynamic_makefile(); - write_dynamic_modules_makefile(); - } } -sub write_static_modules_makefile { +sub write_dynamic_modules_makefile { # Modules Makefile.. print "Writing \033[1;32msrc/modules/Makefile\033[0m\n"; open(FILEHANDLE, ">src/modules/Makefile"); - ### - # Module Makefile Header - ### +### +# Module Makefile Header +### print FILEHANDLE < -# for assisting with making this work right. +# for assisting with making this work right. # # Automatically Generated by ./configure to add a -# modules please run ./configure --modupdate +# modules please run ./configure -modupdate ################################################### all: \$(MODULES) EOF - ### - # End Module Makefile Header - ### - - # Create a Modules List.. - my $modules = ""; - my $cmflags = ""; - my $liflags = ""; - - open(MODLIST,">include/modlist.h"); - ### - # Include File Header - ### - print MODLIST <src/modules/.m_".$i."_static.cpp") or die("Could not create .m_".$i."_static.cpp"); - while (chomp($a = )) { - $a =~ s/init_module/$i\_init/g; - print MUNGED "$a\n"; - } - close(MODULE); - close(MUNGED); - print MODLIST <src/modules/Makefile"); - my $extra = ""; - - if ($config{OSNAME} =~ /CYGWIN/i) { - $extra = "../inspircd.dll.a"; - } - -### -# Module Makefile Header -### - print FILEHANDLE < -# for assisting with making this work right. -# -# Automatically Generated by ./configure to add a -# modules please run ./configure -modupdate -################################################### - -all: \$(MODULES) - -EOF ### # End Module Makefile Header ### @@ -1323,8 +1312,6 @@ EOF my $modules = ""; my $cmflags = ""; my $liflags = ""; - my $crud = ""; - foreach $i (@modlist) { ### # Write Entry to the MakeFile @@ -1335,23 +1322,26 @@ EOF #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n"; - print FILEHANDLE <src/Makefile") or die("Could not write src/Makefile!"); - my $i = 0; - my @cmdlist = (); - opendir(DIRHANDLE, "src"); - foreach $name (sort readdir(DIRHANDLE)) { - if ($name =~ /^cmd_(.+)\.cpp$/) { - $cmdlist[$i++] = $1; - } +sub read_module_directory { + my ($dpath, $reldpath) = @_; + + if (opendir(MDIRHANDLE, $dpath) == 0) { + return; } - closedir(DIRHANDLE); - my $cmdobjs = ""; - my $srcobjs = ""; - foreach my $cmd (@cmdlist) { - $cmdobjs = $cmdobjs . "cmd_$cmd.o "; - $srcobjs = $srcobjs . "cmd_$cmd.cpp "; + + 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); + } } - print FH < -# for assisting with making this work right. -# -# This file is automagically generated by configure -# Any changes made will be lost on ./configure -################################################### - -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 - -$se = "socketengine_select"; -if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) { - $se = "socketengine_kqueue"; -} -elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) { - $se = "socketengine_epoll"; -} -elsif (($has_ports) && ($config{USE_PORTS} eq "y")) { - $se = "socketengine_ports"; } - ### - # This next section is for cygwin dynamic module builds. - # Basically, what we do, is build the inspircd core as a library - # then the main executable uses that. the library is capable of - # loading / unloading the modules dynamically :) - # Massive thanks to the guys on #cygwin @ irc.freenode.net for helping - # make this work :) - ### +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++. - if ($config{OSNAME} =~ /CYGWIN/i) { - print FH <)) + { + if ($line =~ /#include "(.+\.h)"/) + { + if (!exists($dupe{$1})) + { + $retlist = $retlist . "../include/$1 "; + $dupe{$1} = 1; + } + } } - close(FH); + close CPP; + return length($immutable) ? $immutable . " " . $retlist : $retlist; } -sub write_dynamic_makefile { - +sub write_dynamic_makefile +{ my $i = 0; my @cmdlist = (); - opendir(DIRHANDLE, "src"); - foreach $name (sort readdir(DIRHANDLE)) { - if ($name =~ /^cmd_(.+)\.cpp$/) { + my %existing_install_list = (); + opendir(DIRHANDLE, "src/commands"); + foreach $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); - my $cmdobjs = ""; - my $srcobjs = ""; - foreach my $cmd (@cmdlist) { - $cmdobjs = $cmdobjs . "cmd_$cmd.so "; - $srcobjs = $srcobjs . "cmd_$cmd.cpp "; + if (!$has_epoll) + { + $config{USE_EPOLL} = 0; + } + if (!$has_kqueue) + { + $config{USE_KQUEUE} = 0; + } + if (!$has_ports) + { + $config{USE_PORTS} = 0; } - $se = "socketengine_select"; - if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) { - $se = "socketengine_kqueue"; + foreach my $dir (("src","src/commands","src/modes","src/socketengines","src/modules")) + { + print "Scanning \033[1;32m$dir\033[0m for core files "; + opendir(DIRHANDLE, $dir); + foreach $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 (chomp($line = )) + { + if ($line =~ /\/\* \$Core: (\w+) \*\//i) + { + $filelist{$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 (($config{$1} !~ /y/i) and ($config{$1} ne "1")) + { + # Skip to 'endif' + while (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; + $idir = (split(' ',$1))[1]; + $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; + $idir = (split(' ',$1))[1]; + $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"; } - elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) { - $se = "socketengine_epoll"; + + $freebsd4libs = $config{CRAQ}; + + my $all = "all: "; + $all_libsonly = ""; + + if ($config{IS_DARWIN} eq "YES") + { + $libraryext = "dylib"; + $othercrap = " \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd.cpp\n \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o " + } + else + { + $libraryext = "so"; + $RPATH = "-Wl,--rpath -Wl,$config{LIBRARY_DIR}" unless defined $opt_disablerpath; + $othercrap = " \$(CC) -pipe -I../include $RPATH \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) "; } - elsif (($has_ports) && ($config{USE_PORTS} eq "y")) { - $se = "socketengine_ports"; + + foreach my $cpp (sort keys %filelist) + { + $all = $all . $filelist{$cpp} . "." . $libraryext . " "; + $all_libsonly = $all_libsonly . $filelist{$cpp} . "." . $libraryext . " "; + $install_list = $install_list . " -install -m \$(INSTMODE) src/" . $filelist{$cpp} . "." . $libraryext . " \$(LIBPATH)\n"; + $uninstall_list = $uninstall_list . " -rm \$(LIBPATH)/" . $filelist{$cpp} . "." . $libraryext . "\n"; } + $all = $all . "moo inspircd\n"; + + $othercrap = $othercrap . " $all_libsonly\n\n"; open(FH,">src/Makefile") or die("Could not write src/Makefile"); print FH < -# for assisting with making this work right. -# -# This file is automagically generated by configure -# Any changes made will be lost on ./configure -################################################### 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 -if ($config{IS_DARWIN} eq "YES") { - print FH <src/commands/Makefile") or die("Could not write src/commands/Makefile"); + print FH <