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