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