makefilegnu-makevxworks

rm -f and makefile


One of the many makefiles in my project shows errors in the error console when there are no files to delete even though the -f flag is being used. Here's the offending line in the makefile

-rm -f *.o

If I remove the dash at the beginning of the line, it stops dead in its tracks - so I know that this is the line that's generating the error.

This is a big project with a dozen or so makefiles. What I don't understand is that some of the others don't have this problem.

This is the embedded programming world - I'm using WindRiver 2.6 (so the rm utility is "rm.EXE", though it seems to have the usual options).

Does anyone know why an "rm -f" call would still generate an error if there's nothing to delete?


Solution

  • I'm not familiar with the WindRiver tools, but here's an educated guess based on the behavior of typical Unix shells and make tools.

    When you run rm -f *.o, the following happens:

    From the error message, it looks like your rm is broken in that it still complains when no file called *.o can be found. You can work around this by first checking whether any file matches the pattern. I must admit that I don't know how to do that in your environment.