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