]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - configure
Move a bundle of stuff to server.cpp from inspircd.cpp
[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()) ? "not found\n" : "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         else
478         {
479                 # Suggestion from nenolod, weed out odd systems which have glibc built
480                 # against 2.4 kernels (ick)
481
482                 $libcv = 0.0;
483                 $kernelv = 0.0;
484                 open (FH,"/lib/libc.so.6|") or $has_epoll = 0;
485                 if ($has_epoll)
486                 {
487                         while (chomp($line = <FH>))
488                         {
489                                 if ($line =~ /GNU C Library .* version (.*?) /)
490                                 {
491                                         $libcv = $1;
492                                 }
493                                 elsif ($line =~ /Compiled on a Linux (.*?\..*?)\.* system/)
494                                 {
495                                         $kernelv = $1;
496                                 }
497                         }
498                         close FH;
499                         if ($libcv < 2.3)
500                         {
501                                 $has_epoll = 0;
502                                 printf "libc too old: $libcv... ";
503                         }
504                         if ($kernelv < 2.6)
505                         {
506                                 $has_epoll = 0;
507                                 printf "libc built against older kernel $kernelv... ";
508                         }
509                 }
510         }
511 }
512 print "yes\n" if $has_epoll == 1;
513 print "no\n" if $has_epoll == 0;
514
515 printf "Checking if Solaris I/O completion ports are available... ";
516 $has_ports = 0;
517 my $system = `uname -s`;
518 chomp ($system);
519 $has_ports = 1 if ($system eq "SunOS");
520
521 if ($has_ports) {
522         my $kernel = `uname -r`;
523         chomp($kernel);
524         if (($kernel !~ /^5\.1./)) {
525                 $has_ports = 0;
526         }
527 }
528 print "yes\n" if $has_ports == 1;
529 print "no\n" if $has_ports == 0;
530
531 if (($config{OSNAME} =~ /CYGWIN/) || ($config{OSNAME} eq "CYG-STATIC")) {
532         $config{HAS_STRLCPY} = "true";
533 }
534
535 $config{HAS_EPOLL} = $has_epoll;
536 $config{HAS_KQUEUE} = $has_kqueue; 
537
538 printf "Checking for libgnutls... ";
539 if (($config{HAS_GNUTLS}) && (($config{HAS_GNUTLS} >= 1.2) || ($config{HAS_GNUTLS} eq "y"))) {
540         print "yes\n";
541         $config{HAS_GNUTLS} = "y";
542 } else {
543         print "no\n";
544         $config{HAS_GNUTLS} = "n";
545 }
546
547 printf "Checking for openssl... ";
548 if (($config{HAS_OPENSSL}) && (($config{HAS_OPENSSL} >= 0.8) || ($config{HAS_OPENSSL} eq "y"))) {
549         print "yes\n";
550         $config{HAS_OPENSSL} = "y";
551 } else {
552         print "no\n";
553         $config{HAS_OPENSSL} = "n";
554 }
555
556 ################################################################################
557 #                         BEGIN INTERACTIVE PART                              #
558 ################################################################################
559
560 # Clear the Screen..
561 if ($interactive)
562 {
563         system("clear");
564         $wholeos = $^O;
565
566         my $rev = getrevision();
567         # Display Introduction Message..
568         print "
569 Welcome to the \033[1mInspIRCd\033[0m Configuration program! (\033[1minteractive mode\033[0m)
570 \033[1mPackage maintainers: Type ./configure --help for non-interactive help\033[0m
571
572 *** If you are unsure of any of these values, leave it blank for    ***
573 *** standard settings that will work, and your server will run      ***
574 *** using them. Please consult your IRC network admin if in doubt.  ***
575
576 Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter
577 a new value. Please note: You will \033[1mHAVE\033[0m to read the docs
578 dir, otherwise you won't have a config file!
579
580 Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos)
581 Maximum file descriptors: \033[1;32m$config{MAX_CLIENT_T}\033[0m
582 Your InspIRCd revision ID is \033[1;32mr$rev\033[0m";
583         if ($rev eq "r0") {
584                 print " (Non-SVN build)";
585         }
586         print ".\n\n";
587
588         $config{CHANGE_COMPILER} = "n";
589         print "I have detected the following compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.x\033[0m)\n";
590
591         while (($config{GCCVER} < 3) || ($config{GCCVER} eq "")) {
592                 print "\033[1;32mIMPORTANT!\033[0m A GCC 2.x compiler has been detected, and
593 should NOT be used. You should probably specify a newer compiler.\n\n";
594                 yesno(CHANGE_COMPILER,"Do you want to change the compiler?");
595                 if ($config{CHANGE_COMPILER} =~ /y/i) {
596                         print "What command do you want to use to invoke your compiler?\n";
597                         print "[\033[1;32m$config{CC}\033[0m] -> ";
598                         chomp($config{CC} = <STDIN>);
599                         if ($config{CC} eq "") {
600                                 $config{CC} = "g++";
601                         }
602                         chomp($foo = `$config{CC} -dumpversion | cut -c 1`);
603                         if ($foo ne "") {
604                                 chomp($config{GCCVER}       = `$config{CC} -dumpversion | cut -c 1`); # we must redo these if we change compilers
605                                 print "Queried compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.x\033[0m)\n";
606                                 if ($config{GCCVER} < 3) {
607                                         print "\033[1;32mGCC 2.x WILL NOT WORK!\033[0m. Let's try that again, shall we?\n";
608                                 }
609                         }
610                         else {
611                                 print "\033[1;32mWARNING!\033[0m Could not execute the compiler you specified. You may want to try again.\n";
612                         }
613                 }
614         }
615
616         print "\n";
617
618         # Directory Settings..
619         my $tmpbase = $config{BASE_DIR};
620         dir_check("do you wish to install the InspIRCd base", "BASE_DIR");
621         if ($tmpbase ne $config{BASE_DIR}) {
622                 $config{CONFIG_DIR}      = resolve_directory($config{BASE_DIR}."/conf");           # Configuration Dir
623                 $config{MODULE_DIR}      = resolve_directory($config{BASE_DIR}."/modules");     # Modules Directory
624                 $config{BINARY_DIR}      = resolve_directory($config{BASE_DIR}."/bin");     # Binary Directory
625                 $config{LIBRARY_DIR}    = resolve_directory($config{BASE_DIR}."/lib");      # Library Directory
626         }
627
628         dir_check("are the configuration files", "CONFIG_DIR");
629         dir_check("are the modules to be compiled to", "MODULE_DIR");
630         dir_check("is the IRCd binary to be placed", "BINARY_DIR");
631         dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
632
633         if ($has_kqueue) {
634                 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?");
635                 print "\n";
636         }
637         if ($has_epoll) {
638                 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?");
639                 print "\n";
640         }
641         if ($has_ports) {
642                 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?");
643                 print "\n";
644         }
645         $chose_hiperf = (($config{USE_EPOLL} eq "y") || ($config{USE_KQUEUE} eq "y") || ($config{USE_PORTS} eq "y"));
646         if (!$chose_hiperf) {
647                 print "No high-performance socket engines are available, or you chose\n";
648                 print "not to enable one. Defaulting to select() engine.\n\n";
649         }
650
651         yesno(IPV6,"Would you like to build InspIRCd with IPv6 support?");
652         print "\n";
653
654         if ($config{IPV6} eq "y") {
655                 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";
656                 $config{SUPPORT_IP6LINKS} = "y";
657         } else {
658                 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)");
659                 print "\n";
660         }
661
662         if (($config{HAS_GNUTLS} eq "y") && ($config{HAS_OPENSSL} eq "y")) {
663                 print "I have detected both \033[1;32mGnuTLS\033[0m and \033[1;32mOpenSSL\033[0m on your system.\n";
664                 print "I will default to GnuTLS. If you wish to use OpenSSL\n";
665                 print "instead, you should enable the OpenSSL module yourself\n";
666                 print "by copying it from src/modules/extra to src/modules.\n\n";
667                 print "Detected GnuTLS version: \033[1;32m" . $gnutls_ver . "\033[0m\n";
668                 print "Detected OpenSSL version: \033[1;32m" . $openssl_ver . "\033[0m\n\n";
669         }
670
671         if ($config{HAS_GNUTLS} eq "y") {
672                 yesno(USE_GNUTLS, "Would you like to enable SSL Support?");
673                 if ($config{USE_GNUTLS} eq "y") {
674                         print "\nUsing GnuTLS SSL module.\n";
675                 }
676         } elsif ($config{HAS_OPENSSL} eq "y") {
677                         yesno(USE_OPENSSL, "Would you like to enable SSL Support?");
678         if ($config{USE_OPENSSL} eq "y") {
679                         print "\nUsing OpenSSL SSL module.\nYou will get better performance if you move to GnuTLS in the future.\n";
680                 }
681         }
682         else {
683                 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";
684         }
685
686         print "\nThe following questions will ask you for various figures relating\n";
687         print "To your IRCd install. Please note that these should usually be left\n";
688         print "as defaults unless you have a real reason to change them. If they\n";
689         print "changed, then the values must be identical on all servers on your\n";
690         print "network, or malfunctions and/or crashes may occur, with the exception\n";
691         print "of the 'maximum number of clients' setting which may be different on\n";
692         print "different servers on the network.\n\n";
693
694         # File Descriptor Settings..
695         promptnumeric("number of clients at any one time", "MAX_CLIENT_T");
696         $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
697         $config{MAX_DESCRIPTORS} = $config{MAX_CLIENT_T};
698
699         promptnumeric("length of nicknames", "NICK_LENGT");
700         promptnumeric("length of channel names", "CHAN_LENGT");
701         promptnumeric("number of mode changes in one line", "MAXI_MODES");
702         promptnumeric("length of an ident (username)", "MAX_IDENT");
703         promptnumeric("length of a quit message", "MAX_QUIT");
704         promptnumeric("length of a channel topic", "MAX_TOPIC");
705         promptnumeric("length of a kick message", "MAX_KICK");
706         promptnumeric("length of a GECOS (real name)", "MAX_GECOS");
707         promptnumeric("length of an away message", "MAX_AWAY");
708 }
709
710 dumphash();
711
712 if (($config{USE_GNUTLS} eq "y") && ($config{HAS_GNUTLS} ne "y"))
713 {
714         print "Sorry, but i couldn't detect gnutls. Make sure gnutls-config is in your path.\n";
715         exit(0);
716 }
717 if (($config{USE_OPENSSL} eq "y") && ($config{HAS_OPENSSL} ne "y"))
718 {
719         print "Sorry, but i couldn't detect openssl. Make sure openssl is in your path.\n";
720         exit(0);
721 }
722
723 if ($config{USE_GNUTLS} eq "y") {
724         $failed = 0;
725         open(TMP, "<src/modules/m_ssl_gnutls.cpp") or $failed = 1;
726         close(TMP);
727         if ($failed) {
728                 print "Symlinking src/modules/m_ssl_gnutls.cpp from extra/\n";
729                 chdir("src/modules");
730                 system("ln -s extra/m_ssl_gnutls.cpp");
731                 chdir("../..");
732         }
733         getmodules();
734         if ($interactive)
735         {
736                 $failed = 0;
737                 open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
738                 close(TMP);
739                 open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
740                 close(TMP);
741                 if ($failed) {
742                         print "SSL Certificates Not found, Generating.. \n\n
743 *************************************************************
744 * Generating the Private Key may take some time, go grab a  *
745 * Coffee. Even better, to generate some more entropy if it  *
746 * is taking a while, open another console and type du / a   *
747 * few times and get that HD going :) Then answer the        *
748 * Questions which follow. If you are unsure, just hit enter *
749 *************************************************************\n\n";
750                         $failed = make_gnutls_cert();
751                         if ($failed) {
752                                 print "\n\033[1;32mCertificate generation failed!\033[0m\n\n";
753                         } else {
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                                 print "Done.\n\n";
758                         }
759                 }
760                 else {
761                         print "SSL Certificates found, skipping.\n\n";
762                 }
763         }
764         else
765         {
766                 print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
767         }
768 } elsif ($config{USE_OPENSSL} eq "y") {
769         $failed = 0;
770         open(TMP, "<src/modules/m_ssl_openssl.cpp") or $failed = 1;
771         close(TMP);
772         if ($failed) {
773                 print "Symlinking src/modules/m_ssl_openssl.cpp from extra/\n";
774                 chdir("src/modules");
775                 system("ln -s extra/m_ssl_openssl.cpp");
776                 chdir("../..");
777         }
778         getmodules();
779         $failed = 0;
780         if ($interactive)
781         {
782                 open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
783                 close(TMP);
784                 open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
785                 close(TMP);
786                 if ($failed) {
787                         print "SSL Certificates Not found, Generating.. \n\n
788 *************************************************************
789 * Generating the certificates may take some time, go grab a *
790 * coffee, or something.                                     *
791 *************************************************************\n\n";
792                         make_openssl_cert();
793                         print "\nCertificate generation complete, copying to config directory... ";
794                         system("mv key.pem $config{CONFIG_DIR}/key.pem");
795                         system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
796                         system("mv dhparams.pem $config{CONFIG_DIR}/dhparams.pem");
797                         print "Done.\n\n";
798                 } else {
799                         print "SSL Certificates found, skipping.\n\n"
800                 }
801         }
802         else
803         {
804                 print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
805         }
806 }
807 if (($config{USE_GNUTLS} eq "n") && ($config{USE_OPENSSL} eq "n")) {
808         print "Skipping SSL Certificate generation, SSL support is not available.\n\n";
809 }
810
811 getosflags();
812 writefiles(1);
813 makecache();
814
815 print "\n\n";
816 print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
817 if (($config{USE_GNUTLS} eq "y") || ($config{USE_OPENSSL} eq "y")) {
818         print "Please remember that to enable \033[1;32mSSL support\033[0m you must\n";
819         print "load the required modules in your config. This configure process\n";
820         print "has just prepared these modules to be compiled for you, and has not\n";
821         print "configured them to be compiled into the core of the ircd.\n";
822 }
823 print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
824 if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
825         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";
826 }
827
828 if ($config{GCCVER} < "3") {
829         print <<FOO2;
830 \033[1;32mWARNING!\033[0m You are attempting to compile InspIRCd on GCC 2.x!
831 GCC 2.x series compilers only had partial (read as broken) C++ support, and
832 your compile will most likely fail horribly! If you have any problems, do NOT
833 report them to the bugtracker or forums without first upgrading your compiler
834 to a newer 3.x or 4.x (or whatever is available currently) version.
835 FOO2
836 }
837
838 ################################################################################
839 #                             HELPER FUNCTIONS                          #
840 ################################################################################
841 sub getcache {
842         # Retrieves the .config.cache file, and loads values into the main config hash.
843         open(CACHE, ".config.cache") or return 0;
844         while (<CACHE>) {
845                 chomp;
846                 # Ignore Blank lines, and comments..
847                 next if /^\s*$/;
848                 next if /^\s*#/;
849                 my ($key, $value) = split("=", $_, 2);
850                 $value =~ /^\"(.*)\"$/;
851                 # Do something with data here!
852                 $config{$key} = $1;
853         }
854         close(CONFIG);
855         return 1;
856 }
857
858 sub makecache {
859         # Dump the contents of %config
860         print "Writing \033[1;32mcache file\033[0m for future ./configures ...\n";
861         open(FILEHANDLE, ">.config.cache");
862         foreach $key (keys %config) {
863                 print FILEHANDLE "$key=\"$config{$key}\"\n";
864         }
865         close(FILEHANDLE);
866 }
867
868 sub dir_check {
869         my ($desc, $hash_key) = @_;
870         my $complete = 0;
871         while (!$complete) {
872                 print "In what directory $desc?\n";
873                 print "[\033[1;32m$config{$hash_key}\033[0m] -> ";
874                 chomp($var = <STDIN>);
875                 if ($var eq "") {
876                         $var = $config{$hash_key};
877                 }
878                 if ($var =~ /^\~\/(.+)$/) {
879                         # Convert it to a full path..
880                         $var = resolve_directory($ENV{HOME} . "/" . $1);
881                 }
882                 elsif ((($config{OSNAME} =~ /MINGW32/i) and ($var !~ /^[A-Z]{1}:\\.*/)) and (substr($var,0,1) ne "/"))
883                 {
884                         # Assume relative Path was given.. fill in the rest.
885                         $var = $this . "/$var";
886                 }
887                 
888                 $var = resolve_directory($var); 
889                 if (! -e $var) {
890                         print "$var does not exist. Create it?\n[\033[1;32my\033[0m] ";
891                         chomp($tmp = <STDIN>);
892                         if (($tmp eq "") || ($tmp =~ /^y/i)) {
893                                 # Attempt to Create the Dir..
894                                 
895                                 system("mkdir -p \"$var\" >> /dev/null 2>&1");
896                                 $chk = system("mkdir -p \"$var\" >> /dev/null 2>&1") / 256;
897                                 if ($chk != 0) {
898                                         print "Unable to create directory. ($var)\n\n";
899                                         # Restart Loop..
900                                         next;
901                                 }
902                         } else {
903                                 # They said they don't want to create, and we can't install there.
904                                 print "\n\n";
905                                 next;
906                         }
907                 } else {
908                         if (!is_dir($var)) {
909                                 # Target exists, but is not a directory.
910                                 print "File $var exists, but is not a directory.\n\n";
911                                 next;
912                         }
913                 }
914                 # Either Dir Exists, or was created fine.
915                 $config{$hash_key} = $var;
916                 $complete = 1;
917                 print "\n";
918         }
919 }
920
921 sub getosflags {
922
923         $config{LDLIBS} = "-lstdc++";
924         $config{FLAGS}  = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
925         $config{DEVELOPER} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated -g";
926         $SHARED = "-Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared";
927         $config{MAKEPROG} = "make";
928
929         if ($config{OSNAME} =~ /darwin/i) {
930                 $config{FLAGS}  = "-DDARWIN -frtti -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
931                 $SHARED = "-bundle -twolevel_namespace -undefined dynamic_lookup";
932                 $config{LDLIBS} = "-ldl -lstdc++";
933         }
934
935         if ($config{OSNAME} =~ /OpenBSD/i) {
936                 $config{MAKEPROG} = "gmake";
937                 chomp($foo = `eg++ -dumpversion | cut -c 1`);
938                 # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
939                 # if theyre not running this, configure lets the build continue but they probably wont manage to
940                 # compile as this standard version is 2.95.3!
941                 if ($foo ne "") {
942                         $config{CC} = "eg++";
943                         chomp($config{GCCVER}       = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change the compiler path
944                 }
945                 return "OpenBSD";
946         }
947
948         if ($config{OSNAME} =~ /Linux/i) {
949                 $config{LDLIBS} = "-ldl -lstdc++";
950                 $config{FLAGS}  = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
951                 $config{FLAGS}  .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
952                 $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
953                 $config{MAKEPROG} = "make";
954                 if ($config{OSNAME} =~ /CYGWIN/) {
955                         $config{FLAGS}  = "-fno-strict-aliasing -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
956                         $config{LDLIBS} = "";
957                         $config{MAKEPROG} = "/usr/bin/make";
958                         $config{MAKEORDER} = "ircd mods";
959                         return "Cygwin";
960                 } elsif ($config{OSNAME} eq "CYG-STATIC") {
961                         $config{FLAGS} = "-fno-strict-aliasing -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
962                         $config{LDLIBS} = "";
963                         $config{MAKEPROG} = "/usr/bin/make";
964                         $config{MAKEORDER} = "mods ircd";
965                         $config{STATICLIBS} = "modules/mods.a";
966                         $config{STATIC_LINK} = "yes";
967                         return "Cygwin-Static";
968                 }
969         }
970
971         if ($config{OSNAME} =~ /FreeBSD/i) {
972                 $config{FLAGS}  .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
973                 $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
974         }
975
976         if ($config{OSNAME} =~ /SunOS/i or $config{OSNAME} =~ /solaris/i)
977         {
978                 # solaris/sunos needs these
979                 # socket = bsd sockets api
980                 # nsl = dns stuff
981                 # rt = POSIX realtime extensions
982                 # resolv = inet_aton only (why isnt this in nsl?!)
983                 $config{MAKEPROG} = "gmake";
984                 $config{LDLIBS} .= " -lsocket -lnsl -lrt -lresolv";
985                 return "Solaris";
986         }
987         
988         if($config{OSNAME} =~ /MINGW32/i)
989         {
990                 # All code is position-independent on windows
991                 $config{FLAGS} =~ s/-fPIC //;
992                 return "MinGW";
993         }
994
995         return $config{OSNAME};
996 }
997
998 sub writefiles {
999         my($writeheader) = @_;
1000         # First File.. inspircd_config.h
1001         chomp(my $incos = `uname -n -s -r`);
1002         chomp($version = `sh src/version.sh`);
1003         chomp(my $revision2 = getrevision());
1004         if ($writeheader == 1)
1005         {
1006                 print "Writing \033[1;32minspircd_config.h\033[0m\n";
1007                 open(FILEHANDLE, ">include/inspircd_config.h");
1008                 my $NL = $config{NICK_LENGT}+1;
1009                 my $CL = $config{CHAN_LENGT}+1;
1010                 print FILEHANDLE <<EOF;
1011 /* Auto generated by configure, do not modify! */
1012 #ifndef __CONFIGURATION_AUTO__
1013 #define __CONFIGURATION_AUTO__
1014
1015 /* this is for windows support. */
1016 #define CoreExport /**/
1017 #define DllExport /**/
1018
1019 #define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
1020 #define MOD_PATH "$config{MODULE_DIR}"
1021 #define VERSION "$version"
1022 #define REVISION "$revision2"
1023 #define MAXCLIENTS $config{MAX_CLIENT}
1024 #define MAXCLIENTS_S "$config{MAX_CLIENT}"
1025 #define SOMAXCONN_S "$config{_SOMAXCONN}"
1026 #define MAX_DESCRIPTORS $config{MAX_DESCRIPTORS}
1027 #define NICKMAX $NL
1028 #define CHANMAX $CL
1029 #define MAXMODES $config{MAXI_MODES}
1030 #define IDENTMAX $config{MAX_IDENT}
1031 #define MAXQUIT $config{MAX_QUIT}
1032 #define MAXTOPIC $config{MAX_TOPIC}
1033 #define MAXKICK $config{MAX_KICK}
1034 #define MAXGECOS $config{MAX_GECOS}
1035 #define MAXAWAY $config{MAX_AWAY}
1036 #define OPTIMISATION $config{OPTIMITEMP}
1037 #define LIBRARYDIR "$config{LIBRARY_DIR}"
1038 #define SYSTEM "$incos"
1039 EOF
1040 print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
1041
1042                 if ($config{OSNAME} =~ /SunOS/i) {
1043                         print FILEHANDLE "#define IS_SOLARIS\n";
1044                 }
1045                 if ($config{OSNAME} =~ /CYGWIN/i) {
1046                         print FILEHANDLE "#define IS_CYGWIN\n";
1047                         print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE        1024\n#endif\n";
1048                 }
1049                 if ($config{OSNAME} =~ /MINGW32/i) {
1050                         print FILEHANDLE "#define IS_MINGW\n";
1051                 }
1052                 if ($config{OSNAME} =~ /CYG-STATIC/i) {
1053                         print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE    1024\n#endif\n";
1054                 }
1055                 if ($config{STATIC_LINK} eq "yes") {
1056                         print FILEHANDLE "#define STATIC_LINK\n";
1057                 }
1058                 if ($config{GCCVER} >= 3) {
1059                         print FILEHANDLE "#define GCC3\n";
1060                 }
1061                 if ($config{HAS_STRLCPY} eq "true") {
1062                         print FILEHANDLE "#define HAS_STRLCPY\n";
1063                 }
1064                 if ($config{HAS_STDINT} eq "true") {
1065                         print FILEHANDLE "#define HAS_STDINT\n";
1066                 }
1067                 if ($config{IPV6} =~ /y/i) {
1068                         print FILEHANDLE "#define IPV6\n";
1069                 }
1070                 if ($config{SUPPORT_IP6LINKS} =~ /y/i) {
1071                         print FILEHANDLE "#define SUPPORT_IP6LINKS\n";
1072                 }
1073                 my $use_hiperf = 0;
1074                 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1075                         print FILEHANDLE "#define USE_KQUEUE\n";
1076                         $se = "socketengine_kqueue";
1077                         $use_hiperf = 1;
1078                 }
1079                 if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1080                         print FILEHANDLE "#define USE_EPOLL\n";
1081                         $se = "socketengine_epoll";
1082                         $use_hiperf = 1;
1083                 }
1084                 if (($has_ports) && ($config{USE_PORTS} eq "y")) {
1085                         print FILEHANDLE "#define USE_PORTS\n";
1086                         $se = "socketengine_ports";
1087                         $use_hiperf = 1;
1088                 }
1089                 # user didn't choose either epoll or select for their OS.
1090                 # default them to USE_SELECT (ewwy puke puke)
1091                 if (!$use_hiperf) {
1092                         print FILEHANDLE "#define USE_SELECT\n";
1093                         $se = "socketengine_select";
1094                 }
1095                 print FILEHANDLE "\n#endif\n";
1096                 close(FILEHANDLE);
1097         }
1098
1099         if ($writeheader)
1100         {
1101                 open(FILEHANDLE, ">include/inspircd_se_config.h");
1102                 print FILEHANDLE <<EOF;
1103 /* Auto generated by configure, do not modify or commit to svn! */
1104 #ifndef __CONFIGURATION_SOCKETENGINE__
1105 #define __CONFIGURATION_SOCKETENGINE__
1106
1107 #include "$se.h"
1108
1109 #endif
1110 EOF
1111                 close(FILEHANDLE);
1112         }
1113
1114
1115         # Create a Modules List..
1116         my $modules = "";
1117         foreach $i (@modlist)
1118         {
1119                 if ($config{STATIC_LINK} eq "yes") {
1120                         $modules .= "m_".$i.".o ";
1121                 }
1122                 else {
1123                         $modules .= "m_".$i.".so ";
1124                 }
1125         }
1126         chomp($modules);   # Remove Redundant whitespace..
1127
1128         opendir(DIRHANDLE, "src/modules");
1129         foreach $name (sort readdir(DIRHANDLE)) {
1130                 if ($name =~ /^m_(.+?)$/) {
1131                         if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
1132                                 closedir(MDIRHANDLE);
1133                                 $modules .= "$name.so ";
1134                         }
1135                 }
1136         }
1137         closedir(DIRHANDLE);
1138
1139
1140         # Write all .in files.
1141         my $tmp = "";
1142         my $file = "";
1143         my $exe = "inspircd";
1144
1145         if ($config{OSNAME} =~ /CYGWIN/i) {
1146                 $exe = "inspircd.exe";
1147         }
1148
1149         opendir(DIRHANDLE, $this);
1150
1151         # Do this once here, and cache it in the .*.inc files,
1152         # rather than attempting to read src/version.sh from
1153         # compiled code -- we might not have the source to hand.
1154         # Fix for bug#177 by Brain.
1155
1156         chomp(my $version = `sh ./src/version.sh`);
1157         chomp(my $revision = getrevision());
1158         $version = "$version(r$revision)";
1159
1160         my $LIBEXT = "so";
1161         if ($config{IS_DARWIN} eq "YES")
1162         {
1163                 $LIBEXT = "dylib";
1164         }
1165         # We can actually parse any file starting with . and ending with .inc,
1166         # but right now we only parse .inspircd.inc to form './inspircd'
1167
1168         foreach $name (sort readdir(DIRHANDLE)) {
1169                 if ($name =~ /^\.(.+)\.inc$/) {
1170                         $file = $1;
1171
1172                         # Bug #353, omit this on non-darwin
1173                         next if (($config{OSNAME} !~ /darwin/) && ($file eq "org.inspircd.plist"));
1174
1175                         # All .name.inc files need parsing!
1176                         $tmp = "";
1177                         open(FILEHANDLE, ".$file.inc");
1178                         while (<FILEHANDLE>) {
1179                                 $tmp .= $_;
1180                         }
1181                         close(FILEHANDLE);
1182
1183                         $tmp =~ s/\@CC\@/$config{CC}/;
1184                         $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
1185                         $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
1186                         $tmp =~ s/\@DEVELOPER\@/$config{DEVELOPER}/;
1187                         $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
1188                         $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/;
1189                         $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
1190                         $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
1191                         $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
1192                         $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
1193                         $tmp =~ s/\@LIBRARY_EXT\@/$LIBEXT/;
1194                         $tmp =~ s/\@MODULES\@/$modules/;
1195                         $tmp =~ s/\@STARTSCRIPT\@/$config{STARTSCRIPT}/;
1196                         $tmp =~ s/\@DESTINATION\@/$config{DESTINATION}/;
1197                         $tmp =~ s/\@EXTRA_DIR\@/$config{EXTRA_DIR}/;
1198                         $tmp =~ s/\@EXECUTABLE\@/$exe/;
1199                         $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
1200                         $tmp =~ s/\@STATICLIBS\@/$config{STATICLIBS}/;
1201                         $tmp =~ s/\@VERSION\@/$version/;
1202
1203                         print "Writing \033[1;32m$file\033[0m\n";
1204                         open(FILEHANDLE, ">$file");
1205                         print FILEHANDLE $tmp;
1206                 }
1207         }
1208         closedir(DIRHANDLE);
1209
1210         # Make inspircd executable!
1211         chmod 0744, 'inspircd';
1212
1213         if ($config{STATIC_LINK} eq "yes") {
1214                 print "Writing static-build \033[1;32msrc/Makefile\033[0m\n";
1215                 write_static_makefile();
1216                 write_static_modules_makefile();
1217         } elsif ($config{OSNAME} =~ /CYGWIN/i) {
1218                 print "Writing cygwin-build \033[1;32msrc/Makefile\033[0m\n";
1219                 write_static_makefile();
1220                 write_dynamic_modules_makefile();
1221         } else {
1222                 print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
1223                 write_dynamic_makefile();
1224                 write_dynamic_modules_makefile();
1225         }
1226 }
1227
1228 sub write_static_modules_makefile {
1229         # Modules Makefile..
1230         print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
1231         open(FILEHANDLE, ">src/modules/Makefile");
1232
1233         ###
1234         # Module Makefile Header
1235         ###
1236         print FILEHANDLE <<EOF;
1237 ###################################################
1238 # Copyright 2002-2007 The InspIRCd Development Team
1239 #  http://www.inspircd.org/wiki/index.php/Credits
1240 #
1241 # Thanks to Andrew Church <achurch\@achurch.org>
1242 #  for assisting with making this work right.
1243 #
1244 # Automatically Generated by ./configure to add a
1245 #  modules please run ./configure --modupdate
1246 ###################################################
1247
1248 all: \$(MODULES)
1249
1250 EOF
1251         ###
1252         # End Module Makefile Header
1253         ###
1254
1255         # Create a Modules List..
1256         my $modules = "";
1257         my $cmflags = "";
1258         my $liflags = "";
1259
1260         open(MODLIST,">include/modlist.h");
1261
1262         ###
1263         # Include File Header
1264         ###
1265         print MODLIST <<HEADER;
1266 // Generated automatically by configure. DO NOT EDIT!
1267
1268 #ifndef __SYMBOLS__H_CONFIGURED__
1269 #define __SYMBOLS__H_CONFIGURED__
1270
1271 HEADER
1272         ###
1273         # End Include File Header
1274         ###
1275
1276         # Place Module List into Include
1277         foreach $i (@modlist) {
1278                 if ($i !~ /_static$/) {
1279                         print MODLIST "extern \"C\" void * $i\_init (void);\n";
1280                 }
1281         }
1282         print MODLIST "\nstruct {const char *name; initfunc *value; } modsyms[] = {\n";
1283
1284         ###
1285         # Build Module Crap
1286         ###
1287         foreach $i (@modlist)
1288         {
1289                 if ($i !~ /_static$/) {
1290                         $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
1291                         $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
1292                         $deps = getdependencies("src/modules/m_".$i.".cpp");
1293
1294                         #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
1295
1296                         ###
1297                         # Write Entry to the Makefile
1298                         ###
1299                         print FILEHANDLE <<EOCHEESE;
1300 m_$i.o: .m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h $deps
1301         \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c .m_$i\_static.cpp
1302         mv .m_$i\_static.o ../m_$i.o
1303
1304 EOCHEESE
1305                         ###
1306                         # End Write Entry to the MakeFile
1307                         ###
1308                         print "Configuring module [\033[1;32mm_$i.so\033[0m] for static linking... ";
1309                         open(MODULE,"<src/modules/m_".$i.".cpp") or die("Could not open m_".$i.".cpp");
1310                         open(MUNGED,">src/modules/.m_".$i."_static.cpp") or die("Could not create .m_".$i."_static.cpp");
1311                         while (chomp($a = <MODULE>)) { 
1312                                 $a =~ s/init_module/$i\_init/g;
1313                                 print MUNGED "$a\n";
1314                         }
1315                         close(MODULE);
1316                         close(MUNGED);
1317                         print MODLIST <<EOENT;
1318 {"m_$i.so",\&$i\_init},
1319 EOENT
1320                         print "done\n";
1321                 }
1322         }
1323
1324         print MODLIST "{0}};\n\n#endif\n";
1325         close(MODLIST);
1326 }
1327
1328 sub write_dynamic_modules_makefile {
1329         # Modules Makefile..
1330         print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
1331         open(FILEHANDLE, ">src/modules/Makefile");
1332         my $extra = "";
1333
1334         if ($config{OSNAME} =~ /CYGWIN/i) {
1335                 $extra = "../inspircd.dll.a";
1336         }
1337
1338 ###
1339 # Module Makefile Header
1340 ###
1341         print FILEHANDLE <<EOF;
1342 ###################################################
1343 # Copyright 2002-2007 The InspIRCd Development Team
1344 #  http://www.inspircd.org/wiki/index.php/Credits
1345 #
1346 # Thanks to Andrew Church <achurch\@achurch.org>
1347 #   for assisting with making this work right.
1348 #
1349 # Automatically Generated by ./configure to add a
1350 #  modules please run ./configure -modupdate
1351 ###################################################
1352
1353 all: \$(MODULES)
1354
1355 EOF
1356         ###
1357         # End Module Makefile Header
1358         ###
1359
1360         # Create a Modules List..
1361         my $modules = "";
1362         my $cmflags = "";
1363         my $liflags = "";
1364         my $crud = "";
1365
1366         foreach $i (@modlist) {
1367                 ###
1368                 # Write Entry to the MakeFile
1369                 ###
1370                 $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
1371                 $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
1372                 $deps = getdependencies("src/modules/m_".$i.".cpp");
1373         
1374                 #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
1375         
1376                 print FILEHANDLE <<EOCHEESE;
1377 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
1378         \$(CC) -pipe -I../../include \$(FLAGS) $cmflags -export-dynamic -c m_$i.cpp
1379 EOCHEESE
1380
1381 if ($config{OSNAME} =~ /darwin/) {
1382                 print FILEHANDLE <<EOCHEESE;
1383         \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) -bundle $liflags -o m_$i.so m_$i.o $extra
1384
1385 EOCHEESE
1386 } else {
1387                 print FILEHANDLE <<EOCHEESE;
1388         \$(CC) -pipe \$(FLAGS) -shared $liflags -o m_$i.so m_$i.o $extra
1389
1390 EOCHEESE
1391 }
1392                 $crud = $crud . "       install -m \$(INSTMODE) m_$i.so \$(MODPATH)\n";
1393 ###
1394                 # End Write Entry to the MakeFile
1395                 ###
1396         }
1397
1398         opendir(DIRHANDLE, "src/modules");
1399         foreach $name (sort readdir(DIRHANDLE)) {
1400                 if ($name =~ /^m_(.+?)$/) {
1401                         $crapola = "";
1402                         $crap3 = "";
1403                         $mliflags = "";
1404                         # A module made of multiple files, in a dir, e.g. src/modules/m_spanningtree/
1405                         if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
1406                                 my $i = 0;
1407                                 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"; 
1408                                 foreach $fname (sort readdir(MDIRHANDLE)) {
1409                                         if ($fname =~ /\.cpp$/) {
1410                                                 $cmflags = getcompilerflags("src/modules/$name/$fname");
1411                                                 $mliflags = $mliflags . " " . getlinkerflags("src/modules/$name/$fname");
1412                                                 $deps = getdependencies("src/modules/$name/$fname");
1413                                                 $oname = $fname;
1414                                                 $oname =~ s/\.cpp$/.o/g;
1415                                                 print FILEHANDLE " $name/$oname";
1416                                                 $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";
1417                                                 $crapola = $crapola .  "        \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $name/$oname -c $name/$fname\n\n";
1418                                                 $crap3 = $crap3 . " $name/$oname";
1419                                                 $i++;
1420                                         }
1421                                 }
1422                                 print "Composing Makefile rules for directory \033[1;32m$name\033[0m... (\033[1;32m$i files found\033[0m)\n";
1423                                 if ($config{IS_DARWIN} eq "YES") {
1424                                         print FILEHANDLE "\n    \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) -bundle -o $name.so $crap3\n"; 
1425                                 } else {
1426                                         print FILEHANDLE "\n    \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $crap3\n";
1427                                 }
1428                                 print FILEHANDLE "\n$crapola\n";
1429                                 closedir(MDIRHANDLE);
1430                                 $crud = $crud . "       install -m \$(INSTMODE) $name.so \$(MODPATH)\n";
1431                         }
1432                 }
1433         }
1434         closedir(DIRHANDLE);
1435
1436         print FILEHANDLE "modinst:\n    \@echo \"Installing modules...\"\n" . $crud;
1437 }
1438
1439
1440 sub write_static_makefile {
1441         open(FH,">src/Makefile") or die("Could not write src/Makefile!");
1442         my $i = 0;
1443         my @cmdlist = ();
1444         opendir(DIRHANDLE, "src");
1445         foreach $name (sort readdir(DIRHANDLE)) {
1446                 if ($name =~ /^cmd_(.+)\.cpp$/) {
1447                         $cmdlist[$i++] = $1;
1448                 }
1449         }
1450         closedir(DIRHANDLE);
1451         my $cmdobjs = "";
1452         my $srcobjs = "";
1453         foreach my $cmd (@cmdlist) {
1454                 $cmdobjs = $cmdobjs . "cmd_$cmd.o ";
1455                 $srcobjs = $srcobjs . "cmd_$cmd.cpp ";
1456         }
1457         print FH <<EOM;
1458 ###################################################
1459 # Copyright 2002-2007 The InspIRCd Development Team
1460 #  http://www.inspircd.org/wiki/index.php/Credits
1461 #
1462 # Thanks to Andrew Church <achurch\@achurch.org>
1463 #  for assisting with making this work right.
1464 #
1465 # This file is automagically generated by configure
1466 # Any changes made will be lost on ./configure
1467 ###################################################
1468
1469 CC = im a cheezeball
1470
1471 CXXFLAGS = -I../include \${FLAGS}
1472 CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
1473 RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
1474
1475 EOM
1476
1477 $se = "socketengine_select";
1478 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1479         $se = "socketengine_kqueue";
1480 }       
1481 elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1482         $se = "socketengine_epoll";
1483 }
1484 elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
1485         $se = "socketengine_ports";
1486 }
1487
1488         ###
1489         # This next section is for cygwin dynamic module builds.
1490         # Basically, what we do, is build the inspircd core as a library
1491         # then the main executable uses that. the library is capable of
1492         # loading / unloading the modules dynamically :)
1493         # Massive thanks to the guys on #cygwin @ irc.freenode.net for helping
1494         # make this work :)
1495         ###
1496
1497         if ($config{OSNAME} =~ /CYGWIN/i) {
1498                 print FH <<EOM;
1499 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
1500
1501 inspircd.exe: inspircd.dll.a
1502         \$(CC) -o \$@ \$^
1503
1504 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
1505         \$(CC) -shared -Wl,--out-implib=inspircd.dll.a -o inspircd.dll \$^
1506 EOM
1507         } else {
1508                 print FH <<EOM;
1509 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
1510
1511 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
1512         \$(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)
1513 EOM
1514         }
1515
1516         print FH <<EOM;
1517
1518 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
1519         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cull_list.cpp
1520
1521 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
1522         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c snomasks.cpp
1523
1524 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
1525         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c command_parse.cpp
1526
1527 userprocess.o: userprocess.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1528         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c userprocess.cpp
1529
1530 socketengine.o: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
1531         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp $se.cpp
1532
1533 hashcomp.o: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1534         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1535
1536 helperfuncs.o: helperfuncs.cpp ../include/base.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1537         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1538
1539 channels.o: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1540         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1541
1542 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
1543         \${MAKE} -C "modes" DIRNAME="src/modes" CC="\$(CC)" \$(MAKEARGS)
1544         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1545
1546 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
1547         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1548
1549 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
1550         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1551
1552 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
1553         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1554
1555 base.o: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1556         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1557
1558 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
1559         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c configreader.cpp
1560
1561 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
1562         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp $cmdobjs
1563
1564 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
1565         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1566
1567 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
1568         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1569
1570 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
1571         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1572
1573 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
1574         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1575
1576 socket.o: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1577         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1578         
1579 inspsocket.o: inspsocket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1580         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspsocket.cpp
1581
1582 timer.o: timer.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1583         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c timer.cpp
1584
1585 EOM
1586         foreach my $cmd (@cmdlist) {
1587                 print FH <<ITEM;
1588 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
1589         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1590 ITEM
1591         }
1592         close(FH);
1593 }
1594
1595 sub write_dynamic_makefile {
1596
1597         my $i = 0;
1598         my @cmdlist = ();
1599         opendir(DIRHANDLE, "src");
1600         foreach $name (sort readdir(DIRHANDLE)) {
1601                 if ($name =~ /^cmd_(.+)\.cpp$/) {
1602                         $cmdlist[$i++] = $1;
1603                 }
1604         }
1605         closedir(DIRHANDLE);
1606
1607         my $cmdobjs = "";
1608         my $srcobjs = "";
1609         foreach my $cmd (@cmdlist) {
1610                 $cmdobjs = $cmdobjs . "cmd_$cmd.so ";
1611                 $srcobjs = $srcobjs . "cmd_$cmd.cpp ";
1612         }
1613
1614         $se = "socketengine_select";
1615         if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1616                 $se = "socketengine_kqueue";
1617         }
1618         elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1619                 $se = "socketengine_epoll";
1620         }
1621         elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
1622                 $se = "socketengine_ports";
1623         }
1624
1625         open(FH,">src/Makefile") or die("Could not write src/Makefile");
1626         print FH <<EOM;
1627 ###################################################
1628 # Copyright 2002-2007 The InspIRCd Development Team
1629 #  http://www.inspircd.org/wiki/index.php/Credits
1630 #
1631 # Thanks to Andrew Church <achurch\@achurch.org>
1632 #  for assisting with making this work right.
1633 #
1634 # This file is automagically generated by configure 
1635 # Any changes made will be lost on ./configure         
1636 ###################################################
1637
1638 CC = im a cheezeball
1639
1640 CXXFLAGS = -I../include \${FLAGS}
1641 CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
1642 RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
1643
1644 EOM
1645
1646 if ($config{IS_DARWIN} eq "YES") {
1647         print FH <<EOM;
1648 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 libIRCDserver.dylib inspircd
1649
1650 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 libIRCDserver.dylib
1651         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd.cpp
1652         \$(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 libIRCDserver.dylib
1653
1654 libIRCDsocketengine.dylib: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
1655         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp
1656         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c $se.cpp
1657         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDsocketengine.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDsocketengine.dylib socketengine.o $se.o
1658
1659 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
1660         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c snomasks.cpp
1661         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDsnomasks.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDsnomasks.dylib snomasks.o
1662
1663 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
1664         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c command_parse.cpp
1665         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDcommand_parse.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDcommand_parse.dylib command_parse.o
1666
1667 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
1668         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cull_list.cpp
1669         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDcull_list.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDcull_list.dylib cull_list.o
1670
1671 libIRCDuserprocess.dylib: userprocess.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1672         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c userprocess.cpp
1673         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDuserprocess.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDuserprocess.dylib userprocess.o
1674
1675 libIRCDhash.dylib: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1676         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1677         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDhash.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDhash.dylib hashcomp.o
1678
1679 libIRCDhelper.dylib: helperfuncs.cpp ../include/base.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1680         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1681         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDhelper.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDhelper.dylib helperfuncs.o
1682
1683 libIRCDchannels.dylib: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1684         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1685         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDchannels.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDchannels.dylib channels.o
1686
1687 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)
1688         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1689         \${MAKE} -C "modes" DIRNAME="src/modes" CC="\$(CC)" \$(MAKEARGS) CPPFILES="\$(CPPFILES)"
1690         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDmode.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDmode.dylib mode.o modes/modeclasses.a
1691
1692 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
1693         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1694         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDxline.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDxline.dylib xline.o
1695
1696 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
1697         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1698         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDstring.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDstring.dylib inspstring.o
1699
1700 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
1701         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1702         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDasyncdns.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDasyncdns.dylib dns.o
1703
1704 libIRCDbase.dylib: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1705         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1706         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDbase.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDbase.dylib base.o
1707
1708 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
1709         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c configreader.cpp
1710         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDconfigreader.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDconfigreader.dylib configreader.o
1711
1712 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
1713         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
1714         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDcommands.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDcommands.dylib commands.o
1715
1716 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
1717         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1718         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDdynamic.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDdynamic.dylib dynamic.o
1719
1720 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
1721         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1722         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDusers.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDusers.dylib users.o
1723
1724 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
1725         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1726         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDmodules.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDmodules.dylib modules.o
1727
1728 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
1729         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1730         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDwildcard.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDwildcard.dylib wildcard.o
1731
1732 libIRCDsocket.dylib: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1733         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1734         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDsocket.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDsocket.dylib socket.o
1735
1736 libIRCDinspsocket.dylib: inspsocket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1737         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspsocket.cpp
1738         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDinspsocket.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDinspsocket.dylib inspsocket.o
1739
1740 libIRCDtimer.dylib: timer.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1741         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c timer.cpp
1742         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDtimer.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDtimer.dylib timer.o
1743
1744 libIRCDserver.dylib: server.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1745         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c server.cpp
1746         \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDserver.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDserver.dylib server.o
1747
1748 EOM
1749
1750 } else {
1751
1752         print FH <<EOM;
1753 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 libIRCDserver.so inspircd
1754
1755 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 libIRCDserver.so
1756         \$(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 libIRCDserver.so
1757
1758 libIRCDsocketengine.so: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
1759         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp $se.cpp
1760         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsocketengine.so socketengine.o $se.o
1761
1762 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
1763         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c snomasks.cpp
1764         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsnomasks.so snomasks.o
1765
1766 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
1767         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c command_parse.cpp
1768         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcommand_parse.so command_parse.o
1769
1770 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
1771         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cull_list.cpp
1772         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcull_list.so cull_list.o
1773
1774 libIRCDuserprocess.so: userprocess.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h
1775         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c userprocess.cpp
1776         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDuserprocess.so userprocess.o
1777
1778 libIRCDhash.so: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1779         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1780         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDhash.so hashcomp.o
1781
1782 libIRCDhelper.so: helperfuncs.cpp ../include/base.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1783         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1784         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDhelper.so helperfuncs.o
1785
1786 libIRCDchannels.so: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1787         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1788         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDchannels.so channels.o
1789
1790 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)
1791         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1792         \${MAKE} -C "modes" DIRNAME="src/modes" CC="\$(CC)" \$(MAKEARGS) CPPFILES="\$(CPPFILES)"
1793         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDmode.so mode.o modes/modeclasses.a
1794
1795 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
1796         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1797         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDxline.so xline.o
1798
1799 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
1800         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1801         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDstring.so inspstring.o
1802
1803 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
1804         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1805         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDasyncdns.so dns.o
1806
1807 libIRCDbase.so: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1808         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1809         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDbase.so base.o
1810
1811 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
1812         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c configreader.cpp
1813         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDconfigreader.so configreader.o
1814
1815 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
1816         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
1817         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcommands.so commands.o
1818
1819 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
1820         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1821         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDdynamic.so dynamic.o
1822
1823 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
1824         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1825         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDusers.so users.o
1826
1827 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
1828         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1829         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDmodules.so modules.o
1830
1831 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
1832         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1833         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDwildcard.so wildcard.o
1834
1835 libIRCDsocket.so: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1836         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1837         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDsocket.so socket.o
1838
1839 libIRCDinspsocket.so: inspsocket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1840         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspsocket.cpp
1841         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDinspsocket.so inspsocket.o
1842
1843 libIRCDtimer.so: timer.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h ../include/timer.h
1844         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c timer.cpp
1845         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDtimer.so timer.o
1846
1847 libIRCDserver.so: server.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1848         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c server.cpp
1849         \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDserver.so server.o
1850
1851 EOM
1852 }
1853         foreach my $cmd (@cmdlist) {
1854                 print FH <<ITEM;
1855 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
1856         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1857         \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o
1858
1859 ITEM
1860         }
1861         close(FH);
1862 }
1863