[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (gmake) Detecting error in call to $(shell ...)
From: |
Paul D. Smith |
Subject: |
Re: (gmake) Detecting error in call to $(shell ...) |
Date: |
30 Oct 2004 10:57:43 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
%% cakoose@yahoo.com (Kannan Goundan) writes:
kg> I have something like:
kg> CMD = $(shell find-compiler)
kg> file.o: file.c
kg> $(CMD) -c $<
kg> If the "find-compiler" command cannot find an appropriate
kg> compiler, it spits out an error message and returns a non-zero
kg> exit code. Currently, the Makefile doesn't detect that condition
kg> and will try and continue (with $CMD set to the error message
kg> string).
kg> Can I get Make to stop processing immediately after "find-compiler"
kg> returns a non-zero exit code?
You have to write it in the shell script:
file.o: file.c
cc=`find-compiler` || exit 1; $cc -c $<
There is no way to retrieve or act on the exit code from the $shell
function.
You might reply that you don't want to run find-compiler for every
compile, but then I would return that this is exactly what you're doing
in the above makefile, since you're using "=" instead of ":=".
Of course you have lots of other options such as test the value of
$(CMD) after you've assigned it with ifdef or similar to make sure it's
not the empty string. But you want to use ":=" in this case.
--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist