[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (gmake) Detecting error in call to $(shell ...)
From: |
Kannan Goundan |
Subject: |
Re: (gmake) Detecting error in call to $(shell ...) |
Date: |
15 Nov 2004 16:34:57 -0800 |
ps = Paul D. Smith
kg> CMD = $(shell find-compiler)
...
kg> file.o: file.c
kg> $(CMD) -c $<
...
kg> Can I get Make to stop processing immediately after
kg> "find-compiler" returns a non-zero exit code?
ps> You have to write it in the shell script:
ps>
ps> file.o: file.c
ps> cc=`find-compiler` || exit 1; $cc -c $<
ps>
ps> There is no way to retrieve or act on the exit code from the
ps> $shell function.
ps>
ps> You might reply that you don't want to run find-compiler for every
ps> compile, but then I would return that this is exactly what you're
ps> doing in the above makefile, since you're using "=" instead of
ps> ":=".
Hmm...I tried to make my question simple but it looks like I left out
too many details. The reason I don't want to use ":=" is that it'll
be evaluated whenever the Makefile is run (correct?). In my current
setup, I'm trying to create a thunked variable. Here's the full
Makefile:
# To create a thunked variable XYZ, create a variable XYZ_GEN that
# knows how to generate XYZ's value. It will be called only once.
MAKE_THUNK = $(eval $(1) = $$(eval $(1) := $$($(1)_GEN))$$($(1)))
MKBIN_GEN = $(shell find-mkbin)
$(call MAKE_THUNK,MKBIN)
all: a.bin b.bin
%.bin: %.txt
$(MKBIN) $< $@
I'd like to avoid changing the way "find-mkbin" behaves and avoid
creating external files (as Boris' clever solution does). In the end,
of course, I'll just have to use whatever works but I'm wondering if
anybody knows of a better way.
Thanks for the responses.