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