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