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