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