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