+sub read_module_directory {
+ my ($dpath, $reldpath) = @_;
+
+ if (opendir(MDIRHANDLE, $dpath) == 0) {
+ return;
+ }
+
+ foreach $fname (sort readdir(MDIRHANDLE)) {
+ if ($fname =~ /\.cpp$/) {
+ $cmflags = getcompilerflags("$dpath/$fname");
+ $mliflags = $mliflags . " " . getlinkerflags("$dpath/$fname");
+ $deps = getdependencies("$dpath/$fname");
+ $oname = $fname;
+ $oname =~ s/\.cpp$/.o/g;
+ $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";
+ $mfrules = $mfrules . " \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $reldpath/$oname -c $reldpath/$fname\n\n";
+ $mobjs = $mobjs . " $reldpath/$oname";
+ $mfcount++;
+ }
+ elsif ((-d "$dpath/$fname") && !($fname eq ".") && !($fname eq "..")) {
+ read_module_directory($dpath."/".$fname, $reldpath."/".$fname);
+ }
+ }
+}
+