]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - configure
Disable test suite
[user/henk/code/inspircd.git] / configure
1 #!/usr/bin/perl
2
3 # InspIRCd Configuration Script
4 #
5 # Copyright 2003 The ChatSpike Development Team
6 # <brain@chatspike.net>
7 # <Craig@chatspike.net>
8 #
9 # [14:21] Brain: <matrix impression> i know perl-fu!
10 #
11 # $Id$
12 #
13 ########################################
14
15 chomp($topdir = `pwd`);
16 $this = resolve_directory($topdir);                                             # PWD, Regardless.
17 @modlist = ();                                                                  # Declare for Module List..
18 %config = ();                                                                   # Initiate Configuration Hash..
19 $config{ME}                 = resolve_directory($topdir);                       # Present Working Directory
20 $config{BASE_DIR}           = $config{ME};                                      # Use CWD as 'Base' Directory.
21 $config{CONFIG_DIR}         = resolve_directory($config{ME}."/conf");           # Configuration Directory
22 $config{MODULE_DIR}         = resolve_directory($config{ME}."/modules");        # Modules Directory
23 $config{BINARY_DIR}         = resolve_directory($config{ME}."/bin");            # Binary Directory
24 $config{LIBRARY_DIR}        = resolve_directory($config{ME}."/lib");            # Library Directory
25 chomp($config{HAS_GNUTLS}   = `libgnutls-config --version 2>/dev/null | cut -c 1,2,3`); # GNUTLS Version.
26 chomp($config{HAS_OPENSSL}  = `openssl version 2>/dev/null`);                   # Openssl version
27 $config{USE_GNUTLS}         = "n";                                              # Use gnutls.
28 $config{USE_OPENSSL}        = "n";                                              # Use openssl.
29 $config{OPTIMITEMP}         = "0";                                              # Default Optimisation Value
30 $config{OPTIMISATI}         = "-g";                                             # Optimisation Flag
31 $config{NICK_LENGT}         = "31";                                             # Default Nick Length
32 $config{CHAN_LENGT}         = "64";                                             # Default Channel Name Length
33 $config{MAX_CHANNE}         = "20";                                             # Default Max. Channels per user
34 $config{MAX_OPERCH}         = "60";                                             # Default Max. Channels per oper
35 $config{MAXI_MODES}         = "20";                                             # Default Max. Number of Modes set at once.
36 $config{HAS_STRLCPY}        = "false";                                          # strlcpy Check.
37 $config{HAS_STDINT}         = "false";                                          # stdint.h check
38 $config{HAS_EXECINFO}       = "0";                                              # execinfo.h Check.
39 $config{USE_KQUEUE}         = "y";                                              # kqueue enabled
40 $config{USE_EPOLL}          = "y";                                              # epoll enabled
41 $config{THREADED_DNS}       = "n";                                              # threaded dns (experimental)
42 $config{IPV6}               = "n";                                              # IPv6 support (experimental)
43 $config{STATIC_LINK}        = "no";                                             # are doing static modules?
44 chomp($config{MAX_CLIENT_T} = `sh -c \"ulimit -n\"`);                           # FD Limit
45 chomp($config{MAX_DESCRIPTORS} = `sh -c \"ulimit -n\"`);                        # Hard FD Limit
46 chomp($config{GCCVER}       = `g++ -dumpversion | cut -c 1`);                   # Major GCC Version
47 chomp($config{OSNAME}       = `/bin/uname`);                                    # Operating System Name
48 $config{CC}                 = "g++";                                            # C++ compiler
49 $config{MAKEORDER}          = "ircd mods";                                      # build order
50 $config{STATICLIBS}         = "";                                               # library archive path
51 $config{MAX_IDENT}          = "12";                                             # max ident size
52 $config{MAX_QUIT}           = "255";                                            # max quit message size
53 $config{MAX_TOPIC}          = "307";                                            # max topic size
54 $config{MAX_KICK}           = "255";                                            # max kick message size
55 $config{MAX_GECOS}          = "128";                                            # max GECOS size
56 $config{MAX_AWAY}           = "200";                                            # max AWAY size
57
58 $no_svn = 0;
59
60 $config{HAS_OPENSSL} =~ /OpenSSL (\S+) \d+ \S+ \d{4}/;
61 $config{HAS_OPENSSL} = $1;
62
63 if ($config{GCCVER} eq "") {
64         print "g++ was not found! You require g++ (the GNU C++ compiler, part of GCC) to build InspIRCd!\n";
65         return 0;
66 }
67
68 # Minihack! Convert Cygwin to 'Cyg-Static' so i can
69 # Keep my dynamic module experiments here for later
70 # concideration!
71
72 if ($config{OSNAME} =~ /CYGWIN/) {
73         $config{OSNAME} = "CYG-STATIC";
74 }
75
76 if ((!$config{OSNAME}) || ($config{OSNAME} eq "")) {
77         chomp($config{OSNAME} = `/usr/bin/uname`);
78         if ((!$config{OSNAME}) || ($config{OSNAME} eq "")){
79                 $config{OSNAME} = "Unknown";
80         }
81 }
82
83 if (!$config{MAX_CLIENT_T}) { 
84         $config{MAX_CLIENT_T} = 1024;                                 # Set a reasonable 'Default'
85         $fd_scan_fail = "true";                                       # Used Later
86 }
87
88 # Get and Set some important vars..
89 getmodules();
90
91 my $arg = $ARGV[0];                                             # Do Some Argument Checks..
92 if ($arg eq "-clean") {
93         system("rm -rf .config.cache");
94 }               # Remove the config.cache file.
95
96 if ($arg eq "-update") {
97         # Does the cache file exist?
98         if (!getcache()) {
99                 # No, No it doesn't.. *BASH*
100                 print "You have not run ./configure before. Please do this before trying to run the update script.\n";
101                 exit 0;
102         } else {
103                 # We've Loaded the cache file and all our variables..
104                 print "Updating Files..\n";
105                 getosflags();
106                 $has_epoll = $config{HAS_EPOLL};
107                 $has_kqueue = $config{HAS_KQUEUE};
108                 writefiles(1);
109                 print "Complete.\n";
110                 exit;
111         }
112 }
113
114 if ($arg eq "-modupdate") {
115         # Does the cache file exist?
116         if (!getcache()) {
117                 # No, No it doesn't.. *BASH*
118                 print "You have not run ./configure before. Please do this before trying to run the update script.\n";
119                 exit 0;
120         } else {
121                 # We've Loaded the cache file and all our variables..
122                 print "Updating Files..\n";
123                 getosflags();
124                 $has_epoll = $config{HAS_EPOLL};
125                 $has_kqueue = $config{HAS_KQUEUE};
126                 writefiles(0);
127                 print "Complete.\n";
128                 exit;
129         }
130 }
131
132
133
134 if ($arg eq "-svnupdate") {
135         my $fail = 0;
136         open(FH,"<.svn/entries") or $fail = 1;
137         if ($fail) {
138                 print "This is not an SVN copy of InspIRCd.\n";
139                 exit;
140         }
141         system("svn update");
142         system("perl configure -update");
143         if ($ARGV[1] eq "rebuild") {
144                 system("make install");
145         }
146         exit;
147 }
148
149 print "Checking for cache from previous configure...\n";
150 getcache();
151 print "Checking operating system version...\n";
152 getosflags();
153
154 if (!$config{MAX_CLIENT}) { 
155         # If the cache hasn't set the max clients, copy the variable of MAX_CLIENT_T, this
156         # allows us to keep _T for testing purposes. (ie. "Are you sure you want to go
157         # higher than the found value" :))
158         $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
159 }
160
161 printf "Checking if stdint.h exists... ";
162 $config{HAS_STDINT} = "true";
163 my $fail = 0;
164 open(STDINT, "</usr/include/stdint.h") or $config{HAS_STDINT} = "false";
165 if ($config{HAS_STDINT} eq "true") {
166         close(STDINT);
167 }
168 print "yes\n" if $config{HAS_STDINT} eq "true";
169 print "no\n" if $config{HAS_STDINT} eq "false";
170
171
172 printf "Checking if strlcpy exists... ";
173 # Perform the strlcpy() test..
174 $config{HAS_STRLCPY} = "false";
175 my $fail = 0;
176 open(STRLCPY, "</usr/include/string.h") or $fail = 1;
177 if (!$fail) {
178         while (chomp($line = <STRLCPY>)) {
179                 # try and find the delcaration of:
180                 # size_t strlcpy(...)
181                 if ($line =~ /size_t(\0x9|\s)+strlcpy/) {
182                         $config{HAS_STRLCPY} = "true";
183                 }
184         }
185         close(STRLCPY);
186 }
187 print "yes\n" if $config{HAS_STRLCPY} eq "true";
188 print "no\n" if $config{HAS_STRLCPY} eq "false";
189
190 printf "Checking if execinfo.h exists... ";
191 $config{HAS_EXECINFO} = "0";
192 my $fail = 0;
193 open(EXECINFO, "</usr/include/execinfo.h") or $fail = 1;
194 if ($fail) {
195         $fail = 0;
196         open(EXECINFO, "</usr/local/include/execinfo.h") or $fail = 1;
197         if (!$fail) {
198                 printf "/usr/local/include/execinfo.h\n";
199                 $config{HAS_EXECINFO} = "1";
200                 close(EXECINFO);
201         }
202         else {
203                 printf "Not found!\n";
204         }
205 }
206 else {
207         printf "/usr/include/execinfo.h\n";
208         $config{HAS_EXECINFO} = "1";
209         close(EXECINFO);
210 }
211
212 printf "Checking if kqueue exists... ";
213 $has_kqueue = 0;
214 $fail = 0;
215 open(KQUEUE, "</usr/include/sys/event.h") or $fail = 1;
216 if (!$fail) {
217         while (chomp($line = <KQUEUE>)) {
218                 # try and find the delcaration of:
219                 # int kqueue(void);
220                 if ($line =~ /int(\0x9|\s)+kqueue/) {
221                         $has_kqueue = 1;
222                 }
223         }
224         close(KQUEUE);
225 }
226 print "yes\n" if $has_kqueue == 1;
227 print "no\n" if $has_kqueue == 0;
228
229 printf "Checking if epoll exists... ";
230 $has_epoll = 0;
231 $fail = 0;
232 open(EPOLL, "</usr/include/sys/epoll.h") or $fail = 1;
233 if (!$fail) {
234         $has_epoll = 1;
235         close(EPOLL);
236 }
237 if ($has_epoll) {
238         my $kernel = `uname -r`;
239         chomp($kernel);
240         if (($kernel =~ /2\.0/) || ($kernel =~ /2\.2/) || ($kernel =~ /2\.4/)) {
241                 $has_epoll = 0;
242         }
243 }
244 print "yes\n" if $has_epoll == 1;
245 print "no\n" if $has_epoll == 0;
246
247 if (($config{OSNAME} =~ /CYGWIN/) || ($config{OSNAME} eq "CYG-STATIC")) {
248         $config{HAS_STRLCPY} = "true";
249 }
250
251 $config{HAS_EPOLL} = $has_epoll;
252 $config{HAS_KQUEUE} = $has_kqueue; 
253
254 printf "Checking for libgnutls... ";
255 if (($config{HAS_GNUTLS}) && (($config{HAS_GNUTLS} >= 1.2) || ($config{HAS_GNUTLS} eq "y"))) {
256         print "yes\n";
257         $config{HAS_GNUTLS} = "y";
258 } else {
259         print "no\n";
260         $config{HAS_GNUTLS} = "n";
261 }
262
263 printf "Checking for openssl... ";
264 if (($config{HAS_OPENSSL}) && (($config{HAS_OPENSSL} >= 0.8) || ($config{HAS_OPENSSL} eq "y"))) {
265         print "yes\n";
266         $config{HAS_OPENSSL} = "y";
267 } else {
268         print "no\n";
269         $config{HAS_OPENSSL} = "n";
270 }
271
272 ################################################################################
273 #                          BEGIN INTERACTIVE PART                              #
274 ################################################################################
275
276 # Clear the Screen..
277 system("clear");
278 # Display Splash Logo..
279 show_splash();
280 chomp($wholeos = `uname -mnr`);
281
282 my $rev = getrevision();
283 # Display Introduction Message..
284 print "
285 Welcome to the InspIRCd Configuration program!
286
287 *** If you are unsure of any of these values, leave it blank for    ***
288 *** standard settings that will work, and your server will run      ***
289 *** using them. If you are running this server as part of a         ***
290 *** larger network, you must consult with your network admins       ***
291 *** for the proper values to use, or server links will be unstable! ***
292
293 Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter
294 a new value. Please note: You will \033[1mHAVE\033[0m to read the docs
295 dir, otherwise you won't have a config file!
296
297 Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos), fdmax: $config{MAX_CLIENT_T}
298 Your InspIRCd revision ID is \033[1;32mr$rev\033[0m";
299 if ($rev eq "r0") {
300         print " (Non-SVN build)";
301 }
302 print ".\n\n";
303
304 $config{CHANGE_COMPILER} = "n";
305 print "I have detected the following compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.x\033[0m)\n";
306
307 while (($config{GCCVER} < 3) || ($config{GCCVER} eq "")) {
308         print "\033[1;32mIMPORTANT!\033[0m A GCC 2.x compiler has been detected, and
309 should NOT be used. You should probably specify a newer compiler.\n\n";
310         yesno(CHANGE_COMPILER,"Do you want to change the compiler?");
311         if ($config{CHANGE_COMPILER} =~ /y/i) {
312                 print "What command do you want to use to invoke your compiler?\n";
313                 print "[\033[1;32m$config{CC}\033[0m] -> ";
314                 chomp($config{CC} = <STDIN>);
315                 if ($config{CC} eq "") {
316                         $config{CC} = "g++";
317                 }
318                 chomp($foo = `$config{CC} -dumpversion | cut -c 1`);
319                 if ($foo ne "") {
320                         chomp($config{GCCVER}       = `$config{CC} -dumpversion | cut -c 1`); # we must redo these if we change compilers
321                         print "Queried compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.x\033[0m)\n";
322                         if ($config{GCCVER} < 3) {
323                                 print "\033[1;32mGCC 2.x WILL NOT WORK!\033[0m. Let's try that again, shall we?\n";
324                         }
325                 }
326                 else {
327                         print "\033[1;32mWARNING!\033[0m Could not execute the compiler you specified. You may want to try again.\n";
328                 }
329         }
330 }
331
332 print "\n";
333
334 # Directory Settings..
335 my $tmpbase = $config{BASE_DIR};
336 dir_check("do you wish to install the InspIRCd base", "BASE_DIR");
337 if ($tmpbase ne $config{BASE_DIR}) {
338         $config{CONFIG_DIR}         = resolve_directory($config{BASE_DIR}."/conf");           # Configuration Directory
339         $config{MODULE_DIR}         = resolve_directory($config{BASE_DIR}."/modules");        # Modules Directory
340         $config{BINARY_DIR}         = resolve_directory($config{BASE_DIR}."/bin");            # Binary Directory
341         $config{LIBRARY_DIR}        = resolve_directory($config{BASE_DIR}."/lib");            # Library Directory
342 }
343
344 dir_check("are the configuration files", "CONFIG_DIR");
345 dir_check("are the modules to be compiled to", "MODULE_DIR");
346 dir_check("is the IRCd binary to be placed", "BINARY_DIR");
347 dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
348
349 if ($has_kqueue) {
350         yesno(USE_KQUEUE,"You are running a BSD operating system, and kqueue\nwas detected. Would you like to enable kqueue support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable kqueue?");
351         print "\n";
352 }
353 if ($has_epoll) {
354         yesno(USE_EPOLL,"You are running a Linux 2.6+ operating system, and epoll\nwas detected. Would you like to enable epoll support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable epoll?");
355         print "\n";
356 }
357 $chose_hiperf = (($config{USE_EPOLL} eq "y") || ($config{USE_KQUEUE} eq "y"));
358 if (!$chose_hiperf) {
359         print "No high-performance socket engines are available, or you chose\n";
360         print "not to enable one. Defaulting to select() engine.\n\n";
361 }
362
363 yesno(THREADED_DNS,"Would you like to enable the experimental multi-threaded DNS lookup?");
364 print "\n";
365
366 yesno(IPV6,"Would you like to enable IPv6 support?");
367 print "\n";
368
369 if (($config{HAS_GNUTLS} eq "y") && ($config{HAS_OPENSSL} eq "y")) {
370         print "I have detected both GnuTLS and OpenSSL on your system.\n";
371         print "I will default to GnuTLS. If you wish to use OpenSSL\n";
372         print "instead, you should enable the OpenSSL module yourself\n";
373         print "by copying it from src/modules/extra to src/modules.\n\n";
374 }
375
376 if ($config{HAS_GNUTLS} eq "y") {
377         yesno(USE_GNUTLS, "Would you like to enable SSL Support?");
378         if ($config{USE_GNUTLS} eq "y") {
379                 print "\nUsing GnuTLS SSL module.\n";
380         }
381 } elsif ($config{HAS_OPENSSL} eq "y") {
382         yesno(USE_OPENSSL, "Would you like to enable SSL Support?");
383         if ($config{USE_OPENSSL} eq "y") {
384                 print "\nUsing OpenSSL SSL module.\nYou will get better performance if you move to GnuTLS in the future.\n";
385         }
386 }
387
388 print "\nThe following questions will ask you for various figures relating\n";
389 print "To your IRCd install. Please note that these should usually be left\n";
390 print "as defaults unless you have a real reason to change them. If they\n";
391 print "changed, then the values must be identical on all servers on your\n";
392 print "network, or malfunctions and/or crashes may occur, with the exception\n";
393 print "of the 'maximum number of clients' setting which may be different on\n";
394 print "different servers on the network.\n\n";
395
396 # File Descriptor Settings..
397 my $continue = 0;
398 while (!$continue) {
399         print "Maximum number of clients at any one time ($config{MAX_CLIENT_T})\n";
400         print "[\033[1;32m$config{MAX_CLIENT}\033[0m] -> ";
401         chomp($var = <STDIN>);
402         if ($var eq "") {
403                 $var = $config{MAX_CLIENT};
404         }
405         if ($var =~ /^\d+$/) {
406                 if (($var > $config{MAX_CLIENT_T}) && ($fd_scan_failed ne true)) {
407                         # Client has entered a larger number than the 'discovered' value
408                         # Confirm.
409                         print "WARNING: Our scans have indicated that you are attempting
410 to use more sockets than there are avaliable. Are you sure
411 you wish to do this? It may cause the IRCd to malfunction [y/n]
412 [\033[1;32mn\033[0m] -> $c";
413                         chomp($tmp = <STDIN>);
414                         if ($tmp ne "y") {
415                                 print "Please enter the correct value.\n\n";
416                                 next;
417                         }
418                 }
419         } else {
420                 print "You must enter a number in this field. Please try again.\n\n";
421                 next;
422         }
423         # If we get here, we should be good to go.
424         $config{MAX_CLIENT} = $var;
425         $continue = 1;
426         print "\n";
427 }
428
429 my $continue = 0;
430 while (!$continue) {
431         print "What is the maximum length of nicknames?\n";
432         print "[\033[1;32m$config{NICK_LENGT}\033[0m] -> ";
433         chomp($var = <STDIN>);
434         if ($var eq "") {
435                 $var = $config{NICK_LENGT};
436         }
437         if ($var =~ /^\d+$/) {
438                 # We don't care what the number is, set it and be on our way.
439                 $config{NICK_LENGT} = $var;
440                 $continue = 1;
441                 print "\n";
442         } else {
443                 print "You must enter a number in this field. Please try again.\n\n";
444         }
445 }
446
447 $continue = 0;
448 while (!$continue) {
449         print "What is the maximum length of channel names?\n";
450         print "[\033[1;32m$config{CHAN_LENGT}\033[0m] -> ";
451         chomp($var = <STDIN>);
452         if ($var eq "") {
453                 $var = $config{CHAN_LENGT};
454         }
455         if ($var =~ /^\d+$/) {
456                 # We don't care what the number is, set it and be on our way.
457                 $config{CHAN_LENGT} = $var;
458                 $continue = 1;
459                 print "\n";
460         } else {
461                 print "You must enter a number in this field. Please try again.\n\n";
462         }
463 }
464
465 $continue = 0;
466 while (!$continue) {
467         print "What is the maximum number of channels a normal user may join at any one time?\n";
468         print "[\033[1;32m$config{MAX_CHANNE}\033[0m] -> ";
469         chomp($var = <STDIN>);
470         if ($var eq "") {
471                 $var = $config{MAX_CHANNE};
472         }
473         if ($var =~ /^\d+$/) {
474                 # We don't care what the number is, set it and be on our way.
475                 $config{MAX_CHANNE} = $var;
476                 $continue = 1;
477                 print "\n";
478         } else {
479                 print "You must enter a number in this field. Please try again.\n\n";
480         }
481 }
482
483 $continue = 0;
484 while (!$continue) {
485         print "What is the maximum number of channels an oper may join at any one time?\n";
486         print "[\033[1;32m$config{MAX_OPERCH}\033[0m] -> ";
487         chomp($var = <STDIN>);
488         if ($var eq "") {
489                 $var = $config{MAX_OPERCH};
490         }
491         if ($var =~ /^\d+$/) {
492                 # We don't care what the number is, set it and be on our way.
493                 $config{MAX_OPERCH} = $var;
494                 $continue = 1;
495                 print "\n";
496         }
497 }
498
499 $continue = 0;
500 while (!$continue) {
501         print "What is the maximum number of mode changes in one line?\n";
502         print "[\033[1;32m$config{MAXI_MODES}\033[0m] -> ";
503         chomp($var = <STDIN>);
504         if ($var eq "") {
505                 $var = $config{MAXI_MODES};
506         }
507         if ($var =~ /^\d+$/) {
508                 # We don't care what the number is, set it and be on our way.
509                 $config{MAXI_MODES} = $var;
510                 $continue = 1;
511                 print "\n";
512         } else {
513                 print "You must enter a number in this field. Please try again.\n\n";
514         }
515 }
516
517 $continue = 0;
518 while (!$continue) {
519         print "What is the maximum length of an ident (username)?\n";
520         print "[\033[1;32m$config{MAX_IDENT}\033[0m] -> ";
521         chomp($var = <STDIN>);
522         if ($var eq "") {
523                 $var = $config{MAX_IDENT};
524         }
525         if ($var =~ /^\d+$/) {
526                 # We don't care what the number is, set it and be on our way.
527                 $config{MAX_IDENT} = $var;
528                 $continue = 1;
529                 print "\n";
530         } else {
531                 print "You must enter a number in this field. Please try again.\n\n";
532         }
533 }
534
535 $continue = 0;
536 while (!$continue) {
537         print "What is the maximum length of a quit message?\n";
538         print "[\033[1;32m$config{MAX_QUIT}\033[0m] -> ";
539         chomp($var = <STDIN>);
540         if ($var eq "") {
541                 $var = $config{MAX_QUIT};
542         }
543         if ($var =~ /^\d+$/) {
544                 # We don't care what the number is, set it and be on our way.
545                 $config{MAX_QUIT} = $var;
546                 $continue = 1;
547                 print "\n";
548         } else {
549                 print "You must enter a number in this field. Please try again.\n\n";
550         }
551 }
552
553 $continue = 0;
554 while (!$continue) {
555         print "What is the maximum length of a channel topic?\n";
556         print "[\033[1;32m$config{MAX_TOPIC}\033[0m] -> ";
557         chomp($var = <STDIN>);
558         if ($var eq "") {
559                 $var = $config{MAX_TOPIC};
560         }
561         if ($var =~ /^\d+$/) {
562                 # We don't care what the number is, set it and be on our way.
563                 $config{MAX_TOPIC} = $var;
564                 $continue = 1;
565                 print "\n";
566         } else {
567                 print "You must enter a number in this field. Please try again.\n\n";
568         }
569 }
570
571 $continue = 0;
572 while (!$continue) {
573         print "What is the maximum length of a kick message?\n";
574         print "[\033[1;32m$config{MAX_KICK}\033[0m] -> ";
575         chomp($var = <STDIN>);
576         if ($var eq "") {
577                 $var = $config{MAX_KICK};
578         }
579         if ($var =~ /^\d+$/) {
580                 # We don't care what the number is, set it and be on our way.
581                 $config{MAX_KICK} = $var;
582                 $continue = 1;
583                 print "\n";
584         } else {
585                 print "You must enter a number in this field. Please try again.\n\n";
586         }
587 }
588
589 $continue = 0;
590 while (!$continue) {
591         print "What is the maximum length of a GECOS (real name) field?\n";
592         print "[\033[1;32m$config{MAX_GECOS}\033[0m] -> ";
593         chomp($var = <STDIN>);
594         if ($var eq "") {
595                 $var = $config{MAX_GECOS};
596         }
597         if ($var =~ /^\d+$/) {
598                 # We don't care what the number is, set it and be on our way.
599                 $config{MAX_GECOS} = $var;
600                 $continue = 1;
601                 print "\n";
602         } else {
603                 print "You must enter a number in this field. Please try again.\n\n";
604         }
605 }
606
607 $continue = 0;
608 while (!$continue) {
609         print "What is the maximum length of an away message?\n";
610         print "[\033[1;32m$config{MAX_AWAY}\033[0m] -> ";
611         chomp($var = <STDIN>);
612         if ($var eq "") {
613                 $var = $config{MAX_AWAY};
614         }
615         if ($var =~ /^\d+$/) {
616                 # We don't care what the number is, set it and be on our way.
617                 $config{MAX_AWAY} = $var;
618                 $continue = 1;
619                 print "\n";
620         } else {
621                 print "You must enter a number in this field. Please try again.\n\n";
622         }
623 }
624
625 # Code Optimisation
626 print "Enter the Level Of Binary optimisation. This is a number between 0 and 3.
627 The InspIRCd Team will NOT support any bug reports above 0. Also note,
628 the IRCd behaviour will be different depending on this value. Please
629 read the documentation for more information.
630
631 The higher the number, the more optimised your binary will be. This
632 value will default to 0 if you either don't enter a number, or enter
633 a value outside the range.
634
635 As always, if you are unsure, just press enter and accept the default.\n\n";
636 print "[\033[1;32m$config{OPTIMITEMP}\033[0m] -> ";
637 chomp($var = <STDIN>);
638 if ($var eq "") {
639         $var = $config{OPTIMITEMP};
640 }
641
642 if ($var eq "1") {
643         $config{OPTIMITEMP} = 1;
644         $config{OPTIMISATI} = "-O";
645 } elsif ($var eq "2") {
646         $config{OPTIMITEMP} = 2;
647         $config{OPTIMISATI} = "-O2";
648 } elsif ($var eq "3") {
649         $config{OPTIMITEMP} = 3;
650         $config{OPTIMISATI} = "-O3";
651 } else {
652         $config{OPTIMITEMP} = 0;
653         $config{OPTIMISATI} = "-g";
654 }
655
656 print "\n\033[1;32mPre-build configuration is complete!\033[0m\n\n";
657 print "\033[0mBase install path:\033[1;32m\t\t$config{BASE_DIR}\033[0m\n";
658 print "\033[0mConfig path:\033[1;32m\t\t\t$config{CONFIG_DIR}\033[0m\n";
659 print "\033[0mModule path:\033[1;32m\t\t\t$config{MODULE_DIR}\033[0m\n";
660 print "\033[0mLibrary path:\033[1;32m\t\t\t$config{LIBRARY_DIR}\033[0m\n";
661 print "\033[0mMax connections:\033[1;32m\t\t$config{MAX_CLIENT}\033[0m\n";
662 print "\033[0mMax User Channels:\033[1;32m\t\t$config{MAX_CHANNE}\033[0m\n";
663 print "\033[0mMax Oper Channels:\033[1;32m\t\t$config{MAX_OPERCH}\033[0m\n";
664 print "\033[0mMax nickname length:\033[1;32m\t\t$config{NICK_LENGT}\033[0m\n";
665 print "\033[0mMax channel length:\033[1;32m\t\t$config{CHAN_LENGT}\033[0m\n";
666 print "\033[0mMax mode length:\033[1;32m\t\t$config{MAXI_MODES}\033[0m\n";
667 print "\033[0mMax ident length:\033[1;32m\t\t$config{MAX_IDENT}\033[0m\n";
668 print "\033[0mMax quit length:\033[1;32m\t\t$config{MAX_QUIT}\033[0m\n";
669 print "\033[0mMax topic length:\033[1;32m\t\t$config{MAX_TOPIC}\033[0m\n";
670 print "\033[0mMax kick length:\033[1;32m\t\t$config{MAX_KICK}\033[0m\n";
671 print "\033[0mMax name length:\033[1;32m\t\t$config{MAX_GECOS}\033[0m\n";
672 print "\033[0mMax away length:\033[1;32m\t\t$config{MAX_AWAY}\033[0m\n";
673 print "\033[0mGCC Version Found:\033[1;32m\t\t$config{GCCVER}.x\033[0m\n";
674 print "\033[0mOptimization Flag:\033[1;32m\t\t$config{OPTIMISATI}\033[0m\n";
675 print "\033[0mCompiler program:\033[1;32m\t\t$config{CC}\033[0m\n";
676 print "\033[0mStatic modules:\033[1;32m\t\t\t$config{STATIC_LINK}\033[0m\n";
677 print "\033[0mMultithread DNS:\033[1;32m\t\t$config{THREADED_DNS}\033[0m\n";
678 print "\033[0mIPv6 Support:\033[1;32m\t\t\t$config{IPV6}\033[0m\n";
679 print "\033[0mGnuTLS Support:\033[1;32m\t\t\t$config{USE_GNUTLS}\033[0m\n";
680 print "\033[0mOpenSSL Support:\033[1;32m\t\t$config{USE_OPENSSL}\033[0m\n\n";
681
682 if ($config{USE_GNUTLS} eq "y") {
683         $failed = 0;
684         open(TMP, "<src/modules/m_ssl_gnutls.cpp") or $failed = 1;
685         close(TMP);
686         if ($failed) {
687                 print "Symlinking src/modules/m_ssl_gnutls.cpp from extra/\n";
688                 chdir("src/modules");
689                 system("ln -s extra/m_ssl_gnutls.cpp");
690                 chdir("../..");
691         }
692         getmodules();
693         $failed = 0;
694         open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
695         close(TMP);
696         open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
697         close(TMP);
698         if ($failed) {
699                 print "SSL Certificates Not found, Generating.. \n\n
700 *************************************************************
701 * Generating the Private Key may take some time, go grab a  *
702 * Coffee. Even better, to generate some more entropy if it  *
703 * is taking a while, open another console and type du / a   *
704 * few times and get that HD going :) Then answer the        *
705 * Questions which follow. If you are unsure, just hit enter *
706 *************************************************************\n\n";
707                 system("certtool --generate-privkey --outfile key.pem");
708                 system("certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem");
709                 print "\nCertificate generation complete, copying to config directory... ";
710                 system("mv key.pem $config{CONFIG_DIR}/key.pem");
711                 system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
712                 print "Done.\n\n";
713         } else {
714                 print "SSL Certificates found, skipping.\n\n"
715         }       
716 } elsif ($config{USE_OPENSSL} eq "y") {
717         $failed = 0;
718         open(TMP, "<src/modules/m_ssl_openssl.cpp") or $failed = 1;
719         close(TMP);
720         if ($failed) {
721                 print "Symlinking src/modules/m_ssl_openssl.cpp from extra/\n";
722                 chdir("src/modules");
723                 system("ln -s extra/m_ssl_openssl.cpp");
724                 chdir("../..");
725         }
726         getmodules();
727         $failed = 0;
728         open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
729         close(TMP);
730         open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
731         close(TMP);
732         if ($failed) {
733                 print "SSL Certificates Not found, Generating.. \n\n
734 *************************************************************
735 * Generating the certificates may take some time, go grab a *
736 * coffee, or something.                                     *
737 *************************************************************\n\n";
738                 system("openssl req -x509 -nodes -newkey rsa:1024 -keyout key.pem -out cert.pem");
739                 system("openssl dhparam -out dhparams.pem 1024");
740                 print "\nCertificate generation complete, copying to config directory... ";
741                 system("mv key.pem $config{CONFIG_DIR}/key.pem");
742                 system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
743                 system("mv dhparams.pem $config{CONFIG_DIR}/dhparams.pem");
744                 print "Done.\n\n";
745         } else {
746                 print "SSL Certificates found, skipping.\n\n"
747         }
748 }
749 if (($config{USE_GNUTLS} eq "n") && ($config{USE_OPENSSL} eq "n")) {
750         print "Skipping SSL Certificate generation, SSL support is not available.\n\n";
751 }
752
753 getosflags();
754 makecache();
755 writefiles(1);
756
757 print "\n\n";
758 print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
759 if (($config{USE_GNUTLS} eq "y") || ($config{USE_OPENSSL} eq "y")) {
760         print "Please remember that to enable \033[1;32mSSL support\033[0m you must\n";
761         print "load the required modules in your config. This configure process\n";
762         print "has just prepared these modules to be compiled for you, and has not\n";
763         print "configured them to be compiled into the core of the ircd.\n";
764 }
765 print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
766 if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
767         print "\033[1;32mWARNING!\033[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";
768 }
769
770 if ($config{GCCVER} < "3") {
771         print <<FOO2;
772 \033[1;32mWARNING!\033[0m You are attempting to compile InspIRCd on GCC 2.x!
773 GCC 2.x series compilers only had partial (read as broken) C++ support, and
774 your compile will most likely fail horribly! If you have any problems, do NOT
775 report them to the bugtracker or forums without first upgrading your compiler
776 to a newer 3.x or 4.x (or whatever is available currently) version.
777 FOO2
778 }
779
780 ################################################################################
781 #                              HELPER FUNCTIONS                                #
782 ################################################################################
783 sub getcache {
784         # Retrieves the .config.cache file, and loads values into the main config hash.
785         open(CACHE, ".config.cache") or return undef;
786         while (<CACHE>) {
787                 chomp;
788                 # Ignore Blank lines, and comments..
789                 next if /^\s*$/;
790                 next if /^\s*#/;
791                 my ($key, $value) = split("=", $_);
792                 $value =~ /^\"(.*)\"$/;
793                 # Do something with data here!
794                 $config{$key} = $1;
795         }
796         close(CONFIG);
797         return "true";
798 }
799
800 sub makecache {
801         # Dump the contents of %config
802         print "Writing \033[1;32mcache file\033[0m for future ./configures ...\n";
803         open(FILEHANDLE, ">.config.cache");
804         foreach $key (keys %config) {
805                 print FILEHANDLE "$key=\"$config{$key}\"\n";
806         }
807         close(FILEHANDLE);
808 }
809
810 sub dir_check {
811         my ($desc, $hash_key) = @_;
812         my $complete = 0;
813         while (!$complete) {
814                 print "In what directory $desc?\n";
815                 print "[\033[1;32m$config{$hash_key}\033[0m] -> ";
816                 chomp($var = <STDIN>);
817                 if ($var eq "") {
818                         $var = $config{$hash_key};
819                 }
820                 if ($var =~ /^\~\/(.+)$/) {
821                         # Convert it to a full path..
822                         $var = resolve_directory($ENV{HOME} . "/" . $1);
823                 }
824                 if (substr($var,0,1) ne "/")
825                 {
826                         # Assume relative Path was given.. fill in the rest.
827                         $var = $this . "/$var";
828                 }
829                 $var = resolve_directory($var); 
830                 if (! -e $var) {
831                         print "$var does not exist. Create it?\n[\033[1;32my\033[0m] ";
832                         chomp($tmp = <STDIN>);
833                         if (($tmp eq "") || ($tmp =~ /^y/i)) {
834                                 # Attempt to Create the Dir..
835                                 $chk = system("mkdir -p \"$var\" >> /dev/null 2>&1") / 256;
836                                 if ($chk != 0) {
837                                         print "Unable to create directory. ($var)\n\n";
838                                         # Restart Loop..
839                                         next;
840                                 }
841                         } else {
842                                 # They said they don't want to create, and we can't install there.
843                                 print "\n\n";
844                                 next;
845                         }
846                 } else {
847                         if (!is_dir($var)) {
848                                 # Target exists, but is not a directory.
849                                 print "File $var exists, but is not a directory.\n\n";
850                                 next;
851                         }
852                 }
853                 # Either Dir Exists, or was created fine.
854                 $config{$hash_key} = $var;
855                 $complete = 1;
856                 print "\n";
857         }
858 }
859
860 sub getosflags {
861         if ($config{OSNAME} =~ /BSD$/) {
862                 $config{LDLIBS} = "-Ldl -lstdc++";
863                 $config{FLAGS}  = "-fPIC -frtti -Wall -Woverloaded-virtual $config{OPTIMISATI}";
864                 $config{MAKEPROG} = "gmake";
865                 if ($config{OSNAME} eq "OpenBSD") {
866                         chomp($foo = `eg++ -dumpversion | cut -c 1`);
867                         # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
868                         # if theyre not running this, configure lets the build continue but they probably wont manage to
869                         # compile as this standard version is 2.95.3!
870                         if ($foo ne "") {
871                                 $config{CC} = "eg++";
872                                 chomp($config{GCCVER}       = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change the compiler path
873                         }
874                 }
875         } else {
876                 $config{LDLIBS} = "-ldl -lstdc++";
877                 $config{FLAGS}  = "-fPIC -frtti -Wall -Woverloaded-virtual $config{OPTIMISATI}";
878                 $config{MAKEPROG} = "make";
879                 if ($config{OSNAME} =~ /CYGWIN/) {
880                         $config{FLAGS}  = "-frtti -Wall -Woverloaded-virtual $config{OPTIMISATI}";
881                         $config{LDLIBS} = "";
882                         $config{MAKEPROG} = "/usr/bin/make";
883                         $config{MAKEORDER} = "ircd mods";
884                 } elsif ($config{OSNAME} eq "CYG-STATIC") {
885                         $config{FLAGS} = "-frtti -Wall -Woverloaded-virtual $config{OPTIMISATI}";
886                         $config{LDLIBS} = "";
887                         $config{MAKEPROG} = "/usr/bin/make";
888                         $config{MAKEORDER} = "mods ircd";
889                         $config{STATICLIBS} = "modules/mods.a";
890                         $config{STATIC_LINK} = "yes";
891                 }
892         }
893         if ($config{OSNAME} =~ /SunOS/) {
894                 # solaris/sunos needs these
895                 # socket = bsd sockets api
896                 # nsl = dns stuff
897                 # rt = POSIX realtime extensions
898                 # resolv = inet_aton only (why isnt this in nsl?!)
899                 $config{LDLIBS} = $config{LDLIBS} . " -lsocket -lnsl -lrt -lresolv";
900         }
901 }
902
903 sub is_dir {
904         my ($path) = @_;
905         if (chdir($path)) {
906                 chdir($this);
907                 return 1;
908         } else {
909                 # Just in case..
910                 chdir($this);
911                 return 0;
912         }
913 }
914
915 sub getmodules {
916         my $i = 0;
917         print "Detecting modules ";
918         opendir(DIRHANDLE, "src/modules");
919         foreach $name (sort readdir(DIRHANDLE)) {
920                 if ($name =~ /^m_(.+)\.cpp$/)
921                 {
922                         $mod = $1;
923                         if ($mod !~ /_static$/) {
924                                 $modlist[$i++] = $mod;
925                                 print ".";
926                         }
927                 }
928         }
929         closedir(DIRHANDLE);
930         print "\nOk, $i modules.\n";
931 }
932
933 sub getrevision {
934         if ($no_svn) {
935                 return "0";
936         }
937         my $data = `svn info`;
938         if ($data eq "") {
939                 $no_svn = 1;
940                 $rev = "0";
941                 return $rev;
942         }
943         $data =~ /Revision: (\d+)/;
944         my $rev = $1;
945         if (!defined($rev)) {
946                 $rev = "0";
947         }
948         return $rev;
949 }
950
951 sub writefiles {
952         my($writeheader) = @_;
953         # First File.. inspircd_config.h
954         chomp(my $incos = `uname -n -s -r`);
955         chomp(my $version = `sh ./src/version.sh`);
956         chomp(my $revision = getrevision());
957         $version = "$version(r$revision)";
958         chomp(my $revision2 = getrevision());
959         if ($writeheader == 1)
960         {
961                 print "Writing \033[1;32minspircd_config.h\033[0m\n";
962                 open(FILEHANDLE, ">include/inspircd_config.h");
963                 my $NL = $config{NICK_LENGT}+1;
964                 my $CL = $config{CHAN_LENGT}+1;
965                 print FILEHANDLE <<EOF;
966 /* Auto generated by configure, do not modify! */
967 #ifndef __CONFIGURATION_AUTO__
968 #define __CONFIGURATION_AUTO__
969
970 #define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
971 #define MOD_PATH "$config{MODULE_DIR}"
972 #define VERSION "$version"
973 #define REVISION "$revision2"
974 #define MAXCLIENTS $config{MAX_CLIENT}
975 #define MAX_DESCRIPTORS $config{MAX_DESCRIPTORS}
976 #define NICKMAX $NL
977 #define CHANMAX $CL
978 #define MAXCHANS $config{MAX_CHANNE}
979 #define OPERMAXCHANS $config{MAX_OPERCH}
980 #define MAXMODES $config{MAXI_MODES}
981 #define IDENTMAX $config{MAX_IDENT}
982 #define MAXQUIT $config{MAX_QUIT}
983 #define MAXTOPIC $config{MAX_TOPIC}
984 #define MAXKICK $config{MAX_KICK}
985 #define MAXGECOS $config{MAX_GECOS}
986 #define MAXAWAY $config{MAX_AWAY}
987 #define OPTIMISATION $config{OPTIMITEMP}
988 #define SYSTEM "$incos"
989 #define MAXBUF 514
990 EOF
991                 if ($config{OSNAME} =~ /SunOS/) {
992                         print FILEHANDLE "#define IS_SOLARIS\n";
993                 }
994                 if ($config{OSNAME} =~ /CYGWIN/) {
995                         print FILEHANDLE "#define IS_CYGWIN\n";
996                         print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE        1024\n#endif\n";
997                 }
998                 if ($config{OSNAME} eq "CYG-STATIC") {
999                         print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE    1024\n#endif\n";
1000                 }
1001                 if ($config{HAS_EXECINFO} eq "1") {
1002                         print FILEHANDLE "#define HAS_EXECINFO\n";
1003                 }
1004                 if ($config{STATIC_LINK} eq "yes") {
1005                         print FILEHANDLE "#define STATIC_LINK\n";
1006                 }
1007                 if ($config{GCCVER} >= 3) {
1008                         print FILEHANDLE "#define GCC3\n";
1009                 }
1010                 if ($config{HAS_STRLCPY} eq "true") {
1011                         print FILEHANDLE "#define HAS_STRLCPY\n";
1012                 }
1013                 if ($config{HAS_STDINT} eq "true") {
1014                         print FILEHANDLE "#define HAS_STDINT\n";
1015                 }
1016                 if ($config{THREADED_DNS} =~ /y/i) {
1017                         print FILEHANDLE "#define THREADED_DNS\n";
1018                 }
1019                 if ($config{IPV6} =~/y/i) {
1020                         print FILEHANDLE "#define IPV6\n";
1021                 }
1022                 my $use_hiperf = 0;
1023                 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1024                         print FILEHANDLE "#define USE_KQUEUE\n";
1025                         $use_hiperf = 1;
1026                 }
1027                 if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1028                         print FILEHANDLE "#define USE_EPOLL\n";
1029                         $use_hiperf = 1;
1030                 }
1031                 # user didn't choose either epoll or select for their OS.
1032                 # default them to USE_SELECT (ewwy puke puke)
1033                 if (!$use_hiperf) {
1034                         print FILEHANDLE "#define USE_SELECT\n";
1035                 }
1036                 print FILEHANDLE "\n#endif\n";
1037                 close(FILEHANDLE);
1038         }
1039
1040         # Create a Modules List..
1041         my $modules = "";
1042         foreach $i (@modlist)
1043         {
1044                 if ($config{STATIC_LINK} eq "yes") {
1045                         $modules .= "m_".$i.".o ";
1046                 }
1047                 else {
1048                         $modules .= "m_".$i.".so ";
1049                 }
1050         }
1051         chomp($modules);   # Remove Redundant whitespace..
1052
1053
1054         # Write all .in files.
1055         my $tmp = "";
1056         my $file = "";
1057         my $exe = "inspircd";
1058
1059         if ($config{OSNAME} =~ /CYGWIN/) {
1060                 $exe = "inspircd.exe";
1061         }
1062
1063         opendir(DIRHANDLE, $this);
1064         if ($config{THREADED_DNS} =~ /y/i) {
1065                 $config{LDLIBS} = $config{LDLIBS} . " -pthread";
1066         }
1067         foreach $name (sort readdir(DIRHANDLE)) {
1068                 if ($name =~ /^\.(.+)\.inc$/) {
1069                         $file = $1;
1070                         # All .name.inc files need parsing!
1071                         $tmp = "";
1072                         open(FILEHANDLE, ".$file.inc");
1073                         while (<FILEHANDLE>) {
1074                                 $tmp .= $_;
1075                         }
1076                         close(FILEHANDLE);
1077
1078                         $tmp =~ s/\@CC\@/$config{CC}/;
1079                         $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
1080                         $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
1081                         $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
1082                         $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/;
1083                         $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
1084                         $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
1085                         $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
1086                         $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
1087                         $tmp =~ s/\@MODULES\@/$modules/;
1088                         $tmp =~ s/\@EXECUTABLE\@/$exe/;
1089                         $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
1090                         $tmp =~ s/\@STATICLIBS\@/$config{STATICLIBS}/;
1091
1092                         print "Writing \033[1;32m$file\033[0m\n";
1093                         open(FILEHANDLE, ">$file");
1094                         print FILEHANDLE $tmp;
1095                 }
1096         }
1097         closedir(DIRHANDLE);
1098
1099         # Make inspircd executable!
1100         chmod 0744, 'inspircd';
1101
1102         if ($config{STATIC_LINK} eq "yes") {
1103                 print "Writing static-build \033[1;32msrc/Makefile\033[0m\n";
1104                 write_static_makefile();
1105                 write_static_modules_makefile();
1106         } elsif ($config{OSNAME} =~ /CYGWIN/) {
1107                 print "Writing cygwin-build \033[1;32msrc/Makefile\033[0m\n";
1108                 write_static_makefile();
1109                 write_dynamic_modules_makefile();
1110         } else {
1111                 print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
1112                 write_dynamic_makefile();
1113                 write_dynamic_modules_makefile();
1114         }
1115 }
1116
1117 sub getcompilerflags {
1118         my ($file) = @_;
1119         open(FLAGS, $file);
1120         while (<FLAGS>) {
1121         if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
1122                 close(FLAGS);
1123                         return $1;
1124                 }
1125         }
1126         close(FLAGS);
1127         return undef;
1128 }
1129
1130 sub getlinkerflags {
1131         my ($file) = @_;
1132         open(FLAGS, $file);
1133         while (<FLAGS>) {
1134                 if ($_ =~ /^\/\* \$LinkerFlags: (.+) \*\/$/) {
1135                         close(FLAGS);
1136                         return $1;
1137                 }
1138         }
1139         close(FLAGS);
1140         return undef;
1141 }
1142
1143 sub show_splash {
1144   print "'\033[1;33m####\033[0m:'\033[1;33m##\033[0m::: \033[1;33m##\033[0m::'\033[1;33m######\033[0m::'\033[1;33m########\033[0m::'\033[1;33m####\033[0m:'\033[1;33m########\033[0m:::'\033[1;33m######\033[0m::'\033[1;33m########\033[0m::\n";
1145   print ". \033[1;33m##\033[0m:: \033[1;33m###\033[0m:: \033[1;33m##\033[0m:'\033[1;33m##\033[0m... \033[1;33m##\033[0m: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:. \033[1;33m##\033[0m:: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:'\033[1;33m##\033[0m... \033[1;33m##\033[0m: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:\n";
1146   print ": \033[1;33m##\033[0m:: \033[1;33m####\033[0m: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::..:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::..:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:\n";
1147   print ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m \033[1;33m##\033[0m \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m########\033[0m::: \033[1;33m##\033[0m:: \033[1;33m########\033[0m:: \033[1;33m##\033[0m::::::: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:\n";
1148   print ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m. \033[1;33m####\033[0m::..... \033[1;33m##\033[0m: \033[1;33m##\033[0m.....:::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m.. \033[1;33m##\033[0m::: \033[1;33m##\033[0m::::::: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:\n";
1149   print ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m:. \033[1;33m###\033[0m:'\033[1;33m##\033[0m::: \033[1;33m##\033[0m: \033[1;33m##\033[0m::::::::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m::. \033[1;33m##\033[0m:: \033[1;33m##\033[0m::: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:\n";
1150   print "'\033[1;33m####\033[0m: \033[1;33m##\033[0m::. \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m##\033[0m::::::::'\033[1;33m####\033[0m: \033[1;33m##\033[0m:::. \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m########\033[0m::\n";
1151   print "\033[0m\033[0m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::\n\n";
1152 }
1153
1154 sub resolve_directory {
1155         use File::Spec;
1156         return File::Spec->rel2abs($_[0]);
1157 }
1158
1159 sub yesno {
1160         my ($flag,$prompt) = @_;
1161         print "$prompt [\033[1;32m$config{$flag}\033[0m] -> ";
1162         chomp($tmp = <STDIN>);
1163         if ($tmp eq "") { $tmp = $config{$flag} }
1164
1165         if (($tmp eq "") || ($tmp =~ /^y/i)) {
1166                 $config{$flag} = "y";
1167         } else {
1168                 $config{$flag} = "n";
1169         }
1170         return;
1171 }
1172
1173 sub write_static_modules_makefile {
1174         # Modules Makefile..
1175         print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
1176         open(FILEHANDLE, ">src/modules/Makefile");
1177
1178         ###
1179         # Module Makefile Header
1180         ###
1181         print FILEHANDLE <<EOF;
1182 # (C) ChatSpike development team
1183 # Makefile by <Craig\@ChatSpike.net>
1184 # Many Thanks to Andrew Church <achurch\@achurch.org>
1185 #    for assisting with making this work right.
1186 #
1187 # Automatically Generated by ./configure to add a modules
1188 # please run ./configure --update
1189
1190 all: \$(MODULES)
1191
1192 EOF
1193         ###
1194         # End Module Makefile Header
1195         ###
1196
1197         # Create a Modules List..
1198         my $modules = "";
1199         my $cmflags = "";
1200         my $liflags = "";
1201
1202         open(MODLIST,">include/modlist.h");
1203
1204         ###
1205         # Include File Header
1206         ###
1207         print MODLIST <<HEADER;
1208 // Generated automatically by configure. DO NOT EDIT!
1209
1210 #ifndef __SYMBOLS__H_CONFIGURED__
1211 #define __SYMBOLS__H_CONFIGURED__
1212
1213 HEADER
1214         ###
1215         # End Include File Header
1216         ###
1217
1218         # Place Module List into Include
1219         foreach $i (@modlist) {
1220                 if ($i !~ /_static$/) {
1221                         print MODLIST "extern \"C\" void * $i\_init (void);\n";
1222                 }
1223         }
1224         print MODLIST "\nstruct {const char *name; initfunc *value; } modsyms[] = {\n";
1225
1226         ###
1227         # Build Module Crap
1228         ###
1229         foreach $i (@modlist)
1230         {
1231                 if ($i !~ /_static$/) {
1232                         $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
1233                         $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
1234
1235                         ###
1236                         # Write Entry to the Makefile
1237                         ###
1238                         print FILEHANDLE <<EOCHEESE;
1239 m_$i.o: .m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h
1240         \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c .m_$i\_static.cpp
1241         mv m_$i\_static.o ../m_$i.o
1242
1243 EOCHEESE
1244                         ###
1245                         # End Write Entry to the MakeFile
1246                         ###
1247                         print "Configuring module [\033[1;32mm_$i.so\033[0m] for static linking... ";
1248                         open(MODULE,"<src/modules/m_".$i.".cpp") or die("Could not open m_".$i.".cpp");
1249                         open(MUNGED,">src/modules/.m_".$i."_static.cpp") or die("Could not create .m_".$i."_static.cpp");
1250                         while (chomp($a = <MODULE>)) { 
1251                                 $a =~ s/init_module/$i\_init/g;
1252                                 print MUNGED "$a\n";
1253                         }
1254                         close(MODULE);
1255                         close(MUNGED);
1256                         print MODLIST <<EOENT;
1257 {"m_$i.so",\&$i\_init},
1258 EOENT
1259                         print "done\n";
1260                 }
1261         }
1262         print MODLIST "{0}};\n\n#endif\n";
1263         close(MODLIST);
1264 }
1265
1266 sub write_dynamic_modules_makefile {
1267         # Modules Makefile..
1268         print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
1269         open(FILEHANDLE, ">src/modules/Makefile");
1270         my $extra = "";
1271
1272         if ($config{OSNAME} =~ /CYGWIN/) {
1273                 $extra = "../inspircd.dll.a";
1274         }
1275
1276 ###
1277 # Module Makefile Header
1278 ###
1279         print FILEHANDLE <<EOF;
1280 # (C) ChatSpike development team
1281 # Makefile by <Craig\@ChatSpike.net>
1282 # Many Thanks to Andrew Church <achurch\@achurch.org>
1283 #    for assisting with making this work right.
1284 #
1285 # Automatically Generated by ./configure to add a modules
1286 # please run ./configure -update or ./configure -modupdate
1287
1288 all: \$(MODULES)
1289
1290 EOF
1291         ###
1292         # End Module Makefile Header
1293         ###
1294
1295         # Create a Modules List..
1296         my $modules = "";
1297         my $cmflags = "";
1298         my $liflags = "";
1299         my $crud = "";
1300
1301         foreach $i (@modlist) {
1302         ###
1303         # Write Entry to the MakeFile
1304         ###
1305         $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
1306         $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
1307         print FILEHANDLE <<EOCHEESE;
1308 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
1309         \$(CC) -pipe -I../../include \$(FLAGS) $cmflags -export-dynamic -c m_$i.cpp
1310         \$(CC) \$(FLAGS) -shared $liflags -o m_$i.so m_$i.o $extra
1311
1312 EOCHEESE
1313         $crud = $crud . "       \@install -v -m 0700 m_$i.so \$(MODPATH)\n";
1314         ###
1315         # End Write Entry to the MakeFile
1316         ###
1317         }
1318         print FILEHANDLE "modinst:\n    \@echo \"Installing modules...\"\n" . $crud;
1319 }
1320
1321
1322 sub write_static_makefile {
1323         open(FH,">src/Makefile") or die("Could not write src/Makefile!");
1324         my $i = 0;
1325         my @cmdlist = ();
1326         opendir(DIRHANDLE, "src");
1327         foreach $name (sort readdir(DIRHANDLE)) {
1328                 if ($name =~ /^cmd_(.+)\.cpp$/) {
1329                         $cmdlist[$i++] = $1;
1330                 }
1331         }
1332         closedir(DIRHANDLE);
1333         my $cmdobjs = "";
1334         my $srcobjs = "";
1335         foreach my $cmd (@cmdlist) {
1336                 $cmdobjs = $cmdobjs . "cmd_$cmd.o ";
1337                 $srcobjs = $srcobjs . "cmd_$cmd.cpp ";
1338         }
1339         print FH <<EOM;
1340 # Insp Makefile :p
1341 #
1342 # (C) ChatSpike development team
1343 # Makefile by <Craig\@ChatSpike.net>
1344 # Makefile version 2 (statically linked core) by <brain\@inspircd.org>
1345 #
1346
1347 CC = im a cheezeball
1348
1349 CXXFLAGS = -I../include \${FLAGS}
1350 CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
1351 RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
1352
1353 EOM
1354         ###
1355         # This next section is for cygwin dynamic module builds.
1356         # Basically, what we do, is build the inspircd core as a library
1357         # then the main executable uses that. the library is capable of
1358         # loading / unloading the modules dynamically :)
1359         # Massive thanks to the guys on #cygwin @ irc.freenode.net for helping
1360         # make this work :)
1361         ###
1362
1363         if ($config{OSNAME} =~ /CYGWIN/) {
1364                 print FH <<EOM;
1365 all: timer.o aes.o command_parse.o cull_list.o userprocess.o socketengine.o socket.o hashcomp.o channels.o mode.o xline.o inspstring.o dns.o base.o configreader.o inspsocket.o message.o $cmdobjs commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o helperfuncs.o snomasks.o inspircd.exe
1366
1367 inspircd.exe: inspircd.dll.a
1368         \$(CC) -o \$@ \$^
1369
1370 inspircd.dll inspircd.dll.a: inspircd.o channels.o mode.o xline.o inspstring.o dns.o base.o configreader.o inspsocket.o message.o $cmdobjs  commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o helperfuncs.o hashcomp.o socket.o socketengine.o userprocess.o cull_list.o command_parse.o aes.o timer.o snomasks.o
1371         \$(CC) -shared -Wl,--out-implib=inspircd.dll.a -o inspircd.dll \$^
1372 EOM
1373         } else {
1374                 print FH <<EOM;
1375 all: timer.o aes.o command_parse.o cull_list.o userprocess.o socketengine.o socket.o hashcomp.o channels.o mode.o xline.o inspstring.o dns.o base.o configreader.o inspsocket.o message.o $cmdobjs commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o helperfuncs.o snomasks.o \$(MODULES) inspircd.exe
1376
1377 inspircd.exe: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/base.h
1378         \$(CC) -I../include \$(FLAGS) inspircd.cpp -o inspircd.exe \$(LDLIBS) channels.o mode.o xline.o inspstring.o dns.o base.o inspsocket.o configreader.o message.o $cmdobjs commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o helperfuncs.o hashcomp.o socket.o socketengine.o userprocess.o cull_list.o command_parse.o aes.o timer.o snomasks.o modes/modeclasses.a \$(MODULES)
1379 EOM
1380         }
1381
1382         print FH <<EOM;
1383
1384 cull_list.o: cull_list.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/users.h ../include/channels.h
1385         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cull_list.cpp
1386
1387 snomasks.o: snomasks.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h ../include/channels.h
1388         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c snomasks.cpp
1389
1390 command_parse.o: command_parse.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1391         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c command_parse.cpp
1392
1393 userprocess.o: userprocess.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1394         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c userprocess.cpp
1395
1396 socketengine.o: socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1397         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp
1398
1399 hashcomp.o: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1400         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1401
1402 helperfuncs.o: helperfuncs.cpp ../include/base.h ../include/helperfuncs.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1403         \$(CC) -pipe -I/usr/local/include -L/usr/local/lib -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1404
1405 channels.o: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1406         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1407
1408 mode.o: mode.cpp ../include/base.h ../include/mode.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h \$(RELCPPFILES)
1409         \${MAKE} -C "modes" DIRNAME="src/modes" \$(MAKEARGS) CPPFILES="\$(CPPFILES)"
1410         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1411
1412 xline.o: xline.cpp ../include/base.h ../include/xline.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1413         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1414
1415 inspstring.o: inspstring.cpp ../include/base.h ../include/inspstring.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1416         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1417
1418 dns.o: dns.cpp ../include/base.h ../include/dns.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1419         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1420
1421 base.o: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1422         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1423
1424 configreader.o: configreader.cpp ../include/base.h ../include/configreader.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1425         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c configreader.cpp
1426
1427 message.o: message.cpp ../include/base.h ../include/message.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1428         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c message.cpp
1429
1430 commands.o: commands.cpp ../include/base.h ../include/commands.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h $srcobjs
1431         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp $cmdobjs
1432
1433 dnsqueue.o: dnsqueue.cpp ../include/base.h ../include/dnsqueue.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1434         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dnsqueue.cpp
1435
1436 dynamic.o: dynamic.cpp ../include/base.h ../include/dynamic.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1437         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1438
1439 users.o: users.cpp ../include/base.h ../include/users.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1440         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1441
1442 modules.o: modules.cpp ../include/base.h ../include/modules.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1443         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1444
1445 wildcard.o: wildcard.cpp ../include/base.h ../include/wildcard.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1446         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1447
1448 socket.o: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1449         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1450         
1451 inspsocket.o: inspsocket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1452         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspsocket.cpp
1453
1454 aes.o: aes.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1455         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c aes.cpp
1456
1457 timer.o: timer.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1458         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c timer.cpp
1459
1460 EOM
1461         foreach my $cmd (@cmdlist) {
1462                 print FH <<ITEM;
1463 cmd_$cmd.o: cmd_$cmd.cpp ../include/base.h ../include/modules.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h ../include/commands/cmd_$cmd.h
1464         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1465 ITEM
1466         }
1467         close(FH);
1468 }
1469
1470 sub write_dynamic_makefile {
1471
1472         my $i = 0;
1473         my @cmdlist = ();
1474         opendir(DIRHANDLE, "src");
1475         foreach $name (sort readdir(DIRHANDLE)) {
1476                 if ($name =~ /^cmd_(.+)\.cpp$/) {
1477                         $cmdlist[$i++] = $1;
1478                 }
1479         }
1480         closedir(DIRHANDLE);
1481
1482         my $cmdobjs = "";
1483         my $srcobjs = "";
1484         foreach my $cmd (@cmdlist) {
1485                 $cmdobjs = $cmdobjs . "cmd_$cmd.o ";
1486                 $srcobjs = $srcobjs . "cmd_$cmd.cpp ";
1487         }
1488
1489 if (($config{OSNAME} !~ /Linux/i) && ($config{HAS_EXECINFO} eq "1")) {
1490         $extra = "-L/usr/local/lib -lexecinfo";
1491 } else {
1492         $extra = "";
1493 }
1494
1495         open(FH,">src/Makefile") or die("Could not write src/Makefile");
1496         print FH <<EOM;
1497 # Insp Makefile :p
1498 #
1499 # (C) ChatSpike development team
1500 # Makefile by <Craig\@ChatSpike.net>
1501 # Makefile version 2 (dynamically linked core) by <brain\@inspircd.org>
1502 #
1503
1504 CC = im a cheezeball
1505
1506 CXXFLAGS = -I../include \${FLAGS}
1507 CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
1508 RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
1509
1510 all: libIRCDtimer.so libIRCDaes.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 libIRCDmessage.so $cmdobjs libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so libIRCDsnomasks.so inspircd
1511
1512 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 libIRCDaes.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 libIRCDmessage.so $cmdobjs libIRCDsnomasks.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so
1513         \$(CC) -I../include $extra -Wl,--rpath -Wl,/usr/local/lib -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 libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.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 libIRCDaes.so libIRCDtimer.so libIRCDsnomasks.so
1514
1515 libIRCDsocketengine.so: socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1516         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp
1517         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsocketengine.so socketengine.o
1518
1519 libIRCDsnomasks.so: snomasks.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h ../include/channels.h
1520          \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c snomasks.cpp
1521           \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsnomasks.so snomasks.o
1522
1523 libIRCDcommand_parse.so: command_parse.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1524         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c command_parse.cpp
1525         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcommand_parse.so command_parse.o
1526
1527 libIRCDcull_list.so: cull_list.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/users.h ../include/channels.h
1528         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cull_list.cpp
1529         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcull_list.so cull_list.o
1530
1531 libIRCDuserprocess.so: userprocess.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1532         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c userprocess.cpp
1533         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDuserprocess.so userprocess.o
1534
1535 libIRCDhash.so: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1536         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1537         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDhash.so hashcomp.o
1538
1539 libIRCDhelper.so: helperfuncs.cpp ../include/base.h ../include/helperfuncs.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1540         \$(CC) -pipe -I/usr/local/include -L/usr/local/lib -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1541         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDhelper.so helperfuncs.o
1542
1543 libIRCDchannels.so: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1544         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1545         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDchannels.so channels.o
1546
1547 libIRCDmode.so: mode.cpp ../include/base.h ../include/mode.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h \$(RELCPPFILES)
1548         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1549         \${MAKE} -C "modes" DIRNAME="src/modes" \$(MAKEARGS) CPPFILES="\$(CPPFILES)"
1550         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDmode.so mode.o modes/modeclasses.a
1551
1552 libIRCDxline.so: xline.cpp ../include/base.h ../include/xline.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1553         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1554         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDxline.so xline.o
1555
1556 libIRCDstring.so: inspstring.cpp ../include/base.h ../include/inspstring.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1557         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1558         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDstring.so inspstring.o
1559
1560 libIRCDasyncdns.so: dns.cpp ../include/base.h ../include/dns.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1561         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1562         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDasyncdns.so dns.o
1563
1564 libIRCDbase.so: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1565         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1566         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDbase.so base.o
1567
1568 libIRCDconfigreader.so: configreader.cpp ../include/base.h ../include/configreader.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1569         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c configreader.cpp
1570         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDconfigreader.so configreader.o
1571
1572 libIRCDmessage.so: message.cpp ../include/base.h ../include/message.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1573         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c message.cpp
1574         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDmessage.so message.o
1575
1576 libIRCDcommands.so: commands.cpp ../include/base.h ../include/commands.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h $srcobjs
1577         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
1578         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcommands.so commands.o $cmdobjs
1579
1580 libIRCDdnsqueue.so: dnsqueue.cpp ../include/base.h ../include/dnsqueue.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1581         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dnsqueue.cpp
1582         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDdnsqueue.so dnsqueue.o
1583
1584 libIRCDdynamic.so: dynamic.cpp ../include/base.h ../include/dynamic.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1585         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1586         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDdynamic.so dynamic.o
1587
1588 libIRCDusers.so: users.cpp ../include/base.h ../include/users.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1589         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1590         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDusers.so users.o
1591
1592 libIRCDmodules.so: modules.cpp ../include/base.h ../include/modules.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1593         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1594         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDmodules.so modules.o
1595
1596 libIRCDwildcard.so: wildcard.cpp ../include/base.h ../include/wildcard.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1597         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1598         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDwildcard.so wildcard.o
1599
1600 libIRCDsocket.so: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1601         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1602         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsocket.so socket.o
1603
1604 libIRCDinspsocket.so: inspsocket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1605         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspsocket.cpp
1606         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDinspsocket.so inspsocket.o
1607
1608 libIRCDaes.so: aes.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1609         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c aes.cpp
1610         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDaes.so aes.o
1611
1612 libIRCDtimer.so: timer.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1613         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c timer.cpp
1614         \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDtimer.so timer.o
1615
1616 EOM
1617         foreach my $cmd (@cmdlist) {
1618                 print FH <<ITEM;
1619 cmd_$cmd.o: cmd_$cmd.cpp ../include/base.h ../include/modules.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h ../include/commands/cmd_$cmd.h
1620         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1621
1622 ITEM
1623         }
1624         close(FH);
1625 }