- foreach my $dir (("src","src/commands","src/modes","src/socketengines","src/modules"))
- {
- print "Scanning \033[1;32m$dir\033[0m for core files ";
- opendir(DIRHANDLE, $dir);
- foreach my $name (sort readdir(DIRHANDLE))
- {
- if ($name =~ /\.cpp$/)
- {
- open (CPP, "<$dir/$name") or die("Can't open $dir/$name to scan it! oh bugger");
- print ".";
- while (defined(my $line = <CPP>))
- {
- chomp($line);
- if ($line =~ /\/\* \$Core: (\w+) \*\//i)
- {
- $filelist{$name} = $1;
- }
- 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)
- {
- $extrasources{$name} = $1;
- }
- elsif ($line =~ /\/\* \$If: (\w+) \*\//i)
- {
- if (($config{$1} !~ /y/i) and ($config{$1} ne "1"))
- {
- # Skip to 'endif'
- while (defined($line = <CPP>))
- {
- chomp($line);
- 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;
- my $idir = (split(' ',$1))[1];
- my $ifile = (split(' ',$1))[0];
- $install_list = $install_list . " -install -m \$(INSTMODE) $1\n";
- $ifile =~ s/.*\///g;
- $uninstall_list = $uninstall_list . " -rm $idir/$ifile\n";
- }
+# Routine to list out the extra/ modules that have been enabled.
+# Note: when getting any filenames out and comparing, it's important to lc it if the
+# file system is not case-sensitive (== Epoc, MacOS, OS/2 (incl DOS/DJGPP), VMS, Win32
+# (incl NetWare, Symbian)). Cygwin may or may not be case-sensitive, depending on
+# configuration, however, File::Spec does not currently tell us (it assumes Unix behavior).
+sub list_extras () {
+ use File::Spec;
+ # @_ not used
+ my $srcdir = File::Spec->catdir("src", "modules");
+ my $abs_srcdir = File::Spec->rel2abs($srcdir);
+ local $_;
+ my $dd;
+ opendir $dd, File::Spec->catdir($abs_srcdir, "extra") or die (File::Spec->catdir($abs_srcdir, "extra") . ": $!\n");
+ my @extras = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
+ closedir $dd;
+ undef $dd;
+ opendir $dd, $abs_srcdir or die "$abs_srcdir: $!\n";
+ my @sources = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
+ closedir $dd;
+ undef $dd;
+ my $maxlen = (sort { $b <=> $a } (map {length($_)} (@extras)))[0];
+ my %extras = ();
+EXTRA: for my $extra (@extras) {
+ next if (File::Spec->curdir() eq $extra || File::Spec->updir() eq $extra);
+ next if ($extra eq '.svn');
+ my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
+ my $abs_source = File::Spec->catfile($abs_srcdir, $extra);
+ next unless ($extra =~ m/\.(cpp|h)$/ || (-d $abs_extra)); # C++ Source/Header, or directory
+ if (-l $abs_source) {
+ # Symlink, is it in the right place?
+ my $targ = readlink($abs_source);
+ my $abs_targ = File::Spec->rel2abs($targ, $abs_srcdir);
+ if ($abs_targ eq $abs_extra) {
+ $extras{$extra} = "\e[32;1menabled\e[0m";
+ } else {
+ $extras{$extra} = sprintf("\e[31;1mwrong symlink target (%s)\e[0m", $abs_targ);
+ }
+ } elsif (-e $abs_source) {
+ my ($devext, $inoext) = stat($abs_extra);
+ my ($devsrc, $inosrc, undef, $lnksrc) = stat($abs_source);
+ if ($lnksrc > 1) {
+ if ($devsrc == $devext && $inosrc == $inoext) {
+ $extras{$extra} = "\e[32;1menabled\e[0m";
+ } else {
+ $extras{$extra} = sprintf("\e[31;1mwrong hardlink target (%d:%d)\e[0m", $devsrc, $inosrc);
+ }
+ } else {
+ open my $extfd, "<", $abs_extra;
+ open my $srcfd, "<", $abs_source;
+ local $/ = undef;
+ if (scalar(<$extfd>) eq scalar(<$srcfd>)) {
+ $extras{$extra} = "\e[32;1menabled\e[0m";
+ } else {
+ $extras{$extra} = sprintf("\e[31;1mout of synch (re-copy)\e[0m");
+ }
+ }
+ } else {
+ $extras{$extra} = "\e[33;1mdisabled\e[0m";
+ }
+ }
+ # Now let's add dependency info
+ for my $extra (keys(%extras)) {
+ next unless $extras{$extra} =~ m/enabled/; # only process enabled extras.
+ my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
+ my @deps = split / +/, getdependencies($abs_extra);
+ for my $dep (@deps) {
+ if (exists($extras{$dep})) {
+ my $ref = \$extras{$dep}; # Take reference.
+ if ($$ref !~ m/needed by/) {
+ # First dependency found.
+ if ($$ref =~ m/enabled/) {
+ $$ref .= " (needed by \e[32;1m$extra\e[0m";
+ } else {
+ $$ref =~ s/\e\[.*?m//g; # Strip out previous coloring. Will be set in bold+red+blink later.
+ $$ref .= " (needed by \e[0;32;1;5m$extra\e[0;31;1;5m";