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