2 ###################################################
3 # InspIRCd Configuration Script
5 # Copyright 2002-2007 The InspIRCd Development Team
6 # http://www.inspircd.org/wiki/index.php/Credits
8 # Licensed under GPL, please see the COPYING file
13 ###################################################
20 # Utility functions for our buildsystem
24 use make::opensslcert;
26 ###############################################################################################
30 ###############################################################################################
32 # If you wish to ignore a dependency throughout the entire core, add it here.
35 "inspircd_win32wrapper.h", # windows has its own configure program
38 # If you wish for all files in the entire core to have a given dependency, insert it here.
39 # You should keep this to an absolute minimum to avoid rebuilds that are not neccessary.
42 "inspircd_config.h", # auto re-generated by configure
47 ###############################################################################################
49 # NON-EDITABLE VARIABLES
51 ###############################################################################################
53 # This is a list of all files in the core. Each cpp file is mapped to a shared object file,
54 # whos file extension is omitted (these can vary from system to system). Auto detected by
55 # scanning the src/*.cpp files for files containing /* $Core: */ identifiers.
59 # If you wish for a file to have special dependencies in the makefile, add an entry here.
63 # If you wish for a file to have extra make lines (in between the compile and link steps)
64 # then insert them here.
66 my %extrabuildlines = ();
68 # If you wish for a file to be linked against extra objects or arctives, insert them here.
70 my %extraobjects = ();
72 # If you wish to compile extra cpp sources into an object, define them here.
73 # NOTE: Certain cpp files such as the socket engines have a value auto calculated
74 # for this table so that their derived class is built.
76 my %extrasources = ();
80 'enable-gnutls' => \$opt_use_gnutls,
81 'rebuild' => \$opt_rebuild,
82 'enable-openssl' => \$opt_use_openssl,
83 'disable-interactive' => \$opt_nointeractive,
84 'with-nick-length=i' => \$opt_nick_length,
85 'with-channel-length=i' => \$opt_chan_length,
86 'with-max-clients=i' => \$opt_maxclients,
87 'enable-ports' => \$opt_ports,
88 'enable-epoll' => \$opt_epoll,
89 'enable-kqueue' => \$opt_kqueue,
90 'disable-ports' => \$opt_noports,
91 'disable-epoll' => \$opt_noepoll,
92 'disable-kqueue' => \$opt_nokqueue,
93 'enable-ipv6' => \$opt_ipv6,
94 'enable-remote-ipv6' => \$opt_ipv6links,
95 'disable-remote-ipv6' => \$opt_noipv6links,
96 'with-cc=s' => \$opt_cc,
97 'with-ident-length=i' => \$opt_ident,
98 'with-quit-length=i' => \$opt_quit,
99 'with-topic-length=i' => \$opt_topic,
100 'with-maxbuf=i' => \$opt_maxbuf,
101 'with-kick-length=i' => \$opt_kick,
102 'with-gecos-length=i' => \$opt_gecos,
103 'with-away-length=i' => \$opt_away,
104 'with-max-modes=i' => \$opt_modes,
105 'prefix=s' => \$opt_base_dir,
106 'config-dir=s' => \$opt_config_dir,
107 'module-dir=s' => \$opt_module_dir,
108 'binary-dir=s' => \$opt_binary_dir,
109 'library-dir=s' => \$opt_library_dir,
110 'disable-debuginfo' => sub { $opt_disable_debug = 1 },
111 'help' => sub { showhelp(); },
112 'modupdate' => sub { modupdate(); },
113 'update' => sub { update(); },
114 'svnupdate' => sub { svnupdate(); },
115 'clean' => sub { clean(); },
118 my $non_interactive = (
119 (defined $opt_library_dir) ||
120 (defined $opt_base_dir) ||
121 (defined $opt_config_dir) ||
122 (defined $opt_module_dir) ||
123 (defined $opt_base_dir) ||
124 (defined $opt_binary_dir) ||
125 (defined $opt_nointeractive) ||
126 (defined $opt_away) ||
127 (defined $opt_gecos) ||
128 (defined $opt_kick) ||
129 (defined $opt_maxclients) ||
130 (defined $opt_modes) ||
131 (defined $opt_topic) ||
132 (defined $opt_quit) ||
133 (defined $opt_ident) ||
135 (defined $opt_ipv6) ||
136 (defined $opt_ipv6links) ||
137 (defined $opt_noipv6links) ||
138 (defined $opt_kqueue) ||
139 (defined $opt_epoll) ||
140 (defined $opt_ports) ||
141 (defined $opt_maxchans) ||
142 (defined $opt_opermaxchans) ||
143 (defined $opt_chan_length) ||
144 (defined $opt_nick_length) ||
145 (defined $opt_use_openssl) ||
146 (defined $opt_nokqueue) ||
147 (defined $opt_noepoll) ||
148 (defined $opt_noports) ||
149 (defined $opt_maxbuf) ||
150 (defined $opt_use_gnutls)
152 my $interactive = !$non_interactive;
155 chomp($topdir = getcwd());
156 $this = resolve_directory($topdir); # PWD, Regardless.
157 @modlist = (); # Declare for Module List..
158 %config = (); # Initiate Configuration Hash..
159 $config{ME} = resolve_directory($topdir); # Present Working Directory
161 $config{BASE_DIR} = $config{ME};
163 if (defined $opt_base_dir)
165 $config{BASE_DIR} = $opt_base_dir;
168 $config{CONFIG_DIR} = resolve_directory($config{BASE_DIR}."/conf"); # Configuration Directory
169 $config{MODULE_DIR} = resolve_directory($config{BASE_DIR}."/modules"); # Modules Directory
170 $config{BINARY_DIR} = resolve_directory($config{BASE_DIR}."/bin"); # Binary Directory
171 $config{LIBRARY_DIR} = resolve_directory($config{BASE_DIR}."/lib"); # Library Directory
173 if (defined $opt_config_dir)
175 $config{CONFIG_DIR} = $opt_config_dir;
177 if (defined $opt_module_dir)
179 $config{MODULE_DIR} = $opt_module_dir;
181 if (defined $opt_binary_dir)
183 $config{BINARY_DIR} = $opt_binary_dir;
185 if (defined $opt_library_dir)
187 $config{LIBRARY_DIR} = $opt_library_dir;
189 chomp($config{HAS_GNUTLS} = `libgnutls-config --version 2>/dev/null | cut -c 1,2,3`); # GNUTLS Version.
190 chomp($config{HAS_OPENSSL} = `pkg-config --modversion openssl 2>/dev/null`); # Openssl version
191 chomp($gnutls_ver = $config{HAS_GNUTLS});
192 chomp($openssl_ver = $config{HAS_OPENSSL});
193 $config{USE_GNUTLS} = "n";
194 if (defined $opt_use_gnutls)
196 $config{USE_GNUTLS} = "y"; # Use gnutls.
198 $config{USE_OPENSSL} = "n"; # Use openssl.
199 if (defined $opt_use_openssl)
201 $config{USE_OPENSSL} = "y";
204 # no, let's not change these.
205 $config{OPTIMITEMP} = "0"; # Default Optimisation Value
206 if (!defined $opt_disable_debug)
208 $config{OPTIMISATI} = "-g1"; # Optimisation Flag
212 $config{OPTIMISATI} = "-O2"; # DEBUGGING OFF!
215 $config{NICK_LENGT} = "31"; # Default Nick Length
216 if (defined $opt_nick_length)
218 $config{NICK_LENGT} = $opt_nick_length;
220 $config{CHAN_LENGT} = "64"; # Default Channel Name Length
221 if (defined $opt_chan_length)
223 $config{CHAN_LENGT} = $opt_chan_length;
225 $config{MAXI_MODES} = "20"; # Default Max. Number of Modes set at once.
226 if (defined $opt_modes)
228 $config{MAXI_MODES} = $opt_modes;
230 $config{HAS_STRLCPY} = "false"; # strlcpy Check.
231 $config{HAS_STDINT} = "false"; # stdint.h check
232 $config{USE_KQUEUE} = "y"; # kqueue enabled
233 if (defined $opt_kqueue)
235 $config{USE_KQUEUE} = "y";
237 if (defined $opt_nokqueue)
239 $config{USE_KQUEUE} = "n";
241 $config{USE_EPOLL} = "y"; # epoll enabled
242 if (defined $opt_epoll)
244 $config{USE_EPOLL} = "y";
246 if (defined $opt_noepoll)
248 $config{USE_EPOLL} = "n";
250 $config{USE_PORTS} = "y"; # epoll enabled
251 if (defined $opt_ports)
253 $config{USE_PORTS} = "y";
255 if (defined $opt_noports)
257 $config{USE_PORTS} = "n";
259 $config{IPV6} = "n"; # IPv6 support (experimental)
260 if (defined $opt_ipv6)
264 $config{SUPPORT_IP6LINKS} = "y"; # IPv4 supporting IPv6 links (experimental)
265 if (defined $opt_ipv6links)
267 $config{SUPPORT_IP6LINKS} = "y";
269 if (defined $opt_noipv6links)
271 $config{SUPPORT_IP6LINKS} = "n";
273 chomp($config{MAX_CLIENT_T} = `sh -c \"ulimit -n\"`); # FD Limit
274 chomp($config{MAX_DESCRIPTORS} = `sh -c \"ulimit -n\"`); # Hard FD Limit
275 chomp($config{GCCVER} = `g++ -dumpversion | cut -c 1`); # Major GCC Version
276 $config{_SOMAXCONN} = SOMAXCONN; # Max connections in accept queue
277 $config{OSNAME} = $^O; # Operating System Name
278 $config{IS_DARWIN} = "NO"; # Is OSX?
279 $config{STARTSCRIPT} = "inspircd"; # start script?
280 $config{DESTINATION} = "BASE"; # Is target path.
281 $config{EXTRA_DIR} = ""; # Is empty.
282 if ($config{OSNAME} =~ /darwin/i)
284 $config{IS_DARWIN} = "YES";
285 $config{STARTSCRIPT} = "org.inspircd.plist"; # start script for OSX.
286 $config{DESTINATION} = "LAUNCHDPATH"; # Is OSX target.
287 $config{EXTRA_DIR} = " launchd_dir"; # Is OSX specific path.
289 $config{CC} = "g++"; # C++ compiler
292 $config{CC} = $opt_cc;
294 $exec = $config{CC} . " -dumpversion | cut -c 1";
295 chomp($config{GCCVER} = `$exec`); # Major GCC Version
296 $config{MAKEORDER} = "ircd mods"; # build order
297 $config{MAX_IDENT} = "12"; # max ident size
298 $config{MAX_QUIT} = "255"; # max quit message size
299 $config{MAX_TOPIC} = "307"; # max topic size
300 $config{MAX_KICK} = "255"; # max kick message size
301 $config{MAX_GECOS} = "128"; # max GECOS size
302 $config{MAX_AWAY} = "200"; # max AWAY size
303 $config{MAXBUF} = "512"; # Max buffer size
304 if (defined $opt_ident)
306 $config{MAX_IDENT} = $opt_ident;
308 if (defined $opt_quit)
310 $config{MAX_QUIT} = $opt_quit;
312 if (defined $opt_topic)
314 $config{MAX_TOPIC} = $opt_topic;
316 if (defined $opt_kick)
318 $config{MAX_KICK} = $opt_kick;
320 if (defined $opt_gecos)
322 $config{MAX_GECOS} = $opt_gecos;
324 if (defined $opt_away)
326 $config{MAX_AWAY} = $opt_away;
329 $config{HAS_OPENSSL} =~ /^([-[:digit:].]+)([a-z])?(\-[a-z][0-9])?$/;
330 $config{HAS_OPENSSL} = $1;
332 if ($config{GCCVER} eq "") {
333 print $config{CC} . " was not found! You require g++ (the GNU C++ compiler, part of GCC) to build InspIRCd!\n";
337 if (!$config{MAX_CLIENT_T}) {
338 $config{MAX_CLIENT_T} = 1024; # Set a reasonable 'Default'
339 $fd_scan_fail = "true"; # Used Later
342 # Get and Set some important vars..
347 system("rm -rf .config.cache");
353 chomp($topdir = getcwd());
354 $this = resolve_directory($topdir); # PWD, Regardless.
356 # Does the cache file exist?
358 # No, No it doesn't.. *BASH*
359 print "You have not run ./configure before. Please do this before trying to run the update script.\n";
362 # We've Loaded the cache file and all our variables..
363 print "Updating Files..\n";
365 if ($opt_disable_debug == 1)
367 print "Disabling debug information (-g).\n";
368 $config{OPTIMISATI} = "";
371 $has_epoll = $config{HAS_EPOLL};
372 $has_ports = $config{HAS_PORTS};
373 $has_kqueue = $config{HAS_KQUEUE};
382 print "Configure update failed: $@\n";
390 chomp($topdir = getcwd());
391 $this = resolve_directory($topdir); # PWD, Regardless.
393 # Does the cache file exist?
395 # No, No it doesn't.. *BASH*
396 print "You have not run ./configure before. Please do this before trying to run the update script.\n";
399 # We've Loaded the cache file and all our variables..
400 print "Updating Files..\n";
402 $has_epoll = $config{HAS_EPOLL};
403 $has_ports = $config{HAS_PORTS};
404 $has_kqueue = $config{HAS_KQUEUE};
413 print "Module update failed: $@\n";
423 open(FH,"<.svn/entries") or $fail = 1;
425 print "This is not an SVN copy of InspIRCd.\n";
432 system("svn update");
433 system("perl configure -update");
434 if (defined $opt_rebuild) {
435 system("make install");
440 print "Running non-interactive configure...\n" unless $interactive;
441 print "Checking for cache from previous configure... ";
442 print ((!getcache()) ? "not found\n" : "found\n");
443 print "Checking operating system version... ";
444 print getosflags() . "\n";
446 if (defined $opt_maxclients)
448 $config{MAX_CLIENT} = $opt_maxclients;
451 if (!$config{MAX_CLIENT}) {
452 # If the cache hasn't set the max clients, copy the variable of MAX_CLIENT_T, this
453 # allows us to keep _T for testing purposes. (ie. "Are you sure you want to go
454 # higher than the found value" :))
455 $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
458 printf "Checking if stdint.h exists... ";
459 $config{HAS_STDINT} = "true";
461 open(STDINT, "</usr/include/stdint.h") or $config{HAS_STDINT} = "false";
462 if ($config{HAS_STDINT} eq "true") {
465 print "yes\n" if $config{HAS_STDINT} eq "true";
466 print "no\n" if $config{HAS_STDINT} eq "false";
469 printf "Checking if strlcpy exists... ";
470 # Perform the strlcpy() test..
471 $config{HAS_STRLCPY} = "false";
473 open(STRLCPY, "</usr/include/string.h") or $fail = 1;
475 while (chomp($line = <STRLCPY>)) {
476 # try and find the delcaration of:
477 # size_t strlcpy(...)
478 if ($line =~ /size_t(\0x9|\s)+strlcpy/) {
479 $config{HAS_STRLCPY} = "true";
484 print "yes\n" if $config{HAS_STRLCPY} eq "true";
485 print "no\n" if $config{HAS_STRLCPY} eq "false";
488 printf "Checking if kqueue exists... ";
491 open(KQUEUE, "</usr/include/sys/event.h") or $fail = 1;
493 while (chomp($line = <KQUEUE>)) {
494 # try and find the delcaration of:
496 if ($line =~ /int(\0x9|\s)+kqueue/) {
502 print "yes\n" if $has_kqueue == 1;
503 print "no\n" if $has_kqueue == 0;
505 printf "Checking if epoll exists... ";
508 open(EPOLL, "</usr/include/sys/epoll.h") or $fail = 1;
514 my $kernel = `uname -r`;
516 if (($kernel =~ /^2\.0\./) || ($kernel =~ /^2\.2\./) || ($kernel =~ /^2\.4\./)) {
521 # Suggestion from nenolod, weed out odd systems which have glibc built
522 # against 2.4 kernels (ick)
523 my $kernel_arch = `uname -p`;
527 if ($kernel_arch =~ /x86_64/) {
528 open (FH,"/lib64/libc.so.6|") or $has_epoll = 0;
531 open (FH,"/lib/libc.so.6|") or $has_epoll = 0;
535 while (chomp($line = <FH>))
537 if ($line =~ /GNU C Library .* version (.*?) /)
540 $libcv =~ /(\d+\.\d+)/;
543 elsif ($line =~ /Compiled on a Linux (.*?\..*?)\.* system/)
546 # Fix for some retarded libc builds, strip off >> and << etc.
547 $kernelv =~ /(\d+\.\d+)/;
555 printf "libc too old: $libcv... ";
560 printf "libc built against older kernel $kernelv... ";
565 print "yes\n" if $has_epoll == 1;
566 print "no\n" if $has_epoll == 0;
568 printf "Checking if Solaris I/O completion ports are available... ";
570 my $system = `uname -s`;
572 $has_ports = 1 if ($system eq "SunOS");
575 my $kernel = `uname -r`;
577 if (($kernel !~ /^5\.1./)) {
581 print "yes\n" if $has_ports == 1;
582 print "no\n" if $has_ports == 0;
584 $config{HAS_EPOLL} = $has_epoll;
585 $config{HAS_KQUEUE} = $has_kqueue;
587 printf "Checking for libgnutls... ";
588 if (($config{HAS_GNUTLS}) && (($config{HAS_GNUTLS} >= 1.2) || ($config{HAS_GNUTLS} eq "y"))) {
590 $config{HAS_GNUTLS} = "y";
593 $config{HAS_GNUTLS} = "n";
596 printf "Checking for openssl... ";
597 if (($config{HAS_OPENSSL}) && (($config{HAS_OPENSSL} >= 0.8) || ($config{HAS_OPENSSL} eq "y"))) {
599 $config{HAS_OPENSSL} = "y";
602 $config{HAS_OPENSSL} = "n";
605 printf "Checking if you are running an ancient, unsupported OS... ";
606 if ($config{OSNAME} =~ /FreeBSD/i)
608 $version = `uname -r`;
609 if ($version =~ /^4\./)
611 $foundit = `ls -l /usr/local/lib/libgnugetopt* | wc -l`;
614 # ICKY ICKY ICK, FREEBSD 4.x! GET AN UPGRADE!
615 $config{CRAQ} = "-L/usr/local/lib -lgnugetopt -DHAVE_DECL_GETOPT=1";
620 print "\n\nERROR: You require libgnugetopt (from ports or packages) to build InspIRCd on FreeBSD 4.11.\n";
626 print "no ($version)\n";
632 print "no ($config{OSNAME})\n";
635 ################################################################################
636 # BEGIN INTERACTIVE PART #
637 ################################################################################
645 my $rev = getrevision();
646 # Display Introduction Message..
648 Welcome to the \033[1mInspIRCd\033[0m Configuration program! (\033[1minteractive mode\033[0m)
649 \033[1mPackage maintainers: Type ./configure --help for non-interactive help\033[0m
651 *** If you are unsure of any of these values, leave it blank for ***
652 *** standard settings that will work, and your server will run ***
653 *** using them. Please consult your IRC network admin if in doubt. ***
655 Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter
656 a new value. Please note: You will \033[1mHAVE\033[0m to read the docs
657 dir, otherwise you won't have a config file!
659 Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos)
660 Maximum file descriptors: \033[1;32m$config{MAX_CLIENT_T}\033[0m
661 Your InspIRCd revision ID is \033[1;32mr$rev\033[0m";
663 print " (Non-SVN build)";
667 $config{CHANGE_COMPILER} = "n";
668 print "I have detected the following compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.x\033[0m)\n";
670 while (($config{GCCVER} < 3) || ($config{GCCVER} eq "")) {
671 print "\033[1;32mIMPORTANT!\033[0m A GCC 2.x compiler has been detected, and
672 should NOT be used. You should probably specify a newer compiler.\n\n";
673 yesno(CHANGE_COMPILER,"Do you want to change the compiler?");
674 if ($config{CHANGE_COMPILER} =~ /y/i) {
675 print "What command do you want to use to invoke your compiler?\n";
676 print "[\033[1;32m$config{CC}\033[0m] -> ";
677 chomp($config{CC} = <STDIN>);
678 if ($config{CC} eq "") {
681 chomp($foo = `$config{CC} -dumpversion | cut -c 1`);
683 chomp($config{GCCVER} = `$config{CC} -dumpversion | cut -c 1`); # we must redo these if we change compilers
684 print "Queried compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.x\033[0m)\n";
685 if ($config{GCCVER} < 3) {
686 print "\033[1;32mGCC 2.x WILL NOT WORK!\033[0m. Let's try that again, shall we?\n";
690 print "\033[1;32mWARNING!\033[0m Could not execute the compiler you specified. You may want to try again.\n";
697 # Directory Settings..
698 my $tmpbase = $config{BASE_DIR};
699 dir_check("do you wish to install the InspIRCd base", "BASE_DIR");
700 if ($tmpbase ne $config{BASE_DIR}) {
701 $config{CONFIG_DIR} = resolve_directory($config{BASE_DIR}."/conf"); # Configuration Dir
702 $config{MODULE_DIR} = resolve_directory($config{BASE_DIR}."/modules"); # Modules Directory
703 $config{BINARY_DIR} = resolve_directory($config{BASE_DIR}."/bin"); # Binary Directory
704 $config{LIBRARY_DIR} = resolve_directory($config{BASE_DIR}."/lib"); # Library Directory
707 dir_check("are the configuration files", "CONFIG_DIR");
708 dir_check("are the modules to be compiled to", "MODULE_DIR");
709 dir_check("is the IRCd binary to be placed", "BINARY_DIR");
710 dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
713 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?");
717 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?");
721 yesno(USE_PORTS,"You are running Solaris 10.\nWould you like to enable I/O completion ports support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable support for I/O completion ports?");
724 $chose_hiperf = (($config{USE_EPOLL} eq "y") || ($config{USE_KQUEUE} eq "y") || ($config{USE_PORTS} eq "y"));
725 if (!$chose_hiperf) {
726 print "No high-performance socket engines are available, or you chose\n";
727 print "not to enable one. Defaulting to select() engine.\n\n";
730 yesno(IPV6,"Would you like to build InspIRCd with IPv6 support?");
733 if ($config{IPV6} eq "y") {
734 print "You have chosen to build an \033[1;32mIPV6-enabled\033[0m server.\nTo accept IPV4 users, you can still use IPV4 addresses\nin your port bindings..\n\n";
735 $config{SUPPORT_IP6LINKS} = "y";
737 yesno(SUPPORT_IP6LINKS,"You have chosen to build an \033[1;32mIPV4-only\033[0m server.\nWould you like to enable support for linking to IPV6-enabled\nInspIRCd servers?\nIf you are using a recent operating\nsystem and are unsure, answer yes.\nIf you answer 'no' here, your InspIRCd server will be unable\nto parse IPV6 addresses (e.g. for CIDR bans)");
741 if (($config{HAS_GNUTLS} eq "y") && ($config{HAS_OPENSSL} eq "y")) {
742 print "I have detected both \033[1;32mGnuTLS\033[0m and \033[1;32mOpenSSL\033[0m on your system.\n";
743 print "I will default to GnuTLS. If you wish to use OpenSSL\n";
744 print "instead, you should enable the OpenSSL module yourself\n";
745 print "by copying it from src/modules/extra to src/modules.\n\n";
746 print "Detected GnuTLS version: \033[1;32m" . $gnutls_ver . "\033[0m\n";
747 print "Detected OpenSSL version: \033[1;32m" . $openssl_ver . "\033[0m\n\n";
750 if ($config{HAS_GNUTLS} eq "y") {
751 yesno(USE_GNUTLS, "Would you like to enable SSL Support?");
752 if ($config{USE_GNUTLS} eq "y") {
753 print "\nUsing GnuTLS SSL module.\n";
755 } elsif ($config{HAS_OPENSSL} eq "y") {
756 yesno(USE_OPENSSL, "Would you like to enable SSL Support?");
757 if ($config{USE_OPENSSL} eq "y") {
758 print "\nUsing OpenSSL SSL module.\nYou will get better performance if you move to GnuTLS in the future.\n";
762 print "\nCould not detect OpenSSL or GnuTLS. Make sure pkg-config is installed if\nyou intend to use OpenSSL, or that GnuTLS is in your path if you intend\nto use GnuTLS.\n\n";
765 print "\nThe following questions will ask you for various figures relating\n";
766 print "To your IRCd install. Please note that these should usually be left\n";
767 print "as defaults unless you have a real reason to change them. If they\n";
768 print "changed, then the values must be identical on all servers on your\n";
769 print "network, or malfunctions and/or crashes may occur, with the exception\n";
770 print "of the 'maximum number of clients' setting which may be different on\n";
771 print "different servers on the network.\n\n";
773 # File Descriptor Settings..
774 promptnumeric("number of clients at any one time", "MAX_CLIENT_T");
775 $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
776 $config{MAX_DESCRIPTORS} = $config{MAX_CLIENT_T};
778 promptnumeric("length of nicknames", "NICK_LENGT");
779 promptnumeric("length of channel names", "CHAN_LENGT");
780 promptnumeric("number of mode changes in one line", "MAXI_MODES");
781 promptnumeric("length of an ident (username)", "MAX_IDENT");
782 promptnumeric("length of a quit message", "MAX_QUIT");
783 promptnumeric("length of a channel topic", "MAX_TOPIC");
784 promptnumeric("length of a kick message", "MAX_KICK");
785 promptnumeric("length of a GECOS (real name)", "MAX_GECOS");
786 promptnumeric("length of an away message", "MAX_AWAY");
791 if (($config{USE_GNUTLS} eq "y") && ($config{HAS_GNUTLS} ne "y"))
793 print "Sorry, but i couldn't detect gnutls. Make sure gnutls-config is in your path.\n";
796 if (($config{USE_OPENSSL} eq "y") && ($config{HAS_OPENSSL} ne "y"))
798 print "Sorry, but i couldn't detect openssl. Make sure openssl is in your path.\n";
802 if ($config{USE_GNUTLS} eq "y") {
804 open(TMP, "<src/modules/m_ssl_gnutls.cpp") or $failed = 1;
807 print "Symlinking src/modules/m_ssl_gnutls.cpp from extra/\n";
808 chdir("src/modules");
809 system("ln -s extra/m_ssl_gnutls.cpp");
816 open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
818 open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
821 print "SSL Certificates Not found, Generating.. \n\n
822 *************************************************************
823 * Generating the Private Key may take some time, go grab a *
824 * Coffee. Even better, to generate some more entropy if it *
825 * is taking a while, open another console and type du / a *
826 * few times and get that HD going :) Then answer the *
827 * Questions which follow. If you are unsure, just hit enter *
828 *************************************************************\n\n";
829 $failed = make_gnutls_cert();
831 print "\n\033[1;32mCertificate generation failed!\033[0m\n\n";
833 print "\nCertificate generation complete, copying to config directory... ";
834 system("mv key.pem $config{CONFIG_DIR}/key.pem");
835 system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
840 print "SSL Certificates found, skipping.\n\n";
845 print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
847 } elsif ($config{USE_OPENSSL} eq "y") {
849 open(TMP, "<src/modules/m_ssl_openssl.cpp") or $failed = 1;
852 print "Symlinking src/modules/m_ssl_openssl.cpp from extra/\n";
853 chdir("src/modules");
854 system("ln -s extra/m_ssl_openssl.cpp");
861 open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
863 open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
866 print "SSL Certificates Not found, Generating.. \n\n
867 *************************************************************
868 * Generating the certificates may take some time, go grab a *
869 * coffee, or something. *
870 *************************************************************\n\n";
872 print "\nCertificate generation complete, copying to config directory... ";
873 system("mv key.pem $config{CONFIG_DIR}/key.pem");
874 system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
875 system("mv dhparams.pem $config{CONFIG_DIR}/dhparams.pem");
878 print "SSL Certificates found, skipping.\n\n"
883 print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
886 if (($config{USE_GNUTLS} eq "n") && ($config{USE_OPENSSL} eq "n")) {
887 print "Skipping SSL Certificate generation, SSL support is not available.\n\n";
895 print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
896 if (($config{USE_GNUTLS} eq "y") || ($config{USE_OPENSSL} eq "y")) {
897 print "Please remember that to enable \033[1;32mSSL support\033[0m you must\n";
898 print "load the required modules in your config. This configure process\n";
899 print "has just prepared these modules to be compiled for you, and has not\n";
900 print "configured them to be compiled into the core of the ircd.\n";
902 print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
903 if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
904 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";
907 if ($config{GCCVER} < "3") {
909 \033[1;32mWARNING!\033[0m You are attempting to compile InspIRCd on GCC 2.x!
910 GCC 2.x series compilers only had partial (read as broken) C++ support, and
911 your compile will most likely fail horribly! If you have any problems, do NOT
912 report them to the bugtracker or forums without first upgrading your compiler
913 to a newer 3.x or 4.x (or whatever is available currently) version.
917 ################################################################################
919 ################################################################################
921 # Retrieves the .config.cache file, and loads values into the main config hash.
922 open(CACHE, ".config.cache") or return 0;
925 # Ignore Blank lines, and comments..
928 my ($key, $value) = split("=", $_, 2);
929 $value =~ /^\"(.*)\"$/;
930 # Do something with data here!
938 # Dump the contents of %config
939 print "Writing \033[1;32mcache file\033[0m for future ./configures ...\n";
940 open(FILEHANDLE, ">.config.cache");
941 foreach $key (keys %config) {
942 print FILEHANDLE "$key=\"$config{$key}\"\n";
948 my ($desc, $hash_key) = @_;
951 print "In what directory $desc?\n";
952 print "[\033[1;32m$config{$hash_key}\033[0m] -> ";
953 chomp($var = <STDIN>);
955 $var = $config{$hash_key};
957 if ($var =~ /^\~\/(.+)$/) {
958 # Convert it to a full path..
959 $var = resolve_directory($ENV{HOME} . "/" . $1);
961 elsif ((($config{OSNAME} =~ /MINGW32/i) and ($var !~ /^[A-Z]{1}:\\.*/)) and (substr($var,0,1) ne "/"))
963 # Assume relative Path was given.. fill in the rest.
964 $var = $this . "/$var";
967 $var = resolve_directory($var);
969 print "$var does not exist. Create it?\n[\033[1;32my\033[0m] ";
970 chomp($tmp = <STDIN>);
971 if (($tmp eq "") || ($tmp =~ /^y/i)) {
972 # Attempt to Create the Dir..
974 system("mkdir -p \"$var\" >> /dev/null 2>&1");
975 $chk = system("mkdir -p \"$var\" >> /dev/null 2>&1") / 256;
977 print "Unable to create directory. ($var)\n\n";
982 # They said they don't want to create, and we can't install there.
988 # Target exists, but is not a directory.
989 print "File $var exists, but is not a directory.\n\n";
993 # Either Dir Exists, or was created fine.
994 $config{$hash_key} = $var;
1002 $config{LDLIBS} = "-lstdc++";
1003 $config{FLAGS} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
1004 $config{DEVELOPER} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated -g";
1005 $SHARED = "-Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared";
1006 $config{MAKEPROG} = "make";
1008 if ($config{OSNAME} =~ /darwin/i) {
1009 $config{FLAGS} = "-DDARWIN -frtti -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
1010 $SHARED = "-bundle -twolevel_namespace -undefined dynamic_lookup";
1011 $config{LDLIBS} = "-ldl -lstdc++";
1014 if ($config{OSNAME} =~ /OpenBSD/i) {
1015 $config{MAKEPROG} = "gmake";
1016 $config{LDLIBS} = $config{LDLIBS} . " -lunwind";
1017 chomp($foo = `eg++ -dumpversion | cut -c 1`);
1018 # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
1019 # if theyre not running this, configure lets the build continue but they probably wont manage to
1020 # compile as this standard version is 2.95.3!
1022 $config{CC} = "eg++";
1023 chomp($config{GCCVER} = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change the compiler path
1028 if ($config{OSNAME} =~ /Linux/i) {
1029 $config{LDLIBS} = "-ldl -lstdc++";
1030 $config{FLAGS} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
1031 $config{FLAGS} .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
1032 $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
1033 $config{MAKEPROG} = "make";
1036 if ($config{OSNAME} =~ /FreeBSD/i) {
1037 $config{FLAGS} .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
1038 $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
1041 if ($config{OSNAME} =~ /SunOS/i or $config{OSNAME} =~ /solaris/i)
1043 # solaris/sunos needs these
1044 # socket = bsd sockets api
1046 # rt = POSIX realtime extensions
1047 # resolv = inet_aton only (why isnt this in nsl?!)
1048 $config{MAKEPROG} = "gmake";
1049 $config{LDLIBS} .= " -lsocket -lnsl -lrt -lresolv";
1053 if($config{OSNAME} =~ /MINGW32/i)
1055 # All code is position-independent on windows
1056 $config{FLAGS} =~ s/-fPIC //;
1060 return $config{OSNAME};
1064 my($writeheader) = @_;
1065 # First File.. inspircd_config.h
1066 chomp(my $incos = `uname -n -s -r`);
1067 chomp($version = `sh src/version.sh`);
1068 chomp(my $revision2 = getrevision());
1069 if ($writeheader == 1)
1071 print "Writing \033[1;32minspircd_config.h\033[0m\n";
1072 open(FILEHANDLE, ">include/inspircd_config.h");
1073 my $NL = $config{NICK_LENGT}+1;
1074 my $CL = $config{CHAN_LENGT}+1;
1075 print FILEHANDLE <<EOF;
1076 /* Auto generated by configure, do not modify! */
1077 #ifndef __CONFIGURATION_AUTO__
1078 #define __CONFIGURATION_AUTO__
1080 /* this is for windows support. */
1081 #define CoreExport /**/
1082 #define DllExport /**/
1084 #define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
1085 #define MOD_PATH "$config{MODULE_DIR}"
1086 #define VERSION "$version"
1087 #define REVISION "$revision2"
1088 #define MAXCLIENTS $config{MAX_CLIENT}
1089 #define MAXCLIENTS_S "$config{MAX_CLIENT}"
1090 #define SOMAXCONN_S "$config{_SOMAXCONN}"
1091 #define MAX_DESCRIPTORS $config{MAX_DESCRIPTORS}
1094 #define MAXMODES $config{MAXI_MODES}
1095 #define IDENTMAX $config{MAX_IDENT}
1096 #define MAXQUIT $config{MAX_QUIT}
1097 #define MAXTOPIC $config{MAX_TOPIC}
1098 #define MAXKICK $config{MAX_KICK}
1099 #define MAXGECOS $config{MAX_GECOS}
1100 #define MAXAWAY $config{MAX_AWAY}
1101 #define OPTIMISATION $config{OPTIMITEMP}
1102 #define LIBRARYDIR "$config{LIBRARY_DIR}"
1103 #define SYSTEM "$incos"
1105 print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
1107 if ($config{OSNAME} =~ /SunOS/i) {
1108 print FILEHANDLE "#define IS_SOLARIS\n";
1110 if ($config{OSNAME} =~ /MINGW32/i) {
1111 print FILEHANDLE "#define IS_MINGW\n";
1113 if ($config{GCCVER} >= 3) {
1114 print FILEHANDLE "#define GCC3\n";
1116 if ($config{HAS_STRLCPY} eq "true") {
1117 print FILEHANDLE "#define HAS_STRLCPY\n";
1119 if ($config{HAS_STDINT} eq "true") {
1120 print FILEHANDLE "#define HAS_STDINT\n";
1122 if ($config{IPV6} =~ /y/i) {
1123 print FILEHANDLE "#define IPV6\n";
1125 if ($config{SUPPORT_IP6LINKS} =~ /y/i) {
1126 print FILEHANDLE "#define SUPPORT_IP6LINKS\n";
1129 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1130 print FILEHANDLE "#define USE_KQUEUE\n";
1131 $se = "socketengine_kqueue";
1134 if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1135 print FILEHANDLE "#define USE_EPOLL\n";
1136 $se = "socketengine_epoll";
1139 if (($has_ports) && ($config{USE_PORTS} eq "y")) {
1140 print FILEHANDLE "#define USE_PORTS\n";
1141 $se = "socketengine_ports";
1144 # user didn't choose either epoll or select for their OS.
1145 # default them to USE_SELECT (ewwy puke puke)
1147 print FILEHANDLE "#define USE_SELECT\n";
1148 $se = "socketengine_select";
1150 print FILEHANDLE "\n#endif\n";
1156 open(FILEHANDLE, ">include/inspircd_se_config.h");
1157 print FILEHANDLE <<EOF;
1158 /* Auto generated by configure, do not modify or commit to svn! */
1159 #ifndef __CONFIGURATION_SOCKETENGINE__
1160 #define __CONFIGURATION_SOCKETENGINE__
1170 # Create a Modules List..
1172 foreach $i (@modlist)
1174 $modules .= "m_".$i.".so ";
1176 chomp($modules); # Remove Redundant whitespace..
1178 opendir(DIRHANDLE, "src/modules");
1179 foreach $name (sort readdir(DIRHANDLE)) {
1180 if ($name =~ /^m_(.+?)$/) {
1181 if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
1182 closedir(MDIRHANDLE);
1183 $modules .= "$name.so ";
1187 closedir(DIRHANDLE);
1190 # Write all .in files.
1193 my $exe = "inspircd";
1195 opendir(DIRHANDLE, $this);
1197 # Do this once here, and cache it in the .*.inc files,
1198 # rather than attempting to read src/version.sh from
1199 # compiled code -- we might not have the source to hand.
1200 # Fix for bug#177 by Brain.
1202 chomp(my $version = `sh ./src/version.sh`);
1203 chomp(my $revision = getrevision());
1204 $version = "$version(r$revision)";
1207 if ($config{IS_DARWIN} eq "YES")
1211 # We can actually parse any file starting with . and ending with .inc,
1212 # but right now we only parse .inspircd.inc to form './inspircd'
1214 foreach $name (sort readdir(DIRHANDLE)) {
1215 if ($name =~ /^\.(.+)\.inc$/) {
1218 # Bug #353, omit this on non-darwin
1219 next if (($config{OSNAME} !~ /darwin/) && ($file eq "org.inspircd.plist"));
1221 # All .name.inc files need parsing!
1223 open(FILEHANDLE, ".$file.inc");
1224 while (<FILEHANDLE>) {
1229 $tmp =~ s/\@CC\@/$config{CC}/;
1230 $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
1231 $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
1232 $tmp =~ s/\@DEVELOPER\@/$config{DEVELOPER}/;
1233 $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
1234 $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/;
1235 $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
1236 $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
1237 $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
1238 $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
1239 $tmp =~ s/\@LIBRARY_EXT\@/$LIBEXT/;
1240 $tmp =~ s/\@MODULES\@/$modules/;
1241 $tmp =~ s/\@STARTSCRIPT\@/$config{STARTSCRIPT}/;
1242 $tmp =~ s/\@DESTINATION\@/$config{DESTINATION}/;
1243 $tmp =~ s/\@EXTRA_DIR\@/$config{EXTRA_DIR}/;
1244 $tmp =~ s/\@EXECUTABLE\@/$exe/;
1245 $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
1246 $tmp =~ s/\@VERSION\@/$version/;
1248 print "Writing \033[1;32m$file\033[0m\n";
1249 open(FILEHANDLE, ">$file");
1250 print FILEHANDLE $tmp;
1253 closedir(DIRHANDLE);
1255 # Make inspircd executable!
1256 chmod 0744, 'inspircd';
1258 print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
1259 write_dynamic_makefile();
1260 write_dynamic_modules_makefile();
1263 sub write_dynamic_modules_makefile {
1264 # Modules Makefile..
1265 print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
1266 open(FILEHANDLE, ">src/modules/Makefile");
1269 # Module Makefile Header
1271 print FILEHANDLE <<EOF;
1272 ###################################################
1273 # Copyright 2002-2007 The InspIRCd Development Team
1274 # http://www.inspircd.org/wiki/index.php/Credits
1276 # Thanks to Andrew Church <achurch\@achurch.org>
1277 # for assisting with making this work right.
1279 # Automatically Generated by ./configure to add a
1280 # modules please run ./configure -modupdate
1281 ###################################################
1287 if ($config{OSNAME} =~ /darwin/) {
1288 print FILEHANDLE <<EOCHEESE;
1290 PICLDFLAGS = -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) -bundle
1294 print FILEHANDLE <<EOCHEESE;
1296 PICLDFLAGS = -fPIC -DPIC -shared \$(FLAGS)
1302 # End Module Makefile Header
1305 # Create a Modules List..
1311 foreach $i (@modlist) {
1313 # Write Entry to the MakeFile
1315 $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
1316 $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
1317 $deps = getdependencies("src/modules/m_".$i.".cpp");
1319 #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
1321 print FILEHANDLE <<EOCHEESE;
1322 m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps
1323 \$(CC) -pipe -I../../include \$(FLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp
1325 $crud = $crud . " install -m \$(INSTMODE) m_$i.so \$(MODPATH)\n";
1327 # End Write Entry to the MakeFile
1331 opendir(DIRHANDLE, "src/modules");
1332 foreach $name (sort readdir(DIRHANDLE)) {
1333 if ($name =~ /^m_(.+?)$/) {
1338 # A module made of multiple files, in a dir, e.g. src/modules/m_spanningtree/
1339 if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
1340 read_module_directory("src/modules/$name", $name);
1341 print "Composing Makefile rules for directory \033[1;32m$name\033[0m... (\033[1;32m$mfcount files found\033[0m)\n";
1342 print FILEHANDLE "$name.so: ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $mobjs\n";
1343 if ($config{IS_DARWIN} eq "YES") {
1344 print FILEHANDLE " \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) $mliflags -bundle -o $name.so $mobjs\n";
1346 print FILEHANDLE " \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $mobjs\n";
1348 print FILEHANDLE "\n$mfrules\n";
1349 closedir(MDIRHANDLE);
1350 $crud = $crud . " install -m \$(INSTMODE) $name.so \$(MODPATH)\n";
1354 closedir(DIRHANDLE);
1356 print FILEHANDLE "modinst:\n \@echo \"Installing modules...\"\n" . $crud;
1359 sub read_module_directory {
1360 my ($dpath, $reldpath) = @_;
1362 if (opendir(MDIRHANDLE, $dpath) == 0) {
1366 foreach $fname (sort readdir(MDIRHANDLE)) {
1367 if ($fname =~ /\.cpp$/) {
1368 $cmflags = getcompilerflags("$dpath/$fname");
1369 $mliflags = $mliflags . " " . getlinkerflags("$dpath/$fname");
1370 $deps = getdependencies("$dpath/$fname");
1372 $oname =~ s/\.cpp$/.o/g;
1373 $mfrules = $mfrules . "$reldpath/$oname: $reldpath/$fname ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps\n";
1374 $mfrules = $mfrules . " \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $reldpath/$oname -c $reldpath/$fname\n\n";
1375 $mobjs = $mobjs . " $reldpath/$oname";
1378 elsif ((-d "$dpath/$fname") && !($fname eq ".") && !($fname eq "..")) {
1379 read_module_directory($dpath."/".$fname, $reldpath."/".$fname);
1386 # Yes i know we could use gcc -M but it seems to ideneify a lot of 'deep'
1387 # dependencies which are not relevent in C++.
1391 open (CPP, "<$file") or die("Can't open $file for reading!");
1396 foreach my $d (@ignoredeps)
1402 foreach my $dep (@immutabledeps)
1404 $immutable = $immutable . "../include/$dep ";
1406 $immutable =~ s/ $//g;
1408 while (chomp($line = <CPP>))
1410 if ($line =~ /#include "(.+\.h)"/)
1412 if (!exists($dupe{$1}))
1414 $retlist = $retlist . "../include/$1 ";
1420 return length($immutable) ? $immutable . " " . $retlist : $retlist;
1423 sub write_dynamic_makefile
1427 opendir(DIRHANDLE, "src/commands");
1428 foreach $name (sort readdir(DIRHANDLE))
1430 if ($name =~ /^cmd_(.+)\.cpp$/)
1432 $cmdlist[$i++] = $1;
1435 closedir(DIRHANDLE);
1437 print "Scanning src folder for core files";
1438 opendir(DIRHANDLE, "src");
1439 foreach $name (sort readdir(DIRHANDLE))
1441 if ($name =~ /\.cpp$/)
1443 open (CPP, "<src/$name") or die("Can't open src/$name to scan it! oh bugger");
1444 while (chomp($line = <CPP>))
1446 if ($line =~ /\/\* \$Core: (\w+) \*\//)
1448 $filelist{$name} = $1;
1451 elsif ($line =~ /\/\* \$ExtraDeps: (.*?) \*\//)
1453 $specialdeps{$name} = $1;
1455 elsif ($line =~ /\/\* \$ExtraObjects: (.*?) \*\//)
1457 $extraobjects{$name} = $1;
1459 elsif ($line =~ /\/\* \$ExtraBuild: (.*?) \*\//)
1461 $extrabuildlines{$name} = $1;
1463 elsif ($line =~ /\/\* \$ExtraSources: (.*?) \*\//)
1465 $extrasources{$name} = $1;
1471 closedir(DIRHANDLE);
1474 $se = "socketengine_select";
1475 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1476 $se = "socketengine_kqueue";
1478 elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1479 $se = "socketengine_epoll";
1481 elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
1482 $se = "socketengine_ports";
1485 $extrasources{"socketengine.cpp"} = $se . ".cpp";
1486 $extraobjects{"socketengine.cpp"} = $se . ".o";
1488 $freebsd4libs = $config{CRAQ};
1493 if ($config{IS_DARWIN} eq "YES")
1495 $libraryext = "dylib";
1496 $othercrap = " \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd.cpp\n \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o "
1501 $othercrap = " \$(CC) -pipe -I../include -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) ";
1504 foreach my $cpp (sort keys %filelist)
1506 $all = $all . $filelist{$cpp} . "." . $libraryext . " ";
1507 $all_libsonly = $all_libsonly . $filelist{$cpp} . "." . $libraryext . " ";
1509 $all = $all . "moo inspircd\n";
1511 $othercrap = $othercrap . " $all_libsonly\n\n";
1513 open(FH,">src/Makefile") or die("Could not write src/Makefile");
1516 CC = im a cheezeball
1517 CXXFLAGS = -I../include \${FLAGS}
1518 CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
1519 RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
1523 print FH "$all\n\n";
1525 $deps = calcdeps("src/inspircd.cpp");
1526 print FH "inspircd: inspircd.cpp $deps $all_libsonly\n";
1527 print FH "$othercrap\n";
1529 foreach my $cpp (sort keys %filelist)
1531 my $thislib = $filelist{$cpp} . "." . $libraryext;
1534 $objs =~ s/\.cpp$/.o/;
1535 if (exists($extraobjects{$cpp}))
1537 $objs = $objs . " " . $extraobjects{$cpp};
1539 if (exists($extrasources{$cpp}))
1541 $rawcpp = $rawcpp . " " . $extrasources{$cpp};
1543 if ($config{IS_DARWIN} eq "YES")
1545 $libcrap = "-install_name " . $config{LIBRARY_DIR} . "/" . $thislib . " -dynamiclib -twolevel_namespace -undefined dynamic_lookup";
1549 $libcrap = "-Wl,--rpath -Wl," . $config{LIBRARY_DIR} . " -shared";
1551 $deps = calcdeps("src/$cpp");
1552 if (exists($extrasources{$cpp}))
1554 foreach my $seperate (sort split(' ',$extrasources{$cpp}))
1556 $d = calcdeps("src/$extrasources{$cpp}") . " ";
1559 $deps = $deps . $d . " ";
1563 print FH $thislib . ": $cpp $deps ". $specialdeps{$cpp} . "\n";
1564 print FH " \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c $rawcpp\n";
1565 if (exists($extrabuildlines{$cpp}))
1567 print FH " " . $extrabuildlines{$cpp} . "\n";
1569 print FH " \$(CC) -pipe $libcrap -o " . $thislib . " " . $objs . "\n\n";
1572 print FH "moo:\n \${MAKE} -C \"commands\" DIRNAME=\"src/commands\" CC=\"\$(CC)\" \$(MAKEARGS)\n\n";
1574 # close main makefile
1577 # generate a list of .so
1578 foreach my $cmd (@cmdlist) {
1579 $cmdobjs = $cmdobjs . "cmd_$cmd.so ";
1582 # and now reopen the commands makefile
1583 open(FH,">src/commands/Makefile") or die("Could not write src/commands/Makefile");
1586 CXXFLAGS = -I../../include ${FLAGS}
1593 # now print the command file details.
1594 foreach my $cmd (@cmdlist) {
1596 cmd_$cmd.so: cmd_$cmd.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/globals.h ../../include/inspircd_config.h ../../include/commands/cmd_$cmd.h
1597 \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1598 \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o
1602 #try build a .so, no intermediate .o
1603 # \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic $SHARED -o cmd_$cmd.so
1605 #this works for sure
1606 # \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1607 # \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o