]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - configure
*** empty log message ***
[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{CONFIG_DIR}         = resolve_directory($config{ME}."/conf");           # Configuration Directory
20 $config{MODULE_DIR}         = resolve_directory($config{ME}."/modules");        # Modules Directory
21 $config{BINARY_DIR}         = resolve_directory($config{ME}."/bin");            # Binary Directory
22 $config{LIBRARY_DIR}        = resolve_directory($config{ME}."/lib");            # Library Directory
23 $config{OPTIMITEMP}         = "0";                                              # Default Optimisation Value
24 $config{OPTIMISATI}         = "-g";                                             # Optimisation Flag
25 $config{NICK_LENGT}         = "32";                                             # Default Nick Length
26 $config{CHAN_LENGT}         = "64";                                             # Default Channel Name Length
27 $config{MAX_CHANNE}         = "20";                                             # Default Max. Channels per user..
28 $config{MAXI_MODES}         = "20";                                             # Default Max. Number of Modes set at once.
29 $config{HAS_STRLCPY}        = "false";                                          # strlcpy Check.
30 $config{USE_KQUEUE}         = "y";                                              # kqueue enabled
31 $config{USE_EPOLL}          = "y";                                              # epoll enabled
32 chomp($config{MAX_CLIENT_T} = `sh -c \"ulimit -n\"`);                           # FD Limit
33 chomp($config{GCCVER}       = `gcc -dumpversion | cut -c 1`);                   # Major GCC Version
34 chomp($config{GCC34}        = `gcc -dumpversion | cut -c 3`);                   # Minor GCC Version
35 chomp($config{OSNAME}       = `/bin/uname`);                                    # Operating System Name
36 $config{CC}                 = "g++";                                            # C++ compiler
37
38 if ((!$config{OSNAME}) || ($config{OSNAME} eq "")) {
39   chomp($config{OSNAME} = `/usr/bin/uname`);
40   if ((!$config{OSNAME}) || ($config{OSNAME} eq "")){
41         $config{OSNAME} = "Unknown";
42   }
43 }
44
45 if (!$config{MAX_CLIENT_T}) { 
46   $config{MAX_CLIENT_T} = 1024;                                 # Set a reasonable 'Default'
47   $fd_scan_fail = "true";                                       # Used Later
48 }
49
50 # Get and Set some important vars..
51 getmodules();
52
53 my $arg = $ARGV[0];                                             # Do Some Argument Checks..
54 if ($arg eq "-clean") { `rm -rf .config.cache`; }               # Remove the config.cache file.
55
56 if ($arg eq "-update") {
57   # Does the cache file exist?
58   if (!getcache()) {
59     # No, No it doesn't.. *BASH*
60     print "You have not run ./configure before. Please do this before trying to run the update script.\n";
61     exit 0;
62   } else {
63     # We've Loaded the cache file and all our variables..
64     print "Updating Files..\n";
65     getosflags();
66     writefiles();
67     print "Complete.\n";
68     exit;
69   }
70 }
71
72 print "Checking for cache from previous configure...\n";
73 getcache();
74 print "Checking operating system version...\n";
75 getosflags();
76
77 if (!$config{MAX_CLIENT}) { 
78   # If the cache hasn't set the max clients, copy the variable of MAX_CLIENT_T, this
79   # allows us to keep _T for testing purposes. (ie. "Are you sure you want to go
80   # higher than the found value" :))
81   $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
82 }
83
84 printf "Checking if strlcpy exists... ";
85 # Perform the strlcpy() test..
86 $config{HAS_STRLCPY} = "false";
87 my $fail = 0;
88 open(STRLCPY, "</usr/include/string.h") or $fail = 1;
89 if (!$fail)
90 {
91         while (chomp($line = <STRLCPY>))
92         {
93                 # try and find the delcaration of:
94                 # size_t strlcpy(...)
95                 if ($line =~ /size_t(\0x9|\s)+strlcpy/)
96                 {
97                         $config{HAS_STRLCPY} = "true";
98                 }
99         }
100         close(STRLCPY);
101 }
102 print "yes\n" if $config{HAS_STRLCPY} eq "true";
103 print "no\n" if $config{HAS_STRLCPY} eq "false";
104
105 printf "Checking if kqueue exists... ";
106 $has_kqueue = 0;
107 $fail = 0;
108 open(KQUEUE, "</usr/include/sys/event.h") or $fail = 1;
109 if (!$fail)
110 {
111         while (chomp($line = <KQUEUE>))
112         {
113                 # try and find the delcaration of:
114                 # int kqueue(void);
115                 if ($line =~ /int(\0x9|\s)+kqueue/)
116                 {
117                         $has_kqueue = 1;
118                 }
119         }
120         close(KQUEUE);
121 }
122 print "yes\n" if $has_kqueue == 1;
123 print "no\n" if $has_kqueue == 0;
124
125 printf "Checking if epoll exists... ";
126 $has_epoll = 0;
127 $fail = 0;
128 open(EPOLL, "</usr/include/sys/epoll.h") or $fail = 1;
129 if (!$fail)
130 {
131         while (chomp($line = <EPOLL>))
132         {
133                 # try and find the declaration of:
134                 # extern int epoll_create (int __size) __THROW;
135                 if (($line =~ /int(\0x9|\s)+epoll_create(\0x9|\s)+\(/) || ($line =~ /int(\0x9|\s)+epoll_create\(/))
136                 {
137                         $has_epoll = 1;
138                 }
139         }
140         close(EPOLL);
141 }
142 print "yes\n" if $has_epoll == 1;
143 print "no\n" if $has_epoll == 0;
144
145 if ($config{OSNAME} =~ /CYGWIN/) {
146         $config{HAS_STRLCPY} = "true";
147 }
148
149 ################################################################################
150 #                          BEGIN INTERACTIVE PART                              #
151 ################################################################################
152
153 # Clear the Screen..
154 system("clear");
155 # Display Splash Logo..
156 show_splash();
157 chomp($wholeos = `uname -mnr`);
158
159 # Display Introduction Message..
160 print "
161 Welcome to the InspIRCd Configuration program!
162
163 *** If you are unsure of any of these values, leave it blank for    ***
164 *** standard settings that will work, and your server will run      ***
165 *** using them. If you are running this server as part of a         ***
166 *** larger network, you must consult with your network admins       ***
167 *** for the proper values to use, or server links will be unstable! ***
168
169 Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter
170 a new value. Please note: You will \033[1mHAVE\033[0m to read the docs
171 dir, otherwise you won't have a config file!
172
173 Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos), fdmax: $config{MAX_CLIENT_T}\n\n";
174
175 # Directory Settings..
176 dir_check("are the configuration files", "CONFIG_DIR");
177 dir_check("are the modules to be compiled to", "MODULE_DIR");
178 dir_check("is the IRCd binary to be placed", "BINARY_DIR");
179 dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
180
181 if ($has_kqueue) {
182         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?");
183 }
184 if ($has_epoll) {
185         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?");
186 }
187 $chose_hiperf = (($config{USE_EPOLL} eq "y") || ($config{USE_KQUEUE} eq "y"));
188 if (!$chose_hiperf)
189 {
190         print "No high-performance socket engines are available, or you chose\n";
191         print "not to enable one. Defaulting to select() engine.\n\n";
192 }
193
194 # File Descriptor Settings..
195 my $continue = 0;
196 while (!$continue) {
197   print "Maximum number of clients at any one time ($config{MAX_CLIENT_T})\n";
198   print "[\033[1;32m$config{MAX_CLIENT}\033[0m] -> ";
199   chomp($var = <STDIN>);
200   if ($var eq "") { $var = $config{MAX_CLIENT}; }
201   if ($var =~ /^\d+$/) {
202     if (($var > $config{MAX_CLIENT_T}) && ($fd_scan_failed ne true)) {
203       # Client has entered a larger number than the 'discovered' value
204       # Confirm.
205       print "WARNING: Our scans have indicated that you are attempting
206 to use more sockets than there are avaliable. Are you sure
207 you wish to do this? It may cause the IRCd to malfunction [y/n]
208 [\033[1;32mn\033[0m] -> $c";
209       chomp($tmp = <STDIN>);
210       if ($tmp ne "y") {
211         print "Please enter the correct value.\n\n";
212         next;
213       }
214     }
215   } else {
216     print "You must enter a number in this field. Please try again.\n\n";
217     next;
218   }
219   # If we get here, we should be good to go.
220   $config{MAX_CLIENT} = $var;
221   $continue = 1;
222   print "\n";
223 }
224
225 my $continue = 0;
226 while (!$continue) {
227   print "What is the Maximum length of nicknames?\n";
228   print "[\033[1;32m$config{NICK_LENGT}\033[0m] -> ";
229   chomp($var = <STDIN>);
230   if ($var eq "") { $var = $config{NICK_LENGT}; }
231   if ($var =~ /^\d+$/) {
232     # We don't care what the number is, set it and be on our way.
233     $config{NICK_LENGT} = $var;
234     $continue = 1;
235     print "\n";
236   } else {
237     print "You must enter a number in this field. Please try again.\n\n";
238   }
239 }
240
241 my $continue = 0;
242 while (!$continue) {
243   print "What is the Maximum number of mode changes in one line?\n";
244   print "[\033[1;32m$config{MAXI_MODES}\033[0m] -> ";
245   chomp($var = <STDIN>);
246   if ($var eq "") { $var = $config{MAXI_MODES}; }
247   if ($var =~ /^\d+$/) {
248     # We don't care what the number is, set it and be on our way.
249     $config{MAXI_MODES} = $var;
250     $continue = 1;
251     print "\n";
252   } else {
253     print "You must enter a number in this field. Please try again.\n\n";
254   }
255 }
256
257 # Code Optimisation
258 print "Enter the Level Of Binary optimisation. This is a number between 0 and 3 (inclusive)
259 The InspIRCd Team will _NOT_ support any bug reports above 0.
260 Also note, the IRCd behaviour will be different depending on this value.
261 Please read the documentation for more information.
262
263 The Higher the number, the more optimised your binary will be. This value will default to 0
264 If you either a) Dont enter a number, or b) Enter a value outside the range.\n";
265 print "[\033[1;32m$config{OPTIMITEMP}\033[0m] -> ";
266 chomp($var = <STDIN>);
267 if ($var eq "") {
268   $var = $config{OPTIMITEMP};
269 }
270
271 if ($var eq "1") {
272   $config{OPTIMITEMP} = 1;
273   $config{OPTIMISATI} = "-O";
274 } elsif ($var eq "2") {
275   $config{OPTIMITEMP} = 2;
276   $config{OPTIMISATI} = "-O2";
277 } elsif ($var eq "3") {
278   $config{OPTIMITEMP} = 3;
279   $config{OPTIMISATI} = "-O3";
280 } else {
281   $config{OPTIMITEMP} = 0;
282   $config{OPTIMISATI} = "-g";
283 }
284
285 print "\n\033[1;32mPre-build configuration is complete!\033[0m\n\n";
286 print "\033[0mConfig path:\033[1;32m\t\t\t$config{CONFIG_DIR}\n";
287 print "\033[0mModule path:\033[1;32m\t\t\t$config{MODULE_DIR}\n";
288 print "\033[0mMax connections:\033[1;32m\t\t$config{MAX_CLIENT}\n";
289 print "\033[0mMax User Channels\033[1;32m\t\t$config{MAX_CHANNE}\n";
290 print "\033[0mMax nickname length:\033[1;32m\t\t$config{NICK_LENGT}\n";
291 print "\033[0mMax channel length:\033[1;32m\t\t$config{CHAN_LENGT}\n";
292 print "\033[0mMax mode length:\033[1;32m\t\t$config{MAXI_MODES}\n";
293 print "\033[0mGCC Version Found:\033[1;32m\t\t$config{GCCVER}.$config{GCC34}\n";
294 print "\033[0mOptimatizaton Flag:\033[1;32m\t\t$config{OPTIMISATI}\033[0m\n";
295 print "\033[0mCompiler program:\033[1;32m\t\t$config{CC}\033[0m\n\n";
296
297 makecache();
298 writefiles();
299
300 print "\n\n";
301 print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
302 print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
303 if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
304         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";
305 }
306 if ($config{OSNAME} =~ /CYGWIN/) {
307         print "\033[1;32mWARNING!\033[0m CYGWIN does not properly support shared modules,\nso modules are unavailable on this platform.\nThe modules will build as .o files but will not be available for use.\nYou will be able to run the core ircd file (inspircd.exe) as normal.\n";
308 }
309
310 ################################################################################
311 #                              HELPER FUNCTIONS                                #
312 ################################################################################
313 sub getcache {
314   # Retrieves the .config.cache file, and loads values into the main config hash.
315   open(CACHE, ".config.cache") or return undef;
316   while (<CACHE>) {
317     chomp;
318
319     # Ignore Blank lines, and comments..
320     next if /^\s*$/;
321     next if /^\s*#/;
322
323     my ($key, $value) = split("=", $_);
324     $value =~ /^\"(.*)\"$/;
325     # Do something with data here!
326     $config{$key} = $1;
327   }
328   close(CONFIG);
329   return "true";
330 }
331
332 sub makecache {
333   # Dump the contents of %config
334   print "Writing \033[1;32mcache file\033[0m for future ./configures ...\n";
335   open(FILEHANDLE, ">.config.cache");
336   foreach $key (keys %config)
337   {
338     print FILEHANDLE "$key=\"$config{$key}\"\n";
339   }
340   close(FILEHANDLE);
341 }
342
343 sub dir_check {
344   my ($desc, $hash_key) = @_;
345   my $complete = 0;
346   while (!$complete) {
347     print "In what directory $desc?\n";
348     print "[\033[1;32m$config{$hash_key}\033[0m] -> ";
349     chomp($var = <STDIN>);
350     if ($var eq "") { $var = $config{$hash_key}; }
351     if ($var =~ /^\~\/(.+)$/) {
352         # Convert it to a full path..
353         $var = resolve_directory($ENV{HOME} . "/" . $1);
354     }
355     if (substr($var,0,1) ne "/")
356     {
357         # Assume relative Path was given.. fill in the rest.
358         $var = $this . "/$var";
359     }
360     $var = resolve_directory($var); 
361     if (! -e $var) {
362       print "$var does not exist. Create it?\n[\033[1;32my\033[0m] ";
363       chomp($tmp = <STDIN>);
364       if (($tmp eq "") || ($tmp =~ /^y/i)) {
365         # Attempt to Create the Dir..
366         $chk = system("mkdir -p \"$var\" >> /dev/null 2>&1") / 256;
367         if ($chk != 0) {
368           print "Unable to create directory. ($var)\n\n";
369           # Restart Loop..
370           next;
371         }
372       } else {
373         # They said they don't want to create, and we can't install there.
374         print "\n\n";
375         next;
376       }
377     } else {
378       if (!is_dir($var)) {
379         # Target exists, but is not a directory.
380         print "File $var exists, but is not a directory.\n\n";
381         next;
382       }
383     }
384     # Either Dir Exists, or was created fine.
385     $config{$hash_key} = $var;
386     $complete = 1;
387     print "\n";
388   }
389 }
390
391 sub getosflags {
392   if ($config{OSNAME} =~ /BSD$/) {
393     $config{LDLIBS} = "-Ldl";
394     $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
395     $config{MAKEPROG} = "gmake";
396     if ($config{OSNAME} eq "OpenBSD") {
397         chomp($foo = `eg++ -dumpversion | cut -c 1`);
398         # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
399         # if theyre not running this, configure lets the build continue but they probably wont manage to
400         # compile as this standard version is 2.95.3!
401         if ($foo ne "") {
402                 $config{CC} = "eg++";
403                 chomp($config{GCCVER}       = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change
404                 chomp($config{GCC34}        = `eg++ -dumpversion | cut -c 3`); # the compiler path
405         }
406     }
407   } else {
408     $config{LDLIBS} = "-ldl";
409     $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
410     $config{MAKEPROG} = "make";
411     if ($config{OSNAME} =~ /CYGWIN/) {
412        $config{FLAGS}  = "-frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
413        $config{LDLIBS} = "";
414        $config{MAKEPROG} = "/usr/bin/make";
415     }
416   }
417   if ($config{OSNAME} =~ /SunOS/) {
418     # solaris/sunos needs these
419     # socket = bsd sockets api
420     # nsl = dns stuff
421     # rt = POSIX realtime extensions
422     # resolv = inet_aton only (why isnt this in nsl?!)
423     $config{LDLIBS} = $config{LDLIBS} . " -lsocket -lnsl -lrt -lresolv";
424   }
425 }
426
427 sub is_dir {
428   my ($path) = @_;
429   if (chdir($path)) {
430     chdir($this);
431     return 1;
432   } else {
433     # Just in case..
434     chdir($this);
435     return 0;
436   }
437 }
438
439 sub getmodules {
440   my $i = 0;
441   opendir(DIRHANDLE, "src/modules");
442   foreach $name (sort readdir(DIRHANDLE)) {
443     if ($name =~ /^m_(.+)\.cpp$/)
444     {
445       $modlist[$i++] = $1;
446     }
447   }
448   closedir(DIRHANDLE);
449 }
450
451 sub writefiles {
452
453   print "Writing \033[1;32minspircd_config.h\033[0m\n";
454   # First File.. inspircd_config.h
455   chomp(my $incos = `uname -n -s -r`);
456   chomp(my $version = `sh ./src/version.sh`);
457   open(FILEHANDLE, ">include/inspircd_config.h");
458   print FILEHANDLE <<EOF;
459 /* Auto generated by configure, do not modify! */
460 #define SYSLOG_FACILITY LOG_DAEMON
461 #define SYSLOG_LEVEL LOG_NOTICE
462 #define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
463 #define MOD_PATH "$config{MODULE_DIR}"
464 #define VERSION "$version"
465 #define MAXCLIENTS $config{MAX_CLIENT}
466 #define NICKMAX $config{NICK_LENGT}
467 #define CHANMAX $config{CHAN_LENGT}
468 #define MAXCHANS $config{MAX_CHANNE}
469 #define MAXMODES $config{MAXI_MODES}
470 #define OPTIMISATION $config{OPTIMITEMP}
471 #define SYSTEM "$incos"
472 #define MAXBUF 514
473 EOF
474
475   if ($config{OSNAME} =~ /SunOS/) {
476     print FILEHANDLE "#define IS_SOLARIS\n";
477   }
478   if ($config{GCCVER} > 3) {
479     print FILEHANDLE "#define GCC3\n";
480     print FILEHANDLE "#define GCC34\n";
481   }
482   else
483   {
484     if ($config{GCCVER} == 3) {
485       print FILEHANDLE "#define GCC3\n";
486       if ($config{GCC34} > 3) {
487         print FILEHANDLE "#define GCC34\n";
488       }
489     }
490   }
491   if ($config{HAS_STRLCPY} eq "true") {
492     print FILEHANDLE "#define HAS_STRLCPY\n";
493   }
494   my $use_hiperf = 0;
495   if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
496     print FILEHANDLE "#define USE_KQUEUE\n";
497     $use_hiperf = 1;
498   }
499   if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
500     print FILEHANDLE "#define USE_EPOLL\n";
501     $use_hiperf = 1;
502   }
503   # user didn't choose either epoll or select for their OS.
504   # default them to USE_SELECT (ewwy puke puke)
505   if (!$use_hiperf) {
506     print FILEHANDLE "#define USE_SELECT\n";
507   }
508   close(FILEHANDLE);
509
510   # Create a Modules List..
511   my $modules = "";
512   foreach $i (@modlist)
513   {
514     if ($config{OSNAME} =~ /CYGWIN/) {
515         $modules .= "m_".$i.".o ";
516     }
517     else {
518         $modules .= "m_".$i.".so ";
519     }
520   }
521   chomp($modules);   # Remove Redundant whitespace..
522
523
524   # Write all .in files.
525   my $tmp = "";
526   my $file = "";
527   my $exe = "inspircd";
528
529   if ($config{OSNAME} =~ /CYGWIN/) {
530     $exe = "inspircd.exe";
531   }
532
533   opendir(DIRHANDLE, $this);
534   foreach $name (sort readdir(DIRHANDLE)) {
535     if ($name =~ /^\.(.+)\.inc$/)
536     {
537       $file = $1;
538       # All .name.inc files need parsing!
539       $tmp = "";
540       open(FILEHANDLE, ".$file.inc");
541       while (<FILEHANDLE>) {
542         $tmp .= $_;
543       }
544       close(FILEHANDLE);
545
546       $tmp =~ s/\@CC\@/$config{CC}/;
547       $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
548       $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
549       $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
550       $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
551       $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
552       $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
553       $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
554       $tmp =~ s/\@MODULES\@/$modules/;
555       $tmp =~ s/\@EXECUTABLE\@/$exe/;
556
557       print "Writing \033[1;32m$file\033[0m\n";
558       open(FILEHANDLE, ">$file");
559       print FILEHANDLE $tmp;
560     }
561   }
562   closedir(DIRHANDLE);
563
564   # Make inspircd executable!
565   chmod 0744, 'inspircd';
566
567   if ($config{OSNAME} =~ /CYGWIN/) {
568         print "Writing static-build \033[1;32msrc/Makefile\033[0m\n";
569         write_static_makefile();
570   }
571   else {
572         print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
573         write_dynamic_makefile();
574   }
575
576   # Modules Makefile..
577   print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
578   open(FILEHANDLE, ">src/modules/Makefile");
579   print FILEHANDLE <<EOF;
580 # (C) ChatSpike development team
581 # Makefile by <Craig\@ChatSpike.net>
582 # Many Thanks to Andrew Church <achurch\@achurch.org>
583 #    for assisting with making this work right.
584 #
585 # Automatically Generated by ./configure to add a modules
586 # please run ./configure --update
587
588 all: \$(MODULES)
589
590 EOF
591
592   # Create a Modules List..
593   my $modules = "";
594   my $flags = "";
595   foreach $i (@modlist)
596   {
597     $flags = getcompilerflags("src/modules/m_".$i.".cpp");
598     if ($config{OSNAME} =~ /CYGWIN/) {
599        print FILEHANDLE <<EOCHEESE;
600 m_$i.o: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h
601         \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i.cpp
602
603 EOCHEESE
604     }
605     else {
606         print FILEHANDLE <<EOCHEESE;
607 m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h
608         \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i.cpp
609         \$(CC) \$(FLAGS) -shared $flags -o m_$i.so m_$i.o
610         cp m_$i.so \$(MODPATH)/
611         chmod 0700 \$(MODPATH)/m_$i.so
612
613 EOCHEESE
614      }
615   }
616 }
617
618 sub getcompilerflags {
619   my ($file) = @_;
620   open(FLAGS, $file);
621   while (<FLAGS>) {
622     if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
623       close(FLAGS);
624       return $1;
625     }
626   }
627   close(FLAGS);
628   return undef;
629 }
630
631 sub show_splash {
632   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";
633   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";
634   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";
635   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";
636   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";
637   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";
638   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";
639   print "\033[0m\033[0m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::\n\n";
640 }
641
642 sub resolve_directory {
643         use File::Spec;
644         return File::Spec->rel2abs($_[0]);
645 }
646
647 sub yesno {
648         my ($flag,$prompt) = @_;
649         print "$prompt [\033[1;32m$config{$flag}\033[0m] -> ";
650         chomp($tmp = <STDIN>);
651         if ($tmp eq "") { $tmp = $config{$flag} }
652
653         if (($tmp eq "") || ($tmp =~ /^y/i)) {
654                 $config{$flag} = "y";
655         } else {
656                 $config{$flag} = "n";
657         }
658         return;
659 }
660
661
662 sub write_static_makefile {
663         open(FH,">src/Makefile") or die("Could not write src/Makefile!");
664         print FH <<EOM;
665 # Insp Makefile :p
666 #
667 # (C) ChatSpike development team
668 # Makefile by <Craig\@ChatSpike.net>
669 # Makefile version 2 (dynamically linked core) by <brain\@inspircd.org>
670 #
671
672 CC = im a cheezeball
673
674 CXXFLAGS = -I$../include \${FLAGS}
675
676 all: hashcomp.o channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o inspircd.exe
677
678 inspircd.exe: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h
679         \$(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 connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o hashcomp.o
680
681 hashcomp.o: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
682         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
683
684 helperfuncs.o: helperfuncs.cpp ../include/base.h ../include/helperfuncs.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
685         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
686
687 channels.o: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
688         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
689
690 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
691         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
692
693 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
694         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
695
696 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
697         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
698
699 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
700         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
701
702 base.o: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
703         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
704
705 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
706         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_util.cpp
707
708 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
709         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_io.cpp
710
711 connection.o: connection.cpp ../include/base.h ../include/connection.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
712         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c connection.cpp
713
714 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
715         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c message.cpp
716
717 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
718         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
719
720 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
721         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dnsqueue.cpp
722
723 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
724         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
725
726 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 ../include/connection.h
727         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
728
729 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
730         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
731
732 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
733         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
734
735 servers.o: servers.cpp ../include/base.h ../include/servers.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h ../include/connection.h
736         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c servers.cpp
737
738
739 EOM
740 close(FH);
741 }
742
743 sub write_dynamic_makefile {
744         open(FH,">src/Makefile") or die("Could not write src/Makefile");
745         print FH <<EOM;
746 # Insp Makefile :p
747 #
748 # (C) ChatSpike development team
749 # Makefile by <Craig\@ChatSpike.net>
750 # Makefile version 2 (dynamically linked core) by <brain\@inspircd.org>
751 #
752
753 CC = im a cheezeball
754
755 CXXFLAGS = -I$../include ${FLAGS}
756
757 all: libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDutil.so libIRCDio.so libIRCDconnection.so libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDservers.so libIRCDhelper.so inspircd
758
759 inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h
760         \$(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 libIRCDconnection.so libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDservers.so libIRCDhelper.so libIRCDhash.so
761
762 libIRCDhash.so: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
763         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
764         \$(CC) -shared -o libIRCDhash.so hashcomp.o
765
766 libIRCDhelper.so: helperfuncs.cpp ../include/base.h ../include/helperfuncs.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
767         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
768         \$(CC) -shared -o libIRCDhelper.so helperfuncs.o
769
770 libIRCDchannels.so: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
771         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
772         \$(CC) -shared -o libIRCDchannels.so channels.o
773
774 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
775         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
776         \$(CC) -shared -o libIRCDmode.so mode.o
777
778 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
779         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
780         \$(CC) -shared -o libIRCDxline.so xline.o
781
782 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
783         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
784         \$(CC) -shared -o libIRCDstring.so inspstring.o
785
786 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
787         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
788         \$(CC) -shared -o libIRCDasyncdns.so dns.o
789
790 libIRCDbase.so: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
791         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
792         \$(CC) -shared -o libIRCDbase.so base.o
793
794 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
795         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_util.cpp
796         \$(CC) -shared -o libIRCDutil.so inspircd_util.o
797
798 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
799         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_io.cpp
800         \$(CC) -shared -o libIRCDio.so inspircd_io.o
801
802 libIRCDconnection.so: connection.cpp ../include/base.h ../include/connection.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
803         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c connection.cpp
804         \$(CC) -shared -o libIRCDconnection.so connection.o
805
806 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
807         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c message.cpp
808         \$(CC) -shared -o libIRCDmessage.so message.o
809
810 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
811         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
812         \$(CC) -shared -o libIRCDcommands.so commands.o
813
814 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
815         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dnsqueue.cpp
816         \$(CC) -shared -o libIRCDdnsqueue.so dnsqueue.o
817
818 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
819         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
820         \$(CC) -shared -o libIRCDdynamic.so dynamic.o
821
822 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 ../include/connection.h
823         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
824         \$(CC) -shared -o libIRCDusers.so users.o
825
826 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
827         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
828         \$(CC) -shared -o libIRCDmodules.so modules.o
829
830 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
831         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
832         \$(CC) -shared -o libIRCDwildcard.so wildcard.o
833
834 libIRCDservers.so: servers.cpp ../include/base.h ../include/servers.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h ../include/connection.h
835         \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c servers.cpp
836         \$(CC) -shared -o libIRCDservers.so servers.o
837
838 EOM
839 close(FH);
840 }