]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - configure
OnExtendedMode was removed in 1.0, the function names here were incorrect.
[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{MAKEPROG} = "make";
848
849         if ($config{OSNAME} =~ /OpenBSD/i) {
850                 $config{MAKEPROG} = "gmake";
851                 chomp($foo = `eg++ -dumpversion | cut -c 1`);
852                 # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
853                 # if theyre not running this, configure lets the build continue but they probably wont manage to
854                 # compile as this standard version is 2.95.3!
855                 if ($foo ne "") {
856                         $config{CC} = "eg++";
857                         chomp($config{GCCVER}       = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change the compiler path
858                 }
859                 return "OpenBSD";
860         }
861
862         if ($config{OSNAME} =~ /Linux/i) {
863                 $config{LDLIBS} = "-ldl -lstdc++";
864                 $config{FLAGS}  = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual $config{OPTIMISATI}";
865                 $config{FLAGS}  .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
866                 $config{MAKEPROG} = "make";
867                 if ($config{OSNAME} =~ /CYGWIN/) {
868                         $config{FLAGS}  = "-fno-strict-aliasing -Wall -Woverloaded-virtual $config{OPTIMISATI}";
869                         $config{LDLIBS} = "";
870                         $config{MAKEPROG} = "/usr/bin/make";
871                         $config{MAKEORDER} = "ircd mods";
872                         return "Cygwin";
873                 } elsif ($config{OSNAME} eq "CYG-STATIC") {
874                         $config{FLAGS} = "-fno-strict-aliasing -Wall -Woverloaded-virtual $config{OPTIMISATI}";
875                         $config{LDLIBS} = "";
876                         $config{MAKEPROG} = "/usr/bin/make";
877                         $config{MAKEORDER} = "mods ircd";
878                         $config{STATICLIBS} = "modules/mods.a";
879                         $config{STATIC_LINK} = "yes";
880                         return "Cygwin-Static";
881                 }
882                 $config{FLAGS}  .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
883         }
884         
885         if ($config{OSNAME} =~ /SunOS/i)
886         {
887                 # solaris/sunos needs these
888                 # socket = bsd sockets api
889                 # nsl = dns stuff
890                 # rt = POSIX realtime extensions
891                 # resolv = inet_aton only (why isnt this in nsl?!)
892                 $config{MAKEPROG} = "gmake";
893                 $config{LDLIBS} = $config{LDLIBS} . " -lsocket -lnsl -lrt -lresolv";
894                 return "Solaris";
895         }
896         
897         if($config{OSNAME} =~ /MINGW32/i)
898         {
899                 # All code is position-independent on windows
900                 $config{FLAGS} =~ s/-fPIC //;
901                 return "MinGW";
902         }
903
904         return $config{OSNAME};
905 }
906
907 sub writefiles {
908         my($writeheader) = @_;
909         # First File.. inspircd_config.h
910         chomp(my $incos = `uname -n -s -r`);
911         chomp(my $version = `sh ./src/version.sh`);
912         chomp(my $revision = getrevision());
913         $version = "$version(r$revision)";
914         chomp(my $revision2 = getrevision());
915         if ($writeheader == 1)
916         {
917                 print "Writing \033[1;32minspircd_config.h\033[0m\n";
918                 open(FILEHANDLE, ">include/inspircd_config.h");
919                 my $NL = $config{NICK_LENGT}+1;
920                 my $CL = $config{CHAN_LENGT}+1;
921                 print FILEHANDLE <<EOF;
922 /* Auto generated by configure, do not modify! */
923 #ifndef __CONFIGURATION_AUTO__
924 #define __CONFIGURATION_AUTO__
925
926 #define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
927 #define MOD_PATH "$config{MODULE_DIR}"
928 #define VERSION "$version"
929 #define REVISION "$revision2"
930 #define MAXCLIENTS $config{MAX_CLIENT}
931 #define MAXCLIENTS_S "$config{MAX_CLIENT}"
932 #define SOMAXCONN_S "$config{_SOMAXCONN}"
933 #define MAX_DESCRIPTORS $config{MAX_DESCRIPTORS}
934 #define NICKMAX $NL
935 #define CHANMAX $CL
936 #define MAXCHANS $config{MAX_CHANNE}
937 #define OPERMAXCHANS $config{MAX_OPERCH}
938 #define MAXMODES $config{MAXI_MODES}
939 #define IDENTMAX $config{MAX_IDENT}
940 #define MAXQUIT $config{MAX_QUIT}
941 #define MAXTOPIC $config{MAX_TOPIC}
942 #define MAXKICK $config{MAX_KICK}
943 #define MAXGECOS $config{MAX_GECOS}
944 #define MAXAWAY $config{MAX_AWAY}
945 #define OPTIMISATION $config{OPTIMITEMP}
946 #define LIBRARYDIR "$config{LIBRARY_DIR}"
947 #define SYSTEM "$incos"
948 #define MAXBUF 514
949 EOF
950                 if ($config{OSNAME} =~ /SunOS/i) {
951                         print FILEHANDLE "#define IS_SOLARIS\n";
952                 }
953                 if ($config{OSNAME} =~ /CYGWIN/i) {
954                         print FILEHANDLE "#define IS_CYGWIN\n";
955                         print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE        1024\n#endif\n";
956                 }
957                 if ($config{OSNAME} =~ /MINGW32/i) {
958                         print FILEHANDLE "#define IS_MINGW\n";
959                 }
960                 if ($config{OSNAME} =~ /CYG-STATIC/i) {
961                         print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE    1024\n#endif\n";
962                 }
963                 if ($config{STATIC_LINK} eq "yes") {
964                         print FILEHANDLE "#define STATIC_LINK\n";
965                 }
966                 if ($config{GCCVER} >= 3) {
967                         print FILEHANDLE "#define GCC3\n";
968                 }
969                 if ($config{HAS_STRLCPY} eq "true") {
970                         print FILEHANDLE "#define HAS_STRLCPY\n";
971                 }
972                 if ($config{HAS_STDINT} eq "true") {
973                         print FILEHANDLE "#define HAS_STDINT\n";
974                 }
975                 if ($config{IPV6} =~ /y/i) {
976                         print FILEHANDLE "#define IPV6\n";
977                 }
978                 if ($config{SUPPORT_IP6LINKS} =~ /y/i) {
979                         print FILEHANDLE "#define SUPPORT_IP6LINKS\n";
980                 }
981                 my $use_hiperf = 0;
982                 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
983                         print FILEHANDLE "#define USE_KQUEUE\n";
984                         $se = "socketengine_kqueue";
985                         $use_hiperf = 1;
986                 }
987                 if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
988                         print FILEHANDLE "#define USE_EPOLL\n";
989                         $se = "socketengine_epoll";
990                         $use_hiperf = 1;
991                 }
992                 # user didn't choose either epoll or select for their OS.
993                 # default them to USE_SELECT (ewwy puke puke)
994                 if (!$use_hiperf) {
995                         print FILEHANDLE "#define USE_SELECT\n";
996                         $se = "socketengine_select";
997                 }
998                 print FILEHANDLE "\n#endif\n";
999                 close(FILEHANDLE);
1000         }
1001
1002         if ($writeheader)
1003         {
1004                 open(FILEHANDLE, ">include/inspircd_se_config.h");
1005                 print FILEHANDLE <<EOF;
1006 /* Auto generated by configure, do not modify or commit to svn! */
1007 #ifndef __CONFIGURATION_SOCKETENGINE__
1008 #define __CONFIGURATION_SOCKETENGINE__
1009
1010 #include "$se.h"
1011
1012 #endif
1013 EOF
1014                 close(FILEHANDLE);
1015         }
1016
1017
1018         # Create a Modules List..
1019         my $modules = "";
1020         foreach $i (@modlist)
1021         {
1022                 if ($config{STATIC_LINK} eq "yes") {
1023                         $modules .= "m_".$i.".o ";
1024                 }
1025                 else {
1026                         $modules .= "m_".$i.".so ";
1027                 }
1028         }
1029         chomp($modules);   # Remove Redundant whitespace..
1030
1031         opendir(DIRHANDLE, "src/modules");
1032         foreach $name (sort readdir(DIRHANDLE)) {
1033                 if ($name =~ /^m_(.+?)$/) {
1034                         if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
1035                                 closedir(MDIRHANDLE);
1036                                 $modules .= "$name.so ";
1037                         }
1038                 }
1039         }
1040         closedir(DIRHANDLE);
1041
1042
1043         # Write all .in files.
1044         my $tmp = "";
1045         my $file = "";
1046         my $exe = "inspircd";
1047
1048         if ($config{OSNAME} =~ /CYGWIN/i) {
1049                 $exe = "inspircd.exe";
1050         }
1051
1052         opendir(DIRHANDLE, $this);
1053
1054         # Do this once here, and cache it in the .*.inc files,
1055         # rather than attempting to read src/version.sh from
1056         # compiled code -- we might not have the source to hand.
1057         # Fix for bug#177 by Brain.
1058
1059         chomp(my $version = `sh ./src/version.sh`);
1060         chomp(my $revision = getrevision());
1061         $version = "$version(r$revision)";
1062
1063         # We can actually parse any file starting with . and ending with .inc,
1064         # but right now we only parse .inspircd.inc to form './inspircd'
1065
1066         foreach $name (sort readdir(DIRHANDLE)) {
1067                 if ($name =~ /^\.(.+)\.inc$/) {
1068                         $file = $1;
1069                         # All .name.inc files need parsing!
1070                         $tmp = "";
1071                         open(FILEHANDLE, ".$file.inc");
1072                         while (<FILEHANDLE>) {
1073                                 $tmp .= $_;
1074                         }
1075                         close(FILEHANDLE);
1076
1077                         $tmp =~ s/\@CC\@/$config{CC}/;
1078                         $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
1079                         $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
1080                         $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
1081                         $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/;
1082                         $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
1083                         $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
1084                         $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
1085                         $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
1086                         $tmp =~ s/\@MODULES\@/$modules/;
1087                         $tmp =~ s/\@EXECUTABLE\@/$exe/;
1088                         $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
1089                         $tmp =~ s/\@STATICLIBS\@/$config{STATICLIBS}/;
1090                         $tmp =~ s/\@VERSION\@/$version/;
1091
1092                         print "Writing \033[1;32m$file\033[0m\n";
1093                         open(FILEHANDLE, ">$file");
1094                         print FILEHANDLE $tmp;
1095                 }
1096         }
1097         closedir(DIRHANDLE);
1098
1099         # Make inspircd executable!
1100         chmod 0744, 'inspircd';
1101
1102         if ($config{STATIC_LINK} eq "yes") {
1103                 print "Writing static-build \033[1;32msrc/Makefile\033[0m\n";
1104                 write_static_makefile();
1105                 write_static_modules_makefile();
1106         } elsif ($config{OSNAME} =~ /CYGWIN/i) {
1107                 print "Writing cygwin-build \033[1;32msrc/Makefile\033[0m\n";
1108                 write_static_makefile();
1109                 write_dynamic_modules_makefile();
1110         } else {
1111                 print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
1112                 write_dynamic_makefile();
1113                 write_dynamic_modules_makefile();
1114         }
1115 }
1116
1117 sub write_static_modules_makefile {
1118         # Modules Makefile..
1119         print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
1120         open(FILEHANDLE, ">src/modules/Makefile");
1121
1122         ###
1123         # Module Makefile Header
1124         ###
1125         print FILEHANDLE <<EOF;
1126 # (C) ChatSpike development team
1127 # Makefile by <Craig\@ChatSpike.net>
1128 # Many Thanks to Andrew Church <achurch\@achurch.org>
1129 #    for assisting with making this work right.
1130 #
1131 # Automatically Generated by ./configure to add a modules
1132 # please run ./configure --update
1133
1134 all: \$(MODULES)
1135
1136 EOF
1137         ###
1138         # End Module Makefile Header
1139         ###
1140
1141         # Create a Modules List..
1142         my $modules = "";
1143         my $cmflags = "";
1144         my $liflags = "";
1145
1146         open(MODLIST,">include/modlist.h");
1147
1148         ###
1149         # Include File Header
1150         ###
1151         print MODLIST <<HEADER;
1152 // Generated automatically by configure. DO NOT EDIT!
1153
1154 #ifndef __SYMBOLS__H_CONFIGURED__
1155 #define __SYMBOLS__H_CONFIGURED__
1156
1157 HEADER
1158         ###
1159         # End Include File Header
1160         ###
1161
1162         # Place Module List into Include
1163         foreach $i (@modlist) {
1164                 if ($i !~ /_static$/) {
1165                         print MODLIST "extern \"C\" void * $i\_init (void);\n";
1166                 }
1167         }
1168         print MODLIST "\nstruct {const char *name; initfunc *value; } modsyms[] = {\n";
1169
1170         ###
1171         # Build Module Crap
1172         ###
1173         foreach $i (@modlist)
1174         {
1175                 if ($i !~ /_static$/) {
1176                         $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
1177                         $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
1178                         $deps = getdependencies("src/modules/m_".$i.".cpp");
1179
1180                         #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
1181
1182                         ###
1183                         # Write Entry to the Makefile
1184                         ###
1185                         print FILEHANDLE <<EOCHEESE;
1186 m_$i.o: .m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h $deps
1187         \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c .m_$i\_static.cpp
1188         mv .m_$i\_static.o ../m_$i.o
1189
1190 EOCHEESE
1191                         ###
1192                         # End Write Entry to the MakeFile
1193                         ###
1194                         print "Configuring module [\033[1;32mm_$i.so\033[0m] for static linking... ";
1195                         open(MODULE,"<src/modules/m_".$i.".cpp") or die("Could not open m_".$i.".cpp");
1196                         open(MUNGED,">src/modules/.m_".$i."_static.cpp") or die("Could not create .m_".$i."_static.cpp");
1197                         while (chomp($a = <MODULE>)) { 
1198                                 $a =~ s/init_module/$i\_init/g;
1199                                 print MUNGED "$a\n";
1200                         }
1201                         close(MODULE);
1202                         close(MUNGED);
1203                         print MODLIST <<EOENT;
1204 {"m_$i.so",\&$i\_init},
1205 EOENT
1206                         print "done\n";
1207                 }
1208         }
1209
1210         print MODLIST "{0}};\n\n#endif\n";
1211         close(MODLIST);
1212 }
1213
1214 sub write_dynamic_modules_makefile {
1215         # Modules Makefile..
1216         print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
1217         open(FILEHANDLE, ">src/modules/Makefile");
1218         my $extra = "";
1219
1220         if ($config{OSNAME} =~ /CYGWIN/i) {
1221                 $extra = "../inspircd.dll.a";
1222         }
1223
1224 ###
1225 # Module Makefile Header
1226 ###
1227         print FILEHANDLE <<EOF;
1228 # (C) ChatSpike development team
1229 # Makefile by <Craig\@ChatSpike.net>
1230 # Many Thanks to Andrew Church <achurch\@achurch.org>
1231 #    for assisting with making this work right.
1232 #
1233 # Automatically Generated by ./configure to add a modules
1234 # please run ./configure -update or ./configure -modupdate
1235
1236 all: \$(MODULES)
1237
1238 EOF
1239         ###
1240         # End Module Makefile Header
1241         ###
1242
1243         # Create a Modules List..
1244         my $modules = "";
1245         my $cmflags = "";
1246         my $liflags = "";
1247         my $crud = "";
1248
1249         foreach $i (@modlist) {
1250                 ###
1251                 # Write Entry to the MakeFile
1252                 ###
1253                 $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
1254                 $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
1255                 $deps = getdependencies("src/modules/m_".$i.".cpp");
1256         
1257                 #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
1258         
1259                 print FILEHANDLE <<EOCHEESE;
1260 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
1261         \$(CC) -pipe -I../../include \$(FLAGS) $cmflags -export-dynamic -c m_$i.cpp
1262         \$(CC) -pipe \$(FLAGS) -shared $liflags -o m_$i.so m_$i.o $extra
1263
1264 EOCHEESE
1265                 $crud = $crud . "       install -m \$(INSTMODE) m_$i.so \$(MODPATH)\n";
1266 ###
1267                 # End Write Entry to the MakeFile
1268                 ###
1269         }
1270
1271         opendir(DIRHANDLE, "src/modules");
1272         foreach $name (sort readdir(DIRHANDLE)) {
1273                 if ($name =~ /^m_(.+?)$/) {
1274                         $crapola = "";
1275                         $crap3 = "";
1276                         # A module made of multiple files, in a dir, e.g. src/modules/m_spanningtree/
1277                         if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
1278                                 print "Composing Makefile rules for directory \033[1;32m$name\033[0m... ";
1279                                 my $i = 0;
1280                                 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"; 
1281                                 foreach $fname (sort readdir(MDIRHANDLE)) {
1282                                         if ($fname =~ /\.cpp$/) {
1283                                                 $cmflags = getcompilerflags("src/modules/$name/$fname");
1284                                                 $liflags = getlinkerflags("src/modules/$name/$fname");
1285                                                 $deps = getdependencies("src/modules/$name/$fname");
1286                                                 $oname = $fname;
1287                                                 $oname =~ s/\.cpp$/.o/g;
1288                                                 print FILEHANDLE " $name/$oname";
1289                                                 $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";
1290                                                 $crapola = $crapola .  "        \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $name/$oname -c $name/$fname\n\n";
1291                                                 $crap3 = $crap3 . " $name/$oname";
1292                                                 $i++;
1293                                         }
1294                                 }
1295                                 print "(\033[1;32m$i files found\033[0m)\n";
1296                                 print FILEHANDLE "\n    \$(CC) -pipe \$(FLAGS) -shared $liflags -o $name.so $crap3\n";
1297                                 print FILEHANDLE "\n$crapola\n";
1298                                 closedir(MDIRHANDLE);
1299                                 $crud = $crud . "       install -m \$(INSTMODE) $name.so \$(MODPATH)\n";
1300                         }
1301                 }
1302         }
1303         closedir(DIRHANDLE);
1304
1305         print FILEHANDLE "modinst:\n    \@echo \"Installing modules...\"\n" . $crud;
1306 }
1307
1308
1309 sub write_static_makefile {
1310         open(FH,">src/Makefile") or die("Could not write src/Makefile!");
1311         my $i = 0;
1312         my @cmdlist = ();
1313         opendir(DIRHANDLE, "src");
1314         foreach $name (sort readdir(DIRHANDLE)) {
1315                 if ($name =~ /^cmd_(.+)\.cpp$/) {
1316                         $cmdlist[$i++] = $1;
1317                 }
1318         }
1319         closedir(DIRHANDLE);
1320         my $cmdobjs = "";
1321         my $srcobjs = "";
1322         foreach my $cmd (@cmdlist) {
1323                 $cmdobjs = $cmdobjs . "cmd_$cmd.o ";
1324                 $srcobjs = $srcobjs . "cmd_$cmd.cpp ";
1325         }
1326         print FH <<EOM;
1327 # Insp Makefile :p
1328 #
1329 # (C) ChatSpike development team
1330 # Makefile by <Craig\@ChatSpike.net>
1331 # Makefile version 2 (statically linked core) by <brain\@inspircd.org>
1332 #
1333
1334 CC = im a cheezeball
1335
1336 CXXFLAGS = -I../include \${FLAGS}
1337 CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
1338 RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
1339
1340 EOM
1341
1342 $se = "socketengine_select";
1343 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1344         $se = "socketengine_kqueue";
1345 }       
1346 elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1347         $se = "socketengine_epoll";
1348 }
1349
1350         ###
1351         # This next section is for cygwin dynamic module builds.
1352         # Basically, what we do, is build the inspircd core as a library
1353         # then the main executable uses that. the library is capable of
1354         # loading / unloading the modules dynamically :)
1355         # Massive thanks to the guys on #cygwin @ irc.freenode.net for helping
1356         # make this work :)
1357         ###
1358
1359         if ($config{OSNAME} =~ /CYGWIN/i) {
1360                 print FH <<EOM;
1361 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
1362
1363 inspircd.exe: inspircd.dll.a
1364         \$(CC) -o \$@ \$^
1365
1366 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
1367         \$(CC) -shared -Wl,--out-implib=inspircd.dll.a -o inspircd.dll \$^
1368 EOM
1369         } else {
1370                 print FH <<EOM;
1371 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
1372
1373 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
1374         \$(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)
1375 EOM
1376         }
1377
1378         print FH <<EOM;
1379
1380 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
1381         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cull_list.cpp
1382
1383 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
1384         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c snomasks.cpp
1385
1386 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
1387         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c command_parse.cpp
1388
1389 userprocess.o: userprocess.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1390         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c userprocess.cpp
1391
1392 socketengine.o: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
1393         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp $se.cpp
1394
1395 hashcomp.o: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1396         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1397
1398 helperfuncs.o: helperfuncs.cpp ../include/base.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1399         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1400
1401 channels.o: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1402         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1403
1404 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
1405         \${MAKE} -C "modes" DIRNAME="src/modes" CC="\$(CC)" \$(MAKEARGS)
1406         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1407
1408 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
1409         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1410
1411 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
1412         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1413
1414 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
1415         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1416
1417 base.o: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1418         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1419
1420 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
1421         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c configreader.cpp
1422
1423 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
1424         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp $cmdobjs
1425
1426 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
1427         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1428
1429 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
1430         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1431
1432 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
1433         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1434
1435 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
1436         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1437
1438 socket.o: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1439         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1440         
1441 inspsocket.o: inspsocket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1442         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspsocket.cpp
1443
1444 timer.o: timer.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1445         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c timer.cpp
1446
1447 EOM
1448         foreach my $cmd (@cmdlist) {
1449                 print FH <<ITEM;
1450 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
1451         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1452 ITEM
1453         }
1454         close(FH);
1455 }
1456
1457 sub write_dynamic_makefile {
1458
1459         my $i = 0;
1460         my @cmdlist = ();
1461         opendir(DIRHANDLE, "src");
1462         foreach $name (sort readdir(DIRHANDLE)) {
1463                 if ($name =~ /^cmd_(.+)\.cpp$/) {
1464                         $cmdlist[$i++] = $1;
1465                 }
1466         }
1467         closedir(DIRHANDLE);
1468
1469         my $cmdobjs = "";
1470         my $srcobjs = "";
1471         foreach my $cmd (@cmdlist) {
1472                 $cmdobjs = $cmdobjs . "cmd_$cmd.so ";
1473                 $srcobjs = $srcobjs . "cmd_$cmd.cpp ";
1474         }
1475
1476         $se = "socketengine_select";
1477         if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1478                 $se = "socketengine_kqueue";
1479         }
1480         elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1481                 $se = "socketengine_epoll";
1482         }
1483
1484         open(FH,">src/Makefile") or die("Could not write src/Makefile");
1485         print FH <<EOM;
1486 # Insp Makefile :p
1487 #
1488 # (C) ChatSpike development team
1489 # Makefile by <Craig\@ChatSpike.net>
1490 # Makefile version 2 (dynamically linked core) by <brain\@inspircd.org>
1491 #
1492
1493 CC = im a cheezeball
1494
1495 CXXFLAGS = -I../include \${FLAGS}
1496 CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
1497 RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
1498
1499 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
1500
1501 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
1502         \$(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
1503
1504 libIRCDsocketengine.so: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
1505         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp $se.cpp
1506         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsocketengine.so socketengine.o $se.o
1507
1508 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
1509         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c snomasks.cpp
1510         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsnomasks.so snomasks.o
1511
1512 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
1513         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c command_parse.cpp
1514         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcommand_parse.so command_parse.o
1515
1516 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
1517         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cull_list.cpp
1518         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcull_list.so cull_list.o
1519
1520 libIRCDuserprocess.so: userprocess.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1521         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c userprocess.cpp
1522         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDuserprocess.so userprocess.o
1523
1524 libIRCDhash.so: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1525         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1526         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDhash.so hashcomp.o
1527
1528 libIRCDhelper.so: helperfuncs.cpp ../include/base.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1529         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1530         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDhelper.so helperfuncs.o
1531
1532 libIRCDchannels.so: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1533         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1534         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDchannels.so channels.o
1535
1536 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)
1537         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1538         \${MAKE} -C "modes" DIRNAME="src/modes" CC="\$(CC)" \$(MAKEARGS) CPPFILES="\$(CPPFILES)"
1539         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDmode.so mode.o modes/modeclasses.a
1540
1541 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
1542         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1543         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDxline.so xline.o
1544
1545 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
1546         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1547         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDstring.so inspstring.o
1548
1549 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
1550         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1551         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDasyncdns.so dns.o
1552
1553 libIRCDbase.so: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1554         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1555         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDbase.so base.o
1556
1557 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
1558         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c configreader.cpp
1559         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDconfigreader.so configreader.o
1560
1561 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
1562         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
1563         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcommands.so commands.o
1564
1565 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
1566         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1567         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDdynamic.so dynamic.o
1568
1569 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
1570         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1571         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDusers.so users.o
1572
1573 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
1574         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1575         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDmodules.so modules.o
1576
1577 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
1578         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1579         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDwildcard.so wildcard.o
1580
1581 libIRCDsocket.so: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1582         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1583         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsocket.so socket.o
1584
1585 libIRCDinspsocket.so: inspsocket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1586         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspsocket.cpp
1587         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDinspsocket.so inspsocket.o
1588
1589 libIRCDtimer.so: timer.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1590         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c timer.cpp
1591         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDtimer.so timer.o
1592
1593 EOM
1594         foreach my $cmd (@cmdlist) {
1595                 print FH <<ITEM;
1596 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
1597         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1598         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o cmd_$cmd.so cmd_$cmd.o
1599
1600 ITEM
1601         }
1602         close(FH);
1603 }
1604