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