-sub write_root_files {
- # Create a Modules List..
- my $modules = "";
- foreach my $i (@modlist)
- {
- $modules .= "m_".$i.".so ";
- }
- chomp($modules); # Remove Redundant whitespace..
-
- opendir(DIRHANDLE, "src/modules");
- foreach my $name (sort readdir(DIRHANDLE)) {
- if ($name =~ /^m_(.+?)$/) {
- if (defined(opendir(MDIRHANDLE, "src/modules/$name"))) {
- closedir(MDIRHANDLE);
- $modules .= "$name.so ";
- $uninstall_list = $uninstall_list . " -rm \$(MODULES)/$name.so\n";
- }
- }
- }
- closedir(DIRHANDLE);
-
- # Write all .in files.
- my $exe = "inspircd";
-
- # 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'
-
- opendir(DIRHANDLE, $this);
-
- foreach my $name (sort readdir(DIRHANDLE)) {
- if ($name =~ /^\.(.+)\.inc$/) {
- my $file = $1;
-
- # Bug #353, omit this on non-darwin
- next if (($config{OSNAME} !~ /darwin/) && ($file eq "org.inspircd.plist"));
-
- # All .name.inc files need parsing!
- my $tmp = "";
- open(FILEHANDLE, ".$file.inc") or die ("Can't open .$file.inc");
- while (<FILEHANDLE>) {
- $tmp .= $_;
- }
- close(FILEHANDLE);
-
- print "Writing \e[1;32m$file\e[0m ...\n";
- $tmp =~ s/\@CC\@/$config{CC}/ if defined $config{CC};
- $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/ if defined $config{MAKEPROG};
- $tmp =~ s/\@FLAGS\@/$config{FLAGS}/ if defined $config{FLAGS};
- $tmp =~ s/\@DEVELOPER\@/$config{DEVELOPER}/ if defined $config{DEVELOPER};
- $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/ if defined $config{LDLIBS};
- $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/ if defined $config{BASE_DIR};
- $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/ if defined $config{CONFIG_DIR};
- $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/ if defined $config{MODULE_DIR};
- $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/ if defined $config{BINARY_DIR};
- $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/ if defined $config{LIBRARY_DIR};
- $tmp =~ s/\@MODULES\@/$modules/ if defined $modules;
- $tmp =~ s/\@STARTSCRIPT\@/$config{STARTSCRIPT}/ if defined $config{STARTSCRIPT};
- $tmp =~ s/\@DESTINATION\@/$config{DESTINATION}/ if defined $config{DESTINATION};
- $tmp =~ s/\@EXTRA_DIR\@/$config{EXTRA_DIR}/ if defined $config{EXTRA_DIR};
- $tmp =~ s/\@EXECUTABLE\@/$exe/ if defined $exe;
- $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/ if defined $config{MAKEORDER};
- $tmp =~ s/\@VERSION\@/$version/ if defined $version;
- $tmp =~ s/\@INSTALL_LIST\@/$install_list/ if defined $install_list;
- $tmp =~ s/\@UNINSTALL_LIST\@/$uninstall_list/ if defined $uninstall_list;
-
- open(FILEHANDLE, ">$file");
- print FILEHANDLE $tmp;
- }
- }
- closedir(DIRHANDLE);
-
- # Make inspircd executable!
- chmod 0744, 'inspircd';
-
-}
-