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