#
###############################################################################################
-# List of commands that make up 'make install'
+# List of commands that make up 'make install' and 'make deinstall'
my $install_list = "";
+my $uninstall_list = "";
# This is a list of all files in the core. Each cpp file is mapped to a shared object file,
# whos file extension is omitted (these can vary from system to system). Auto detected by
'disable-ports' => \$opt_noports,
'disable-epoll' => \$opt_noepoll,
'disable-kqueue' => \$opt_nokqueue,
+ 'disable-rpath' => \$opt_disablerpath,
'enable-ipv6' => \$opt_ipv6,
'enable-remote-ipv6' => \$opt_ipv6links,
'disable-remote-ipv6' => \$opt_noipv6links,
sub clean
{
- system("rm -rf .config.cache");
+ unlink(".config.cache");
}
sub update
exit 0;
} else {
# We've Loaded the cache file and all our variables..
- print "Updating Files..\n";
+ print "Updating files...\n";
getosflags();
if ($opt_disable_debug == 1)
{
exit 0;
} else {
# We've Loaded the cache file and all our variables..
- print "Updating Files..\n";
+ print "Updating files...\n";
getosflags();
$has_epoll = $config{HAS_EPOLL};
$has_ports = $config{HAS_PORTS};
$config{HAS_KQUEUE} = $has_kqueue;
printf "Checking for libgnutls... ";
-if (($config{HAS_GNUTLS}) && (($config{HAS_GNUTLS} >= 1.2) || ($config{HAS_GNUTLS} eq "y"))) {
+if (($config{HAS_GNUTLS}) || ($config{HAS_GNUTLS} eq "y")) {
print "yes\n";
$config{HAS_GNUTLS} = "y";
} else {
}
printf "Checking for openssl... ";
-if (($config{HAS_OPENSSL}) && (($config{HAS_OPENSSL} >= 0.8) || ($config{HAS_OPENSSL} eq "y"))) {
+if (($config{HAS_OPENSSL}) || ($config{HAS_OPENSSL} eq "y")) {
print "yes\n";
$config{HAS_OPENSSL} = "y";
} else {
sub getosflags {
$config{LDLIBS} = "-lstdc++";
- $config{FLAGS} = "-W -pedantic -fPIC $config{OPTIMISATI}";
- $config{DEVELOPER} = "-W -pedantic -fPIC -g";
- $SHARED = "-Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared";
+ $config{FLAGS} = "-fPIC -Wall -pedantic $config{OPTIMISATI}";
+ $config{DEVELOPER} = "-fPIC -Wall -pedantic -g";
+ $SHARED = "-Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared" unless defined $opt_disablerpath;
$config{MAKEPROG} = "make";
if ($config{OSNAME} =~ /darwin/i) {
- $config{FLAGS} = "-W -pedantic -DDARWIN -frtti -fPIC $config{OPTIMISATI}";
+ $config{FLAGS} = "-DDARWIN -frtti -fPIC -Wall -pedantic $config{OPTIMISATI}";
$SHARED = "-bundle -twolevel_namespace -undefined dynamic_lookup";
$config{LDLIBS} = "-ldl -lstdc++";
}
if ($config{OSNAME} =~ /Linux/i) {
$config{LDLIBS} = "-ldl -lstdc++";
- $config{FLAGS} = "-W -pedantic -fPIC $config{OPTIMISATI}";
+ $config{FLAGS} = "-fPIC -Wall -pedantic $config{OPTIMISATI}";
$config{FLAGS} .= " " . $ENV{CXXFLAGS} if exists($ENV{CXXFLAGS});
$config{LDLIBS} .= " " . $ENV{LDLIBS} if exists($ENV{LDLIBS});
$config{MAKEPROG} = "make";
#ifndef __CONFIGURATION_SOCKETENGINE__
#define __CONFIGURATION_SOCKETENGINE__
-#include "$se.h"
+#include "socketengines/$se.h"
#endif
EOF
if (opendir(MDIRHANDLE, "src/modules/$name") != 0) {
closedir(MDIRHANDLE);
$modules .= "$name.so ";
+ $uninstall_list = $uninstall_list . " -rm \$(MODULES)/$name.so\n";
}
}
}
# We can actually parse any file starting with . and ending with .inc,
# but right now we only parse .inspircd.inc to form './inspircd'
- print "Writing dynamic-build \033[1;32msrc/Makefile\033[0m\n";
- write_dynamic_makefile();
+ print "Writing \033[1;32mMakefiles\033[0m\n";
write_dynamic_modules_makefile();
+ write_dynamic_makefile();
opendir(DIRHANDLE, $this);
$tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
$tmp =~ s/\@VERSION\@/$version/;
$tmp =~ s/\@INSTALL_LIST\@/$install_list/;
+ $tmp =~ s/\@UNINSTALL_LIST\@/$uninstall_list/;
open(FILEHANDLE, ">$file");
print FILEHANDLE $tmp;
EOF
-$nicerflags = $config{FLAGS};
-$nicerflags =~ s/\-pedantic//g;
-
if ($config{OSNAME} =~ /darwin/) {
print FILEHANDLE <<EOCHEESE;
-PICLDFLAGS = -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) -bundle
-LAMEFLAGS = $nicerflags
-LAMEPICFLAGS = -twolevel_namespace -undefined dynamic_lookup $nicerflags -bundle
+PICLDFLAGS = -twolevel_namespace -undefined dynamic_lookup -bundle
EOCHEESE
} else {
print FILEHANDLE <<EOCHEESE;
-PICLDFLAGS = -fPIC -DPIC -shared \$(FLAGS)
-LAMEFLAGS = $nicerflags
-LAMEPICFLAGS = -fPIC -DPIC -shared $nicerflags
+PICLDFLAGS = -fPIC -DPIC -shared
EOCHEESE
}
my $modules = "";
my $cmflags = "";
my $liflags = "";
- my $crud = "";
-
foreach $i (@modlist) {
###
# Write Entry to the MakeFile
$cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
$liflags = getlinkerflags("src/modules/m_".$i.".cpp");
$deps = getdependencies("src/modules/m_".$i.".cpp");
+
+ #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
+
+
+ $nicerflags = $config{FLAGS};
+ $nicerflags =~ s/-pedantic//g;
if (nopedantic("src/modules/m_".$i.".cpp"))
{
- $fl = "\$(LAMEFLAGS)";
- $pfl = "\$(LAMEPICFLAGS)";
+ print FILEHANDLE "
+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
+ \$(CC) -pipe -I../../include $nicerflags $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp
+"
}
else
{
- $fl = "\$(FLAGS)";
- $pfl = "\$(PICFLAGS)";
- }
-
- #print "file: $i: cmflags=$cmflags; liflags=$liflags; deps=$deps\n";
-
- print FILEHANDLE <<EOCHEESE;
+ print FILEHANDLE "
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
- \$(CC) -pipe -I../../include $fl $cmflags $pfl $liflags -export-dynamic -o m_$i.so m_$i.cpp
-EOCHEESE
- $crud = $crud . " install -m \$(INSTMODE) m_$i.so \$(MODPATH)\n";
+ \$(CC) -pipe -I../../include \$(FLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp
+";
+ }
+ $install_list = $install_list . " install -m \$(INSTMODE) src/modules/m_$i.so \$(MODPATH)\n";
+ $uninstall_list = $uninstall_list . " -rm \$(MODULES)/m_$i.so\n";
###
# End Write Entry to the MakeFile
###
print "Composing Makefile rules for directory \033[1;32m$name\033[0m... (\033[1;32m$mfcount files found\033[0m)\n";
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";
if ($config{IS_DARWIN} eq "YES") {
- print FILEHANDLE " \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup $fl $mliflags -bundle -o $name.so $mobjs\n";
+ print FILEHANDLE " \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) $mliflags -bundle -o $name.so $mobjs\n";
} else {
- print FILEHANDLE " \$(CC) -pipe $fl -shared $mliflags -o $name.so $mobjs\n";
+ print FILEHANDLE " \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $mobjs\n";
}
print FILEHANDLE "\n$mfrules\n";
closedir(MDIRHANDLE);
- $crud = $crud . " install -m \$(INSTMODE) $name.so \$(MODPATH)\n";
+ $install_list = $install_list . " install -m \$(INSTMODE) src/modules/$name.so \$(MODPATH)\n";
}
}
}
closedir(DIRHANDLE);
-
- print FILEHANDLE "modinst:\n \@echo \"Installing modules...\"\n" . $crud;
}
sub read_module_directory {
{
my $i = 0;
my @cmdlist = ();
+ my %existing_install_list = ();
opendir(DIRHANDLE, "src/commands");
foreach $name (sort readdir(DIRHANDLE))
{
if ($name =~ /^cmd_(.+)\.cpp$/)
{
$cmdlist[$i++] = $1;
- $install_list = $install_list . " -install -m \$(INSTMODE) src/commands/cmd_" . $1 . ".so \$(LIBPATH)\n";
+ $install_list = $install_list . " -install -m \$(INSTMODE) src/commands/cmd_" . $1 . ".so \$(LIBPATH)\n";
+ $uninstall_list = $uninstall_list . " -rm \$(LIBPATH)/cmd_$1.so\n";
}
}
closedir(DIRHANDLE);
$config{USE_PORTS} = 0;
}
- print "Scanning src folder for core files";
- opendir(DIRHANDLE, "src");
- foreach $name (sort readdir(DIRHANDLE))
+ foreach my $dir (("src","src/commands","src/modes","src/socketengines","src/modules"))
{
- if ($name =~ /\.cpp$/)
+ print "Scanning \033[1;32m$dir\033[0m for core files ";
+ opendir(DIRHANDLE, $dir);
+ foreach $name (sort readdir(DIRHANDLE))
{
- open (CPP, "<src/$name") or die("Can't open src/$name to scan it! oh bugger");
- while (chomp($line = <CPP>))
+ if ($name =~ /\.cpp$/)
{
- if ($line =~ /\/\* \$Core: (\w+) \*\//i)
- {
- $filelist{$name} = $1;
- print ".";
- }
- elsif ($line =~ /\/\* \$ExtraDeps: (.*?) \*\//i)
- {
- $specialdeps{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraObjects: (.*?) \*\//i)
- {
- $extraobjects{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraBuild: (.*?) \*\//i)
- {
- $extrabuildlines{$name} = $1;
- }
- elsif ($line =~ /\/\* \$ExtraSources: (.*?) \*\//i)
+ open (CPP, "<$dir/$name") or die("Can't open $dir/$name to scan it! oh bugger");
+ print ".";
+ while (chomp($line = <CPP>))
{
- $extrasources{$name} = $1;
- }
- elsif ($line =~ /\/\* \$If: (\w+) \*\//i)
- {
- if (($config{$1} !~ /y/i) and ($config{$1} ne "1"))
+ if ($line =~ /\/\* \$Core: (\w+) \*\//i)
+ {
+ $filelist{$name} = $1;
+ }
+ elsif ($line =~ /\/\* \$ExtraDeps: (.*?) \*\//i)
{
- # Skip to 'endif'
- while (chomp($line = <CPP>))
+ $specialdeps{$name} = $1;
+ }
+ elsif ($line =~ /\/\* \$ExtraObjects: (.*?) \*\//i)
+ {
+ $extraobjects{$name} = $1;
+ }
+ elsif ($line =~ /\/\* \$ExtraBuild: (.*?) \*\//i)
+ {
+ $extrabuildlines{$name} = $1;
+ }
+ elsif ($line =~ /\/\* \$ExtraSources: (.*?) \*\//i)
+ {
+ $extrasources{$name} = $1;
+ }
+ elsif ($line =~ /\/\* \$If: (\w+) \*\//i)
+ {
+ if (($config{$1} !~ /y/i) and ($config{$1} ne "1"))
{
- die ("\$If buildsystem instruction within another \$If in file src/$name") if ($line =~ /\/\* \$If: (\w+) \*\//i);
- last if ($line =~ /\/\* \$EndIf \*\//i);
+ # Skip to 'endif'
+ while (chomp($line = <CPP>))
+ {
+ die ("\$If buildsystem instruction within another \$If in file $dir/$name") if ($line =~ /\/\* \$If: (\w+) \*\//i);
+ last if ($line =~ /\/\* \$EndIf \*\//i);
+ }
+ }
+ }
+ elsif ($line =~ /\/\* \$Install: (.*?) \*\//i)
+ {
+ if (!exists($existing_install_list{$1}))
+ {
+ $existing_install_list{$1} = 1;
+ $idir = (split(' ',$1))[1];
+ $ifile = (split(' ',$1))[0];
+ $install_list = $install_list . " -install -m \$(INSTMODE) $1\n";
+ $ifile =~ s/.*\///g;
+ $uninstall_list = $uninstall_list . " -rm $idir/$ifile\n";
+ }
+ }
+ elsif ($line =~ /\/\* \$CopyInstall: (.*?) \*\//i)
+ {
+ if (!exists($existing_install_list{$1}))
+ {
+ $existing_install_list{$1} = 1;
+ $idir = (split(' ',$1))[1];
+ $ifile = (split(' ',$1))[0];
+ $install_list = $install_list . " -cp $1\n";
+ $ifile =~ s/.*\///g;
+ $uninstall_list = $uninstall_list . " -rm $idir/$ifile\n";
}
}
}
+ close CPP;
}
- close CPP;
}
+ closedir(DIRHANDLE);
+ print " done!\n";
}
- closedir(DIRHANDLE);
- print " done!\n";
$freebsd4libs = $config{CRAQ};
else
{
$libraryext = "so";
- $othercrap = " \$(CC) -pipe -I../include -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) ";
+ $RPATH = "-Wl,--rpath -Wl,$config{LIBRARY_DIR}" unless defined $opt_disablerpath;
+ $othercrap = " \$(CC) -pipe -I../include $RPATH \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) ";
}
foreach my $cpp (sort keys %filelist)
$all = $all . $filelist{$cpp} . "." . $libraryext . " ";
$all_libsonly = $all_libsonly . $filelist{$cpp} . "." . $libraryext . " ";
$install_list = $install_list . " -install -m \$(INSTMODE) src/" . $filelist{$cpp} . "." . $libraryext . " \$(LIBPATH)\n";
+ $uninstall_list = $uninstall_list . " -rm \$(LIBPATH)/" . $filelist{$cpp} . "." . $libraryext . "\n";
}
$all = $all . "moo inspircd\n";
}
else
{
- $libcrap = "-Wl,--rpath -Wl," . $config{LIBRARY_DIR} . " -shared";
+ if (defined $opt_disablerpath)
+ {
+ $libcrap = " -shared";
+ }
+ else
+ {
+ $libcrap = "-Wl,--rpath -Wl," . $config{LIBRARY_DIR} . " -shared";
+ }
}
$deps = calcdeps("src/$cpp");
if (exists($extrasources{$cpp}))