2 # InspIRCd Configuration Script
4 # Copyright 2003 The ChatSpike Development Team
5 # <brain@chatspike.net>
6 # <Craig@chatspike.net>
8 # [14:21] Brain: <matrix impression> i know perl-fu!
12 ########################################
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} = "31"; # 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 $config{STATIC_LINK} = "no"; # are doing static modules?
33 chomp($config{MAX_CLIENT_T} = `sh -c \"ulimit -n\"`); # FD Limit
34 chomp($config{GCCVER} = `gcc -dumpversion | cut -c 1`); # Major GCC Version
35 chomp($config{GCC34} = `gcc -dumpversion | cut -c 3`); # Minor GCC Version
36 chomp($config{OSNAME} = `/bin/uname`); # Operating System Name
37 $config{CC} = "g++"; # C++ compiler
38 $config{MAKEORDER} = "ircd mods config bininst"; # build order
39 $config{STATICLIBS} = ""; # library archive path
40 $config{MAX_IDENT} = "12"; # max ident size
41 $config{MAX_QUIT} = "255"; # max quit message size
42 $config{MAX_TOPIC} = "307"; # max topic size
43 $config{MAX_KICK} = "255"; # max kick message size
44 $config{MAX_GECOS} = "128"; # max GECOS size
45 $config{MAX_AWAY} = "200"; # max AWAY size
47 if ((!$config{OSNAME}) || ($config{OSNAME} eq "")) {
48 chomp($config{OSNAME} = `/usr/bin/uname`);
49 if ((!$config{OSNAME}) || ($config{OSNAME} eq "")){
50 $config{OSNAME} = "Unknown";
54 if (!$config{MAX_CLIENT_T}) {
55 $config{MAX_CLIENT_T} = 1024; # Set a reasonable 'Default'
56 $fd_scan_fail = "true"; # Used Later
59 # Get and Set some important vars..
62 my $arg = $ARGV[0]; # Do Some Argument Checks..
63 if ($arg eq "-clean") { `rm -rf .config.cache`; } # Remove the config.cache file.
65 if ($arg eq "-update") {
66 # Does the cache file exist?
68 # No, No it doesn't.. *BASH*
69 print "You have not run ./configure before. Please do this before trying to run the update script.\n";
72 # We've Loaded the cache file and all our variables..
73 print "Updating Files..\n";
75 $has_epoll = $config{HAS_EPOLL};
76 $has_kqueue = $config{HAS_KQUEUE};
83 print "Checking for cache from previous configure...\n";
85 print "Checking operating system version...\n";
88 if (!$config{MAX_CLIENT}) {
89 # If the cache hasn't set the max clients, copy the variable of MAX_CLIENT_T, this
90 # allows us to keep _T for testing purposes. (ie. "Are you sure you want to go
91 # higher than the found value" :))
92 $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
95 printf "Checking if strlcpy exists... ";
96 # Perform the strlcpy() test..
97 $config{HAS_STRLCPY} = "false";
99 open(STRLCPY, "</usr/include/string.h") or $fail = 1;
102 while (chomp($line = <STRLCPY>))
104 # try and find the delcaration of:
105 # size_t strlcpy(...)
106 if ($line =~ /size_t(\0x9|\s)+strlcpy/)
108 $config{HAS_STRLCPY} = "true";
113 print "yes\n" if $config{HAS_STRLCPY} eq "true";
114 print "no\n" if $config{HAS_STRLCPY} eq "false";
116 printf "Checking if kqueue exists... ";
119 open(KQUEUE, "</usr/include/sys/event.h") or $fail = 1;
122 while (chomp($line = <KQUEUE>))
124 # try and find the delcaration of:
126 if ($line =~ /int(\0x9|\s)+kqueue/)
133 print "yes\n" if $has_kqueue == 1;
134 print "no\n" if $has_kqueue == 0;
136 printf "Checking if epoll exists... ";
139 open(EPOLL, "</usr/include/sys/epoll.h") or $fail = 1;
142 while (chomp($line = <EPOLL>))
144 # try and find the declaration of:
145 # extern int epoll_create (int __size) __THROW;
146 if (($line =~ /int(\0x9|\s)+epoll_create(\0x9|\s)+\(/) || ($line =~ /int(\0x9|\s)+epoll_create\(/))
153 print "yes\n" if $has_epoll == 1;
154 print "no\n" if $has_epoll == 0;
156 if ($config{OSNAME} =~ /CYGWIN/) {
157 $config{HAS_STRLCPY} = "true";
160 $config{HAS_EPOLL} = $has_epoll;
161 $config{HAS_KQUEUE} = $has_kqueue;
163 ################################################################################
164 # BEGIN INTERACTIVE PART #
165 ################################################################################
169 # Display Splash Logo..
171 chomp($wholeos = `uname -mnr`);
173 # Display Introduction Message..
175 Welcome to the InspIRCd Configuration program!
177 *** If you are unsure of any of these values, leave it blank for ***
178 *** standard settings that will work, and your server will run ***
179 *** using them. If you are running this server as part of a ***
180 *** larger network, you must consult with your network admins ***
181 *** for the proper values to use, or server links will be unstable! ***
183 Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter
184 a new value. Please note: You will \033[1mHAVE\033[0m to read the docs
185 dir, otherwise you won't have a config file!
187 Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos), fdmax: $config{MAX_CLIENT_T}\n\n";
189 # Directory Settings..
190 dir_check("are the configuration files", "CONFIG_DIR");
191 dir_check("are the modules to be compiled to", "MODULE_DIR");
192 dir_check("is the IRCd binary to be placed", "BINARY_DIR");
193 dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
196 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?");
200 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?");
203 $chose_hiperf = (($config{USE_EPOLL} eq "y") || ($config{USE_KQUEUE} eq "y"));
206 print "No high-performance socket engines are available, or you chose\n";
207 print "not to enable one. Defaulting to select() engine.\n\n";
210 print "\nThe following questions will ask you for various figures relating\n";
211 print "To your IRCd install. Please note that these should usually be left\n";
212 print "as defaults unless you have a real reason to change them. If they\n";
213 print "changed, then the values must be identical on all servers on your\n";
214 print "network, or malfunctions and/or crashes may occur, with the exception\n";
215 print "of the 'maximum number of clients' setting which may be different on\n";
216 print "different servers on the network.\n\n";
218 # File Descriptor Settings..
221 print "Maximum number of clients at any one time ($config{MAX_CLIENT_T})\n";
222 print "[\033[1;32m$config{MAX_CLIENT}\033[0m] -> ";
223 chomp($var = <STDIN>);
224 if ($var eq "") { $var = $config{MAX_CLIENT}; }
225 if ($var =~ /^\d+$/) {
226 if (($var > $config{MAX_CLIENT_T}) && ($fd_scan_failed ne true)) {
227 # Client has entered a larger number than the 'discovered' value
229 print "WARNING: Our scans have indicated that you are attempting
230 to use more sockets than there are avaliable. Are you sure
231 you wish to do this? It may cause the IRCd to malfunction [y/n]
232 [\033[1;32mn\033[0m] -> $c";
233 chomp($tmp = <STDIN>);
235 print "Please enter the correct value.\n\n";
240 print "You must enter a number in this field. Please try again.\n\n";
243 # If we get here, we should be good to go.
244 $config{MAX_CLIENT} = $var;
251 print "What is the maximum length of nicknames?\n";
252 print "[\033[1;32m$config{NICK_LENGT}\033[0m] -> ";
253 chomp($var = <STDIN>);
254 if ($var eq "") { $var = $config{NICK_LENGT}; }
255 if ($var =~ /^\d+$/) {
256 # We don't care what the number is, set it and be on our way.
257 $config{NICK_LENGT} = $var;
261 print "You must enter a number in this field. Please try again.\n\n";
267 print "What is the maximum length of channel names?\n";
268 print "[\033[1;32m$config{CHAN_LENGT}\033[0m] -> ";
269 chomp($var = <STDIN>);
270 if ($var eq "") { $var = $config{CHAN_LENGT}; }
271 if ($var =~ /^\d+$/) {
272 # We don't care what the number is, set it and be on our way.
273 $config{CHAN_LENGT} = $var;
277 print "You must enter a number in this field. Please try again.\n\n";
283 print "What is the maximum number of channels a user may join at any one time?\n";
284 print "[\033[1;32m$config{MAX_CHANNE}\033[0m] -> ";
285 chomp($var = <STDIN>);
286 if ($var eq "") { $var = $config{MAX_CHANNE}; }
287 if ($var =~ /^\d+$/) {
288 # We don't care what the number is, set it and be on our way.
289 $config{MAX_CHANNE} = $var;
293 print "You must enter a number in this field. Please try again.\n\n";
299 print "What is the maximum number of mode changes in one line?\n";
300 print "[\033[1;32m$config{MAXI_MODES}\033[0m] -> ";
301 chomp($var = <STDIN>);
302 if ($var eq "") { $var = $config{MAXI_MODES}; }
303 if ($var =~ /^\d+$/) {
304 # We don't care what the number is, set it and be on our way.
305 $config{MAXI_MODES} = $var;
309 print "You must enter a number in this field. Please try again.\n\n";
315 print "What is the maximum length of an ident (username)?\n";
316 print "[\033[1;32m$config{MAX_IDENT}\033[0m] -> ";
317 chomp($var = <STDIN>);
318 if ($var eq "") { $var = $config{MAX_IDENT}; }
319 if ($var =~ /^\d+$/) {
320 # We don't care what the number is, set it and be on our way.
321 $config{MAX_IDENT} = $var;
325 print "You must enter a number in this field. Please try again.\n\n";
331 print "What is the maximum length of a quit message?\n";
332 print "[\033[1;32m$config{MAX_QUIT}\033[0m] -> ";
333 chomp($var = <STDIN>);
334 if ($var eq "") { $var = $config{MAX_QUIT}; }
335 if ($var =~ /^\d+$/) {
336 # We don't care what the number is, set it and be on our way.
337 $config{MAX_QUIT} = $var;
341 print "You must enter a number in this field. Please try again.\n\n";
347 print "What is the maximum length of a channel topic?\n";
348 print "[\033[1;32m$config{MAX_TOPIC}\033[0m] -> ";
349 chomp($var = <STDIN>);
350 if ($var eq "") { $var = $config{MAX_TOPIC}; }
351 if ($var =~ /^\d+$/) {
352 # We don't care what the number is, set it and be on our way.
353 $config{MAX_TOPIC} = $var;
357 print "You must enter a number in this field. Please try again.\n\n";
363 print "What is the maximum length of a kick message?\n";
364 print "[\033[1;32m$config{MAX_KICK}\033[0m] -> ";
365 chomp($var = <STDIN>);
366 if ($var eq "") { $var = $config{MAX_KICK}; }
367 if ($var =~ /^\d+$/) {
368 # We don't care what the number is, set it and be on our way.
369 $config{MAX_KICK} = $var;
373 print "You must enter a number in this field. Please try again.\n\n";
379 print "What is the maximum length of a GECOS (real name) field?\n";
380 print "[\033[1;32m$config{MAX_GECOS}\033[0m] -> ";
381 chomp($var = <STDIN>);
382 if ($var eq "") { $var = $config{MAX_GECOS}; }
383 if ($var =~ /^\d+$/) {
384 # We don't care what the number is, set it and be on our way.
385 $config{MAX_GECOS} = $var;
389 print "You must enter a number in this field. Please try again.\n\n";
395 print "What is the maximum length of an away message?\n";
396 print "[\033[1;32m$config{MAX_AWAY}\033[0m] -> ";
397 chomp($var = <STDIN>);
398 if ($var eq "") { $var = $config{MAX_AWAY}; }
399 if ($var =~ /^\d+$/) {
400 # We don't care what the number is, set it and be on our way.
401 $config{MAX_AWAY} = $var;
405 print "You must enter a number in this field. Please try again.\n\n";
410 print "Enter the Level Of Binary optimisation. This is a number between 0 and 3.
411 The InspIRCd Team will NOT support any bug reports above 0. Also note,
412 the IRCd behaviour will be different depending on this value. Please
413 read the documentation for more information.
415 The higher the number, the more optimised your binary will be. This
416 value will default to 0 if you either don't enter a number, or enter
417 a value outside the range.
419 As always, if you are unsure, just press enter and accept the default.\n\n";
420 print "[\033[1;32m$config{OPTIMITEMP}\033[0m] -> ";
421 chomp($var = <STDIN>);
423 $var = $config{OPTIMITEMP};
427 $config{OPTIMITEMP} = 1;
428 $config{OPTIMISATI} = "-O";
429 } elsif ($var eq "2") {
430 $config{OPTIMITEMP} = 2;
431 $config{OPTIMISATI} = "-O2";
432 } elsif ($var eq "3") {
433 $config{OPTIMITEMP} = 3;
434 $config{OPTIMISATI} = "-O3";
436 $config{OPTIMITEMP} = 0;
437 $config{OPTIMISATI} = "-g";
440 print "\n\033[1;32mPre-build configuration is complete!\033[0m\n\n";
441 print "\033[0mConfig path:\033[1;32m\t\t\t$config{CONFIG_DIR}\n";
442 print "\033[0mModule path:\033[1;32m\t\t\t$config{MODULE_DIR}\n";
443 print "\033[0mMax connections:\033[1;32m\t\t$config{MAX_CLIENT}\n";
444 print "\033[0mMax User Channels:\033[1;32m\t\t$config{MAX_CHANNE}\n";
445 print "\033[0mMax nickname length:\033[1;32m\t\t$config{NICK_LENGT}\n";
446 print "\033[0mMax channel length:\033[1;32m\t\t$config{CHAN_LENGT}\n";
447 print "\033[0mMax mode length:\033[1;32m\t\t$config{MAXI_MODES}\n";
448 print "\033[0mMax ident length:\033[1;32m\t\t$config{MAX_IDENT}\n";
449 print "\033[0mMax quit length:\033[1;32m\t\t$config{MAX_QUIT}\n";
450 print "\033[0mMax topic length:\033[1;32m\t\t$config{MAX_TOPIC}\n";
451 print "\033[0mMax kick length:\033[1;32m\t\t$config{MAX_KICK}\n";
452 print "\033[0mMax name length:\033[1;32m\t\t$config{MAX_GECOS}\n";
453 print "\033[0mMax away length:\033[1;32m\t\t$config{MAX_AWAY}\n";
454 print "\033[0mGCC Version Found:\033[1;32m\t\t$config{GCCVER}.$config{GCC34}\n";
455 print "\033[0mOptimatizaton Flag:\033[1;32m\t\t$config{OPTIMISATI}\033[0m\n";
456 print "\033[0mCompiler program:\033[1;32m\t\t$config{CC}\033[0m\n";
457 print "\033[0mStatic modules:\033[1;32m\t\t\t$config{STATIC_LINK}\033[0m\n\n";
463 print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
464 print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
465 if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
466 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";
468 if ($config{OSNAME} =~ /CYGWIN/) {
470 \033[1;32mWARNING!\033[0m CYGWIN does not properly support shared modules,
471 so modules will be compiled statically into the core of the ircd. The modules
472 will act like they are being loaded from disk and being unloaded from RAM,
473 however they are in fact being enabled and disabled similar to features in
478 if ($config{GCCVER} < "3") {
480 \033[1;32mWARNING!\033[0m You are attempting to compile InspIRCd on GCC 2.x!
481 GCC 2.x series compilers only had partial (read as broken) C++ support, and
482 your compile will most likely fail horribly! If you have any problems, do NOT
483 report them to the bugtracker or forums without first upgrading your compiler
484 to a newer 3.x or 4.x (or whatever is available currently) version.
488 ################################################################################
490 ################################################################################
492 # Retrieves the .config.cache file, and loads values into the main config hash.
493 open(CACHE, ".config.cache") or return undef;
497 # Ignore Blank lines, and comments..
501 my ($key, $value) = split("=", $_);
502 $value =~ /^\"(.*)\"$/;
503 # Do something with data here!
511 # Dump the contents of %config
512 print "Writing \033[1;32mcache file\033[0m for future ./configures ...\n";
513 open(FILEHANDLE, ">.config.cache");
514 foreach $key (keys %config)
516 print FILEHANDLE "$key=\"$config{$key}\"\n";
522 my ($desc, $hash_key) = @_;
525 print "In what directory $desc?\n";
526 print "[\033[1;32m$config{$hash_key}\033[0m] -> ";
527 chomp($var = <STDIN>);
528 if ($var eq "") { $var = $config{$hash_key}; }
529 if ($var =~ /^\~\/(.+)$/) {
530 # Convert it to a full path..
531 $var = resolve_directory($ENV{HOME} . "/" . $1);
533 if (substr($var,0,1) ne "/")
535 # Assume relative Path was given.. fill in the rest.
536 $var = $this . "/$var";
538 $var = resolve_directory($var);
540 print "$var does not exist. Create it?\n[\033[1;32my\033[0m] ";
541 chomp($tmp = <STDIN>);
542 if (($tmp eq "") || ($tmp =~ /^y/i)) {
543 # Attempt to Create the Dir..
544 $chk = system("mkdir -p \"$var\" >> /dev/null 2>&1") / 256;
546 print "Unable to create directory. ($var)\n\n";
551 # They said they don't want to create, and we can't install there.
557 # Target exists, but is not a directory.
558 print "File $var exists, but is not a directory.\n\n";
562 # Either Dir Exists, or was created fine.
563 $config{$hash_key} = $var;
570 if ($config{OSNAME} =~ /BSD$/) {
571 $config{LDLIBS} = "-Ldl";
572 $config{FLAGS} = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
573 $config{MAKEPROG} = "gmake";
574 if ($config{OSNAME} eq "OpenBSD") {
575 chomp($foo = `eg++ -dumpversion | cut -c 1`);
576 # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
577 # if theyre not running this, configure lets the build continue but they probably wont manage to
578 # compile as this standard version is 2.95.3!
580 $config{CC} = "eg++";
581 chomp($config{GCCVER} = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change
582 chomp($config{GCC34} = `eg++ -dumpversion | cut -c 3`); # the compiler path
586 $config{LDLIBS} = "-ldl";
587 $config{FLAGS} = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
588 $config{MAKEPROG} = "make";
589 if ($config{OSNAME} =~ /CYGWIN/) {
590 $config{FLAGS} = "-frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
591 $config{LDLIBS} = "";
592 $config{MAKEPROG} = "/usr/bin/make";
593 $config{MAKEORDER} = "mods ircd config bininst";
594 $config{STATICLIBS} = "modules/mods.a";
595 $config{STATIC_LINK} = "yes";
598 if ($config{OSNAME} =~ /SunOS/) {
599 # solaris/sunos needs these
600 # socket = bsd sockets api
602 # rt = POSIX realtime extensions
603 # resolv = inet_aton only (why isnt this in nsl?!)
604 $config{LDLIBS} = $config{LDLIBS} . " -lsocket -lnsl -lrt -lresolv";
622 opendir(DIRHANDLE, "src/modules");
623 foreach $name (sort readdir(DIRHANDLE)) {
624 if ($name =~ /^m_(.+)\.cpp$/)
627 if ($mod !~ /_static$/) {
628 $modlist[$i++] = $mod;
637 print "Writing \033[1;32minspircd_config.h\033[0m\n";
638 # First File.. inspircd_config.h
639 chomp(my $incos = `uname -n -s -r`);
640 chomp(my $version = `sh ./src/version.sh`);
641 open(FILEHANDLE, ">include/inspircd_config.h");
642 my $NL = $config{NICK_LENGT}+1;
643 my $CL = $config{CHAN_LENGT}+1;
644 print FILEHANDLE <<EOF;
645 /* Auto generated by configure, do not modify! */
646 #ifndef __CONFIGURATION_AUTO__
647 #define __CONFIGURATION_AUTO__
649 #define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
650 #define MOD_PATH "$config{MODULE_DIR}"
651 #define VERSION "$version"
652 #define MAXCLIENTS $config{MAX_CLIENT}
655 #define MAXCHANS $config{MAX_CHANNE}
656 #define MAXMODES $config{MAXI_MODES}
657 #define IDENTMAX $config{MAX_IDENT}
658 #define MAXQUIT $config{MAX_QUIT}
659 #define MAXTOPIC $config{MAX_TOPIC}
660 #define MAXKICK $config{MAX_KICK}
661 #define MAXGECOS $config{MAX_GECOS}
662 #define MAXAWAY $config{MAX_AWAY}
663 #define OPTIMISATION $config{OPTIMITEMP}
664 #define SYSTEM "$incos"
668 if ($config{OSNAME} =~ /SunOS/) {
669 print FILEHANDLE "#define IS_SOLARIS\n";
671 if ($config{OSNAME} =~ /CYGWIN/) {
672 print FILEHANDLE "#define IS_CYGWIN\n";
673 print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE 1024\n#endif\n";
675 if ($config{STATIC_LINK} eq "yes") {
676 print FILEHANDLE "#define STATIC_LINK\n";
678 if ($config{GCCVER} > 3) {
679 print FILEHANDLE "#define GCC3\n";
680 print FILEHANDLE "#define GCC34\n";
684 if ($config{GCCVER} == 3) {
685 print FILEHANDLE "#define GCC3\n";
686 if ($config{GCC34} > 3) {
687 print FILEHANDLE "#define GCC34\n";
691 if ($config{HAS_STRLCPY} eq "true") {
692 print FILEHANDLE "#define HAS_STRLCPY\n";
695 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
696 print FILEHANDLE "#define USE_KQUEUE\n";
699 if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
700 print FILEHANDLE "#define USE_EPOLL\n";
703 # user didn't choose either epoll or select for their OS.
704 # default them to USE_SELECT (ewwy puke puke)
706 print FILEHANDLE "#define USE_SELECT\n";
708 print FILEHANDLE "\n#endif\n";
711 # Create a Modules List..
713 foreach $i (@modlist)
715 if ($config{OSNAME} =~ /CYGWIN/) {
716 $modules .= "m_".$i.".o ";
719 $modules .= "m_".$i.".so ";
722 chomp($modules); # Remove Redundant whitespace..
725 # Write all .in files.
728 my $exe = "inspircd";
730 if ($config{OSNAME} =~ /CYGWIN/) {
731 $exe = "inspircd.exe";
734 opendir(DIRHANDLE, $this);
735 foreach $name (sort readdir(DIRHANDLE)) {
736 if ($name =~ /^\.(.+)\.inc$/)
739 # All .name.inc files need parsing!
741 open(FILEHANDLE, ".$file.inc");
742 while (<FILEHANDLE>) {
747 $tmp =~ s/\@CC\@/$config{CC}/;
748 $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
749 $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
750 $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
751 $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
752 $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
753 $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
754 $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
755 $tmp =~ s/\@MODULES\@/$modules/;
756 $tmp =~ s/\@EXECUTABLE\@/$exe/;
757 $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
758 $tmp =~ s/\@STATICLIBS\@/$config{STATICLIBS}/;
760 print "Writing \033[1;32m$file\033[0m\n";
761 open(FILEHANDLE, ">$file");
762 print FILEHANDLE $tmp;
767 # Make inspircd executable!
768 chmod 0744, 'inspircd';
770 if ($config{OSNAME} =~ /CYGWIN/) {
771 print "Writing static-build \033[1;32msrc/Makefile\033[0m\n";
772 write_static_makefile();
775 print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
776 write_dynamic_makefile();
781 print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
782 open(FILEHANDLE, ">src/modules/Makefile");
783 print FILEHANDLE <<EOF;
784 # (C) ChatSpike development team
785 # Makefile by <Craig\@ChatSpike.net>
786 # Many Thanks to Andrew Church <achurch\@achurch.org>
787 # for assisting with making this work right.
789 # Automatically Generated by ./configure to add a modules
790 # please run ./configure --update
796 # Create a Modules List..
799 if ($config{OSNAME} =~ /CYGWIN/) {
800 open(MODLIST,">include/modlist.h");
801 print MODLIST <<HEADER;
802 // Generated automatically by configure. DO NOT EDIT!
804 #ifndef __SYMBOLS__H_CONFIGURED__
805 #define __SYMBOLS__H_CONFIGURED__
808 foreach $i (@modlist) {
809 if ($i !~ /_static$/) {
810 print MODLIST "extern \"C\" void * $i\_init (void);\n";
813 print MODLIST "\nstruct {const char *name; initfunc *value; } modsyms[] = {\n";
815 foreach $i (@modlist)
817 if ($i !~ /_static$/) {
818 $flags = getcompilerflags("src/modules/m_".$i.".cpp");
819 if ($config{OSNAME} =~ /CYGWIN/) {
820 print FILEHANDLE <<EOCHEESE;
821 m_$i.o: m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h
822 \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i\_static.cpp
823 mv m_$i\_static.o ../m_$i.o
826 print "Configuring module [\033[1;32mm_$i.so\033[0m] for static linking... ";
827 open(MODULE,"<src/modules/m_".$i.".cpp") or die("Could not open m_".$i.".cpp");
828 open(MUNGED,">src/modules/m_".$i."_static.cpp") or die("Could not create m_".$i."_static.cpp");
829 while (chomp($a = <MODULE>)) {
830 $a =~ s/init_module/$i\_init/g;
831 $a =~ s/Srv/$i\Srv/g;
836 print MODLIST <<EOENT;
837 {"m_$i.so",\&$i\_init},
842 print FILEHANDLE <<EOCHEESE;
843 m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h
844 \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i.cpp
845 \$(CC) \$(FLAGS) -shared $flags -o m_$i.so m_$i.o
846 @-rm -f \$(MODPATH)/m_$i.so
847 cp m_$i.so \$(MODPATH)/
848 chmod 0700 \$(MODPATH)/m_$i.so
854 if ($config{OSNAME} =~ /CYGWIN/) {
855 print MODLIST "{0}};\n\n#endif\n";
860 sub getcompilerflags {
864 if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
874 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";
875 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";
876 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";
877 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";
878 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";
879 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";
880 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";
881 print "\033[0m\033[0m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::\n\n";
884 sub resolve_directory {
886 return File::Spec->rel2abs($_[0]);
890 my ($flag,$prompt) = @_;
891 print "$prompt [\033[1;32m$config{$flag}\033[0m] -> ";
892 chomp($tmp = <STDIN>);
893 if ($tmp eq "") { $tmp = $config{$flag} }
895 if (($tmp eq "") || ($tmp =~ /^y/i)) {
896 $config{$flag} = "y";
898 $config{$flag} = "n";
904 sub write_static_makefile {
905 open(FH,">src/Makefile") or die("Could not write src/Makefile!");
909 # (C) ChatSpike development team
910 # Makefile by <Craig\@ChatSpike.net>
911 # Makefile version 2 (dynamically linked core) by <brain\@inspircd.org>
916 CXXFLAGS = -I../include \${FLAGS}
918 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 \$(MODULES) inspircd.exe
920 inspircd.exe: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h
921 \$(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 \$(MODULES)
923 hashcomp.o: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
924 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
926 helperfuncs.o: helperfuncs.cpp ../include/base.h ../include/helperfuncs.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
927 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
929 channels.o: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
930 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
932 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
933 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
935 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
936 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
938 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
939 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
941 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
942 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
944 base.o: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
945 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
947 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
948 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_util.cpp
950 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
951 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_io.cpp
953 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
954 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c connection.cpp
956 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
957 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c message.cpp
959 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
960 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
962 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
963 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dnsqueue.cpp
965 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
966 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
968 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
969 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
971 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
972 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
974 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
975 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
977 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
978 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c servers.cpp
985 sub write_dynamic_makefile {
986 open(FH,">src/Makefile") or die("Could not write src/Makefile");
990 # (C) ChatSpike development team
991 # Makefile by <Craig\@ChatSpike.net>
992 # Makefile version 2 (dynamically linked core) by <brain\@inspircd.org>
997 CXXFLAGS = -I../include \${FLAGS}
999 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
1001 inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h
1002 \$(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
1004 libIRCDhash.so: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1005 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
1006 \$(CC) -shared -o libIRCDhash.so hashcomp.o
1008 libIRCDhelper.so: helperfuncs.cpp ../include/base.h ../include/helperfuncs.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1009 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c helperfuncs.cpp
1010 \$(CC) -shared -o libIRCDhelper.so helperfuncs.o
1012 libIRCDchannels.so: channels.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
1013 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c channels.cpp
1014 \$(CC) -shared -o libIRCDchannels.so channels.o
1016 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
1017 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c mode.cpp
1018 \$(CC) -shared -o libIRCDmode.so mode.o
1020 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
1021 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c xline.cpp
1022 \$(CC) -shared -o libIRCDxline.so xline.o
1024 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
1025 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspstring.cpp
1026 \$(CC) -shared -o libIRCDstring.so inspstring.o
1028 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
1029 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dns.cpp
1030 \$(CC) -shared -o libIRCDasyncdns.so dns.o
1032 libIRCDbase.so: base.cpp ../include/base.h ../include/globals.h ../include/inspircd_config.h
1033 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c base.cpp
1034 \$(CC) -shared -o libIRCDbase.so base.o
1036 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
1037 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_util.cpp
1038 \$(CC) -shared -o libIRCDutil.so inspircd_util.o
1040 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
1041 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd_io.cpp
1042 \$(CC) -shared -o libIRCDio.so inspircd_io.o
1044 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
1045 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c connection.cpp
1046 \$(CC) -shared -o libIRCDconnection.so connection.o
1048 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
1049 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c message.cpp
1050 \$(CC) -shared -o libIRCDmessage.so message.o
1052 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
1053 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
1054 \$(CC) -shared -o libIRCDcommands.so commands.o
1056 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
1057 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dnsqueue.cpp
1058 \$(CC) -shared -o libIRCDdnsqueue.so dnsqueue.o
1060 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
1061 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
1062 \$(CC) -shared -o libIRCDdynamic.so dynamic.o
1064 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
1065 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c users.cpp
1066 \$(CC) -shared -o libIRCDusers.so users.o
1068 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
1069 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c modules.cpp
1070 \$(CC) -shared -o libIRCDmodules.so modules.o
1072 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
1073 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c wildcard.cpp
1074 \$(CC) -shared -o libIRCDwildcard.so wildcard.o
1076 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
1077 \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c servers.cpp
1078 \$(CC) -shared -o libIRCDservers.so servers.o