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