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