I reported a bug for my distro last year but I recently found some time to look at it again and I finally solved the problem.
Original bug report: http://bugs.gentoo.org/show_bug.cgi?id=170108
Depbuild uses the STL facility (cout) to output parts of the depfile. It also uses system() to pass the output of nasm to its own stdout. Unfortunately this causes problems sometimes. On my system depbuild works perfectly on a terminal but fails silently when output is redirected (for example when called from the Makefile). The Makefile then usually terminates because of a syntax error in makefile.dep. The content is there but nasm output is randomly interleaved with depbuild "cout" output.
I don't know how widespread is the problem.
I wrote a patch to fix this:
Code: Select all
--- depbuild.cpp.old 2008-10-08 21:58:01.000000000 +0200
+++ depbuild.cpp.new 2008-10-08 21:59:04.000000000 +0200
@@ -131,7 +131,15 @@
void dependency_calculate_asm(const char *filename)
{
string command = nasm + " " + nflags + " -M " + filename;
- system(command.c_str());
+ FILE *fp = popen(command.c_str(), "r");
+ if (fp)
+ {
+ char line[256];
+ while (fgets(line, sizeof(line), fp)) //Process all lines of output
+ {
+ cout << line;
+ }
+ }
}
I also wrote a shell script that does the same work of depbuild. I did that because I couldn't really understand all that code and I didn't think the solution would be so simple. But I can send it to anyone who's interested. Drop me a line if you need it.
Thanks.