From 4fd09d8d677edd42f3f0a75ec7091f8a095a0908 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 22 Oct 2007 18:13:45 +0000 Subject: *POSSIBLE BREAKAGE WARNING* new (currently undocumented) buildsystem that builds an operating system specific makefile from a set of hashes/arrays in configure that are OS independent git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8304 e03df62e-2008-0410-955e-edbf42e46eb7 --- configure | 403 +++++++++++++++++++++++++------------------------------------- 1 file changed, 165 insertions(+), 238 deletions(-) (limited to 'configure') diff --git a/configure b/configure index d538c1b33..d87a8f7c1 100755 --- a/configure +++ b/configure @@ -23,6 +23,58 @@ use make::configure; use make::gnutlscert; use make::opensslcert; + my %filelist = ( + "channels.cpp" => "libIRCDchannels", + "mode.cpp" => "libIRCDmode", + "xline.cpp" => "libIRCDxline", + "inspstring.cpp"=> "libIRCDstring", + "dns.cpp" => "libIRCDasyncdns", + "base.cpp" => "libIRCDbase", + "configreader.cpp"=> "libIRCDconfigreader", + "inspsocket.cpp"=> "libIRCDinspsocket", + "commands.cpp" => "libIRCDcommands", + "dynamic.cpp" => "libIRCDdynamic", + "users.cpp" => "libIRCDusers", + "modules.cpp" => "libIRCDmodules", + "wildcard.cpp" => "libIRCDwildcard", + "helperfuncs.cpp"=> "libIRCDhelper", + "hashcomp.cpp" => "libIRCDhash", + "socket.cpp" => "libIRCDsocket", + "socketengine.cpp"=> "libIRCDsocketengine", + "userprocess.cpp"=> "libIRCDuserprocess", + "cull_list.cpp"=> "libIRCDcull_list", + "command_parse.cpp"=> "libIRCDcommand_parse", + "timer.cpp" => "libIRCDtimer", + "snomasks.cpp" => "libIRCDsnomasks", + "server.cpp" => "libIRCDserver", + "filelogger.cpp"=> "libIRCDfilelogger", + "user_resolver.cpp"=> "libIRCDuserresolver", + ); + + my %specialdeps = ( + "mode.cpp" => "\$(RELCPPFILES)", + ); + + my %extrabuildlines = ( + "mode.cpp" => "\${MAKE} -C \"modes\" DIRNAME=\"src/modes\" CC=\"\$(CC)\" \$(MAKEARGS) CPPFILES=\"\$(CPPFILES)\"", + ); + + my %extraobjects = ( + "mode.cpp" => "modes/modeclasses.a" + ); + + my %extrasources = ( + ); + + my @ignoredeps = ( + "inspircd_win32wrapper.h", + ); + + my @immutabledeps = ( + "inspircd_config.h", + ); + + GetOptions ( 'enable-gnutls' => \$opt_use_gnutls, 'rebuild' => \$opt_rebuild, @@ -1328,6 +1380,45 @@ sub read_module_directory { } } +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 (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; @@ -1351,258 +1442,94 @@ sub write_dynamic_makefile { $se = "socketengine_ports"; } + $extrasources{"socketengine.cpp"} = $se . ".cpp"; + $extraobjects{"socketengine.cpp"} = $se . ".o"; + $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"; + $othercrap = " \$(CC) -pipe -I../include -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) "; + } + + foreach my $cpp (sort keys %filelist) + { + $all = $all . $filelist{$cpp} . "." . $libraryext . " "; + $all_libsonly = $all_libsonly . $filelist{$cpp} . "." . $libraryext . " "; + } + $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 <