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