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