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