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