]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - configure
Added a 'Base' installation path to allow installing of the launcher (handy)
[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 $config{OPTIMITEMP}         = "0";                                              # Default Optimisation Value
25 $config{OPTIMISATI}         = "-g";                                             # Optimisation Flag
26 $config{NICK_LENGT}         = "31";                                             # Default Nick Length
27 $config{CHAN_LENGT}         = "64";                                             # Default Channel Name Length
28 $config{MAX_CHANNE}         = "20";                                             # Default Max. Channels per user..
29 $config{MAXI_MODES}         = "20";                                             # Default Max. Number of Modes set at once.
30 $config{HAS_STRLCPY}        = "false";                                          # strlcpy Check.
31 $config{USE_KQUEUE}         = "y";                                              # kqueue enabled
32 $config{USE_EPOLL}          = "y";                                              # epoll enabled
33 $config{STATIC_LINK}        = "no";                                             # are doing static modules?
34 chomp($config{MAX_CLIENT_T} = `sh -c \"ulimit -n\"`);                           # FD Limit
35 chomp($config{GCCVER}       = `gcc -dumpversion | cut -c 1`);                   # Major GCC Version
36 chomp($config{GCC34}        = `gcc -dumpversion | cut -c 3`);                   # Minor GCC Version
37 chomp($config{OSNAME}       = `/bin/uname`);                                    # Operating System Name
38 $config{CC}                 = "g++";                                            # C++ compiler
39 $config{MAKEORDER}          = "ircd mods config bininst";                       # build order
40 $config{STATICLIBS}         = "";                                               # library archive path
41 $config{MAX_IDENT}          = "12";                                             # max ident size
42 $config{MAX_QUIT}           = "255";                                            # max quit message size
43 $config{MAX_TOPIC}          = "307";                                            # max topic size
44 $config{MAX_KICK}           = "255";                                            # max kick message size
45 $config{MAX_GECOS}          = "128";                                            # max GECOS size
46 $config{MAX_AWAY}           = "200";                                            # max AWAY size
47
48 if ((!$config{OSNAME}) || ($config{OSNAME} eq "")) {
49   chomp($config{OSNAME} = `/usr/bin/uname`);
50   if ((!$config{OSNAME}) || ($config{OSNAME} eq "")){
51         $config{OSNAME} = "Unknown";
52   }
53 }
54
55 if (!$config{MAX_CLIENT_T}) { 
56   $config{MAX_CLIENT_T} = 1024;                                 # Set a reasonable 'Default'
57   $fd_scan_fail = "true";                                       # Used Later
58 }
59
60 # Get and Set some important vars..
61 getmodules();
62
63 my $arg = $ARGV[0];                                             # Do Some Argument Checks..
64 if ($arg eq "-clean") { `rm -rf .config.cache`; }               # Remove the config.cache file.
65
66 if ($arg eq "-update") {
67   # Does the cache file exist?
68   if (!getcache()) {
69     # No, No it doesn't.. *BASH*
70     print "You have not run ./configure before. Please do this before trying to run the update script.\n";
71     exit 0;
72   } else {
73     # We've Loaded the cache file and all our variables..
74     print "Updating Files..\n";
75     getosflags();
76     $has_epoll = $config{HAS_EPOLL};
77     $has_kqueue = $config{HAS_KQUEUE};
78     writefiles();
79     print "Complete.\n";
80     exit;
81   }
82 }
83
84 print "Checking for cache from previous configure...\n";
85 getcache();
86 print "Checking operating system version...\n";
87 getosflags();
88
89 if (!$config{MAX_CLIENT}) { 
90   # If the cache hasn't set the max clients, copy the variable of MAX_CLIENT_T, this
91   # allows us to keep _T for testing purposes. (ie. "Are you sure you want to go
92   # higher than the found value" :))
93   $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
94 }
95
96 printf "Checking if strlcpy exists... ";
97 # Perform the strlcpy() test..
98 $config{HAS_STRLCPY} = "false";
99 my $fail = 0;
100 open(STRLCPY, "</usr/include/string.h") or $fail = 1;
101 if (!$fail)
102 {
103         while (chomp($line = <STRLCPY>))
104         {
105                 # try and find the delcaration of:
106                 # size_t strlcpy(...)
107                 if ($line =~ /size_t(\0x9|\s)+strlcpy/)
108                 {
109                         $config{HAS_STRLCPY} = "true";
110                 }
111         }
112         close(STRLCPY);
113 }
114 print "yes\n" if $config{HAS_STRLCPY} eq "true";
115 print "no\n" if $config{HAS_STRLCPY} eq "false";
116
117 printf "Checking if kqueue exists... ";
118 $has_kqueue = 0;
119 $fail = 0;
120 open(KQUEUE, "</usr/include/sys/event.h") or $fail = 1;
121 if (!$fail)
122 {
123         while (chomp($line = <KQUEUE>))
124         {
125                 # try and find the delcaration of:
126                 # int kqueue(void);
127                 if ($line =~ /int(\0x9|\s)+kqueue/)
128                 {
129                         $has_kqueue = 1;
130                 }
131         }
132         close(KQUEUE);
133 }
134 print "yes\n" if $has_kqueue == 1;
135 print "no\n" if $has_kqueue == 0;
136
137 printf "Checking if epoll exists... ";
138 $has_epoll = 0;
139 $fail = 0;
140 open(EPOLL, "</usr/include/sys/epoll.h") or $fail = 1;
141 if (!$fail)
142 {
143         while (chomp($line = <EPOLL>))
144         {
145                 # try and find the declaration of:
146                 # extern int epoll_create (int __size) __THROW;
147                 if (($line =~ /int(\0x9|\s)+epoll_create(\0x9|\s)+\(/) || ($line =~ /int(\0x9|\s)+epoll_create\(/))
148                 {
149                         $has_epoll = 1;
150                 }
151         }
152         close(EPOLL);
153 }
154 if ($has_epoll) {
155         my $kernel = `uname -r`;
156         chomp($kernel);
157         if (($kernel =~ /2\.0/) || ($kernel =~ /2\.2/) || ($kernel =~ /2\.4/)) {
158                 $has_epoll = 0;
159         }
160 }
161 print "yes\n" if $has_epoll == 1;
162 print "no\n" if $has_epoll == 0;
163
164 if ($config{OSNAME} =~ /CYGWIN/) {
165         $config{HAS_STRLCPY} = "true";
166 }
167
168 $config{HAS_EPOLL} = $has_epoll;
169 $config{HAS_KQUEUE} = $has_kqueue; 
170
171 ################################################################################
172 #                          BEGIN INTERACTIVE PART                              #
173 ################################################################################
174
175 # Clear the Screen..
176 system("clear");
177 # Display Splash Logo..
178 show_splash();
179 chomp($wholeos = `uname -mnr`);
180
181 # Display Introduction Message..
182 print "
183 Welcome to the InspIRCd Configuration program!
184
185 *** If you are unsure of any of these values, leave it blank for    ***
186 *** standard settings that will work, and your server will run      ***
187 *** using them. If you are running this server as part of a         ***
188 *** larger network, you must consult with your network admins       ***
189 *** for the proper values to use, or server links will be unstable! ***
190
191 Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter
192 a new value. Please note: You will \033[1mHAVE\033[0m to read the docs
193 dir, otherwise you won't have a config file!
194
195 Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos), fdmax: $config{MAX_CLIENT_T}\n\n";
196
197 $config{CHANGE_COMPILER} = "n";
198 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";
199
200 if ($config{GCCVER} < 3)
201 {
202         print "\033[1;32mIMPORTANT!\033[0m A GCC 2.x compiler has been detected, and
203 should NOT be used. You should probably specify a newer compiler.\n";
204 }
205 yesno(CHANGE_COMPILER,"Do you want to change the compiler?");
206 if ($config{CHANGE_COMPILER} =~ /y/i)
207 {
208     print "What command do you want to use to invoke your compiler?\n";
209     print "[\033[1;32m$config{CC}\033[0m] -> ";
210     chomp($config{CC} = <STDIN>);
211     if ($config{CC} eq "") { $config{CC} = "g++"; }
212     chomp($foo = `$config{CC} -dumpversion | cut -c 1`);
213     if ($foo ne "") {
214             chomp($config{GCCVER}       = `$config{CC} -dumpversion | cut -c 1`); # we must redo these if we change
215             chomp($config{GCC34}        = `$config{CC} -dumpversion | cut -c 3`); # the compiler path
216             print "Queried compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.$config{GCC34}\033[0m)\n";
217     }
218     else
219     {
220             print "\033[1;32mWARNING!\033[0m Could not execute the compiler you specified. You may want to try again.\n";
221     }
222 }
223
224 print "\n";
225
226 # Directory Settings..
227 dir_check("do you wish to install the InspIRCd base", "BASE_DIR");
228 $config{CONFIG_DIR}         = resolve_directory($config{BASE_DIR}."/conf");           # Configuration Directory
229 $config{MODULE_DIR}         = resolve_directory($config{BASE_DIR}."/modules");        # Modules Directory
230 $config{BINARY_DIR}         = resolve_directory($config{BASE_DIR}."/bin");            # Binary Directory
231 $config{LIBRARY_DIR}        = resolve_directory($config{BASE_DIR}."/lib");            # Library Directory
232
233 dir_check("are the configuration files", "CONFIG_DIR");
234 dir_check("are the modules to be compiled to", "MODULE_DIR");
235 dir_check("is the IRCd binary to be placed", "BINARY_DIR");
236 dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
237
238 if ($has_kqueue) {
239         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?");
240         print "\n";
241 }
242 if ($has_epoll) {
243         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?");
244         print "\n";
245 }
246 $chose_hiperf = (($config{USE_EPOLL} eq "y") || ($config{USE_KQUEUE} eq "y"));
247 if (!$chose_hiperf)
248 {
249         print "No high-performance socket engines are available, or you chose\n";
250         print "not to enable one. Defaulting to select() engine.\n\n";
251 }
252
253 print "\nThe following questions will ask you for various figures relating\n";
254 print "To your IRCd install. Please note that these should usually be left\n";
255 print "as defaults unless you have a real reason to change them. If they\n";
256 print "changed, then the values must be identical on all servers on your\n";
257 print "network, or malfunctions and/or crashes may occur, with the exception\n";
258 print "of the 'maximum number of clients' setting which may be different on\n";
259 print "different servers on the network.\n\n";
260
261 # File Descriptor Settings..
262 my $continue = 0;
263 while (!$continue) {
264   print "Maximum number of clients at any one time ($config{MAX_CLIENT_T})\n";
265   print "[\033[1;32m$config{MAX_CLIENT}\033[0m] -> ";
266   chomp($var = <STDIN>);
267   if ($var eq "") { $var = $config{MAX_CLIENT}; }
268   if ($var =~ /^\d+$/) {
269     if (($var > $config{MAX_CLIENT_T}) && ($fd_scan_failed ne true)) {
270       # Client has entered a larger number than the 'discovered' value
271       # Confirm.
272       print "WARNING: Our scans have indicated that you are attempting
273 to use more sockets than there are avaliable. Are you sure
274 you wish to do this? It may cause the IRCd to malfunction [y/n]
275 [\033[1;32mn\033[0m] -> $c";
276       chomp($tmp = <STDIN>);
277       if ($tmp ne "y") {
278         print "Please enter the correct value.\n\n";
279         next;
280       }
281     }
282   } else {
283     print "You must enter a number in this field. Please try again.\n\n";
284     next;
285   }
286   # If we get here, we should be good to go.
287   $config{MAX_CLIENT} = $var;
288   $continue = 1;
289   print "\n";
290 }
291
292 my $continue = 0;
293 while (!$continue) {
294   print "What is the maximum length of nicknames?\n";
295   print "[\033[1;32m$config{NICK_LENGT}\033[0m] -> ";
296   chomp($var = <STDIN>);
297   if ($var eq "") { $var = $config{NICK_LENGT}; }
298   if ($var =~ /^\d+$/) {
299     # We don't care what the number is, set it and be on our way.
300     $config{NICK_LENGT} = $var;
301     $continue = 1;
302     print "\n";
303   } else {
304     print "You must enter a number in this field. Please try again.\n\n";
305   }
306 }
307
308 $continue = 0;
309 while (!$continue) {
310   print "What is the maximum length of channel names?\n";
311   print "[\033[1;32m$config{CHAN_LENGT}\033[0m] -> ";
312   chomp($var = <STDIN>);
313   if ($var eq "") { $var = $config{CHAN_LENGT}; }
314   if ($var =~ /^\d+$/) {
315     # We don't care what the number is, set it and be on our way.
316     $config{CHAN_LENGT} = $var;
317     $continue = 1;
318     print "\n";
319   } else {
320     print "You must enter a number in this field. Please try again.\n\n";
321   }
322 }
323
324 $continue = 0;
325 while (!$continue) {
326   print "What is the maximum number of channels a user may join at any one time?\n";
327   print "[\033[1;32m$config{MAX_CHANNE}\033[0m] -> ";
328   chomp($var = <STDIN>);
329   if ($var eq "") { $var = $config{MAX_CHANNE}; }
330   if ($var =~ /^\d+$/) {
331     # We don't care what the number is, set it and be on our way.
332     $config{MAX_CHANNE} = $var;
333     $continue = 1;
334     print "\n";
335   } else {
336     print "You must enter a number in this field. Please try again.\n\n";
337   }
338 }
339
340 $continue = 0;
341 while (!$continue) {
342   print "What is the maximum number of mode changes in one line?\n";
343   print "[\033[1;32m$config{MAXI_MODES}\033[0m] -> ";
344   chomp($var = <STDIN>);
345   if ($var eq "") { $var = $config{MAXI_MODES}; }
346   if ($var =~ /^\d+$/) {
347     # We don't care what the number is, set it and be on our way.
348     $config{MAXI_MODES} = $var;
349     $continue = 1;
350     print "\n";
351   } else {
352     print "You must enter a number in this field. Please try again.\n\n";
353   }
354 }
355
356 $continue = 0;
357 while (!$continue) {
358   print "What is the maximum length of an ident (username)?\n";
359   print "[\033[1;32m$config{MAX_IDENT}\033[0m] -> ";
360   chomp($var = <STDIN>);
361   if ($var eq "") { $var = $config{MAX_IDENT}; }
362   if ($var =~ /^\d+$/) {
363     # We don't care what the number is, set it and be on our way.
364     $config{MAX_IDENT} = $var;
365     $continue = 1;
366     print "\n";
367   } else {
368     print "You must enter a number in this field. Please try again.\n\n";
369   }
370 }
371
372 $continue = 0;
373 while (!$continue) {
374   print "What is the maximum length of a quit message?\n";
375   print "[\033[1;32m$config{MAX_QUIT}\033[0m] -> ";
376   chomp($var = <STDIN>);
377   if ($var eq "") { $var = $config{MAX_QUIT}; }
378   if ($var =~ /^\d+$/) {
379     # We don't care what the number is, set it and be on our way.
380     $config{MAX_QUIT} = $var;
381     $continue = 1;
382     print "\n";
383   } else {
384     print "You must enter a number in this field. Please try again.\n\n";
385   }
386 }
387
388 $continue = 0;
389 while (!$continue) {
390   print "What is the maximum length of a channel topic?\n";
391   print "[\033[1;32m$config{MAX_TOPIC}\033[0m] -> ";
392   chomp($var = <STDIN>);
393   if ($var eq "") { $var = $config{MAX_TOPIC}; }
394   if ($var =~ /^\d+$/) {
395     # We don't care what the number is, set it and be on our way.
396     $config{MAX_TOPIC} = $var;
397     $continue = 1;
398     print "\n";
399   } else {
400     print "You must enter a number in this field. Please try again.\n\n";
401   }
402 }
403
404 $continue = 0;
405 while (!$continue) {
406   print "What is the maximum length of a kick message?\n";
407   print "[\033[1;32m$config{MAX_KICK}\033[0m] -> ";
408   chomp($var = <STDIN>);
409   if ($var eq "") { $var = $config{MAX_KICK}; }
410   if ($var =~ /^\d+$/) {
411     # We don't care what the number is, set it and be on our way.
412     $config{MAX_KICK} = $var;
413     $continue = 1;
414     print "\n";
415   } else {
416     print "You must enter a number in this field. Please try again.\n\n";
417   }
418 }
419
420 $continue = 0;
421 while (!$continue) {
422   print "What is the maximum length of a GECOS (real name) field?\n";
423   print "[\033[1;32m$config{MAX_GECOS}\033[0m] -> ";
424   chomp($var = <STDIN>);
425   if ($var eq "") { $var = $config{MAX_GECOS}; }
426   if ($var =~ /^\d+$/) {
427     # We don't care what the number is, set it and be on our way.
428     $config{MAX_GECOS} = $var;
429     $continue = 1;
430     print "\n";
431   } else {
432     print "You must enter a number in this field. Please try again.\n\n";
433   }
434 }
435
436 $continue = 0;
437 while (!$continue) {
438   print "What is the maximum length of an away message?\n";
439   print "[\033[1;32m$config{MAX_AWAY}\033[0m] -> ";
440   chomp($var = <STDIN>);
441   if ($var eq "") { $var = $config{MAX_AWAY}; }
442   if ($var =~ /^\d+$/) {
443     # We don't care what the number is, set it and be on our way.
444     $config{MAX_AWAY} = $var;
445     $continue = 1;
446     print "\n";
447   } else {
448     print "You must enter a number in this field. Please try again.\n\n";
449   }
450 }
451
452 # Code Optimisation
453 print "Enter the Level Of Binary optimisation. This is a number between 0 and 3.
454 The InspIRCd Team will NOT support any bug reports above 0. Also note,
455 the IRCd behaviour will be different depending on this value. Please
456 read the documentation for more information.
457
458 The higher the number, the more optimised your binary will be. This
459 value will default to 0 if you either don't enter a number, or enter
460 a value outside the range.
461
462 As always, if you are unsure, just press enter and accept the default.\n\n";
463 print "[\033[1;32m$config{OPTIMITEMP}\033[0m] -> ";
464 chomp($var = <STDIN>);
465 if ($var eq "") {
466   $var = $config{OPTIMITEMP};
467 }
468
469 if ($var eq "1") {
470   $config{OPTIMITEMP} = 1;
471   $config{OPTIMISATI} = "-O";
472 } elsif ($var eq "2") {
473   $config{OPTIMITEMP} = 2;
474   $config{OPTIMISATI} = "-O2";
475 } elsif ($var eq "3") {
476   $config{OPTIMITEMP} = 3;
477   $config{OPTIMISATI} = "-O3";
478 } else {
479   $config{OPTIMITEMP} = 0;
480   $config{OPTIMISATI} = "-g";
481 }
482
483 print "\n\033[1;32mPre-build configuration is complete!\033[0m\n\n";
484 print "\033[0mConfig path:\033[1;32m\t\t\t$config{CONFIG_DIR}\n";
485 print "\033[0mModule path:\033[1;32m\t\t\t$config{MODULE_DIR}\n";
486 print "\033[0mMax connections:\033[1;32m\t\t$config{MAX_CLIENT}\n";
487 print "\033[0mMax User Channels:\033[1;32m\t\t$config{MAX_CHANNE}\n";
488 print "\033[0mMax nickname length:\033[1;32m\t\t$config{NICK_LENGT}\n";
489 print "\033[0mMax channel length:\033[1;32m\t\t$config{CHAN_LENGT}\n";
490 print "\033[0mMax mode length:\033[1;32m\t\t$config{MAXI_MODES}\n";
491 print "\033[0mMax ident length:\033[1;32m\t\t$config{MAX_IDENT}\n";
492 print "\033[0mMax quit length:\033[1;32m\t\t$config{MAX_QUIT}\n";
493 print "\033[0mMax topic length:\033[1;32m\t\t$config{MAX_TOPIC}\n";
494 print "\033[0mMax kick length:\033[1;32m\t\t$config{MAX_KICK}\n";
495 print "\033[0mMax name length:\033[1;32m\t\t$config{MAX_GECOS}\n";
496 print "\033[0mMax away length:\033[1;32m\t\t$config{MAX_AWAY}\n";
497 print "\033[0mGCC Version Found:\033[1;32m\t\t$config{GCCVER}.$config{GCC34}\n";
498 print "\033[0mOptimatizaton Flag:\033[1;32m\t\t$config{OPTIMISATI}\033[0m\n";
499 print "\033[0mCompiler program:\033[1;32m\t\t$config{CC}\033[0m\n";
500 print "\033[0mStatic modules:\033[1;32m\t\t\t$config{STATIC_LINK}\033[0m\n\n";
501
502 makecache();
503 writefiles();
504
505 print "\n\n";
506 print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
507 print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
508 if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
509         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";
510 }
511 if ($config{OSNAME} =~ /CYGWIN/) {
512         print <<FOO;
513 \033[1;32mWARNING!\033[0m CYGWIN does not properly support shared modules,
514 so modules will be compiled statically into the core of the ircd. The modules
515 will act like they are being loaded from disk and being unloaded from RAM,
516 however they are in fact being enabled and disabled similar to features in
517 other ircds.
518 FOO
519 }
520
521 if ($config{GCCVER} < "3") {
522         print <<FOO2;
523 \033[1;32mWARNING!\033[0m You are attempting to compile InspIRCd on GCC 2.x!
524 GCC 2.x series compilers only had partial (read as broken) C++ support, and
525 your compile will most likely fail horribly! If you have any problems, do NOT
526 report them to the bugtracker or forums without first upgrading your compiler
527 to a newer 3.x or 4.x (or whatever is available currently) version.
528 FOO2
529 }
530
531 ################################################################################
532 #                              HELPER FUNCTIONS                                #
533 ################################################################################
534 sub getcache {
535   # Retrieves the .config.cache file, and loads values into the main config hash.
536   open(CACHE, ".config.cache") or return undef;
537   while (<CACHE>) {
538     chomp;
539
540     # Ignore Blank lines, and comments..
541     next if /^\s*$/;
542     next if /^\s*#/;
543
544     my ($key, $value) = split("=", $_);
545     $value =~ /^\"(.*)\"$/;
546     # Do something with data here!
547     $config{$key} = $1;
548   }
549   close(CONFIG);
550   return "true";
551 }
552
553 sub makecache {
554   # Dump the contents of %config
555   print "Writing \033[1;32mcache file\033[0m for future ./configures ...\n";
556   open(FILEHANDLE, ">.config.cache");
557   foreach $key (keys %config)
558   {
559     print FILEHANDLE "$key=\"$config{$key}\"\n";
560   }
561   close(FILEHANDLE);
562 }
563
564 sub dir_check {
565   my ($desc, $hash_key) = @_;
566   my $complete = 0;
567   while (!$complete) {
568     print "In what directory $desc?\n";
569     print "[\033[1;32m$config{$hash_key}\033[0m] -> ";
570     chomp($var = <STDIN>);
571     if ($var eq "") { $var = $config{$hash_key}; }
572     if ($var =~ /^\~\/(.+)$/) {
573         # Convert it to a full path..
574         $var = resolve_directory($ENV{HOME} . "/" . $1);
575     }
576     if (substr($var,0,1) ne "/")
577     {
578         # Assume relative Path was given.. fill in the rest.
579         $var = $this . "/$var";
580     }
581     $var = resolve_directory($var); 
582     if (! -e $var) {
583       print "$var does not exist. Create it?\n[\033[1;32my\033[0m] ";
584       chomp($tmp = <STDIN>);
585       if (($tmp eq "") || ($tmp =~ /^y/i)) {
586         # Attempt to Create the Dir..
587         $chk = system("mkdir -p \"$var\" >> /dev/null 2>&1") / 256;
588         if ($chk != 0) {
589           print "Unable to create directory. ($var)\n\n";
590           # Restart Loop..
591           next;
592         }
593       } else {
594         # They said they don't want to create, and we can't install there.
595         print "\n\n";
596         next;
597       }
598     } else {
599       if (!is_dir($var)) {
600         # Target exists, but is not a directory.
601         print "File $var exists, but is not a directory.\n\n";
602         next;
603       }
604     }
605     # Either Dir Exists, or was created fine.
606     $config{$hash_key} = $var;
607     $complete = 1;
608     print "\n";
609   }
610 }
611
612 sub getosflags {
613   if ($config{OSNAME} =~ /BSD$/) {
614     $config{LDLIBS} = "-Ldl";
615     $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Wall -Woverloaded-virtual $config{OPTIMISATI}";
616     $config{MAKEPROG} = "gmake";
617     if ($config{OSNAME} eq "OpenBSD") {
618         chomp($foo = `eg++ -dumpversion | cut -c 1`);
619         # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
620         # if theyre not running this, configure lets the build continue but they probably wont manage to
621         # compile as this standard version is 2.95.3!
622         if ($foo ne "") {
623                 $config{CC} = "eg++";
624                 chomp($config{GCCVER}       = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change
625                 chomp($config{GCC34}        = `eg++ -dumpversion | cut -c 3`); # the compiler path
626         }
627     }
628   } else {
629     $config{LDLIBS} = "-ldl";
630     $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Wall -Woverloaded-virtual $config{OPTIMISATI}";
631     $config{MAKEPROG} = "make";
632     if ($config{OSNAME} =~ /CYGWIN/) {
633        $config{FLAGS}  = "-frtti $OPTIMISATI -Wall -Woverloaded-virtual $config{OPTIMISATI}";
634        $config{LDLIBS} = "";
635        $config{MAKEPROG} = "/usr/bin/make";
636        $config{MAKEORDER} = "mods ircd config bininst";
637        $config{STATICLIBS} = "modules/mods.a";
638        $config{STATIC_LINK} = "yes";
639     }
640   }
641   if ($config{OSNAME} =~ /SunOS/) {
642     # solaris/sunos needs these
643     # socket = bsd sockets api
644     # nsl = dns stuff
645     # rt = POSIX realtime extensions
646     # resolv = inet_aton only (why isnt this in nsl?!)
647     $config{LDLIBS} = $config{LDLIBS} . " -lsocket -lnsl -lrt -lresolv";
648   }
649 }
650
651 sub is_dir {
652   my ($path) = @_;
653   if (chdir($path)) {
654     chdir($this);
655     return 1;
656   } else {
657     # Just in case..
658     chdir($this);
659     return 0;
660   }
661 }
662
663 sub getmodules {
664   my $i = 0;
665   opendir(DIRHANDLE, "src/modules");
666   foreach $name (sort readdir(DIRHANDLE)) {
667     if ($name =~ /^m_(.+)\.cpp$/)
668     {
669       $mod = $1;
670       if ($mod !~ /_static$/) {
671               $modlist[$i++] = $mod;
672       }
673     }
674   }
675   closedir(DIRHANDLE);
676 }
677
678 sub writefiles {
679
680   print "Writing \033[1;32minspircd_config.h\033[0m\n";
681   # First File.. inspircd_config.h
682   chomp(my $incos = `uname -n -s -r`);
683   chomp(my $version = `sh ./src/version.sh`);
684   open(FILEHANDLE, ">include/inspircd_config.h");
685   my $NL = $config{NICK_LENGT}+1;
686   my $CL = $config{CHAN_LENGT}+1;
687   print FILEHANDLE <<EOF;
688 /* Auto generated by configure, do not modify! */
689 #ifndef __CONFIGURATION_AUTO__
690 #define __CONFIGURATION_AUTO__
691
692 #define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
693 #define MOD_PATH "$config{MODULE_DIR}"
694 #define VERSION "$version"
695 #define MAXCLIENTS $config{MAX_CLIENT}
696 #define NICKMAX $NL
697 #define CHANMAX $CL
698 #define MAXCHANS $config{MAX_CHANNE}
699 #define MAXMODES $config{MAXI_MODES}
700 #define IDENTMAX $config{MAX_IDENT}
701 #define MAXQUIT $config{MAX_QUIT}
702 #define MAXTOPIC $config{MAX_TOPIC}
703 #define MAXKICK $config{MAX_KICK}
704 #define MAXGECOS $config{MAX_GECOS}
705 #define MAXAWAY $config{MAX_AWAY}
706 #define OPTIMISATION $config{OPTIMITEMP}
707 #define SYSTEM "$incos"
708 #define MAXBUF 514
709 EOF
710
711   if ($config{OSNAME} =~ /SunOS/) {
712     print FILEHANDLE "#define IS_SOLARIS\n";
713   }
714   if ($config{OSNAME} =~ /CYGWIN/) {
715     print FILEHANDLE "#define IS_CYGWIN\n";
716     print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE    1024\n#endif\n";
717   }
718   if ($config{STATIC_LINK} eq "yes") {
719     print FILEHANDLE "#define STATIC_LINK\n";
720   }
721   if ($config{GCCVER} > 3) {
722     print FILEHANDLE "#define GCC3\n";
723     print FILEHANDLE "#define GCC34\n";
724   }
725   else
726   {
727     if ($config{GCCVER} == 3) {
728       print FILEHANDLE "#define GCC3\n";
729       if ($config{GCC34} > 3) {
730         print FILEHANDLE "#define GCC34\n";
731       }
732     }
733   }
734   if ($config{HAS_STRLCPY} eq "true") {
735     print FILEHANDLE "#define HAS_STRLCPY\n";
736   }
737   my $use_hiperf = 0;
738   if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
739     print FILEHANDLE "#define USE_KQUEUE\n";
740     $use_hiperf = 1;
741   }
742   if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
743     print FILEHANDLE "#define USE_EPOLL\n";
744     $use_hiperf = 1;
745   }
746   # user didn't choose either epoll or select for their OS.
747   # default them to USE_SELECT (ewwy puke puke)
748   if (!$use_hiperf) {
749     print FILEHANDLE "#define USE_SELECT\n";
750   }
751   print FILEHANDLE "\n#endif\n";
752   close(FILEHANDLE);
753
754   # Create a Modules List..
755   my $modules = "";
756   foreach $i (@modlist)
757   {
758     if ($config{OSNAME} =~ /CYGWIN/) {
759         $modules .= "m_".$i.".o ";
760     }
761     else {
762         $modules .= "m_".$i.".so ";
763     }
764   }
765   chomp($modules);   # Remove Redundant whitespace..
766
767
768   # Write all .in files.
769   my $tmp = "";
770   my $file = "";
771   my $exe = "inspircd";
772
773   if ($config{OSNAME} =~ /CYGWIN/) {
774     $exe = "inspircd.exe";
775   }
776
777   opendir(DIRHANDLE, $this);
778   foreach $name (sort readdir(DIRHANDLE)) {
779     if ($name =~ /^\.(.+)\.inc$/)
780     {
781       $file = $1;
782       # All .name.inc files need parsing!
783       $tmp = "";
784       open(FILEHANDLE, ".$file.inc");
785       while (<FILEHANDLE>) {
786         $tmp .= $_;
787       }
788       close(FILEHANDLE);
789
790       $tmp =~ s/\@CC\@/$config{CC}/;
791       $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
792       $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
793       $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
794       $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/;
795       $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
796       $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
797       $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
798       $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
799       $tmp =~ s/\@MODULES\@/$modules/;
800       $tmp =~ s/\@EXECUTABLE\@/$exe/;
801       $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
802       $tmp =~ s/\@STATICLIBS\@/$config{STATICLIBS}/;
803
804       print "Writing \033[1;32m$file\033[0m\n";
805       open(FILEHANDLE, ">$file");
806       print FILEHANDLE $tmp;
807     }
808   }
809   closedir(DIRHANDLE);
810
811   # Make inspircd executable!
812   chmod 0744, 'inspircd';
813
814   if ($config{OSNAME} =~ /CYGWIN/) {
815         print "Writing static-build \033[1;32msrc/Makefile\033[0m\n";
816         write_static_makefile();
817   }
818   else {
819         print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
820         write_dynamic_makefile();
821   }
822
823
824   # Modules Makefile..
825   print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
826   open(FILEHANDLE, ">src/modules/Makefile");
827   print FILEHANDLE <<EOF;
828 # (C) ChatSpike development team
829 # Makefile by <Craig\@ChatSpike.net>
830 # Many Thanks to Andrew Church <achurch\@achurch.org>
831 #    for assisting with making this work right.
832 #
833 # Automatically Generated by ./configure to add a modules
834 # please run ./configure --update
835
836 all: \$(MODULES)
837
838 EOF
839
840   # Create a Modules List..
841   my $modules = "";
842   my $flags = "";
843   if ($config{OSNAME} =~ /CYGWIN/) {
844      open(MODLIST,">include/modlist.h");
845      print MODLIST <<HEADER;
846 // Generated automatically by configure. DO NOT EDIT!
847
848 #ifndef __SYMBOLS__H_CONFIGURED__
849 #define __SYMBOLS__H_CONFIGURED__
850
851 HEADER
852      foreach $i (@modlist) {
853         if ($i !~ /_static$/) {
854                 print MODLIST "extern \"C\" void * $i\_init (void);\n";
855         }
856      }
857      print MODLIST "\nstruct {const char *name; initfunc *value; } modsyms[] = {\n";
858   }
859   foreach $i (@modlist)
860   {
861     if ($i !~ /_static$/) {
862      $flags = getcompilerflags("src/modules/m_".$i.".cpp");
863      if ($config{OSNAME} =~ /CYGWIN/) {
864         print FILEHANDLE <<EOCHEESE;
865 m_$i.o: m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h
866         \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i\_static.cpp
867         mv m_$i\_static.o ../m_$i.o
868
869 EOCHEESE
870         print "Configuring module [\033[1;32mm_$i.so\033[0m] for static linking... ";
871         open(MODULE,"<src/modules/m_".$i.".cpp") or die("Could not open m_".$i.".cpp");
872         open(MUNGED,">src/modules/m_".$i."_static.cpp") or die("Could not create m_".$i."_static.cpp");
873         while (chomp($a = <MODULE>)) { 
874                 $a =~ s/init_module/$i\_init/g;
875                 $a =~ s/Srv/$i\Srv/g;
876                 print MUNGED "$a\n";
877         }
878         close(MODULE);
879         close(MUNGED);
880         print MODLIST <<EOENT;
881 {"m_$i.so",\&$i\_init},
882 EOENT
883         print "done\n";
884      }
885      else {
886          print FILEHANDLE <<EOCHEESE;
887 m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h
888         \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i.cpp
889         \$(CC) \$(FLAGS) -shared $flags -o m_$i.so m_$i.o
890         @-rm -f \$(MODPATH)/m_$i.so
891         cp m_$i.so \$(MODPATH)/
892         chmod 0700 \$(MODPATH)/m_$i.so
893
894 EOCHEESE
895       }
896    }
897   }
898   if ($config{OSNAME} =~ /CYGWIN/) {
899      print MODLIST "{0}};\n\n#endif\n";
900      close(MODLIST);
901   }
902 }
903
904 sub getcompilerflags {
905   my ($file) = @_;
906   open(FLAGS, $file);
907   while (<FLAGS>) {
908     if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
909       close(FLAGS);
910       return $1;
911     }
912   }
913   close(FLAGS);
914   return undef;
915 }
916
917 sub show_splash {
918   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";
919   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";
920   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";
921   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";
922   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";
923   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";
924   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";
925   print "\033[0m\033[0m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::\n\n";
926 }
927
928 sub resolve_directory {
929         use File::Spec;
930         return File::Spec->rel2abs($_[0]);
931 }
932
933 sub yesno {
934         my ($flag,$prompt) = @_;
935         print "$prompt [\033[1;32m$config{$flag}\033[0m] -> ";
936         chomp($tmp = <STDIN>);
937         if ($tmp eq "") { $tmp = $config{$flag} }
938
939         if (($tmp eq "") || ($tmp =~ /^y/i)) {
940                 $config{$flag} = "y";
941         } else {
942                 $config{$flag} = "n";
943         }
944         return;
945 }
946
947
948 sub write_static_makefile {
949         open(FH,">src/Makefile") or die("Could not write src/Makefile!");
950         print FH <<EOM;
951 # Insp Makefile :p
952 #
953 # (C) ChatSpike development team
954 # Makefile by <Craig\@ChatSpike.net>
955 # Makefile version 2 (dynamically linked core) by <brain\@inspircd.org>
956 #
957
958 CC = im a cheezeball
959
960 CXXFLAGS = -I../include \${FLAGS}
961
962 all: socket.o hashcomp.o channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o helperfuncs.o \$(MODULES) inspircd.exe
963
964 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
965         \$(CC) -I../include \$(FLAGS) inspircd.cpp -o inspircd.exe \$(LDLIBS) channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o hashcomp.o socket.o \$(MODULES)
966
967 hashcomp.o: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
968         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
969
970 helperfuncs.o: helperfuncs.cpp ../include/base.h ../include/helperfuncs.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
971         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
972
973 channels.o: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
974         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
975
976 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
977         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
978
979 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
980         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
981
982 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
983         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
984
985 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
986         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
987
988 base.o: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
989         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
990
991 inspircd_util.o: inspircd_util.cpp ../include/base.h ../include/inspircd_util.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
992         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_util.cpp
993
994 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
995         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_io.cpp
996
997 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
998         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c message.cpp
999
1000 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
1001         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
1002
1003 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
1004         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dnsqueue.cpp
1005
1006 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
1007         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1008
1009 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
1010         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1011
1012 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
1013         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1014
1015 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
1016         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1017
1018 socket.o: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1019         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1020
1021
1022 EOM
1023 close(FH);
1024 }
1025
1026 sub write_dynamic_makefile {
1027         open(FH,">src/Makefile") or die("Could not write src/Makefile");
1028         print FH <<EOM;
1029 # Insp Makefile :p
1030 #
1031 # (C) ChatSpike development team
1032 # Makefile by <Craig\@ChatSpike.net>
1033 # Makefile version 2 (dynamically linked core) by <brain\@inspircd.org>
1034 #
1035
1036 CC = im a cheezeball
1037
1038 CXXFLAGS = -I../include \${FLAGS}
1039
1040 all: libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDutil.so libIRCDio.so libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so inspircd
1041
1042 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
1043         \$(CC) -I../include \$(FLAGS) -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDutil.so libIRCDio.so libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDhash.so libIRCDsocket.so
1044
1045 libIRCDhash.so: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1046         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1047         \$(CC) -shared -o libIRCDhash.so hashcomp.o
1048
1049 libIRCDhelper.so: helperfuncs.cpp ../include/base.h ../include/helperfuncs.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1050         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1051         \$(CC) -shared -o libIRCDhelper.so helperfuncs.o
1052
1053 libIRCDchannels.so: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1054         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1055         \$(CC) -shared -o libIRCDchannels.so channels.o
1056
1057 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
1058         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1059         \$(CC) -shared -o libIRCDmode.so mode.o
1060
1061 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
1062         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1063         \$(CC) -shared -o libIRCDxline.so xline.o
1064
1065 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
1066         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1067         \$(CC) -shared -o libIRCDstring.so inspstring.o
1068
1069 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
1070         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1071         \$(CC) -shared -o libIRCDasyncdns.so dns.o
1072
1073 libIRCDbase.so: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1074         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1075         \$(CC) -shared -o libIRCDbase.so base.o
1076
1077 libIRCDutil.so: inspircd_util.cpp ../include/base.h ../include/inspircd_util.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1078         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_util.cpp
1079         \$(CC) -shared -o libIRCDutil.so inspircd_util.o
1080
1081 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
1082         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_io.cpp
1083         \$(CC) -shared -o libIRCDio.so inspircd_io.o
1084
1085 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
1086         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c message.cpp
1087         \$(CC) -shared -o libIRCDmessage.so message.o
1088
1089 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
1090         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
1091         \$(CC) -shared -o libIRCDcommands.so commands.o
1092
1093 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
1094         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dnsqueue.cpp
1095         \$(CC) -shared -o libIRCDdnsqueue.so dnsqueue.o
1096
1097 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
1098         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1099         \$(CC) -shared -o libIRCDdynamic.so dynamic.o
1100
1101 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
1102         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1103         \$(CC) -shared -o libIRCDusers.so users.o
1104
1105 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
1106         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1107         \$(CC) -shared -o libIRCDmodules.so modules.o
1108
1109 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
1110         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1111         \$(CC) -shared -o libIRCDwildcard.so wildcard.o
1112
1113 libIRCDsocket.so: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
1114         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
1115         \$(CC) -shared -o libIRCDsocket.so socket.o
1116
1117 EOM
1118 close(FH);
1119 }