diff -d --strip-trailing-cr --ignore-tab-expansion -x '*.obj' -x '*.exe' -x '*.swp' -x '*.map' -x win32.mak -rpu origDMD/import.c dmd/import.c
--- origDMD/import.c	2009-05-11 15:57:22 +0200
+++ dmd/import.c	2009-07-01 18:39:04 +0200
@@ -112,6 +112,27 @@ void Import::load(Scope *sc)
 }
 
 
+char* escapePath(char* fname, char* buffer, int bufLen) {
+	char* res = buffer;
+	bufLen -= 2;	// for \0 and an occasional escape char
+	int dst = 0;
+	for (; dst < bufLen && *fname; ++dst, ++fname) {
+		switch (*fname) {
+			case '(':
+			case ')':
+			case '\\':
+				buffer[dst++] = '\\';
+				// fall through
+
+			default:
+				buffer[dst] = *fname;
+		}
+	}
+	buffer[dst] = '\0';
+	return buffer;
+}
+
+
 void Import::semantic(Scope *sc)
 {
     //printf("Import::semantic('%s')\n", toChars());
@@ -162,6 +183,67 @@ void Import::semantic(Scope *sc)
 	sc = sc->pop();
     }
     //printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
+
+	if (global.params.moduleDeps != NULL) {
+		char fnameBuf[262];		// MAX_PATH+2
+
+		OutBuffer *const ob = global.params.moduleDeps;
+		ob->printf("%s (%s) : ",
+				sc->module->toPrettyChars(),
+				escapePath(sc->module->srcfile->toChars(), fnameBuf, sizeof(fnameBuf) / sizeof(*fnameBuf))
+		);
+
+		char* protStr = "";
+		switch (sc->protection) {
+			case PROTpublic: protStr = "public"; break;
+			case PROTprivate: protStr = "private"; break;
+			case PROTpackage: protStr = "package"; break;
+			default: break;
+		}
+		ob->writestring(protStr);
+		if (isstatic) {
+			ob->writestring(" static");
+		}
+		ob->writestring(" : ");
+
+		if (this->packages) {
+		    for (size_t i = 0; i < this->packages->dim; i++) {
+				Identifier *pid = (Identifier *)this->packages->data[i];
+				ob->printf("%s.", pid->toChars());
+		    }
+		}
+
+		ob->printf("%s (%s)",
+				this->id->toChars(),
+				mod ? escapePath(mod->srcfile->toChars(), fnameBuf, sizeof(fnameBuf) / sizeof(*fnameBuf)) : "???"
+		);
+
+		if (names.dim > 0) {
+			ob->writestring(" : ");
+			for (size_t i = 0; i < names.dim; i++)
+			{
+				if (i > 0) {
+					ob->writebyte(',');
+				}
+
+				Identifier *name = (Identifier *)names.data[i];
+				Identifier *alias = (Identifier *)aliases.data[i];
+
+				if (!alias) {
+					ob->printf("%s", name->toChars());
+					alias = name;
+				} else {
+					ob->printf("%s=%s", alias->toChars(), name->toChars());
+				}
+			}
+		}
+	
+	    if (aliasId) {
+			ob->printf(" -> %s", aliasId->toChars());
+		}
+
+		ob->writenl();
+	}
 }
 
 void Import::semantic2(Scope *sc)
diff -d --strip-trailing-cr --ignore-tab-expansion -x '*.obj' -x '*.exe' -x '*.swp' -x '*.map' -x win32.mak -rpu origDMD/mars.c dmd/mars.c
--- origDMD/mars.c	2009-05-11 15:57:22 +0200
+++ dmd/mars.c	2009-07-01 18:05:00 +0200
@@ -215,6 +215,7 @@ Usage:\n\
   -debug=ident   compile in debug code identified by ident\n\
   -debuglib=name    set symbolic debug library to name\n\
   -defaultlib=name  set default library to name\n\
+  -deps=filename write module dependencies to filename\n\
   -g             add symbolic debug info\n\
   -gc            add symbolic debug info, pretend to be C\n\
   -H             generate 'header' file\n\
@@ -295,6 +296,9 @@ int main(int argc, char *argv[])
     global.params.objfiles = new Array();
     global.params.ddocfiles = new Array();
 
+	global.params.moduleDeps = NULL;
+	global.params.moduleDepsFile = NULL;
+
 #if TARGET_WINDOS
     global.params.defaultlibname = "phobos";
 #elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
@@ -596,6 +600,11 @@ int main(int argc, char *argv[])
 		setdebuglib = 1;
 		global.params.debuglibname = p + 1 + 9;
 	    }
+	    else if (memcmp(p + 1, "deps=", 5) == 0)
+	    {
+		global.params.moduleDepsFile = p + 1 + 5;
+		global.params.moduleDeps = new OutBuffer;
+	    }
 	    else if (memcmp(p + 1, "man", 3) == 0)
 	    {
 #if _WIN32
@@ -1062,6 +1071,15 @@ int main(int argc, char *argv[])
     if (global.errors)
 	fatal();
 
+	if (global.params.moduleDeps != NULL) {
+		assert (global.params.moduleDepsFile != NULL);
+
+		File deps(global.params.moduleDepsFile);
+		OutBuffer* ob = global.params.moduleDeps;
+		deps.setbuffer((void*)ob->data, ob->offset);
+		deps.write();
+	}
+
     // Scan for functions to inline
     if (global.params.useInline)
     {
diff -d --strip-trailing-cr --ignore-tab-expansion -x '*.obj' -x '*.exe' -x '*.swp' -x '*.map' -x win32.mak -rpu origDMD/mars.h dmd/mars.h
--- origDMD/mars.h	2009-05-11 15:57:22 +0200
+++ dmd/mars.h	2009-07-01 18:05:00 +0200
@@ -106,6 +106,7 @@ the target object file format:
 
 
 struct Array;
+struct OutBuffer;
 
 // Put command line switches in here
 struct Param
@@ -176,6 +177,9 @@ struct Param
 
     const char *xmlname;	// filename for XML output
 
+	OutBuffer *moduleDeps;
+	char *moduleDepsFile;
+
     // Hidden debug switches
     char debuga;
     char debugb;
