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