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