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 # This is a list of all files in the core. Each cpp file is mapped to a shared object file,
33 # whos file extension is omitted (these can vary from system to system).
36 "channels.cpp" => "libIRCDchannels",
37 "mode.cpp" => "libIRCDmode",
38 "xline.cpp" => "libIRCDxline",
39 "inspstring.cpp" => "libIRCDstring",
40 "dns.cpp" => "libIRCDasyncdns",
41 "base.cpp" => "libIRCDbase",
42 "configreader.cpp" => "libIRCDconfigreader",
43 "inspsocket.cpp" => "libIRCDinspsocket",
44 "commands.cpp" => "libIRCDcommands",
45 "dynamic.cpp" => "libIRCDdynamic",
46 "users.cpp" => "libIRCDusers",
47 "modules.cpp" => "libIRCDmodules",
48 "wildcard.cpp" => "libIRCDwildcard",
49 "helperfuncs.cpp" => "libIRCDhelper",
50 "hashcomp.cpp" => "libIRCDhash",
51 "socket.cpp" => "libIRCDsocket",
52 "socketengine.cpp" => "libIRCDsocketengine",
53 "userprocess.cpp" => "libIRCDuserprocess",
54 "cull_list.cpp" => "libIRCDcull_list",
55 "command_parse.cpp" => "libIRCDcommand_parse",
56 "timer.cpp" => "libIRCDtimer",
57 "snomasks.cpp" => "libIRCDsnomasks",
58 "server.cpp" => "libIRCDserver",
59 "filelogger.cpp" => "libIRCDfilelogger",
60 "user_resolver.cpp" => "libIRCDuserresolver",
63 # If you wish for a file to have special dependencies in the makefile, add an entry here.
66 "mode.cpp" => "\$(RELCPPFILES)",
69 # If you wish for a file to have extra make lines (in between the compile and link steps)
70 # then insert them here.
72 my %extrabuildlines = (
73 "mode.cpp" => "\${MAKE} -C \"modes\" DIRNAME=\"src/modes\" CC=\"\$(CC)\" \$(MAKEARGS) CPPFILES=\"\$(CPPFILES)\"",
76 # If you wish for a file to be linked against extra objects or arctives, insert them here.
79 "mode.cpp" => "modes/modeclasses.a"
82 # If you wish to compile extra cpp sources into an object, define them here.
83 # NOTE: Certain cpp files such as the socket engines have a value auto calculated
84 # for this table so that their derived class is built.
89 # If you wish to ignore a dependency throughout the entire core, add it here.
92 "inspircd_win32wrapper.h", # windows has its own configure program
95 # If you wish for all files in the entire core to have a given dependency, insert it here.
96 # You should keep this to an absolute minimum to avoid rebuilds that are not neccessary.
99 "inspircd_config.h", # auto re-generated by configure
104 ###############################################################################################
106 # NON-EDITABLE VARIABLES
108 ###############################################################################################
112 'enable-gnutls' => \$opt_use_gnutls,
113 'rebuild' => \$opt_rebuild,
114 'enable-openssl' => \$opt_use_openssl,
115 'disable-interactive' => \$opt_nointeractive,
116 'with-nick-length=i' => \$opt_nick_length,
117 'with-channel-length=i' => \$opt_chan_length,
118 'with-max-clients=i' => \$opt_maxclients,
119 'enable-ports' => \$opt_ports,
120 'enable-epoll' => \$opt_epoll,
121 'enable-kqueue' => \$opt_kqueue,
122 'disable-ports' => \$opt_noports,
123 'disable-epoll' => \$opt_noepoll,
124 'disable-kqueue' => \$opt_nokqueue,
125 'enable-ipv6' => \$opt_ipv6,
126 'enable-remote-ipv6' => \$opt_ipv6links,
127 'disable-remote-ipv6' => \$opt_noipv6links,
128 'with-cc=s' => \$opt_cc,
129 'with-ident-length=i' => \$opt_ident,
130 'with-quit-length=i' => \$opt_quit,
131 'with-topic-length=i' => \$opt_topic,
132 'with-maxbuf=i' => \$opt_maxbuf,
133 'with-kick-length=i' => \$opt_kick,
134 'with-gecos-length=i' => \$opt_gecos,
135 'with-away-length=i' => \$opt_away,
136 'with-max-modes=i' => \$opt_modes,
137 'prefix=s' => \$opt_base_dir,
138 'config-dir=s' => \$opt_config_dir,
139 'module-dir=s' => \$opt_module_dir,
140 'binary-dir=s' => \$opt_binary_dir,
141 'library-dir=s' => \$opt_library_dir,
142 'disable-debuginfo' => sub { $opt_disable_debug = 1 },
143 'help' => sub { showhelp(); },
144 'modupdate' => sub { modupdate(); },
145 'update' => sub { update(); },
146 'svnupdate' => sub { svnupdate(); },
147 'clean' => sub { clean(); },
150 my $non_interactive = (
151 (defined $opt_library_dir) ||
152 (defined $opt_base_dir) ||
153 (defined $opt_config_dir) ||
154 (defined $opt_module_dir) ||
155 (defined $opt_base_dir) ||
156 (defined $opt_binary_dir) ||
157 (defined $opt_nointeractive) ||
158 (defined $opt_away) ||
159 (defined $opt_gecos) ||
160 (defined $opt_kick) ||
161 (defined $opt_maxclients) ||
162 (defined $opt_modes) ||
163 (defined $opt_topic) ||
164 (defined $opt_quit) ||
165 (defined $opt_ident) ||
167 (defined $opt_ipv6) ||
168 (defined $opt_ipv6links) ||
169 (defined $opt_noipv6links) ||
170 (defined $opt_kqueue) ||
171 (defined $opt_epoll) ||
172 (defined $opt_ports) ||
173 (defined $opt_maxchans) ||
174 (defined $opt_opermaxchans) ||
175 (defined $opt_chan_length) ||
176 (defined $opt_nick_length) ||
177 (defined $opt_use_openssl) ||
178 (defined $opt_nokqueue) ||
179 (defined $opt_noepoll) ||
180 (defined $opt_noports) ||
181 (defined $opt_maxbuf) ||
182 (defined $opt_use_gnutls)
184 my $interactive = !$non_interactive;
187 chomp($topdir = getcwd());
188 $this = resolve_directory($topdir); # PWD, Regardless.
189 @modlist = (); # Declare for Module List..
190 %config = (); # Initiate Configuration Hash..
191 $config{ME} = resolve_directory($topdir); # Present Working Directory
193 $config{BASE_DIR} = $config{ME};
195 if (defined $opt_base_dir)
197 $config{BASE_DIR} = $opt_base_dir;
200 $config{CONFIG_DIR} = resolve_directory($config{BASE_DIR}."/conf"); # Configuration Directory
201 $config{MODULE_DIR} = resolve_directory($config{BASE_DIR}."/modules"); # Modules Directory
202 $config{BINARY_DIR} = resolve_directory($config{BASE_DIR}."/bin"); # Binary Directory
203 $config{LIBRARY_DIR} = resolve_directory($config{BASE_DIR}."/lib"); # Library Directory
205 if (defined $opt_config_dir)
207 $config{CONFIG_DIR} = $opt_config_dir;
209 if (defined $opt_module_dir)
211 $config{MODULE_DIR} = $opt_module_dir;
213 if (defined $opt_binary_dir)
215 $config{BINARY_DIR} = $opt_binary_dir;
217 if (defined $opt_library_dir)
219 $config{LIBRARY_DIR} = $opt_library_dir;
221 chomp($config{HAS_GNUTLS} = `libgnutls-config --version 2>/dev/null | cut -c 1,2,3`); # GNUTLS Version.
222 chomp($config{HAS_OPENSSL} = `pkg-config --modversion openssl 2>/dev/null`); # Openssl version
223 chomp($gnutls_ver = $config{HAS_GNUTLS});
224 chomp($openssl_ver = $config{HAS_OPENSSL});
225 $config{USE_GNUTLS} = "n";
226 if (defined $opt_use_gnutls)
228 $config{USE_GNUTLS} = "y"; # Use gnutls.
230 $config{USE_OPENSSL} = "n"; # Use openssl.
231 if (defined $opt_use_openssl)
233 $config{USE_OPENSSL} = "y";
236 # no, let's not change these.
237 $config{OPTIMITEMP} = "0"; # Default Optimisation Value
238 if (!defined $opt_disable_debug)
240 $config{OPTIMISATI} = "-g1"; # Optimisation Flag
244 $config{OPTIMISATI} = "-O2"; # DEBUGGING OFF!
247 $config{NICK_LENGT} = "31"; # Default Nick Length
248 if (defined $opt_nick_length)
250 $config{NICK_LENGT} = $opt_nick_length;
252 $config{CHAN_LENGT} = "64"; # Default Channel Name Length
253 if (defined $opt_chan_length)
255 $config{CHAN_LENGT} = $opt_chan_length;
257 $config{MAXI_MODES} = "20"; # Default Max. Number of Modes set at once.
258 if (defined $opt_modes)
260 $config{MAXI_MODES} = $opt_modes;
262 $config{HAS_STRLCPY} = "false"; # strlcpy Check.
263 $config{HAS_STDINT} = "false"; # stdint.h check
264 $config{USE_KQUEUE} = "y"; # kqueue enabled
265 if (defined $opt_kqueue)
267 $config{USE_KQUEUE} = "y";
269 if (defined $opt_nokqueue)
271 $config{USE_KQUEUE} = "n";
273 $config{USE_EPOLL} = "y"; # epoll enabled
274 if (defined $opt_epoll)
276 $config{USE_EPOLL} = "y";
278 if (defined $opt_noepoll)
280 $config{USE_EPOLL} = "n";
282 $config{USE_PORTS} = "y"; # epoll enabled
283 if (defined $opt_ports)
285 $config{USE_PORTS} = "y";
287 if (defined $opt_noports)
289 $config{USE_PORTS} = "n";
291 $config{IPV6} = "n"; # IPv6 support (experimental)
292 if (defined $opt_ipv6)
296 $config{SUPPORT_IP6LINKS} = "y"; # IPv4 supporting IPv6 links (experimental)
297 if (defined $opt_ipv6links)
299 $config{SUPPORT_IP6LINKS} = "y";
301 if (defined $opt_noipv6links)
303 $config{SUPPORT_IP6LINKS} = "n";
305 chomp($config{MAX_CLIENT_T} = `sh -c \"ulimit -n\"`); # FD Limit
306 chomp($config{MAX_DESCRIPTORS} = `sh -c \"ulimit -n\"`); # Hard FD Limit
307 chomp($config{GCCVER} = `g++ -dumpversion | cut -c 1`); # Major GCC Version
308 $config{_SOMAXCONN} = SOMAXCONN; # Max connections in accept queue
309 $config{OSNAME} = $^O; # Operating System Name
310 $config{IS_DARWIN} = "NO"; # Is OSX?
311 $config{STARTSCRIPT} = "inspircd"; # start script?
312 $config{DESTINATION} = "BASE"; # Is target path.
313 $config{EXTRA_DIR} = ""; # Is empty.
314 if ($config{OSNAME} =~ /darwin/i)
316 $config{IS_DARWIN} = "YES";
317 $config{STARTSCRIPT} = "org.inspircd.plist"; # start script for OSX.
318 $config{DESTINATION} = "LAUNCHDPATH"; # Is OSX target.
319 $config{EXTRA_DIR} = " launchd_dir"; # Is OSX specific path.
321 $config{CC} = "g++"; # C++ compiler
324 $config{CC} = $opt_cc;
326 $exec = $config{CC} . " -dumpversion | cut -c 1";
327 chomp($config{GCCVER} = `$exec`); # Major GCC Version
328 $config{MAKEORDER} = "ircd mods"; # build order
329 $config{MAX_IDENT} = "12"; # max ident size
330 $config{MAX_QUIT} = "255"; # max quit message size
331 $config{MAX_TOPIC} = "307"; # max topic size
332 $config{MAX_KICK} = "255"; # max kick message size
333 $config{MAX_GECOS} = "128"; # max GECOS size
334 $config{MAX_AWAY} = "200"; # max AWAY size
335 $config{MAXBUF} = "512"; # Max buffer size
336 if (defined $opt_ident)
338 $config{MAX_IDENT} = $opt_ident;
340 if (defined $opt_quit)
342 $config{MAX_QUIT} = $opt_quit;
344 if (defined $opt_topic)
346 $config{MAX_TOPIC} = $opt_topic;
348 if (defined $opt_kick)
350 $config{MAX_KICK} = $opt_kick;
352 if (defined $opt_gecos)
354 $config{MAX_GECOS} = $opt_gecos;
356 if (defined $opt_away)
358 $config{MAX_AWAY} = $opt_away;
361 $config{HAS_OPENSSL} =~ /^([-[:digit:].]+)([a-z])?(\-[a-z][0-9])?$/;
362 $config{HAS_OPENSSL} = $1;
364 if ($config{GCCVER} eq "") {
365 print $config{CC} . " was not found! You require g++ (the GNU C++ compiler, part of GCC) to build InspIRCd!\n";
369 if (!$config{MAX_CLIENT_T}) {
370 $config{MAX_CLIENT_T} = 1024; # Set a reasonable 'Default'
371 $fd_scan_fail = "true"; # Used Later
374 # Get and Set some important vars..
379 system("rm -rf .config.cache");
385 chomp($topdir = getcwd());
386 $this = resolve_directory($topdir); # PWD, Regardless.
388 # Does the cache file exist?
390 # No, No it doesn't.. *BASH*
391 print "You have not run ./configure before. Please do this before trying to run the update script.\n";
394 # We've Loaded the cache file and all our variables..
395 print "Updating Files..\n";
397 if ($opt_disable_debug == 1)
399 print "Disabling debug information (-g).\n";
400 $config{OPTIMISATI} = "";
403 $has_epoll = $config{HAS_EPOLL};
404 $has_ports = $config{HAS_PORTS};
405 $has_kqueue = $config{HAS_KQUEUE};
414 print "Configure update failed: $@\n";
422 chomp($topdir = getcwd());
423 $this = resolve_directory($topdir); # PWD, Regardless.
425 # Does the cache file exist?
427 # No, No it doesn't.. *BASH*
428 print "You have not run ./configure before. Please do this before trying to run the update script.\n";
431 # We've Loaded the cache file and all our variables..
432 print "Updating Files..\n";
434 $has_epoll = $config{HAS_EPOLL};
435 $has_ports = $config{HAS_PORTS};
436 $has_kqueue = $config{HAS_KQUEUE};
445 print "Module update failed: $@\n";
455 open(FH,"<.svn/entries") or $fail = 1;
457 print "This is not an SVN copy of InspIRCd.\n";
464 system("svn update");
465 system("perl configure -update");
466 if (defined $opt_rebuild) {
467 system("make install");
472 print "Running non-interactive configure...\n" unless $interactive;
473 print "Checking for cache from previous configure... ";
474 print ((!getcache()) ? "not found\n" : "found\n");
475 print "Checking operating system version... ";
476 print getosflags() . "\n";
478 if (defined $opt_maxclients)
480 $config{MAX_CLIENT} = $opt_maxclients;
483 if (!$config{MAX_CLIENT}) {
484 # If the cache hasn't set the max clients, copy the variable of MAX_CLIENT_T, this
485 # allows us to keep _T for testing purposes. (ie. "Are you sure you want to go
486 # higher than the found value" :))
487 $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
490 printf "Checking if stdint.h exists... ";
491 $config{HAS_STDINT} = "true";
493 open(STDINT, "</usr/include/stdint.h") or $config{HAS_STDINT} = "false";
494 if ($config{HAS_STDINT} eq "true") {
497 print "yes\n" if $config{HAS_STDINT} eq "true";
498 print "no\n" if $config{HAS_STDINT} eq "false";
501 printf "Checking if strlcpy exists... ";
502 # Perform the strlcpy() test..
503 $config{HAS_STRLCPY} = "false";
505 open(STRLCPY, "</usr/include/string.h") or $fail = 1;
507 while (chomp($line = <STRLCPY>)) {
508 # try and find the delcaration of:
509 # size_t strlcpy(...)
510 if ($line =~ /size_t(\0x9|\s)+strlcpy/) {
511 $config{HAS_STRLCPY} = "true";
516 print "yes\n" if $config{HAS_STRLCPY} eq "true";
517 print "no\n" if $config{HAS_STRLCPY} eq "false";
520 printf "Checking if kqueue exists... ";
523 open(KQUEUE, "</usr/include/sys/event.h") or $fail = 1;
525 while (chomp($line = <KQUEUE>)) {
526 # try and find the delcaration of:
528 if ($line =~ /int(\0x9|\s)+kqueue/) {
534 print "yes\n" if $has_kqueue == 1;
535 print "no\n" if $has_kqueue == 0;
537 printf "Checking if epoll exists... ";
540 open(EPOLL, "</usr/include/sys/epoll.h") or $fail = 1;
546 my $kernel = `uname -r`;
548 if (($kernel =~ /^2\.0\./) || ($kernel =~ /^2\.2\./) || ($kernel =~ /^2\.4\./)) {
553 # Suggestion from nenolod, weed out odd systems which have glibc built
554 # against 2.4 kernels (ick)
555 my $kernel_arch = `uname -p`;
559 if ($kernel_arch =~ /x86_64/) {
560 open (FH,"/lib64/libc.so.6|") or $has_epoll = 0;
563 open (FH,"/lib/libc.so.6|") or $has_epoll = 0;
567 while (chomp($line = <FH>))
569 if ($line =~ /GNU C Library .* version (.*?) /)
572 $libcv =~ /(\d+\.\d+)/;
575 elsif ($line =~ /Compiled on a Linux (.*?\..*?)\.* system/)
578 # Fix for some retarded libc builds, strip off >> and << etc.
579 $kernelv =~ /(\d+\.\d+)/;
587 printf "libc too old: $libcv... ";
592 printf "libc built against older kernel $kernelv... ";
597 print "yes\n" if $has_epoll == 1;
598 print "no\n" if $has_epoll == 0;
600 printf "Checking if Solaris I/O completion ports are available... ";
602 my $system = `uname -s`;
604 $has_ports = 1 if ($system eq "SunOS");
607 my $kernel = `uname -r`;
609 if (($kernel !~ /^5\.1./)) {
613 print "yes\n" if $has_ports == 1;
614 print "no\n" if $has_ports == 0;
616 $config{HAS_EPOLL} = $has_epoll;
617 $config{HAS_KQUEUE} = $has_kqueue;
619 printf "Checking for libgnutls... ";
620 if (($config{HAS_GNUTLS}) && (($config{HAS_GNUTLS} >= 1.2) || ($config{HAS_GNUTLS} eq "y"))) {
622 $config{HAS_GNUTLS} = "y";
625 $config{HAS_GNUTLS} = "n";
628 printf "Checking for openssl... ";
629 if (($config{HAS_OPENSSL}) && (($config{HAS_OPENSSL} >= 0.8) || ($config{HAS_OPENSSL} eq "y"))) {
631 $config{HAS_OPENSSL} = "y";
634 $config{HAS_OPENSSL} = "n";
637 printf "Checking if you are running an ancient, unsupported OS... ";
638 if ($config{OSNAME} =~ /FreeBSD/i)
640 $version = `uname -r`;
641 if ($version =~ /^4\./)
643 $foundit = `ls -l /usr/local/lib/libgnugetopt* | wc -l`;
646 # ICKY ICKY ICK, FREEBSD 4.x! GET AN UPGRADE!
647 $config{CRAQ} = "-L/usr/local/lib -lgnugetopt -DHAVE_DECL_GETOPT=1";
652 print "\n\nERROR: You require libgnugetopt (from ports or packages) to build InspIRCd on FreeBSD 4.11.\n";
658 print "no ($version)\n";
664 print "no ($config{OSNAME})\n";
667 ################################################################################
668 # BEGIN INTERACTIVE PART #
669 ################################################################################
677 my $rev = getrevision();
678 # Display Introduction Message..
680 Welcome to the \033[1mInspIRCd\033[0m Configuration program! (\033[1minteractive mode\033[0m)
681 \033[1mPackage maintainers: Type ./configure --help for non-interactive help\033[0m
683 *** If you are unsure of any of these values, leave it blank for ***
684 *** standard settings that will work, and your server will run ***
685 *** using them. Please consult your IRC network admin if in doubt. ***
687 Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter
688 a new value. Please note: You will \033[1mHAVE\033[0m to read the docs
689 dir, otherwise you won't have a config file!
691 Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos)
692 Maximum file descriptors: \033[1;32m$config{MAX_CLIENT_T}\033[0m
693 Your InspIRCd revision ID is \033[1;32mr$rev\033[0m";
695 print " (Non-SVN build)";
699 $config{CHANGE_COMPILER} = "n";
700 print "I have detected the following compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.x\033[0m)\n";
702 while (($config{GCCVER} < 3) || ($config{GCCVER} eq "")) {
703 print "\033[1;32mIMPORTANT!\033[0m A GCC 2.x compiler has been detected, and
704 should NOT be used. You should probably specify a newer compiler.\n\n";
705 yesno(CHANGE_COMPILER,"Do you want to change the compiler?");
706 if ($config{CHANGE_COMPILER} =~ /y/i) {
707 print "What command do you want to use to invoke your compiler?\n";
708 print "[\033[1;32m$config{CC}\033[0m] -> ";
709 chomp($config{CC} = <STDIN>);
710 if ($config{CC} eq "") {
713 chomp($foo = `$config{CC} -dumpversion | cut -c 1`);
715 chomp($config{GCCVER} = `$config{CC} -dumpversion | cut -c 1`); # we must redo these if we change compilers
716 print "Queried compiler: \033[1;32m$config{CC}\033[0m (version \033[1;32m$config{GCCVER}.x\033[0m)\n";
717 if ($config{GCCVER} < 3) {
718 print "\033[1;32mGCC 2.x WILL NOT WORK!\033[0m. Let's try that again, shall we?\n";
722 print "\033[1;32mWARNING!\033[0m Could not execute the compiler you specified. You may want to try again.\n";
729 # Directory Settings..
730 my $tmpbase = $config{BASE_DIR};
731 dir_check("do you wish to install the InspIRCd base", "BASE_DIR");
732 if ($tmpbase ne $config{BASE_DIR}) {
733 $config{CONFIG_DIR} = resolve_directory($config{BASE_DIR}."/conf"); # Configuration Dir
734 $config{MODULE_DIR} = resolve_directory($config{BASE_DIR}."/modules"); # Modules Directory
735 $config{BINARY_DIR} = resolve_directory($config{BASE_DIR}."/bin"); # Binary Directory
736 $config{LIBRARY_DIR} = resolve_directory($config{BASE_DIR}."/lib"); # Library Directory
739 dir_check("are the configuration files", "CONFIG_DIR");
740 dir_check("are the modules to be compiled to", "MODULE_DIR");
741 dir_check("is the IRCd binary to be placed", "BINARY_DIR");
742 dir_check("are the IRCd libraries to be placed", "LIBRARY_DIR");
745 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?");
749 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?");
753 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?");
756 $chose_hiperf = (($config{USE_EPOLL} eq "y") || ($config{USE_KQUEUE} eq "y") || ($config{USE_PORTS} eq "y"));
757 if (!$chose_hiperf) {
758 print "No high-performance socket engines are available, or you chose\n";
759 print "not to enable one. Defaulting to select() engine.\n\n";
762 yesno(IPV6,"Would you like to build InspIRCd with IPv6 support?");
765 if ($config{IPV6} eq "y") {
766 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";
767 $config{SUPPORT_IP6LINKS} = "y";
769 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)");
773 if (($config{HAS_GNUTLS} eq "y") && ($config{HAS_OPENSSL} eq "y")) {
774 print "I have detected both \033[1;32mGnuTLS\033[0m and \033[1;32mOpenSSL\033[0m on your system.\n";
775 print "I will default to GnuTLS. If you wish to use OpenSSL\n";
776 print "instead, you should enable the OpenSSL module yourself\n";
777 print "by copying it from src/modules/extra to src/modules.\n\n";
778 print "Detected GnuTLS version: \033[1;32m" . $gnutls_ver . "\033[0m\n";
779 print "Detected OpenSSL version: \033[1;32m" . $openssl_ver . "\033[0m\n\n";
782 if ($config{HAS_GNUTLS} eq "y") {
783 yesno(USE_GNUTLS, "Would you like to enable SSL Support?");
784 if ($config{USE_GNUTLS} eq "y") {
785 print "\nUsing GnuTLS SSL module.\n";
787 } elsif ($config{HAS_OPENSSL} eq "y") {
788 yesno(USE_OPENSSL, "Would you like to enable SSL Support?");
789 if ($config{USE_OPENSSL} eq "y") {
790 print "\nUsing OpenSSL SSL module.\nYou will get better performance if you move to GnuTLS in the future.\n";
794 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";
797 print "\nThe following questions will ask you for various figures relating\n";
798 print "To your IRCd install. Please note that these should usually be left\n";
799 print "as defaults unless you have a real reason to change them. If they\n";
800 print "changed, then the values must be identical on all servers on your\n";
801 print "network, or malfunctions and/or crashes may occur, with the exception\n";
802 print "of the 'maximum number of clients' setting which may be different on\n";
803 print "different servers on the network.\n\n";
805 # File Descriptor Settings..
806 promptnumeric("number of clients at any one time", "MAX_CLIENT_T");
807 $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
808 $config{MAX_DESCRIPTORS} = $config{MAX_CLIENT_T};
810 promptnumeric("length of nicknames", "NICK_LENGT");
811 promptnumeric("length of channel names", "CHAN_LENGT");
812 promptnumeric("number of mode changes in one line", "MAXI_MODES");
813 promptnumeric("length of an ident (username)", "MAX_IDENT");
814 promptnumeric("length of a quit message", "MAX_QUIT");
815 promptnumeric("length of a channel topic", "MAX_TOPIC");
816 promptnumeric("length of a kick message", "MAX_KICK");
817 promptnumeric("length of a GECOS (real name)", "MAX_GECOS");
818 promptnumeric("length of an away message", "MAX_AWAY");
823 if (($config{USE_GNUTLS} eq "y") && ($config{HAS_GNUTLS} ne "y"))
825 print "Sorry, but i couldn't detect gnutls. Make sure gnutls-config is in your path.\n";
828 if (($config{USE_OPENSSL} eq "y") && ($config{HAS_OPENSSL} ne "y"))
830 print "Sorry, but i couldn't detect openssl. Make sure openssl is in your path.\n";
834 if ($config{USE_GNUTLS} eq "y") {
836 open(TMP, "<src/modules/m_ssl_gnutls.cpp") or $failed = 1;
839 print "Symlinking src/modules/m_ssl_gnutls.cpp from extra/\n";
840 chdir("src/modules");
841 system("ln -s extra/m_ssl_gnutls.cpp");
848 open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
850 open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
853 print "SSL Certificates Not found, Generating.. \n\n
854 *************************************************************
855 * Generating the Private Key may take some time, go grab a *
856 * Coffee. Even better, to generate some more entropy if it *
857 * is taking a while, open another console and type du / a *
858 * few times and get that HD going :) Then answer the *
859 * Questions which follow. If you are unsure, just hit enter *
860 *************************************************************\n\n";
861 $failed = make_gnutls_cert();
863 print "\n\033[1;32mCertificate generation failed!\033[0m\n\n";
865 print "\nCertificate generation complete, copying to config directory... ";
866 system("mv key.pem $config{CONFIG_DIR}/key.pem");
867 system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
872 print "SSL Certificates found, skipping.\n\n";
877 print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
879 } elsif ($config{USE_OPENSSL} eq "y") {
881 open(TMP, "<src/modules/m_ssl_openssl.cpp") or $failed = 1;
884 print "Symlinking src/modules/m_ssl_openssl.cpp from extra/\n";
885 chdir("src/modules");
886 system("ln -s extra/m_ssl_openssl.cpp");
893 open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
895 open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
898 print "SSL Certificates Not found, Generating.. \n\n
899 *************************************************************
900 * Generating the certificates may take some time, go grab a *
901 * coffee, or something. *
902 *************************************************************\n\n";
904 print "\nCertificate generation complete, copying to config directory... ";
905 system("mv key.pem $config{CONFIG_DIR}/key.pem");
906 system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
907 system("mv dhparams.pem $config{CONFIG_DIR}/dhparams.pem");
910 print "SSL Certificates found, skipping.\n\n"
915 print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
918 if (($config{USE_GNUTLS} eq "n") && ($config{USE_OPENSSL} eq "n")) {
919 print "Skipping SSL Certificate generation, SSL support is not available.\n\n";
927 print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
928 if (($config{USE_GNUTLS} eq "y") || ($config{USE_OPENSSL} eq "y")) {
929 print "Please remember that to enable \033[1;32mSSL support\033[0m you must\n";
930 print "load the required modules in your config. This configure process\n";
931 print "has just prepared these modules to be compiled for you, and has not\n";
932 print "configured them to be compiled into the core of the ircd.\n";
934 print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
935 if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
936 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";
939 if ($config{GCCVER} < "3") {
941 \033[1;32mWARNING!\033[0m You are attempting to compile InspIRCd on GCC 2.x!
942 GCC 2.x series compilers only had partial (read as broken) C++ support, and
943 your compile will most likely fail horribly! If you have any problems, do NOT
944 report them to the bugtracker or forums without first upgrading your compiler
945 to a newer 3.x or 4.x (or whatever is available currently) version.
949 ################################################################################
951 ################################################################################
953 # Retrieves the .config.cache file, and loads values into the main config hash.
954 open(CACHE, ".config.cache") or return 0;
957 # Ignore Blank lines, and comments..
960 my ($key, $value) = split("=", $_, 2);
961 $value =~ /^\"(.*)\"$/;
962 # Do something with data here!
970 # Dump the contents of %config
971 print "Writing \033[1;32mcache file\033[0m for future ./configures ...\n";
972 open(FILEHANDLE, ">.config.cache");
973 foreach $key (keys %config) {
974 print FILEHANDLE "$key=\"$config{$key}\"\n";
980 my ($desc, $hash_key) = @_;
983 print "In what directory $desc?\n";
984 print "[\033[1;32m$config{$hash_key}\033[0m] -> ";
985 chomp($var = <STDIN>);
987 $var = $config{$hash_key};
989 if ($var =~ /^\~\/(.+)$/) {
990 # Convert it to a full path..
991 $var = resolve_directory($ENV{HOME} . "/" . $1);
993 elsif ((($config{OSNAME} =~ /MINGW32/i) and ($var !~ /^[A-Z]{1}:\\.*/)) and (substr($var,0,1) ne "/"))
995 # Assume relative Path was given.. fill in the rest.
996 $var = $this . "/$var";
999 $var = resolve_directory($var);
1001 print "$var does not exist. Create it?\n[\033[1;32my\033[0m] ";
1002 chomp($tmp = <STDIN>);
1003 if (($tmp eq "") || ($tmp =~ /^y/i)) {
1004 # Attempt to Create the Dir..
1006 system("mkdir -p \"$var\" >> /dev/null 2>&1");
1007 $chk = system("mkdir -p \"$var\" >> /dev/null 2>&1") / 256;
1009 print "Unable to create directory. ($var)\n\n";
1014 # They said they don't want to create, and we can't install there.
1019 if (!is_dir($var)) {
1020 # Target exists, but is not a directory.
1021 print "File $var exists, but is not a directory.\n\n";
1025 # Either Dir Exists, or was created fine.
1026 $config{$hash_key} = $var;
1034 $config{LDLIBS} = "-lstdc++";
1035 $config{FLAGS} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
1036 $config{DEVELOPER} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated -g";
1037 $SHARED = "-Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared";
1038 $config{MAKEPROG} = "make";
1040 if ($config{OSNAME} =~ /darwin/i) {
1041 $config{FLAGS} = "-DDARWIN -frtti -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
1042 $SHARED = "-bundle -twolevel_namespace -undefined dynamic_lookup";
1043 $config{LDLIBS} = "-ldl -lstdc++";
1046 if ($config{OSNAME} =~ /OpenBSD/i) {
1047 $config{MAKEPROG} = "gmake";
1048 $config{LDLIBS} = $config{LDLIBS} . " -lunwind";
1049 chomp($foo = `eg++ -dumpversion | cut -c 1`);
1050 # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
1051 # if theyre not running this, configure lets the build continue but they probably wont manage to
1052 # compile as this standard version is 2.95.3!
1054 $config{CC} = "eg++";
1055 chomp($config{GCCVER} = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change the compiler path
1060 if ($config{OSNAME} =~ /Linux/i) {
1061 $config{LDLIBS} = "-ldl -lstdc++";
1062 $config{FLAGS} = "-fno-strict-aliasing -fPIC -Wall -Woverloaded-virtual -Wno-deprecated $config{OPTIMISATI}";
1063 $config{FLAGS} .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
1064 $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
1065 $config{MAKEPROG} = "make";
1068 if ($config{OSNAME} =~ /FreeBSD/i) {
1069 $config{FLAGS} .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
1070 $config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
1073 if ($config{OSNAME} =~ /SunOS/i or $config{OSNAME} =~ /solaris/i)
1075 # solaris/sunos needs these
1076 # socket = bsd sockets api
1078 # rt = POSIX realtime extensions
1079 # resolv = inet_aton only (why isnt this in nsl?!)
1080 $config{MAKEPROG} = "gmake";
1081 $config{LDLIBS} .= " -lsocket -lnsl -lrt -lresolv";
1085 if($config{OSNAME} =~ /MINGW32/i)
1087 # All code is position-independent on windows
1088 $config{FLAGS} =~ s/-fPIC //;
1092 return $config{OSNAME};
1096 my($writeheader) = @_;
1097 # First File.. inspircd_config.h
1098 chomp(my $incos = `uname -n -s -r`);
1099 chomp($version = `sh src/version.sh`);
1100 chomp(my $revision2 = getrevision());
1101 if ($writeheader == 1)
1103 print "Writing \033[1;32minspircd_config.h\033[0m\n";
1104 open(FILEHANDLE, ">include/inspircd_config.h");
1105 my $NL = $config{NICK_LENGT}+1;
1106 my $CL = $config{CHAN_LENGT}+1;
1107 print FILEHANDLE <<EOF;
1108 /* Auto generated by configure, do not modify! */
1109 #ifndef __CONFIGURATION_AUTO__
1110 #define __CONFIGURATION_AUTO__
1112 /* this is for windows support. */
1113 #define CoreExport /**/
1114 #define DllExport /**/
1116 #define CONFIG_FILE "$config{CONFIG_DIR}/inspircd.conf"
1117 #define MOD_PATH "$config{MODULE_DIR}"
1118 #define VERSION "$version"
1119 #define REVISION "$revision2"
1120 #define MAXCLIENTS $config{MAX_CLIENT}
1121 #define MAXCLIENTS_S "$config{MAX_CLIENT}"
1122 #define SOMAXCONN_S "$config{_SOMAXCONN}"
1123 #define MAX_DESCRIPTORS $config{MAX_DESCRIPTORS}
1126 #define MAXMODES $config{MAXI_MODES}
1127 #define IDENTMAX $config{MAX_IDENT}
1128 #define MAXQUIT $config{MAX_QUIT}
1129 #define MAXTOPIC $config{MAX_TOPIC}
1130 #define MAXKICK $config{MAX_KICK}
1131 #define MAXGECOS $config{MAX_GECOS}
1132 #define MAXAWAY $config{MAX_AWAY}
1133 #define OPTIMISATION $config{OPTIMITEMP}
1134 #define LIBRARYDIR "$config{LIBRARY_DIR}"
1135 #define SYSTEM "$incos"
1137 print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
1139 if ($config{OSNAME} =~ /SunOS/i) {
1140 print FILEHANDLE "#define IS_SOLARIS\n";
1142 if ($config{OSNAME} =~ /MINGW32/i) {
1143 print FILEHANDLE "#define IS_MINGW\n";
1145 if ($config{GCCVER} >= 3) {
1146 print FILEHANDLE "#define GCC3\n";
1148 if ($config{HAS_STRLCPY} eq "true") {
1149 print FILEHANDLE "#define HAS_STRLCPY\n";
1151 if ($config{HAS_STDINT} eq "true") {
1152 print FILEHANDLE "#define HAS_STDINT\n";
1154 if ($config{IPV6} =~ /y/i) {
1155 print FILEHANDLE "#define IPV6\n";
1157 if ($config{SUPPORT_IP6LINKS} =~ /y/i) {
1158 print FILEHANDLE "#define SUPPORT_IP6LINKS\n";
1161 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1162 print FILEHANDLE "#define USE_KQUEUE\n";
1163 $se = "socketengine_kqueue";
1166 if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1167 print FILEHANDLE "#define USE_EPOLL\n";
1168 $se = "socketengine_epoll";
1171 if (($has_ports) && ($config{USE_PORTS} eq "y")) {
1172 print FILEHANDLE "#define USE_PORTS\n";
1173 $se = "socketengine_ports";
1176 # user didn't choose either epoll or select for their OS.
1177 # default them to USE_SELECT (ewwy puke puke)
1179 print FILEHANDLE "#define USE_SELECT\n";
1180 $se = "socketengine_select";
1182 print FILEHANDLE "\n#endif\n";
1188 open(FILEHANDLE, ">include/inspircd_se_config.h");
1189 print FILEHANDLE <<EOF;
1190 /* Auto generated by configure, do not modify or commit to svn! */
1191 #ifndef __CONFIGURATION_SOCKETENGINE__
1192 #define __CONFIGURATION_SOCKETENGINE__
1202 # Create a Modules List..
1204 foreach $i (@modlist)
1206 $modules .= "m_".$i.".so ";
1208 chomp($modules); # Remove Redundant whitespace..
1210 opendir(DIRHANDLE, "src/modules");
1211 foreach $name (sort readdir(DIRHANDLE)) {
1212 if ($name =~ /^m_(.+?)$/) {
1213 if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
1214 closedir(MDIRHANDLE);
1215 $modules .= "$name.so ";
1219 closedir(DIRHANDLE);
1222 # Write all .in files.
1225 my $exe = "inspircd";
1227 opendir(DIRHANDLE, $this);
1229 # Do this once here, and cache it in the .*.inc files,
1230 # rather than attempting to read src/version.sh from
1231 # compiled code -- we might not have the source to hand.
1232 # Fix for bug#177 by Brain.
1234 chomp(my $version = `sh ./src/version.sh`);
1235 chomp(my $revision = getrevision());
1236 $version = "$version(r$revision)";
1239 if ($config{IS_DARWIN} eq "YES")
1243 # We can actually parse any file starting with . and ending with .inc,
1244 # but right now we only parse .inspircd.inc to form './inspircd'
1246 foreach $name (sort readdir(DIRHANDLE)) {
1247 if ($name =~ /^\.(.+)\.inc$/) {
1250 # Bug #353, omit this on non-darwin
1251 next if (($config{OSNAME} !~ /darwin/) && ($file eq "org.inspircd.plist"));
1253 # All .name.inc files need parsing!
1255 open(FILEHANDLE, ".$file.inc");
1256 while (<FILEHANDLE>) {
1261 $tmp =~ s/\@CC\@/$config{CC}/;
1262 $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
1263 $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
1264 $tmp =~ s/\@DEVELOPER\@/$config{DEVELOPER}/;
1265 $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
1266 $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/;
1267 $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
1268 $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
1269 $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
1270 $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
1271 $tmp =~ s/\@LIBRARY_EXT\@/$LIBEXT/;
1272 $tmp =~ s/\@MODULES\@/$modules/;
1273 $tmp =~ s/\@STARTSCRIPT\@/$config{STARTSCRIPT}/;
1274 $tmp =~ s/\@DESTINATION\@/$config{DESTINATION}/;
1275 $tmp =~ s/\@EXTRA_DIR\@/$config{EXTRA_DIR}/;
1276 $tmp =~ s/\@EXECUTABLE\@/$exe/;
1277 $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
1278 $tmp =~ s/\@VERSION\@/$version/;
1280 print "Writing \033[1;32m$file\033[0m\n";
1281 open(FILEHANDLE, ">$file");
1282 print FILEHANDLE $tmp;
1285 closedir(DIRHANDLE);
1287 # Make inspircd executable!
1288 chmod 0744, 'inspircd';
1290 print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
1291 write_dynamic_makefile();
1292 write_dynamic_modules_makefile();
1295 sub write_dynamic_modules_makefile {
1296 # Modules Makefile..
1297 print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
1298 open(FILEHANDLE, ">src/modules/Makefile");
1301 # Module Makefile Header
1303 print FILEHANDLE <<EOF;
1304 ###################################################
1305 # Copyright 2002-2007 The InspIRCd Development Team
1306 # http://www.inspircd.org/wiki/index.php/Credits
1308 # Thanks to Andrew Church <achurch\@achurch.org>
1309 # for assisting with making this work right.
1311 # Automatically Generated by ./configure to add a
1312 # modules please run ./configure -modupdate
1313 ###################################################
1319 if ($config{OSNAME} =~ /darwin/) {
1320 print FILEHANDLE <<EOCHEESE;
1322 PICLDFLAGS = -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) -bundle
1326 print FILEHANDLE <<EOCHEESE;
1328 PICLDFLAGS = -fPIC -DPIC -shared \$(FLAGS)
1334 # End Module Makefile Header
1337 # Create a Modules List..
1343 foreach $i (@modlist) {
1345 # Write Entry to the MakeFile
1347 $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
1348 $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
1349 $deps = getdependencies("src/modules/m_".$i.".cpp");
1351 #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
1353 print FILEHANDLE <<EOCHEESE;
1354 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
1355 \$(CC) -pipe -I../../include \$(FLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp
1357 $crud = $crud . " install -m \$(INSTMODE) m_$i.so \$(MODPATH)\n";
1359 # End Write Entry to the MakeFile
1363 opendir(DIRHANDLE, "src/modules");
1364 foreach $name (sort readdir(DIRHANDLE)) {
1365 if ($name =~ /^m_(.+?)$/) {
1370 # A module made of multiple files, in a dir, e.g. src/modules/m_spanningtree/
1371 if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
1372 read_module_directory("src/modules/$name", $name);
1373 print "Composing Makefile rules for directory \033[1;32m$name\033[0m... (\033[1;32m$mfcount files found\033[0m)\n";
1374 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";
1375 if ($config{IS_DARWIN} eq "YES") {
1376 print FILEHANDLE " \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) $mliflags -bundle -o $name.so $mobjs\n";
1378 print FILEHANDLE " \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $mobjs\n";
1380 print FILEHANDLE "\n$mfrules\n";
1381 closedir(MDIRHANDLE);
1382 $crud = $crud . " install -m \$(INSTMODE) $name.so \$(MODPATH)\n";
1386 closedir(DIRHANDLE);
1388 print FILEHANDLE "modinst:\n \@echo \"Installing modules...\"\n" . $crud;
1391 sub read_module_directory {
1392 my ($dpath, $reldpath) = @_;
1394 if (opendir(MDIRHANDLE, $dpath) == 0) {
1398 foreach $fname (sort readdir(MDIRHANDLE)) {
1399 if ($fname =~ /\.cpp$/) {
1400 $cmflags = getcompilerflags("$dpath/$fname");
1401 $mliflags = $mliflags . " " . getlinkerflags("$dpath/$fname");
1402 $deps = getdependencies("$dpath/$fname");
1404 $oname =~ s/\.cpp$/.o/g;
1405 $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";
1406 $mfrules = $mfrules . " \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $reldpath/$oname -c $reldpath/$fname\n\n";
1407 $mobjs = $mobjs . " $reldpath/$oname";
1410 elsif ((-d "$dpath/$fname") && !($fname eq ".") && !($fname eq "..")) {
1411 read_module_directory($dpath."/".$fname, $reldpath."/".$fname);
1418 # Yes i know we could use gcc -M but it seems to ideneify a lot of 'deep'
1419 # dependencies which are not relevent in C++.
1423 open (CPP, "<$file") or die("Can't open $file for reading!");
1428 foreach my $d (@ignoredeps)
1434 foreach my $dep (@immutabledeps)
1436 $immutable = $immutable . "../include/$dep ";
1438 $immutable =~ s/ $//g;
1440 while (chomp($line = <CPP>))
1442 if ($line =~ /#include "(.+\.h)"/)
1444 if (!exists($dupe{$1}))
1446 $retlist = $retlist . "../include/$1 ";
1452 return length($immutable) ? $immutable . " " . $retlist : $retlist;
1455 sub write_dynamic_makefile {
1459 opendir(DIRHANDLE, "src/commands");
1460 foreach $name (sort readdir(DIRHANDLE)) {
1461 if ($name =~ /^cmd_(.+)\.cpp$/) {
1462 $cmdlist[$i++] = $1;
1465 closedir(DIRHANDLE);
1467 $se = "socketengine_select";
1468 if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
1469 $se = "socketengine_kqueue";
1471 elsif (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
1472 $se = "socketengine_epoll";
1474 elsif (($has_ports) && ($config{USE_PORTS} eq "y")) {
1475 $se = "socketengine_ports";
1478 $extrasources{"socketengine.cpp"} = $se . ".cpp";
1479 $extraobjects{"socketengine.cpp"} = $se . ".o";
1481 $freebsd4libs = $config{CRAQ};
1486 if ($config{IS_DARWIN} eq "YES")
1488 $libraryext = "dylib";
1489 $othercrap = " \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd.cpp\n \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o "
1494 $othercrap = " \$(CC) -pipe -I../include -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) ";
1497 foreach my $cpp (sort keys %filelist)
1499 $all = $all . $filelist{$cpp} . "." . $libraryext . " ";
1500 $all_libsonly = $all_libsonly . $filelist{$cpp} . "." . $libraryext . " ";
1502 $all = $all . "moo inspircd\n";
1504 $othercrap = $othercrap . " $all_libsonly\n\n";
1506 open(FH,">src/Makefile") or die("Could not write src/Makefile");
1509 CC = im a cheezeball
1510 CXXFLAGS = -I../include \${FLAGS}
1511 CPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* //' | grep -v svn)
1512 RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//' | grep -v svn)
1516 print FH "$all\n\n";
1518 $deps = calcdeps("src/inspircd.cpp");
1519 print FH "inspircd: inspircd.cpp $deps $all_libsonly\n";
1520 print FH "$othercrap\n";
1522 foreach my $cpp (sort keys %filelist)
1524 my $thislib = $filelist{$cpp} . "." . $libraryext;
1527 $objs =~ s/\.cpp$/.o/;
1528 if (exists($extraobjects{$cpp}))
1530 $objs = $objs . " " . $extraobjects{$cpp};
1532 if (exists($extrasources{$cpp}))
1534 $rawcpp = $rawcpp . " " . $extrasources{$cpp};
1536 if ($config{IS_DARWIN} eq "YES")
1538 $libcrap = "-install_name " . $config{LIBRARY_DIR} . "/" . $thislib . " -dynamiclib -twolevel_namespace -undefined dynamic_lookup";
1542 $libcrap = "-Wl,--rpath -Wl," . $config{LIBRARY_DIR} . " -shared";
1544 $deps = calcdeps("src/$cpp");
1545 if (exists($extrasources{$cpp}))
1547 foreach my $seperate (sort split(' ',$extrasources{$cpp}))
1549 $d = calcdeps("src/$extrasources{$cpp}") . " ";
1552 $deps = $deps . $d . " ";
1556 print FH $thislib . ": $cpp $deps ". $specialdeps{$cpp} . "\n";
1557 print FH " \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c $rawcpp\n";
1558 if (exists($extrabuildlines{$cpp}))
1560 print FH " " . $extrabuildlines{$cpp} . "\n";
1562 print FH " \$(CC) -pipe $libcrap -o " . $thislib . " " . $objs . "\n\n";
1565 print FH "moo:\n \${MAKE} -C \"commands\" DIRNAME=\"src/commands\" CC=\"\$(CC)\" \$(MAKEARGS)\n\n";
1567 # close main makefile
1570 # generate a list of .so
1571 foreach my $cmd (@cmdlist) {
1572 $cmdobjs = $cmdobjs . "cmd_$cmd.so ";
1575 # and now reopen the commands makefile
1576 open(FH,">src/commands/Makefile") or die("Could not write src/commands/Makefile");
1579 CXXFLAGS = -I../../include ${FLAGS}
1586 # now print the command file details.
1587 foreach my $cmd (@cmdlist) {
1589 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
1590 \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1591 \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o
1595 #try build a .so, no intermediate .o
1596 # \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic $SHARED -o cmd_$cmd.so
1598 #this works for sure
1599 # \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp
1600 # \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o