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