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