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