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