+ if ($config{OSNAME} =~ /SunOS/i) {
+ print FILEHANDLE "#define IS_SOLARIS\n";
+ }
+ if ($config{OSNAME} =~ /CYGWIN/i) {
+ print FILEHANDLE "#define IS_CYGWIN\n";
+ print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE 1024\n#endif\n";
+ }
+ if ($config{OSNAME} =~ /MINGW32/i) {
+ print FILEHANDLE "#define IS_MINGW\n";
+ }
+ if ($config{OSNAME} =~ /CYG-STATIC/i) {
+ print FILEHANDLE "#ifndef FD_SETSIZE\n#define FD_SETSIZE 1024\n#endif\n";
+ }
+ if ($config{STATIC_LINK} eq "yes") {
+ print FILEHANDLE "#define STATIC_LINK\n";
+ }
+ if ($config{GCCVER} >= 3) {
+ print FILEHANDLE "#define GCC3\n";
+ }
+ if ($config{HAS_STRLCPY} eq "true") {
+ print FILEHANDLE "#define HAS_STRLCPY\n";
+ }
+ if ($config{HAS_STDINT} eq "true") {
+ print FILEHANDLE "#define HAS_STDINT\n";
+ }
+ if ($config{IPV6} =~ /y/i) {
+ print FILEHANDLE "#define IPV6\n";
+ }
+ if ($config{SUPPORT_IP6LINKS} =~ /y/i) {
+ print FILEHANDLE "#define SUPPORT_IP6LINKS\n";
+ }
+ my $use_hiperf = 0;
+ if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
+ print FILEHANDLE "#define USE_KQUEUE\n";
+ $se = "socketengine_kqueue";
+ $use_hiperf = 1;
+ }
+ if (($has_epoll) && ($config{USE_EPOLL} eq "y")) {
+ print FILEHANDLE "#define USE_EPOLL\n";
+ $se = "socketengine_epoll";
+ $use_hiperf = 1;
+ }
+ # user didn't choose either epoll or select for their OS.
+ # default them to USE_SELECT (ewwy puke puke)
+ if (!$use_hiperf) {
+ print FILEHANDLE "#define USE_SELECT\n";
+ $se = "socketengine_select";
+ }
+ print FILEHANDLE "\n#endif\n";
+ close(FILEHANDLE);
+ }
+
+ if ($writeheader)
+ {
+ open(FILEHANDLE, ">include/inspircd_se_config.h");
+ print FILEHANDLE <<EOF;
+/* Auto generated by configure, do not modify or commit to svn! */
+#ifndef __CONFIGURATION_SOCKETENGINE__
+#define __CONFIGURATION_SOCKETENGINE__
+
+#include "$se.h"
+
+#endif
+EOF
+ close(FILEHANDLE);
+ }
+
+
+ # Create a Modules List..
+ my $modules = "";
+ foreach $i (@modlist)
+ {
+ if ($config{STATIC_LINK} eq "yes") {
+ $modules .= "m_".$i.".o ";
+ }
+ else {
+ $modules .= "m_".$i.".so ";
+ }
+ }
+ chomp($modules); # Remove Redundant whitespace..
+
+ opendir(DIRHANDLE, "src/modules");
+ foreach $name (sort readdir(DIRHANDLE)) {
+ if ($name =~ /^m_(.+?)$/) {
+ if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
+ closedir(MDIRHANDLE);
+ $modules .= "$name.so ";
+ }
+ }
+ }
+ closedir(DIRHANDLE);
+
+
+ # Write all .in files.
+ my $tmp = "";
+ my $file = "";
+ my $exe = "inspircd";
+
+ if ($config{OSNAME} =~ /CYGWIN/i) {
+ $exe = "inspircd.exe";
+ }
+
+ opendir(DIRHANDLE, $this);
+
+ # Do this once here, and cache it in the .*.inc files,
+ # rather than attempting to read src/version.sh from
+ # compiled code -- we might not have the source to hand.
+ # Fix for bug#177 by Brain.
+
+ chomp(my $version = `sh ./src/version.sh`);
+ chomp(my $revision = getrevision());
+ $version = "$version(r$revision)";
+
+ # We can actually parse any file starting with . and ending with .inc,
+ # but right now we only parse .inspircd.inc to form './inspircd'
+
+ foreach $name (sort readdir(DIRHANDLE)) {
+ if ($name =~ /^\.(.+)\.inc$/) {
+ $file = $1;
+ # All .name.inc files need parsing!
+ $tmp = "";
+ open(FILEHANDLE, ".$file.inc");
+ while (<FILEHANDLE>) {
+ $tmp .= $_;
+ }
+ close(FILEHANDLE);
+
+ $tmp =~ s/\@CC\@/$config{CC}/;
+ $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
+ $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
+ $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;
+ $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/;
+ $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/;
+ $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/;
+ $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/;
+ $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
+ $tmp =~ s/\@MODULES\@/$modules/;
+ $tmp =~ s/\@EXECUTABLE\@/$exe/;
+ $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
+ $tmp =~ s/\@STATICLIBS\@/$config{STATICLIBS}/;
+ $tmp =~ s/\@VERSION\@/$version/;
+
+ print "Writing \033[1;32m$file\033[0m\n";
+ open(FILEHANDLE, ">$file");
+ print FILEHANDLE $tmp;
+ }
+ }
+ closedir(DIRHANDLE);
+
+ # Make inspircd executable!
+ chmod 0744, 'inspircd';
+
+ if ($config{STATIC_LINK} eq "yes") {
+ print "Writing static-build \033[1;32msrc/Makefile\033[0m\n";
+ write_static_makefile();
+ write_static_modules_makefile();
+ } elsif ($config{OSNAME} =~ /CYGWIN/i) {
+ print "Writing cygwin-build \033[1;32msrc/Makefile\033[0m\n";
+ write_static_makefile();
+ write_dynamic_modules_makefile();
+ } else {
+ print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
+ write_dynamic_makefile();
+ write_dynamic_modules_makefile();
+ }
+}