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