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