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