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