bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange problem with 'echo' target


From: Paul D. Smith
Subject: Re: strange problem with 'echo' target
Date: Fri, 15 Dec 2000 17:07:13 -0500

%% Regarding strange problem with 'echo' target; you wrote:

  ss> I'm experiencing a strange problem with make, which I can't
  ss> narrow down. What happens is that I have an 'echo' executable
  ss> in the local directory, which gets executed whenever I call
  ss> 'make echo'.

Please always remember to include the version of GNU make that you're
using, and the kind and version of OS you're running it on.

  ss>   Must remake target `echo.o'.
  ss> hello world

  ss> where the 'hello world' line is the actual output from my 'echo'
  ss> script (which I created for the purpose of this test. Note that I
  ss> don't have any 'echo' target in my Makefile. However, I have this:

"echo" is a singularly poor choice of name.

  ss> %.o:              $(srcdir)/%.cc
  ss>           @echo compiling $(@F)
  ss>           $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@

Well, the first command line above invokes "echo compiling $(@F)".

If "." is on your PATH before /bin or /usr/bin, then the "echo" in the
current directory will be found first, and invoked.

That program prints "hello world", just as you report, and then exits
with a non-0 error code:

  ss> make: *** [echo.o] Error 255

255 (or -1) in this case.  Make sees that the echo command failed and so
it doesn't run the next command, the compiler.

  ss> PS: in fact, the problem I'm struggling with is that in my real
  ss>     case, I do have an 'echo' target (echo.cc -> echo.o -> echo),
  ss>     and the make process simply hangs (sleeps) once the target is
  ss>     done. (i.e. no other targets are built).

In this case, probably the target is built which then creates the "echo"
program.  The next time your makefile tries to invoke "echo", as above,
it runs the program you just built which, without any arguments or
anything, probably runs forever doing nothing, and make is running
forever waiting for it to finish doing nothing forever.


In short: pick a better name for your executable, or make sure that "."
is not on your PATH (or at least, not first on your PATH--this is very
good advice from a security standpoint anyway).

HTH.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

[Prev in Thread] Current Thread [Next in Thread]