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